Pavel Glazov | 040d1c6 | 2024-10-09 20:13:07 +0400 | [diff] [blame] | 1 | @Library('tcp-qa')_
|
| 2 |
|
| 3 | import groovy.xml.XmlUtil
|
| 4 |
|
| 5 | common = new com.mirantis.mk.Common()
|
| 6 | shared = new com.mirantis.system_qa.SharedPipeline()
|
| 7 |
|
| 8 | NODE_LABEL = env.NODE_LABEL ?: "sre-team-infra"
|
| 9 | MAINTENANCE_TEAM_SSH_ID = env.MAINTENANCE_TEAM_SSH_ID ?: 'maintenance-team-ssh'
|
| 10 | //IPMI_CREDS = 'lab_engineer' // base bm lab
|
| 11 | seed_ext_ip = env.SEED_EXT_IP ?: '172.16.180.2'
|
| 12 | ssh_params = "-o ConnectTimeout=20 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
| 13 | kubectl_openstack_cmd = "ssh ${ssh_params} root@${seed_ext_ip} /root/kaas-bootstrap/bin/kubectl --kubeconfig /root/child.kubeconfig -n openstack "
|
| 14 |
|
| 15 | timeout(time: 6, unit: 'HOURS') {
|
| 16 | timestamps {
|
| 17 | node ("${NODE_LABEL}") {
|
| 18 | checkout scm
|
| 19 | shared.update_working_dir()
|
| 20 | sshagent(credentials: ['maintenance-team-ssh']) {
|
| 21 | withCredentials(
|
| 22 | [[$class: 'SSHUserPrivateKeyBinding',
|
| 23 | keyFileVariable: "MAINTENANCE_TEAM_SSH_KEY",
|
| 24 | credentialsId: MAINTENANCE_TEAM_SSH_ID,
|
| 25 | usernameVariable: "MAINTENANCE_TEAM_SSH_USERNAME"]]) {
|
| 26 | stage("Delete old tempest pod") {
|
| 27 | cmd_get_service_list_wo_tempest = "${kubectl_openstack_cmd} get osdpl osh-dev -o jsonpath='{.spec.features.services}' | jq 'del(.[index(\\\"tempest\\\")])' "
|
| 28 | try {
|
| 29 | service_list_wo_tempest = sh(returnStdout: true, script: "${cmd_get_service_list_wo_tempest}").trim()
|
| 30 | sh "${kubectl_openstack_cmd} patch osdpl osh-dev --type merge -p '{\\\"spec\\\":{\\\"features\\\":{\\\"services\\\":${service_list_wo_tempest}}}}'"
|
| 31 | sleep 60
|
| 32 | }
|
| 33 | catch(Exception e) {
|
| 34 | println("Tempest not included in services (Exception: ${e}")}
|
| 35 | }
|
| 36 | stage("Tempest configuration and run") {
|
| 37 | sh "${kubectl_openstack_cmd} patch osdpl osh-dev --type merge -p '{\\\"spec\\\":{\\\"features\\\":{\\\"services\\\":[\\\"tempest\\\"]}}}'"
|
| 38 | tempest_pod_name_cmd = "ssh ${ssh_params} root@${seed_ext_ip} '/root/kaas-bootstrap/bin/kubectl --kubeconfig /root/child.kubeconfig -n openstack get pods -o custom-columns=POD:.metadata.name --no-headers | grep openstack-tempest-run-tests'"
|
| 39 | tempest_pod_name = ''
|
| 40 | while(tempest_pod_name==''){
|
| 41 | try{
|
| 42 | tempest_pod_name = sh(returnStdout: true, script: "${tempest_pod_name_cmd}").trim()
|
| 43 | } catch(Exception e) {
|
| 44 | println("Wait tempest pod start (Exception: ${e}")}
|
| 45 | sleep 30
|
| 46 | }
|
| 47 | tempest_check_cmd = "ssh ${ssh_params} root@${seed_ext_ip} '/root/kaas-bootstrap/bin/kubectl --kubeconfig /root/child.kubeconfig -n openstack get -o jsonpath=\'{.status.phase}\' pod/${tempest_pod_name}'"
|
| 48 | status = ""
|
| 49 | while (status != "Succeeded"){ //Completed
|
| 50 | status = sh(returnStdout: true, script: "${tempest_check_cmd}").trim()
|
| 51 | println("Tempest pod status is ${status}")
|
| 52 | sleep 60
|
| 53 | }
|
| 54 | } //stage tempest
|
| 55 | stage("Run archive artifacts job") {
|
| 56 | def deploy = build job: 'mosk-archive-artifacts',
|
| 57 | parameters: [
|
| 58 | string(name: 'NODE_LABEL', value: NODE_LABEL),
|
| 59 | string(name: 'MAINTENANCE_TEAM_SSH_ID', value: MAINTENANCE_TEAM_SSH_ID),
|
| 60 | string(name: 'TCP_QA_REFS', value: env.TCP_QA_REFS),
|
| 61 | string(name: 'SEED_EXT_IP', value: seed_ext_ip)
|
| 62 | ],
|
| 63 | wait: false,
|
| 64 | propagate: false
|
| 65 | }
|
| 66 | } //withCredentials
|
| 67 | } //sshagent
|
| 68 | } //node
|
| 69 | } //timestamps
|
| 70 | } //timeout |