diff options
author | Theodore Ts'o <tytso@mit.edu> | 2023-07-03 22:48:21 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2023-07-03 23:13:42 -0400 |
commit | 5a2b84764371f59f5cad91e1c391d4dd2cf3da01 (patch) | |
tree | d95fd984fb0c518ec714f7177d1030926defb239 | |
parent | 1c347c58c31926d0dda62146f1e3d55dfa9c850d (diff) | |
download | xfstests-bld-5a2b84764371f59f5cad91e1c391d4dd2cf3da01.tar.gz |
test-appliance: add support for continuing after a VM is preempted
We can determine whether the VM was preempted by querying the metadata
server in the 30 seconds grace period after VM is preempted. If that
is the case hint that this is happened by setting the file
/results/preempted. Then when the system is restarted, have
runtests.sh detect that this happened and restart the test was running
at the time the VM was preempted.
Also teach gce-xfstests the new subcommand simulate-maintenance-event.
This can be used to test a preemptible VM by using the command
"gce-xfstests simulate-maintenance-event <VM-NAME>". Then after the
VM has stopped, then resume the VM using the command "gce-xfstests
start <VM-NAME>".
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rwxr-xr-x | run-fstests/gce-xfstests | 9 | ||||
-rwxr-xr-x | test-appliance/files/etc/acpi/powerbtn-acpi-support.sh | 11 | ||||
-rwxr-xr-x | test-appliance/files/root/runtests.sh | 16 | ||||
-rwxr-xr-x | test-appliance/files/usr/local/sbin/gce-shutdown | 6 | ||||
-rw-r--r-- | test-appliance/gce-xfstests-bld.sh | 3 |
5 files changed, 37 insertions, 8 deletions
diff --git a/run-fstests/gce-xfstests b/run-fstests/gce-xfstests index 4caa14cd..7f1b0742 100755 --- a/run-fstests/gce-xfstests +++ b/run-fstests/gce-xfstests @@ -276,6 +276,15 @@ case "$1" in done exit 0 ;; + simulate-maintenance-event) + shift + for i in "$@" + do + run_gcloud compute -q instances simulate-maintenance-event "$i" \ + --zone $(get_gce_zone "$i") & + done + exit 0 + ;; ls-disks|ls-disk) run_gcloud compute disks list exit $? diff --git a/test-appliance/files/etc/acpi/powerbtn-acpi-support.sh b/test-appliance/files/etc/acpi/powerbtn-acpi-support.sh index 04e16831..8f20f738 100755 --- a/test-appliance/files/etc/acpi/powerbtn-acpi-support.sh +++ b/test-appliance/files/etc/acpi/powerbtn-acpi-support.sh @@ -1,7 +1,18 @@ #!/bin/bash +logger powerbtn-acpi-support.sh started + +preempted="$(curl "http://metadata.google.internal/computeMetadata/v1/instance/preempted" -H "Metadata-Flavor: Google")" +if test "$preempted" = "TRUE" +then + logger "VM preempted" + touch /results/preempted + /sbin/poweroff +fi + touch /run/powerbtn if test -e /usr/local/sbin/gce-shutdown then + logger initiating gce-shutdown from powerbtn-acpi-support.sh /usr/local/sbin/gce-shutdown fi diff --git a/test-appliance/files/root/runtests.sh b/test-appliance/files/root/runtests.sh index 23b2b280..d178d40a 100755 --- a/test-appliance/files/root/runtests.sh +++ b/test-appliance/files/root/runtests.sh @@ -624,7 +624,16 @@ do /root/xfstests/bin/syncfs "$RESULT_BASE" gce_run_hooks pre-xfstests $TC $j if test -n "$RUN_ONCE" ; then - if test -f "$RESULT_BASE/completed" + if test -f "/results/preempted" + then + rm -f "/results/preempted" + if test -f "$RESULT_BASE/completed" + then + # Backup and restart the test that was interrupted + head -n -2 "$RESULT_BASE/completed" > /tmp/completed + mv /tmp/completed "$RESULT_BASE/completed" + fi + elif test -f "$RESULT_BASE/completed" then last_test="$(tail -n 1 "$RESULT_BASE/completed")" @@ -637,11 +646,6 @@ do copy_xunit_results fi /root/xfstests/bin/syncfs $RESULT_BASE - - # this was part of the in-progress preemption work, - # removing for now as it conflicts with the crash recovery stuff - # head -n -2 "$RESULT_BASE/completed" > /tmp/completed - # mv /tmp/completed "$RESULT_BASE/completed" else touch "$RESULT_BASE/completed" fi diff --git a/test-appliance/files/usr/local/sbin/gce-shutdown b/test-appliance/files/usr/local/sbin/gce-shutdown index 0ca1d328..6e3a8ac6 100755 --- a/test-appliance/files/usr/local/sbin/gce-shutdown +++ b/test-appliance/files/usr/local/sbin/gce-shutdown @@ -90,7 +90,7 @@ then REPORT_EMAIL=$(gce_attribute report_email) run_hooks send-email - if test -n "$REPORT_EMAIL" -a -n "$SENDGRID_API_KEY" -a ! -f /run/powerbtn + if test -n "$REPORT_EMAIL" -a -n "$SENDGRID_API_KEY" then if test -s /results/report then @@ -99,6 +99,10 @@ then RESULTS_REPORT=/results/runtests.log fi subj="$suite results $TESTRUNID - $(uname -r)" + if test -f /run/powerbtn + then + subj="$subj - test run aborted" + fi if test -z "$GCE_REPORT_SENDER" then GCE_REPORT_SENDER="$USER@$HOSTNAME" diff --git a/test-appliance/gce-xfstests-bld.sh b/test-appliance/gce-xfstests-bld.sh index 2c054d0f..6e1188f2 100644 --- a/test-appliance/gce-xfstests-bld.sh +++ b/test-appliance/gce-xfstests-bld.sh @@ -19,7 +19,8 @@ F2FS_TOOLS="@F2FS_TOOLS@" # Hardcoded go version GO_VERSION=1.17.6 -PACKAGES="bash-completion \ +PACKAGES="acpid \ + bash-completion \ bc \ bison \ blktrace \ |