Scott Baker | ff88771 | 2020-04-29 13:39:41 -0700 | [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: 90, unit: 'MINUTES') |
| 27 | } |
| 28 | environment { |
| 29 | KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal" |
| 30 | VOLTCONFIG="$HOME/.volt/config-minimal" |
| 31 | PATH="$WORKSPACE/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| 32 | TYPE="minimal" |
| 33 | FANCY=0 |
| 34 | WITH_SIM_ADAPTERS="n" |
| 35 | WITH_RADIUS="y" |
| 36 | WITH_BBSIM="y" |
| 37 | DEPLOY_K8S="y" |
| 38 | VOLTHA_LOG_LEVEL="DEBUG" |
| 39 | CONFIG_SADIS="n" |
| 40 | ROBOT_MISC_ARGS="-d $WORKSPACE/RobotLogs" |
| 41 | } |
| 42 | |
| 43 | stages { |
| 44 | |
| 45 | stage('Repo') { |
| 46 | steps { |
| 47 | step([$class: 'WsCleanup']) |
| 48 | checkout(changelog: false, \ |
| 49 | poll: false, |
| 50 | scm: [$class: 'RepoScm', \ |
| 51 | manifestRepositoryUrl: "${params.manifestUrl}", \ |
| 52 | manifestBranch: "${params.manifestBranch}", \ |
| 53 | currentBranch: true, \ |
| 54 | destinationDir: 'voltha', \ |
| 55 | forceSync: true, |
| 56 | resetFirst: true, \ |
| 57 | quiet: true, \ |
| 58 | jobs: 4, \ |
| 59 | showAllChanges: true] \ |
| 60 | ) |
| 61 | } |
| 62 | } |
| 63 | stage('Patch') { |
| 64 | steps { |
| 65 | sh """ |
| 66 | pushd voltha |
| 67 | repo download "${gerritProject}" "${gerritChangeNumber}/${gerritPatchsetNumber}" |
| 68 | popd |
| 69 | """ |
| 70 | } |
| 71 | } |
| 72 | stage('Create K8s Cluster') { |
| 73 | steps { |
| 74 | sh """ |
| 75 | git clone https://github.com/ciena/kind-voltha.git |
| 76 | cd kind-voltha/ |
| 77 | JUST_K8S=y ./voltha up |
| 78 | bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/kind-voltha/bin" |
| 79 | """ |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | stage('Build Images') { |
| 84 | steps { |
| 85 | sh """ |
| 86 | make-local () { |
| 87 | make -C $WORKSPACE/voltha/\$1 DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build |
| 88 | } |
| 89 | """ |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | stage('Push Images') { |
| 94 | steps { |
| 95 | sh ''' |
| 96 | export GOROOT=/usr/local/go |
| 97 | export GOPATH=\$(pwd) |
| 98 | docker images | grep citest |
| 99 | for image in \$(docker images -f "reference=*/*citest" --format "{{.Repository}}"); do echo "Pushing \$image to nodes"; kind load docker-image \$image:citest --name voltha-\$TYPE --nodes voltha-\$TYPE-worker,voltha-\$TYPE-worker2; done |
| 100 | ''' |
| 101 | } |
| 102 | } |
| 103 | stage('Deploy Voltha') { |
| 104 | steps { |
| 105 | sh ''' |
| 106 | export EXTRA_HELM_FLAGS="--set log_agent.enabled=False ${extraHelmFlags} " |
| 107 | |
| 108 | cd $WORKSPACE/kind-voltha/ |
| 109 | echo \$EXTRA_HELM_FLAGS |
| 110 | kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log & |
| 111 | ./voltha up |
| 112 | ''' |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | stage('Run E2E Tests') { |
| 117 | steps { |
| 118 | sh ''' |
| 119 | mkdir -p $WORKSPACE/RobotLogs |
| 120 | |
| 121 | # tell the kubernetes script to use images tagged citest and pullPolicy:Never |
| 122 | sed -i 's/master/citest/g' $WORKSPACE/voltha/device-management/kubernetes/deploy-redfish-importer.yaml |
| 123 | sed -i 's/imagePullPolicy: Always/imagePullPolicy: Never/g' $WORKSPACE/voltha/device-management/kubernetes/deploy-redfish-importer.yaml |
| 124 | make -C $WORKSPACE/voltha/device-management functional-mock-test || true |
| 125 | ''' |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | post { |
| 131 | always { |
| 132 | sh ''' |
| 133 | set +e |
| 134 | cp $WORKSPACE/kind-voltha/install-minimal.log $WORKSPACE/ |
| 135 | kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c |
| 136 | kubectl get nodes -o wide |
| 137 | kubectl get pods -o wide |
| 138 | kubectl get pods -n voltha -o wide |
| 139 | |
| 140 | sync |
| 141 | pkill kail || true |
| 142 | |
| 143 | ## Pull out errors from log files |
| 144 | extract_errors_go() { |
| 145 | echo |
| 146 | echo "Error summary for $1:" |
| 147 | grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg' |
| 148 | echo |
| 149 | } |
| 150 | |
| 151 | extract_errors_python() { |
| 152 | echo |
| 153 | echo "Error summary for $1:" |
| 154 | grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2- |
| 155 | echo |
| 156 | } |
| 157 | |
| 158 | extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log |
| 159 | extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log |
| 160 | extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log |
| 161 | extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log |
| 162 | |
| 163 | gzip $WORKSPACE/onos-voltha-combined.log |
| 164 | |
| 165 | ## shut down kind-voltha |
| 166 | cd $WORKSPACE/kind-voltha |
| 167 | WAIT_ON_DOWN=y ./voltha down |
| 168 | ''' |
| 169 | step([$class: 'RobotPublisher', |
| 170 | disableArchiveOutput: false, |
| 171 | logFileName: 'RobotLogs/log*.html', |
| 172 | otherFiles: '', |
| 173 | outputFileName: 'RobotLogs/output*.xml', |
| 174 | outputPath: '.', |
| 175 | passThreshold: 80, |
| 176 | reportFileName: 'RobotLogs/report*.html', |
| 177 | unstableThreshold: 0]); |
| 178 | archiveArtifacts artifacts: '*.log,*.gz' |
| 179 | } |
| 180 | } |
| 181 | } |