Merge lp:~elopio/snappy/15.04_to_rolling-3 into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by Leo Arias
Status: Superseded
Proposed branch: lp:~elopio/snappy/15.04_to_rolling-3
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Prerequisite: lp:~elopio/snappy/test_go_info
Diff against target: 396 lines (+244/-18) (has conflicts)
5 files modified
_integration-tests/main.go (+74/-6)
_integration-tests/tests/common/common.go (+90/-10)
_integration-tests/tests/latest/info_test.go (+74/-0)
_integration-tests/tests/update/update_test.go (+1/-1)
run-checks (+5/-1)
Text conflict in _integration-tests/main.go
Text conflict in _integration-tests/tests/common/common.go
Text conflict in _integration-tests/tests/latest/info_test.go
To merge this branch: bzr merge lp:~elopio/snappy/15.04_to_rolling-3
Reviewer Review Type Date Requested Status
Snappy Developers Pending
Review via email: mp+264938@code.launchpad.net

This proposal supersedes a proposal from 2015-07-15.

This proposal has been superseded by a proposal from 2015-07-16.

To post a comment you must log in.
lp:~elopio/snappy/15.04_to_rolling-3 updated
588. By Leo Arias

Fixed the regexps.

589. By Leo Arias

Various fixes.

590. By Leo Arias

Updated comments and logs.

591. By Leo Arias

Merge

592. By Leo Arias

Better not replace the version yet.

593. By Leo Arias

Reverted the last change.

594. By Leo Arias

Only execute the setup if there is no reboot in progress.

595. By Leo Arias

Added a comment to Config.

596. By Leo Arias

Use the installed snappy for the update.

597. By Leo Arias

Moved the update tests to the latest package.

598. By Leo Arias

Renamed the latest package to cmd.

599. By Leo Arias

Added the isInRebootProcess method.

600. By Leo Arias

Use a map for the regex.

601. By Leo Arias

Moved the examples from run-checks to the README.

602. By Leo Arias

Merged with trunk.

603. By Leo Arias

