github.com/verrazzano/verrazzano@v1.7.1/ci/oke-capi-cluster-driver/Jenkinsfile (about) 1 // Copyright (c) 2023, 2024, 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-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 VZ_CLI_TARGZ="vz-linux-amd64.tar.gz" 194 195 // used to emit metrics 196 PROMETHEUS_CREDENTIALS = credentials('prometheus-credentials') 197 TEST_ENV = "OKE" 198 TEST_ENV_LABEL = "magicdns_oke" 199 200 // used to generate Ginkgo test reports 201 TEST_REPORT = "test-report.xml" 202 GINKGO_REPORT_ARGS = "--junit-report=${TEST_REPORT} --keep-separate-reports=true" 203 TEST_REPORT_DIR = "${WORKSPACE}/tests/e2e" 204 205 OPERATOR_YAML_FILE = "${WORKSPACE}/acceptance-test-operator.yaml" 206 207 // For Ginkgo test 208 OKE_CAPI_CLUSTER_NAME_SUFFIX = "${OKECAPIClusterNameSuffix}" 209 OKE_VERSIONS = "v1.27.2, v1.26.7, v1.26.2, v1.25.12, v1.25.4" 210 } 211 212 stages { 213 stage('Clean workspace and checkout') { 214 steps { 215 sh """ 216 echo "${NODE_LABELS}" 217 """ 218 219 script { 220 EFFECTIVE_DUMP_K8S_CLUSTER_ON_SUCCESS = getEffectiveDumpOnSuccess() 221 if (params.GIT_COMMIT_TO_USE == "NONE") { 222 echo "Specific GIT commit was not specified, use current head" 223 def scmInfo = checkout scm 224 env.GIT_COMMIT = scmInfo.GIT_COMMIT 225 env.GIT_BRANCH = scmInfo.GIT_BRANCH 226 } else { 227 echo "SCM checkout of ${params.GIT_COMMIT_TO_USE}" 228 def scmInfo = checkout([ 229 $class: 'GitSCM', 230 branches: [[name: params.GIT_COMMIT_TO_USE]], 231 doGenerateSubmoduleConfigurations: false, 232 extensions: [], 233 submoduleCfg: [], 234 userRemoteConfigs: [[url: env.SCM_VERRAZZANO_GIT_URL]]]) 235 env.GIT_COMMIT = scmInfo.GIT_COMMIT 236 env.GIT_BRANCH = scmInfo.GIT_BRANCH 237 // If the commit we were handed is not what the SCM says we are using, fail 238 if (!env.GIT_COMMIT.equals(params.GIT_COMMIT_TO_USE)) { 239 echo "SCM didn't checkout the commit we expected. Expected: ${params.GIT_COMMIT_TO_USE}, Found: ${scmInfo.GIT_COMMIT}" 240 exit 1 241 } 242 } 243 echo "SCM checkout of ${env.GIT_BRANCH} at ${env.GIT_COMMIT}" 244 } 245 246 sh """ 247 cp -f "${NETRC_FILE}" $HOME/.netrc 248 chmod 600 $HOME/.netrc 249 """ 250 251 script { 252 try { 253 sh """ 254 echo "${DOCKER_CREDS_PSW}" | docker login ${env.DOCKER_REPO} -u ${DOCKER_CREDS_USR} --password-stdin 255 """ 256 } catch(error) { 257 echo "docker login failed, retrying after sleep" 258 retry(4) { 259 sleep(30) 260 sh """ 261 echo "${DOCKER_CREDS_PSW}" | docker login ${env.DOCKER_REPO} -u ${DOCKER_CREDS_USR} --password-stdin 262 """ 263 } 264 } 265 } 266 sh """ 267 rm -rf ${GO_REPO_PATH}/verrazzano 268 mkdir -p ${GO_REPO_PATH}/verrazzano 269 tar cf - . | (cd ${GO_REPO_PATH}/verrazzano/ ; tar xf -) 270 """ 271 272 script { 273 def props = readProperties file: '.verrazzano-development-version' 274 VERRAZZANO_DEV_VERSION = props['verrazzano-development-version'] 275 TIMESTAMP = sh(returnStdout: true, script: "date +%Y%m%d%H%M%S").trim() 276 SHORT_COMMIT_HASH = sh(returnStdout: true, script: "git rev-parse --short=8 HEAD").trim() 277 DOCKER_IMAGE_TAG = "${VERRAZZANO_DEV_VERSION}-${TIMESTAMP}-${SHORT_COMMIT_HASH}" 278 // update the description with some meaningful info 279 setDisplayName() 280 currentBuild.description = params.KUBERNETES_CLUSTER_VERSION + " : " + SHORT_COMMIT_HASH + " : " + env.GIT_COMMIT + " : " + params.GIT_COMMIT_TO_USE 281 282 // derive the prefix for the OKE cluster 283 OKE_CLUSTER_PREFIX = sh(returnStdout: true, script: "${WORKSPACE}/ci/scripts/derive_oke_cluster_name.sh").trim() 284 } 285 script { 286 sh """ 287 echo "Downloading VZ CLI from object storage" 288 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} 289 tar xzf ${VZ_CLI_TARGZ} -C ${GO_REPO_PATH} 290 ${GO_REPO_PATH}/vz version 291 """ 292 } 293 } 294 } 295 296 stage("Create OKE Cluster") { 297 steps { 298 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" 299 } 300 } 301 302 stage('Install Verrazzano') { 303 steps { 304 sh """ 305 # Create image pull secret for Verrazzano docker images 306 cd ${GO_REPO_PATH}/verrazzano 307 ./tests/e2e/config/scripts/create-image-pull-secret.sh "${IMAGE_PULL_SECRET}" "${DOCKER_REPO}" "${DOCKER_CREDS_USR}" "${DOCKER_CREDS_PSW}" 308 ./tests/e2e/config/scripts/create-image-pull-secret.sh github-packages "${DOCKER_REPO}" "${DOCKER_CREDS_USR}" "${DOCKER_CREDS_PSW}" 309 ./tests/e2e/config/scripts/create-image-pull-secret.sh ocr "${DOCKER_REPO}" "${DOCKER_CREDS_USR}" "${DOCKER_CREDS_PSW}" 310 311 echo "Download Platform Operator" 312 if [ "NONE" = "${VERRAZZANO_OPERATOR_IMAGE}" ]; then 313 echo "Using operator.yaml from object storage" 314 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 315 cp ${WORKSPACE}/downloaded-operator.yaml ${WORKSPACE}/acceptance-test-operator.yaml 316 else 317 echo "Generating operator.yaml based on image name provided: ${VERRAZZANO_OPERATOR_IMAGE}" 318 env IMAGE_PULL_SECRETS=verrazzano-container-registry DOCKER_IMAGE=${VERRAZZANO_OPERATOR_IMAGE} ./tools/scripts/generate_operator_yaml.sh > ${WORKSPACE}/acceptance-test-operator.yaml 319 fi 320 321 echo "Create the verrazzano-install namespace" 322 kubectl create namespace verrazzano-install 323 324 # create secret in verrazzano-install ns 325 ./tests/e2e/config/scripts/create-image-pull-secret.sh "${IMAGE_PULL_SECRET}" "${DOCKER_REPO}" "${DOCKER_CREDS_USR}" "${DOCKER_CREDS_PSW}" "verrazzano-install" 326 ./tests/e2e/config/scripts/process_nipio_install_yaml.sh ${INSTALL_CONFIG_FILE} 327 328 echo "Installing Verrazzano on OKE" 329 ${VZ_COMMAND} install --filename ${INSTALL_CONFIG_FILE} --manifests ${WORKSPACE}/acceptance-test-operator.yaml --timeout 45m 330 """ 331 } 332 post { 333 always { 334 archiveArtifacts artifacts: "acceptance-test-operator.yaml,downloaded-operator.yaml", allowEmptyArchive: true 335 } 336 success { 337 script { 338 if (EFFECTIVE_DUMP_K8S_CLUSTER_ON_SUCCESS == true) { 339 dumpK8sCluster('verrazzano-install-cluster-dump') 340 } 341 } 342 } 343 failure { 344 script { 345 dumpK8sCluster('verrazzano-install-failure-cluster-dump') 346 sh """ 347 mkdir -p ${WORKSPACE}/verrazzano-platform-operator/scripts/install/build/logs 348 ${LOOPING_TEST_SCRIPTS_DIR}/dump_resources.sh > ${WORKSPACE}/verrazzano-platform-operator/scripts/install/build/logs/resources.log 349 """ 350 } 351 } 352 } 353 } 354 355 stage("OKE CAPI Cluster Driver Tests") { 356 steps { 357 script { 358 // Required environment variables for running the oke-capi-driver Ginkgo test suite 359 env.TF_VAR_label_prefix="${OKE_CLUSTER_PREFIX}" 360 setUpEnvVarsForOKECAPIClusterCreation() 361 362 runGinkgo('clusterapi/oke-capi-driver') 363 } 364 } 365 post { 366 always { 367 archiveArtifacts artifacts: '**/coverage.html,**/logs/*,**/test-cluster-dumps/**', allowEmptyArchive: true 368 } 369 aborted { 370 script { 371 dumpK8sCluster('oke-capi-cluster-driver-cluster-dump') 372 } 373 } 374 failure { 375 script { 376 dumpK8sCluster('oke-capi-cluster-driver-cluster-dump') 377 } 378 } 379 success { 380 script { 381 if (EFFECTIVE_DUMP_K8S_CLUSTER_ON_SUCCESS == true) { 382 dumpK8sCluster('oke-capi-cluster-driver-cluster-dump') 383 } 384 } 385 } 386 } 387 } 388 } 389 390 post { 391 always { 392 sh """ 393 # Copy the generated test reports to WORKSPACE to archive them 394 mkdir -p ${TEST_REPORT_DIR} 395 cd ${GO_REPO_PATH}/verrazzano/tests/e2e 396 find . -name "${TEST_REPORT}" | cpio -pdm ${TEST_REPORT_DIR} 397 """ 398 archiveArtifacts artifacts: "**/oke_kubeconfig,**/coverage.html,**/logs/**,**/build/resources/**,**/verrazzano_images.txt,**/*full-cluster*/**,**/bug-report/**,**/${TEST_REPORT}", allowEmptyArchive: true 399 junit testResults: "**/${TEST_REPORT}", allowEmptyResults: true 400 } 401 failure { 402 script { 403 archiveArtifacts artifacts: '**/oke_kubeconfig,**/coverage.html,**/logs/**,**/build/resources/**,**/verrazzano_images.txt,**/*full-cluster*/**,**/bug-report/**', allowEmptyArchive: true 404 } 405 } 406 cleanup { 407 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" 408 deleteDir() 409 } 410 } 411 } 412 413 def dumpK8sCluster(dumpDirectory) { 414 sh """ 415 ${GO_REPO_PATH}/verrazzano/ci/scripts/capture_cluster_snapshot.sh ${dumpDirectory} 416 """ 417 } 418 419 def getEffectiveDumpOnSuccess() { 420 def effectiveValue = params.DUMP_K8S_CLUSTER_ON_SUCCESS 421 if (FORCE_DUMP_K8S_CLUSTER_ON_SUCCESS.equals("true") && (env.BRANCH_NAME.equals("master"))) { 422 effectiveValue = true 423 echo "Forcing dump on success based on global override setting" 424 } 425 return effectiveValue 426 } 427 428 def setDisplayName() { 429 echo "Start setDisplayName" 430 def causes = currentBuild.getBuildCauses() 431 echo "causes: " + causes.toString() 432 for (cause in causes) { 433 def causeString = cause.toString() 434 echo "current cause: " + causeString 435 if (causeString.contains("UpstreamCause") && causeString.contains("Started by upstream project")) { 436 echo "This job was caused by " + causeString 437 if (causeString.contains("verrazzano-periodic-triggered-tests")) { 438 currentBuild.displayName = env.BUILD_NUMBER + " : PERIODIC" 439 } else if (causeString.contains("verrazzano-flaky-tests")) { 440 currentBuild.displayName = env.BUILD_NUMBER + " : FLAKY" 441 } 442 } 443 } 444 echo "End setDisplayName" 445 } 446 447 def createImagePullSecrets() { 448 sh """ 449 # Create image pull secrets for Verrazzano docker images 450 cd ${WORKSPACE} 451 ./tests/e2e/config/scripts/create-image-pull-secret.sh "${IMAGE_PULL_SECRET}" "${GHCR_REPO}" "${GITHUB_PKGS_CREDS_USR}" "${GITHUB_PKGS_CREDS_PSW}" 452 ./tests/e2e/config/scripts/create-image-pull-secret.sh github-packages "${GHCR_REPO}" "${GITHUB_PKGS_CREDS_USR}" "${GITHUB_PKGS_CREDS_PSW}" 453 ./tests/e2e/config/scripts/create-image-pull-secret.sh ocr "${OCR_REPO}" "${OCR_CREDS_USR}" "${OCR_CREDS_PSW}" 454 """ 455 } 456 457 // Run the OKE CAPI Cluster Driver Ginkgo test suite, passing in some parameters 458 def runGinkgo(testSuitePath) { 459 catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { 460 sh """ 461 echo Starting the OKE CAPI cluster driver tests 462 cd ${WORKSPACE}/tests/e2e 463 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} 464 """ 465 } 466 } 467 468 def setUpEnvVarsForOKECAPIClusterCreation() { 469 sh "echo Setting up inputs for the OKE CAPI cluster driver tests" 470 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() 471 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() 472 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() 473 474 // required environment variables for the Ginkgo test suite 475 env.OCI_REGION="${env.TF_VAR_region}" 476 env.OCI_VCN_ID="${env.VCN_ID}" 477 env.OCI_USER_ID="${env.TF_VAR_user_id}" 478 env.OCI_TENANCY_ID="${env.TF_VAR_tenancy_id}" 479 env.OCI_CREDENTIALS_FINGERPRINT="${env.TF_VAR_api_fingerprint}" 480 env.OCI_PRIVATE_KEY_PATH="${TF_VAR_api_private_key_path}" 481 env.NODE_PUBLIC_KEY_PATH="${TF_VAR_ssh_public_key_path}" 482 env.OCI_COMPARTMENT_ID="${env.TF_VAR_compartment_id}" 483 env.WORKER_NODE_SUBNET="${env.SUBNET_ID}" 484 env.CONTROL_PLANE_SUBNET="${env.SUBNET_ID}" 485 env.LOAD_BALANCER_SUBNET="${env.LB_SUBNET_ID}" 486 487 // optional parameters 488 env.DOCKER_ROOT_DIR="${params.DOCKER_ROOT_DIR}" 489 env.ENABLE_CLUSTER_ALERTING="${params.ENABLE_CLUSTER_ALERTING}" 490 env.ENABLE_CLUSTER_MONITORING="${params.ENABLE_CLUSTER_MONITORING}" 491 env.ENABLE_NETWORK_POLICY="${params.ENABLE_NETWORK_POLICY}" 492 env.WINDOWS_PREFERRED_CLUSTER="${params.WINDOWS_PREFERRED_CLUSTER}" 493 env.CLUSTER_CIDR="${params.CLUSTER_CIDR}" 494 env.IMAGE_DISPLAY_NAME="${params.IMAGE_DISPLAY_NAME}" 495 env.IMAGE_ID="${params.IMAGE_ID}" 496 env.KUBERNETES_VERSION="${params.KUBERNETES_VERSION}" 497 env.OKE_CAPI_VERSION="${params.OKE_CAPI_VERSION}" 498 env.POD_CIDR="${params.POD_CIDR}" 499 env.USE_NODE_PV_ENCRYPTION="${params.USE_NODE_PV_ENCRYPTION}" 500 env.NODE_SHAPE="${params.NODE_SHAPE}" 501 env.NUM_WORKER_NODES="${params.NUM_WORKER_NODES}" 502 env.APPLY_YAMLS="${params.APPLY_YAMLS}" 503 } 504 505 def downloadCLI() { 506 script { 507 sh "echo Downloading VZ CLI from object storage" 508 sh """ 509 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} 510 tar xzf ${VZ_CLI_TARGZ} -C ${GO_REPO_PATH} 511 ${GO_REPO_PATH}/vz version 512 """ 513 } 514 } 515 516 // Either download the specified release of the platform operator YAML, or create one 517 // using the specific operator image provided by the user. 518 def getVerrazzanoOperatorYaml() { 519 script { 520 sh """ 521 echo "Platform Operator Configuration" 522 cd ${GO_REPO_PATH}/verrazzano 523 if [ "NONE" == "${params.VERRAZZANO_OPERATOR_IMAGE}" ]; then 524 echo "Downloading operator.yaml from branch ${env.BRANCH_NAME} for commit ${SHORT_COMMIT_HASH}" 525 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} 526 else 527 echo "Generating operator.yaml based on image name provided: ${params.VERRAZZANO_OPERATOR_IMAGE}" 528 env IMAGE_PULL_SECRETS=verrazzano-container-registry DOCKER_IMAGE=${params.VERRAZZANO_OPERATOR_IMAGE} ./tools/scripts/generate_operator_yaml.sh > ${OPERATOR_YAML_FILE} 529 fi 530 """ 531 } 532 } 533 534 def performVerrazzanoDirectoryOperations() { 535 script { 536 sh """ 537 rm -rf ${GO_REPO_PATH}/verrazzano 538 mkdir -p ${GO_REPO_PATH}/verrazzano 539 tar cf - . | (cd ${GO_REPO_PATH}/verrazzano/ ; tar xf -) 540 """ 541 } 542 }