Merge lp:~mvo/snappy/selftest-failover into lp:~mvo/snappy/snappy-selftest-snap

Proposed by Michael Vogt on 2015-05-08
Status: Superseded
Proposed branch: lp:~mvo/snappy/selftest-failover
Merge into: lp:~mvo/snappy/snappy-selftest-snap
Prerequisite: lp:~mvo/snappy/selftest-upgrade-rollback
Diff against target: 138 lines (+78/-6)
4 files modified
tests/07_test_install_framework (+3/-1)
tests/80_test_failover (+70/-0)
tests/90_test_upgrade (+3/-3)
tests/91_test_upgrade_from_stable_image (+2/-2)
To merge this branch: bzr merge lp:~mvo/snappy/selftest-failover
Reviewer Review Type Date Requested Status
Snappy Developers 2015-05-08 Pending
Review via email: mp+258655@code.launchpad.net

Description of the Change

Test that failover from a broken partition to a good partition works as expected, ugly but should be a good starting point.

To test run:
$ adt-run upgrade-test/ --- ssh -s snappy -- -i ~/path/to/snappy.img

There is too much code duplication between 80_, 90_, 91_ right now so best is probably to use this as the starting point for a cleanup branch.

To post a comment you must log in.
lp:~mvo/snappy/selftest-failover updated on 2015-05-21
45. By Michael Vogt on 2015-05-09

tests/07_test_install_framework: revert incorrect debug change (thanks Steve!)

46. By Michael Vogt on 2015-05-21

README: fix README

47. By Michael Vogt on 2015-05-21

extract common code into common.sh and cleanup

48. By Michael Vogt on 2015-05-21

improve debug output if upgrade/downgrade/failover fails

49. By Michael Vogt on 2015-05-21

merged lp:snappy/selftest

50. By Michael Vogt on 2015-05-21

prepare for BBB auto tests

51. By Michael Vogt on 2015-05-21

tests/common.sh: typo fix

52. By Michael Vogt on 2015-05-21

README: document how to run on a BBB

Unmerged revisions

52. By Michael Vogt on 2015-05-21

README: document how to run on a BBB

51. By Michael Vogt on 2015-05-21

tests/common.sh: typo fix

50. By Michael Vogt on 2015-05-21

prepare for BBB auto tests

49. By Michael Vogt on 2015-05-21

merged lp:snappy/selftest

48. By Michael Vogt on 2015-05-21

improve debug output if upgrade/downgrade/failover fails

47. By Michael Vogt on 2015-05-21

extract common code into common.sh and cleanup

46. By Michael Vogt on 2015-05-21

README: fix README

45. By Michael Vogt on 2015-05-09

tests/07_test_install_framework: revert incorrect debug change (thanks Steve!)

44. By Michael Vogt on 2015-05-08

add basic test for failover

43. By Michael Vogt on 2015-05-08

