Debian Codegraph @

launcher/image/test/test_ingress_network.yaml

raw
1 # This test needs to be run in a private Cloud Build pool, so the Cloud Build instance
2 # can be in the same network as the test VM.
3 substitutions:
4 '_IMAGE_NAME': ''
5 '_IMAGE_PROJECT': ''
6 '_CLEANUP': 'true'
7 '_ZONE': 'asia-east1-a'
8 '_WORKLOAD_IMAGE': 'docker.io/library/nginx:latest'
9
10 steps:
11 - name: 'gcr.io/cloud-builders/gcloud'
12 id: CreateServerWorkload
13 entrypoint: 'bash'
14 env:
15 - 'BUILD_ID=$BUILD_ID'
16 args: ['create_vm.sh','-i', '${_IMAGE_NAME}',
17 '-p', '${_IMAGE_PROJECT}',
18 '-m', 'tee-image-reference=${_WORKLOAD_IMAGE}',
19 '-n', 'ingress-network-test-${BUILD_ID}',
20 '-z', '${_ZONE}',
21 ]
22
23 - name: 'gcr.io/cloud-builders/gcloud'
24 id: CheckReachability
25 waitFor: ['CreateServerWorkload']
26 entrypoint: 'bash'
27 args:
28 - -c
29 - |
30 echo "sleeping 200s, waiting for workload server to setup..."
31 sleep 200
32 internalIP=$(gcloud -q compute instances describe ingress-network-test-${BUILD_ID} --zone=${_ZONE} --format='get(networkInterfaces[0].networkIP)')
33 echo "workload internal IP: "${internalIP}
34
35 # try to connect to the nginx server
36 response=$(curl -v ${internalIP}:80)
37 echo "got response [${response}]"
38
39 # check nginx default response
40 if [[ "${response}" == *"Welcome to nginx!"* ]];
41 then
42 echo "workload reachable through the internal network"
43 else
44 echo "FAILED: workload not reachable through the internal network"
45 echo 'TEST FAILED' > /workspace/status.txt
46 fi
47
48 - name: 'gcr.io/cloud-builders/gcloud'
49 id: CleanUp
50 waitFor: ['CheckReachability']
51 entrypoint: 'bash'
52 env:
53 - 'CLEANUP=$_CLEANUP'
54 args: ['cleanup.sh', 'ingress-network-test-${BUILD_ID}', '${_ZONE}']
55
56 # Must come after cleanup.
57 - name: 'gcr.io/cloud-builders/gcloud'
58 id: CheckFailure
59 waitFor: ['CleanUp']
60 entrypoint: 'bash'
61 env:
62 - 'BUILD_ID=$BUILD_ID'
63 args: ['check_failure.sh']
64
65 options:
66 pool:
67 name: 'projects/confidential-space-images-dev/locations/us-west1/workerPools/cs-image-build-vpc'