Debian Codegraph @

launcher/image/test/test_debug_cloudbuild.yaml

raw
1 substitutions:
2 '_IMAGE_NAME': ''
3 '_IMAGE_PROJECT': ''
4 '_CLEANUP': 'true'
5 '_VM_NAME_PREFIX': 'cs-debug-test'
6 '_ZONE': 'us-central1-a'
7 '_CC': ''
8 '_WORKLOAD_IMAGE': 'us-west1-docker.pkg.dev/confidential-space-images-dev/cs-integ-test-images/basic-test:latest,tee-cmd=["newCmd"],tee-env-ALLOWED_OVERRIDE=overridden'
9 steps:
10 - name: 'gcr.io/cloud-builders/gcloud'
11 id: CreateVM
12 entrypoint: 'bash'
13 env:
14 - 'BUILD_ID=$BUILD_ID'
15 args: ['create_vm.sh','-i', '${_IMAGE_NAME}',
16 '-p', '${_IMAGE_PROJECT}',
17 '-m', 'tee-image-reference=${_WORKLOAD_IMAGE},tee-container-log-redirect=true',
18 '-n', '${_VM_NAME_PREFIX}-${BUILD_ID}',
19 '-z', '${_ZONE}',
20 '-c', '${_CC}',
21 ]
22 - name: 'gcr.io/cloud-builders/gcloud'
23 id: BasicWorkloadTest
24 entrypoint: 'bash'
25 args: ['scripts/test_launcher_workload.sh', '${_VM_NAME_PREFIX}-${BUILD_ID}', '${_ZONE}']
26 - name: 'gcr.io/cloud-builders/gcloud'
27 id: BasicWorkloadTestCloudLogging
28 entrypoint: 'bash'
29 env:
30 - 'PROJECT_ID=$PROJECT_ID'
31 args: ['scripts/test_launcher_workload_cloudlogging.sh', '${_VM_NAME_PREFIX}-${BUILD_ID}']
32 - name: 'gcr.io/cloud-builders/gcloud'
33 id: ChangeMDSVariables
34 entrypoint: 'bash'
35 args: ['util/change_metadata_vars.sh',
36 '-n', '${_VM_NAME_PREFIX}-${BUILD_ID}',
37 '-z', '${_ZONE}',
38 '-m', 'tee-image-reference=gcr.io/cloudrun/hello:latest',
39 ]
40 - name: 'gcr.io/cloud-builders/gcloud'
41 id: ChangeMDSVariablesTest
42 entrypoint: 'bash'
43 args: ['scripts/test_mds_var_change.sh', '${_VM_NAME_PREFIX}-${BUILD_ID}', '${_ZONE}']
44 - name: 'gcr.io/cloud-builders/gcloud'
45 id: CheckDebugVMAliveAfterLauncherExits
46 script: |
47 #!/usr/bin/env bash
48 set -euo pipefail
49
50 # Waiting for 2.5 mins, after the workload is finished.
51 # If using a debug image, the VM should still be accessible after
52 # the workload exit normally.
53 # Check the script: launcher/image/exit_script.sh for detail logic.
54 sleep 150
55
56 result=$(gcloud compute instances list --filter="name=(${_VM_NAME_PREFIX}-${BUILD_ID})" --zones=${_ZONE} --format="value(STATUS)")
57
58 if [[ "${result}" == "RUNNING" ]]; then
59 echo "verified debug VM is still running after 2.5 mins"
60 else
61 echo "FAILED: expect debug VM to be still running"
62 echo "TEST FAILED. Expect debug VM to be still running" > /workspace/status.txt
63 fi
64 automapSubstitutions: true
65 - name: 'gcr.io/cloud-builders/gcloud'
66 id: CleanUp
67 entrypoint: 'bash'
68 env:
69 - 'CLEANUP=$_CLEANUP'
70 args: ['cleanup.sh', '${_VM_NAME_PREFIX}-${BUILD_ID}', '${_ZONE}']
71 # Must come after cleanup.
72 - name: 'gcr.io/cloud-builders/gcloud'
73 id: CheckFailure
74 entrypoint: 'bash'
75 env:
76 - 'BUILD_ID=$BUILD_ID'
77 args: ['check_failure.sh']
78
79 options:
80 pool:
81 name: 'projects/confidential-space-images-dev/locations/us-west1/workerPools/cs-image-build-vpc'