updating mcord-build-test job to redeploy prior to build
Change-Id: I4dc9ef16462283e0e343e3dbb986da07cb266d84
diff --git a/jjb/cord-test/mcord-build.yaml b/jjb/cord-test/mcord-build.yaml
index f90f2ed..d448364 100644
--- a/jjb/cord-test/mcord-build.yaml
+++ b/jjb/cord-test/mcord-build.yaml
@@ -25,10 +25,26 @@
build-timeout: '{build-timeout}'
jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
parameters:
- string:
+ name: configRepoUrl
+ default: 'https://gerrit.opencord.org/pod-configs'
+ description: 'The URL of the POD configs repository'
+
+ - string:
+ name: configRepoBaseDir
+ default: 'pod-configs/'
+ description: 'The directory inside the POD configs repository'
+
+ - string:
+ name: configRepoFile
+ default: 'kubernetes-configs/flex-ocp-mcord.yml'
+ description: 'The deployment config file'
+
+ - string:
name: executorNode
- default: 'flex-ocp-mcord'
+ default: 'qa-testvm-pod'
description: 'Name of the Jenkins node to run the job on'
- string:
@@ -39,8 +55,9 @@
project-type: pipeline
concurrent: false
- dsl: !include-raw-escape: ../pipeline/mcord-deployment.groovy
+ dsl: !include-raw-escape: ../pipeline/mcord-build-test.groovy
triggers:
- - reverse:
- jobs: 'deploy-node-maas'
+ - timed: |
+ TZ=America/Los_Angeles
+ H 6 * * *
diff --git a/jjb/pipeline/mcord-build-test.groovy b/jjb/pipeline/mcord-build-test.groovy
new file mode 100644
index 0000000..635aa6a
--- /dev/null
+++ b/jjb/pipeline/mcord-build-test.groovy
@@ -0,0 +1,134 @@
+/*re-deploy node then use mcord-in-a-box.sh to deploy MCORD and then E2E TEST*/
+
+pipeline {
+
+ /* no label, executor is determined by JJB */
+ agent {
+ label "${params.executorNode}"
+ }
+
+ stages {
+
+ stage ("Parse deployment configuration file") {
+ steps {
+ sh returnStdout: true, script: 'rm -rf ${configRepoBaseDir}'
+ sh returnStdout: true, script: 'git clone -b ${branch} ${configRepoUrl}'
+ script { deployment_config = readYaml file: "${configRepoBaseDir}${configRepoFile}" }
+ }
+ }
+
+ stage ('Re-Deploy Node') {
+ steps {
+ sh "maas login maas http://${deployment_config.maas.ip}/MAAS/api/2.0 ${deployment_config.maas.api_key}"
+ sh "maas maas machine release ${deployment_config.maas.head_system_id}"
+
+ timeout(time:15) {
+ waitUntil {
+ script {
+ try {
+ sh "maas maas machine read ${deployment_config.maas.head_system_id} | grep Ready"
+ return true
+ } catch (exception) {
+ return false
+ }
+ }
+ }
+ }
+
+ sh "maas maas machines allocate"
+ sh "maas maas machine deploy ${deployment_config.maas.head_system_id}"
+
+ timeout(time:15) {
+ waitUntil {
+ script {
+ try {
+ sh "maas maas machine read ${deployment_config.maas.head_system_id} | grep Deployed"
+ return true
+ } catch (exception) {
+ return false
+ }
+ }
+ }
+ }
+ }
+ }
+ stage ('Get Node IP') {
+ steps {
+ sh "maas login maas http://${deployment_config.maas.ip}/MAAS/api/2.0 ${deployment_config.maas.api_key}"
+ timeout(time:15) {
+ waitUntil {
+ script {
+ try {
+ node_ip = sh (script: "maas maas machine read ${deployment_config.maas.head_system_id} | grep ip_address | head -n1 | grep -oE '\\b([0-9]{1,3}\\.){3}[0-9]{1,3}\\b'", returnStdout: true).toString().trim()
+ return true
+ } catch (exception) {
+ return false
+ }
+ }
+ }
+ sh "echo ${node_ip}"
+ }
+ }
+ }
+
+ stage ('Checkout Automation-Tools Repo') {
+ steps {
+ script {
+ sh (script: "ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} 'mkdir ~/cord; cd ~/cord/; git clone https://gerrit.opencord.org/automation-tools'", returnStdout: true)
+ }
+ }
+ }
+
+ stage ('Install MCORD') {
+ options {
+ timeout(time: 3, unit: 'HOURS')
+ }
+ steps {
+ script {
+ sh "sleep 120"
+ sh "ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} 'cd ~/cord/; ./automation-tools/mcord/mcord-in-a-box.sh 1>&2'"
+ }
+ }
+ }
+
+ stage ('Configure K8 Compute Node DNS') {
+ steps {
+ sh """
+ COMPUTEHOSTNAME=\$(ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} 'cat /etc/hostname')
+ IPADDRESS=\$(ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} "ip route get 8.8.8.8 | head -1 | cut -d' ' -f8")
+ cat <<EOF > /tmp/\$COMPUTEHOSTNAME-dns.yaml
+ kind: Service
+ apiVersion: v1
+ metadata:
+ name: \$COMPUTEHOSTNAME
+ namespace: default
+ spec:
+ type: ExternalName
+ externalName: \$IPADDRESS
+EOF
+ cat /tmp/\$COMPUTEHOSTNAME-dns.yaml | ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} "cat > /tmp/\$COMPUTEHOSTNAME-dns.yaml"
+ ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} "kubectl create -f /tmp/\$COMPUTEHOSTNAME-dns.yaml 1>&2"
+ """
+ }
+ }
+
+ stage ('Test MCORD') {
+ steps {
+ script {
+ sh "ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} 'cd ~/cord/; git clone https://gerrit.opencord.org/mcord; cd mcord/test; ansible-playbook -i localhost, -c local mcord-cavium-test-playbook.yml 1>&2'"
+ }
+ }
+ }
+
+ }
+
+ post {
+ always {
+ script {
+ sh (script: "ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} 'helm ls; kubectl get pods --all-namespaces 1>&2'", returnStdout: true)
+ sh (script: "ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} 'export OS_CLOUD=openstack_helm; openstack image list; openstack network list; openstack server list --all-projects 1>&2'", returnStdout: true)
+ }
+ step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
+ }
+ }
+}
diff --git a/jjb/pipeline/mcord-deployment.groovy b/jjb/pipeline/mcord-deployment.groovy
deleted file mode 100644
index 5c9eb94..0000000
--- a/jjb/pipeline/mcord-deployment.groovy
+++ /dev/null
@@ -1,79 +0,0 @@
-/* mcord-in-a-box 6.0 pipeline build and test*/
-
-pipeline {
-
- /* no label, executor is determined by JJB */
- agent {
- label "${params.executorNode}"
- }
-
- stages {
-
- stage ('Checkout Automation-Tools Repo') {
- steps {
- sh '''
- pushd $WORKSPACE
- mkdir cord
- cd cord/
- git clone https://gerrit.opencord.org/automation-tools
- popd
- '''
- }
- }
-
- stage ('Install MCORD') {
- steps {
- sh '''
- pushd $WORKSPACE/cord
- ./automation-tools/mcord/mcord-in-a-box.sh
- popd
- '''
- }
- }
- stage ('Configure K8 Compute Node DNS') {
- steps {
- sh '''
- pushd $WORKSPACE
- HOSTNAME=\$(cat /etc/hostname)
- IPADDRESS=\$(ip route get 8.8.8.8 | head -1 | cut -d' ' -f8)
- cat <<EOF > /tmp/\$HOSTNAME-dns.yaml
- kind: Service
- apiVersion: v1
- metadata:
- name: \$HOSTNAME
- namespace: default
- spec:
- type: ExternalName
- externalName: \$IPADDRESS
-EOF
- popd
- kubectl create -f /tmp/\$HOSTNAME-dns.yaml
- '''
- }
- }
-
- stage ('Test MCORD') {
- steps {
- sh '''
- pushd $WORKSPACE
- git clone https://gerrit.opencord.org/mcord
- cd mcord/test
- ansible-playbook -i localhost, -c local mcord-cavium-test-playbook.yml
- popd
- '''
- }
- }
- }
-
- post {
- always {
- sh '''
- pushd $WORKSPACE
- kubectl get pods --all-namespaces
- helm list
- popd
- '''
- step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
- }
- }
-}
diff --git a/jjb/pipeline/redeploy-node-maas.groovy b/jjb/pipeline/redeploy-node-maas.groovy
deleted file mode 100644
index fe93747..0000000
--- a/jjb/pipeline/redeploy-node-maas.groovy
+++ /dev/null
@@ -1,54 +0,0 @@
-/*re-deploy node via maas cli commands. to be used prior to mcord 6.0 build job*/
-
-pipeline {
-
- /* no label, executor is determined by JJB */
- agent {
- label "${params.executorNode}"
- }
-
- stages {
-
- stage ('Re-Deploy Node') {
- steps {
- sh "maas login maas http://${maas_ip}/MAAS/api/2.0 ${maas_api_key}"
- sh "maas maas machine release ${node_id}"
-
- timeout(time:15) {
- waitUntil {
- script {
- try {
- sh "maas maas machine read ${node_id} | grep Ready"
- return true
- } catch (exception) {
- return false
- }
- }
- }
- }
-
- sh "maas maas machines allocate"
- sh "maas maas machine deploy ${node_id}"
-
- timeout(time:15) {
- waitUntil {
- script {
- try {
- sh "maas maas machine read ${node_id} | grep Deployed"
- return true
- } catch (exception) {
- return false
- }
- }
- }
- }
- }
- }
- }
-
- post {
- always {
- step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
- }
- }
-}
diff --git a/jjb/redeploy-node-maas.yaml b/jjb/redeploy-node-maas.yaml
deleted file mode 100644
index a0c7e00..0000000
--- a/jjb/redeploy-node-maas.yaml
+++ /dev/null
@@ -1,58 +0,0 @@
----
-# Job to re-deploy a particular node on a given maas server
-# Job requires maas server api-key and node id
-
-- project:
- name: deploy-node
-
- project-name: '{name}'
-
- jobs:
- - 'deploy-node-maas'
-
-- job-template:
- id: deploy-node-maas
- name: 'deploy-node-maas'
- description: |
- Created by {id} job-template from ci-management/jjb/redeploy-node-maas.yaml
-
- properties:
- - cord-infra-properties:
- build-days-to-keep: '{build-days-to-keep}'
- artifact-num-to-keep: '{artifact-num-to-keep}'
-
- wrappers:
- - lf-infra-wrappers:
- build-timeout: '{build-timeout}'
- jenkins-ssh-credential: '{jenkins-ssh-credential}'
-
- parameters:
- - string:
- name: executorNode
- default: 'qa-testvm-pod'
- description: 'Name of the Jenkins node to run the job on. This node must have access to the maas server'
-
- - string:
- name: maas_ip
- default: ''
- description: 'IP of MAAS Server'
-
- - string:
- name: maas_api_key
- default: ''
- description: 'MAAS API Key'
-
- - string:
- name: node_id
- default: 'rrwkmn'
- description: 'Node Id of node to release acquire and deploy'
-
- - string:
- name: notificationEmail
- default: 'kailash@opennetworking.org, you@opennetworking.org, suchitra@opennetworking.org'
- description: 'List of email recipients'
-
- project-type: pipeline
- concurrent: false
-
- dsl: !include-raw-escape: pipeline/redeploy-node-maas.groovy