Merge lp:~elopio/snappy/test_go_rollback into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by Leo Arias
Status: Merged
Approved by: Leo Arias
Approved revision: 588
Merged at revision: 589
Proposed branch: lp:~elopio/snappy/test_go_rollback
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Diff against target: 175 lines (+53/-97)
4 files modified
_integration-tests/tests/90_test_upgrade (+0/-45)
_integration-tests/tests/91_test_upgrade_from_stable_image (+0/-51)
_integration-tests/tests/common/common.go (+1/-1)
_integration-tests/tests/latest/rollback_test.go (+52/-0)
To merge this branch: bzr merge lp:~elopio/snappy/test_go_rollback
Reviewer Review Type Date Requested Status
Federico Gimenez (community) Approve
Review via email: mp+265082@code.launchpad.net

Commit message

Added an integration test for a fake rollback. Removed the shell test that used to do it.

To post a comment you must log in.
Revision history for this message
Federico Gimenez (fgimenez) wrote :

Nice +1, I'm getting the following error from one of the remaining shell tests, probably expected:

****** Running ./_integration-tests/tests/91_test_upgrade_from_stable_image
current version: 110
available version: 110
Boot order
set cmdline="root=LABEL=$label ro init=/lib/systemd/systemd console=ttyS0 console=tty1 panic=-1"
snappy_mode=regular
snappy_ab=a
---
current version: 110
available version: 110
ERROR 110 is not newer than 110
FAILED: ./_integration-tests/tests/91_test_upgrade_from_stable_image

review: Approve
lp:~elopio/snappy/test_go_rollback updated
588. By Leo Arias

Also remove the dependent 91 test.

Revision history for this message
Leo Arias (elopio) wrote :

Thanks for catching that.

