Andrea Campanella | f3c32af | 2020-12-10 12:21:57 +0100 | [diff] [blame] | 1 | // Copyright 2017-present Open Networking Foundation |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | // voltha-2.x e2e tests |
| 16 | // uses kind-voltha to deploy voltha-2.X |
| 17 | // uses bbsim to simulate OLT/ONUs |
| 18 | |
| 19 | pipeline { |
| 20 | |
| 21 | /* no label, executor is determined by JJB */ |
| 22 | agent { |
| 23 | label "${params.buildNode}" |
| 24 | } |
| 25 | options { |
| 26 | timeout(time: 190, unit: 'MINUTES') |
| 27 | } |
| 28 | environment { |
| 29 | KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal" |
| 30 | VOLTCONFIG="$HOME/.volt/config-minimal" |
| 31 | PATH="$PATH:$WORKSPACE/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| 32 | NAME="minimal" |
| 33 | FANCY=0 |
| 34 | WITH_SIM_ADAPTERS="no" |
| 35 | WITH_RADIUS="yes" |
| 36 | WITH_BBSIM="yes" |
| 37 | DEPLOY_K8S="yes" |
| 38 | VOLTHA_LOG_LEVEL="DEBUG" |
| 39 | CONFIG_SADIS="external" |
| 40 | BBSIM_CFG="configs/bbsim-sadis-att.yaml" |
| 41 | ROBOT_MISC_ARGS="-e PowerSwitch ${params.extraRobotArgs}" |
| 42 | KARAF_HOME="${params.karafHome}" |
| 43 | DIAGS_PROFILE="VOLTHA_PROFILE" |
| 44 | NUM_OF_BBSIM="${olts}" |
| 45 | } |
| 46 | stages { |
| 47 | stage('Clone kind-voltha') { |
| 48 | steps { |
| 49 | checkout([ |
| 50 | $class: 'GitSCM', |
| 51 | userRemoteConfigs: [[ |
| 52 | url: "https://gerrit.opencord.org/kind-voltha", |
| 53 | // refspec: "${kindVolthaChange}" |
| 54 | ]], |
| 55 | branches: [[ name: "master", ]], |
| 56 | extensions: [ |
| 57 | [$class: 'WipeWorkspace'], |
| 58 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"], |
| 59 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 60 | ], |
| 61 | ]) |
| 62 | } |
| 63 | } |
| 64 | stage('Cleanup') { |
| 65 | steps { |
| 66 | sh """ |
| 67 | cd $WORKSPACE/kind-voltha/ |
| 68 | WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down || ./voltha down |
| 69 | """ |
| 70 | } |
| 71 | } |
| 72 | stage('Clone voltha-system-tests') { |
| 73 | steps { |
| 74 | checkout([ |
| 75 | $class: 'GitSCM', |
| 76 | userRemoteConfigs: [[ |
| 77 | url: "https://gerrit.opencord.org/voltha-system-tests", |
| 78 | // refspec: "${volthaSystemTestsChange}" |
| 79 | ]], |
| 80 | branches: [[ name: "${branch}", ]], |
| 81 | extensions: [ |
| 82 | [$class: 'WipeWorkspace'], |
| 83 | [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"], |
| 84 | [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false], |
| 85 | ], |
| 86 | ]) |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | stage('Deploy Voltha') { |
| 91 | steps { |
| 92 | sh """ |
| 93 | export EXTRA_HELM_FLAGS="" |
| 94 | if [ "${branch}" != "master" ]; then |
| 95 | echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}" |
| 96 | source "$WORKSPACE/kind-voltha/releases/${branch}" |
| 97 | else |
| 98 | echo "on master, using default settings for kind-voltha" |
| 99 | fi |
| 100 | |
| 101 | EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${params.extraHelmFlags}" |
| 102 | |
| 103 | cd $WORKSPACE/kind-voltha/ |
| 104 | ./voltha up |
| 105 | """ |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | stage('Device Management Interface Tests') { |
| 110 | environment { |
| 111 | ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/DMITests" |
| 112 | } |
| 113 | steps { |
| 114 | sh ''' |
| 115 | set +e |
| 116 | mkdir -p $ROBOT_LOGS_DIR |
| 117 | cd $WORKSPACE/kind-voltha/scripts |
| 118 | ./log-collector.sh > /dev/null & |
| 119 | ./log-combine.sh > /dev/null & |
| 120 | |
| 121 | export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR" |
| 122 | make -C $WORKSPACE/voltha-system-tests ${makeTarget} || true |
| 123 | ''' |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | post { |
| 129 | always { |
| 130 | sh ''' |
| 131 | set +e |
| 132 | cp $WORKSPACE/kind-voltha/install-minimal.log $WORKSPACE/ |
| 133 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq |
| 134 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq |
| 135 | kubectl get nodes -o wide |
| 136 | kubectl get pods -o wide |
| 137 | kubectl get pods -n voltha -o wide |
| 138 | |
| 139 | sleep 60 # Wait for log-collector and log-combine to complete |
| 140 | |
| 141 | ## Pull out errors from log files |
| 142 | extract_errors_go() { |
| 143 | echo |
| 144 | echo "Error summary for $1:" |
| 145 | grep '"level":"error"' $WORKSPACE/kind-voltha/scripts/logger/combined/$1* |
| 146 | echo |
| 147 | } |
| 148 | |
| 149 | extract_errors_python() { |
| 150 | echo |
| 151 | echo "Error summary for $1:" |
| 152 | grep 'ERROR' $WORKSPACE/kind-voltha/scripts/logger/combined/$1* |
| 153 | echo |
| 154 | } |
| 155 | |
| 156 | extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log |
| 157 | extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log |
| 158 | extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log |
| 159 | extract_errors_go voltha-ofagent >> $WORKSPACE/error-report.log |
| 160 | extract_errors_python onos >> $WORKSPACE/error-report.log |
| 161 | |
| 162 | gzip error-report.log || true |
| 163 | |
| 164 | cd $WORKSPACE/kind-voltha/scripts/logger/combined/ |
| 165 | tar czf $WORKSPACE/container-logs.tgz * |
| 166 | |
| 167 | cd $WORKSPACE |
| 168 | gzip *-combined.log || true |
| 169 | |
| 170 | ## shut down voltha but leave kind-voltha cluster |
| 171 | cd $WORKSPACE/kind-voltha/ |
| 172 | DEPLOY_K8S=n WAIT_ON_DOWN=y ./voltha down |
| 173 | kubectl delete deployment voltctl || true |
| 174 | ''' |
| 175 | step([$class: 'RobotPublisher', |
| 176 | disableArchiveOutput: false, |
| 177 | logFileName: '**/log*.html', |
| 178 | otherFiles: '', |
| 179 | outputFileName: '**/output*.xml', |
| 180 | outputPath: 'RobotLogs', |
| 181 | passThreshold: 100, |
| 182 | reportFileName: '**/report*.html', |
| 183 | unstableThreshold: 0]); |
| 184 | |
| 185 | archiveArtifacts artifacts: '*.log,*.gz,*.tgz' |
| 186 | |
| 187 | } |
| 188 | } |
| 189 | } |