Feature 11006: make juju installation optional in community installer
[osm/devops.git] / jenkins / ci-pipelines / ci_stage_3.groovy
index bdbc175..90cd9f7 100644 (file)
@@ -31,7 +31,10 @@ properties([
         string(defaultValue: 'artifactory-osm', description: '', name: 'ARTIFACTORY_SERVER'),
         string(defaultValue: 'osm-stage_4', description: '', name: 'DOWNSTREAM_STAGE_NAME'),
         string(defaultValue: 'testing-daily', description: '', name: 'DOCKER_TAG'),
-        string(defaultValue: 'ubuntu20.04', description: '', name: 'OPENSTACK_BASE_IMAGE'),
+        string(defaultValue: 'ubuntu22.04', description: '', name: 'OPENSTACK_BASE_IMAGE'),
+        string(defaultValue: 'osm.sanity', description: '', name: 'OPENSTACK_OSM_FLAVOR'),
+        booleanParam(defaultValue: false, description: '', name: 'TRY_OLD_SERVICE_ASSURANCE'),
+        booleanParam(defaultValue: true, description: '', name: 'TRY_JUJU_INSTALLATION'),
         booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_FAIL'),
         booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_PASS'),
         booleanParam(defaultValue: true, description: '', name: 'SAVE_ARTIFACTS_ON_SMOKE_SUCCESS'),
@@ -158,9 +161,7 @@ void archive_logs(Map remote) {
     sh 'rm -rf logs'
     sshCommand remote: remote, command: '''ls -al logs'''
     sshGet remote: remote, from: 'logs', into: '.', override: true
-    sh 'cp logs/* .'
-    sh 'cp logs/dags/* .'
-    archiveArtifacts artifacts: '*.log'
+    archiveArtifacts artifacts: 'logs/*.log, logs/dags/*.log'
 }
 
 String get_value(String key, String output) {
@@ -401,7 +402,7 @@ node("${params.NODE}") {
                     println('Launching new VM')
                     output = sh(returnStdout: true, script: """#!/bin/sh -e
                         for line in `grep OS ~/hive/robot-systest.cfg | grep -v OS_CLOUD` ; do export \$line ; done
-                        openstack server create --flavor osm.sanity \
+                        openstack server create --flavor ${OPENSTACK_OSM_FLAVOR} \
                                                 --image ${OPENSTACK_BASE_IMAGE} \
                                                 --key-name CICD \
                                                 --property build_url="${BUILD_URL}" \
@@ -443,6 +444,30 @@ node("${params.NODE}") {
                         }
                     }
                     println('VM is ready and accepting ssh connections')
+
+                    //////////////////////////////////////////////////////////////////////////////////////////////
+                    println('Applying sshd config workaround for Ubuntu 22.04 and old jsch client in Jenkins...')
+
+                    sh( returnStatus: true,
+                        script: "ssh -T -i ${SSH_KEY} " +
+                            "-o StrictHostKeyChecking=no " +
+                            "-o UserKnownHostsFile=/dev/null " +
+                            "ubuntu@${IP_ADDRESS} " +
+                            "'echo HostKeyAlgorithms +ssh-rsa | sudo tee -a /etc/ssh/sshd_config'")
+                    sh( returnStatus: true,
+                        script: "ssh -T -i ${SSH_KEY} " +
+                            "-o StrictHostKeyChecking=no " +
+                            "-o UserKnownHostsFile=/dev/null " +
+                            "ubuntu@${IP_ADDRESS} " +
+                            "'echo PubkeyAcceptedKeyTypes +ssh-rsa | sudo tee -a /etc/ssh/sshd_config'")
+                    sh( returnStatus: true,
+                        script: "ssh -T -i ${SSH_KEY} " +
+                            "-o StrictHostKeyChecking=no " +
+                            "-o UserKnownHostsFile=/dev/null " +
+                            "ubuntu@${IP_ADDRESS} " +
+                            "'sudo systemctl restart sshd'")
+                    //////////////////////////////////////////////////////////////////////////////////////////////
+
                 } // stage("Spawn Remote VM")
 
 ///////////////////////////////////////////////////////////////////////////////////////
@@ -507,7 +532,7 @@ node("${params.NODE}") {
                     ]
 
                     sshCommand remote: remote, command: '''
-                        wget https://osm-download.etsi.org/ftp/osm-13.0-thirteen/install_osm.sh
+                        wget https://osm-download.etsi.org/ftp/osm-14.0-fourteen/install_osm.sh
                         chmod +x ./install_osm.sh
                         sed -i '1 i\\export PATH=/snap/bin:\$PATH' ~/.bashrc
                     '''
@@ -542,6 +567,13 @@ node("${params.NODE}") {
                         osmHostname = "nbi.${IP_ADDRESS}.nip.io:443"
                     } else {
                         // Run -k8s installer here specifying internal docker registry and docker proxy
+                        osm_installation_options = ""
+                        if (params.TRY_OLD_SERVICE_ASSURANCE) {
+                            osm_installation_options = "${osm_installation_options} --old-sa"
+                        }
+                        if (params.TRY_JUJU_INSTALLATION) {
+                            osm_installation_options = "${osm_installation_options} --juju --lxd"
+                        }
                         withCredentials([gitlabCredentialsMap]) {
                             sshCommand remote: remote, command: """
                                 ./install_osm.sh -y \
@@ -550,7 +582,8 @@ node("${params.NODE}") {
                                     ${release} -r unstable \
                                     -d ${USERNAME}:${PASSWORD}@${INTERNAL_DOCKER_REGISTRY} \
                                     -p ${INTERNAL_DOCKER_PROXY} \
-                                    -t ${containerName}
+                                    -t ${containerName} \
+                                    ${osm_installation_options}
                             """
                         }
                         prometheusHostname = IP_ADDRESS
@@ -683,24 +716,25 @@ EOF"""
                         } // stage('Snap promotion')
                         stage('Charm promotion') {
                             charms = [
-                                'osm', // bundle
-                                'osm-ha', // bundle
-                                'osm-grafana',
-                                'osm-mariadb',
-                                'mongodb-exporter-k8s',
-                                'mysqld-exporter-k8s',
-                                'osm-lcm',
-                                'osm-mon',
-                                'osm-nbi',
-                                'osm-ng-ui',
-                                'osm-pol',
-                                'osm-ro',
-                                'osm-prometheus',
-                                'osm-update-db-operator',
-                                'osm-vca-integrator',
+                                [name: 'osm',                       base: "22.04"],
+                                [name: 'osm-ha',                    base: "22.04"],
+                                [name: 'mongodb-exporter-k8s',      base: "20.04"],
+                                [name: 'mysqld-exporter-k8s',       base: "20.04"],
+                                [name: 'osm-grafana',               base: "20.04"],
+                                [name: 'osm-keystone',              base: "22.04"],
+                                [name: 'osm-lcm',                   base: "22.04"],
+                                [name: 'osm-mon',                   base: "22.04"],
+                                [name: 'osm-nbi',                   base: "22.04"],
+                                [name: 'osm-ng-ui',                 base: "22.04"],
+                                [name: 'osm-pol',                   base: "22.04"],
+                                [name: 'osm-ro',                    base: "22.04"],
+                                [name: 'osm-prometheus',            base: "20.04"],
+                                [name: 'osm-update-db-operator',    base: "20.04"],
+                                [name: 'osm-vca-integrator',        base: "22.04"],
                             ]
-                            for (charm in charms) {
-
+                            for (entry in charms) {
+                                charm = entry.name
+                                base = entry.base
                                 channel = 'latest'
                                 if (BRANCH_NAME.startsWith('v')) {
                                     channel = BRANCH_NAME.substring(1)
@@ -710,15 +744,15 @@ EOF"""
 
                                 withCredentials([string(credentialsId: 'Charmstore', variable: 'CHARMCRAFT_AUTH')]) {
                                     sh "charmcraft status $charm --format json > ${charm}.json"
-                                    isCharm = sh(returnStdout: true, script: "grep architecture ${charm}.json | wc -l").trim() as int
+                                    isCharm = sh(returnStdout: true, script: "grep architecture ${charm}.json | wc -l 2>/dev/null").trim() as int
                                     resourceArgument = ""
                                     if (isCharm) {
-                                        jqScriptEdge = "cat ${charm}.json | jq -r '.[] | select(.track==\"$channel\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"20.04\") | .releases[] | select(.channel==\"$channel/edge/merged\")| .version'|head -1"
-                                        jqScriptBeta = "cat ${charm}.json | jq -r '.[] | select(.track==\"$channel\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"20.04\") | .releases[] | select(.channel==\"$channel/beta\")| .version'|head -1"
+                                        jqScriptEdge = "cat ${charm}.json | jq -r '.[] | select(.track==\"$channel\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"$base\") | .releases[] | select(.channel==\"$channel/edge/merged\")| .version'|head -1"
+                                        jqScriptBeta = "cat ${charm}.json | jq -r '.[] | select(.track==\"$channel\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"$base\") | .releases[] | select(.channel==\"$channel/beta\")| .version'|head -1"
                                         index=0
                                         while (index < 5) {
-                                            resourceNameScript = "cat ${charm}.json | jq -r '.[] | select(.track==\"$channel\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"20.04\") | .releases[] | select(.channel==\"$channel/edge/merged\")| .resources[$index].name'|head -1"
-                                            resourceRevsScript = "cat ${charm}.json | jq -r '.[] | select(.track==\"$channel\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"20.04\") | .releases[] | select(.channel==\"$channel/edge/merged\")| .resources[$index].revision'|head -1"
+                                            resourceNameScript = "cat ${charm}.json | jq -r '.[] | select(.track==\"$channel\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"$base\") | .releases[] | select(.channel==\"$channel/edge/merged\")| .resources[$index].name'|head -1"
+                                            resourceRevsScript = "cat ${charm}.json | jq -r '.[] | select(.track==\"$channel\") | .mappings[] | select(.base.architecture==\"amd64\" and .base.channel==\"$base\") | .releases[] | select(.channel==\"$channel/edge/merged\")| .resources[$index].revision'|head -1"
                                             resourceName = sh(returnStdout: true, script: resourceNameScript).trim()
                                             resourceRevs = sh(returnStdout: true, script: resourceRevsScript).trim()
                                             if (resourceName != "null") {