Add conformance execution for containerD cases
Change-Id: I48dd104776e36c4a176e1364150660cf255ac190
Related-PROD: PROD-24954
diff --git a/cloud-deploy-pipeline.groovy b/cloud-deploy-pipeline.groovy
index 1f7dd1f..8802cea 100644
--- a/cloud-deploy-pipeline.groovy
+++ b/cloud-deploy-pipeline.groovy
@@ -551,24 +551,39 @@
if (common.checkContains('STACK_TEST', 'k8s')) {
stage('Run k8s conformance e2e tests') {
def image = TEST_K8S_CONFORMANCE_IMAGE
- def output_file = image.replaceAll('/', '-') + '.output'
- def target = "ctl01* ${extra_tgt}"
- def conformance_output_file = 'conformance_test.tar'
+ def autodetect = AUTODETECT
+ def ctl_target = 'I@kubernetes:master'
+ firstTarget = salt.getFirstMinion(venvPepper, ctl_target)
+ def containerd_enabled = salt.getPillar(
+ venvPepper, firstTarget, "kubernetes:common:containerd:enabled"
+ )["return"][0].values()[0].toBoolean()
+ if (containerd_enabled) {
+ def config = ['master': venvPepper,
+ 'target': firstTarget,
+ 'junitResults': true,
+ 'autodetect': autodetect,
+ 'image': image]
+ test.executeConformance(config)
+ } else {
+ def output_file = image.replaceAll('/', '-') + '.output'
+ def target = "ctl01* ${extra_tgt}"
+ def conformance_output_file = 'conformance_test.tar'
- // run image
- test.runConformanceTests(venvPepper, target, TEST_K8S_API_SERVER, image)
+ // run image
+ test.runConformanceTests(venvPepper, target, TEST_K8S_API_SERVER, image)
- // collect output
- sh "mkdir -p ${artifacts_dir}"
- file_content = salt.getFileContent(venvPepper, target, '/tmp/' + output_file)
- writeFile file: "${artifacts_dir}${output_file}", text: file_content
- sh "cat ${artifacts_dir}${output_file}"
+ // collect output
+ sh "mkdir -p ${artifacts_dir}"
+ file_content = salt.getFileContent(venvPepper, target, '/tmp/' + output_file)
+ writeFile file: "${artifacts_dir}${output_file}", text: file_content
+ sh "cat ${artifacts_dir}${output_file}"
- // collect artifacts
- archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
+ // collect artifacts
+ archiveArtifacts artifacts: "${artifacts_dir}${output_file}"
- // Copy test results
- test.CopyConformanceResults(venvPepper, target, artifacts_dir, conformance_output_file)
+ // Copy test results
+ test.CopyConformanceResults(venvPepper, target, artifacts_dir, conformance_output_file)
+ }
}
}
diff --git a/k8s-upgrade-pipeline.groovy b/k8s-upgrade-pipeline.groovy
index 980aa2f..46a846e 100644
--- a/k8s-upgrade-pipeline.groovy
+++ b/k8s-upgrade-pipeline.groovy
@@ -27,6 +27,7 @@
def common = new com.mirantis.mk.Common()
def salt = new com.mirantis.mk.Salt()
def python = new com.mirantis.mk.Python()
+def test = new com.mirantis.mk.Test()
def updates = TARGET_UPDATES.tokenize(",").collect{it -> it.trim()}
def pepperEnv = "pepperEnv"
@@ -258,6 +259,24 @@
}
}
+def containerDinstalled(pepperEnv, target) {
+ def salt = new com.mirantis.mk.Salt()
+ return salt.cmdRun(pepperEnv, target, "containerd --version 2>1 1>/dev/null && echo 'true' || echo 'false'"
+ )['return'][0].values()[0].replaceAll('Salt command execution success','').trim().toBoolean()
+}
+
+def containerDenabled(pepperEnv, target) {
+ def salt = new com.mirantis.mk.Salt()
+ return salt.getPillar(venvPepper, target, "kubernetes:common:containerd:enabled"
+ )["return"][0].values()[0].toBoolean()
+}
+
+def conformancePodDefExists(pepperEnv, target) {
+ def salt = new com.mirantis.mk.Salt()
+ return salt.cmdRun(pepperEnv, target, "test -e /srv/kubernetes/conformance.yml && echo 'true' || echo 'false'"
+ )['return'][0].values()[0].replaceAll('Salt command execution success','').trim().toBoolean()
+}
+
def checkCalicoUpgradeSuccessful(pepperEnv, target) {
def salt = new com.mirantis.mk.Salt()
@@ -336,7 +355,18 @@
def mcp_repo = ARTIFACTORY_URL
def k8s_api = TEST_K8S_API_SERVER
firstTarget = salt.getFirstMinion(pepperEnv, target)
- executeConformance(pepperEnv, firstTarget, k8s_api, mcp_repo)
+ def containerd_enabled = containerDenabled(pepperEnv, firstTarget)
+ def containerd_installed = containerDinstalled(pepperEnv, firstTarget)
+ def conformance_pod_ready = conformancePodDefExists(pepperEnv, firstTarget)
+ if (containerd_enabled && containerd_installed && conformance_pod_ready) {
+ def config = ['master': pepperEnv,
+ 'target': firstTarget,
+ 'junitResults': false,
+ 'autodetect': true]
+ test.executeConformance(config)
+ } else {
+ executeConformance(pepperEnv, firstTarget, k8s_api, mcp_repo)
+ }
}
if ((common.validInputParam('KUBERNETES_HYPERKUBE_IMAGE')) && (common.validInputParam('KUBERNETES_PAUSE_IMAGE'))) {
@@ -452,7 +482,18 @@
def mcp_repo = ARTIFACTORY_URL
def k8s_api = TEST_K8S_API_SERVER
firstTarget = salt.getFirstMinion(pepperEnv, target)
- executeConformance(pepperEnv, firstTarget, k8s_api, mcp_repo)
+ def containerd_enabled = containerDenabled(pepperEnv, firstTarget)
+ def containerd_installed = containerDinstalled(pepperEnv, firstTarget)
+ def conformance_pod_ready = conformancePodDefExists(pepperEnv, firstTarget)
+ if (containerd_enabled && containerd_installed && conformance_pod_ready) {
+ def config = ['master': pepperEnv,
+ 'target': firstTarget,
+ 'junitResults': false,
+ 'autodetect': true]
+ test.executeConformance(config)
+ } else {
+ executeConformance(pepperEnv, firstTarget, k8s_api, mcp_repo)
+ }
}
} catch (Throwable e) {
// If there was an error or exception thrown, the build failed