Debian Codegraph @

launcher/image/test/scripts/test_log_redirect.sh

raw
1 #!/bin/bash
2 set -euxo pipefail
3 source util/read_serial.sh
4 source util/read_cloud_logging.sh
5
6 # Allow VM some time to boot and start the workload.
7 sleep 150
8
9 output=""
10 if [[ "$1" == "serial" ]]; then
11 echo "Reading from serial console for VM $3 in zone $4"
12 output=$(read_serial $3 $4)
13 elif [[ "$1" == "cloud_logging" ]]; then
14 echo "Reading from cloud logging for VM $3"
15 output=$(read_cloud_logging $3)
16 else
17 echo "Usage: test_log_redirect.sh <serial|cloud_logging> <expectLogs=true|false> <VM_NAME> <ZONE>"
18 return 1
19 fi
20
21 if [[ $output != *"Token looks okay"* ]] && [[ "$2" == "true" ]]; then
22 echo "FAILED: did not find workload logs in $1, but expected to:"
23 echo $output
24 echo 'TEST FAILED.' > /workspace/status.txt
25 elif [[ $output == *"Token looks okay"* ]] && [[ "$2" == "false" ]]; then
26 echo "FAILED: found workload logs in $1, but did not expect to:"
27 echo $output
28 echo 'TEST FAILED.' > /workspace/status.txt
29 fi
30