| 1 |
#!/bin/bash |
| 2 |
set -euo pipefail |
| 3 |
|
| 4 |
echo 'Running multi-writer PD test' |
| 5 |
|
| 6 |
# grep -z reads the whole input, and -v inverts matches. |
| 7 |
from_src_image=$(gcloud beta compute disks create --image-family confidential-space --image-project confidential-space-images --multi-writer test-multi-writer-img --zone us-west1-a 2>&1 || true) |
| 8 |
if echo "$from_src_image" | grep -vz 'Cannot create a multi-writer disk from a source image'; then |
| 9 |
echo "$from_src_image" |
| 10 |
echo 'Multi-writer PD creation from image source enabled.' |
| 11 |
echo 'TEST FAILED.' > /workspace/status.txt |
| 12 |
fi |
| 13 |
|
| 14 |
DISK_NAME="source-boot-disk-$BUILD_ID" |
| 15 |
echo "Creating PD $DISK_NAME" |
| 16 |
gcloud compute disks create --image-family confidential-space --image-project confidential-space-images $DISK_NAME --zone us-west1-a |
| 17 |
|
| 18 |
from_src_disk=$(gcloud beta compute disks create test-multi-writer-disk --source-disk=$DISK_NAME --multi-writer --zone us-west1-a 2>&1 || true) |
| 19 |
# Cleanup disk before seeing test result. |
| 20 |
gcloud compute disks delete $DISK_NAME -q --zone us-west1-a |
| 21 |
if echo "$from_src_disk" | grep -vz 'Cannot create a multi-writer disk from a source disk'; then |
| 22 |
echo "$from_src_disk" |
| 23 |
echo 'Multi-writer PD creation from boot disk source enabled.' |
| 24 |
echo 'TEST FAILED.' > /workspace/status.txt |
| 25 |
fi |