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: | Merged |
---|---|
Approved by: | Leo Arias |
Approved revision: | 603 |
Merged at revision: | 593 |
Proposed branch: | lp:~elopio/snappy/15.04_to_rolling-3 |
Merge into: | lp:~snappy-dev/snappy/snappy-moved-to-github |
Diff against target: |
474 lines (+123/-75) 15 files modified
_integration-tests/README.md (+19/-0) _integration-tests/main.go (+16/-16) _integration-tests/tests/cmd/apt_test.go (+1/-1) _integration-tests/tests/cmd/base_test.go (+1/-1) _integration-tests/tests/cmd/build_test.go (+1/-1) _integration-tests/tests/cmd/info_test.go (+2/-17) _integration-tests/tests/cmd/installApp_test.go (+1/-1) _integration-tests/tests/cmd/installFramework_test.go (+1/-1) _integration-tests/tests/cmd/list_test.go (+1/-1) _integration-tests/tests/cmd/rollback_test.go (+1/-1) _integration-tests/tests/cmd/search_test.go (+1/-1) _integration-tests/tests/cmd/update_test.go (+7/-11) _integration-tests/tests/cmd/writablePaths_test.go (+1/-1) _integration-tests/tests/common/common.go (+69/-21) run-checks (+1/-1) |
To merge this branch: | bzr merge lp:~elopio/snappy/15.04_to_rolling-3 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Federico Gimenez (community) | Approve | ||
Review via email:
|
This proposal supersedes a proposal from 2015-07-15.
Commit message
Added support for real updates before running the integration tests.
Description of the change
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Leo Arias (elopio) wrote : | # |
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Federico Gimenez (fgimenez) wrote : | # |
Great Leo, just a couple of nits inline and a question about reverting the si config when there's no update available, otherwise it's a +1. This will give us a lot of flexibility.
Thanks,
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Leo Arias (elopio) wrote : | # |
Thanks for the review Federico. I replied, and pushed. What should we do with this? Land or wait until ssh into the image if fixed?
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Federico Gimenez (fgimenez) wrote : | # |
Thanks, I'm ok with landing it already, we can fix any pending issues later.
Cheers!
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '_integration-tests/README.md' | |||
2 | --- _integration-tests/README.md 2015-07-15 07:37:35 +0000 | |||
3 | +++ _integration-tests/README.md 2015-07-21 00:41:17 +0000 | |||
4 | @@ -77,3 +77,22 @@ | |||
5 | 77 | Run the tests with: | 77 | Run the tests with: |
6 | 78 | 78 | ||
7 | 79 | go run _integration-tests/main.go --ip {beaglebone-ip} --arch arm | 79 | go run _integration-tests/main.go --ip {beaglebone-ip} --arch arm |
8 | 80 | |||
9 | 81 | ## Testing an update | ||
10 | 82 | |||
11 | 83 | You can flash an old image, update to the latest and then run the whole suite | ||
12 | 84 | on the updated system. The release, the channel and the revision flags specify | ||
13 | 85 | the image that will be flashed, and the target-release and target-channel flags | ||
14 | 86 | specify the values to be used in the update. | ||
15 | 87 | |||
16 | 88 | For example, to update from rolling edge -1 to the latest and then run the | ||
17 | 89 | integration tests: | ||
18 | 90 | |||
19 | 91 | go run _integration-tests/main.go --snappy-from-branch \ | ||
20 | 92 | --revision=-1 --target-release=rolling --target-channel=edge | ||
21 | 93 | |||
22 | 94 | To update from 15.04 edge to rolling edge and then run the integration tests: | ||
23 | 95 | |||
24 | 96 | go run _integration-tests/main.go --snappy-from-branch \ | ||
25 | 97 | --release=15.04 --channel=edge \ | ||
26 | 98 | --target-release=rolling --target-channel=edge | ||
27 | 80 | 99 | ||
28 | === modified file '_integration-tests/main.go' | |||
29 | --- _integration-tests/main.go 2015-07-17 15:43:11 +0000 | |||
30 | +++ _integration-tests/main.go 2015-07-21 00:41:17 +0000 | |||
31 | @@ -47,12 +47,10 @@ | |||
32 | 47 | ) | 47 | ) |
33 | 48 | 48 | ||
34 | 49 | var ( | 49 | var ( |
41 | 50 | commonSSHOptions = []string{"---", "ssh"} | 50 | commonSSHOptions = []string{"---", "ssh"} |
42 | 51 | configFileName = filepath.Join(dataOutputDir, "testconfig.json") | 51 | configFileName = filepath.Join(dataOutputDir, "testconfig.json") |
43 | 52 | controlFile = filepath.Join(dataOutputDir, "control") | 52 | controlFile = filepath.Join(dataOutputDir, "control") |
44 | 53 | testPackagesLatest = []string{"latest", "failover"} | 53 | testPackages = []string{"cmd", "failover"} |
39 | 54 | testPackageUpdate = []string{"update"} | ||
40 | 55 | testPackages = append(testPackagesLatest, testPackageUpdate...) | ||
45 | 56 | ) | 54 | ) |
46 | 57 | 55 | ||
47 | 58 | func buildAssets(useSnappyFromBranch bool, arch string) { | 56 | func buildAssets(useSnappyFromBranch bool, arch string) { |
48 | @@ -66,12 +64,18 @@ | |||
49 | 66 | buildTests(arch) | 64 | buildTests(arch) |
50 | 67 | } | 65 | } |
51 | 68 | 66 | ||
53 | 69 | func writeTestConfig(release, channel string) { | 67 | func writeTestConfig(release, channel, targetRelease, targetChannel string) { |
54 | 70 | fmt.Println("Writing test config...") | 68 | fmt.Println("Writing test config...") |
55 | 71 | testConfig := map[string]string{ | 69 | testConfig := map[string]string{ |
56 | 72 | "release": release, | 70 | "release": release, |
57 | 73 | "channel": channel, | 71 | "channel": channel, |
58 | 74 | } | 72 | } |
59 | 73 | if targetRelease != "" { | ||
60 | 74 | testConfig["targetRelease"] = targetRelease | ||
61 | 75 | } | ||
62 | 76 | if targetChannel != "" { | ||
63 | 77 | testConfig["targetChannel"] = targetChannel | ||
64 | 78 | } | ||
65 | 75 | fmt.Println(testConfig) | 79 | fmt.Println(testConfig) |
66 | 76 | encoded, err := json.Marshal(testConfig) | 80 | encoded, err := json.Marshal(testConfig) |
67 | 77 | if err != nil { | 81 | if err != nil { |
68 | @@ -86,14 +90,6 @@ | |||
69 | 86 | adtRun(rootPath, testFilter, testPackages, | 90 | adtRun(rootPath, testFilter, testPackages, |
70 | 87 | kvmSSHOptions(imageName)) | 91 | kvmSSHOptions(imageName)) |
71 | 88 | } | 92 | } |
72 | 89 | |||
73 | 90 | // Update from revision -1. | ||
74 | 91 | img.SetRevision("-1") | ||
75 | 92 | if imageName, err := img.UdfCreate(); err == nil { | ||
76 | 93 | adtRun( | ||
77 | 94 | rootPath, "updateSuite.TestUpdateToSameReleaseAndChannel", | ||
78 | 95 | testPackageUpdate, kvmSSHOptions(imageName)) | ||
79 | 96 | } | ||
80 | 97 | } | 93 | } |
81 | 98 | 94 | ||
82 | 99 | func setupAndRunRemoteTests(rootPath, testFilter, testbedIP string, testbedPort int) { | 95 | func setupAndRunRemoteTests(rootPath, testFilter, testbedIP string, testbedPort int) { |
83 | @@ -220,6 +216,10 @@ | |||
84 | 220 | "Channel of the image to be built, defaults to "+defaultChannel) | 216 | "Channel of the image to be built, defaults to "+defaultChannel) |
85 | 221 | imgRevision = flag.String("revision", "", | 217 | imgRevision = flag.String("revision", "", |
86 | 222 | "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") | 218 | "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") |
87 | 219 | targetRelease = flag.String("target-release", "", | ||
88 | 220 | "If specified, the image will be updated to this release before running the tests.") | ||
89 | 221 | targetChannel = flag.String("target-channel", "", | ||
90 | 222 | "If specified, the image will be updated to this channel before running the tests.") | ||
91 | 223 | ) | 223 | ) |
92 | 224 | 224 | ||
93 | 225 | flag.Parse() | 225 | flag.Parse() |
94 | @@ -232,7 +232,7 @@ | |||
95 | 232 | 232 | ||
96 | 233 | // TODO: pass the config as arguments to the test binaries. | 233 | // TODO: pass the config as arguments to the test binaries. |
97 | 234 | // --elopio - 2015-07-15 | 234 | // --elopio - 2015-07-15 |
99 | 235 | writeTestConfig(*imgRelease, *imgChannel) | 235 | writeTestConfig(*imgRelease, *imgChannel, *targetRelease, *targetChannel) |
100 | 236 | 236 | ||
101 | 237 | rootPath := getRootPath() | 237 | rootPath := getRootPath() |
102 | 238 | 238 | ||
103 | 239 | 239 | ||
104 | === renamed directory '_integration-tests/tests/latest' => '_integration-tests/tests/cmd' | |||
105 | === modified file '_integration-tests/tests/cmd/apt_test.go' | |||
106 | --- _integration-tests/tests/latest/apt_test.go 2015-07-17 00:02:32 +0000 | |||
107 | +++ _integration-tests/tests/cmd/apt_test.go 2015-07-21 00:41:17 +0000 | |||
108 | @@ -17,7 +17,7 @@ | |||
109 | 17 | * | 17 | * |
110 | 18 | */ | 18 | */ |
111 | 19 | 19 | ||
113 | 20 | package latest | 20 | package cmd |
114 | 21 | 21 | ||
115 | 22 | import ( | 22 | import ( |
116 | 23 | . "../common" | 23 | . "../common" |
117 | 24 | 24 | ||
118 | === modified file '_integration-tests/tests/cmd/base_test.go' | |||
119 | --- _integration-tests/tests/latest/base_test.go 2015-07-01 14:00:36 +0000 | |||
120 | +++ _integration-tests/tests/cmd/base_test.go 2015-07-21 00:41:17 +0000 | |||
121 | @@ -17,7 +17,7 @@ | |||
122 | 17 | * | 17 | * |
123 | 18 | */ | 18 | */ |
124 | 19 | 19 | ||
126 | 20 | package latest | 20 | package cmd |
127 | 21 | 21 | ||
128 | 22 | import ( | 22 | import ( |
129 | 23 | "testing" | 23 | "testing" |
130 | 24 | 24 | ||
131 | === modified file '_integration-tests/tests/cmd/build_test.go' | |||
132 | --- _integration-tests/tests/latest/build_test.go 2015-07-08 01:08:26 +0000 | |||
133 | +++ _integration-tests/tests/cmd/build_test.go 2015-07-21 00:41:17 +0000 | |||
134 | @@ -17,7 +17,7 @@ | |||
135 | 17 | * | 17 | * |
136 | 18 | */ | 18 | */ |
137 | 19 | 19 | ||
139 | 20 | package latest | 20 | package cmd |
140 | 21 | 21 | ||
141 | 22 | import ( | 22 | import ( |
142 | 23 | "fmt" | 23 | "fmt" |
143 | 24 | 24 | ||
144 | === modified file '_integration-tests/tests/cmd/info_test.go' | |||
145 | --- _integration-tests/tests/latest/info_test.go 2015-07-15 15:18:22 +0000 | |||
146 | +++ _integration-tests/tests/cmd/info_test.go 2015-07-21 00:41:17 +0000 | |||
147 | @@ -17,12 +17,10 @@ | |||
148 | 17 | * | 17 | * |
149 | 18 | */ | 18 | */ |
150 | 19 | 19 | ||
152 | 20 | package latest | 20 | package cmd |
153 | 21 | 21 | ||
154 | 22 | import ( | 22 | import ( |
155 | 23 | "encoding/json" | ||
156 | 24 | "fmt" | 23 | "fmt" |
157 | 25 | "io/ioutil" | ||
158 | 26 | 24 | ||
159 | 27 | . "../common" | 25 | . "../common" |
160 | 28 | 26 | ||
161 | @@ -35,24 +33,11 @@ | |||
162 | 35 | SnappySuite | 33 | SnappySuite |
163 | 36 | } | 34 | } |
164 | 37 | 35 | ||
165 | 38 | func readConfig(c *check.C) map[string]string { | ||
166 | 39 | b, err := ioutil.ReadFile("_integration-tests/data/output/testconfig.json") | ||
167 | 40 | c.Assert( | ||
168 | 41 | err, check.IsNil, check.Commentf("Failed to read test config: %v", err)) | ||
169 | 42 | |||
170 | 43 | var decoded map[string]string | ||
171 | 44 | err = json.Unmarshal(b, &decoded) | ||
172 | 45 | c.Assert( | ||
173 | 46 | err, check.IsNil, check.Commentf("Failed to decode test config: %v", err)) | ||
174 | 47 | return decoded | ||
175 | 48 | } | ||
176 | 49 | |||
177 | 50 | func (s *infoSuite) TestInfoMustPrintReleaseAndChannel(c *check.C) { | 36 | func (s *infoSuite) TestInfoMustPrintReleaseAndChannel(c *check.C) { |
178 | 51 | infoOutput := ExecCommand(c, "snappy", "info") | 37 | infoOutput := ExecCommand(c, "snappy", "info") |
179 | 52 | 38 | ||
180 | 53 | config := readConfig(c) | ||
181 | 54 | expected := "(?ms)" + | 39 | expected := "(?ms)" + |
183 | 55 | fmt.Sprintf("^release: ubuntu-core/%s/%s\n", config["release"], config["channel"]) + | 40 | fmt.Sprintf("^release: ubuntu-core/%s/%s\n", Config["release"], Config["channel"]) + |
184 | 56 | ".*" | 41 | ".*" |
185 | 57 | 42 | ||
186 | 58 | c.Assert(infoOutput, check.Matches, expected) | 43 | c.Assert(infoOutput, check.Matches, expected) |
187 | 59 | 44 | ||
188 | === modified file '_integration-tests/tests/cmd/installApp_test.go' | |||
189 | --- _integration-tests/tests/latest/installApp_test.go 2015-07-15 05:36:24 +0000 | |||
190 | +++ _integration-tests/tests/cmd/installApp_test.go 2015-07-21 00:41:17 +0000 | |||
191 | @@ -17,7 +17,7 @@ | |||
192 | 17 | * | 17 | * |
193 | 18 | */ | 18 | */ |
194 | 19 | 19 | ||
196 | 20 | package latest | 20 | package cmd |
197 | 21 | 21 | ||
198 | 22 | import ( | 22 | import ( |
199 | 23 | "net/http" | 23 | "net/http" |
200 | 24 | 24 | ||
201 | === modified file '_integration-tests/tests/cmd/installFramework_test.go' | |||
202 | --- _integration-tests/tests/latest/installFramework_test.go 2015-07-14 15:54:52 +0000 | |||
203 | +++ _integration-tests/tests/cmd/installFramework_test.go 2015-07-21 00:41:17 +0000 | |||
204 | @@ -17,7 +17,7 @@ | |||
205 | 17 | * | 17 | * |
206 | 18 | */ | 18 | */ |
207 | 19 | 19 | ||
209 | 20 | package latest | 20 | package cmd |
210 | 21 | 21 | ||
211 | 22 | import ( | 22 | import ( |
212 | 23 | "fmt" | 23 | "fmt" |
213 | 24 | 24 | ||
214 | === modified file '_integration-tests/tests/cmd/list_test.go' | |||
215 | --- _integration-tests/tests/latest/list_test.go 2015-07-17 00:28:36 +0000 | |||
216 | +++ _integration-tests/tests/cmd/list_test.go 2015-07-21 00:41:17 +0000 | |||
217 | @@ -17,7 +17,7 @@ | |||
218 | 17 | * | 17 | * |
219 | 18 | */ | 18 | */ |
220 | 19 | 19 | ||
222 | 20 | package latest | 20 | package cmd |
223 | 21 | 21 | ||
224 | 22 | import ( | 22 | import ( |
225 | 23 | "fmt" | 23 | "fmt" |
226 | 24 | 24 | ||
227 | === modified file '_integration-tests/tests/cmd/rollback_test.go' | |||
228 | --- _integration-tests/tests/latest/rollback_test.go 2015-07-17 04:21:07 +0000 | |||
229 | +++ _integration-tests/tests/cmd/rollback_test.go 2015-07-21 00:41:17 +0000 | |||
230 | @@ -17,7 +17,7 @@ | |||
231 | 17 | * | 17 | * |
232 | 18 | */ | 18 | */ |
233 | 19 | 19 | ||
235 | 20 | package latest | 20 | package cmd |
236 | 21 | 21 | ||
237 | 22 | import ( | 22 | import ( |
238 | 23 | "strconv" | 23 | "strconv" |
239 | 24 | 24 | ||
240 | === modified file '_integration-tests/tests/cmd/search_test.go' | |||
241 | --- _integration-tests/tests/latest/search_test.go 2015-07-15 05:54:33 +0000 | |||
242 | +++ _integration-tests/tests/cmd/search_test.go 2015-07-21 00:41:17 +0000 | |||
243 | @@ -17,7 +17,7 @@ | |||
244 | 17 | * | 17 | * |
245 | 18 | */ | 18 | */ |
246 | 19 | 19 | ||
248 | 20 | package latest | 20 | package cmd |
249 | 21 | 21 | ||
250 | 22 | import ( | 22 | import ( |
251 | 23 | . "../common" | 23 | . "../common" |
252 | 24 | 24 | ||
253 | === renamed file '_integration-tests/tests/update/update_test.go' => '_integration-tests/tests/cmd/update_test.go' | |||
254 | --- _integration-tests/tests/update/update_test.go 2015-07-14 15:16:59 +0000 | |||
255 | +++ _integration-tests/tests/cmd/update_test.go 2015-07-21 00:41:17 +0000 | |||
256 | @@ -17,19 +17,14 @@ | |||
257 | 17 | * | 17 | * |
258 | 18 | */ | 18 | */ |
259 | 19 | 19 | ||
261 | 20 | package update | 20 | package cmd |
262 | 21 | 21 | ||
263 | 22 | import ( | 22 | import ( |
264 | 23 | "testing" | ||
265 | 24 | |||
266 | 25 | . "../common" | 23 | . "../common" |
268 | 26 | . "gopkg.in/check.v1" | 24 | check "gopkg.in/check.v1" |
269 | 27 | ) | 25 | ) |
270 | 28 | 26 | ||
275 | 29 | // Hook up gocheck into the "go test" runner. | 27 | var _ = check.Suite(&updateSuite{}) |
272 | 30 | func Test(t *testing.T) { TestingT(t) } | ||
273 | 31 | |||
274 | 32 | var _ = Suite(&updateSuite{}) | ||
276 | 33 | 28 | ||
277 | 34 | type updateSuite struct { | 29 | type updateSuite struct { |
278 | 35 | SnappySuite | 30 | SnappySuite |
279 | @@ -39,12 +34,13 @@ | |||
280 | 39 | // version. If there is no update available, the channel version will be | 34 | // version. If there is no update available, the channel version will be |
281 | 40 | // modified to fake an update. If there is a version available, the image will | 35 | // modified to fake an update. If there is a version available, the image will |
282 | 41 | // be up-to-date after running this test. | 36 | // be up-to-date after running this test. |
284 | 42 | func (s *updateSuite) TestUpdateToSameReleaseAndChannel(c *C) { | 37 | func (s *updateSuite) TestUpdateToSameReleaseAndChannel(c *check.C) { |
285 | 43 | if BeforeReboot() { | 38 | if BeforeReboot() { |
287 | 44 | CallUpdate(c) | 39 | CallFakeUpdate(c) |
288 | 45 | Reboot(c) | 40 | Reboot(c) |
289 | 46 | } else if AfterReboot(c) { | 41 | } else if AfterReboot(c) { |
290 | 47 | RemoveRebootMark(c) | 42 | RemoveRebootMark(c) |
292 | 48 | c.Assert(GetCurrentUbuntuCoreVersion(c) > GetSavedVersion(c), Equals, true) | 43 | c.Assert(GetCurrentUbuntuCoreVersion(c) > GetSavedVersion(c), |
293 | 44 | check.Equals, true) | ||
294 | 49 | } | 45 | } |
295 | 50 | } | 46 | } |
296 | 51 | 47 | ||
297 | === modified file '_integration-tests/tests/cmd/writablePaths_test.go' | |||
298 | --- _integration-tests/tests/latest/writablePaths_test.go 2015-07-17 16:16:03 +0000 | |||
299 | +++ _integration-tests/tests/cmd/writablePaths_test.go 2015-07-21 00:41:17 +0000 | |||
300 | @@ -17,7 +17,7 @@ | |||
301 | 17 | * | 17 | * |
302 | 18 | */ | 18 | */ |
303 | 19 | 19 | ||
305 | 20 | package latest | 20 | package cmd |
306 | 21 | 21 | ||
307 | 22 | import ( | 22 | import ( |
308 | 23 | "bufio" | 23 | "bufio" |
309 | 24 | 24 | ||
310 | === modified file '_integration-tests/tests/common/common.go' | |||
311 | --- _integration-tests/tests/common/common.go 2015-07-17 04:21:07 +0000 | |||
312 | +++ _integration-tests/tests/common/common.go 2015-07-21 00:41:17 +0000 | |||
313 | @@ -20,6 +20,7 @@ | |||
314 | 20 | package common | 20 | package common |
315 | 21 | 21 | ||
316 | 22 | import ( | 22 | import ( |
317 | 23 | "encoding/json" | ||
318 | 23 | "fmt" | 24 | "fmt" |
319 | 24 | "io/ioutil" | 25 | "io/ioutil" |
320 | 25 | "os" | 26 | "os" |
321 | @@ -39,6 +40,10 @@ | |||
322 | 39 | channelCfgFile = "/etc/system-image/channel.ini" | 40 | channelCfgFile = "/etc/system-image/channel.ini" |
323 | 40 | ) | 41 | ) |
324 | 41 | 42 | ||
325 | 43 | // Config is a map of strings that contains the configurations values passed | ||
326 | 44 | // from the host to the testbed. | ||
327 | 45 | var Config map[string]string | ||
328 | 46 | |||
329 | 42 | // SnappySuite is a structure used as a base test suite for all the snappy | 47 | // SnappySuite is a structure used as a base test suite for all the snappy |
330 | 43 | // integration tests. | 48 | // integration tests. |
331 | 44 | type SnappySuite struct { | 49 | type SnappySuite struct { |
332 | @@ -50,6 +55,22 @@ | |||
333 | 50 | func (s *SnappySuite) SetUpSuite(c *check.C) { | 55 | func (s *SnappySuite) SetUpSuite(c *check.C) { |
334 | 51 | ExecCommand(c, "sudo", "systemctl", "stop", "snappy-autopilot.timer") | 56 | ExecCommand(c, "sudo", "systemctl", "stop", "snappy-autopilot.timer") |
335 | 52 | ExecCommand(c, "sudo", "systemctl", "disable", "snappy-autopilot.timer") | 57 | ExecCommand(c, "sudo", "systemctl", "disable", "snappy-autopilot.timer") |
336 | 58 | if !isInRebootProcess() { | ||
337 | 59 | Config = readConfig(c) | ||
338 | 60 | targetRelease, _ := Config["targetRelease"] | ||
339 | 61 | targetChannel, _ := Config["targetChannel"] | ||
340 | 62 | if targetRelease != "" || targetChannel != "" { | ||
341 | 63 | switchSystemImageConf(c, targetRelease, targetChannel, "0") | ||
342 | 64 | // Always use the installed snappy because we are updating from an old | ||
343 | 65 | // image, so we should not use the snappy from the branch. | ||
344 | 66 | output := ExecCommand(c, "sudo", "/usr/bin/snappy", "update") | ||
345 | 67 | if output != "" { | ||
346 | 68 | RebootWithMark(c, "setupsuite-update") | ||
347 | 69 | } | ||
348 | 70 | } | ||
349 | 71 | } else if CheckRebootMark("setupsuite-update") { | ||
350 | 72 | RemoveRebootMark(c) | ||
351 | 73 | } | ||
352 | 53 | } | 74 | } |
353 | 54 | 75 | ||
354 | 55 | // SetUpTest handles reboots and stores version information. It will run before | 76 | // SetUpTest handles reboots and stores version information. It will run before |
355 | @@ -112,6 +133,47 @@ | |||
356 | 112 | s.cleanupHandlers = append(s.cleanupHandlers, f) | 133 | s.cleanupHandlers = append(s.cleanupHandlers, f) |
357 | 113 | } | 134 | } |
358 | 114 | 135 | ||
359 | 136 | func readConfig(c *check.C) map[string]string { | ||
360 | 137 | b, err := ioutil.ReadFile("_integration-tests/data/output/testconfig.json") | ||
361 | 138 | c.Assert( | ||
362 | 139 | err, check.IsNil, check.Commentf("Failed to read test config: %v", err)) | ||
363 | 140 | |||
364 | 141 | var decoded map[string]string | ||
365 | 142 | err = json.Unmarshal(b, &decoded) | ||
366 | 143 | c.Assert( | ||
367 | 144 | err, check.IsNil, check.Commentf("Failed to decode test config: %v", err)) | ||
368 | 145 | return decoded | ||
369 | 146 | } | ||
370 | 147 | |||
371 | 148 | func switchSystemImageConf(c *check.C, release, channel, version string) { | ||
372 | 149 | targets := []string{"/", BaseOtherPath} | ||
373 | 150 | for _, target := range targets { | ||
374 | 151 | file := filepath.Join(target, channelCfgFile) | ||
375 | 152 | if _, err := os.Stat(file); err == nil { | ||
376 | 153 | MakeWritable(c, target) | ||
377 | 154 | defer MakeReadonly(c, target) | ||
378 | 155 | replaceSystemImageValues(c, file, release, channel, version) | ||
379 | 156 | } | ||
380 | 157 | } | ||
381 | 158 | } | ||
382 | 159 | |||
383 | 160 | func replaceSystemImageValues(c *check.C, file, release, channel, version string) { | ||
384 | 161 | c.Log("Switching the system image conf...") | ||
385 | 162 | replaceRegex := map[string]string{ | ||
386 | 163 | release: `s#channel: ubuntu-core/.*/\(.*\)#channel: ubuntu-core/%s/\1#`, | ||
387 | 164 | channel: `s#channel: ubuntu-core/\(.*\)/.*#channel: ubuntu-core/\1/%s#`, | ||
388 | 165 | version: `s/build_number: .*/build_number: %s/`, | ||
389 | 166 | } | ||
390 | 167 | for value, regex := range replaceRegex { | ||
391 | 168 | if value != "" { | ||
392 | 169 | ExecCommand(c, | ||
393 | 170 | "sudo", "sed", "-i", fmt.Sprintf(regex, value), file) | ||
394 | 171 | } | ||
395 | 172 | } | ||
396 | 173 | // Leave the new file in the test log. | ||
397 | 174 | ExecCommand(c, "cat", file) | ||
398 | 175 | } | ||
399 | 176 | |||
400 | 115 | func channelCfgBackupFile() string { | 177 | func channelCfgBackupFile() string { |
401 | 116 | return filepath.Join(os.Getenv("ADT_ARTIFACTS"), "channel.ini") | 178 | return filepath.Join(os.Getenv("ADT_ARTIFACTS"), "channel.ini") |
402 | 117 | } | 179 | } |
403 | @@ -168,19 +230,6 @@ | |||
404 | 168 | return version | 230 | return version |
405 | 169 | } | 231 | } |
406 | 170 | 232 | ||
407 | 171 | // CallUpdate executes an snappy update. If there is no update available, the | ||
408 | 172 | // channel version will be modified to fake an update. | ||
409 | 173 | func CallUpdate(c *check.C) { | ||
410 | 174 | c.Log("Calling snappy update...") | ||
411 | 175 | output := ExecCommand(c, "sudo", "snappy", "update") | ||
412 | 176 | // XXX Instead of trying the update, we should have a command to tell us | ||
413 | 177 | // if there is an available update. --elopio - 2015-07-01 | ||
414 | 178 | if output == "" { | ||
415 | 179 | c.Log("There is no update available.") | ||
416 | 180 | CallFakeUpdate(c) | ||
417 | 181 | } | ||
418 | 182 | } | ||
419 | 183 | |||
420 | 184 | // CallFakeUpdate calls snappy update after faking the current version | 233 | // CallFakeUpdate calls snappy update after faking the current version |
421 | 185 | func CallFakeUpdate(c *check.C) { | 234 | func CallFakeUpdate(c *check.C) { |
422 | 186 | c.Log("Preparing fake and calling update.") | 235 | c.Log("Preparing fake and calling update.") |
423 | @@ -191,11 +240,11 @@ | |||
424 | 191 | func fakeAvailableUpdate(c *check.C) { | 240 | func fakeAvailableUpdate(c *check.C) { |
425 | 192 | c.Log("Faking an available update...") | 241 | c.Log("Faking an available update...") |
426 | 193 | currentVersion := GetCurrentUbuntuCoreVersion(c) | 242 | currentVersion := GetCurrentUbuntuCoreVersion(c) |
428 | 194 | switchChannelVersion(c, currentVersion, currentVersion-1) | 243 | switchChannelVersionWithBackup(c, currentVersion-1) |
429 | 195 | SetSavedVersion(c, currentVersion-1) | 244 | SetSavedVersion(c, currentVersion-1) |
430 | 196 | } | 245 | } |
431 | 197 | 246 | ||
433 | 198 | func switchChannelVersion(c *check.C, oldVersion, newVersion int) { | 247 | func switchChannelVersionWithBackup(c *check.C, newVersion int) { |
434 | 199 | m := make(map[string]string) | 248 | m := make(map[string]string) |
435 | 200 | m["/"] = channelCfgBackupFile() | 249 | m["/"] = channelCfgBackupFile() |
436 | 201 | m[BaseOtherPath] = channelCfgOtherBackupFile() | 250 | m[BaseOtherPath] = channelCfgOtherBackupFile() |
437 | @@ -206,12 +255,7 @@ | |||
438 | 206 | defer MakeReadonly(c, target) | 255 | defer MakeReadonly(c, target) |
439 | 207 | // Back up the file. It will be restored during the test tear down. | 256 | // Back up the file. It will be restored during the test tear down. |
440 | 208 | ExecCommand(c, "cp", file, backup) | 257 | ExecCommand(c, "cp", file, backup) |
447 | 209 | ExecCommand(c, | 258 | replaceSystemImageValues(c, file, "", "", strconv.Itoa(newVersion)) |
442 | 210 | "sudo", "sed", "-i", | ||
443 | 211 | fmt.Sprintf( | ||
444 | 212 | "s/build_number: %d/build_number: %d/g", | ||
445 | 213 | oldVersion, newVersion), | ||
446 | 214 | file) | ||
448 | 215 | } | 259 | } |
449 | 216 | } | 260 | } |
450 | 217 | } | 261 | } |
451 | @@ -263,6 +307,10 @@ | |||
452 | 263 | return os.Getenv("ADT_REBOOT_MARK") == mark | 307 | return os.Getenv("ADT_REBOOT_MARK") == mark |
453 | 264 | } | 308 | } |
454 | 265 | 309 | ||
455 | 310 | func isInRebootProcess() bool { | ||
456 | 311 | return !CheckRebootMark("") || NeedsReboot() | ||
457 | 312 | } | ||
458 | 313 | |||
459 | 266 | // RemoveRebootMark removes the reboot mark to signal that the reboot has been | 314 | // RemoveRebootMark removes the reboot mark to signal that the reboot has been |
460 | 267 | // handled. | 315 | // handled. |
461 | 268 | func RemoveRebootMark(c *check.C) { | 316 | func RemoveRebootMark(c *check.C) { |
462 | 269 | 317 | ||
463 | === removed directory '_integration-tests/tests/update' | |||
464 | === modified file 'run-checks' | |||
465 | --- run-checks 2015-07-08 15:50:31 +0000 | |||
466 | +++ run-checks 2015-07-21 00:41:17 +0000 | |||
467 | @@ -76,7 +76,7 @@ | |||
468 | 76 | 76 | ||
469 | 77 | # integration suite in kvm | 77 | # integration suite in kvm |
470 | 78 | if which adt-run >/dev/null 2>&1; then | 78 | if which adt-run >/dev/null 2>&1; then |
472 | 79 | echo "Running integration tests" | 79 | echo "Running integration tests on rolling edge" |
473 | 80 | go run _integration-tests/main.go --snappy-from-branch | 80 | go run _integration-tests/main.go --snappy-from-branch |
474 | 81 | fi | 81 | fi |
475 | 82 | 82 |
I'm not yet able to test this because of the ssh bug.