diff --git a/tests/v2/validation/pipeline/Jenkinsfile.release.upgrade.local b/tests/v2/validation/pipeline/Jenkinsfile.release.upgrade.local index 8812734eb6e..1e106b28b8e 100644 --- a/tests/v2/validation/pipeline/Jenkinsfile.release.upgrade.local +++ b/tests/v2/validation/pipeline/Jenkinsfile.release.upgrade.local @@ -27,8 +27,11 @@ node { def patchedConfigsDir = "patched-cattle-configs" def testResultsOut = "results.xml" + def testResultsJSON = "results.json" def envFile = ".env" def rancherConfig = "rancher_env.config" + def qaseRun = "./testrun" // + def testRunConfig = "testrunconfig.yaml" // Config file for Qase // rancher def rancherRepo = scm.getUserRemoteConfigs()[0].getUrl() @@ -40,8 +43,6 @@ node { branch = "${env.BRANCH}" } - def qaseID = "${env.QASE_TEST_RUN_ID}" - // corral def corralBranch = "main" if ("${env.RANCHER_CORRAL_PACKAGES_REPO_BRANCH}" != "null" && "${env.RANCHER_CORRAL_PACKAGES_REPO_BRANCH}" != "") { @@ -120,7 +121,8 @@ node { string(credentialsId: 'RANCHER_VALID_TLS_KEY', variable: 'RANCHER_VALID_TLS_KEY'), string(credentialsId: 'RANCHER_BYO_TLS_CERT', variable: 'RANCHER_BYO_TLS_CERT'), string(credentialsId: 'RANCHER_BYO_TLS_KEY', variable: 'RANCHER_BYO_TLS_KEY'), - string(credentialsId: 'RANCHER_LINODE_ACCESSKEY', variable: "RANCHER_LINODE_ACCESSKEY")]) { + string(credentialsId: 'QASE_AUTOMATION_TOKEN', variable: 'QASE_AUTOMATION_TOKEN'), + string(credentialsId: 'RANCHER_LINODE_ACCESSKEY', variable: 'RANCHER_LINODE_ACCESSKEY')]) { withEnv(paramsMap) { stage('Checkout') { deleteDir() @@ -174,7 +176,12 @@ node { stage("Build Environment") { try { sh "docker run -v ${validationVolume}:/root --name ${buildTestContainer} -t --env-file ${envFile} " + - "${imageName} sh -c \"${workPath}pipeline/scripts/setup_environment.sh; ${workPath}pipeline/scripts/build_qase_auto_testrun.sh\"" + "${imageName} sh -c \"${workPath}pipeline/scripts/setup_environment.sh;${workPath}pipeline/scripts/build_qase_auto_testrun.sh\"" + + echo "Checking the current working directory and its contents" + sh "pwd" + sh "${workPath}" + } catch(err) { sh "docker stop ${buildTestContainer}" sh "docker rm -v ${buildTestContainer}" @@ -229,23 +236,25 @@ node { returnStdout: true ).trim() + jobs["$it-provisioning"] = { stage("Parallel Provisioning: $it"){ def containerName = "${job_name}${env.BUILD_NUMBER}_$it-provisioning" try { + echo "Starting provisioning tests. Getting qase run iD: " sh "docker run --volumes-from ${buildTestContainer} --name ${containerName} -t -e CATTLE_TEST_CONFIG=\"${absoluteConfigPath}\" " + - "${imageName} sh -c \"gotestsum --format standard-verbose --packages=\"${testsDir}${testPackage}\" --junitfile ${testResultsOut} -- -tags=validation ${testCase} -timeout=\"60m\" -v\"" + "${imageName} sh -c \"gotestsum --format standard-verbose --packages=\"${testsDir}${testPackage}\" --junitfile ${testResultsJSON} -- -tags=validation ${testCase} -timeout=\"60m\" -v\"" + + dir("./${patchedConfigsDir}") { sh "docker cp ${containerName}:${rootPath}${configsDir}/$it ." } - } catch (err){ sh "docker stop ${containerName}" sh "docker rm -v ${containerName}" } - sh "./${qaseRun} --startRun=false" sh "docker stop ${containerName}" sh "docker rm -v ${containerName}" } @@ -285,6 +294,7 @@ node { try { jobs = [:] + configFiles.each { try { def configPath = "./${configsDir}/$it" @@ -306,99 +316,112 @@ node { string(name: 'REPO', value: "${rancherRepo}"), string(name: 'BRANCH', value: "${branch}"), string(name: 'TEST_PACKAGE', value: "${testPackage}"), + string(name: 'QASE_TEST_RUN_ID', value: "${testRunID}"), string(name: 'TAGS', value: "${defaultTag}"), string(name: 'GOTEST_TESTCASE', value: "${testCase}"), - string(name: 'RKE_VERSION', value: "${env.RKE_VERSION}"), - string(name: 'QASE_TEST_RUN_ID', value: "${testRunID}") + string(name: 'RKE_VERSION', value: "${env.RKE_VERSION}") ] - jobs["$it-preupgrade"] = { build job: 'go-automation-freeform-job', parameters: goValidationParams } + jobs["$it-preupgrade"] = { + build job: 'go-automation-freeform-job', parameters: goValidationParams + echo envFile + echo ${workpath} + try { + sh """ + docker run --name ${testContainer} -t --env-file ${envFile} \ + ${imageName} sh -c "/go/bin/gotestsum --format standard-verbose --packages=${testsDir} \ + --junitfile ${testResultsOut} -- ${GOTEST_TESTCASE} -timeout=${timeout} -v; \ + .${workpath}pipeline/scripts/build_qase_auto_testrun.sh; \ + .${workpath}reporter" + """ + }catch (err) { + echo "Test run for ${configFile} had failures. Collecting results..." + } + } } catch(err) { echo "Pre upgrade $it had failures: " + err } } + parallel jobs } catch(err) { echo "Pre upgrade tests had failures: " + err } - sh "./${qaseRun} --startRun=false" - } - stage('Upgrade local cluster version') { - try { - def configPath = "./${configsDir}/${localConfigFileName}" - def configYaml = readFile(file: "./${patchedConfigsDir}/${localConfigFileName}") - - def testCase = sh ( - script: "./yq '.testCases.upgradeKubernetesTestCase' ${configPath}", - returnStdout: true - ).trim() - - def testPackage = sh ( - script: "./yq '.testCases.upgradeTestCase' ${configPath}", - returnStdout: true - ).trim() - - def goValidationParams = [ - string(name: 'TIMEOUT', value: "2h"), - text(name: 'CONFIG', value: configYaml), - string(name: 'REPO', value: "${rancherRepo}"), - string(name: 'BRANCH', value: "${branch}"), - string(name: 'TEST_PACKAGE', value: "${testPackage}"), - string(name: 'TAGS', value: "${defaultTag}"), - string(name: 'GOTEST_TESTCASE', value: "${testCase}" ), - string(name: 'RKE_VERSION', value: "${env.RKE_VERSION}"), - string(name: 'QASE_TEST_RUN_ID', value: "${testRunID}") - ] - - build job: 'go-automation-freeform-job', parameters: goValidationParams - } catch(err) { - echo "Kubernetes upgrade tests had failures: " + err - } - sh "./${qaseRun} --startRun=false" + sh "./${qaseRun} --startRun=false" } - stage('Run postupgrade checks') { - try { - jobs = [:] - - configFiles.each { - try { - def configPath = "./${configsDir}/$it" - def configYaml = readFile(file: "./${patchedConfigsDir}/$it") - - def testCase = sh ( - script: "./yq '.testCases.postUpgradeTestCase' ${configPath}", - returnStdout: true - ).trim() - - def testPackage = sh ( - script: "./yq '.testCases.upgradeTestCase' ${configPath}", - returnStdout: true - ).trim() - - def goValidationParams = [ - string(name: 'TIMEOUT', value: "30m"), - text(name: 'CONFIG', value: configYaml), - string(name: 'REPO', value: "${rancherRepo}"), - string(name: 'BRANCH', value: "${branch}"), - string(name: 'TEST_PACKAGE', value: "${testPackage}"), - string(name: 'TAGS', value: "${defaultTag}"), - string(name: 'GOTEST_TESTCASE', value: "${testCase}"), - string(name: 'RKE_VERSION', value: "${env.RKE_VERSION}"), - string(name: 'QASE_TEST_RUN_ID', value: "${testRunID}") - ] - - jobs["$it-postupgrade"] = { build job: 'go-automation-freeform-job', parameters: goValidationParams } - } catch(err) { - echo "Post upgrade $it had failures: " + err - } - } - parallel jobs - } catch(err){ - echo "Post upgrade tests had failures: " + err - } - sh "./${qaseRun} --startRun=false" - } + // stage('Upgrade local cluster version') { + // try { + // def configPath = "./${configsDir}/${localConfigFileName}" + // def configYaml = readFile(file: "./${patchedConfigsDir}/${localConfigFileName}") + + // def testCase = sh ( + // script: "./yq '.testCases.upgradeKubernetesTestCase' ${configPath}", + // returnStdout: true + // ).trim() + + // def testPackage = sh ( + // script: "./yq '.testCases.upgradeTestCase' ${configPath}", + // returnStdout: true + // ).trim() + + // def goValidationParams = [ + // string(name: 'TIMEOUT', value: "2h"), + // text(name: 'CONFIG', value: configYaml), + // string(name: 'REPO', value: "${rancherRepo}"), + // string(name: 'BRANCH', value: "${branch}"), + // string(name: 'TEST_PACKAGE', value: "${testPackage}"), + // string(name: 'TAGS', value: "${defaultTag}"), + // string(name: 'GOTEST_TESTCASE', value: "${testCase}" ), + // string(name: 'RKE_VERSION', value: "${env.RKE_VERSION}") + // ] + + // build job: 'go-automation-freeform-job', parameters: goValidationParams + // } catch(err) { + // echo "Kubernetes upgrade tests had failures: " + err + // } + // } + // stage('Run postupgrade checks') { + // try { + // jobs = [:] + + // configFiles.each { + // try { + // def configPath = "./${configsDir}/$it" + // def configYaml = readFile(file: "./${patchedConfigsDir}/$it") + + // def testCase = sh ( + // script: "./yq '.testCases.postUpgradeTestCase' ${configPath}", + // returnStdout: true + // ).trim() + + // def testPackage = sh ( + // script: "./yq '.testCases.upgradeTestCase' ${configPath}", + // returnStdout: true + // ).trim() + + // def goValidationParams = [ + // string(name: 'TIMEOUT', value: "30m"), + // text(name: 'CONFIG', value: configYaml), + // string(name: 'REPO', value: "${rancherRepo}"), + // string(name: 'BRANCH', value: "${branch}"), + // string(name: 'TEST_PACKAGE', value: "${testPackage}"), + // string(name: 'TAGS', value: "${defaultTag}"), + // string(name: 'GOTEST_TESTCASE', value: "${testCase}"), + // string(name: 'RKE_VERSION', value: "${env.RKE_VERSION}") + // ] + + // jobs["$it-postupgrade"] = { build job: 'go-automation-freeform-job', parameters: goValidationParams } + // } catch(err) { + // echo "Post upgrade $it had failures: " + err + // } + // } + + // parallel jobs + // } catch(err){ + // echo "Post upgrade tests had failures: " + err + // } + // } stage('Delete Rancher and resources') { if (cleanup.toBoolean()) { try{ @@ -462,4 +485,4 @@ node { } // creds } // folder properties } // wrap -} // node +} // node \ No newline at end of file diff --git a/tests/v2/validation/pipeline/qase/testrun/main.go b/tests/v2/validation/pipeline/qase/testrun/main.go index ae3a60a9b08..fc27cf6ffbb 100644 --- a/tests/v2/validation/pipeline/qase/testrun/main.go +++ b/tests/v2/validation/pipeline/qase/testrun/main.go @@ -19,7 +19,7 @@ const ( ) var ( - testRunName = os.Getenv(qasedefaults.TestRunNameEnvVar) + testRunName = "Anu test run" qaseToken = os.Getenv(qasedefaults.QaseTokenEnvVar) ) @@ -36,6 +36,8 @@ func main() { cfg.AddDefaultHeader("Token", qaseToken) client := qase.NewAPIClient(cfg) + logrus.Info("starting qase test run script.") + if *startRun { // create test run resp, err := createTestRun(client, testRunName) diff --git a/tests/v2/validation/pipeline/scripts/build_qase_auto_testrun.sh b/tests/v2/validation/pipeline/scripts/build_qase_auto_testrun.sh index fc527caf1e1..b9234779626 100755 --- a/tests/v2/validation/pipeline/scripts/build_qase_auto_testrun.sh +++ b/tests/v2/validation/pipeline/scripts/build_qase_auto_testrun.sh @@ -2,5 +2,16 @@ set -e cd $(dirname $0)/../../../../../ +echo "Current directory after cd command:" +pwd + echo "building qase auto testrun bin" - env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o tests/v2/validation/testrun ./tests/v2/validation/pipeline/qase/testrun \ No newline at end of file + env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o tests/v2/validation/testrun ./tests/v2/validation/pipeline/qase/testrun + + if [ $? -ne 0 ]; then + echo "Failed to build Qase auto testrun binary" >&2 + exit 1 +else + echo "Successfully built Qase auto testrun binary" + echo "ls tests/v2/validation/testrun" +fi \ No newline at end of file