summaryrefslogtreecommitdiff
diff options
authorJonathan Cave <jonathan.cave@canonical.com>2020-04-16 19:00:05 +0100
committerJonathan Cave <jonathan.cave@canonical.com>2020-04-16 19:00:05 +0100
commit956bfa670980bd7a195857e252231c096038b738 (patch)
tree344f67874f33bf6406c4bf9a89b96ea69a7aafb0
parent46902e8884e8c4a14d027caf5eeafa72df5400e4 (diff)
power-management: add failed service checks
After running tests that cause the device to reboot, check for any failed services. Could be pertinent to the watchdog test where the shutdown is not manageed.
-rwxr-xr-xbin/failed_service_check.sh11
-rw-r--r--units/power-management/jobs.pxu20
-rw-r--r--units/power-management/test-plan.pxu2
-rw-r--r--units/watchdog/jobs.pxu10
-rw-r--r--units/watchdog/test-plan.pxu1
5 files changed, 44 insertions, 0 deletions
diff --git a/bin/failed_service_check.sh b/bin/failed_service_check.sh
new file mode 100755
index 00000000..172f20a8
--- /dev/null
+++ b/bin/failed_service_check.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+COUNT=$(systemctl --system --no-ask-password --no-pager --no-legend list-units --state=failed | wc -l)
+printf "Found %s failed units\n" "$COUNT"
+if [ "$COUNT" -eq 0 ]; then
+ exit 0
+else
+ printf "\nFailed units:\n"
+ systemctl --system --no-ask-password --no-pager list-units --state=failed
+fi
+exit 1
diff --git a/units/power-management/jobs.pxu b/units/power-management/jobs.pxu
index 36e31c2a..a84f0045 100644
--- a/units/power-management/jobs.pxu
+++ b/units/power-management/jobs.pxu
@@ -290,6 +290,16 @@ user: root
flags: preserve-locale noreturn autorestart
estimated_duration: 180.0
+id: power-management/post-warm-reboot
+after: power-management/warm-reboot
+category_id: com.canonical.plainbox::power-management
+_summary: Post warm reboot service check
+_description: Check there are no failed services after the warm reboot
+unit: job
+plugin: shell
+command: failed_service_check.sh
+estimated_duration: 1.0
+
id: power-management/cold-reboot
category_id: com.canonical.plainbox::power-management
_summary: Cold reboot
@@ -307,6 +317,16 @@ user: root
flags: preserve-locale noreturn autorestart
estimated_duration: 300
+id: power-management/post-cold-reboot
+after: power-management/cold-reboot
+category_id: com.canonical.plainbox::power-management
+_summary: Post cold reboot service check
+_description: Check there are no failed services after the cold reboot
+unit: job
+plugin: shell
+command: failed_service_check.sh
+estimated_duration: 1.0
+
unit: template
template-resource: model_assertion
template-unit: job
diff --git a/units/power-management/test-plan.pxu b/units/power-management/test-plan.pxu
index bb782c10..8391bca5 100644
--- a/units/power-management/test-plan.pxu
+++ b/units/power-management/test-plan.pxu
@@ -75,7 +75,9 @@ _name: Automated power tests
_description: Automated power tests for Snappy Ubuntu Core devices
include:
power-management/warm-reboot
+ power-management/post-warm-reboot
power-management/cold-reboot
+ power-management/post-cold-reboot
id: power-manual
unit: test plan
diff --git a/units/watchdog/jobs.pxu b/units/watchdog/jobs.pxu
index 2b5b236c..3247941e 100644
--- a/units/watchdog/jobs.pxu
+++ b/units/watchdog/jobs.pxu
@@ -65,3 +65,13 @@ user: root
plugin: shell
category_id: com.canonical.plainbox::power-management
estimated_duration: 60
+
+id: watchdog/post-trigger-system-reset-auto
+after: watchdog/trigger-system-reset-auto
+category_id: com.canonical.plainbox::power-management
+_summary: Post watchdog reset service check
+_description: Check there are no failed services after the watchdog triggered
+unit: job
+plugin: shell
+command: failed_service_check.sh
+estimated_duration: 1.0
diff --git a/units/watchdog/test-plan.pxu b/units/watchdog/test-plan.pxu
index 407a2734..6de8e710 100644
--- a/units/watchdog/test-plan.pxu
+++ b/units/watchdog/test-plan.pxu
@@ -25,3 +25,4 @@ estimated_duration: 1s
include:
watchdog/systemd-config
watchdog/trigger-system-reset-auto
+ watchdog/post-trigger-system-reset-auto