<elopio> fgimenez: ugh, that 91 tests depends on the 90 test. Are you ok if I just remove both?
<fgimenez> elopio, sure
<elopio> 91 in this case will just do a fake update, which we already have. And the 15.04_to_rolling branch fully replaces 91.
<fgimenez> elopio, yes, it's already covered

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file '_integration-tests/tests/90_test_upgrade'
2--- _integration-tests/tests/90_test_upgrade 2015-06-15 15:36:29 +0000
3+++ _integration-tests/tests/90_test_upgrade 1970-01-01 00:00:00 +0000
4@@ -1,45 +0,0 @@
5-# Test that we can upgrade to the latest image version and roll back to the
6-# original version. Test will be skipped the testbed does not offer reboot
7-# (needs autopkgtest with a supporting runner).
8-
9-test() {
10- can_reboot || { echo "SKIP: cannot reboot testbed"; return; }
11-
12- # debug
13- version_info
14- boot_info
15-
16- if after_reboot; then
17- # second reboot: after rollback
18- if [ -e "${ADT_ARTIFACTS}/rolled_back" ]; then
19- orig_current=$(cat "${ADT_ARTIFACTS}/current")
20- [ "$orig_current" = "$current" ] || fail "did not roll back to version $orig_current ($all_versions)"
21- return
22- fi
23-
24- # first reboot: after upgrade
25- orig_avail=$(cat "${ADT_ARTIFACTS}/avail")
26- [ "$orig_avail" = "$current" ] || fail "did not upgrade to current version $orig_avail != $current ($all_versions)"
27-
28- echo "rolling back..."
29- sudo snappy rollback ubuntu-core
30- touch "${ADT_ARTIFACTS}/rolled_back"
31- reboot
32- return
33- fi
34-
35- # fake new available version by doing a current--
36- switch_channel "s/build_number: $current/build_number: $((current-1))/"
37-
38- # we should have something now :)
39- version_info
40-
41- [ $avail -gt $current ] || fail "$avail is not newer than $current"
42-
43- # save version for post-upgrade test
44- save_version_info $avail $current
45-
46- echo "upgrading..."
47- sudo snappy update
48- reboot
49-}
50
51=== removed file '_integration-tests/tests/91_test_upgrade_from_stable_image'
52--- _integration-tests/tests/91_test_upgrade_from_stable_image 2015-06-15 15:36:29 +0000
53+++ _integration-tests/tests/91_test_upgrade_from_stable_image 1970-01-01 00:00:00 +0000
54@@ -1,51 +0,0 @@
55-# Test that we can upgrade from the latest *stable* image version to the
56-# current edge image version and rollback original version.
57-#
58-# Make image for this with:
59-#
60-# $ sudo ubuntu-device-flash core --channel=stable 15.04 -o snappy-stable.img --developer-mode --enable-ssh
61-#
62-# Run with:
63-# adt-run upgrade-test/ --- ssh -s snappy -- -i /path/to/snappy-stable.img
64-
65-test() {
66- can_reboot || { echo "SKIP: cannot reboot testbed"; return; }
67-
68- # debug
69- version_info
70- boot_info
71-
72- if after_reboot; then
73- # second reboot: after rollback
74- if [ -e "${ADT_ARTIFACTS}/rolled_back-stable" ]; then
75- orig_current=$(cat "${ADT_ARTIFACTS}/current")
76- [ "$orig_current" = "$current" ] || fail "did not roll back to version $orig_current ($all_versions)"
77- return
78- fi
79-
80- # first reboot: after upgrade
81- orig_avail=$(cat "${ADT_ARTIFACTS}/avail")
82- [ "$orig_avail" = "$current" ] || fail "did not upgrade to current version ($all_versions)"
83-
84- echo "rolling back..."
85- sudo snappy rollback ubuntu-core
86- touch "${ADT_ARTIFACTS}/rolled_back-stable"
87- reboot
88- return
89- fi
90-
91- # switch channel
92- switch_channel 's#channel: ubuntu-core/\(.*\)/stable#channel: ubuntu-core/\1/edge#'
93-
94- # now upgrade to latest edge from stable
95- version_info
96-
97- [ $avail -gt $current ] || fail "$avail is not newer than $current"
98-
99- # save version for post-upgrade test
100- save_version_info $avail $current
101-
102- echo "upgrading..."
103- sudo snappy update
104- reboot
105-}
106
107=== modified file '_integration-tests/tests/common/common.go'
108--- _integration-tests/tests/common/common.go 2015-07-16 00:12:27 +0000
109+++ _integration-tests/tests/common/common.go 2015-07-17 15:34:51 +0000
110@@ -254,7 +254,7 @@
111 // rebooted.
112 func AfterReboot(c *check.C) bool {
113 // $ADT_REBOOT_MARK contains the reboot mark, if we have rebooted it'll be the test name
114- return CheckRebootMark(c.TestName())
115+ return strings.HasPrefix(os.Getenv("ADT_REBOOT_MARK"), c.TestName())
116 }
117
118 // CheckRebootMark returns True if the reboot mark matches the string passed as
119
120=== added file '_integration-tests/tests/latest/rollback_test.go'
121--- _integration-tests/tests/latest/rollback_test.go 1970-01-01 00:00:00 +0000
122+++ _integration-tests/tests/latest/rollback_test.go 2015-07-17 15:34:51 +0000
123@@ -0,0 +1,52 @@
124+// -*- Mode: Go; indent-tabs-mode: t -*-
125+
126+/*
127+ * Copyright (C) 2015 Canonical Ltd
128+ *
129+ * This program is free software: you can redistribute it and/or modify
130+ * it under the terms of the GNU General Public License version 3 as
131+ * published by the Free Software Foundation.
132+ *
133+ * This program is distributed in the hope that it will be useful,
134+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
135+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
136+ * GNU General Public License for more details.
137+ *
138+ * You should have received a copy of the GNU General Public License
139+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
140+ *
141+ */
142+
143+package latest
144+
145+import (
146+ "strconv"
147+
148+ . "../common"
149+ check "gopkg.in/check.v1"
150+)
151+
152+var _ = check.Suite(&rollbackSuite{})
153+
154+type rollbackSuite struct {
155+ SnappySuite
156+}
157+
158+func (s *rollbackSuite) TestRollbackMustRebootToOtherVersion(c *check.C) {
159+ if BeforeReboot() {
160+ CallFakeUpdate(c)
161+ Reboot(c)
162+ } else if CheckRebootMark(c.TestName()) {
163+ RemoveRebootMark(c)
164+ currentVersion := GetCurrentUbuntuCoreVersion(c)
165+ c.Assert(currentVersion, check.Equals, GetSavedVersion(c)+1)
166+ ExecCommand(c, "sudo", "snappy", "rollback", "ubuntu-core",
167+ strconv.Itoa(GetSavedVersion(c)))
168+ SetSavedVersion(c, currentVersion)
169+ RebootWithMark(c, c.TestName()+"-rollback")
170+ } else if CheckRebootMark(c.TestName() + "-rollback") {
171+ RemoveRebootMark(c)
172+ c.Assert(
173+ GetCurrentUbuntuCoreVersion(c), check.Equals, GetSavedVersion(c)-1)
174+ }
175+}

Subscribers

People subscribed via source and target branches