Merge lp:~elopio/snappy/15.04_to_rolling-3 into lp:~snappy-dev/snappy/snappy-moved-to-github
- 15.04_to_rolling-3
- Merge into 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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Snappy Developers | Pending | ||
Review via email:
|
This proposal supersedes a proposal from 2015-07-15.
This proposal has been superseded by a proposal from 2015-07-16.
Commit message
Description of the change
To post a comment you must log in.
- 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
1 | === modified file '_integration-tests/main.go' |
2 | --- _integration-tests/main.go 2015-07-15 15:53:51 +0000 |
3 | +++ _integration-tests/main.go 2015-07-16 00:24:47 +0000 |
4 | @@ -64,6 +64,7 @@ |
5 | buildSnappyCLI(arch) |
6 | } |
7 | buildTests(arch) |
8 | +<<<<<<< TREE |
9 | } |
10 | |
11 | func writeTestConfig(release, channel string) { |
12 | @@ -88,6 +89,38 @@ |
13 | |
14 | // Run the tests on the latest rolling edge image. |
15 | if imageName, err := img.UdfCreate(); err == nil { |
16 | +======= |
17 | +} |
18 | + |
19 | +func writeTestConfig(release, channel, targetRelease, targetChannel string) { |
20 | + fmt.Println("Writing test config...") |
21 | + testConfig := map[string]string{ |
22 | + "release": release, |
23 | + "channel": channel, |
24 | + } |
25 | + if targetRelease != "" { |
26 | + testConfig["targetRelease"] = targetRelease |
27 | + } |
28 | + if targetChannel != "" { |
29 | + testConfig["targetChannel"] = targetChannel |
30 | + } |
31 | + fmt.Println(testConfig) |
32 | + encoded, err := json.Marshal(testConfig) |
33 | + if err != nil { |
34 | + log.Fatalf("Error encoding the test config: %v", testConfig) |
35 | + } |
36 | + ioutil.WriteFile(configFileName, encoded, 0644) |
37 | +} |
38 | + |
39 | +func setupAndRunLocalTests(rootPath, testFilter string, img image.Image) { |
40 | + var includeShell bool |
41 | + if testFilter == "" { |
42 | + includeShell = true |
43 | + } |
44 | + |
45 | + // Run the tests on the latest rolling edge image. |
46 | + if imageName, err := img.UdfCreate(); err == nil { |
47 | +>>>>>>> MERGE-SOURCE |
48 | adtRun(rootPath, testFilter, testPackages, |
49 | kvmSSHOptions(imageName), includeShell) |
50 | } |
51 | @@ -228,16 +261,30 @@ |
52 | "SSH port of the testbed. Defaults to use port "+strconv.Itoa(defaultSSHPort)) |
53 | testFilter = flag.String("filter", "", |
54 | "Suites or tests to run, for instance MyTestSuite, MyTestSuite.FirstCustomTest or MyTestSuite.*CustomTest") |
55 | - imgRelease = flag.String("release", defaultRelease, |
56 | - "Release of the image to be built, defaults to "+defaultRelease) |
57 | - imgChannel = flag.String("channel", defaultChannel, |
58 | - "Channel of the image to be built, defaults to "+defaultChannel) |
59 | - imgRevision = flag.String("revision", "", |
60 | - "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") |
61 | +<<<<<<< TREE |
62 | + imgRelease = flag.String("release", defaultRelease, |
63 | + "Release of the image to be built, defaults to "+defaultRelease) |
64 | + imgChannel = flag.String("channel", defaultChannel, |
65 | + "Channel of the image to be built, defaults to "+defaultChannel) |
66 | + imgRevision = flag.String("revision", "", |
67 | + "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") |
68 | +======= |
69 | + imgRelease = flag.String("release", defaultRelease, |
70 | + "Release of the image to be built, defaults to "+defaultRelease) |
71 | + imgChannel = flag.String("channel", defaultChannel, |
72 | + "Channel of the image to be built, defaults to "+defaultChannel) |
73 | + imgRevision = flag.String("revision", "", |
74 | + "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") |
75 | + targetRelease = flag.String("target-release", "", |
76 | + "If specified, the image will be updated to this release before running the tests.") |
77 | + targetChannel = flag.String("target-channel", "", |
78 | + "If specified, the image will be updated to this channel before running the tests.") |
79 | +>>>>>>> MERGE-SOURCE |
80 | ) |
81 | |
82 | flag.Parse() |
83 | |
84 | +<<<<<<< TREE |
85 | buildAssets(*useSnappyFromBranch, *arch) |
86 | |
87 | // TODO: generate the files out of the source tree. --elopio - 2015-07-15 |
88 | @@ -257,4 +304,25 @@ |
89 | } else { |
90 | setupAndRunRemoteTests(rootPath, *testFilter, *testbedIP, *testbedPort) |
91 | } |
92 | +======= |
93 | + buildAssets(*useSnappyFromBranch, *arch) |
94 | + |
95 | + // TODO: generate the files out of the source tree. --elopio - 2015-07-15 |
96 | + utils.PrepareTargetDir(dataOutputDir) |
97 | + defer os.RemoveAll(dataOutputDir) |
98 | + |
99 | + // TODO: pass the config as arguments to the test binaries. |
100 | + // --elopio - 2015-07-15 |
101 | + writeTestConfig(*imgRelease, *imgChannel, *targetRelease, *targetChannel) |
102 | + |
103 | + rootPath := getRootPath() |
104 | + |
105 | + if *testbedIP == "" { |
106 | + img := image.NewImage(*imgRelease, *imgChannel, *imgRevision, baseDir) |
107 | + setupAndRunLocalTests(rootPath, *testFilter, *img) |
108 | + |
109 | + } else { |
110 | + setupAndRunRemoteTests(rootPath, *testFilter, *testbedIP, *testbedPort) |
111 | + } |
112 | +>>>>>>> MERGE-SOURCE |
113 | } |
114 | |
115 | === modified file '_integration-tests/tests/common/common.go' |
116 | --- _integration-tests/tests/common/common.go 2015-07-16 00:12:27 +0000 |
117 | +++ _integration-tests/tests/common/common.go 2015-07-16 00:24:47 +0000 |
118 | @@ -20,6 +20,7 @@ |
119 | package common |
120 | |
121 | import ( |
122 | + "encoding/json" |
123 | "fmt" |
124 | "io/ioutil" |
125 | "os" |
126 | @@ -39,6 +40,8 @@ |
127 | channelCfgFile = "/etc/system-image/channel.ini" |
128 | ) |
129 | |
130 | +var Config map[string]string |
131 | + |
132 | // SnappySuite is a structure used as a base test suite for all the snappy |
133 | // integration tests. |
134 | type SnappySuite struct { |
135 | @@ -50,6 +53,19 @@ |
136 | func (s *SnappySuite) SetUpSuite(c *check.C) { |
137 | ExecCommand(c, "sudo", "systemctl", "stop", "snappy-autopilot.timer") |
138 | ExecCommand(c, "sudo", "systemctl", "disable", "snappy-autopilot.timer") |
139 | + if CheckRebootMark("") { |
140 | + Config = readConfig(c) |
141 | + targetRelease, _ := Config["targetRelease"] |
142 | + targetChannel, _ := Config["targetChannel"] |
143 | + if targetRelease != "" || targetChannel != "" { |
144 | + switchSystemImageConf(c, targetRelease, targetChannel, "0") |
145 | + if CallUpdate(c) { |
146 | + RebootWithMark(c, c.TestName()+"-setupsuite-update") |
147 | + } |
148 | + } |
149 | + } else if CheckRebootMark(c.TestName() + "-setupsuite-update") { |
150 | + RemoveRebootMark(c) |
151 | + } |
152 | } |
153 | |
154 | // SetUpTest handles reboots and stores version information. It will run before |
155 | @@ -112,6 +128,59 @@ |
156 | s.cleanupHandlers = append(s.cleanupHandlers, f) |
157 | } |
158 | |
159 | +func readConfig(c *check.C) map[string]string { |
160 | + b, err := ioutil.ReadFile("_integration-tests/data/output/testconfig.json") |
161 | + c.Assert( |
162 | + err, check.IsNil, check.Commentf("Failed to read test config: %v", err)) |
163 | + |
164 | + var decoded map[string]string |
165 | + err = json.Unmarshal(b, &decoded) |
166 | + c.Assert( |
167 | + err, check.IsNil, check.Commentf("Failed to decode test config: %v", err)) |
168 | + return decoded |
169 | +} |
170 | + |
171 | +func switchSystemImageConf(c *check.C, release, channel, version string) { |
172 | + targets := []string{"/", BaseOtherPath} |
173 | + for _, target := range targets { |
174 | + file := filepath.Join(target, channelCfgFile) |
175 | + if _, err := os.Stat(file); err == nil { |
176 | + MakeWritable(c, target) |
177 | + defer MakeReadonly(c, target) |
178 | + replaceSystemImageValues(c, file, release, channel, version) |
179 | + } |
180 | + } |
181 | +} |
182 | + |
183 | +func replaceSystemImageValues(c *check.C, file, release, channel, version string) { |
184 | + c.Log("Switching the system image conf...") |
185 | + regex := []string{} |
186 | + if release != "" { |
187 | + regex = append(regex, |
188 | + fmt.Sprintf( |
189 | + `s#channel: ubuntu-core/.*/\(.*\)#channel: ubuntu-core/%s/\1#`, |
190 | + release)) |
191 | + } |
192 | + if channel != "" { |
193 | + regex = append(regex, |
194 | + fmt.Sprintf( |
195 | + `s#channel: ubuntu-core/\(.*\)/.*#channel: ubuntu-core/\1/%s#`, |
196 | + channel)) |
197 | + } |
198 | + if version != "" { |
199 | + regex = append(regex, |
200 | + fmt.Sprintf( |
201 | + `s/build_number: .*/build_number: %s/`, |
202 | + version)) |
203 | + } |
204 | + for i := range regex { |
205 | + ExecCommand(c, |
206 | + "sudo", "sed", "-i", regex[i], file) |
207 | + } |
208 | + // Leave the new file in the test log. |
209 | + ExecCommand(c, "cat", file) |
210 | +} |
211 | + |
212 | func channelCfgBackupFile() string { |
213 | return filepath.Join(os.Getenv("ADT_ARTIFACTS"), "channel.ini") |
214 | } |
215 | @@ -168,17 +237,28 @@ |
216 | return version |
217 | } |
218 | |
219 | -// CallUpdate executes an snappy update. If there is no update available, the |
220 | -// channel version will be modified to fake an update. |
221 | -func CallUpdate(c *check.C) { |
222 | +// CallUpdate executes an snappy update. It returns true if an update was |
223 | +// installed and it is waiting for a reboot to be activated. |
224 | +func CallUpdate(c *check.C) bool { |
225 | c.Log("Calling snappy update...") |
226 | output := ExecCommand(c, "sudo", "snappy", "update") |
227 | // XXX Instead of trying the update, we should have a command to tell us |
228 | // if there is an available update. --elopio - 2015-07-01 |
229 | +<<<<<<< TREE |
230 | if output == "" { |
231 | c.Log("There is no update available.") |
232 | CallFakeUpdate(c) |
233 | } |
234 | +======= |
235 | + return output != "" |
236 | +} |
237 | + |
238 | +// CallFakeUpdate calls snappy update after faking the current version |
239 | +func CallFakeUpdate(c *check.C) { |
240 | + c.Log("Preparing fake and calling update.") |
241 | + fakeAvailableUpdate(c) |
242 | + ExecCommand(c, "sudo", "snappy", "update") |
243 | +>>>>>>> MERGE-SOURCE |
244 | } |
245 | |
246 | // CallFakeUpdate calls snappy update after faking the current version |
247 | @@ -190,12 +270,17 @@ |
248 | |
249 | func fakeAvailableUpdate(c *check.C) { |
250 | c.Log("Faking an available update...") |
251 | +<<<<<<< TREE |
252 | currentVersion := GetCurrentUbuntuCoreVersion(c) |
253 | switchChannelVersion(c, currentVersion, currentVersion-1) |
254 | +======= |
255 | + currentVersion := GetCurrentUbuntuCoreVersion(c) |
256 | + switchChannelVersionWithBackup(c, currentVersion-1) |
257 | +>>>>>>> MERGE-SOURCE |
258 | SetSavedVersion(c, currentVersion-1) |
259 | } |
260 | |
261 | -func switchChannelVersion(c *check.C, oldVersion, newVersion int) { |
262 | +func switchChannelVersionWithBackup(c *check.C, newVersion int) { |
263 | m := make(map[string]string) |
264 | m["/"] = channelCfgBackupFile() |
265 | m[BaseOtherPath] = channelCfgOtherBackupFile() |
266 | @@ -206,12 +291,7 @@ |
267 | defer MakeReadonly(c, target) |
268 | // Back up the file. It will be restored during the test tear down. |
269 | ExecCommand(c, "cp", file, backup) |
270 | - ExecCommand(c, |
271 | - "sudo", "sed", "-i", |
272 | - fmt.Sprintf( |
273 | - "s/build_number: %d/build_number: %d/g", |
274 | - oldVersion, newVersion), |
275 | - file) |
276 | + replaceSystemImageValues(c, file, "", "", strconv.Itoa(newVersion)) |
277 | } |
278 | } |
279 | } |
280 | |
281 | === modified file '_integration-tests/tests/latest/info_test.go' |
282 | --- _integration-tests/tests/latest/info_test.go 2015-07-15 15:18:22 +0000 |
283 | +++ _integration-tests/tests/latest/info_test.go 2015-07-16 00:24:47 +0000 |
284 | @@ -1,3 +1,4 @@ |
285 | +<<<<<<< TREE |
286 | // -*- Mode: Go; indent-tabs-mode: t -*- |
287 | |
288 | /* |
289 | @@ -84,3 +85,76 @@ |
290 | ".*" |
291 | c.Assert(infoOutput, check.Matches, expected) |
292 | } |
293 | +======= |
294 | +// -*- Mode: Go; indent-tabs-mode: t -*- |
295 | + |
296 | +/* |
297 | + * Copyright (C) 2015 Canonical Ltd |
298 | + * |
299 | + * This program is free software: you can redistribute it and/or modify |
300 | + * it under the terms of the GNU General Public License version 3 as |
301 | + * published by the Free Software Foundation. |
302 | + * |
303 | + * This program is distributed in the hope that it will be useful, |
304 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
305 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
306 | + * GNU General Public License for more details. |
307 | + * |
308 | + * You should have received a copy of the GNU General Public License |
309 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
310 | + * |
311 | + */ |
312 | + |
313 | +package latest |
314 | + |
315 | +import ( |
316 | + "fmt" |
317 | + |
318 | + . "../common" |
319 | + |
320 | + check "gopkg.in/check.v1" |
321 | +) |
322 | + |
323 | +var _ = check.Suite(&infoSuite{}) |
324 | + |
325 | +type infoSuite struct { |
326 | + SnappySuite |
327 | +} |
328 | + |
329 | +func (s *infoSuite) TestInfoMustPrintReleaseAndChannel(c *check.C) { |
330 | + infoOutput := ExecCommand(c, "snappy", "info") |
331 | + |
332 | + expected := "(?ms)" + |
333 | + fmt.Sprintf("^release: ubuntu-core/%s/%s\n", Config["release"], Config["channel"]) + |
334 | + ".*" |
335 | + |
336 | + c.Assert(infoOutput, check.Matches, expected) |
337 | +} |
338 | + |
339 | +func (s *infoSuite) TestInfoMustPrintInstalledApps(c *check.C) { |
340 | + InstallSnap(c, "hello-world") |
341 | + s.AddCleanup(func() { |
342 | + RemoveSnap(c, "hello-world") |
343 | + }) |
344 | + infoOutput := ExecCommand(c, "snappy", "info") |
345 | + |
346 | + expected := "(?ms)" + |
347 | + ".*" + |
348 | + "^apps: .*hello-world.*\n" |
349 | + c.Assert(infoOutput, check.Matches, expected) |
350 | +} |
351 | + |
352 | +func (s *infoSuite) TestInfoMustPrintInstalledFrameworks(c *check.C) { |
353 | + InstallSnap(c, "hello-dbus-fwk.canonical") |
354 | + s.AddCleanup(func() { |
355 | + RemoveSnap(c, "hello-dbus-fwk.canonical") |
356 | + }) |
357 | + infoOutput := ExecCommand(c, "snappy", "info") |
358 | + |
359 | + expected := "(?ms)" + |
360 | + ".*" + |
361 | + "^frameworks: .*hello-dbus-fwk.*\n" + |
362 | + ".*" |
363 | + c.Assert(infoOutput, check.Matches, expected) |
364 | +} |
365 | +>>>>>>> MERGE-SOURCE |
366 | |
367 | === modified file '_integration-tests/tests/update/update_test.go' |
368 | --- _integration-tests/tests/update/update_test.go 2015-07-14 15:16:59 +0000 |
369 | +++ _integration-tests/tests/update/update_test.go 2015-07-16 00:24:47 +0000 |
370 | @@ -41,7 +41,7 @@ |
371 | // be up-to-date after running this test. |
372 | func (s *updateSuite) TestUpdateToSameReleaseAndChannel(c *C) { |
373 | if BeforeReboot() { |
374 | - CallUpdate(c) |
375 | + CallFakeUpdate(c) |
376 | Reboot(c) |
377 | } else if AfterReboot(c) { |
378 | RemoveRebootMark(c) |
379 | |
380 | === modified file 'run-checks' |
381 | --- run-checks 2015-07-08 15:50:31 +0000 |
382 | +++ run-checks 2015-07-16 00:24:47 +0000 |
383 | @@ -76,8 +76,12 @@ |
384 | |
385 | # integration suite in kvm |
386 | if which adt-run >/dev/null 2>&1; then |
387 | - echo "Running integration tests" |
388 | + echo "Running integration tests on rolling edge" |
389 | go run _integration-tests/main.go --snappy-from-branch |
390 | + echo "Update from rolling edge -1 and run the integration tests" |
391 | + go run _integration-tests/main.go --snappy-from-branch --revision=-1 --target-release=rolling --target-channel=edge |
392 | + echo "Update from 15.04 edge to rolling edge and run the integration tests" |
393 | + go run _integration-tests/main.go --snappy-from-branch --release=15.04 --channel=edge --target-release=rolling --target-channel=edge |
394 | fi |
395 | |
396 | echo "All good, what could possibly go wrong" |