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
=== removed file '_integration-tests/tests/90_test_upgrade'
--- _integration-tests/tests/90_test_upgrade 2015-06-15 15:36:29 +0000
+++ _integration-tests/tests/90_test_upgrade 1970-01-01 00:00:00 +0000
@@ -1,45 +0,0 @@
1# Test that we can upgrade to the latest image version and roll back to the
2# original version. Test will be skipped the testbed does not offer reboot
3# (needs autopkgtest with a supporting runner).
4
5test() {
6 can_reboot || { echo "SKIP: cannot reboot testbed"; return; }
7
8 # debug
9 version_info
10 boot_info
11
12 if after_reboot; then
13 # second reboot: after rollback
14 if [ -e "${ADT_ARTIFACTS}/rolled_back" ]; then
15 orig_current=$(cat "${ADT_ARTIFACTS}/current")
16 [ "$orig_current" = "$current" ] || fail "did not roll back to version $orig_current ($all_versions)"
17 return
18 fi
19
20 # first reboot: after upgrade
21 orig_avail=$(cat "${ADT_ARTIFACTS}/avail")
22 [ "$orig_avail" = "$current" ] || fail "did not upgrade to current version $orig_avail != $current ($all_versions)"
23
24 echo "rolling back..."
25 sudo snappy rollback ubuntu-core
26 touch "${ADT_ARTIFACTS}/rolled_back"
27 reboot
28 return
29 fi
30
31 # fake new available version by doing a current--
32 switch_channel "s/build_number: $current/build_number: $((current-1))/"
33
34 # we should have something now :)
35 version_info
36
37 [ $avail -gt $current ] || fail "$avail is not newer than $current"
38
39 # save version for post-upgrade test
40 save_version_info $avail $current
41
42 echo "upgrading..."
43 sudo snappy update
44 reboot
45}
460
=== removed file '_integration-tests/tests/91_test_upgrade_from_stable_image'
--- _integration-tests/tests/91_test_upgrade_from_stable_image 2015-06-15 15:36:29 +0000
+++ _integration-tests/tests/91_test_upgrade_from_stable_image 1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
1# Test that we can upgrade from the latest *stable* image version to the
2# current edge image version and rollback original version.
3#
4# Make image for this with:
5#
6# $ sudo ubuntu-device-flash core --channel=stable 15.04 -o snappy-stable.img --developer-mode --enable-ssh
7#
8# Run with:
9# adt-run upgrade-test/ --- ssh -s snappy -- -i /path/to/snappy-stable.img
10
11test() {
12 can_reboot || { echo "SKIP: cannot reboot testbed"; return; }
13
14 # debug
15 version_info
16 boot_info
17
18 if after_reboot; then
19 # second reboot: after rollback
20 if [ -e "${ADT_ARTIFACTS}/rolled_back-stable" ]; then
21 orig_current=$(cat "${ADT_ARTIFACTS}/current")
22 [ "$orig_current" = "$current" ] || fail "did not roll back to version $orig_current ($all_versions)"
23 return
24 fi
25
26 # first reboot: after upgrade
27 orig_avail=$(cat "${ADT_ARTIFACTS}/avail")
28 [ "$orig_avail" = "$current" ] || fail "did not upgrade to current version ($all_versions)"
29
30 echo "rolling back..."
31 sudo snappy rollback ubuntu-core
32 touch "${ADT_ARTIFACTS}/rolled_back-stable"
33 reboot
34 return
35 fi
36
37 # switch channel
38 switch_channel 's#channel: ubuntu-core/\(.*\)/stable#channel: ubuntu-core/\1/edge#'
39
40 # now upgrade to latest edge from stable
41 version_info
42
43 [ $avail -gt $current ] || fail "$avail is not newer than $current"
44
45 # save version for post-upgrade test
46 save_version_info $avail $current
47
48 echo "upgrading..."
49 sudo snappy update
50 reboot
51}
520
=== modified file '_integration-tests/tests/common/common.go'
--- _integration-tests/tests/common/common.go 2015-07-16 00:12:27 +0000
+++ _integration-tests/tests/common/common.go 2015-07-17 15:34:51 +0000
@@ -254,7 +254,7 @@
254// rebooted.254// rebooted.
255func AfterReboot(c *check.C) bool {255func AfterReboot(c *check.C) bool {
256 // $ADT_REBOOT_MARK contains the reboot mark, if we have rebooted it'll be the test name256 // $ADT_REBOOT_MARK contains the reboot mark, if we have rebooted it'll be the test name
257 return CheckRebootMark(c.TestName())257 return strings.HasPrefix(os.Getenv("ADT_REBOOT_MARK"), c.TestName())
258}258}
259259
260// CheckRebootMark returns True if the reboot mark matches the string passed as260// CheckRebootMark returns True if the reboot mark matches the string passed as
261261
=== added file '_integration-tests/tests/latest/rollback_test.go'
--- _integration-tests/tests/latest/rollback_test.go 1970-01-01 00:00:00 +0000
+++ _integration-tests/tests/latest/rollback_test.go 2015-07-17 15:34:51 +0000
@@ -0,0 +1,52 @@
1// -*- Mode: Go; indent-tabs-mode: t -*-
2
3/*
4 * Copyright (C) 2015 Canonical Ltd
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 */
19
20package latest
21
22import (
23 "strconv"
24
25 . "../common"
26 check "gopkg.in/check.v1"
27)
28
29var _ = check.Suite(&rollbackSuite{})
30
31type rollbackSuite struct {
32 SnappySuite
33}
34
35func (s *rollbackSuite) TestRollbackMustRebootToOtherVersion(c *check.C) {
36 if BeforeReboot() {
37 CallFakeUpdate(c)
38 Reboot(c)
39 } else if CheckRebootMark(c.TestName()) {
40 RemoveRebootMark(c)
41 currentVersion := GetCurrentUbuntuCoreVersion(c)
42 c.Assert(currentVersion, check.Equals, GetSavedVersion(c)+1)
43 ExecCommand(c, "sudo", "snappy", "rollback", "ubuntu-core",
44 strconv.Itoa(GetSavedVersion(c)))
45 SetSavedVersion(c, currentVersion)
46 RebootWithMark(c, c.TestName()+"-rollback")
47 } else if CheckRebootMark(c.TestName() + "-rollback") {
48 RemoveRebootMark(c)
49 c.Assert(
50 GetCurrentUbuntuCoreVersion(c), check.Equals, GetSavedVersion(c)-1)
51 }
52}

Subscribers

People subscribed via source and target branches