add upgrade test for stable->edge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/07_test_install_framework'
2--- tests/07_test_install_framework 2015-05-08 15:54:20 +0000
3+++ tests/07_test_install_framework 2015-05-08 15:54:20 +0000
4@@ -1,7 +1,9 @@
5 test() {
6 if after_reboot; then
7 # ensure the service comes up after a reboot
8- services=$(systemctl | grep "${framework}_.*.service")
9+ services="$(systemctl)"
10+ echo "$services"
11+ echo "$services" | grep "${framework}_.*.service"
12 [ -n "$services" ] || fail "$framework provided no services"
13 return
14 fi
15
16=== added file 'tests/80_test_failover'
17--- tests/80_test_failover 1970-01-01 00:00:00 +0000
18+++ tests/80_test_failover 2015-05-08 15:54:20 +0000
19@@ -0,0 +1,70 @@
20+# Test that we rollback on failed upgrades
21+# (needs autopkgtest with a supporting runner).
22+
23+test() {
24+ can_reboot || { echo "SKIP: cannot reboot testbed"; return; }
25+
26+ versions=$(snappy list)
27+ current=$(echo "$versions" | awk '/^ubuntu-core/ {print $3}')
28+ echo "original current snappy version: $current"
29+
30+ # debug
31+ echo "Boot order"
32+ grep root=LABEL /boot/grub/grub.cfg
33+ cat /boot/grub/grubenv
34+
35+ if after_reboot; then
36+ # reboot: ensure we booted back into original
37+ orig_current=$(cat $ADT_ARTIFACTS/current)
38+ if [ "$orig_current" != "$current" ]; then
39+ fail "did not failover to good version (\"$orig_current\" != \"$current\")"
40+ fi
41+
42+ # FIXME: grep log(other partition) for the crash to ensure it
43+ # really worked
44+ # FIXME2: reboot again as regression test for #1449904
45+
46+ # we booted, cleanup the panic for the next tests to work
47+ sudo mount -o remount,rw /writable/cache/system
48+ sudo rm /writable/cache/system/etc/rc.local
49+ return
50+ fi
51+
52+ # fake new available version by doing a current--
53+ sudo mount -o remount,rw /
54+ sudo sed -i "s/build_number: $current/build_number: $((current-1))/" /etc/system-image/channel.ini
55+ sudo mount -o remount,ro /
56+
57+ if [ -e /writable/cache/system/etc/system-image/channel.ini ]; then
58+ sudo mount -o remount,rw /writable/cache/system/
59+ sudo sed -i 's/build_number: $current/build_number: $((current-1))/' /writable/cache/system/etc/system-image/channel.ini
60+ sudo mount -o remount,ro /writable/cache/system/
61+ fi
62+
63+ # we should have something now :)
64+ versions=$(snappy list)
65+ current=$(echo "$versions" | awk '/^ubuntu-core/ {print $3}')
66+ echo "faked current snappy version: $current"
67+
68+ versions=$(snappy list -u)
69+ avail=$(echo "$versions" | awk '/^ubuntu-core/ {print $3}')
70+ echo "available snappy version to upgrade: $avail"
71+
72+ # skip if not numeric, e. g. "-"
73+ [ "$avail" != "${avail#[0-9]}" ] || { echo "SKIP: no image to upgrade to"; return; }
74+
75+ [ $avail -gt $current ] || fail "$avail is not newer than $current"
76+
77+ # save version for post-upgrade test
78+ echo "$avail" > $ADT_ARTIFACTS/avail
79+ echo "$current" > $ADT_ARTIFACTS/current
80+
81+ echo "upgrading..."
82+ sudo snappy update
83+
84+ # break the upgrade
85+ sudo mount -o remount,rw /writable/cache/system/
86+ printf "#!/bin/sh\nprintf c > /proc/sysrq-trigger" | sudo tee /writable/cache/system/etc/rc.local
87+
88+ reboot
89+}
90
91=== modified file 'tests/90_test_upgrade'
92--- tests/90_test_upgrade 2015-05-08 15:54:20 +0000
93+++ tests/90_test_upgrade 2015-05-08 15:54:20 +0000
94@@ -6,7 +6,7 @@
95 can_reboot || { echo "SKIP: cannot reboot testbed"; return; }
96
97 versions=$(snappy list)
98- current=$(echo "$versions" | awk '/ubuntu-core/ {print $3}')
99+ current=$(echo "$versions" | awk '/^ubuntu-core/ {print $3}')
100 echo "original current snappy version: $current"
101
102 # debug
103@@ -45,11 +45,11 @@
104
105 # we should have something now :)
106 versions=$(snappy list)
107- current=$(echo "$versions" | awk '/ubuntu-core/ {print $3}')
108+ current=$(echo "$versions" | awk '/^ubuntu-core/ {print $3}')
109 echo "faked current snappy version: $current"
110
111 versions=$(snappy list -u)
112- avail=$(echo "$versions" | awk '/ubuntu-core/ {print $3}')
113+ avail=$(echo "$versions" | awk '/^ubuntu-core/ {print $3}')
114 echo "available snappy version to upgrade: $avail"
115
116 # skip if not numeric, e. g. "-"
117
118=== modified file 'tests/91_test_upgrade_from_stable_image'
119--- tests/91_test_upgrade_from_stable_image 2015-05-08 15:54:20 +0000
120+++ tests/91_test_upgrade_from_stable_image 2015-05-08 15:54:20 +0000
121@@ -12,7 +12,7 @@
122 can_reboot || { echo "SKIP: cannot reboot testbed"; return; }
123
124 versions=$(snappy list)
125- current=$(echo "$versions" | awk '/ubuntu-core/ {print $3}')
126+ current=$(echo "$versions" | awk '/^ubuntu-core/ {print $3}')
127 echo "original current snappy version: $current"
128
129 # debug
130@@ -51,7 +51,7 @@
131
132 # now upgrade to latest edge from stable
133 versions=$(snappy list -u)
134- avail=$(echo "$versions" | awk '/ubuntu-core/ {print $3}')
135+ avail=$(echo "$versions" | awk '/^ubuntu-core/ {print $3}')
136 echo "available snappy version to upgrade: $avail"
137
138 # skip if not numeric, e. g. "-"

Subscribers

People subscribed via source and target branches

to all changes: