aboutsummaryrefslogtreecommitdiffstats
path: root/ci/build-auto.sh
diff options
context:
space:
mode:
Diffstat (limited to 'ci/build-auto.sh')
-rwxr-xr-xci/build-auto.sh222
1 files changed, 222 insertions, 0 deletions
diff --git a/ci/build-auto.sh b/ci/build-auto.sh
new file mode 100755
index 0000000..00b67b1
--- /dev/null
+++ b/ci/build-auto.sh
@@ -0,0 +1,222 @@
+#!/bin/bash
+#
+# Copyright 2015-2018 Intel Corporation., Tieto
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# CI helper script for execution of AUTO project jenkins jobs.
+# This script is based on the file ci/build-vsperf.sh from OPNFV vswitchperf
+# project.
+
+# Usage:
+# build-auto.sh job_type
+#
+# Parameters:
+# job_type - is one of "verify", "merge" or "daily"
+#
+# Example:
+# ./ci/build-auto.sh verify
+
+#
+# exit codes
+#
+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
+#
+# execute pylint and yamllint to check code quality
+function execute_auto_lint_check() {
+ if ! ./check -b ; then
+ EXIT=$EXIT_LINT_FAILED
+ 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
+#
+echo
+
+# enter workspace dir
+cd $WORKSPACE
+
+# check if required packages are installed
+dependencies_check
+
+# execute job based on passed parameter
+case $1 in
+ "verify")
+ echo "==============="
+ echo "AUTO verify job"
+ echo "==============="
+
+ virtualenv_prepare
+ execute_auto_lint_check
+ #execute_auto_doc_check
+
+ # Everything went well, so report SUCCESS to Jenkins
+ exit $EXIT
+ ;;
+ "merge")
+ echo "=============="
+ echo "AUTO merge job"
+ echo "=============="
+
+ virtualenv_prepare
+ execute_auto_lint_check
+ #execute_auto_doc_check
+
+ # propagate result to the Jenkins job
+ exit $EXIT
+ ;;
+ "daily")
+ 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
+
+ # 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
+ ;;
+ *)
+ echo
+ echo "ERRROR: Unknown job type \"$1\""
+ echo
+ exit $EXIT_UNKNOWN_JOB_TYPE
+ ;;
+esac
+
+exit $EXIT_UNKNOWN_JOB_TYPE
+
+#
+# end
+#