github.com/verrazzano/verrazzano@v1.7.0/ci/oke-capi-cluster-driver/Jenkinsfile (about) 1 // Copyright (c) 2023, Oracle and/or its affiliates. 2 // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 4 def agentLabel = env.JOB_NAME.contains('-dns-') ? "" : env.JOB_NAME.contains('master') ? "2.0-large-phx" : "2.0-large" 5 6 // pulling "ap-*" from the test regions given discovery of image pull issues 7 def availableRegions = [ "us-ashburn-1", "ca-montreal-1", "ca-toronto-1", "eu-amsterdam-1", "eu-frankfurt-1", "eu-zurich-1", "uk-london-1" ] 8 Collections.shuffle(availableRegions) 9 def OKE_CLUSTER_PREFIX = "" 10 def EFFECTIVE_DUMP_K8S_CLUSTER_ON_SUCCESS = false 11 def OKECAPIClusterNameSuffix = UUID.randomUUID().toString().substring(0,6).replace('-','') 12 13 pipeline { 14 options { 15 skipDefaultCheckout true 16 copyArtifactPermission('*'); 17 timestamps () 18 } 19 20 agent { 21 docker { 22 image "${RUNNER_DOCKER_IMAGE}" 23 args "${RUNNER_DOCKER_ARGS} --cap-add=NET_ADMIN" 24 registryUrl "${RUNNER_DOCKER_REGISTRY_URL}" 25 label "${agentLabel}" 26 } 27 } 28 29 parameters { 30 // OKE_CLUSTER_REGION parameter will be ignored for private DNS tests. They get overwritten with runner region 31 choice (description: 'OCI region to launch OKE clusters in. This parameter will be ignored for private DNS tests', name: 'OKE_CLUSTER_REGION', 32 // 1st choice is the default value 33 choices: availableRegions ) 34 choice (description: 'OKE node pool configuration', name: 'OKE_NODE_POOL', 35 // 1st choice is the default value 36 choices: [ "VM.Standard.E3.Flex-4-2", "VM.Standard2.4-2", "VM.Standard.E3.Flex-8-2", "VM.Standard.E2.2" ]) 37 choice (description: 'Specifies Nginx LoadBalancer scope. Values: GLOBAL, PRIVATE. Default: GLOBAL',name: 'NGINX_LB_SCOPE', 38 // 1st choice is the default value 39 choices: [ "GLOBAL","PRIVATE" ]) 40 choice (description: 'Specifies Istio LoadBalancer scope. Values: GLOBAL, PRIVATE. Default: GLOBAL',name: 'ISTIO_LB_SCOPE', 41 // 1st choice is the default value 42 choices: [ "GLOBAL","PRIVATE" ]) 43 choice (description: 'Kubernetes Version for OKE Cluster', name: 'OKE_CLUSTER_VERSION', 44 // 1st choice is the default value 45 choices: [ "v1.27.2", "v1.26.2", "v1.25.4", "v1.24.1" ]) 46 choice (name: 'CRD_API_VERSION', 47 description: 'This is the API crd version.', 48 // 1st choice is the default value 49 choices: [ "v1beta1", "v1alpha1"]) 50 string defaultValue: 'prod', description: 'Verrazzano install profile name', name: "INSTALL_PROFILE", trim: true 51 string defaultValue: 'NONE', description: 'Verrazzano platform operator image name (within ghcr.io/verrazzano repo)', name: 'VERRAZZANO_OPERATOR_IMAGE', trim: true 52 string (name: 'GIT_COMMIT_TO_USE', 53 defaultValue: 'NONE', 54 description: 'This is the full git commit hash from the source build to be used for all jobs', 55 trim: true) 56 booleanParam (description: 'Whether to create the cluster with Calico for AT testing', name: 'CREATE_CLUSTER_USE_CALICO', defaultValue: true) 57 booleanParam (description: 'Whether to dump k8s cluster on success (off by default can be useful to capture for comparing to failed cluster)', name: 'DUMP_K8S_CLUSTER_ON_SUCCESS', defaultValue: false) 58 string (name: 'TAGGED_TESTS', 59 defaultValue: '', 60 description: 'A comma separated list of build tags for tests that should be executed (e.g. unstable_test). Default:', 61 trim: true) 62 string (name: 'INCLUDED_TESTS', 63 defaultValue: '.*', 64 description: 'A regex matching any fully qualified test file that should be executed (e.g. examples/helidon/). Default: .*', 65 trim: true) 66 string (name: 'EXCLUDED_TESTS', 67 defaultValue: '_excluded_test', 68 description: 'A regex matching any fully qualified test file that should not be executed (e.g. multicluster/|_excluded_test). Default: _excluded_test', 69 trim: true) 70 booleanParam (description: 'Whether to run all the OKE CAPI Cluster Driver tests (true), or just the 1 bare minimum test case (false).', name: 'RUN_ALL_TESTS', defaultValue: false) 71 72 // Optional parameters to the Ginkgo test suite 73 string (name: 'DOCKER_ROOT_DIR', 74 defaultValue: '', 75 description: 'An optional override to be passed into the OKE CAPI cluster creation request.', 76 trim: true) 77 string (name: 'ENABLE_CLUSTER_ALERTING', 78 defaultValue: '', 79 description: 'An optional override to be passed into the OKE CAPI cluster creation request.', 80 trim: true) 81 string (name: 'ENABLE_CLUSTER_MONITORING', 82 defaultValue: '', 83 description: 'An optional override to be passed into the OKE CAPI cluster creation request.', 84 trim: true) 85 string (name: 'ENABLE_NETWORK_POLICY', 86 defaultValue: '', 87 description: 'An optional override to be passed into the OKE CAPI cluster creation request.', 88 trim: true) 89 string (name: 'WINDOWS_PREFERRED_CLUSTER', 90 defaultValue: '', 91 description: 'An optional override to be passed into the OKE CAPI cluster creation request.', 92 trim: true) 93 string (name: 'CLUSTER_CIDR', 94 defaultValue: '', 95 description: 'An optional override to be passed into the OKE CAPI cluster creation request.', 96 trim: true) 97 string (name: 'IMAGE_DISPLAY_NAME', 98 defaultValue: '', 99 description: 'An optional override to be passed into the OKE CAPI cluster creation request.', 100 trim: true) 101 string (name: 'IMAGE_ID', 102 defaultValue: '', 103 description: 'An optional override to be passed into the OKE CAPI cluster creation request.', 104 trim: true) 105 string (name: 'KUBERNETES_VERSION', 106 defaultValue: '', 107 description: 'An optional override to be passed into the OKE CAPI cluster creation request.', 108 trim: true) 109 string (name: 'POD_CIDR', 110 defaultValue: '', 111 description: 'An optional override to be passed into the OKE CAPI cluster creation request.', 112 trim: true) 113 string (name: 'NODE_SHAPE', 114 defaultValue: '', 115 description: 'An optional override to be passed into the OKE CAPI cluster creation request.', 116 trim: true) 117 string (name: 'APPLY_YAMLS', 118 defaultValue: '', 119 description: 'An optional override to be passed into the OKE CAPI cluster creation request.', 120 trim: true) 121 } 122 123 environment { 124 DOCKER_CREDS = credentials('github-packages-credentials-rw') 125 DOCKER_EMAIL = credentials('github-packages-email') 126 DOCKER_REPO = 'ghcr.io' 127 TEST_CONFIG_FILE = "${HOME}/testConfigOke.yaml" 128 OCI_CLI_REGION = "${params.OKE_CLUSTER_REGION}" 129 DISABLE_SPINNER=1 130 VZ_ENVIRONMENT_NAME = "default" 131 WEBLOGIC_PSW = credentials('weblogic-example-domain-password') 132 DATABASE_PSW = credentials('todo-mysql-password') 133 134 CLUSTER_NAME = 'byok8s-kind' 135 OCR_CREDS = credentials('ocr-pull-and-push-account') 136 NETRC_FILE = credentials('netrc') 137 OCR_REPO = 'container-registry.oracle.com' 138 GHCR_REPO = 'ghcr.io' 139 VERRAZZANO_OPERATOR_IMAGE="${params.VERRAZZANO_OPERATOR_IMAGE}" 140 INSTALL_PROFILE = "${params.INSTALL_PROFILE}" 141 GITHUB_PKGS_CREDS = credentials('github-packages-credentials-rw') 142 OCIR_CREDS = credentials('ocir-pull-and-push-account') 143 IMAGE_PULL_SECRET = 'verrazzano-container-registry' 144 OCIR_PHX_REPO = 'phx.ocir.io' 145 POST_DUMP_FAILED = 'false' 146 GOPATH = '/home/opc/go' 147 GO_REPO_PATH = "${GOPATH}/src/github.com/verrazzano" 148 149 TF_VAR_compartment_id = credentials('oci-tiburon-dev-compartment-ocid') 150 TF_VAR_tenancy_id = credentials('oci-tenancy') 151 TF_VAR_tenancy_name = credentials('oci-tenancy-name') 152 TF_VAR_user_id = credentials('oci-user-ocid') 153 TF_VAR_region = "${params.OKE_CLUSTER_REGION}" 154 TF_VAR_kubernetes_version = "${params.OKE_CLUSTER_VERSION}" 155 TF_VAR_nodepool_config = "${params.OKE_NODE_POOL}" 156 TF_VAR_api_fingerprint = credentials('oci-api-key-fingerprint') 157 TF_VAR_api_private_key_path = credentials('oci-api-key') 158 TF_VAR_s3_bucket_access_key = credentials('oci-s3-bucket-access-key') 159 TF_VAR_s3_bucket_secret_key = credentials('oci-s3-bucket-secret-key') 160 TF_VAR_ssh_public_key_path = credentials('oci-tf-pub-ssh-key') 161 162 OCI_CLI_TENANCY = credentials('oci-tenancy') 163 OCI_CLI_USER = credentials('oci-user-ocid') 164 OCI_CLI_FINGERPRINT = credentials('oci-api-key-fingerprint') 165 OCI_CLI_KEY_FILE = credentials('oci-api-key') 166 OCI_CLI_SUPPRESS_FILE_PERMISSIONS_WARNING = 'True' 167 168 KUBECONFIG = "${WORKSPACE}/test_kubeconfig" 169 VERRAZZANO_KUBECONFIG = "${KUBECONFIG}" 170 171 TIMESTAMP = sh(returnStdout: true, script: "date +%Y%m%d%H%M%S").trim() 172 SHORT_TIME_STAMP = sh(returnStdout: true, script: "date +%m%d%H%M%S").trim() 173 174 POST_DUMP_FAILED_FILE = "${WORKSPACE}/post_dump_failed_file.tmp" 175 176 INSTALL_CONFIG_FILE = "${WORKSPACE}/tests/e2e/config/scripts/${params.CRD_API_VERSION}/install-verrazzano-nipio.yaml" 177 178 // Environment variables required to capture cluster snapshot and bug report on test failure 179 DUMP_KUBECONFIG="${KUBECONFIG}" 180 DUMP_COMMAND="${WORKSPACE}/tools/scripts/k8s-dump-cluster.sh" 181 TEST_DUMP_ROOT="${WORKSPACE}/test-cluster-snapshots" 182 TEST_SCRIPTS_DIR = "${GO_REPO_PATH}/verrazzano/tests/e2e/config/scripts" 183 LOOPING_TEST_SCRIPTS_DIR = "${TEST_SCRIPTS_DIR}/looping-test" 184 UNINSTALL_TEST_SCRIPTS_DIR = "${TEST_SCRIPTS_DIR}/uninstall-test" 185 186 // Environment variable for Verrazzano CLI executable 187 VZ_COMMAND="${GO_REPO_PATH}/vz" 188 189 // used for console artifact capture on failure 190 JENKINS_READ = credentials('jenkins-auditor') 191 OCI_OS_NAMESPACE = credentials('oci-os-namespace') 192 OCI_OS_ARTIFACT_BUCKET="build-failure-artifacts" 193 OCI_OS_COMMIT_BUCKET="verrazzano-builds-by-commit" 194 VZ_CLI_TARGZ="vz-linux-amd64.tar.gz" 195 196 // used to emit metrics 197 PROMETHEUS_CREDENTIALS = credentials('prometheus-credentials') 198 TEST_ENV = "OKE" 199 TEST_ENV_LABEL = "magicdns_oke" 200 SEARCH_HTTP_ENDPOINT = credentials('search-gw-url') 201 SEARCH_PASSWORD = "${PROMETHEUS_CREDENTIALS_PSW}" 202 SEARCH_USERNAME = "${PROMETHEUS_CREDENTIALS_USR}" 203 204 // used to generate Ginkgo test reports 205 TEST_REPORT = "test-report.xml" 206 GINKGO_REPORT_ARGS = "--junit-report=${TEST_REPORT} --keep-separate-reports=true" 207 TEST_REPORT_DIR = "${WORKSPACE}/tests/e2e" 208 209 OPERATOR_YAML_FILE = "${WORKSPACE}/acceptance-test-operator.yaml" 210 211 // For Ginkgo test 212 OKE_CAPI_CLUSTER_NAME_SUFFIX = "${OKECAPIClusterNameSuffix}" 213 OKE_VERSIONS = "v1.27.2, v1.26.7, v1.26.2, v1.25.12, v1.25.4" 214 } 215 216 stages { 217 stage('Clean workspace and checkout') { 218 steps { 219 sh """ 220 echo "${NODE_LABELS}" 221 """ 222 223 script { 224 EFFECTIVE_DUMP_K8S_CLUSTER_ON_SUCCESS = getEffectiveDumpOnSuccess() 225 if (params.GIT_COMMIT_TO_USE == "NONE") { 226 echo "Specific GIT commit was not specified, use current head" 227 def scmInfo = checkout scm 228 env.GIT_COMMIT = scmInfo.GIT_COMMIT 229 env.GIT_BRANCH = scmInfo.GIT_BRANCH 230 } else { 231 echo "SCM checkout of ${params.GIT_COMMIT_TO_USE}" 232 def scmInfo = checkout([ 233 $class: 'GitSCM', 234 branches: [[name: params.GIT_COMMIT_TO_USE]], 235 doGenerateSubmoduleConfigurations: false, 236 extensions: [], 237 submoduleCfg: [], 238 userRemoteConfigs: [[url: env.SCM_VERRAZZANO_GIT_URL]]]) 239 env.GIT_COMMIT = scmInfo.GIT_COMMIT 240 env.GIT_BRANCH = scmInfo.GIT_BRANCH 241 // If the commit we were handed is not what the SCM says we are using, fail 242 if (!env.GIT_COMMIT.equals(params.GIT_COMMIT_TO_USE)) { 243 echo "SCM didn't checkout the commit we expected. Expected: ${params.GIT_COMMIT_TO_USE}, Found: ${scmInfo.GIT_COMMIT}" 244 exit 1 245 } 246 } 247 echo "SCM checkout of ${env.GIT_BRANCH} at ${env.GIT_COMMIT}" 248 } 249 250 sh """ 251 cp -f "${NETRC_FILE}" $HOME/.netrc 252 chmod 600 $HOME/.netrc 253 """ 254 255 script { 256 try { 257 sh """ 258 echo "${DOCKER_CREDS_PSW}" | docker login ${env.DOCKER_REPO} -u ${DOCKER_CREDS_USR} --password-stdin 259 """ 260 } catch(error) { 261 echo "docker login failed, retrying after sleep" 262 retry(4) { 263 sleep(30) 264 sh """ 265 echo "${DOCKER_CREDS_PSW}" | docker login ${env.DOCKER_REPO} -u ${DOCKER_CREDS_USR} --password-stdin 266 """ 267 } 268 } 269 } 270 sh """ 271 rm -rf ${GO_REPO_PATH}/verrazzano 272 mkdir -p ${GO_REPO_PATH}/verrazzano 273 tar cf - . | (cd ${GO_REPO_PATH}/verrazzano/ ; tar xf -) 274 """ 275 276 script { 277 def props = readProperties file: '.verrazzano-development-version' 278 VERRAZZANO_DEV_VERSION = props['verrazzano-development-version'] 279 TIMESTAMP = sh(returnStdout: true, script: "date +%Y%m%d%H%M%S").trim() 280 SHORT_COMMIT_HASH = sh(returnStdout: true, script: "git rev-parse --short=8 HEAD").trim() 281 DOCKER_IMAGE_TAG = "${VERRAZZANO_DEV_VERSION}-${TIMESTAMP}-${SHORT_COMMIT_HASH}" 282 // update the description with some meaningful info 283 setDisplayName() 284 currentBuild.description = params.KUBERNETES_CLUSTER_VERSION + " : " + SHORT_COMMIT_HASH + " : " + env.GIT_COMMIT + " : " + params.GIT_COMMIT_TO_USE 285 286 // derive the prefix for the OKE cluster 287 OKE_CLUSTER_PREFIX = sh(returnStdout: true, script: "${WORKSPACE}/ci/scripts/derive_oke_cluster_name.sh").trim() 288 } 289 script { 290 sh """ 291 echo "Downloading VZ CLI from object storage" 292 oci --region us-phoenix-1 os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_COMMIT_BUCKET} --name ephemeral/${env.BRANCH_NAME}/${SHORT_COMMIT_HASH}/${VZ_CLI_TARGZ} --file ${VZ_CLI_TARGZ} 293 tar xzf ${VZ_CLI_TARGZ} -C ${GO_REPO_PATH} 294 ${GO_REPO_PATH}/vz version 295 """ 296 } 297 } 298 } 299 300 stage("Create OKE Cluster") { 301 steps { 302 sh "TF_VAR_label_prefix=${OKE_CLUSTER_PREFIX} TF_VAR_state_name=oke-capi-driver-${env.BUILD_NUMBER}-${env.BRANCH_NAME}/${env.TIMESTAMP} ${GO_REPO_PATH}/verrazzano/tests/e2e/config/scripts/create_oke_cluster.sh" 303 } 304 } 305 306 stage('Install Verrazzano') { 307 steps { 308 sh """ 309 # Create image pull secret for Verrazzano docker images 310 cd ${GO_REPO_PATH}/verrazzano 311 ./tests/e2e/config/scripts/create-image-pull-secret.sh "${IMAGE_PULL_SECRET}" "${DOCKER_REPO}" "${DOCKER_CREDS_USR}" "${DOCKER_CREDS_PSW}" 312 ./tests/e2e/config/scripts/create-image-pull-secret.sh github-packages "${DOCKER_REPO}" "${DOCKER_CREDS_USR}" "${DOCKER_CREDS_PSW}" 313 ./tests/e2e/config/scripts/create-image-pull-secret.sh ocr "${DOCKER_REPO}" "${DOCKER_CREDS_USR}" "${DOCKER_CREDS_PSW}" 314 315 echo "Download Platform Operator" 316 if [ "NONE" = "${VERRAZZANO_OPERATOR_IMAGE}" ]; then 317 echo "Using operator.yaml from object storage" 318 oci --region us-phoenix-1 os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_COMMIT_BUCKET} --name ephemeral/${env.BRANCH_NAME}/${SHORT_COMMIT_HASH}/operator.yaml --file ${WORKSPACE}/downloaded-operator.yaml 319 cp ${WORKSPACE}/downloaded-operator.yaml ${WORKSPACE}/acceptance-test-operator.yaml 320 else 321 echo "Generating operator.yaml based on image name provided: ${VERRAZZANO_OPERATOR_IMAGE}" 322 env IMAGE_PULL_SECRETS=verrazzano-container-registry DOCKER_IMAGE=${VERRAZZANO_OPERATOR_IMAGE} ./tools/scripts/generate_operator_yaml.sh > ${WORKSPACE}/acceptance-test-operator.yaml 323 fi 324 325 echo "Create the verrazzano-install namespace" 326 kubectl create namespace verrazzano-install 327 328 # create secret in verrazzano-install ns 329 ./tests/e2e/config/scripts/create-image-pull-secret.sh "${IMAGE_PULL_SECRET}" "${DOCKER_REPO}" "${DOCKER_CREDS_USR}" "${DOCKER_CREDS_PSW}" "verrazzano-install" 330 ./tests/e2e/config/scripts/process_nipio_install_yaml.sh ${INSTALL_CONFIG_FILE} 331 332 echo "Installing Verrazzano on OKE" 333 ${VZ_COMMAND} install --filename ${INSTALL_CONFIG_FILE} --manifests ${WORKSPACE}/acceptance-test-operator.yaml --timeout 45m 334 """ 335 } 336 post { 337 always { 338 archiveArtifacts artifacts: "acceptance-test-operator.yaml,downloaded-operator.yaml", allowEmptyArchive: true 339 } 340 success { 341 script { 342 if (EFFECTIVE_DUMP_K8S_CLUSTER_ON_SUCCESS == true) { 343 dumpK8sCluster('verrazzano-install-cluster-dump') 344 } 345 } 346 } 347 failure { 348 script { 349 dumpK8sCluster('verrazzano-install-failure-cluster-dump') 350 sh """ 351 mkdir -p ${WORKSPACE}/verrazzano-platform-operator/scripts/install/build/logs 352 ${LOOPING_TEST_SCRIPTS_DIR}/dump_resources.sh > ${WORKSPACE}/verrazzano-platform-operator/scripts/install/build/logs/resources.log 353 """ 354 } 355 } 356 } 357 } 358 359 stage("OKE CAPI Cluster Driver Tests") { 360 steps { 361 script { 362 // Required environment variables for running the oke-capi-driver Ginkgo test suite 363 env.TF_VAR_label_prefix="${OKE_CLUSTER_PREFIX}" 364 setUpEnvVarsForOKECAPIClusterCreation() 365 366 runGinkgo('clusterapi/oke-capi-driver') 367 } 368 } 369 post { 370 always { 371 archiveArtifacts artifacts: '**/coverage.html,**/logs/*,**/test-cluster-dumps/**', allowEmptyArchive: true 372 } 373 aborted { 374 script { 375 dumpK8sCluster('oke-capi-cluster-driver-cluster-dump') 376 } 377 } 378 failure { 379 script { 380 dumpK8sCluster('oke-capi-cluster-driver-cluster-dump') 381 } 382 } 383 success { 384 script { 385 if (EFFECTIVE_DUMP_K8S_CLUSTER_ON_SUCCESS == true) { 386 dumpK8sCluster('oke-capi-cluster-driver-cluster-dump') 387 } 388 } 389 } 390 } 391 } 392 } 393 394 post { 395 always { 396 sh """ 397 # Copy the generated test reports to WORKSPACE to archive them 398 mkdir -p ${TEST_REPORT_DIR} 399 cd ${GO_REPO_PATH}/verrazzano/tests/e2e 400 find . -name "${TEST_REPORT}" | cpio -pdm ${TEST_REPORT_DIR} 401 """ 402 archiveArtifacts artifacts: "**/oke_kubeconfig,**/coverage.html,**/logs/**,**/build/resources/**,**/verrazzano_images.txt,**/*full-cluster*/**,**/bug-report/**,**/${TEST_REPORT}", allowEmptyArchive: true 403 junit testResults: "**/${TEST_REPORT}", allowEmptyResults: true 404 } 405 failure { 406 script { 407 archiveArtifacts artifacts: '**/oke_kubeconfig,**/coverage.html,**/logs/**,**/build/resources/**,**/verrazzano_images.txt,**/*full-cluster*/**,**/bug-report/**', allowEmptyArchive: true 408 } 409 } 410 cleanup { 411 sh "VERRAZZANO_KUBECONFIG=${env.KUBECONFIG} TF_VAR_label_prefix=${OKE_CLUSTER_PREFIX} TF_VAR_state_name=oke-capi-driver-${env.BUILD_NUMBER}-${env.BRANCH_NAME}/${env.TIMESTAMP} ${GO_REPO_PATH}/verrazzano/tests/e2e/config/scripts/delete_oke_cluster.sh || true" 412 deleteDir() 413 } 414 } 415 } 416 417 def dumpK8sCluster(dumpDirectory) { 418 sh """ 419 ${GO_REPO_PATH}/verrazzano/ci/scripts/capture_cluster_snapshot.sh ${dumpDirectory} 420 """ 421 } 422 423 def getEffectiveDumpOnSuccess() { 424 def effectiveValue = params.DUMP_K8S_CLUSTER_ON_SUCCESS 425 if (FORCE_DUMP_K8S_CLUSTER_ON_SUCCESS.equals("true") && (env.BRANCH_NAME.equals("master"))) { 426 effectiveValue = true 427 echo "Forcing dump on success based on global override setting" 428 } 429 return effectiveValue 430 } 431 432 def setDisplayName() { 433 echo "Start setDisplayName" 434 def causes = currentBuild.getBuildCauses() 435 echo "causes: " + causes.toString() 436 for (cause in causes) { 437 def causeString = cause.toString() 438 echo "current cause: " + causeString 439 if (causeString.contains("UpstreamCause") && causeString.contains("Started by upstream project")) { 440 echo "This job was caused by " + causeString 441 if (causeString.contains("verrazzano-periodic-triggered-tests")) { 442 currentBuild.displayName = env.BUILD_NUMBER + " : PERIODIC" 443 } else if (causeString.contains("verrazzano-flaky-tests")) { 444 currentBuild.displayName = env.BUILD_NUMBER + " : FLAKY" 445 } 446 } 447 } 448 echo "End setDisplayName" 449 } 450 451 def createImagePullSecrets() { 452 sh """ 453 # Create image pull secrets for Verrazzano docker images 454 cd ${WORKSPACE} 455 ./tests/e2e/config/scripts/create-image-pull-secret.sh "${IMAGE_PULL_SECRET}" "${GHCR_REPO}" "${GITHUB_PKGS_CREDS_USR}" "${GITHUB_PKGS_CREDS_PSW}" 456 ./tests/e2e/config/scripts/create-image-pull-secret.sh github-packages "${GHCR_REPO}" "${GITHUB_PKGS_CREDS_USR}" "${GITHUB_PKGS_CREDS_PSW}" 457 ./tests/e2e/config/scripts/create-image-pull-secret.sh ocr "${OCR_REPO}" "${OCR_CREDS_USR}" "${OCR_CREDS_PSW}" 458 """ 459 } 460 461 // Run the OKE CAPI Cluster Driver Ginkgo test suite, passing in some parameters 462 def runGinkgo(testSuitePath) { 463 catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { 464 sh """ 465 echo Starting the OKE CAPI cluster driver tests 466 cd ${WORKSPACE}/tests/e2e 467 ginkgo -p -v --timeout 2h --keep-going --no-color ${GINKGO_REPORT_ARGS} -tags="${params.TAGGED_TESTS}" --focus-file="${params.INCLUDED_TESTS}" --skip-file="${params.EXCLUDED_TESTS}" ${testSuitePath}/... -- --runAllTests=${params.RUN_ALL_TESTS} 468 """ 469 } 470 } 471 472 def setUpEnvVarsForOKECAPIClusterCreation() { 473 sh "echo Setting up inputs for the OKE CAPI cluster driver tests" 474 env.VCN_ID=sh(returnStdout: true, script: """ oci network vcn list --compartment-id ${env.TF_VAR_compartment_id} --display-name ${env.TF_VAR_label_prefix}-oke-vcn | jq -r '.data[0].id' """).trim() 475 env.SUBNET_ID=sh(returnStdout: true, script: """ oci network subnet list --compartment-id ${env.TF_VAR_compartment_id} --vcn-id ${env.VCN_ID} --display-name ${env.TF_VAR_label_prefix}-workers | jq -r '.data[0].id' """).trim() 476 env.LB_SUBNET_ID=sh(returnStdout: true, script: """ oci network subnet list --compartment-id ${env.TF_VAR_compartment_id} --vcn-id ${env.VCN_ID} --display-name ${env.TF_VAR_label_prefix}-pub_lb | jq -r '.data[0].id' """).trim() 477 478 // required environment variables for the Ginkgo test suite 479 env.OCI_REGION="${env.TF_VAR_region}" 480 env.OCI_VCN_ID="${env.VCN_ID}" 481 env.OCI_USER_ID="${env.TF_VAR_user_id}" 482 env.OCI_TENANCY_ID="${env.TF_VAR_tenancy_id}" 483 env.OCI_CREDENTIALS_FINGERPRINT="${env.TF_VAR_api_fingerprint}" 484 env.OCI_PRIVATE_KEY_PATH="${TF_VAR_api_private_key_path}" 485 env.NODE_PUBLIC_KEY_PATH="${TF_VAR_ssh_public_key_path}" 486 env.OCI_COMPARTMENT_ID="${env.TF_VAR_compartment_id}" 487 env.WORKER_NODE_SUBNET="${env.SUBNET_ID}" 488 env.CONTROL_PLANE_SUBNET="${env.SUBNET_ID}" 489 env.LOAD_BALANCER_SUBNET="${env.LB_SUBNET_ID}" 490 491 // optional parameters 492 env.DOCKER_ROOT_DIR="${params.DOCKER_ROOT_DIR}" 493 env.ENABLE_CLUSTER_ALERTING="${params.ENABLE_CLUSTER_ALERTING}" 494 env.ENABLE_CLUSTER_MONITORING="${params.ENABLE_CLUSTER_MONITORING}" 495 env.ENABLE_NETWORK_POLICY="${params.ENABLE_NETWORK_POLICY}" 496 env.WINDOWS_PREFERRED_CLUSTER="${params.WINDOWS_PREFERRED_CLUSTER}" 497 env.CLUSTER_CIDR="${params.CLUSTER_CIDR}" 498 env.IMAGE_DISPLAY_NAME="${params.IMAGE_DISPLAY_NAME}" 499 env.IMAGE_ID="${params.IMAGE_ID}" 500 env.KUBERNETES_VERSION="${params.KUBERNETES_VERSION}" 501 env.OKE_CAPI_VERSION="${params.OKE_CAPI_VERSION}" 502 env.POD_CIDR="${params.POD_CIDR}" 503 env.USE_NODE_PV_ENCRYPTION="${params.USE_NODE_PV_ENCRYPTION}" 504 env.NODE_SHAPE="${params.NODE_SHAPE}" 505 env.NUM_WORKER_NODES="${params.NUM_WORKER_NODES}" 506 env.APPLY_YAMLS="${params.APPLY_YAMLS}" 507 } 508 509 def downloadCLI() { 510 script { 511 sh "echo Downloading VZ CLI from object storage" 512 sh """ 513 oci --region us-phoenix-1 os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_COMMIT_BUCKET} --name ephemeral/${env.BRANCH_NAME}/${SHORT_COMMIT_HASH}/${VZ_CLI_TARGZ} --file ${VZ_CLI_TARGZ} 514 tar xzf ${VZ_CLI_TARGZ} -C ${GO_REPO_PATH} 515 ${GO_REPO_PATH}/vz version 516 """ 517 } 518 } 519 520 // Either download the specified release of the platform operator YAML, or create one 521 // using the specific operator image provided by the user. 522 def getVerrazzanoOperatorYaml() { 523 script { 524 sh """ 525 echo "Platform Operator Configuration" 526 cd ${GO_REPO_PATH}/verrazzano 527 if [ "NONE" == "${params.VERRAZZANO_OPERATOR_IMAGE}" ]; then 528 echo "Downloading operator.yaml from branch ${env.BRANCH_NAME} for commit ${SHORT_COMMIT_HASH}" 529 oci --region us-phoenix-1 os object get --namespace ${OCI_OS_NAMESPACE} -bn ${OCI_OS_COMMIT_BUCKET} --name ephemeral/${env.BRANCH_NAME}/${SHORT_COMMIT_HASH}/operator.yaml --file ${OPERATOR_YAML_FILE} 530 else 531 echo "Generating operator.yaml based on image name provided: ${params.VERRAZZANO_OPERATOR_IMAGE}" 532 env IMAGE_PULL_SECRETS=verrazzano-container-registry DOCKER_IMAGE=${params.VERRAZZANO_OPERATOR_IMAGE} ./tools/scripts/generate_operator_yaml.sh > ${OPERATOR_YAML_FILE} 533 fi 534 """ 535 } 536 } 537 538 def performVerrazzanoDirectoryOperations() { 539 script { 540 sh """ 541 rm -rf ${GO_REPO_PATH}/verrazzano 542 mkdir -p ${GO_REPO_PATH}/verrazzano 543 tar cf - . | (cd ${GO_REPO_PATH}/verrazzano/ ; tar xf -) 544 """ 545 } 546 }