Renamed the packages.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '_integration-tests/main.go'
--- _integration-tests/main.go 2015-07-15 15:53:51 +0000
+++ _integration-tests/main.go 2015-07-16 00:24:47 +0000
@@ -64,6 +64,7 @@
64 buildSnappyCLI(arch)64 buildSnappyCLI(arch)
65 }65 }
66 buildTests(arch)66 buildTests(arch)
67<<<<<<< TREE
67}68}
6869
69func writeTestConfig(release, channel string) {70func writeTestConfig(release, channel string) {
@@ -88,6 +89,38 @@
8889
89 // Run the tests on the latest rolling edge image.90 // Run the tests on the latest rolling edge image.
90 if imageName, err := img.UdfCreate(); err == nil {91 if imageName, err := img.UdfCreate(); err == nil {
92=======
93}
94
95func writeTestConfig(release, channel, targetRelease, targetChannel string) {
96 fmt.Println("Writing test config...")
97 testConfig := map[string]string{
98 "release": release,
99 "channel": channel,
100 }
101 if targetRelease != "" {
102 testConfig["targetRelease"] = targetRelease
103 }
104 if targetChannel != "" {
105 testConfig["targetChannel"] = targetChannel
106 }
107 fmt.Println(testConfig)
108 encoded, err := json.Marshal(testConfig)
109 if err != nil {
110 log.Fatalf("Error encoding the test config: %v", testConfig)
111 }
112 ioutil.WriteFile(configFileName, encoded, 0644)
113}
114
115func setupAndRunLocalTests(rootPath, testFilter string, img image.Image) {
116 var includeShell bool
117 if testFilter == "" {
118 includeShell = true
119 }
120
121 // Run the tests on the latest rolling edge image.
122 if imageName, err := img.UdfCreate(); err == nil {
123>>>>>>> MERGE-SOURCE
91 adtRun(rootPath, testFilter, testPackages,124 adtRun(rootPath, testFilter, testPackages,
92 kvmSSHOptions(imageName), includeShell)125 kvmSSHOptions(imageName), includeShell)
93 }126 }
@@ -228,16 +261,30 @@
228 "SSH port of the testbed. Defaults to use port "+strconv.Itoa(defaultSSHPort))261 "SSH port of the testbed. Defaults to use port "+strconv.Itoa(defaultSSHPort))
229 testFilter = flag.String("filter", "",262 testFilter = flag.String("filter", "",
230 "Suites or tests to run, for instance MyTestSuite, MyTestSuite.FirstCustomTest or MyTestSuite.*CustomTest")263 "Suites or tests to run, for instance MyTestSuite, MyTestSuite.FirstCustomTest or MyTestSuite.*CustomTest")
231 imgRelease = flag.String("release", defaultRelease,264<<<<<<< TREE
232 "Release of the image to be built, defaults to "+defaultRelease)265 imgRelease = flag.String("release", defaultRelease,
233 imgChannel = flag.String("channel", defaultChannel,266 "Release of the image to be built, defaults to "+defaultRelease)
234 "Channel of the image to be built, defaults to "+defaultChannel)267 imgChannel = flag.String("channel", defaultChannel,
235 imgRevision = flag.String("revision", "",268 "Channel of the image to be built, defaults to "+defaultChannel)
236 "Revision of the image to be built (can be relative to the latest available revision in the given release and channel as in -1), defaults to the empty string")269 imgRevision = flag.String("revision", "",
270 "Revision of the image to be built (can be relative to the latest available revision in the given release and channel as in -1), defaults to the empty string")
271=======
272 imgRelease = flag.String("release", defaultRelease,
273 "Release of the image to be built, defaults to "+defaultRelease)
274 imgChannel = flag.String("channel", defaultChannel,
275 "Channel of the image to be built, defaults to "+defaultChannel)
276 imgRevision = flag.String("revision", "",
277 "Revision of the image to be built (can be relative to the latest available revision in the given release and channel as in -1), defaults to the empty string")
278 targetRelease = flag.String("target-release", "",
279 "If specified, the image will be updated to this release before running the tests.")
280 targetChannel = flag.String("target-channel", "",
281 "If specified, the image will be updated to this channel before running the tests.")
282>>>>>>> MERGE-SOURCE
237 )283 )
238284
239 flag.Parse()285 flag.Parse()
240286
287<<<<<<< TREE
241 buildAssets(*useSnappyFromBranch, *arch)288 buildAssets(*useSnappyFromBranch, *arch)
242289
243 // TODO: generate the files out of the source tree. --elopio - 2015-07-15290 // TODO: generate the files out of the source tree. --elopio - 2015-07-15
@@ -257,4 +304,25 @@
257 } else {304 } else {
258 setupAndRunRemoteTests(rootPath, *testFilter, *testbedIP, *testbedPort)305 setupAndRunRemoteTests(rootPath, *testFilter, *testbedIP, *testbedPort)
259 }306 }
307=======
308 buildAssets(*useSnappyFromBranch, *arch)
309
310 // TODO: generate the files out of the source tree. --elopio - 2015-07-15
311 utils.PrepareTargetDir(dataOutputDir)
312 defer os.RemoveAll(dataOutputDir)
313
314 // TODO: pass the config as arguments to the test binaries.
315 // --elopio - 2015-07-15
316 writeTestConfig(*imgRelease, *imgChannel, *targetRelease, *targetChannel)
317
318 rootPath := getRootPath()
319
320 if *testbedIP == "" {
321 img := image.NewImage(*imgRelease, *imgChannel, *imgRevision, baseDir)
322 setupAndRunLocalTests(rootPath, *testFilter, *img)
323
324 } else {
325 setupAndRunRemoteTests(rootPath, *testFilter, *testbedIP, *testbedPort)
326 }
327>>>>>>> MERGE-SOURCE
260}328}
261329
=== 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-16 00:24:47 +0000
@@ -20,6 +20,7 @@
20package common20package common
2121
22import (22import (
23 "encoding/json"
23 "fmt"24 "fmt"
24 "io/ioutil"25 "io/ioutil"
25 "os"26 "os"
@@ -39,6 +40,8 @@
39 channelCfgFile = "/etc/system-image/channel.ini"40 channelCfgFile = "/etc/system-image/channel.ini"
40)41)
4142
43var Config map[string]string
44
42// SnappySuite is a structure used as a base test suite for all the snappy45// SnappySuite is a structure used as a base test suite for all the snappy
43// integration tests.46// integration tests.
44type SnappySuite struct {47type SnappySuite struct {
@@ -50,6 +53,19 @@
50func (s *SnappySuite) SetUpSuite(c *check.C) {53func (s *SnappySuite) SetUpSuite(c *check.C) {
51 ExecCommand(c, "sudo", "systemctl", "stop", "snappy-autopilot.timer")54 ExecCommand(c, "sudo", "systemctl", "stop", "snappy-autopilot.timer")
52 ExecCommand(c, "sudo", "systemctl", "disable", "snappy-autopilot.timer")55 ExecCommand(c, "sudo", "systemctl", "disable", "snappy-autopilot.timer")
56 if CheckRebootMark("") {
57 Config = readConfig(c)
58 targetRelease, _ := Config["targetRelease"]
59 targetChannel, _ := Config["targetChannel"]
60 if targetRelease != "" || targetChannel != "" {
61 switchSystemImageConf(c, targetRelease, targetChannel, "0")
62 if CallUpdate(c) {
63 RebootWithMark(c, c.TestName()+"-setupsuite-update")
64 }
65 }
66 } else if CheckRebootMark(c.TestName() + "-setupsuite-update") {
67 RemoveRebootMark(c)
68 }
53}69}
5470
55// SetUpTest handles reboots and stores version information. It will run before71// SetUpTest handles reboots and stores version information. It will run before
@@ -112,6 +128,59 @@
112 s.cleanupHandlers = append(s.cleanupHandlers, f)128 s.cleanupHandlers = append(s.cleanupHandlers, f)
113}129}
114130
131func readConfig(c *check.C) map[string]string {
132 b, err := ioutil.ReadFile("_integration-tests/data/output/testconfig.json")
133 c.Assert(
134 err, check.IsNil, check.Commentf("Failed to read test config: %v", err))
135
136 var decoded map[string]string
137 err = json.Unmarshal(b, &decoded)
138 c.Assert(
139 err, check.IsNil, check.Commentf("Failed to decode test config: %v", err))
140 return decoded
141}
142
143func switchSystemImageConf(c *check.C, release, channel, version string) {
144 targets := []string{"/", BaseOtherPath}
145 for _, target := range targets {
146 file := filepath.Join(target, channelCfgFile)
147 if _, err := os.Stat(file); err == nil {
148 MakeWritable(c, target)
149 defer MakeReadonly(c, target)
150 replaceSystemImageValues(c, file, release, channel, version)
151 }
152 }
153}
154
155func replaceSystemImageValues(c *check.C, file, release, channel, version string) {
156 c.Log("Switching the system image conf...")
157 regex := []string{}
158 if release != "" {
159 regex = append(regex,
160 fmt.Sprintf(
161 `s#channel: ubuntu-core/.*/\(.*\)#channel: ubuntu-core/%s/\1#`,
162 release))
163 }
164 if channel != "" {
165 regex = append(regex,
166 fmt.Sprintf(
167 `s#channel: ubuntu-core/\(.*\)/.*#channel: ubuntu-core/\1/%s#`,
168 channel))
169 }
170 if version != "" {
171 regex = append(regex,
172 fmt.Sprintf(
173 `s/build_number: .*/build_number: %s/`,
174 version))
175 }
176 for i := range regex {
177 ExecCommand(c,
178 "sudo", "sed", "-i", regex[i], file)
179 }
180 // Leave the new file in the test log.
181 ExecCommand(c, "cat", file)
182}
183
115func channelCfgBackupFile() string {184func channelCfgBackupFile() string {
116 return filepath.Join(os.Getenv("ADT_ARTIFACTS"), "channel.ini")185 return filepath.Join(os.Getenv("ADT_ARTIFACTS"), "channel.ini")
117}186}
@@ -168,17 +237,28 @@
168 return version237 return version
169}238}
170239
171// CallUpdate executes an snappy update. If there is no update available, the240// CallUpdate executes an snappy update. It returns true if an update was
172// channel version will be modified to fake an update.241// installed and it is waiting for a reboot to be activated.
173func CallUpdate(c *check.C) {242func CallUpdate(c *check.C) bool {
174 c.Log("Calling snappy update...")243 c.Log("Calling snappy update...")
175 output := ExecCommand(c, "sudo", "snappy", "update")244 output := ExecCommand(c, "sudo", "snappy", "update")
176 // XXX Instead of trying the update, we should have a command to tell us245 // XXX Instead of trying the update, we should have a command to tell us
177 // if there is an available update. --elopio - 2015-07-01246 // if there is an available update. --elopio - 2015-07-01
247<<<<<<< TREE
178 if output == "" {248 if output == "" {
179 c.Log("There is no update available.")249 c.Log("There is no update available.")
180 CallFakeUpdate(c)250 CallFakeUpdate(c)
181 }251 }
252=======
253 return output != ""
254}
255
256// CallFakeUpdate calls snappy update after faking the current version
257func CallFakeUpdate(c *check.C) {
258 c.Log("Preparing fake and calling update.")
259 fakeAvailableUpdate(c)
260 ExecCommand(c, "sudo", "snappy", "update")
261>>>>>>> MERGE-SOURCE
182}262}
183263
184// CallFakeUpdate calls snappy update after faking the current version264// CallFakeUpdate calls snappy update after faking the current version
@@ -190,12 +270,17 @@
190270
191func fakeAvailableUpdate(c *check.C) {271func fakeAvailableUpdate(c *check.C) {
192 c.Log("Faking an available update...")272 c.Log("Faking an available update...")
273<<<<<<< TREE
193 currentVersion := GetCurrentUbuntuCoreVersion(c)274 currentVersion := GetCurrentUbuntuCoreVersion(c)
194 switchChannelVersion(c, currentVersion, currentVersion-1)275 switchChannelVersion(c, currentVersion, currentVersion-1)
276=======
277 currentVersion := GetCurrentUbuntuCoreVersion(c)
278 switchChannelVersionWithBackup(c, currentVersion-1)
279>>>>>>> MERGE-SOURCE
195 SetSavedVersion(c, currentVersion-1)280 SetSavedVersion(c, currentVersion-1)
196}281}
197282
198func switchChannelVersion(c *check.C, oldVersion, newVersion int) {283func switchChannelVersionWithBackup(c *check.C, newVersion int) {
199 m := make(map[string]string)284 m := make(map[string]string)
200 m["/"] = channelCfgBackupFile()285 m["/"] = channelCfgBackupFile()
201 m[BaseOtherPath] = channelCfgOtherBackupFile()286 m[BaseOtherPath] = channelCfgOtherBackupFile()
@@ -206,12 +291,7 @@
206 defer MakeReadonly(c, target)291 defer MakeReadonly(c, target)
207 // Back up the file. It will be restored during the test tear down.292 // Back up the file. It will be restored during the test tear down.
208 ExecCommand(c, "cp", file, backup)293 ExecCommand(c, "cp", file, backup)
209 ExecCommand(c,294 replaceSystemImageValues(c, file, "", "", strconv.Itoa(newVersion))
210 "sudo", "sed", "-i",
211 fmt.Sprintf(
212 "s/build_number: %d/build_number: %d/g",
213 oldVersion, newVersion),
214 file)
215 }295 }
216 }296 }
217}297}
218298
=== modified file '_integration-tests/tests/latest/info_test.go'
--- _integration-tests/tests/latest/info_test.go 2015-07-15 15:18:22 +0000
+++ _integration-tests/tests/latest/info_test.go 2015-07-16 00:24:47 +0000
@@ -1,3 +1,4 @@
1<<<<<<< TREE
1// -*- Mode: Go; indent-tabs-mode: t -*-2// -*- Mode: Go; indent-tabs-mode: t -*-
23
3/*4/*
@@ -84,3 +85,76 @@
84 ".*"85 ".*"
85 c.Assert(infoOutput, check.Matches, expected)86 c.Assert(infoOutput, check.Matches, expected)
86}87}
88=======
89// -*- Mode: Go; indent-tabs-mode: t -*-
90
91/*
92 * Copyright (C) 2015 Canonical Ltd
93 *
94 * This program is free software: you can redistribute it and/or modify
95 * it under the terms of the GNU General Public License version 3 as
96 * published by the Free Software Foundation.
97 *
98 * This program is distributed in the hope that it will be useful,
99 * but WITHOUT ANY WARRANTY; without even the implied warranty of
100 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
101 * GNU General Public License for more details.
102 *
103 * You should have received a copy of the GNU General Public License
104 * along with this program. If not, see <http://www.gnu.org/licenses/>.
105 *
106 */
107
108package latest
109
110import (
111 "fmt"
112
113 . "../common"
114
115 check "gopkg.in/check.v1"
116)
117
118var _ = check.Suite(&infoSuite{})
119
120type infoSuite struct {
121 SnappySuite
122}
123
124func (s *infoSuite) TestInfoMustPrintReleaseAndChannel(c *check.C) {
125 infoOutput := ExecCommand(c, "snappy", "info")
126
127 expected := "(?ms)" +
128 fmt.Sprintf("^release: ubuntu-core/%s/%s\n", Config["release"], Config["channel"]) +
129 ".*"
130
131 c.Assert(infoOutput, check.Matches, expected)
132}
133
134func (s *infoSuite) TestInfoMustPrintInstalledApps(c *check.C) {
135 InstallSnap(c, "hello-world")
136 s.AddCleanup(func() {
137 RemoveSnap(c, "hello-world")
138 })
139 infoOutput := ExecCommand(c, "snappy", "info")
140
141 expected := "(?ms)" +
142 ".*" +
143 "^apps: .*hello-world.*\n"
144 c.Assert(infoOutput, check.Matches, expected)
145}
146
147func (s *infoSuite) TestInfoMustPrintInstalledFrameworks(c *check.C) {
148 InstallSnap(c, "hello-dbus-fwk.canonical")
149 s.AddCleanup(func() {
150 RemoveSnap(c, "hello-dbus-fwk.canonical")
151 })
152 infoOutput := ExecCommand(c, "snappy", "info")
153
154 expected := "(?ms)" +
155 ".*" +
156 "^frameworks: .*hello-dbus-fwk.*\n" +
157 ".*"
158 c.Assert(infoOutput, check.Matches, expected)
159}
160>>>>>>> MERGE-SOURCE
87161
=== modified file '_integration-tests/tests/update/update_test.go'
--- _integration-tests/tests/update/update_test.go 2015-07-14 15:16:59 +0000
+++ _integration-tests/tests/update/update_test.go 2015-07-16 00:24:47 +0000
@@ -41,7 +41,7 @@
41// be up-to-date after running this test.41// be up-to-date after running this test.
42func (s *updateSuite) TestUpdateToSameReleaseAndChannel(c *C) {42func (s *updateSuite) TestUpdateToSameReleaseAndChannel(c *C) {
43 if BeforeReboot() {43 if BeforeReboot() {
44 CallUpdate(c)44 CallFakeUpdate(c)
45 Reboot(c)45 Reboot(c)
46 } else if AfterReboot(c) {46 } else if AfterReboot(c) {
47 RemoveRebootMark(c)47 RemoveRebootMark(c)
4848
=== modified file 'run-checks'
--- run-checks 2015-07-08 15:50:31 +0000
+++ run-checks 2015-07-16 00:24:47 +0000
@@ -76,8 +76,12 @@
7676
77# integration suite in kvm77# integration suite in kvm
78if which adt-run >/dev/null 2>&1; then78if which adt-run >/dev/null 2>&1; then
79 echo "Running integration tests"79 echo "Running integration tests on rolling edge"
80 go run _integration-tests/main.go --snappy-from-branch80 go run _integration-tests/main.go --snappy-from-branch
81 echo "Update from rolling edge -1 and run the integration tests"
82 go run _integration-tests/main.go --snappy-from-branch --revision=-1 --target-release=rolling --target-channel=edge
83 echo "Update from 15.04 edge to rolling edge and run the integration tests"
84 go run _integration-tests/main.go --snappy-from-branch --release=15.04 --channel=edge --target-release=rolling --target-channel=edge
81fi85fi
8286
83echo "All good, what could possibly go wrong"87echo "All good, what could possibly go wrong"

Subscribers

People subscribed via source and target branches