aboutsummaryrefslogtreecommitdiffstats
path: root/ci/build-auto.sh
diff options
context:
space:
mode:
Diffstat (limited to 'ci/build-auto.sh')
-rwxr-xr-xci/build-auto.sh158
1 files changed, 120 insertions, 38 deletions
diff --git a/ci/build-auto.sh b/ci/build-auto.sh
index 96588b9..00b67b1 100755
--- a/ci/build-auto.sh
+++ b/ci/build-auto.sh
@@ -20,10 +20,12 @@
# Usage:
# build-auto.sh job_type
-# where job_type is one of "verify", "merge", "daily"
+#
+# Parameters:
+# job_type - is one of "verify", "merge" or "daily"
#
# Example:
-# ./ci/build-auto.sh daily
+# ./ci/build-auto.sh verify
#
# exit codes
@@ -31,11 +33,21 @@
EXIT=0
EXIT_UNKNOWN_JOB_TYPE=1
EXIT_LINT_FAILED=2
+EXIT_FUEL_FAILED=10
#
# configuration
#
AUTOENV_DIR="$HOME/autoenv"
+TIMESTAMP=$(date +%Y%m%d_%H%M%S)
+LOG_DIR=$HOME/auto_ci_daily_logs
+WORKSPACE=${WORKSPACE:-$PWD}
+
+# POD and SCENARIO details used during OPNFV deployment performed by daily job
+NODE_NAME=${NODE_NAME:-"ericsson-virtual1"}
+POD_LAB=$(echo $NODE_NAME | cut -d '-' -f1)
+POD_NAME=$(echo $NODE_NAME | cut -d '-' -f2)
+DEPLOY_SCENARIO=${DEPLOY_SCENARIO:-"os-nosdn-onap-noha"}
#
# functions
@@ -47,6 +59,42 @@ function execute_auto_lint_check() {
fi
}
+# check and install required packages
+function dependencies_check() {
+ . /etc/os-release
+ if [ $ID == "ubuntu" ] ; then
+ echo "Dependencies check"
+ echo "=================="
+ # install system packages
+ for PACKAGE in "virtualenv" "pylint" "yamllint" "gnuplot" ; do
+ if dpkg -s $PACKAGE &> /dev/null ; then
+ printf " %-70s %-6s\n" $PACKAGE "OK"
+ else
+ printf " %-70s %-6s\n" $PACKAGE "missing"
+ sudo apt-get install -y $PACKAGE
+ fi
+ done
+ echo
+ fi
+}
+
+# create virtualenv if needed and enable it
+function virtualenv_prepare() {
+ if [ ! -e $AUTOENV_DIR ] ; then
+ echo "Create AUTO environment"
+ echo "======================="
+ virtualenv "$AUTOENV_DIR"
+ echo
+ fi
+
+ # activate and update virtualenv
+ echo "Update AUTO environment"
+ echo "======================="
+ source "$AUTOENV_DIR"/bin/activate
+ pip install -r ./requirements.txt
+ echo
+}
+
#
# main
#
@@ -55,20 +103,8 @@ echo
# enter workspace dir
cd $WORKSPACE
-# create virtualenv if needed
-if [ ! -e $AUTOENV_DIR ] ; then
- echo "Create AUTO environment"
- echo "======================="
- virtualenv "$AUTOENV_DIR"
- echo
-fi
-
-# activate and update virtualenv
-echo "Update AUTO environment"
-echo "======================="
-source "$AUTOENV_DIR"/bin/activate
-pip install -r ./requirements.txt
-echo
+# check if required packages are installed
+dependencies_check
# execute job based on passed parameter
case $1 in
@@ -77,15 +113,9 @@ case $1 in
echo "AUTO verify job"
echo "==============="
- # Example of verify job body. Functions can call
- # external scripts, etc.
-
+ virtualenv_prepare
execute_auto_lint_check
#execute_auto_doc_check
- #install_opnfv MCP
- #install_onap
- #execute_sanity_check
- #execute_tests $1
# Everything went well, so report SUCCESS to Jenkins
exit $EXIT
@@ -95,15 +125,9 @@ case $1 in
echo "AUTO merge job"
echo "=============="
- # Example of merge job body. Functions can call
- # external scripts, etc.
-
+ virtualenv_prepare
execute_auto_lint_check
#execute_auto_doc_check
- #install_opnfv MCP
- #install_onap
- #execute_sanity_check
- #execute_tests $1
# propagate result to the Jenkins job
exit $EXIT
@@ -112,15 +136,73 @@ case $1 in
echo "=============="
echo "AUTO daily job"
echo "=============="
+ echo
+ echo "Deployment details:"
+ echo " LAB: $POD_LAB"
+ echo " POD: $POD_NAME"
+ echo " Scenario: $DEPLOY_SCENARIO"
+ echo " WORKSPACE: $WORKSPACE"
+ echo
- # Example of daily job body. Functions can call
- # external scripts, etc.
-
- #install_opnfv MCP
- #install_onap
- #execute_sanity_check
- #execute_tests $1
- #push_results_and_logs_to_artifactory
+ # create log dir if needed
+ if [ ! -e $LOG_DIR ] ; then
+ echo "Create AUTO LOG DIRECTORY"
+ echo "========================="
+ echo "mkdir $LOG_DIR"
+ mkdir $LOG_DIR
+ echo
+ fi
+
+ echo "Installation of OPNFV and ONAP"
+ echo "=============================="
+ # clone fuel and execute installation of ONAP scenario to install
+ # ONAP on top of OPNFV deployment
+ [ -e fuel ] && rm -rf fuel
+ git clone https://gerrit.opnfv.org/gerrit/fuel
+ cd fuel
+ # Fuel master branch is currently broken; thus use stable/gambia
+ # branch with recent master version of ONAP scenario
+ git checkout stable/gambia
+ git checkout origin/master mcp/config/states/onap \
+ mcp/config/scenario/os-nosdn-onap-ha.yaml \
+ mcp/config/scenario/os-nosdn-onap-noha.yaml
+ # use larger disk size for virtual nodes
+ sed -i -re 's/(qemu-img resize.*)100G/\1400G/' mcp/scripts/lib_jump_deploy.sh
+
+ LOG_FILE="$LOG_DIR/deploy_${TIMESTAMP}.log"
+ echo "ci/deploy.sh -l $POD_LAB -p $POD_NAME -s $DEPLOY_SCENARIO |&\
+ tee $LOG_FILE"
+ DEPLOY_START=$(date +%Y%m%d_%H%M%S)
+ ci/deploy.sh -l $POD_LAB -p $POD_NAME -s $DEPLOY_SCENARIO |&\
+ tee $LOG_FILE
+
+ # report failure if fuel failed to install OPNFV or ONAP
+ [ $? -ne 0 ] && exit $EXIT_FUEL_FAILED
+
+ # process report
+ DEPLOY_END=$(date +%Y%m%d_%H%M%S)
+ REPORT_FILE="$LOG_DIR/deploy_report_${TIMESTAMP}.txt"
+ CSV_SUMMARY="$LOG_DIR/deploy_summary_${TIMESTAMP}.csv"
+ MARKER="ONAP INSTALLATION REPORT"
+ # cut report from installation log file
+ sed -n "/^$MARKER/,/^END OF $MARKER/p;/^END OF $MARKER/q" \
+ $LOG_FILE > $REPORT_FILE
+ PODS_TOTAL=$(grep "PODs Total" $REPORT_FILE | sed -e 's/[^0-9]//g')
+ PODS_FAILED=$(grep "PODs Failed" $REPORT_FILE | sed -e 's/[^0-9]//g')
+ TC_SUM=$(grep "tests total" $REPORT_FILE | tail -n1 |\
+ sed -e 's/[^0-9,]//g')
+
+ echo "Start Time,End Time,Total PODs,Failed PODs,Total Tests,Passed"\
+ "Tests,Failed Tests" >> $CSV_SUMMARY
+ echo "$DEPLOY_START,$DEPLOY_END,$PODS_TOTAL,$PODS_FAILED,$TC_SUM"\
+ >> $CSV_SUMMARY
+
+ # plot graphs from result summaries and print txt versions if possible
+ cd $WORKSPACE
+ ci/plot-results.sh
+ for GRAPH in $(ls -1 graph*txt 2> /dev/null) ; do
+ cat $GRAPH
+ done
# propagate result to the Jenkins job
exit $EXIT