blob: 478f790548e82cae62c2c694d16bad740c2450d1 [file] [log] [blame]
Kailashc8170bb2019-03-26 10:06:55 -07001// 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// chart-api-test-helm.groovy
16// Checks functionality of the helm-chart, without overriding the version/tag used
17
18pipeline {
19
20 /* no label, executor is determined by JJB */
21 agent {
22 label "${params.executorNode}"
23 }
24
25 stages {
26
27 stage('repo') {
28 steps {
29 checkout(changelog: false, \
30 poll: false,
31 scm: [$class: 'RepoScm', \
32 manifestRepositoryUrl: "${params.manifestUrl}", \
33 manifestBranch: "${params.manifestBranch}", \
34 currentBranch: true, \
35 destinationDir: 'cord', \
36 forceSync: true,
37 resetFirst: true, \
38 quiet: true, \
39 jobs: 4, \
40 showAllChanges: true] \
41 )
42 }
43 }
44
45 stage('minikube') {
46 steps {
47 /* see https://github.com/kubernetes/minikube/#linux-continuous-integration-without-vm-support */
48 sh '''
49 export MINIKUBE_WANTUPDATENOTIFICATION=false
50 export MINIKUBE_WANTREPORTERRORPROMPT=false
51 export CHANGE_MINIKUBE_NONE_USER=true
52 export MINIKUBE_HOME=$HOME
53 mkdir -p $HOME/.kube || true
54 touch $HOME/.kube/config
55 export KUBECONFIG=$HOME/.kube/config
56 sudo -E /usr/bin/minikube start --vm-driver=none
57 '''
58 script {
59 timeout(3) {
60 waitUntil {
61 sleep 5
62 def kc_ret = sh script: "kubectl get po", returnStatus: true
63 return (kc_ret == 0);
64 }
65 }
66 }
67 }
68 }
69
70 stage('helm') {
71 steps {
72 sh '''
73 helm init
74 sleep 60
75 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
76 '''
77 }
78 }
79
80 stage ('Build XOS Core and TestService') {
81 steps {
82 sh """
83 #!/usr/bin/env bash
84 set -eu -o pipefail
85
86 sudo service docker restart
87 cd $WORKSPACE/cord/orchestration/xos/containers/xos
88 make build
89 cd $WORKSPACE/cord/orchestration/xos/testservice
90 docker build --no-cache -t xosproject/testservice-synchronizer:candidate -f Dockerfile.synchronizer .
91 """
92 }
93 }
94
95 stage('Install XOS w/TestService') {
96 steps {
97 sh """
98 #!/usr/bin/env bash
99 set -eu -o pipefail
100
101 pushd cord/helm-charts
102 helm dep update xos-core
103 helm install --set images.xos_core.tag=candidate,images.xos_core.pullPolicy=Never xos-core -n xos-core
104
105 git clone https://gerrit.opencord.org/helm-repo-tools
106 helm-repo-tools/wait_for_pods.sh
107
108 #install testservice
109 cd $WORKSPACE/cord/orchestration/xos/testservice
110 helm install -f testservice-devel.yaml testservice -n testservice
111 popd
112 """
113 }
114 }
115 stage('Wait for Core') {
116 steps {
117 sh """
118 #wait for xos-core and models to be loaded
119 timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/core/sites |jq '.items[0].name'|grep -q mysite; do echo 'Waiting for API To be up'; sleep 10; done"
120 """
121 }
122 }
123 stage('Test Core') {
124 steps {
125 sh """
126 #!/usr/bin/env bash
127 set -eu -o pipefail
128 pushd cord/test/cord-tester/src/test/cord-api/
129 source setup_venv.sh
130 cd Tests/xos-test-service
131 robot -e notready test-service.robot || true
132 popd
133 """
134 }
135 }
136 }
137 post {
138 always {
139 sh """
140 kubectl get pods --all-namespaces
141
142 # copy robot logs
143 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
144 cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/xos-test-service/Log/*ml ./RobotLogs
145 echo "# removing helm deployments"
146 kubectl get pods
147 helm list
148
149 for hchart in \$(helm list -q);
150 do
151 echo "## Purging chart: \${hchart} ##"
152 helm delete --purge "\${hchart}"
153 done
154
155 sudo minikube delete
156 """
157 step([$class: 'RobotPublisher',
158 disableArchiveOutput: false,
159 logFileName: 'RobotLogs/log*.html',
160 otherFiles: '',
161 outputFileName: 'RobotLogs/output*.xml',
162 outputPath: '.',
163 passThreshold: 100,
164 reportFileName: 'RobotLogs/report*.html',
165 unstableThreshold: 0]);
166 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org, teo@opennetworking.org", sendToIndividuals: false])
167
168 }
169 }
170}