blob: 77da73febb719f95e5294c4e2a8a394601e807ae [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
Kailashc8170bb2019-03-26 10:06:55 -070086 cd $WORKSPACE/cord/orchestration/xos/containers/xos
87 make build
88 cd $WORKSPACE/cord/orchestration/xos/testservice
89 docker build --no-cache -t xosproject/testservice-synchronizer:candidate -f Dockerfile.synchronizer .
90 """
91 }
92 }
93
94 stage('Install XOS w/TestService') {
95 steps {
96 sh """
97 #!/usr/bin/env bash
98 set -eu -o pipefail
99
100 pushd cord/helm-charts
101 helm dep update xos-core
102 helm install --set images.xos_core.tag=candidate,images.xos_core.pullPolicy=Never xos-core -n xos-core
103
104 git clone https://gerrit.opencord.org/helm-repo-tools
105 helm-repo-tools/wait_for_pods.sh
106
107 #install testservice
Kailashfe840382019-03-26 21:11:09 -0700108 cd $WORKSPACE/cord/orchestration/xos/testservice/helm-charts
Kailashc8170bb2019-03-26 10:06:55 -0700109 helm install -f testservice-devel.yaml testservice -n testservice
110 popd
111 """
112 }
113 }
114 stage('Wait for Core') {
115 steps {
116 sh """
Kailashfe840382019-03-26 21:11:09 -0700117 #!/usr/bin/env bash
118 set -ex -o pipefail
119
Kailashc8170bb2019-03-26 10:06:55 -0700120 #wait for xos-core and models to be loaded
121 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"
122 """
123 }
124 }
125 stage('Test Core') {
126 steps {
127 sh """
128 #!/usr/bin/env bash
129 set -eu -o pipefail
130 pushd cord/test/cord-tester/src/test/cord-api/
131 source setup_venv.sh
132 cd Tests/xos-test-service
133 robot -e notready test-service.robot || true
134 popd
135 """
136 }
137 }
138 }
139 post {
140 always {
141 sh """
142 kubectl get pods --all-namespaces
143
144 # copy robot logs
145 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
Kailashfe840382019-03-26 21:11:09 -0700146 cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/xos-test-service/*ml ./RobotLogs
Kailashc8170bb2019-03-26 10:06:55 -0700147 echo "# removing helm deployments"
148 kubectl get pods
149 helm list
150
151 for hchart in \$(helm list -q);
152 do
153 echo "## Purging chart: \${hchart} ##"
154 helm delete --purge "\${hchart}"
155 done
156
157 sudo minikube delete
158 """
159 step([$class: 'RobotPublisher',
160 disableArchiveOutput: false,
161 logFileName: 'RobotLogs/log*.html',
162 otherFiles: '',
163 outputFileName: 'RobotLogs/output*.xml',
164 outputPath: '.',
165 passThreshold: 100,
166 reportFileName: 'RobotLogs/report*.html',
167 unstableThreshold: 0]);
168 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org, teo@opennetworking.org", sendToIndividuals: false])
169
170 }
171 }
172}