Kailash | aad7101 | 2019-08-27 10:36:53 -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.executorNode}" |
| 24 | } |
| 25 | options { |
Andy Bavier | 5f4b2fa | 2019-10-03 07:48:49 -0700 | [diff] [blame] | 26 | timeout(time: 90, unit: 'MINUTES') |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | stages { |
| 30 | |
| 31 | stage('Repo') { |
| 32 | steps { |
| 33 | checkout(changelog: false, \ |
| 34 | poll: false, |
| 35 | scm: [$class: 'RepoScm', \ |
| 36 | manifestRepositoryUrl: "${params.manifestUrl}", \ |
| 37 | manifestBranch: "${params.manifestBranch}", \ |
| 38 | currentBranch: true, \ |
| 39 | destinationDir: 'voltha', \ |
| 40 | forceSync: true, |
| 41 | resetFirst: true, \ |
| 42 | quiet: true, \ |
| 43 | jobs: 4, \ |
| 44 | showAllChanges: true] \ |
| 45 | ) |
| 46 | } |
| 47 | } |
| 48 | stage('Patch') { |
| 49 | steps { |
| 50 | sh """ |
| 51 | pushd voltha |
| 52 | PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml) |
| 53 | repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}" |
| 54 | popd |
| 55 | """ |
| 56 | } |
| 57 | } |
| 58 | stage('Create K8s Cluster') { |
| 59 | steps { |
| 60 | sh """ |
| 61 | git clone https://gerrit.opencord.org/voltha-system-tests |
| 62 | git clone https://github.com/ciena/kind-voltha.git |
| 63 | cd kind-voltha/ |
Kailash | 9eac273 | 2019-09-03 18:05:48 -0700 | [diff] [blame] | 64 | DEPLOY_K8S=y JUST_K8S=y FANCY=0 ./voltha up |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 65 | """ |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | stage('Build Images') { |
| 70 | steps { |
| 71 | sh """ |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 72 | if [ "${gerritProject}" != "voltha-helm-charts" ]; then |
| 73 | cd $WORKSPACE/voltha/${gerritProject}/ |
| 74 | make DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build |
| 75 | fi |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 76 | """ |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | stage('Push Images') { |
| 81 | steps { |
| 82 | sh ''' |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 83 | if [ "${gerritProject}" != "voltha-helm-charts" ]; then |
| 84 | |
| 85 | export GOROOT=/usr/local/go |
| 86 | export GOPATH=\$(pwd) |
| 87 | export TYPE=minimal |
| 88 | export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")" |
| 89 | export VOLTCONFIG="/home/jenkins/.volt/config-minimal" |
| 90 | export PATH=/w/workspace/${gerritProject}_sanity-system-test/kind-voltha/bin:$PATH |
| 91 | docker images | grep citest |
| 92 | 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 |
| 93 | fi |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 94 | ''' |
| 95 | } |
| 96 | } |
| 97 | stage('Deploy Voltha') { |
| 98 | steps { |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 99 | sh ''' |
Andy Bavier | 5f4b2fa | 2019-10-03 07:48:49 -0700 | [diff] [blame] | 100 | HELM_FLAG="--set defaults.image_tag=voltha-2.1,wpa_wait=10,dhcp_wait=10 " |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 101 | |
| 102 | if [ "${gerritProject}" = "voltha-go" ]; then |
Andy Bavier | a985757 | 2019-10-04 15:33:02 -0700 | [diff] [blame] | 103 | HELM_FLAG+="-f $WORKSPACE/voltha-system-tests/tests/data/ci-test.yaml " |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 104 | fi |
| 105 | |
| 106 | if [ "${gerritProject}" = "voltha-openolt-adapter" ]; then |
Andy Bavier | a985757 | 2019-10-04 15:33:02 -0700 | [diff] [blame] | 107 | HELM_FLAG+="--set images.adapter_open_olt.tag=citest,images.adapter_open_olt.pullPolicy=Never " |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 108 | fi |
| 109 | |
| 110 | if [ "${gerritProject}" = "voltha-openonu-adapter" ]; then |
Andy Bavier | a985757 | 2019-10-04 15:33:02 -0700 | [diff] [blame] | 111 | HELM_FLAG+="--set images.adapter_open_onu.tag=citest,images.adapter_open_onu.pullPolicy=Never " |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 112 | fi |
| 113 | |
Andy Bavier | c4183ba | 2019-09-30 15:40:18 -0700 | [diff] [blame] | 114 | if [ "${gerritProject}" = "voltha-bbsim" ]; then |
Andy Bavier | a985757 | 2019-10-04 15:33:02 -0700 | [diff] [blame] | 115 | HELM_FLAG+="--set images.bbsim.tag=citest,images.bbsim.pullPolicy=Never " |
Andy Bavier | c4183ba | 2019-09-30 15:40:18 -0700 | [diff] [blame] | 116 | fi |
| 117 | |
Scott Baker | 9ac2371 | 2019-10-02 09:26:50 -0700 | [diff] [blame] | 118 | if [ "${gerritProject}" = "voltha-api-server" ]; then |
Andy Bavier | a985757 | 2019-10-04 15:33:02 -0700 | [diff] [blame] | 119 | HELM_FLAG+="--set images.afrouter.tag=citest,images.afrouter.pullPolicy=Never,images.afrouterd.tag=citest,images.afrouterd.pullPolicy=Never " |
Zack Williams | 0499750 | 2019-10-04 14:32:20 -0700 | [diff] [blame] | 120 | else |
| 121 | # afrouter is disaggregated from the core, and lacks voltha-2.1 tags |
| 122 | HELM_FLAG+="--set images.afrouter.tag=master,images.afrouterd.tag=master " |
Scott Baker | 9ac2371 | 2019-10-02 09:26:50 -0700 | [diff] [blame] | 123 | fi |
| 124 | |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 125 | if [ "${gerritProject}" = "voltha-helm-charts" ]; then |
Andy Bavier | 4540634 | 2019-10-02 16:45:40 -0700 | [diff] [blame] | 126 | export CHART_PATH=$WORKSPACE/voltha/voltha-helm-charts |
| 127 | export VOLTHA_CHART=\$CHART_PATH/voltha |
| 128 | export VOLTHA_ADAPTER_OPEN_OLT_CHART=\$CHART_PATH/voltha-adapter-openolt |
| 129 | export VOLTHA_ADAPTER_OPEN_ONU_CHART=\$CHART_PATH/voltha-adapter-openonu |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 130 | helm dep update \$VOLTHA_CHART |
| 131 | helm dep update \$VOLTHA_ADAPTER_OPEN_OLT_CHART |
| 132 | helm dep update \$VOLTHA_ADAPTER_OPEN_ONU_CHART |
| 133 | fi |
| 134 | |
| 135 | cd $WORKSPACE/kind-voltha/ |
Kailash | da9b656 | 2019-09-03 12:48:31 -0700 | [diff] [blame] | 136 | echo \$HELM_FLAG |
Andy Bavier | 3d8d528 | 2019-10-04 16:03:49 -0700 | [diff] [blame] | 137 | EXTRA_HELM_FLAGS=\$HELM_FLAG VOLTHA_LOG_LEVEL=DEBUG TYPE=minimal WITH_RADIUS=y WITH_BBSIM=y INSTALL_ONOS_APPS=y CONFIG_SADIS=y FANCY=0 WITH_SIM_ADAPTERS=n ./voltha up |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 138 | ''' |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 139 | } |
| 140 | } |
| 141 | |
| 142 | stage('Run E2E Tests') { |
| 143 | steps { |
| 144 | sh ''' |
| 145 | cd kind-voltha/ |
| 146 | export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")" |
| 147 | export VOLTCONFIG="/home/jenkins/.volt/config-minimal" |
Kailash | eadb2e2 | 2019-09-05 10:30:06 -0700 | [diff] [blame] | 148 | export PATH=/w/workspace/${gerritProject}_sanity-system-test/kind-voltha/bin:$PATH |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 149 | cd $WORKSPACE/voltha-system-tests/tests/sanity |
Kailash | 184cbea | 2019-09-11 13:54:47 -0700 | [diff] [blame] | 150 | robot -v ONOS_REST_PORT:8181 -v ONOS_SSH_PORT:8101 -e notready --critical sanity --noncritical VOL-1705 -v num_onus:1 sanity.robot || true |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 151 | ''' |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | post { |
| 157 | always { |
| 158 | sh ''' |
Andy Bavier | 07615f9 | 2019-10-03 12:31:18 -0700 | [diff] [blame] | 159 | set +e |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 160 | # copy robot logs |
| 161 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs |
| 162 | cp -r $WORKSPACE/voltha-system-tests/tests/sanity/*ml ./RobotLogs || true |
| 163 | cd kind-voltha/ |
| 164 | cp install-minimal.log $WORKSPACE/ |
| 165 | export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")" |
| 166 | export VOLTCONFIG="/home/jenkins/.volt/config-minimal" |
Kailash | eadb2e2 | 2019-09-05 10:30:06 -0700 | [diff] [blame] | 167 | export PATH=/w/workspace/${gerritProject}_sanity-system-test/kind-voltha/bin:$PATH |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 168 | kubectl get pods --all-namespaces -o jsonpath="{..image}" |tr -s "[[:space:]]" "\n" | sort | uniq -c |
| 169 | kubectl get nodes -o wide |
| 170 | kubectl get pods -o wide |
| 171 | kubectl get pods -n voltha -o wide |
| 172 | ## get default pod logs |
| 173 | for pod in \$(kubectl get pods --no-headers | awk '{print \$1}'); |
| 174 | do |
| 175 | if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then |
| 176 | kubectl logs \$pod onos> $WORKSPACE/\$pod.log; |
| 177 | else |
| 178 | kubectl logs \$pod> $WORKSPACE/\$pod.log; |
| 179 | fi |
| 180 | done |
| 181 | ## get voltha pod logs |
| 182 | for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}'); |
| 183 | do |
| 184 | if [[ \$pod == *"-api-"* ]]; then |
| 185 | kubectl logs \$pod arouter -n voltha > $WORKSPACE/\$pod.log; |
| 186 | else |
| 187 | kubectl logs \$pod -n voltha > $WORKSPACE/\$pod.log; |
| 188 | fi |
| 189 | done |
Kailash | 2365ea8 | 2019-09-10 11:09:58 -0700 | [diff] [blame] | 190 | ## clean up node |
Andy Bavier | 3d8d528 | 2019-10-04 16:03:49 -0700 | [diff] [blame] | 191 | FANCY=0 WAIT_ON_DOWN=y ./voltha down |
Kailash | 2365ea8 | 2019-09-10 11:09:58 -0700 | [diff] [blame] | 192 | cd $WORKSPACE/ |
| 193 | rm -rf kind-voltha/ voltha-system-tests/ || true |
Kailash | aad7101 | 2019-08-27 10:36:53 -0700 | [diff] [blame] | 194 | ''' |
| 195 | step([$class: 'RobotPublisher', |
| 196 | disableArchiveOutput: false, |
| 197 | logFileName: 'RobotLogs/log*.html', |
| 198 | otherFiles: '', |
| 199 | outputFileName: 'RobotLogs/output*.xml', |
| 200 | outputPath: '.', |
| 201 | passThreshold: 80, |
| 202 | reportFileName: 'RobotLogs/report*.html', |
| 203 | unstableThreshold: 0]); |
| 204 | archiveArtifacts artifacts: '*.log' |
| 205 | |
| 206 | } |
| 207 | } |
| 208 | } |
Kailash Khalasi | af3a2a6 | 2019-10-02 09:44:08 -0700 | [diff] [blame] | 209 | |