Merge lp:~elopio/snappy/15.04-backport-integration into lp:~snappy-dev/snappy/15.04-deprecated
- 15.04-backport-integration
- Merge into 15.04-deprecated
Proposed by
Leo Arias
Status: | Superseded |
---|---|
Proposed branch: | lp:~elopio/snappy/15.04-backport-integration |
Merge into: | lp:~snappy-dev/snappy/15.04-deprecated |
Diff against target: |
3484 lines (+2665/-70) 78 files modified
_integration-tests/README.md (+117/-0) _integration-tests/data/snaps/basic/meta/package.yaml (+4/-0) _integration-tests/data/snaps/basic/meta/readme.md (+3/-0) _integration-tests/data/snaps/missing-readme/meta/package.yaml (+4/-0) _integration-tests/data/snaps/wrong-yaml/meta/package.yaml (+5/-0) _integration-tests/data/snaps/wrong-yaml/meta/readme.md (+3/-0) _integration-tests/data/tpl/control (+4/-0) _integration-tests/main.go (+105/-0) _integration-tests/reboot-wrapper (+35/-0) _integration-tests/tests/apt_test.go (+39/-0) _integration-tests/tests/base_test.go (+29/-0) _integration-tests/tests/build_test.go (+90/-0) _integration-tests/tests/failover_rclocal_crash_test.go (+54/-0) _integration-tests/tests/failover_systemd_loop_test.go (+114/-0) _integration-tests/tests/failover_test.go (+58/-0) _integration-tests/tests/failover_zero_size_file_test.go (+258/-0) _integration-tests/tests/info_test.go (+79/-0) _integration-tests/tests/installApp_test.go (+128/-0) _integration-tests/tests/installFramework_test.go (+93/-0) _integration-tests/tests/list_test.go (+78/-0) _integration-tests/tests/rollback_test.go (+53/-0) _integration-tests/tests/search_test.go (+44/-0) _integration-tests/tests/update_test.go (+51/-0) _integration-tests/tests/writablePaths_test.go (+106/-0) _integration-tests/testutils/autopkgtest/autopkgtest.go (+111/-0) _integration-tests/testutils/autopkgtest/ssh.go (+46/-0) _integration-tests/testutils/build/build.go (+76/-0) _integration-tests/testutils/common/common.go (+379/-0) _integration-tests/testutils/common/common_test.go (+68/-0) _integration-tests/testutils/config/config.go (+75/-0) _integration-tests/testutils/config/config_test.go (+121/-0) _integration-tests/testutils/image/image.go (+86/-0) _integration-tests/testutils/testutils.go (+61/-0) clickdeb/deb_test.go (+2/-2) cmd/snappy/cmd_low_level_unpack_test.go (+1/-1) cmd/snappy/cmd_set_test.go (+2/-2) coreconfig/config_test.go (+2/-2) debian/control (+1/-1) dependencies.tsv (+1/-1) helpers/cmp_test.go (+1/-1) helpers/helpers_test.go (+1/-1) helpers/touch_test.go (+1/-1) logger/logger_test.go (+1/-1) oauth/oauth_test.go (+1/-1) partition/bootloader_grub_test.go (+1/-1) partition/bootloader_uboot_test.go (+1/-1) partition/partition_test.go (+2/-2) partition/utils_test.go (+1/-1) policy/policy_test.go (+3/-2) priv/priv_test.go (+1/-1) progress/progress_test.go (+2/-2) release/release_test.go (+2/-2) run-checks (+19/-3) snappy/auth_test.go (+13/-13) snappy/build_test.go (+1/-1) snappy/click_test.go (+2/-2) snappy/common_test.go (+3/-2) snappy/config_test.go (+1/-1) snappy/datadir_test.go (+1/-1) snappy/dbus_test.go (+1/-1) snappy/firstboot_test.go (+1/-1) snappy/hashes_test.go (+1/-1) snappy/hwaccess_test.go (+1/-1) snappy/install_test.go (+1/-1) snappy/oem_test.go (+1/-1) snappy/parts_test.go (+1/-1) snappy/purge_test.go (+1/-1) snappy/remove_test.go (+1/-1) snappy/rollback_test.go (+1/-1) snappy/security_test.go (+1/-1) snappy/set_test.go (+1/-1) snappy/snapp_test.go (+1/-1) snappy/sort_test.go (+1/-1) snappy/systemimage_native_test.go (+1/-1) snappy/systemimage_test.go (+2/-2) snappy/timeout_test.go (+1/-1) snappy/udev_test.go (+1/-1) systemd/systemd_test.go (+2/-2) |
To merge this branch: | bzr merge lp:~elopio/snappy/15.04-backport-integration |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Federico Gimenez (community) | tested | Approve | |
Review via email:
|
This proposal has been superseded by a proposal from 2015-08-02.
Commit message
Backported 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 : | # |
Thanks for this Leo, leaving my approval here
review:
Approve
(tested)
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Federico Gimenez (fgimenez) wrote : | # |
There's a problem with the gocheck dependency, the installed package name doesn't match the import name [1]. We should modify also dependencies.tsv.
Thanks!
[1] http://
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory '_integration-tests' | |||
2 | === added file '_integration-tests/README.md' | |||
3 | --- _integration-tests/README.md 1970-01-01 00:00:00 +0000 | |||
4 | +++ _integration-tests/README.md 2015-08-02 12:28:18 +0000 | |||
5 | @@ -0,0 +1,117 @@ | |||
6 | 1 | # Integration testing for snappy | ||
7 | 2 | |||
8 | 3 | ## Requirements | ||
9 | 4 | |||
10 | 5 | * autopkgtest (>= 3.15.1) | ||
11 | 6 | |||
12 | 7 | Get the latest autopkgtest deb from | ||
13 | 8 | https://packages.debian.org/sid/all/autopkgtest/download | ||
14 | 9 | |||
15 | 10 | * Internet access in the test bed. | ||
16 | 11 | |||
17 | 12 | ## Setting up the project | ||
18 | 13 | |||
19 | 14 | First you need to set up the GOPATH, get the snappy sources and the | ||
20 | 15 | dependencies as explained in the `README.md` that is located at the root of the | ||
21 | 16 | branch. | ||
22 | 17 | |||
23 | 18 | ## Testing a virtual machine | ||
24 | 19 | |||
25 | 20 | You can execute the full integration suite in a local virtual machine with: | ||
26 | 21 | |||
27 | 22 | go run _integration-tests/main.go | ||
28 | 23 | |||
29 | 24 | The test runner will create the snappy images with `ubuntu-device-flash`, so it | ||
30 | 25 | will ask for your password to run this command with `sudo`. | ||
31 | 26 | |||
32 | 27 | You can also especify more options to customize the image being created, including | ||
33 | 28 | the release, the channel and the revision to use. This parameters will be passed | ||
34 | 29 | to `ubuntu-device-flash`: | ||
35 | 30 | |||
36 | 31 | go run _integration-tests/main.go -release 15.04 -channel stable -revision 3 | ||
37 | 32 | |||
38 | 33 | The default values are suited to testing the most recent version, `rolling` for | ||
39 | 34 | release, `edge` for channel and an empty revision, which picks the latest | ||
40 | 35 | available. | ||
41 | 36 | |||
42 | 37 | ## Testing snappy from a branch | ||
43 | 38 | |||
44 | 39 | With the --snappy-from-branch flag, the snappy CLI command will be compiled | ||
45 | 40 | from the current branch, copied to the test bed and used during the integration | ||
46 | 41 | tests: | ||
47 | 42 | |||
48 | 43 | go run _integration-tests/main.go --snappy-from-branch | ||
49 | 44 | |||
50 | 45 | You can use this flag to test in a remote machine too. | ||
51 | 46 | |||
52 | 47 | ## Filtering the tests to run | ||
53 | 48 | |||
54 | 49 | With the --filter flag you can select the tests to run. For instance you can | ||
55 | 50 | pass MyTestSuite, MyTestSuite.FirstCustomTest or MyTestSuite.*CustomTest: | ||
56 | 51 | |||
57 | 52 | go run _integration-tests/main.go --filter MyTestSuite.FirstCustomTest | ||
58 | 53 | |||
59 | 54 | ## Testing a remote machine | ||
60 | 55 | |||
61 | 56 | You can execute the integration suite in a remote snappy machine with: | ||
62 | 57 | |||
63 | 58 | go run _integration-tests/main.go --ip {testbed-ip} --port {testbed-port} \ | ||
64 | 59 | --arch {testbed-arch} | ||
65 | 60 | |||
66 | 61 | The test runner will use `ssh-copy-id` to send your identity file to the | ||
67 | 62 | testbed, so it will ask for the password of the ubuntu user in the test bed. | ||
68 | 63 | |||
69 | 64 | When running in a remote machine, the test runner assumes the test bed is in | ||
70 | 65 | the latest rolling edge version, and it will skip all the tests that | ||
71 | 66 | require a different version. See the following section for instructions for | ||
72 | 67 | setting up a BeagleBone Black as the test bed. | ||
73 | 68 | |||
74 | 69 | ## Testing a BeagleBone Black | ||
75 | 70 | |||
76 | 71 | First flash the latest 15.04 edge version into the sd card | ||
77 | 72 | (replacing /dev/sdX with the path to your card): | ||
78 | 73 | |||
79 | 74 | sudo ubuntu-device-flash core 15.04 --channel edge --oem beagleblack \ | ||
80 | 75 | --developer-mode --enable-ssh -o ubuntu-15.04-edge-armhf-bbb.img | ||
81 | 76 | |||
82 | 77 | sudo dd if=ubuntu-15.04-edge-armhf-bbb.img of=/dev/sdX bs=32M | ||
83 | 78 | sync | ||
84 | 79 | |||
85 | 80 | Then boot the board with the sd card, make sure that it is connected to the | ||
86 | 81 | same network as the test runner host, and find the {beaglebone-ip}. | ||
87 | 82 | |||
88 | 83 | Run the tests with: | ||
89 | 84 | |||
90 | 85 | go run _integration-tests/main.go --ip {beaglebone-ip} --arch arm | ||
91 | 86 | |||
92 | 87 | ## Testing an update | ||
93 | 88 | |||
94 | 89 | With the --update flag you can flash an old image, update to the latest and | ||
95 | 90 | then run the whole suite on the updated system. The release, the channel and | ||
96 | 91 | the revision flags specify the image that will be flashed, and the | ||
97 | 92 | target-release and target-channel flags specify the values to be used in the | ||
98 | 93 | update if they are different from the flashed values. | ||
99 | 94 | |||
100 | 95 | For example, to update from 15.04 edge -1 to the latest and then run the | ||
101 | 96 | integration tests: | ||
102 | 97 | |||
103 | 98 | go run _integration-tests/main.go --snappy-from-branch \ | ||
104 | 99 | --release=15.04 --revision=-1 --update | ||
105 | 100 | |||
106 | 101 | To update from 15.04 alpha to 15.04 edge and then run the integration tests: | ||
107 | 102 | |||
108 | 103 | go run _integration-tests/main.go --snappy-from-branch \ | ||
109 | 104 | --release=15.04 --channel=alpha \ | ||
110 | 105 | --update --target-channel=edge | ||
111 | 106 | |||
112 | 107 | ## Testing a rollback | ||
113 | 108 | |||
114 | 109 | With the --rollback flag you can flash an old image, update to the latest, | ||
115 | 110 | rollback again to the old image and then run the whole suite on the rolled | ||
116 | 111 | back system. You should use the release, channel, revision, target-release and | ||
117 | 112 | target-channel flags as when testing an update. | ||
118 | 113 | |||
119 | 114 | For example, to test a rollback from latest 15.04 edge to 15.04 edge -1: | ||
120 | 115 | |||
121 | 116 | go run _integration-tests/main.go \ | ||
122 | 117 | --release=15.04 --revision=-1 --rollback | ||
123 | 0 | 118 | ||
124 | === added directory '_integration-tests/data' | |||
125 | === added directory '_integration-tests/data/snaps' | |||
126 | === added directory '_integration-tests/data/snaps/basic' | |||
127 | === added directory '_integration-tests/data/snaps/basic/meta' | |||
128 | === added file '_integration-tests/data/snaps/basic/meta/package.yaml' | |||
129 | --- _integration-tests/data/snaps/basic/meta/package.yaml 1970-01-01 00:00:00 +0000 | |||
130 | +++ _integration-tests/data/snaps/basic/meta/package.yaml 2015-08-02 12:28:18 +0000 | |||
131 | @@ -0,0 +1,4 @@ | |||
132 | 1 | name: basic | ||
133 | 2 | version: 1.0 | ||
134 | 3 | vendor: Snappy Developers <snappy-devel@lists.ubuntu.com> | ||
135 | 4 | icon: meta/snappy64.png | ||
136 | 0 | 5 | ||
137 | === added file '_integration-tests/data/snaps/basic/meta/readme.md' | |||
138 | --- _integration-tests/data/snaps/basic/meta/readme.md 1970-01-01 00:00:00 +0000 | |||
139 | +++ _integration-tests/data/snaps/basic/meta/readme.md 2015-08-02 12:28:18 +0000 | |||
140 | @@ -0,0 +1,3 @@ | |||
141 | 1 | Basic snap | ||
142 | 2 | |||
143 | 3 | A basic buildable snap | ||
144 | 0 | 4 | ||
145 | === added file '_integration-tests/data/snaps/basic/meta/snappy64.png' | |||
146 | 1 | Binary files _integration-tests/data/snaps/basic/meta/snappy64.png 1970-01-01 00:00:00 +0000 and _integration-tests/data/snaps/basic/meta/snappy64.png 2015-08-02 12:28:18 +0000 differ | 5 | Binary files _integration-tests/data/snaps/basic/meta/snappy64.png 1970-01-01 00:00:00 +0000 and _integration-tests/data/snaps/basic/meta/snappy64.png 2015-08-02 12:28:18 +0000 differ |
147 | === added directory '_integration-tests/data/snaps/missing-readme' | |||
148 | === added directory '_integration-tests/data/snaps/missing-readme/meta' | |||
149 | === added file '_integration-tests/data/snaps/missing-readme/meta/package.yaml' | |||
150 | --- _integration-tests/data/snaps/missing-readme/meta/package.yaml 1970-01-01 00:00:00 +0000 | |||
151 | +++ _integration-tests/data/snaps/missing-readme/meta/package.yaml 2015-08-02 12:28:18 +0000 | |||
152 | @@ -0,0 +1,4 @@ | |||
153 | 1 | name: missing-readme | ||
154 | 2 | version: 1.0 | ||
155 | 3 | vendor: Snappy Developers <snappy-devel@lists.ubuntu.com> | ||
156 | 4 | icon: meta/snappy64.png | ||
157 | 0 | 5 | ||
158 | === added file '_integration-tests/data/snaps/missing-readme/meta/snappy64.png' | |||
159 | 1 | Binary files _integration-tests/data/snaps/missing-readme/meta/snappy64.png 1970-01-01 00:00:00 +0000 and _integration-tests/data/snaps/missing-readme/meta/snappy64.png 2015-08-02 12:28:18 +0000 differ | 6 | Binary files _integration-tests/data/snaps/missing-readme/meta/snappy64.png 1970-01-01 00:00:00 +0000 and _integration-tests/data/snaps/missing-readme/meta/snappy64.png 2015-08-02 12:28:18 +0000 differ |
160 | === added directory '_integration-tests/data/snaps/wrong-yaml' | |||
161 | === added directory '_integration-tests/data/snaps/wrong-yaml/meta' | |||
162 | === added file '_integration-tests/data/snaps/wrong-yaml/meta/package.yaml' | |||
163 | --- _integration-tests/data/snaps/wrong-yaml/meta/package.yaml 1970-01-01 00:00:00 +0000 | |||
164 | +++ _integration-tests/data/snaps/wrong-yaml/meta/package.yaml 2015-08-02 12:28:18 +0000 | |||
165 | @@ -0,0 +1,5 @@ | |||
166 | 1 | # This is an invalid yaml, there's a missing colon after the 'name' field | ||
167 | 2 | name wrong-yaml | ||
168 | 3 | version: 1.0 | ||
169 | 4 | vendor: Snappy Developers <snappy-devel@lists.ubuntu.com> | ||
170 | 5 | icon: meta/snappy64.png | ||
171 | 0 | 6 | ||
172 | === added file '_integration-tests/data/snaps/wrong-yaml/meta/readme.md' | |||
173 | --- _integration-tests/data/snaps/wrong-yaml/meta/readme.md 1970-01-01 00:00:00 +0000 | |||
174 | +++ _integration-tests/data/snaps/wrong-yaml/meta/readme.md 2015-08-02 12:28:18 +0000 | |||
175 | @@ -0,0 +1,3 @@ | |||
176 | 1 | Wrong metadata snap | ||
177 | 2 | |||
178 | 3 | A snap with an invalid meta/package.yaml | ||
179 | 0 | 4 | ||
180 | === added file '_integration-tests/data/snaps/wrong-yaml/meta/snappy64.png' | |||
181 | 1 | Binary files _integration-tests/data/snaps/wrong-yaml/meta/snappy64.png 1970-01-01 00:00:00 +0000 and _integration-tests/data/snaps/wrong-yaml/meta/snappy64.png 2015-08-02 12:28:18 +0000 differ | 5 | Binary files _integration-tests/data/snaps/wrong-yaml/meta/snappy64.png 1970-01-01 00:00:00 +0000 and _integration-tests/data/snaps/wrong-yaml/meta/snappy64.png 2015-08-02 12:28:18 +0000 differ |
182 | === added directory '_integration-tests/data/tpl' | |||
183 | === added file '_integration-tests/data/tpl/control' | |||
184 | --- _integration-tests/data/tpl/control 1970-01-01 00:00:00 +0000 | |||
185 | +++ _integration-tests/data/tpl/control 2015-08-02 12:28:18 +0000 | |||
186 | @@ -0,0 +1,4 @@ | |||
187 | 1 | {{ $filter := .Filter }} | ||
188 | 2 | {{ $test := .Test }} | ||
189 | 3 | Test-Command: ./_integration-tests/reboot-wrapper {{ $test }} {{ if $filter }}-gocheck.f {{ $filter }}{{ end }} | ||
190 | 4 | Restrictions: allow-stderr | ||
191 | 0 | 5 | ||
192 | === added file '_integration-tests/main.go' | |||
193 | --- _integration-tests/main.go 1970-01-01 00:00:00 +0000 | |||
194 | +++ _integration-tests/main.go 2015-08-02 12:28:18 +0000 | |||
195 | @@ -0,0 +1,105 @@ | |||
196 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
197 | 2 | |||
198 | 3 | /* | ||
199 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
200 | 5 | * | ||
201 | 6 | * This program is free software: you can redistribute it and/or modify | ||
202 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
203 | 8 | * published by the Free Software Foundation. | ||
204 | 9 | * | ||
205 | 10 | * This program is distributed in the hope that it will be useful, | ||
206 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
207 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
208 | 13 | * GNU General Public License for more details. | ||
209 | 14 | * | ||
210 | 15 | * You should have received a copy of the GNU General Public License | ||
211 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
212 | 17 | * | ||
213 | 18 | */ | ||
214 | 19 | |||
215 | 20 | package main | ||
216 | 21 | |||
217 | 22 | import ( | ||
218 | 23 | "flag" | ||
219 | 24 | "log" | ||
220 | 25 | "os" | ||
221 | 26 | "path/filepath" | ||
222 | 27 | "strconv" | ||
223 | 28 | |||
224 | 29 | "launchpad.net/snappy/_integration-tests/testutils" | ||
225 | 30 | "launchpad.net/snappy/_integration-tests/testutils/autopkgtest" | ||
226 | 31 | "launchpad.net/snappy/_integration-tests/testutils/build" | ||
227 | 32 | "launchpad.net/snappy/_integration-tests/testutils/config" | ||
228 | 33 | "launchpad.net/snappy/_integration-tests/testutils/image" | ||
229 | 34 | ) | ||
230 | 35 | |||
231 | 36 | const ( | ||
232 | 37 | baseDir = "/tmp/snappy-test" | ||
233 | 38 | defaultRelease = "rolling" | ||
234 | 39 | defaultChannel = "edge" | ||
235 | 40 | defaultSSHPort = 22 | ||
236 | 41 | dataOutputDir = "_integration-tests/data/output/" | ||
237 | 42 | ) | ||
238 | 43 | |||
239 | 44 | var configFileName = filepath.Join(dataOutputDir, "testconfig.json") | ||
240 | 45 | |||
241 | 46 | func main() { | ||
242 | 47 | var ( | ||
243 | 48 | useSnappyFromBranch = flag.Bool("snappy-from-branch", false, | ||
244 | 49 | "If this flag is used, snappy will be compiled from this branch, copied to the testbed and used for the tests. Otherwise, the snappy installed with the image will be used.") | ||
245 | 50 | arch = flag.String("arch", "", | ||
246 | 51 | "Architecture of the test bed. Defaults to use the same architecture as the host.") | ||
247 | 52 | testbedIP = flag.String("ip", "", | ||
248 | 53 | "IP of the testbed. If no IP is passed, a virtual machine will be created for the test.") | ||
249 | 54 | testbedPort = flag.Int("port", defaultSSHPort, | ||
250 | 55 | "SSH port of the testbed. Defaults to use port "+strconv.Itoa(defaultSSHPort)) | ||
251 | 56 | testFilter = flag.String("filter", "", | ||
252 | 57 | "Suites or tests to run, for instance MyTestSuite, MyTestSuite.FirstCustomTest or MyTestSuite.*CustomTest") | ||
253 | 58 | imgRelease = flag.String("release", defaultRelease, | ||
254 | 59 | "Release of the image to be built, defaults to "+defaultRelease) | ||
255 | 60 | imgChannel = flag.String("channel", defaultChannel, | ||
256 | 61 | "Channel of the image to be built, defaults to "+defaultChannel) | ||
257 | 62 | imgRevision = flag.String("revision", "", | ||
258 | 63 | "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") | ||
259 | 64 | update = flag.Bool("update", false, | ||
260 | 65 | "If this flag is used, the image will be updated before running the tests.") | ||
261 | 66 | targetRelease = flag.String("target-release", "", | ||
262 | 67 | "If the update flag is used, the image will be updated to this release before running the tests.") | ||
263 | 68 | targetChannel = flag.String("target-channel", "", | ||
264 | 69 | "If the update flag is used, the image will be updated to this channel before running the tests.") | ||
265 | 70 | rollback = flag.Bool("rollback", false, | ||
266 | 71 | "If this flag is used, the image will be updated and then rolled back before running the tests.") | ||
267 | 72 | ) | ||
268 | 73 | |||
269 | 74 | flag.Parse() | ||
270 | 75 | |||
271 | 76 | build.Assets(*useSnappyFromBranch, *arch) | ||
272 | 77 | |||
273 | 78 | // TODO: generate the files out of the source tree. --elopio - 2015-07-15 | ||
274 | 79 | testutils.PrepareTargetDir(dataOutputDir) | ||
275 | 80 | defer os.RemoveAll(dataOutputDir) | ||
276 | 81 | |||
277 | 82 | remoteTestbed := *testbedIP != "" | ||
278 | 83 | |||
279 | 84 | // TODO: pass the config as arguments to the test binaries. | ||
280 | 85 | // --elopio - 2015-07-15 | ||
281 | 86 | cfg := config.NewConfig( | ||
282 | 87 | configFileName, *imgRelease, *imgChannel, *targetRelease, *targetChannel, | ||
283 | 88 | remoteTestbed, *update, *rollback) | ||
284 | 89 | cfg.Write() | ||
285 | 90 | |||
286 | 91 | rootPath := testutils.RootPath() | ||
287 | 92 | |||
288 | 93 | test := autopkgtest.NewAutopkgtest(rootPath, baseDir, *testFilter, build.IntegrationTestName) | ||
289 | 94 | if !remoteTestbed { | ||
290 | 95 | img := image.NewImage(*imgRelease, *imgChannel, *imgRevision, baseDir) | ||
291 | 96 | |||
292 | 97 | if imagePath, err := img.UdfCreate(); err == nil { | ||
293 | 98 | test.AdtRunLocal(imagePath) | ||
294 | 99 | } else { | ||
295 | 100 | log.Panic(err.Error()) | ||
296 | 101 | } | ||
297 | 102 | } else { | ||
298 | 103 | test.AdtRunRemote(*testbedIP, *testbedPort) | ||
299 | 104 | } | ||
300 | 105 | } | ||
301 | 0 | 106 | ||
302 | === added file '_integration-tests/reboot-wrapper' | |||
303 | --- _integration-tests/reboot-wrapper 1970-01-01 00:00:00 +0000 | |||
304 | +++ _integration-tests/reboot-wrapper 2015-08-02 12:28:18 +0000 | |||
305 | @@ -0,0 +1,35 @@ | |||
306 | 1 | #!/bin/sh | ||
307 | 2 | |||
308 | 3 | # Copyright (C) 2015 Canonical Ltd | ||
309 | 4 | # | ||
310 | 5 | # This program is free software: you can redistribute it and/or modify | ||
311 | 6 | # it under the terms of the GNU General Public License version 3 as | ||
312 | 7 | # published by the Free Software Foundation. | ||
313 | 8 | # | ||
314 | 9 | # This program is distributed in the hope that it will be useful, | ||
315 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
316 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
317 | 12 | # GNU General Public License for more details. | ||
318 | 13 | # | ||
319 | 14 | # You should have received a copy of the GNU General Public License | ||
320 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
321 | 16 | |||
322 | 17 | # This runs the $1 go test binary and reboots if necessary. | ||
323 | 18 | |||
324 | 19 | set -e | ||
325 | 20 | |||
326 | 21 | TEST=$1 | ||
327 | 22 | NEEDS_REBOOT=/tmp/needs-reboot | ||
328 | 23 | |||
329 | 24 | export PATH=$(pwd)/_integration-tests/bin:$PATH | ||
330 | 25 | |||
331 | 26 | # shift to remove the test binary name (first argument) and be able to pass the rest | ||
332 | 27 | # of them to it | ||
333 | 28 | shift | ||
334 | 29 | ${TEST} -check.vv -test.outputdir=$ADT_ARTIFACTS-$ADT_REBOOT_MARK "$@" | ||
335 | 30 | |||
336 | 31 | if [ -e ${NEEDS_REBOOT} ]; then | ||
337 | 32 | mark=`cat ${NEEDS_REBOOT}` | ||
338 | 33 | echo "Rebooting..." | ||
339 | 34 | sudo /tmp/autopkgtest-reboot "$mark" | ||
340 | 35 | fi | ||
341 | 0 | 36 | ||
342 | === added directory '_integration-tests/tests' | |||
343 | === added file '_integration-tests/tests/apt_test.go' | |||
344 | --- _integration-tests/tests/apt_test.go 1970-01-01 00:00:00 +0000 | |||
345 | +++ _integration-tests/tests/apt_test.go 2015-08-02 12:28:18 +0000 | |||
346 | @@ -0,0 +1,39 @@ | |||
347 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
348 | 2 | |||
349 | 3 | /* | ||
350 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
351 | 5 | * | ||
352 | 6 | * This program is free software: you can redistribute it and/or modify | ||
353 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
354 | 8 | * published by the Free Software Foundation. | ||
355 | 9 | * | ||
356 | 10 | * This program is distributed in the hope that it will be useful, | ||
357 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
358 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
359 | 13 | * GNU General Public License for more details. | ||
360 | 14 | * | ||
361 | 15 | * You should have received a copy of the GNU General Public License | ||
362 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
363 | 17 | * | ||
364 | 18 | */ | ||
365 | 19 | |||
366 | 20 | package tests | ||
367 | 21 | |||
368 | 22 | import ( | ||
369 | 23 | . "launchpad.net/snappy/_integration-tests/testutils/common" | ||
370 | 24 | |||
371 | 25 | check "gopkg.in/check.v1" | ||
372 | 26 | ) | ||
373 | 27 | |||
374 | 28 | var _ = check.Suite(&aptSuite{}) | ||
375 | 29 | |||
376 | 30 | type aptSuite struct { | ||
377 | 31 | SnappySuite | ||
378 | 32 | } | ||
379 | 33 | |||
380 | 34 | func (s *aptSuite) TestAptGetMustPrintError(c *check.C) { | ||
381 | 35 | aptOutput := ExecCommand(c, "apt-get", "update") | ||
382 | 36 | |||
383 | 37 | expected := "Ubuntu Core does not use apt-get, see 'snappy --help'!\n" | ||
384 | 38 | c.Assert(aptOutput, check.Equals, expected) | ||
385 | 39 | } | ||
386 | 0 | 40 | ||
387 | === added file '_integration-tests/tests/base_test.go' | |||
388 | --- _integration-tests/tests/base_test.go 1970-01-01 00:00:00 +0000 | |||
389 | +++ _integration-tests/tests/base_test.go 2015-08-02 12:28:18 +0000 | |||
390 | @@ -0,0 +1,29 @@ | |||
391 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
392 | 2 | |||
393 | 3 | /* | ||
394 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
395 | 5 | * | ||
396 | 6 | * This program is free software: you can redistribute it and/or modify | ||
397 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
398 | 8 | * published by the Free Software Foundation. | ||
399 | 9 | * | ||
400 | 10 | * This program is distributed in the hope that it will be useful, | ||
401 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
402 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
403 | 13 | * GNU General Public License for more details. | ||
404 | 14 | * | ||
405 | 15 | * You should have received a copy of the GNU General Public License | ||
406 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
407 | 17 | * | ||
408 | 18 | */ | ||
409 | 19 | |||
410 | 20 | package tests | ||
411 | 21 | |||
412 | 22 | import ( | ||
413 | 23 | "testing" | ||
414 | 24 | |||
415 | 25 | . "gopkg.in/check.v1" | ||
416 | 26 | ) | ||
417 | 27 | |||
418 | 28 | // Hook up gocheck into the "go test" runner. | ||
419 | 29 | func Test(t *testing.T) { TestingT(t) } | ||
420 | 0 | 30 | ||
421 | === added file '_integration-tests/tests/build_test.go' | |||
422 | --- _integration-tests/tests/build_test.go 1970-01-01 00:00:00 +0000 | |||
423 | +++ _integration-tests/tests/build_test.go 2015-08-02 12:28:18 +0000 | |||
424 | @@ -0,0 +1,90 @@ | |||
425 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
426 | 2 | |||
427 | 3 | /* | ||
428 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
429 | 5 | * | ||
430 | 6 | * This program is free software: you can redistribute it and/or modify | ||
431 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
432 | 8 | * published by the Free Software Foundation. | ||
433 | 9 | * | ||
434 | 10 | * This program is distributed in the hope that it will be useful, | ||
435 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
436 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
437 | 13 | * GNU General Public License for more details. | ||
438 | 14 | * | ||
439 | 15 | * You should have received a copy of the GNU General Public License | ||
440 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
441 | 17 | * | ||
442 | 18 | */ | ||
443 | 19 | |||
444 | 20 | package tests | ||
445 | 21 | |||
446 | 22 | import ( | ||
447 | 23 | "fmt" | ||
448 | 24 | "os" | ||
449 | 25 | "os/exec" | ||
450 | 26 | |||
451 | 27 | . "launchpad.net/snappy/_integration-tests/testutils/common" | ||
452 | 28 | |||
453 | 29 | . "gopkg.in/check.v1" | ||
454 | 30 | ) | ||
455 | 31 | |||
456 | 32 | const ( | ||
457 | 33 | baseSnapPath = "_integration-tests/data/snaps" | ||
458 | 34 | basicSnapName = "basic" | ||
459 | 35 | wrongYamlSnapName = "wrong-yaml" | ||
460 | 36 | missingReadmeSnapName = "missing-readme" | ||
461 | 37 | ) | ||
462 | 38 | |||
463 | 39 | var _ = Suite(&buildSuite{}) | ||
464 | 40 | |||
465 | 41 | type buildSuite struct { | ||
466 | 42 | SnappySuite | ||
467 | 43 | } | ||
468 | 44 | |||
469 | 45 | func buildSnap(c *C, snapPath string) string { | ||
470 | 46 | return ExecCommand(c, "snappy", "build", snapPath) | ||
471 | 47 | } | ||
472 | 48 | |||
473 | 49 | func (s *buildSuite) TestBuildBasicSnapOnSnappy(c *C) { | ||
474 | 50 | // build basic snap and check output | ||
475 | 51 | snapPath := baseSnapPath + "/" + basicSnapName | ||
476 | 52 | buildOutput := buildSnap(c, snapPath) | ||
477 | 53 | snapName := basicSnapName + "_1.0_all.snap" | ||
478 | 54 | expected := fmt.Sprintf("Generated '%s' snap\n", snapName) | ||
479 | 55 | c.Check(buildOutput, Equals, expected) | ||
480 | 56 | defer os.Remove(snapPath + "/" + snapName) | ||
481 | 57 | |||
482 | 58 | // install built snap and check output | ||
483 | 59 | installOutput := InstallSnap(c, snapName) | ||
484 | 60 | defer RemoveSnap(c, basicSnapName) | ||
485 | 61 | expected = "(?ms)" + | ||
486 | 62 | "Installing " + snapName + "\n" + | ||
487 | 63 | ".*Signature check failed, but installing anyway as requested\n" + | ||
488 | 64 | "Name +Date +Version +Developer \n" + | ||
489 | 65 | ".*\n" + | ||
490 | 66 | basicSnapName + " +.* +.* +sideload \n" + | ||
491 | 67 | ".*\n" | ||
492 | 68 | |||
493 | 69 | c.Check(installOutput, Matches, expected) | ||
494 | 70 | |||
495 | 71 | // teardown, remove snap file | ||
496 | 72 | c.Assert(os.Remove(snapName), IsNil, Commentf("Error removing %s", snapName)) | ||
497 | 73 | } | ||
498 | 74 | |||
499 | 75 | func (s *buildSuite) TestBuildWrongYamlSnapOnSnappy(c *C) { | ||
500 | 76 | commonWrongTest(c, wrongYamlSnapName, "(?msi).*Can not parse.*yaml: line 2: mapping values are not allowed in this context.*") | ||
501 | 77 | } | ||
502 | 78 | |||
503 | 79 | func (s *buildSuite) TestBuildMissingReadmeSnapOnSnappy(c *C) { | ||
504 | 80 | commonWrongTest(c, missingReadmeSnapName, ".*readme.md: no such file or directory\n") | ||
505 | 81 | } | ||
506 | 82 | |||
507 | 83 | func commonWrongTest(c *C, testName, expected string) { | ||
508 | 84 | // build wrong snap and check output | ||
509 | 85 | cmd := exec.Command("snappy", "build", fmt.Sprintf("%s/%s", baseSnapPath, testName)) | ||
510 | 86 | echoOutput, err := cmd.CombinedOutput() | ||
511 | 87 | c.Assert(err, NotNil, Commentf("%s should not be built", testName)) | ||
512 | 88 | |||
513 | 89 | c.Assert(string(echoOutput), Matches, expected) | ||
514 | 90 | } | ||
515 | 0 | 91 | ||
516 | === added file '_integration-tests/tests/failover_rclocal_crash_test.go' | |||
517 | --- _integration-tests/tests/failover_rclocal_crash_test.go 1970-01-01 00:00:00 +0000 | |||
518 | +++ _integration-tests/tests/failover_rclocal_crash_test.go 2015-08-02 12:28:18 +0000 | |||
519 | @@ -0,0 +1,54 @@ | |||
520 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
521 | 2 | |||
522 | 3 | /* | ||
523 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
524 | 5 | * | ||
525 | 6 | * This program is free software: you can redistribute it and/or modify | ||
526 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
527 | 8 | * published by the Free Software Foundation. | ||
528 | 9 | * | ||
529 | 10 | * This program is distributed in the hope that it will be useful, | ||
530 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
531 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
532 | 13 | * GNU General Public License for more details. | ||
533 | 14 | * | ||
534 | 15 | * You should have received a copy of the GNU General Public License | ||
535 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
536 | 17 | * | ||
537 | 18 | */ | ||
538 | 19 | |||
539 | 20 | package tests | ||
540 | 21 | |||
541 | 22 | import ( | ||
542 | 23 | "fmt" | ||
543 | 24 | |||
544 | 25 | . "launchpad.net/snappy/_integration-tests/testutils/common" | ||
545 | 26 | |||
546 | 27 | check "gopkg.in/check.v1" | ||
547 | 28 | ) | ||
548 | 29 | |||
549 | 30 | type rcLocalCrash struct{} | ||
550 | 31 | |||
551 | 32 | func (rcLocalCrash) set(c *check.C) { | ||
552 | 33 | MakeWritable(c, BaseAltPartitionPath) | ||
553 | 34 | defer MakeReadonly(c, BaseAltPartitionPath) | ||
554 | 35 | targetFile := fmt.Sprintf("%s/etc/rc.local", BaseAltPartitionPath) | ||
555 | 36 | ExecCommand(c, "sudo", "chmod", "a+xw", targetFile) | ||
556 | 37 | ExecCommandToFile(c, targetFile, | ||
557 | 38 | "sudo", "echo", "#!bin/sh\nprintf c > /proc/sysrq-trigger") | ||
558 | 39 | } | ||
559 | 40 | |||
560 | 41 | func (rcLocalCrash) unset(c *check.C) { | ||
561 | 42 | MakeWritable(c, BaseAltPartitionPath) | ||
562 | 43 | defer MakeReadonly(c, BaseAltPartitionPath) | ||
563 | 44 | ExecCommand(c, "sudo", "rm", fmt.Sprintf("%s/etc/rc.local", BaseAltPartitionPath)) | ||
564 | 45 | } | ||
565 | 46 | |||
566 | 47 | /* | ||
567 | 48 | TODO: uncomment when bug https://bugs.launchpad.net/snappy/+bug/1476129 is fixed | ||
568 | 49 | (fgimenez 20150728) | ||
569 | 50 | |||
570 | 51 | func (s *failoverSuite) TestRCLocalCrash(c *check.C) { | ||
571 | 52 | commonFailoverTest(c, rcLocalCrash{}) | ||
572 | 53 | } | ||
573 | 54 | */ | ||
574 | 0 | 55 | ||
575 | === added file '_integration-tests/tests/failover_systemd_loop_test.go' | |||
576 | --- _integration-tests/tests/failover_systemd_loop_test.go 1970-01-01 00:00:00 +0000 | |||
577 | +++ _integration-tests/tests/failover_systemd_loop_test.go 2015-08-02 12:28:18 +0000 | |||
578 | @@ -0,0 +1,114 @@ | |||
579 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
580 | 2 | |||
581 | 3 | /* | ||
582 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
583 | 5 | * | ||
584 | 6 | * This program is free software: you can redistribute it and/or modify | ||
585 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
586 | 8 | * published by the Free Software Foundation. | ||
587 | 9 | * | ||
588 | 10 | * This program is distributed in the hope that it will be useful, | ||
589 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
590 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
591 | 13 | * GNU General Public License for more details. | ||
592 | 14 | * | ||
593 | 15 | * You should have received a copy of the GNU General Public License | ||
594 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
595 | 17 | * | ||
596 | 18 | */ | ||
597 | 19 | |||
598 | 20 | package tests | ||
599 | 21 | |||
600 | 22 | import ( | ||
601 | 23 | "fmt" | ||
602 | 24 | |||
603 | 25 | . "launchpad.net/snappy/_integration-tests/testutils/common" | ||
604 | 26 | |||
605 | 27 | check "gopkg.in/check.v1" | ||
606 | 28 | ) | ||
607 | 29 | |||
608 | 30 | const ( | ||
609 | 31 | deadlockService = `[Unit] | ||
610 | 32 | Before=sysinit.target | ||
611 | 33 | DefaultDependencies=no | ||
612 | 34 | |||
613 | 35 | [Service] | ||
614 | 36 | Type=oneshot | ||
615 | 37 | ExecStartPre=-/bin/sh -c "echo 'DEBUG: $(date): deadlocked system' >/dev/console" | ||
616 | 38 | ExecStartPre=-/bin/sh -c "echo 'DEBUG: $(date): deadlocked system' >/dev/ttyS0" | ||
617 | 39 | ExecStart=/bin/systemctl start deadlock.service | ||
618 | 40 | RemainAfterExit=yes | ||
619 | 41 | |||
620 | 42 | [Install] | ||
621 | 43 | RequiredBy=sysinit.target | ||
622 | 44 | ` | ||
623 | 45 | rebootService = `[Unit] | ||
624 | 46 | DefaultDependencies=no | ||
625 | 47 | Description=Hack to force reboot if booting did not finish after 20s | ||
626 | 48 | |||
627 | 49 | [Service] | ||
628 | 50 | Type=oneshot | ||
629 | 51 | ExecStartPre=/bin/sleep 20 | ||
630 | 52 | ExecStart=-/bin/sh -c 'if ! systemctl is-active default.target; then wall "EMERGENCY REBOOT"; reboot -f; fi' | ||
631 | 53 | |||
632 | 54 | [Install] | ||
633 | 55 | RequiredBy=sysinit.target | ||
634 | 56 | ` | ||
635 | 57 | baseSystemdPath = "/lib/systemd/system" | ||
636 | 58 | systemdTargetRequiresDir = "sysinit.target.requires" | ||
637 | 59 | ) | ||
638 | 60 | |||
639 | 61 | type systemdDependencyLoop struct{} | ||
640 | 62 | |||
641 | 63 | func (systemdDependencyLoop) set(c *check.C) { | ||
642 | 64 | installService(c, "deadlock", deadlockService, BaseAltPartitionPath) | ||
643 | 65 | installService(c, "emerg-reboot", rebootService, BaseAltPartitionPath) | ||
644 | 66 | } | ||
645 | 67 | |||
646 | 68 | func (systemdDependencyLoop) unset(c *check.C) { | ||
647 | 69 | unInstallService(c, "deadlock", BaseAltPartitionPath) | ||
648 | 70 | unInstallService(c, "emerg-reboot", BaseAltPartitionPath) | ||
649 | 71 | } | ||
650 | 72 | |||
651 | 73 | func installService(c *check.C, serviceName, serviceCfg, basePath string) { | ||
652 | 74 | MakeWritable(c, basePath) | ||
653 | 75 | defer MakeReadonly(c, basePath) | ||
654 | 76 | |||
655 | 77 | // Create service file | ||
656 | 78 | serviceFile := fmt.Sprintf("%s%s/%s.service", basePath, baseSystemdPath, serviceName) | ||
657 | 79 | ExecCommand(c, "sudo", "chmod", "a+w", fmt.Sprintf("%s%s", basePath, baseSystemdPath)) | ||
658 | 80 | ExecCommandToFile(c, serviceFile, "sudo", "echo", serviceCfg) | ||
659 | 81 | |||
660 | 82 | // Create requires directory | ||
661 | 83 | requiresDirPart := fmt.Sprintf("%s/%s", baseSystemdPath, systemdTargetRequiresDir) | ||
662 | 84 | requiresDir := fmt.Sprintf("%s%s", basePath, requiresDirPart) | ||
663 | 85 | ExecCommand(c, "sudo", "mkdir", "-p", requiresDir) | ||
664 | 86 | |||
665 | 87 | // Symlink from the requires dir to the service file (with chroot for being | ||
666 | 88 | // usable in the other partition) | ||
667 | 89 | ExecCommand(c, "sudo", "chroot", basePath, "ln", "-s", | ||
668 | 90 | fmt.Sprintf("%s/%s.service", baseSystemdPath, serviceName), | ||
669 | 91 | fmt.Sprintf("%s/%s.service", requiresDirPart, serviceName), | ||
670 | 92 | ) | ||
671 | 93 | } | ||
672 | 94 | |||
673 | 95 | func unInstallService(c *check.C, serviceName, basePath string) { | ||
674 | 96 | MakeWritable(c, basePath) | ||
675 | 97 | defer MakeReadonly(c, basePath) | ||
676 | 98 | |||
677 | 99 | // Disable the service | ||
678 | 100 | ExecCommand(c, "sudo", "chroot", basePath, | ||
679 | 101 | "systemctl", "disable", fmt.Sprintf("%s.service", serviceName)) | ||
680 | 102 | |||
681 | 103 | // Remove the service file | ||
682 | 104 | ExecCommand(c, "sudo", "rm", | ||
683 | 105 | fmt.Sprintf("%s%s/%s.service", basePath, baseSystemdPath, serviceName)) | ||
684 | 106 | |||
685 | 107 | // Remove the requires symlink | ||
686 | 108 | ExecCommand(c, "sudo", "rm", | ||
687 | 109 | fmt.Sprintf("%s%s/%s/%s.service", basePath, baseSystemdPath, systemdTargetRequiresDir, serviceName)) | ||
688 | 110 | } | ||
689 | 111 | |||
690 | 112 | func (s *failoverSuite) TestSystemdDependencyLoop(c *check.C) { | ||
691 | 113 | commonFailoverTest(c, systemdDependencyLoop{}) | ||
692 | 114 | } | ||
693 | 0 | 115 | ||
694 | === added file '_integration-tests/tests/failover_test.go' | |||
695 | --- _integration-tests/tests/failover_test.go 1970-01-01 00:00:00 +0000 | |||
696 | +++ _integration-tests/tests/failover_test.go 2015-08-02 12:28:18 +0000 | |||
697 | @@ -0,0 +1,58 @@ | |||
698 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
699 | 2 | |||
700 | 3 | /* | ||
701 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
702 | 5 | * | ||
703 | 6 | * This program is free software: you can redistribute it and/or modify | ||
704 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
705 | 8 | * published by the Free Software Foundation. | ||
706 | 9 | * | ||
707 | 10 | * This program is distributed in the hope that it will be useful, | ||
708 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
709 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
710 | 13 | * GNU General Public License for more details. | ||
711 | 14 | * | ||
712 | 15 | * You should have received a copy of the GNU General Public License | ||
713 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
714 | 17 | * | ||
715 | 18 | */ | ||
716 | 19 | |||
717 | 20 | package tests | ||
718 | 21 | |||
719 | 22 | import ( | ||
720 | 23 | check "gopkg.in/check.v1" | ||
721 | 24 | |||
722 | 25 | . "launchpad.net/snappy/_integration-tests/testutils/common" | ||
723 | 26 | ) | ||
724 | 27 | |||
725 | 28 | var _ = check.Suite(&failoverSuite{}) | ||
726 | 29 | |||
727 | 30 | type failoverSuite struct { | ||
728 | 31 | SnappySuite | ||
729 | 32 | } | ||
730 | 33 | |||
731 | 34 | // The types that implement this interface can be used in the test logic | ||
732 | 35 | type failer interface { | ||
733 | 36 | // Sets the failure conditions | ||
734 | 37 | set(c *check.C) | ||
735 | 38 | // Unsets the failure conditions | ||
736 | 39 | unset(c *check.C) | ||
737 | 40 | } | ||
738 | 41 | |||
739 | 42 | // This is the logic common to all the failover tests. Each of them has define a | ||
740 | 43 | // type implementing the failer interface and call this function with an instance | ||
741 | 44 | // of it | ||
742 | 45 | func commonFailoverTest(c *check.C, f failer) { | ||
743 | 46 | currentVersion := GetCurrentUbuntuCoreVersion(c) | ||
744 | 47 | |||
745 | 48 | if AfterReboot(c) { | ||
746 | 49 | RemoveRebootMark(c) | ||
747 | 50 | f.unset(c) | ||
748 | 51 | c.Assert(GetSavedVersion(c), check.Equals, currentVersion) | ||
749 | 52 | } else { | ||
750 | 53 | SetSavedVersion(c, currentVersion-1) | ||
751 | 54 | CallFakeUpdate(c) | ||
752 | 55 | f.set(c) | ||
753 | 56 | Reboot(c) | ||
754 | 57 | } | ||
755 | 58 | } | ||
756 | 0 | 59 | ||
757 | === added file '_integration-tests/tests/failover_zero_size_file_test.go' | |||
758 | --- _integration-tests/tests/failover_zero_size_file_test.go 1970-01-01 00:00:00 +0000 | |||
759 | +++ _integration-tests/tests/failover_zero_size_file_test.go 2015-08-02 12:28:18 +0000 | |||
760 | @@ -0,0 +1,258 @@ | |||
761 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
762 | 2 | |||
763 | 3 | /* | ||
764 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
765 | 5 | * | ||
766 | 6 | * This program is free software: you can redistribute it and/or modify | ||
767 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
768 | 8 | * published by the Free Software Foundation. | ||
769 | 9 | * | ||
770 | 10 | * This program is distributed in the hope that it will be useful, | ||
771 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
772 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
773 | 13 | * GNU General Public License for more details. | ||
774 | 14 | * | ||
775 | 15 | * You should have received a copy of the GNU General Public License | ||
776 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
777 | 17 | * | ||
778 | 18 | */ | ||
779 | 19 | |||
780 | 20 | package tests | ||
781 | 21 | |||
782 | 22 | import ( | ||
783 | 23 | "bufio" | ||
784 | 24 | "fmt" | ||
785 | 25 | "os" | ||
786 | 26 | "path/filepath" | ||
787 | 27 | "strings" | ||
788 | 28 | |||
789 | 29 | . "launchpad.net/snappy/_integration-tests/testutils/common" | ||
790 | 30 | |||
791 | 31 | check "gopkg.in/check.v1" | ||
792 | 32 | ) | ||
793 | 33 | |||
794 | 34 | const ( | ||
795 | 35 | origBootFilenamePattern = "boot/%s%s*" | ||
796 | 36 | origSystemdFilenamePattern = "lib/systemd/%s%s" | ||
797 | 37 | kernelFilename = "vmlinuz" | ||
798 | 38 | initrdFilename = "initrd" | ||
799 | 39 | systemdFilename = "systemd" | ||
800 | 40 | destFilenamePrefix = "snappy-selftest-" | ||
801 | 41 | bootBase = "/boot" | ||
802 | 42 | ubootDir = bootBase + "/uboot" | ||
803 | 43 | grubDir = bootBase + "/grub" | ||
804 | 44 | ubootConfigFile = ubootDir + "/snappy-system.txt" | ||
805 | 45 | grubConfigFile = grubDir + "/grubenv" | ||
806 | 46 | ) | ||
807 | 47 | |||
808 | 48 | type zeroSizeKernel struct{} | ||
809 | 49 | type zeroSizeInitrd struct{} | ||
810 | 50 | type zeroSizeSystemd struct{} | ||
811 | 51 | |||
812 | 52 | func (zeroSizeKernel) set(c *check.C) { | ||
813 | 53 | commonSet(c, BaseAltPartitionPath, origBootFilenamePattern, kernelFilename) | ||
814 | 54 | } | ||
815 | 55 | |||
816 | 56 | func (zeroSizeKernel) unset(c *check.C) { | ||
817 | 57 | commonUnset(c, BaseAltPartitionPath, origBootFilenamePattern, kernelFilename) | ||
818 | 58 | } | ||
819 | 59 | |||
820 | 60 | func (zeroSizeInitrd) set(c *check.C) { | ||
821 | 61 | if classicKernelFiles(c) { | ||
822 | 62 | commonSet(c, BaseAltPartitionPath, origBootFilenamePattern, initrdFilename) | ||
823 | 63 | } else { | ||
824 | 64 | boot := bootSystem(c) | ||
825 | 65 | dir := bootDirectory(boot) | ||
826 | 66 | bootFileNamePattern := newKernelFilenamePattern(c, boot, true) | ||
827 | 67 | commonSet(c, dir, bootFileNamePattern, initrdFilename) | ||
828 | 68 | } | ||
829 | 69 | } | ||
830 | 70 | |||
831 | 71 | func (zeroSizeInitrd) unset(c *check.C) { | ||
832 | 72 | if classicKernelFiles(c) { | ||
833 | 73 | commonUnset(c, BaseAltPartitionPath, origBootFilenamePattern, initrdFilename) | ||
834 | 74 | } else { | ||
835 | 75 | boot := bootSystem(c) | ||
836 | 76 | dir := bootDirectory(boot) | ||
837 | 77 | bootFileNamePattern := newKernelFilenamePattern(c, boot, false) | ||
838 | 78 | commonUnset(c, dir, bootFileNamePattern, initrdFilename) | ||
839 | 79 | } | ||
840 | 80 | } | ||
841 | 81 | |||
842 | 82 | func (zeroSizeSystemd) set(c *check.C) { | ||
843 | 83 | commonSet(c, BaseAltPartitionPath, origSystemdFilenamePattern, systemdFilename) | ||
844 | 84 | } | ||
845 | 85 | |||
846 | 86 | func (zeroSizeSystemd) unset(c *check.C) { | ||
847 | 87 | commonUnset(c, BaseAltPartitionPath, origSystemdFilenamePattern, systemdFilename) | ||
848 | 88 | } | ||
849 | 89 | |||
850 | 90 | func commonSet(c *check.C, baseOtherPath, origPattern, filename string) { | ||
851 | 91 | filenamePattern := fmt.Sprintf(origPattern, "", filename) | ||
852 | 92 | completePattern := filepath.Join( | ||
853 | 93 | baseOtherPath, | ||
854 | 94 | filenamePattern) | ||
855 | 95 | oldFilename := getSingleFilename(c, completePattern) | ||
856 | 96 | filenameSuffix := fmt.Sprintf( | ||
857 | 97 | strings.Replace(origPattern, "*", "", 1), destFilenamePrefix, filepath.Base(oldFilename)) | ||
858 | 98 | newFilename := fmt.Sprintf( | ||
859 | 99 | "%s/%s", baseOtherPath, filenameSuffix) | ||
860 | 100 | |||
861 | 101 | renameFile(c, baseOtherPath, oldFilename, newFilename, true) | ||
862 | 102 | } | ||
863 | 103 | |||
864 | 104 | func commonUnset(c *check.C, baseOtherPath, origPattern, filename string) { | ||
865 | 105 | completePattern := filepath.Join( | ||
866 | 106 | baseOtherPath, | ||
867 | 107 | fmt.Sprintf(origPattern, destFilenamePrefix, filename)) | ||
868 | 108 | oldFilename := getSingleFilename(c, completePattern) | ||
869 | 109 | newFilename := strings.Replace(oldFilename, destFilenamePrefix, "", 1) | ||
870 | 110 | |||
871 | 111 | renameFile(c, baseOtherPath, oldFilename, newFilename, false) | ||
872 | 112 | } | ||
873 | 113 | |||
874 | 114 | func renameFile(c *check.C, basePath, oldFilename, newFilename string, keepOld bool) { | ||
875 | 115 | // Only need to make writable and revert for BaseAltPartitionPath, | ||
876 | 116 | // kernel files' boot directory is writable | ||
877 | 117 | if basePath == BaseAltPartitionPath { | ||
878 | 118 | MakeWritable(c, basePath) | ||
879 | 119 | defer MakeReadonly(c, basePath) | ||
880 | 120 | } | ||
881 | 121 | |||
882 | 122 | ExecCommand(c, "sudo", "mv", oldFilename, newFilename) | ||
883 | 123 | |||
884 | 124 | if keepOld { | ||
885 | 125 | ExecCommand(c, "sudo", "touch", oldFilename) | ||
886 | 126 | mode := getFileMode(c, newFilename) | ||
887 | 127 | ExecCommand(c, "sudo", "chmod", fmt.Sprintf("%o", mode), oldFilename) | ||
888 | 128 | } | ||
889 | 129 | } | ||
890 | 130 | |||
891 | 131 | func getFileMode(c *check.C, filePath string) os.FileMode { | ||
892 | 132 | info, err := os.Stat(filePath) | ||
893 | 133 | c.Check(err, check.IsNil, check.Commentf("Error getting Stat of %s", filePath)) | ||
894 | 134 | |||
895 | 135 | return info.Mode() | ||
896 | 136 | } | ||
897 | 137 | |||
898 | 138 | func getSingleFilename(c *check.C, pattern string) string { | ||
899 | 139 | matches, err := filepath.Glob(pattern) | ||
900 | 140 | |||
901 | 141 | c.Assert(err, check.IsNil, check.Commentf("Error: %v", err)) | ||
902 | 142 | c.Assert(len(matches), check.Equals, 1, | ||
903 | 143 | check.Commentf("%d files matching %s, 1 expected", len(matches), pattern)) | ||
904 | 144 | |||
905 | 145 | return matches[0] | ||
906 | 146 | } | ||
907 | 147 | |||
908 | 148 | func classicKernelFiles(c *check.C) bool { | ||
909 | 149 | initrdClassicFilenamePattern := fmt.Sprintf("/boot/%s*-generic", initrdFilename) | ||
910 | 150 | matches, err := filepath.Glob(initrdClassicFilenamePattern) | ||
911 | 151 | |||
912 | 152 | c.Assert(err, check.IsNil, check.Commentf("Error: %v", err)) | ||
913 | 153 | |||
914 | 154 | return len(matches) == 1 | ||
915 | 155 | } | ||
916 | 156 | |||
917 | 157 | func bootSystem(c *check.C) string { | ||
918 | 158 | matches, err := filepath.Glob(bootBase + "/grub") | ||
919 | 159 | |||
920 | 160 | c.Assert(err, check.IsNil, check.Commentf("Error: %v", err)) | ||
921 | 161 | |||
922 | 162 | if len(matches) == 1 { | ||
923 | 163 | return "grub" | ||
924 | 164 | } | ||
925 | 165 | return "uboot" | ||
926 | 166 | } | ||
927 | 167 | |||
928 | 168 | func bootDirectory(bootSystem string) string { | ||
929 | 169 | if bootSystem == "grub" { | ||
930 | 170 | return grubDir | ||
931 | 171 | } | ||
932 | 172 | return ubootDir | ||
933 | 173 | } | ||
934 | 174 | |||
935 | 175 | func bootConfigFile(bootSystem string) string { | ||
936 | 176 | if bootSystem == "grub" { | ||
937 | 177 | return grubConfigFile | ||
938 | 178 | } | ||
939 | 179 | return ubootConfigFile | ||
940 | 180 | } | ||
941 | 181 | |||
942 | 182 | func currentPartition(c *check.C, bootSystem string) (partition string) { | ||
943 | 183 | bootConfigFile := bootConfigFile(bootSystem) | ||
944 | 184 | file, err := os.Open(bootConfigFile) | ||
945 | 185 | |||
946 | 186 | c.Assert(err, check.IsNil, | ||
947 | 187 | check.Commentf("Error reading boot config file %s", bootConfigFile)) | ||
948 | 188 | |||
949 | 189 | defer file.Close() | ||
950 | 190 | |||
951 | 191 | reader := bufio.NewReader(file) | ||
952 | 192 | scanner := bufio.NewScanner(reader) | ||
953 | 193 | |||
954 | 194 | scanner.Split(bufio.ScanLines) | ||
955 | 195 | |||
956 | 196 | for scanner.Scan() { | ||
957 | 197 | if strings.HasPrefix(scanner.Text(), "snappy_ab") { | ||
958 | 198 | fields := strings.Split(scanner.Text(), "=") | ||
959 | 199 | if len(fields) > 1 { | ||
960 | 200 | if bootSystem == "grub" { | ||
961 | 201 | partition = fields[1] | ||
962 | 202 | } else { | ||
963 | 203 | partition = otherPart(fields[1]) | ||
964 | 204 | } | ||
965 | 205 | } | ||
966 | 206 | return | ||
967 | 207 | } | ||
968 | 208 | } | ||
969 | 209 | return | ||
970 | 210 | } | ||
971 | 211 | |||
972 | 212 | func otherPart(current string) string { | ||
973 | 213 | if current == "a" { | ||
974 | 214 | return "b" | ||
975 | 215 | } | ||
976 | 216 | return "a" | ||
977 | 217 | } | ||
978 | 218 | |||
979 | 219 | // newKernelFilenamePattern returns the filename pattern to modify files | ||
980 | 220 | // in the partition declared in the boot config file. | ||
981 | 221 | // | ||
982 | 222 | // After the update, the config file is already changed to point to the new partition. | ||
983 | 223 | // If we are on a and update, the config file would point to b | ||
984 | 224 | // and this function would return "b/%s%s*" | ||
985 | 225 | // If we are not in an update process (ie. we are unsetting the failover conditions) | ||
986 | 226 | // we want to change the files in the other partition | ||
987 | 227 | func newKernelFilenamePattern(c *check.C, bootSystem string, afterUpdate bool) string { | ||
988 | 228 | var actualPartition string | ||
989 | 229 | partition := currentPartition(c, bootSystem) | ||
990 | 230 | if afterUpdate { | ||
991 | 231 | actualPartition = partition | ||
992 | 232 | } else { | ||
993 | 233 | actualPartition = otherPart(partition) | ||
994 | 234 | } | ||
995 | 235 | return filepath.Join(actualPartition, "%s%s*") | ||
996 | 236 | } | ||
997 | 237 | |||
998 | 238 | /* | ||
999 | 239 | TODO: uncomment when bug https://bugs.launchpad.net/snappy/+bug/1467553 is fixed | ||
1000 | 240 | (fgimenez 20150729) | ||
1001 | 241 | |||
1002 | 242 | func (s *failoverSuite) TestZeroSizeKernel(c *check.C) { | ||
1003 | 243 | commonFailoverTest(c, zeroSizeKernel{}) | ||
1004 | 244 | } | ||
1005 | 245 | */ | ||
1006 | 246 | |||
1007 | 247 | func (s *failoverSuite) TestZeroSizeInitrd(c *check.C) { | ||
1008 | 248 | // Skip if on uboot due to https://bugs.launchpad.net/snappy/+bug/1480248 | ||
1009 | 249 | // (fgimenez 20150731) | ||
1010 | 250 | if bootSystem(c) == "uboot" { | ||
1011 | 251 | c.Skip("Failover for empty initrd not working in uboot") | ||
1012 | 252 | } | ||
1013 | 253 | commonFailoverTest(c, zeroSizeInitrd{}) | ||
1014 | 254 | } | ||
1015 | 255 | |||
1016 | 256 | func (s *failoverSuite) TestZeroSizeSystemd(c *check.C) { | ||
1017 | 257 | commonFailoverTest(c, zeroSizeSystemd{}) | ||
1018 | 258 | } | ||
1019 | 0 | 259 | ||
1020 | === added file '_integration-tests/tests/info_test.go' | |||
1021 | --- _integration-tests/tests/info_test.go 1970-01-01 00:00:00 +0000 | |||
1022 | +++ _integration-tests/tests/info_test.go 2015-08-02 12:28:18 +0000 | |||
1023 | @@ -0,0 +1,79 @@ | |||
1024 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
1025 | 2 | |||
1026 | 3 | /* | ||
1027 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
1028 | 5 | * | ||
1029 | 6 | * This program is free software: you can redistribute it and/or modify | ||
1030 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1031 | 8 | * published by the Free Software Foundation. | ||
1032 | 9 | * | ||
1033 | 10 | * This program is distributed in the hope that it will be useful, | ||
1034 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1035 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1036 | 13 | * GNU General Public License for more details. | ||
1037 | 14 | * | ||
1038 | 15 | * You should have received a copy of the GNU General Public License | ||
1039 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1040 | 17 | * | ||
1041 | 18 | */ | ||
1042 | 19 | |||
1043 | 20 | package tests | ||
1044 | 21 | |||
1045 | 22 | import ( | ||
1046 | 23 | "fmt" | ||
1047 | 24 | |||
1048 | 25 | . "launchpad.net/snappy/_integration-tests/testutils/common" | ||
1049 | 26 | |||
1050 | 27 | check "gopkg.in/check.v1" | ||
1051 | 28 | ) | ||
1052 | 29 | |||
1053 | 30 | var _ = check.Suite(&infoSuite{}) | ||
1054 | 31 | |||
1055 | 32 | type infoSuite struct { | ||
1056 | 33 | SnappySuite | ||
1057 | 34 | } | ||
1058 | 35 | |||
1059 | 36 | func (s *infoSuite) TestInfoMustPrintReleaseAndChannel(c *check.C) { | ||
1060 | 37 | // skip test when having a remote testbed (we can't know which the | ||
1061 | 38 | // release and channels are) | ||
1062 | 39 | if Cfg.RemoteTestbed { | ||
1063 | 40 | c.Skip(fmt.Sprintf( | ||
1064 | 41 | "Skipping %s while testing in remote testbed", | ||
1065 | 42 | c.TestName())) | ||
1066 | 43 | } | ||
1067 | 44 | |||
1068 | 45 | infoOutput := ExecCommand(c, "snappy", "info") | ||
1069 | 46 | |||
1070 | 47 | expected := "(?ms)" + | ||
1071 | 48 | fmt.Sprintf("^release: ubuntu-core/%s/%s\n", Cfg.Release, Cfg.Channel) + | ||
1072 | 49 | ".*" | ||
1073 | 50 | |||
1074 | 51 | c.Assert(infoOutput, check.Matches, expected) | ||
1075 | 52 | } | ||
1076 | 53 | |||
1077 | 54 | func (s *infoSuite) TestInfoMustPrintInstalledApps(c *check.C) { | ||
1078 | 55 | InstallSnap(c, "hello-world") | ||
1079 | 56 | s.AddCleanup(func() { | ||
1080 | 57 | RemoveSnap(c, "hello-world") | ||
1081 | 58 | }) | ||
1082 | 59 | infoOutput := ExecCommand(c, "snappy", "info") | ||
1083 | 60 | |||
1084 | 61 | expected := "(?ms)" + | ||
1085 | 62 | ".*" + | ||
1086 | 63 | "^apps: .*hello-world.*\n" | ||
1087 | 64 | c.Assert(infoOutput, check.Matches, expected) | ||
1088 | 65 | } | ||
1089 | 66 | |||
1090 | 67 | func (s *infoSuite) TestInfoMustPrintInstalledFrameworks(c *check.C) { | ||
1091 | 68 | InstallSnap(c, "hello-dbus-fwk.canonical") | ||
1092 | 69 | s.AddCleanup(func() { | ||
1093 | 70 | RemoveSnap(c, "hello-dbus-fwk.canonical") | ||
1094 | 71 | }) | ||
1095 | 72 | infoOutput := ExecCommand(c, "snappy", "info") | ||
1096 | 73 | |||
1097 | 74 | expected := "(?ms)" + | ||
1098 | 75 | ".*" + | ||
1099 | 76 | "^frameworks: .*hello-dbus-fwk.*\n" + | ||
1100 | 77 | ".*" | ||
1101 | 78 | c.Assert(infoOutput, check.Matches, expected) | ||
1102 | 79 | } | ||
1103 | 0 | 80 | ||
1104 | === added file '_integration-tests/tests/installApp_test.go' | |||
1105 | --- _integration-tests/tests/installApp_test.go 1970-01-01 00:00:00 +0000 | |||
1106 | +++ _integration-tests/tests/installApp_test.go 2015-08-02 12:28:18 +0000 | |||
1107 | @@ -0,0 +1,128 @@ | |||
1108 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
1109 | 2 | |||
1110 | 3 | /* | ||
1111 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
1112 | 5 | * | ||
1113 | 6 | * This program is free software: you can redistribute it and/or modify | ||
1114 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1115 | 8 | * published by the Free Software Foundation. | ||
1116 | 9 | * | ||
1117 | 10 | * This program is distributed in the hope that it will be useful, | ||
1118 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1119 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1120 | 13 | * GNU General Public License for more details. | ||
1121 | 14 | * | ||
1122 | 15 | * You should have received a copy of the GNU General Public License | ||
1123 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1124 | 17 | * | ||
1125 | 18 | */ | ||
1126 | 19 | |||
1127 | 20 | package tests | ||
1128 | 21 | |||
1129 | 22 | import ( | ||
1130 | 23 | "fmt" | ||
1131 | 24 | "net/http" | ||
1132 | 25 | "os/exec" | ||
1133 | 26 | "time" | ||
1134 | 27 | |||
1135 | 28 | . "launchpad.net/snappy/_integration-tests/testutils/common" | ||
1136 | 29 | |||
1137 | 30 | check "gopkg.in/check.v1" | ||
1138 | 31 | ) | ||
1139 | 32 | |||
1140 | 33 | var _ = check.Suite(&installAppSuite{}) | ||
1141 | 34 | |||
1142 | 35 | type installAppSuite struct { | ||
1143 | 36 | SnappySuite | ||
1144 | 37 | } | ||
1145 | 38 | |||
1146 | 39 | func (s *installAppSuite) TestInstallAppMustPrintPackageInformation(c *check.C) { | ||
1147 | 40 | installOutput := InstallSnap(c, "hello-world") | ||
1148 | 41 | s.AddCleanup(func() { | ||
1149 | 42 | RemoveSnap(c, "hello-world") | ||
1150 | 43 | }) | ||
1151 | 44 | |||
1152 | 45 | expected := "(?ms)" + | ||
1153 | 46 | "Installing hello-world\n" + | ||
1154 | 47 | "Name +Date +Version +Developer \n" + | ||
1155 | 48 | ".*" + | ||
1156 | 49 | "^hello-world +.* +.* +canonical \n" + | ||
1157 | 50 | ".*" | ||
1158 | 51 | |||
1159 | 52 | c.Assert(installOutput, check.Matches, expected) | ||
1160 | 53 | } | ||
1161 | 54 | |||
1162 | 55 | func (s *installAppSuite) TestCallBinaryFromInstalledSnap(c *check.C) { | ||
1163 | 56 | InstallSnap(c, "hello-world") | ||
1164 | 57 | s.AddCleanup(func() { | ||
1165 | 58 | RemoveSnap(c, "hello-world") | ||
1166 | 59 | }) | ||
1167 | 60 | |||
1168 | 61 | echoOutput := ExecCommand(c, "hello-world.echo") | ||
1169 | 62 | |||
1170 | 63 | c.Assert(echoOutput, check.Equals, "Hello World!\n") | ||
1171 | 64 | } | ||
1172 | 65 | |||
1173 | 66 | func (s *installAppSuite) TestCallBinaryWithPermissionDeniedMustPrintError(c *check.C) { | ||
1174 | 67 | InstallSnap(c, "hello-world") | ||
1175 | 68 | s.AddCleanup(func() { | ||
1176 | 69 | RemoveSnap(c, "hello-world") | ||
1177 | 70 | }) | ||
1178 | 71 | |||
1179 | 72 | cmd := exec.Command("hello-world.evil") | ||
1180 | 73 | echoOutput, err := cmd.CombinedOutput() | ||
1181 | 74 | c.Assert(err, check.NotNil, check.Commentf("hello-world.evil did not fail")) | ||
1182 | 75 | |||
1183 | 76 | expected := "" + | ||
1184 | 77 | "Hello Evil World!\n" + | ||
1185 | 78 | "This example demonstrates the app confinement\n" + | ||
1186 | 79 | "You should see a permission denied error next\n" + | ||
1187 | 80 | "/apps/hello-world.canonical/.*/bin/evil: \\d+: " + | ||
1188 | 81 | "/apps/hello-world.canonical/.*/bin/evil: " + | ||
1189 | 82 | "cannot create /var/tmp/myevil.txt: Permission denied\n" | ||
1190 | 83 | |||
1191 | 84 | c.Assert(string(echoOutput), check.Matches, expected) | ||
1192 | 85 | } | ||
1193 | 86 | |||
1194 | 87 | func (s *installAppSuite) TestInfoMustPrintInstalledPackageInformation(c *check.C) { | ||
1195 | 88 | InstallSnap(c, "hello-world") | ||
1196 | 89 | s.AddCleanup(func() { | ||
1197 | 90 | RemoveSnap(c, "hello-world") | ||
1198 | 91 | }) | ||
1199 | 92 | |||
1200 | 93 | infoOutput := ExecCommand(c, "snappy", "info") | ||
1201 | 94 | |||
1202 | 95 | expected := "(?ms).*^apps: hello-world\n" | ||
1203 | 96 | c.Assert(infoOutput, check.Matches, expected) | ||
1204 | 97 | } | ||
1205 | 98 | |||
1206 | 99 | func (s *installAppSuite) TestAppNetworkingServiceMustBeStarted(c *check.C) { | ||
1207 | 100 | baseAppName := "xkcd-webserver" | ||
1208 | 101 | appName := baseAppName + ".canonical" | ||
1209 | 102 | InstallSnap(c, appName) | ||
1210 | 103 | s.AddCleanup(func() { | ||
1211 | 104 | RemoveSnap(c, appName) | ||
1212 | 105 | }) | ||
1213 | 106 | |||
1214 | 107 | appVersion := GetCurrentVersion(c, baseAppName) | ||
1215 | 108 | appService := fmt.Sprintf("%s_%s_%s.service", baseAppName, baseAppName, appVersion) | ||
1216 | 109 | |||
1217 | 110 | err := WaitForActiveService(c, appService) | ||
1218 | 111 | c.Assert(err, check.IsNil) | ||
1219 | 112 | |||
1220 | 113 | time.Sleep(1 * time.Second) | ||
1221 | 114 | resp, err := http.Get("http://localhost") | ||
1222 | 115 | c.Assert(err, check.IsNil) | ||
1223 | 116 | c.Check(resp.Status, check.Equals, "200 OK") | ||
1224 | 117 | c.Assert(resp.Proto, check.Equals, "HTTP/1.0") | ||
1225 | 118 | } | ||
1226 | 119 | |||
1227 | 120 | func (s *installAppSuite) TestInstallUnexistingAppMustPrintError(c *check.C) { | ||
1228 | 121 | cmd := exec.Command("sudo", "snappy", "install", "unexisting.canonical") | ||
1229 | 122 | output, err := cmd.CombinedOutput() | ||
1230 | 123 | |||
1231 | 124 | c.Assert(err, check.NotNil) | ||
1232 | 125 | c.Assert(string(output), check.Equals, | ||
1233 | 126 | "Installing unexisting.canonical\n"+ | ||
1234 | 127 | "unexisting.canonical failed to install: snappy package not found\n") | ||
1235 | 128 | } | ||
1236 | 0 | 129 | ||
1237 | === added file '_integration-tests/tests/installFramework_test.go' | |||
1238 | --- _integration-tests/tests/installFramework_test.go 1970-01-01 00:00:00 +0000 | |||
1239 | +++ _integration-tests/tests/installFramework_test.go 2015-08-02 12:28:18 +0000 | |||
1240 | @@ -0,0 +1,93 @@ | |||
1241 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
1242 | 2 | |||
1243 | 3 | /* | ||
1244 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
1245 | 5 | * | ||
1246 | 6 | * This program is free software: you can redistribute it and/or modify | ||
1247 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1248 | 8 | * published by the Free Software Foundation. | ||
1249 | 9 | * | ||
1250 | 10 | * This program is distributed in the hope that it will be useful, | ||
1251 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1252 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1253 | 13 | * GNU General Public License for more details. | ||
1254 | 14 | * | ||
1255 | 15 | * You should have received a copy of the GNU General Public License | ||
1256 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1257 | 17 | * | ||
1258 | 18 | */ | ||
1259 | 19 | |||
1260 | 20 | package tests | ||
1261 | 21 | |||
1262 | 22 | import ( | ||
1263 | 23 | "fmt" | ||
1264 | 24 | "regexp" | ||
1265 | 25 | |||
1266 | 26 | . "launchpad.net/snappy/_integration-tests/testutils/common" | ||
1267 | 27 | |||
1268 | 28 | check "gopkg.in/check.v1" | ||
1269 | 29 | ) | ||
1270 | 30 | |||
1271 | 31 | var _ = check.Suite(&installFrameworkSuite{}) | ||
1272 | 32 | |||
1273 | 33 | type installFrameworkSuite struct { | ||
1274 | 34 | SnappySuite | ||
1275 | 35 | } | ||
1276 | 36 | |||
1277 | 37 | func (s *installFrameworkSuite) TearDownTest(c *check.C) { | ||
1278 | 38 | if !NeedsReboot() && CheckRebootMark("") { | ||
1279 | 39 | RemoveSnap(c, "docker") | ||
1280 | 40 | } | ||
1281 | 41 | // run cleanup last | ||
1282 | 42 | s.SnappySuite.TearDownTest(c) | ||
1283 | 43 | } | ||
1284 | 44 | |||
1285 | 45 | func isDockerServiceRunning(c *check.C) bool { | ||
1286 | 46 | dockerVersion := GetCurrentVersion(c, "docker") | ||
1287 | 47 | dockerService := fmt.Sprintf("docker_docker-daemon_%s.service", dockerVersion) | ||
1288 | 48 | |||
1289 | 49 | err := WaitForActiveService(c, dockerService) | ||
1290 | 50 | c.Assert(err, check.IsNil) | ||
1291 | 51 | |||
1292 | 52 | statusOutput := ExecCommand( | ||
1293 | 53 | c, "systemctl", "status", | ||
1294 | 54 | dockerService) | ||
1295 | 55 | |||
1296 | 56 | expected := "(?ms)" + | ||
1297 | 57 | ".* docker_docker-daemon_.*\\.service .*\n" + | ||
1298 | 58 | ".*Loaded: loaded .*\n" + | ||
1299 | 59 | ".*Active: active \\(running\\) .*\n" + | ||
1300 | 60 | ".*" | ||
1301 | 61 | |||
1302 | 62 | matched, err := regexp.MatchString(expected, statusOutput) | ||
1303 | 63 | c.Assert(err, check.IsNil) | ||
1304 | 64 | return matched | ||
1305 | 65 | } | ||
1306 | 66 | |||
1307 | 67 | func (s *installFrameworkSuite) TestInstallFrameworkMustPrintPackageInformation(c *check.C) { | ||
1308 | 68 | installOutput := InstallSnap(c, "docker") | ||
1309 | 69 | |||
1310 | 70 | expected := "(?ms)" + | ||
1311 | 71 | "Installing docker\n" + | ||
1312 | 72 | "Name +Date +Version +Developer \n" + | ||
1313 | 73 | ".*" + | ||
1314 | 74 | "^docker +.* +.* +canonical \n" + | ||
1315 | 75 | ".*" | ||
1316 | 76 | |||
1317 | 77 | c.Assert(installOutput, check.Matches, expected) | ||
1318 | 78 | } | ||
1319 | 79 | |||
1320 | 80 | func (s *installFrameworkSuite) TestInstalledFrameworkServiceMustBeStarted(c *check.C) { | ||
1321 | 81 | InstallSnap(c, "docker") | ||
1322 | 82 | c.Assert(isDockerServiceRunning(c), check.Equals, true) | ||
1323 | 83 | } | ||
1324 | 84 | |||
1325 | 85 | func (s *installFrameworkSuite) TestFrameworkServiceMustBeStartedAfterReboot(c *check.C) { | ||
1326 | 86 | if BeforeReboot() { | ||
1327 | 87 | InstallSnap(c, "docker") | ||
1328 | 88 | Reboot(c) | ||
1329 | 89 | } else if AfterReboot(c) { | ||
1330 | 90 | RemoveRebootMark(c) | ||
1331 | 91 | c.Assert(isDockerServiceRunning(c), check.Equals, true) | ||
1332 | 92 | } | ||
1333 | 93 | } | ||
1334 | 0 | 94 | ||
1335 | === added file '_integration-tests/tests/list_test.go' | |||
1336 | --- _integration-tests/tests/list_test.go 1970-01-01 00:00:00 +0000 | |||
1337 | +++ _integration-tests/tests/list_test.go 2015-08-02 12:28:18 +0000 | |||
1338 | @@ -0,0 +1,78 @@ | |||
1339 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
1340 | 2 | |||
1341 | 3 | /* | ||
1342 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
1343 | 5 | * | ||
1344 | 6 | * This program is free software: you can redistribute it and/or modify | ||
1345 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1346 | 8 | * published by the Free Software Foundation. | ||
1347 | 9 | * | ||
1348 | 10 | * This program is distributed in the hope that it will be useful, | ||
1349 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1350 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1351 | 13 | * GNU General Public License for more details. | ||
1352 | 14 | * | ||
1353 | 15 | * You should have received a copy of the GNU General Public License | ||
1354 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1355 | 17 | * | ||
1356 | 18 | */ | ||
1357 | 19 | |||
1358 | 20 | package tests | ||
1359 | 21 | |||
1360 | 22 | import ( | ||
1361 | 23 | "fmt" | ||
1362 | 24 | "os" | ||
1363 | 25 | |||
1364 | 26 | . "launchpad.net/snappy/_integration-tests/testutils/common" | ||
1365 | 27 | |||
1366 | 28 | "github.com/mvo5/goconfigparser" | ||
1367 | 29 | check "gopkg.in/check.v1" | ||
1368 | 30 | ) | ||
1369 | 31 | |||
1370 | 32 | var _ = check.Suite(&listSuite{}) | ||
1371 | 33 | |||
1372 | 34 | type listSuite struct { | ||
1373 | 35 | SnappySuite | ||
1374 | 36 | } | ||
1375 | 37 | |||
1376 | 38 | func getVersionFromConfig(c *check.C) string { | ||
1377 | 39 | cfg := goconfigparser.New() | ||
1378 | 40 | f, err := os.Open("/etc/system-image/channel.ini") | ||
1379 | 41 | c.Assert(err, check.IsNil, | ||
1380 | 42 | check.Commentf("Error opening the config file: %v:", err)) | ||
1381 | 43 | defer f.Close() | ||
1382 | 44 | err = cfg.Read(f) | ||
1383 | 45 | c.Assert(err, check.IsNil, | ||
1384 | 46 | check.Commentf("Error parsing the config file: %v", err)) | ||
1385 | 47 | version, err := cfg.Get("service", "build_number") | ||
1386 | 48 | c.Assert(err, check.IsNil, | ||
1387 | 49 | check.Commentf("Error getting the build number: %v", err)) | ||
1388 | 50 | return version | ||
1389 | 51 | } | ||
1390 | 52 | |||
1391 | 53 | func (s *listSuite) TestListMustPrintCoreVersion(c *check.C) { | ||
1392 | 54 | listOutput := ExecCommand(c, "snappy", "list") | ||
1393 | 55 | |||
1394 | 56 | expected := "(?ms)" + | ||
1395 | 57 | "Name +Date +Version +Developer *\n" + | ||
1396 | 58 | ".*" + | ||
1397 | 59 | fmt.Sprintf("^ubuntu-core +.* +%s +ubuntu *\n", getVersionFromConfig(c)) + | ||
1398 | 60 | ".*" | ||
1399 | 61 | c.Assert(listOutput, check.Matches, expected) | ||
1400 | 62 | } | ||
1401 | 63 | |||
1402 | 64 | func (s *listSuite) TestListMustPrintAppVersion(c *check.C) { | ||
1403 | 65 | InstallSnap(c, "hello-world") | ||
1404 | 66 | s.AddCleanup(func() { | ||
1405 | 67 | RemoveSnap(c, "hello-world") | ||
1406 | 68 | }) | ||
1407 | 69 | |||
1408 | 70 | listOutput := ExecCommand(c, "snappy", "list") | ||
1409 | 71 | expected := "(?ms)" + | ||
1410 | 72 | "Name +Date +Version +Developer *\n" + | ||
1411 | 73 | ".*" + | ||
1412 | 74 | "^hello-world +.* +(\\d+)(\\.\\d+)* +.* +.* *\n" + | ||
1413 | 75 | ".*" | ||
1414 | 76 | |||
1415 | 77 | c.Assert(listOutput, check.Matches, expected) | ||
1416 | 78 | } | ||
1417 | 0 | 79 | ||
1418 | === added file '_integration-tests/tests/rollback_test.go' | |||
1419 | --- _integration-tests/tests/rollback_test.go 1970-01-01 00:00:00 +0000 | |||
1420 | +++ _integration-tests/tests/rollback_test.go 2015-08-02 12:28:18 +0000 | |||
1421 | @@ -0,0 +1,53 @@ | |||
1422 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
1423 | 2 | |||
1424 | 3 | /* | ||
1425 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
1426 | 5 | * | ||
1427 | 6 | * This program is free software: you can redistribute it and/or modify | ||
1428 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1429 | 8 | * published by the Free Software Foundation. | ||
1430 | 9 | * | ||
1431 | 10 | * This program is distributed in the hope that it will be useful, | ||
1432 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1433 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1434 | 13 | * GNU General Public License for more details. | ||
1435 | 14 | * | ||
1436 | 15 | * You should have received a copy of the GNU General Public License | ||
1437 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1438 | 17 | * | ||
1439 | 18 | */ | ||
1440 | 19 | |||
1441 | 20 | package tests | ||
1442 | 21 | |||
1443 | 22 | import ( | ||
1444 | 23 | "strconv" | ||
1445 | 24 | |||
1446 | 25 | . "launchpad.net/snappy/_integration-tests/testutils/common" | ||
1447 | 26 | |||
1448 | 27 | check "gopkg.in/check.v1" | ||
1449 | 28 | ) | ||
1450 | 29 | |||
1451 | 30 | var _ = check.Suite(&rollbackSuite{}) | ||
1452 | 31 | |||
1453 | 32 | type rollbackSuite struct { | ||
1454 | 33 | SnappySuite | ||
1455 | 34 | } | ||
1456 | 35 | |||
1457 | 36 | func (s *rollbackSuite) TestRollbackMustRebootToOtherVersion(c *check.C) { | ||
1458 | 37 | if BeforeReboot() { | ||
1459 | 38 | CallFakeUpdate(c) | ||
1460 | 39 | Reboot(c) | ||
1461 | 40 | } else if CheckRebootMark(c.TestName()) { | ||
1462 | 41 | RemoveRebootMark(c) | ||
1463 | 42 | currentVersion := GetCurrentUbuntuCoreVersion(c) | ||
1464 | 43 | c.Assert(currentVersion > GetSavedVersion(c), check.Equals, true) | ||
1465 | 44 | ExecCommand(c, "sudo", "snappy", "rollback", "ubuntu-core", | ||
1466 | 45 | strconv.Itoa(GetSavedVersion(c))) | ||
1467 | 46 | SetSavedVersion(c, currentVersion) | ||
1468 | 47 | RebootWithMark(c, c.TestName()+"-rollback") | ||
1469 | 48 | } else if CheckRebootMark(c.TestName() + "-rollback") { | ||
1470 | 49 | RemoveRebootMark(c) | ||
1471 | 50 | c.Assert( | ||
1472 | 51 | GetCurrentUbuntuCoreVersion(c) < GetSavedVersion(c), check.Equals, true) | ||
1473 | 52 | } | ||
1474 | 53 | } | ||
1475 | 0 | 54 | ||
1476 | === added file '_integration-tests/tests/search_test.go' | |||
1477 | --- _integration-tests/tests/search_test.go 1970-01-01 00:00:00 +0000 | |||
1478 | +++ _integration-tests/tests/search_test.go 2015-08-02 12:28:18 +0000 | |||
1479 | @@ -0,0 +1,44 @@ | |||
1480 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
1481 | 2 | |||
1482 | 3 | /* | ||
1483 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
1484 | 5 | * | ||
1485 | 6 | * This program is free software: you can redistribute it and/or modify | ||
1486 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1487 | 8 | * published by the Free Software Foundation. | ||
1488 | 9 | * | ||
1489 | 10 | * This program is distributed in the hope that it will be useful, | ||
1490 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1491 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1492 | 13 | * GNU General Public License for more details. | ||
1493 | 14 | * | ||
1494 | 15 | * You should have received a copy of the GNU General Public License | ||
1495 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1496 | 17 | * | ||
1497 | 18 | */ | ||
1498 | 19 | |||
1499 | 20 | package tests | ||
1500 | 21 | |||
1501 | 22 | import ( | ||
1502 | 23 | . "launchpad.net/snappy/_integration-tests/testutils/common" | ||
1503 | 24 | |||
1504 | 25 | . "gopkg.in/check.v1" | ||
1505 | 26 | ) | ||
1506 | 27 | |||
1507 | 28 | var _ = Suite(&searchSuite{}) | ||
1508 | 29 | |||
1509 | 30 | type searchSuite struct { | ||
1510 | 31 | SnappySuite | ||
1511 | 32 | } | ||
1512 | 33 | |||
1513 | 34 | func (s *searchSuite) TestSearchFrameworkMustPrintMatch(c *C) { | ||
1514 | 35 | searchOutput := ExecCommand(c, "snappy", "search", "hello-dbus-fwk") | ||
1515 | 36 | |||
1516 | 37 | expected := "(?ms)" + | ||
1517 | 38 | "Name +Version +Summary *\n" + | ||
1518 | 39 | ".*" + | ||
1519 | 40 | "^hello-dbus-fwk +.* +hello-dbus-fwk *\n" + | ||
1520 | 41 | ".*" | ||
1521 | 42 | |||
1522 | 43 | c.Assert(searchOutput, Matches, expected) | ||
1523 | 44 | } | ||
1524 | 0 | 45 | ||
1525 | === added file '_integration-tests/tests/update_test.go' | |||
1526 | --- _integration-tests/tests/update_test.go 1970-01-01 00:00:00 +0000 | |||
1527 | +++ _integration-tests/tests/update_test.go 2015-08-02 12:28:18 +0000 | |||
1528 | @@ -0,0 +1,51 @@ | |||
1529 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
1530 | 2 | |||
1531 | 3 | /* | ||
1532 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
1533 | 5 | * | ||
1534 | 6 | * This program is free software: you can redistribute it and/or modify | ||
1535 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1536 | 8 | * published by the Free Software Foundation. | ||
1537 | 9 | * | ||
1538 | 10 | * This program is distributed in the hope that it will be useful, | ||
1539 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1540 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1541 | 13 | * GNU General Public License for more details. | ||
1542 | 14 | * | ||
1543 | 15 | * You should have received a copy of the GNU General Public License | ||
1544 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1545 | 17 | * | ||
1546 | 18 | */ | ||
1547 | 19 | |||
1548 | 20 | package tests | ||
1549 | 21 | |||
1550 | 22 | import ( | ||
1551 | 23 | . "launchpad.net/snappy/_integration-tests/testutils/common" | ||
1552 | 24 | |||
1553 | 25 | check "gopkg.in/check.v1" | ||
1554 | 26 | ) | ||
1555 | 27 | |||
1556 | 28 | var _ = check.Suite(&updateSuite{}) | ||
1557 | 29 | |||
1558 | 30 | type updateSuite struct { | ||
1559 | 31 | SnappySuite | ||
1560 | 32 | } | ||
1561 | 33 | |||
1562 | 34 | // Test that the update to the same release and channel must install a newer | ||
1563 | 35 | // version. If there is no update available, the channel version will be | ||
1564 | 36 | // modified to fake an update. If there is a version available, the image will | ||
1565 | 37 | // be up-to-date after running this test. | ||
1566 | 38 | func (s *updateSuite) TestUpdateToSameReleaseAndChannel(c *check.C) { | ||
1567 | 39 | if BeforeReboot() { | ||
1568 | 40 | updateOutput := CallFakeUpdate(c) | ||
1569 | 41 | expected := "(?ms)" + | ||
1570 | 42 | ".*" + | ||
1571 | 43 | "^Reboot to use .*ubuntu-core.\n" | ||
1572 | 44 | c.Assert(updateOutput, check.Matches, expected) | ||
1573 | 45 | Reboot(c) | ||
1574 | 46 | } else if AfterReboot(c) { | ||
1575 | 47 | RemoveRebootMark(c) | ||
1576 | 48 | c.Assert(GetCurrentUbuntuCoreVersion(c) > GetSavedVersion(c), | ||
1577 | 49 | check.Equals, true) | ||
1578 | 50 | } | ||
1579 | 51 | } | ||
1580 | 0 | 52 | ||
1581 | === added file '_integration-tests/tests/writablePaths_test.go' | |||
1582 | --- _integration-tests/tests/writablePaths_test.go 1970-01-01 00:00:00 +0000 | |||
1583 | +++ _integration-tests/tests/writablePaths_test.go 2015-08-02 12:28:18 +0000 | |||
1584 | @@ -0,0 +1,106 @@ | |||
1585 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
1586 | 2 | |||
1587 | 3 | /* | ||
1588 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
1589 | 5 | * | ||
1590 | 6 | * This program is free software: you can redistribute it and/or modify | ||
1591 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1592 | 8 | * published by the Free Software Foundation. | ||
1593 | 9 | * | ||
1594 | 10 | * This program is distributed in the hope that it will be useful, | ||
1595 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1596 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1597 | 13 | * GNU General Public License for more details. | ||
1598 | 14 | * | ||
1599 | 15 | * You should have received a copy of the GNU General Public License | ||
1600 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1601 | 17 | * | ||
1602 | 18 | */ | ||
1603 | 19 | |||
1604 | 20 | package tests | ||
1605 | 21 | |||
1606 | 22 | import ( | ||
1607 | 23 | "bufio" | ||
1608 | 24 | "fmt" | ||
1609 | 25 | "os" | ||
1610 | 26 | "os/exec" | ||
1611 | 27 | "path/filepath" | ||
1612 | 28 | "strings" | ||
1613 | 29 | |||
1614 | 30 | . "launchpad.net/snappy/_integration-tests/testutils/common" | ||
1615 | 31 | |||
1616 | 32 | check "gopkg.in/check.v1" | ||
1617 | 33 | ) | ||
1618 | 34 | |||
1619 | 35 | const writablePathsListFile = "/etc/system-image/writable-paths" | ||
1620 | 36 | |||
1621 | 37 | var _ = check.Suite(&writablePathsSuite{}) | ||
1622 | 38 | |||
1623 | 39 | type writablePathsSuite struct { | ||
1624 | 40 | SnappySuite | ||
1625 | 41 | } | ||
1626 | 42 | |||
1627 | 43 | var IsWritable check.Checker = &isWritable{} | ||
1628 | 44 | |||
1629 | 45 | type isWritable struct { | ||
1630 | 46 | } | ||
1631 | 47 | |||
1632 | 48 | func (is *isWritable) Info() *check.CheckerInfo { | ||
1633 | 49 | return &check.CheckerInfo{Name: "IsWritable", Params: []string{"path"}} | ||
1634 | 50 | } | ||
1635 | 51 | |||
1636 | 52 | func (is *isWritable) Check(params []interface{}, names []string) (result bool, error string) { | ||
1637 | 53 | if path, ok := params[0].(string); ok { | ||
1638 | 54 | filename := filepath.Join(path, "tmpfile") | ||
1639 | 55 | |||
1640 | 56 | cmd := exec.Command("sudo", "touch", filename) | ||
1641 | 57 | rmCmd := exec.Command("sudo", "rm", filename) | ||
1642 | 58 | defer rmCmd.Run() | ||
1643 | 59 | |||
1644 | 60 | if _, err := cmd.CombinedOutput(); err == nil { | ||
1645 | 61 | result = true | ||
1646 | 62 | } else { | ||
1647 | 63 | error = fmt.Sprintf("Error creating file %s", filename) | ||
1648 | 64 | } | ||
1649 | 65 | } else { | ||
1650 | 66 | error = fmt.Sprintf("First param of checker %v is of type %T and it should be a string", params[0], params[0]) | ||
1651 | 67 | } | ||
1652 | 68 | return result, error | ||
1653 | 69 | } | ||
1654 | 70 | |||
1655 | 71 | func (s *writablePathsSuite) TestWritablePathsAreWritable(c *check.C) { | ||
1656 | 72 | for writablePath := range generateWritablePaths(c) { | ||
1657 | 73 | c.Logf("Checking if %s is writable", writablePath) | ||
1658 | 74 | c.Check(writablePath, IsWritable) | ||
1659 | 75 | } | ||
1660 | 76 | } | ||
1661 | 77 | |||
1662 | 78 | func generateWritablePaths(c *check.C) chan string { | ||
1663 | 79 | ch := make(chan string) | ||
1664 | 80 | |||
1665 | 81 | go func() { | ||
1666 | 82 | file, err := os.Open(writablePathsListFile) | ||
1667 | 83 | |||
1668 | 84 | c.Assert(err, check.IsNil, | ||
1669 | 85 | check.Commentf("Error reading writable files list %s", writablePathsListFile)) | ||
1670 | 86 | |||
1671 | 87 | defer file.Close() | ||
1672 | 88 | |||
1673 | 89 | reader := bufio.NewReader(file) | ||
1674 | 90 | scanner := bufio.NewScanner(reader) | ||
1675 | 91 | |||
1676 | 92 | scanner.Split(bufio.ScanLines) | ||
1677 | 93 | |||
1678 | 94 | for scanner.Scan() { | ||
1679 | 95 | fields := strings.Fields(scanner.Text()) | ||
1680 | 96 | if len(fields) > 0 && fields[0] != "#" { | ||
1681 | 97 | if src, err := os.Stat(fields[0]); err == nil && src.IsDir() { | ||
1682 | 98 | ch <- fields[0] | ||
1683 | 99 | } | ||
1684 | 100 | } | ||
1685 | 101 | } | ||
1686 | 102 | close(ch) | ||
1687 | 103 | }() | ||
1688 | 104 | |||
1689 | 105 | return ch | ||
1690 | 106 | } | ||
1691 | 0 | 107 | ||
1692 | === added directory '_integration-tests/testutils' | |||
1693 | === added directory '_integration-tests/testutils/autopkgtest' | |||
1694 | === added file '_integration-tests/testutils/autopkgtest/autopkgtest.go' | |||
1695 | --- _integration-tests/testutils/autopkgtest/autopkgtest.go 1970-01-01 00:00:00 +0000 | |||
1696 | +++ _integration-tests/testutils/autopkgtest/autopkgtest.go 2015-08-02 12:28:18 +0000 | |||
1697 | @@ -0,0 +1,111 @@ | |||
1698 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
1699 | 2 | |||
1700 | 3 | /* | ||
1701 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
1702 | 5 | * | ||
1703 | 6 | * This program is free software: you can redistribute it and/or modify | ||
1704 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1705 | 8 | * published by the Free Software Foundation. | ||
1706 | 9 | * | ||
1707 | 10 | * This program is distributed in the hope that it will be useful, | ||
1708 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1709 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1710 | 13 | * GNU General Public License for more details. | ||
1711 | 14 | * | ||
1712 | 15 | * You should have received a copy of the GNU General Public License | ||
1713 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1714 | 17 | * | ||
1715 | 18 | */ | ||
1716 | 19 | |||
1717 | 20 | package autopkgtest | ||
1718 | 21 | |||
1719 | 22 | import ( | ||
1720 | 23 | "fmt" | ||
1721 | 24 | "os" | ||
1722 | 25 | "path/filepath" | ||
1723 | 26 | "strconv" | ||
1724 | 27 | "text/template" | ||
1725 | 28 | |||
1726 | 29 | "log" | ||
1727 | 30 | |||
1728 | 31 | "launchpad.net/snappy/_integration-tests/testutils" | ||
1729 | 32 | ) | ||
1730 | 33 | |||
1731 | 34 | const ( | ||
1732 | 35 | controlTpl = "_integration-tests/data/tpl/control" | ||
1733 | 36 | dataOutputDir = "_integration-tests/data/output/" | ||
1734 | 37 | ) | ||
1735 | 38 | |||
1736 | 39 | var controlFile = filepath.Join(dataOutputDir, "control") | ||
1737 | 40 | |||
1738 | 41 | // Autopkgtest is the type that knows how to call adt-run | ||
1739 | 42 | type Autopkgtest struct { | ||
1740 | 43 | sourceCodePath string // location of the source code on the host | ||
1741 | 44 | testArtifactsPath string // location of the test artifacts on the host | ||
1742 | 45 | testFilter string | ||
1743 | 46 | integrationTestName string | ||
1744 | 47 | } | ||
1745 | 48 | |||
1746 | 49 | // NewAutopkgtest is the Autopkgtest constructor | ||
1747 | 50 | func NewAutopkgtest(sourceCodePath, testArtifactsPath, testFilter, integrationTestName string) *Autopkgtest { | ||
1748 | 51 | return &Autopkgtest{ | ||
1749 | 52 | sourceCodePath: sourceCodePath, | ||
1750 | 53 | testArtifactsPath: testArtifactsPath, | ||
1751 | 54 | testFilter: testFilter, | ||
1752 | 55 | integrationTestName: integrationTestName} | ||
1753 | 56 | } | ||
1754 | 57 | |||
1755 | 58 | // AdtRunLocal starts a kvm running the image passed as argument and runs the | ||
1756 | 59 | // autopkgtests using it as the testbed. | ||
1757 | 60 | func (a *Autopkgtest) AdtRunLocal(imgPath string) { | ||
1758 | 61 | // Run the tests on the latest rolling edge image. | ||
1759 | 62 | a.adtRun(kvmSSHOptions(imgPath)) | ||
1760 | 63 | } | ||
1761 | 64 | |||
1762 | 65 | // AdtRunRemote runs the autopkgtests using a remote machine as the testbed. | ||
1763 | 66 | func (a *Autopkgtest) AdtRunRemote(testbedIP string, testbedPort int) { | ||
1764 | 67 | testutils.ExecCommand("ssh-copy-id", "-p", strconv.Itoa(testbedPort), | ||
1765 | 68 | "ubuntu@"+testbedIP) | ||
1766 | 69 | a.adtRun(remoteTestbedSSHOptions(testbedIP, testbedPort)) | ||
1767 | 70 | } | ||
1768 | 71 | |||
1769 | 72 | func (a *Autopkgtest) adtRun(testbedOptions []string) { | ||
1770 | 73 | a.createControlFile() | ||
1771 | 74 | |||
1772 | 75 | fmt.Println("Calling adt-run...") | ||
1773 | 76 | outputDir := filepath.Join(a.testArtifactsPath, "output") | ||
1774 | 77 | testutils.PrepareTargetDir(outputDir) | ||
1775 | 78 | |||
1776 | 79 | cmd := []string{ | ||
1777 | 80 | "adt-run", "-B", | ||
1778 | 81 | "--setup-commands", "touch /run/autopkgtest_no_reboot.stamp", | ||
1779 | 82 | "--override-control", controlFile, | ||
1780 | 83 | "--built-tree", a.sourceCodePath, | ||
1781 | 84 | "--output-dir", outputDir} | ||
1782 | 85 | |||
1783 | 86 | testutils.ExecCommand(append(cmd, testbedOptions...)...) | ||
1784 | 87 | } | ||
1785 | 88 | |||
1786 | 89 | func (a *Autopkgtest) createControlFile() { | ||
1787 | 90 | type controlData struct { | ||
1788 | 91 | Filter string | ||
1789 | 92 | Test string | ||
1790 | 93 | } | ||
1791 | 94 | |||
1792 | 95 | tpl, err := template.ParseFiles(controlTpl) | ||
1793 | 96 | if err != nil { | ||
1794 | 97 | log.Panicf("Error reading adt-run control template %s", controlTpl) | ||
1795 | 98 | } | ||
1796 | 99 | |||
1797 | 100 | outputFile, err := os.Create(controlFile) | ||
1798 | 101 | if err != nil { | ||
1799 | 102 | log.Panicf("Error creating control file %s", controlFile) | ||
1800 | 103 | } | ||
1801 | 104 | defer outputFile.Close() | ||
1802 | 105 | |||
1803 | 106 | err = tpl.Execute(outputFile, | ||
1804 | 107 | controlData{Test: a.integrationTestName, Filter: a.testFilter}) | ||
1805 | 108 | if err != nil { | ||
1806 | 109 | log.Panicf("execution: %s", err) | ||
1807 | 110 | } | ||
1808 | 111 | } | ||
1809 | 0 | 112 | ||
1810 | === added file '_integration-tests/testutils/autopkgtest/ssh.go' | |||
1811 | --- _integration-tests/testutils/autopkgtest/ssh.go 1970-01-01 00:00:00 +0000 | |||
1812 | +++ _integration-tests/testutils/autopkgtest/ssh.go 2015-08-02 12:28:18 +0000 | |||
1813 | @@ -0,0 +1,46 @@ | |||
1814 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
1815 | 2 | |||
1816 | 3 | /* | ||
1817 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
1818 | 5 | * | ||
1819 | 6 | * This program is free software: you can redistribute it and/or modify | ||
1820 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1821 | 8 | * published by the Free Software Foundation. | ||
1822 | 9 | * | ||
1823 | 10 | * This program is distributed in the hope that it will be useful, | ||
1824 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1825 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1826 | 13 | * GNU General Public License for more details. | ||
1827 | 14 | * | ||
1828 | 15 | * You should have received a copy of the GNU General Public License | ||
1829 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1830 | 17 | * | ||
1831 | 18 | */ | ||
1832 | 19 | |||
1833 | 20 | package autopkgtest | ||
1834 | 21 | |||
1835 | 22 | import ( | ||
1836 | 23 | "os" | ||
1837 | 24 | "path/filepath" | ||
1838 | 25 | "strconv" | ||
1839 | 26 | ) | ||
1840 | 27 | |||
1841 | 28 | var commonSSHOptions = []string{"---", "ssh"} | ||
1842 | 29 | |||
1843 | 30 | func kvmSSHOptions(imagePath string) []string { | ||
1844 | 31 | return append( | ||
1845 | 32 | commonSSHOptions, | ||
1846 | 33 | []string{ | ||
1847 | 34 | "-s", "/usr/share/autopkgtest/ssh-setup/snappy", | ||
1848 | 35 | "--", "-i", imagePath}...) | ||
1849 | 36 | } | ||
1850 | 37 | |||
1851 | 38 | func remoteTestbedSSHOptions(testbedIP string, testbedPort int) []string { | ||
1852 | 39 | options := []string{ | ||
1853 | 40 | "-H", testbedIP, | ||
1854 | 41 | "-p", strconv.Itoa(testbedPort), | ||
1855 | 42 | "-l", "ubuntu", | ||
1856 | 43 | "-i", filepath.Join(os.Getenv("HOME"), ".ssh", "id_rsa"), | ||
1857 | 44 | "--reboot"} | ||
1858 | 45 | return append(commonSSHOptions, options...) | ||
1859 | 46 | } | ||
1860 | 0 | 47 | ||
1861 | === added directory '_integration-tests/testutils/build' | |||
1862 | === added file '_integration-tests/testutils/build/build.go' | |||
1863 | --- _integration-tests/testutils/build/build.go 1970-01-01 00:00:00 +0000 | |||
1864 | +++ _integration-tests/testutils/build/build.go 2015-08-02 12:28:18 +0000 | |||
1865 | @@ -0,0 +1,76 @@ | |||
1866 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
1867 | 2 | |||
1868 | 3 | /* | ||
1869 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
1870 | 5 | * | ||
1871 | 6 | * This program is free software: you can redistribute it and/or modify | ||
1872 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1873 | 8 | * published by the Free Software Foundation. | ||
1874 | 9 | * | ||
1875 | 10 | * This program is distributed in the hope that it will be useful, | ||
1876 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1877 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1878 | 13 | * GNU General Public License for more details. | ||
1879 | 14 | * | ||
1880 | 15 | * You should have received a copy of the GNU General Public License | ||
1881 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1882 | 17 | * | ||
1883 | 18 | */ | ||
1884 | 19 | |||
1885 | 20 | package build | ||
1886 | 21 | |||
1887 | 22 | import ( | ||
1888 | 23 | "fmt" | ||
1889 | 24 | "os" | ||
1890 | 25 | |||
1891 | 26 | "launchpad.net/snappy/_integration-tests/testutils" | ||
1892 | 27 | ) | ||
1893 | 28 | |||
1894 | 29 | const ( | ||
1895 | 30 | // IntegrationTestName is the name of the test binary. | ||
1896 | 31 | IntegrationTestName = "integration.test" | ||
1897 | 32 | defaultGoArm = "7" | ||
1898 | 33 | testsBinDir = "_integration-tests/bin/" | ||
1899 | 34 | ) | ||
1900 | 35 | |||
1901 | 36 | // Assets builds the snappy and integration tests binaries for the target | ||
1902 | 37 | // architecture. | ||
1903 | 38 | func Assets(useSnappyFromBranch bool, arch string) { | ||
1904 | 39 | testutils.PrepareTargetDir(testsBinDir) | ||
1905 | 40 | |||
1906 | 41 | if useSnappyFromBranch { | ||
1907 | 42 | // FIXME We need to build an image that has the snappy from the branch | ||
1908 | 43 | // installed. --elopio - 2015-06-25. | ||
1909 | 44 | buildSnappyCLI(arch) | ||
1910 | 45 | } | ||
1911 | 46 | buildTests(arch) | ||
1912 | 47 | } | ||
1913 | 48 | |||
1914 | 49 | func buildSnappyCLI(arch string) { | ||
1915 | 50 | fmt.Println("Building snappy CLI...") | ||
1916 | 51 | // On the root of the project we have a directory called snappy, so we | ||
1917 | 52 | // output the binary for the tests in the tests directory. | ||
1918 | 53 | goCall(arch, "build", "-o", testsBinDir+"snappy", "./cmd/snappy") | ||
1919 | 54 | } | ||
1920 | 55 | |||
1921 | 56 | func buildTests(arch string) { | ||
1922 | 57 | fmt.Println("Building tests...") | ||
1923 | 58 | |||
1924 | 59 | goCall(arch, "test", "-c", "./_integration-tests/tests") | ||
1925 | 60 | // XXX Go test 1.3 does not have the output flag, so we move the | ||
1926 | 61 | // binaries after they are generated. | ||
1927 | 62 | os.Rename("tests.test", testsBinDir+IntegrationTestName) | ||
1928 | 63 | } | ||
1929 | 64 | |||
1930 | 65 | func goCall(arch string, cmds ...string) { | ||
1931 | 66 | if arch != "" { | ||
1932 | 67 | defer os.Setenv("GOARCH", os.Getenv("GOARCH")) | ||
1933 | 68 | os.Setenv("GOARCH", arch) | ||
1934 | 69 | if arch == "arm" { | ||
1935 | 70 | defer os.Setenv("GOARM", os.Getenv("GOARM")) | ||
1936 | 71 | os.Setenv("GOARM", defaultGoArm) | ||
1937 | 72 | } | ||
1938 | 73 | } | ||
1939 | 74 | goCmd := append([]string{"go"}, cmds...) | ||
1940 | 75 | testutils.ExecCommand(goCmd...) | ||
1941 | 76 | } | ||
1942 | 0 | 77 | ||
1943 | === added directory '_integration-tests/testutils/common' | |||
1944 | === added file '_integration-tests/testutils/common/common.go' | |||
1945 | --- _integration-tests/testutils/common/common.go 1970-01-01 00:00:00 +0000 | |||
1946 | +++ _integration-tests/testutils/common/common.go 2015-08-02 12:28:18 +0000 | |||
1947 | @@ -0,0 +1,379 @@ | |||
1948 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
1949 | 2 | |||
1950 | 3 | /* | ||
1951 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
1952 | 5 | * | ||
1953 | 6 | * This program is free software: you can redistribute it and/or modify | ||
1954 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
1955 | 8 | * published by the Free Software Foundation. | ||
1956 | 9 | * | ||
1957 | 10 | * This program is distributed in the hope that it will be useful, | ||
1958 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1959 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1960 | 13 | * GNU General Public License for more details. | ||
1961 | 14 | * | ||
1962 | 15 | * You should have received a copy of the GNU General Public License | ||
1963 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1964 | 17 | * | ||
1965 | 18 | */ | ||
1966 | 19 | |||
1967 | 20 | package common | ||
1968 | 21 | |||
1969 | 22 | import ( | ||
1970 | 23 | "fmt" | ||
1971 | 24 | "io/ioutil" | ||
1972 | 25 | "os" | ||
1973 | 26 | "os/exec" | ||
1974 | 27 | "path/filepath" | ||
1975 | 28 | "regexp" | ||
1976 | 29 | "strconv" | ||
1977 | 30 | "strings" | ||
1978 | 31 | "time" | ||
1979 | 32 | |||
1980 | 33 | check "gopkg.in/check.v1" | ||
1981 | 34 | |||
1982 | 35 | "launchpad.net/snappy/_integration-tests/testutils/config" | ||
1983 | 36 | ) | ||
1984 | 37 | |||
1985 | 38 | const ( | ||
1986 | 39 | // BaseAltPartitionPath is the path to the B system partition. | ||
1987 | 40 | BaseAltPartitionPath = "/writable/cache/system" | ||
1988 | 41 | needsRebootFile = "/tmp/needs-reboot" | ||
1989 | 42 | channelCfgFile = "/etc/system-image/channel.ini" | ||
1990 | 43 | ) | ||
1991 | 44 | |||
1992 | 45 | // Cfg is a struct that contains the configuration values passed from the | ||
1993 | 46 | // host to the testbed. | ||
1994 | 47 | var Cfg *config.Config | ||
1995 | 48 | |||
1996 | 49 | // SnappySuite is a structure used as a base test suite for all the snappy | ||
1997 | 50 | // integration tests. | ||
1998 | 51 | type SnappySuite struct { | ||
1999 | 52 | cleanupHandlers []func() | ||
2000 | 53 | } | ||
2001 | 54 | |||
2002 | 55 | // SetUpSuite disables the snappy autopilot. It will run before all the | ||
2003 | 56 | // integration suites. | ||
2004 | 57 | func (s *SnappySuite) SetUpSuite(c *check.C) { | ||
2005 | 58 | ExecCommand(c, "sudo", "systemctl", "stop", "snappy-autopilot.timer") | ||
2006 | 59 | ExecCommand(c, "sudo", "systemctl", "disable", "snappy-autopilot.timer") | ||
2007 | 60 | if !isInRebootProcess() { | ||
2008 | 61 | var err error | ||
2009 | 62 | Cfg, err = config.ReadConfig( | ||
2010 | 63 | "_integration-tests/data/output/testconfig.json") | ||
2011 | 64 | c.Assert(err, check.IsNil, check.Commentf("Error reading config: %v", err)) | ||
2012 | 65 | if Cfg.Update || Cfg.Rollback { | ||
2013 | 66 | switchSystemImageConf(c, Cfg.TargetRelease, Cfg.TargetChannel, "0") | ||
2014 | 67 | // Always use the installed snappy because we are updating from an old | ||
2015 | 68 | // image, so we should not use the snappy from the branch. | ||
2016 | 69 | output := ExecCommand(c, "sudo", "/usr/bin/snappy", "update") | ||
2017 | 70 | if output != "" { | ||
2018 | 71 | RebootWithMark(c, "setupsuite-update") | ||
2019 | 72 | } | ||
2020 | 73 | } | ||
2021 | 74 | } else if CheckRebootMark("setupsuite-update") { | ||
2022 | 75 | RemoveRebootMark(c) | ||
2023 | 76 | if Cfg.Rollback { | ||
2024 | 77 | ExecCommand(c, "sudo", "snappy", "rollback", "ubuntu-core") | ||
2025 | 78 | RebootWithMark(c, "setupsuite-rollback") | ||
2026 | 79 | } | ||
2027 | 80 | } else if CheckRebootMark("setupsuite-rollback") { | ||
2028 | 81 | RemoveRebootMark(c) | ||
2029 | 82 | } | ||
2030 | 83 | } | ||
2031 | 84 | |||
2032 | 85 | // SetUpTest handles reboots and stores version information. It will run before | ||
2033 | 86 | // all the integration tests. Before running a test, it will save the | ||
2034 | 87 | // ubuntu-core version. If a reboot was requested by a previous test, it | ||
2035 | 88 | // will skip all the following tests. If the suite is being called after the | ||
2036 | 89 | // test bed was rebooted, it will resume the test that requested the reboot. | ||
2037 | 90 | func (s *SnappySuite) SetUpTest(c *check.C) { | ||
2038 | 91 | if NeedsReboot() { | ||
2039 | 92 | contents, err := ioutil.ReadFile(needsRebootFile) | ||
2040 | 93 | c.Assert(err, check.IsNil, check.Commentf("Error reading needs-reboot file %v", err)) | ||
2041 | 94 | c.Skip(fmt.Sprintf("****** Skipped %s during reboot caused by %s", | ||
2042 | 95 | c.TestName(), contents)) | ||
2043 | 96 | } else { | ||
2044 | 97 | if CheckRebootMark("") { | ||
2045 | 98 | c.Logf("****** Running %s", c.TestName()) | ||
2046 | 99 | SetSavedVersion(c, GetCurrentUbuntuCoreVersion(c)) | ||
2047 | 100 | } else { | ||
2048 | 101 | if AfterReboot(c) { | ||
2049 | 102 | c.Logf("****** Resuming %s after reboot", c.TestName()) | ||
2050 | 103 | } else { | ||
2051 | 104 | c.Skip(fmt.Sprintf("****** Skipped %s after reboot caused by %s", | ||
2052 | 105 | c.TestName(), os.Getenv("ADT_REBOOT_MARK"))) | ||
2053 | 106 | } | ||
2054 | 107 | } | ||
2055 | 108 | } | ||
2056 | 109 | // clear slice | ||
2057 | 110 | s.cleanupHandlers = nil | ||
2058 | 111 | } | ||
2059 | 112 | |||
2060 | 113 | // TearDownTest cleans up the channel.ini files in case they were changed by | ||
2061 | 114 | // the test. | ||
2062 | 115 | // It also runs the cleanup handlers | ||
2063 | 116 | func (s *SnappySuite) TearDownTest(c *check.C) { | ||
2064 | 117 | if !NeedsReboot() && CheckRebootMark("") { | ||
2065 | 118 | // Only restore the channel config files if the reboot has been handled. | ||
2066 | 119 | m := make(map[string]string) | ||
2067 | 120 | m[channelCfgBackupFile()] = "/" | ||
2068 | 121 | m[channelCfgOtherBackupFile()] = BaseAltPartitionPath | ||
2069 | 122 | for backup, target := range m { | ||
2070 | 123 | if _, err := os.Stat(backup); err == nil { | ||
2071 | 124 | MakeWritable(c, target) | ||
2072 | 125 | defer MakeReadonly(c, target) | ||
2073 | 126 | original := filepath.Join(target, channelCfgFile) | ||
2074 | 127 | c.Logf("Restoring %s...", original) | ||
2075 | 128 | ExecCommand(c, "sudo", "mv", backup, original) | ||
2076 | 129 | } | ||
2077 | 130 | } | ||
2078 | 131 | } | ||
2079 | 132 | |||
2080 | 133 | // run cleanup handlers and clear the slice | ||
2081 | 134 | for _, f := range s.cleanupHandlers { | ||
2082 | 135 | f() | ||
2083 | 136 | } | ||
2084 | 137 | s.cleanupHandlers = nil | ||
2085 | 138 | } | ||
2086 | 139 | |||
2087 | 140 | // AddCleanup adds a new cleanup function to the test | ||
2088 | 141 | func (s *SnappySuite) AddCleanup(f func()) { | ||
2089 | 142 | s.cleanupHandlers = append(s.cleanupHandlers, f) | ||
2090 | 143 | } | ||
2091 | 144 | |||
2092 | 145 | func switchSystemImageConf(c *check.C, release, channel, version string) { | ||
2093 | 146 | targets := []string{"/", BaseAltPartitionPath} | ||
2094 | 147 | for _, target := range targets { | ||
2095 | 148 | file := filepath.Join(target, channelCfgFile) | ||
2096 | 149 | if _, err := os.Stat(file); err == nil { | ||
2097 | 150 | MakeWritable(c, target) | ||
2098 | 151 | defer MakeReadonly(c, target) | ||
2099 | 152 | replaceSystemImageValues(c, file, release, channel, version) | ||
2100 | 153 | } | ||
2101 | 154 | } | ||
2102 | 155 | } | ||
2103 | 156 | |||
2104 | 157 | func replaceSystemImageValues(c *check.C, file, release, channel, version string) { | ||
2105 | 158 | c.Log("Switching the system image conf...") | ||
2106 | 159 | replaceRegex := map[string]string{ | ||
2107 | 160 | release: `s#channel: ubuntu-core/.*/\(.*\)#channel: ubuntu-core/%s/\1#`, | ||
2108 | 161 | channel: `s#channel: ubuntu-core/\(.*\)/.*#channel: ubuntu-core/\1/%s#`, | ||
2109 | 162 | version: `s/build_number: .*/build_number: %s/`, | ||
2110 | 163 | } | ||
2111 | 164 | for value, regex := range replaceRegex { | ||
2112 | 165 | if value != "" { | ||
2113 | 166 | ExecCommand(c, | ||
2114 | 167 | "sudo", "sed", "-i", fmt.Sprintf(regex, value), file) | ||
2115 | 168 | } | ||
2116 | 169 | } | ||
2117 | 170 | // Leave the new file in the test log. | ||
2118 | 171 | ExecCommand(c, "cat", file) | ||
2119 | 172 | } | ||
2120 | 173 | |||
2121 | 174 | func channelCfgBackupFile() string { | ||
2122 | 175 | return filepath.Join(os.Getenv("ADT_ARTIFACTS"), "channel.ini") | ||
2123 | 176 | } | ||
2124 | 177 | |||
2125 | 178 | func channelCfgOtherBackupFile() string { | ||
2126 | 179 | return filepath.Join(os.Getenv("ADT_ARTIFACTS"), "channel.ini.other") | ||
2127 | 180 | } | ||
2128 | 181 | |||
2129 | 182 | // ExecCommand executes a shell command and returns a string with the output | ||
2130 | 183 | // of the command. In case of error, it will fail the test. | ||
2131 | 184 | func ExecCommand(c *check.C, cmds ...string) string { | ||
2132 | 185 | fmt.Println(strings.Join(cmds, " ")) | ||
2133 | 186 | cmd := exec.Command(cmds[0], cmds[1:len(cmds)]...) | ||
2134 | 187 | output, err := cmd.CombinedOutput() | ||
2135 | 188 | stringOutput := string(output) | ||
2136 | 189 | fmt.Print(stringOutput) | ||
2137 | 190 | c.Assert(err, check.IsNil, check.Commentf("Error: %v", stringOutput)) | ||
2138 | 191 | return stringOutput | ||
2139 | 192 | } | ||
2140 | 193 | |||
2141 | 194 | // ExecCommandToFile executes a shell command and saves the output of the | ||
2142 | 195 | // command to a file. In case of error, it will fail the test. | ||
2143 | 196 | func ExecCommandToFile(c *check.C, filename string, cmds ...string) { | ||
2144 | 197 | cmd := exec.Command(cmds[0], cmds[1:len(cmds)]...) | ||
2145 | 198 | outfile, err := os.Create(filename) | ||
2146 | 199 | c.Assert(err, check.IsNil, check.Commentf("Error creating output file %s", filename)) | ||
2147 | 200 | |||
2148 | 201 | defer outfile.Close() | ||
2149 | 202 | cmd.Stdout = outfile | ||
2150 | 203 | |||
2151 | 204 | err = cmd.Run() | ||
2152 | 205 | c.Assert(err, check.IsNil, check.Commentf("Error executing command '%v': %v", cmds, err)) | ||
2153 | 206 | } | ||
2154 | 207 | |||
2155 | 208 | // GetCurrentVersion returns the version of the installed and active package. | ||
2156 | 209 | func GetCurrentVersion(c *check.C, packageName string) string { | ||
2157 | 210 | output := ExecCommand(c, "snappy", "list") | ||
2158 | 211 | pattern := "(?mU)^" + packageName + " +(.*)$" | ||
2159 | 212 | re := regexp.MustCompile(pattern) | ||
2160 | 213 | match := re.FindStringSubmatch(string(output)) | ||
2161 | 214 | c.Assert(match, check.NotNil, check.Commentf("Version not found in %s", output)) | ||
2162 | 215 | |||
2163 | 216 | // match is like "ubuntu-core 2015-06-18 93 ubuntu" | ||
2164 | 217 | items := strings.Fields(match[0]) | ||
2165 | 218 | return items[2] | ||
2166 | 219 | } | ||
2167 | 220 | |||
2168 | 221 | // GetCurrentUbuntuCoreVersion returns the version number of the installed and | ||
2169 | 222 | // active ubuntu-core. | ||
2170 | 223 | func GetCurrentUbuntuCoreVersion(c *check.C) int { | ||
2171 | 224 | versionString := GetCurrentVersion(c, "ubuntu-core") | ||
2172 | 225 | version, err := strconv.Atoi(versionString) | ||
2173 | 226 | c.Assert(err, check.IsNil, check.Commentf("Error converting version to int %v", version)) | ||
2174 | 227 | return version | ||
2175 | 228 | } | ||
2176 | 229 | |||
2177 | 230 | // CallFakeUpdate calls snappy update after faking the current version | ||
2178 | 231 | func CallFakeUpdate(c *check.C) string { | ||
2179 | 232 | c.Log("Preparing fake and calling update.") | ||
2180 | 233 | fakeAvailableUpdate(c) | ||
2181 | 234 | return ExecCommand(c, "sudo", "snappy", "update") | ||
2182 | 235 | } | ||
2183 | 236 | |||
2184 | 237 | func fakeAvailableUpdate(c *check.C) { | ||
2185 | 238 | c.Log("Faking an available update...") | ||
2186 | 239 | currentVersion := GetCurrentUbuntuCoreVersion(c) | ||
2187 | 240 | switchChannelVersionWithBackup(c, currentVersion-1) | ||
2188 | 241 | SetSavedVersion(c, currentVersion-1) | ||
2189 | 242 | } | ||
2190 | 243 | |||
2191 | 244 | func switchChannelVersionWithBackup(c *check.C, newVersion int) { | ||
2192 | 245 | m := make(map[string]string) | ||
2193 | 246 | m["/"] = channelCfgBackupFile() | ||
2194 | 247 | m[BaseAltPartitionPath] = channelCfgOtherBackupFile() | ||
2195 | 248 | for target, backup := range m { | ||
2196 | 249 | file := filepath.Join(target, channelCfgFile) | ||
2197 | 250 | if _, err := os.Stat(file); err == nil { | ||
2198 | 251 | MakeWritable(c, target) | ||
2199 | 252 | defer MakeReadonly(c, target) | ||
2200 | 253 | // Back up the file. It will be restored during the test tear down. | ||
2201 | 254 | ExecCommand(c, "cp", file, backup) | ||
2202 | 255 | replaceSystemImageValues(c, file, "", "", strconv.Itoa(newVersion)) | ||
2203 | 256 | } | ||
2204 | 257 | } | ||
2205 | 258 | } | ||
2206 | 259 | |||
2207 | 260 | // MakeWritable remounts a path with read and write permissions. | ||
2208 | 261 | func MakeWritable(c *check.C, path string) { | ||
2209 | 262 | ExecCommand(c, "sudo", "mount", "-o", "remount,rw", path) | ||
2210 | 263 | } | ||
2211 | 264 | |||
2212 | 265 | // MakeReadonly remounts a path with only read permissions. | ||
2213 | 266 | func MakeReadonly(c *check.C, path string) { | ||
2214 | 267 | ExecCommand(c, "sudo", "mount", "-o", "remount,ro", path) | ||
2215 | 268 | } | ||
2216 | 269 | |||
2217 | 270 | // Reboot requests a reboot using the test name as the mark. | ||
2218 | 271 | func Reboot(c *check.C) { | ||
2219 | 272 | RebootWithMark(c, c.TestName()) | ||
2220 | 273 | } | ||
2221 | 274 | |||
2222 | 275 | // RebootWithMark requests a reboot using a specified mark. | ||
2223 | 276 | func RebootWithMark(c *check.C, mark string) { | ||
2224 | 277 | c.Log("Preparing reboot with mark " + mark) | ||
2225 | 278 | err := ioutil.WriteFile(needsRebootFile, []byte(mark), 0777) | ||
2226 | 279 | c.Assert(err, check.IsNil, check.Commentf("Error writing needs-reboot file: %v", err)) | ||
2227 | 280 | } | ||
2228 | 281 | |||
2229 | 282 | // NeedsReboot returns True if a reboot has been requested by a test. | ||
2230 | 283 | func NeedsReboot() bool { | ||
2231 | 284 | _, err := os.Stat(needsRebootFile) | ||
2232 | 285 | return err == nil | ||
2233 | 286 | } | ||
2234 | 287 | |||
2235 | 288 | // BeforeReboot returns True if the test is running before the test bed has | ||
2236 | 289 | // been rebooted, or after the test that requested the reboot handled it. | ||
2237 | 290 | func BeforeReboot() bool { | ||
2238 | 291 | return CheckRebootMark("") | ||
2239 | 292 | } | ||
2240 | 293 | |||
2241 | 294 | // AfterReboot returns True if the test is running after the test bed has been | ||
2242 | 295 | // rebooted. | ||
2243 | 296 | func AfterReboot(c *check.C) bool { | ||
2244 | 297 | // $ADT_REBOOT_MARK contains the reboot mark, if we have rebooted it'll be the test name | ||
2245 | 298 | return strings.HasPrefix(os.Getenv("ADT_REBOOT_MARK"), c.TestName()) | ||
2246 | 299 | } | ||
2247 | 300 | |||
2248 | 301 | // CheckRebootMark returns True if the reboot mark matches the string passed as | ||
2249 | 302 | // argument. | ||
2250 | 303 | func CheckRebootMark(mark string) bool { | ||
2251 | 304 | return os.Getenv("ADT_REBOOT_MARK") == mark | ||
2252 | 305 | } | ||
2253 | 306 | |||
2254 | 307 | func isInRebootProcess() bool { | ||
2255 | 308 | return !CheckRebootMark("") || NeedsReboot() | ||
2256 | 309 | } | ||
2257 | 310 | |||
2258 | 311 | // RemoveRebootMark removes the reboot mark to signal that the reboot has been | ||
2259 | 312 | // handled. | ||
2260 | 313 | func RemoveRebootMark(c *check.C) { | ||
2261 | 314 | os.Setenv("ADT_REBOOT_MARK", "") | ||
2262 | 315 | } | ||
2263 | 316 | |||
2264 | 317 | // SetSavedVersion saves a version number into a file so it can be used on | ||
2265 | 318 | // tests after reboots. | ||
2266 | 319 | func SetSavedVersion(c *check.C, version int) { | ||
2267 | 320 | versionFile := getVersionFile() | ||
2268 | 321 | err := ioutil.WriteFile(versionFile, []byte(strconv.Itoa(version)), 0777) | ||
2269 | 322 | c.Assert(err, check.IsNil, check.Commentf("Error writing version file %s with %s", versionFile, version)) | ||
2270 | 323 | } | ||
2271 | 324 | |||
2272 | 325 | // GetSavedVersion returns the saved version number. | ||
2273 | 326 | func GetSavedVersion(c *check.C) int { | ||
2274 | 327 | versionFile := getVersionFile() | ||
2275 | 328 | contents, err := ioutil.ReadFile(versionFile) | ||
2276 | 329 | c.Assert(err, check.IsNil, check.Commentf("Error reading version file %s", versionFile)) | ||
2277 | 330 | |||
2278 | 331 | version, err := strconv.Atoi(string(contents)) | ||
2279 | 332 | c.Assert(err, check.IsNil, check.Commentf("Error converting version %v", contents)) | ||
2280 | 333 | |||
2281 | 334 | return version | ||
2282 | 335 | } | ||
2283 | 336 | |||
2284 | 337 | func getVersionFile() string { | ||
2285 | 338 | return filepath.Join(os.Getenv("ADT_ARTIFACTS"), "version") | ||
2286 | 339 | } | ||
2287 | 340 | |||
2288 | 341 | // InstallSnap executes the required command to install the specified snap | ||
2289 | 342 | func InstallSnap(c *check.C, packageName string) string { | ||
2290 | 343 | return ExecCommand(c, "sudo", "snappy", "install", packageName, "--allow-unauthenticated") | ||
2291 | 344 | } | ||
2292 | 345 | |||
2293 | 346 | // RemoveSnap executes the required command to remove the specified snap | ||
2294 | 347 | func RemoveSnap(c *check.C, packageName string) string { | ||
2295 | 348 | return ExecCommand(c, "sudo", "snappy", "remove", packageName) | ||
2296 | 349 | } | ||
2297 | 350 | |||
2298 | 351 | // WaitForActiveService keeps asking for the active state of the given service until | ||
2299 | 352 | // it is active or the maximun waiting time expires, in which case an error is returned | ||
2300 | 353 | func WaitForActiveService(c *check.C, serviceName string) error { | ||
2301 | 354 | maxWait := time.Second * 10 | ||
2302 | 355 | checkInterval := time.Millisecond * 500 | ||
2303 | 356 | |||
2304 | 357 | timer := time.NewTimer(maxWait) | ||
2305 | 358 | timeChan := timer.C | ||
2306 | 359 | |||
2307 | 360 | ticker := time.NewTicker(checkInterval) | ||
2308 | 361 | tickChan := ticker.C | ||
2309 | 362 | |||
2310 | 363 | for { | ||
2311 | 364 | select { | ||
2312 | 365 | case <-timeChan: | ||
2313 | 366 | ticker.Stop() | ||
2314 | 367 | journalctlOutput := ExecCommand(c, "sudo", "journalctl", "-u", serviceName) | ||
2315 | 368 | return fmt.Errorf("Service %s not active after %s, journalctl output: %s", | ||
2316 | 369 | serviceName, maxWait, journalctlOutput) | ||
2317 | 370 | case <-tickChan: | ||
2318 | 371 | statusOutput := ExecCommand( | ||
2319 | 372 | c, "systemctl", "show", "-p", "ActiveState", serviceName) | ||
2320 | 373 | if statusOutput == "ActiveState=active\n" { | ||
2321 | 374 | timer.Stop() | ||
2322 | 375 | return nil | ||
2323 | 376 | } | ||
2324 | 377 | } | ||
2325 | 378 | } | ||
2326 | 379 | } | ||
2327 | 0 | 380 | ||
2328 | === added file '_integration-tests/testutils/common/common_test.go' | |||
2329 | --- _integration-tests/testutils/common/common_test.go 1970-01-01 00:00:00 +0000 | |||
2330 | +++ _integration-tests/testutils/common/common_test.go 2015-08-02 12:28:18 +0000 | |||
2331 | @@ -0,0 +1,68 @@ | |||
2332 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
2333 | 2 | |||
2334 | 3 | /* | ||
2335 | 4 | * Copyright (C) 2014-2015 Canonical Ltd | ||
2336 | 5 | * | ||
2337 | 6 | * This program is free software: you can redistribute it and/or modify | ||
2338 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
2339 | 8 | * published by the Free Software Foundation. | ||
2340 | 9 | * | ||
2341 | 10 | * This program is distributed in the hope that it will be useful, | ||
2342 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2343 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2344 | 13 | * GNU General Public License for more details. | ||
2345 | 14 | * | ||
2346 | 15 | * You should have received a copy of the GNU General Public License | ||
2347 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2348 | 17 | * | ||
2349 | 18 | */ | ||
2350 | 19 | |||
2351 | 20 | package common | ||
2352 | 21 | |||
2353 | 22 | import ( | ||
2354 | 23 | "testing" | ||
2355 | 24 | |||
2356 | 25 | . "gopkg.in/check.v1" | ||
2357 | 26 | ) | ||
2358 | 27 | |||
2359 | 28 | // Hook up check.v1 into the "go test" runner | ||
2360 | 29 | func Test(t *testing.T) { TestingT(t) } | ||
2361 | 30 | |||
2362 | 31 | // testing a testsuite - thats so meta | ||
2363 | 32 | type MetaTestSuite struct { | ||
2364 | 33 | } | ||
2365 | 34 | |||
2366 | 35 | var _ = Suite(&MetaTestSuite{}) | ||
2367 | 36 | |||
2368 | 37 | // test trivial cleanup | ||
2369 | 38 | func (m *MetaTestSuite) TestCleanupSimple(c *C) { | ||
2370 | 39 | canary := "not-called" | ||
2371 | 40 | s := SnappySuite{} | ||
2372 | 41 | |||
2373 | 42 | s.AddCleanup(func() { | ||
2374 | 43 | canary = "was-called" | ||
2375 | 44 | }) | ||
2376 | 45 | s.TearDownTest(c) | ||
2377 | 46 | |||
2378 | 47 | c.Assert(canary, Equals, "was-called") | ||
2379 | 48 | } | ||
2380 | 49 | |||
2381 | 50 | // a mock method that takes a parameter | ||
2382 | 51 | func mockCleanupMethodWithParameters(s *string) { | ||
2383 | 52 | *s = "was-called" | ||
2384 | 53 | } | ||
2385 | 54 | |||
2386 | 55 | // test that whle AddCleanup() does not take any parameters itself, | ||
2387 | 56 | // functions that need parameters can be passed by creating an | ||
2388 | 57 | // anonymous function as a wrapper | ||
2389 | 58 | func (m *MetaTestSuite) TestCleanupWithParameters(c *C) { | ||
2390 | 59 | canary := "not-called" | ||
2391 | 60 | s := SnappySuite{} | ||
2392 | 61 | |||
2393 | 62 | s.AddCleanup(func() { | ||
2394 | 63 | mockCleanupMethodWithParameters(&canary) | ||
2395 | 64 | }) | ||
2396 | 65 | s.TearDownTest(c) | ||
2397 | 66 | |||
2398 | 67 | c.Assert(canary, Equals, "was-called") | ||
2399 | 68 | } | ||
2400 | 0 | 69 | ||
2401 | === added directory '_integration-tests/testutils/config' | |||
2402 | === added file '_integration-tests/testutils/config/config.go' | |||
2403 | --- _integration-tests/testutils/config/config.go 1970-01-01 00:00:00 +0000 | |||
2404 | +++ _integration-tests/testutils/config/config.go 2015-08-02 12:28:18 +0000 | |||
2405 | @@ -0,0 +1,75 @@ | |||
2406 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
2407 | 2 | |||
2408 | 3 | /* | ||
2409 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
2410 | 5 | * | ||
2411 | 6 | * This program is free software: you can redistribute it and/or modify | ||
2412 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
2413 | 8 | * published by the Free Software Foundation. | ||
2414 | 9 | * | ||
2415 | 10 | * This program is distributed in the hope that it will be useful, | ||
2416 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2417 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2418 | 13 | * GNU General Public License for more details. | ||
2419 | 14 | * | ||
2420 | 15 | * You should have received a copy of the GNU General Public License | ||
2421 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2422 | 17 | * | ||
2423 | 18 | */ | ||
2424 | 19 | |||
2425 | 20 | package config | ||
2426 | 21 | |||
2427 | 22 | import ( | ||
2428 | 23 | "encoding/json" | ||
2429 | 24 | "fmt" | ||
2430 | 25 | "io/ioutil" | ||
2431 | 26 | "log" | ||
2432 | 27 | ) | ||
2433 | 28 | |||
2434 | 29 | // Config contains the values to pass to the test bed from the host. | ||
2435 | 30 | type Config struct { | ||
2436 | 31 | FileName string | ||
2437 | 32 | Release string | ||
2438 | 33 | Channel string | ||
2439 | 34 | TargetRelease string | ||
2440 | 35 | TargetChannel string | ||
2441 | 36 | RemoteTestbed bool | ||
2442 | 37 | Update bool | ||
2443 | 38 | Rollback bool | ||
2444 | 39 | } | ||
2445 | 40 | |||
2446 | 41 | // NewConfig is the Config constructor | ||
2447 | 42 | func NewConfig(fileName, release, channel, targetRelease, targetChannel string, remoteTestbed, update, rollback bool) *Config { | ||
2448 | 43 | return &Config{ | ||
2449 | 44 | FileName: fileName, Release: release, Channel: channel, | ||
2450 | 45 | TargetRelease: targetRelease, TargetChannel: targetChannel, | ||
2451 | 46 | RemoteTestbed: remoteTestbed, Update: update, Rollback: rollback, | ||
2452 | 47 | } | ||
2453 | 48 | } | ||
2454 | 49 | |||
2455 | 50 | // Write writes the config to a file that will be copied to the test bed. | ||
2456 | 51 | func (cfg Config) Write() { | ||
2457 | 52 | fmt.Println("Writing test config...") | ||
2458 | 53 | fmt.Println(cfg) | ||
2459 | 54 | encoded, err := json.Marshal(cfg) | ||
2460 | 55 | if err != nil { | ||
2461 | 56 | log.Panicf("Error encoding the test config: %v", err) | ||
2462 | 57 | } | ||
2463 | 58 | err = ioutil.WriteFile(cfg.FileName, encoded, 0644) | ||
2464 | 59 | if err != nil { | ||
2465 | 60 | log.Panicf("Error writing the test config: %v", err) | ||
2466 | 61 | } | ||
2467 | 62 | } | ||
2468 | 63 | |||
2469 | 64 | // ReadConfig the config from a file | ||
2470 | 65 | func ReadConfig(fileName string) (*Config, error) { | ||
2471 | 66 | b, err := ioutil.ReadFile(fileName) | ||
2472 | 67 | if err != nil { | ||
2473 | 68 | return nil, err | ||
2474 | 69 | } | ||
2475 | 70 | var decoded Config | ||
2476 | 71 | if err = json.Unmarshal(b, &decoded); err != nil { | ||
2477 | 72 | return nil, err | ||
2478 | 73 | } | ||
2479 | 74 | return &decoded, nil | ||
2480 | 75 | } | ||
2481 | 0 | 76 | ||
2482 | === added file '_integration-tests/testutils/config/config.test' | |||
2483 | 1 | Binary files _integration-tests/testutils/config/config.test 1970-01-01 00:00:00 +0000 and _integration-tests/testutils/config/config.test 2015-08-02 12:28:18 +0000 differ | 77 | Binary files _integration-tests/testutils/config/config.test 1970-01-01 00:00:00 +0000 and _integration-tests/testutils/config/config.test 2015-08-02 12:28:18 +0000 differ |
2484 | === added file '_integration-tests/testutils/config/config_test.go' | |||
2485 | --- _integration-tests/testutils/config/config_test.go 1970-01-01 00:00:00 +0000 | |||
2486 | +++ _integration-tests/testutils/config/config_test.go 2015-08-02 12:28:18 +0000 | |||
2487 | @@ -0,0 +1,121 @@ | |||
2488 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
2489 | 2 | |||
2490 | 3 | /* | ||
2491 | 4 | * Copyright (C) 2014-2015 Canonical Ltd | ||
2492 | 5 | * | ||
2493 | 6 | * This program is free software: you can redistribute it and/or modify | ||
2494 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
2495 | 8 | * published by the Free Software Foundation. | ||
2496 | 9 | * | ||
2497 | 10 | * This program is distributed in the hope that it will be useful, | ||
2498 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2499 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2500 | 13 | * GNU General Public License for more details. | ||
2501 | 14 | * | ||
2502 | 15 | * You should have received a copy of the GNU General Public License | ||
2503 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2504 | 17 | * | ||
2505 | 18 | */ | ||
2506 | 19 | |||
2507 | 20 | package config | ||
2508 | 21 | |||
2509 | 22 | import ( | ||
2510 | 23 | "fmt" | ||
2511 | 24 | "io/ioutil" | ||
2512 | 25 | "os" | ||
2513 | 26 | "path/filepath" | ||
2514 | 27 | "testing" | ||
2515 | 28 | |||
2516 | 29 | check "gopkg.in/check.v1" | ||
2517 | 30 | ) | ||
2518 | 31 | |||
2519 | 32 | // Hook up check.v1 into the "go test" runner | ||
2520 | 33 | func Test(t *testing.T) { check.TestingT(t) } | ||
2521 | 34 | |||
2522 | 35 | type ConfigSuite struct{} | ||
2523 | 36 | |||
2524 | 37 | var _ = check.Suite(&ConfigSuite{}) | ||
2525 | 38 | |||
2526 | 39 | func testConfigFileName(c *check.C) string { | ||
2527 | 40 | tmpDir, err := ioutil.TempDir("", "") | ||
2528 | 41 | c.Assert(err, check.IsNil, check.Commentf( | ||
2529 | 42 | "Error creating a temporary directory: %v", err)) | ||
2530 | 43 | return filepath.Join(tmpDir, "test.config") | ||
2531 | 44 | } | ||
2532 | 45 | |||
2533 | 46 | func testConfigStruct(fileName string) *Config { | ||
2534 | 47 | return NewConfig( | ||
2535 | 48 | fileName, | ||
2536 | 49 | "testrelease", "testchannel", "testtargetrelease", "testtargetchannel", | ||
2537 | 50 | true, true, true) | ||
2538 | 51 | } | ||
2539 | 52 | func testConfigContents(fileName string) string { | ||
2540 | 53 | return `{` + | ||
2541 | 54 | fmt.Sprintf(`"FileName":"%s",`, fileName) + | ||
2542 | 55 | `"Release":"testrelease",` + | ||
2543 | 56 | `"Channel":"testchannel",` + | ||
2544 | 57 | `"TargetRelease":"testtargetrelease",` + | ||
2545 | 58 | `"TargetChannel":"testtargetchannel",` + | ||
2546 | 59 | `"RemoteTestbed":true,` + | ||
2547 | 60 | `"Update":true,` + | ||
2548 | 61 | `"Rollback":true` + | ||
2549 | 62 | `}` | ||
2550 | 63 | } | ||
2551 | 64 | |||
2552 | 65 | func (s *ConfigSuite) TestWriteConfig(c *check.C) { | ||
2553 | 66 | // Do not print to stdout. | ||
2554 | 67 | devnull, err := os.Open(os.DevNull) | ||
2555 | 68 | c.Assert(err, check.IsNil) | ||
2556 | 69 | oldStdout := os.Stdout | ||
2557 | 70 | os.Stdout = devnull | ||
2558 | 71 | defer func() { | ||
2559 | 72 | os.Stdout = oldStdout | ||
2560 | 73 | }() | ||
2561 | 74 | configFileName := testConfigFileName(c) | ||
2562 | 75 | |||
2563 | 76 | cfg := testConfigStruct(configFileName) | ||
2564 | 77 | cfg.Write() | ||
2565 | 78 | |||
2566 | 79 | writtenConfig, err := ioutil.ReadFile(configFileName) | ||
2567 | 80 | c.Assert(err, check.IsNil, check.Commentf("Error reading config: %v", err)) | ||
2568 | 81 | c.Assert(string(writtenConfig), check.Equals, testConfigContents(configFileName)) | ||
2569 | 82 | } | ||
2570 | 83 | |||
2571 | 84 | func (s *ConfigSuite) TestReadConfig(c *check.C) { | ||
2572 | 85 | configFileName := testConfigFileName(c) | ||
2573 | 86 | |||
2574 | 87 | configContents := testConfigContents(configFileName) | ||
2575 | 88 | ioutil.WriteFile(configFileName, []byte(configContents), 0644) | ||
2576 | 89 | |||
2577 | 90 | cfg, err := ReadConfig(configFileName) | ||
2578 | 91 | |||
2579 | 92 | c.Assert(err, check.IsNil, check.Commentf("Error reading config: %v", err)) | ||
2580 | 93 | c.Assert(cfg, check.DeepEquals, testConfigStruct(configFileName)) | ||
2581 | 94 | } | ||
2582 | 95 | |||
2583 | 96 | func (s *ConfigSuite) TestReadConfigLocalTestBed(c *check.C) { | ||
2584 | 97 | configFileName := testConfigFileName(c) | ||
2585 | 98 | |||
2586 | 99 | configContents := `{` + | ||
2587 | 100 | fmt.Sprintf(`"FileName":"%s",`, configFileName) + | ||
2588 | 101 | `"Release":"testrelease",` + | ||
2589 | 102 | `"Channel":"testchannel",` + | ||
2590 | 103 | `"TargetRelease":"testtargetrelease",` + | ||
2591 | 104 | `"TargetChannel":"testtargetchannel",` + | ||
2592 | 105 | `"RemoteTestbed":false,` + | ||
2593 | 106 | `"Update":true,` + | ||
2594 | 107 | `"Rollback":true` + | ||
2595 | 108 | `}` | ||
2596 | 109 | |||
2597 | 110 | ioutil.WriteFile(configFileName, []byte(configContents), 0644) | ||
2598 | 111 | |||
2599 | 112 | cfg, err := ReadConfig(configFileName) | ||
2600 | 113 | |||
2601 | 114 | testConfigStruct := NewConfig( | ||
2602 | 115 | configFileName, | ||
2603 | 116 | "testrelease", "testchannel", "testtargetrelease", "testtargetchannel", | ||
2604 | 117 | false, true, true) | ||
2605 | 118 | |||
2606 | 119 | c.Assert(err, check.IsNil, check.Commentf("Error reading config: %v", err)) | ||
2607 | 120 | c.Assert(cfg, check.DeepEquals, testConfigStruct) | ||
2608 | 121 | } | ||
2609 | 0 | 122 | ||
2610 | === added directory '_integration-tests/testutils/image' | |||
2611 | === added file '_integration-tests/testutils/image/image.go' | |||
2612 | --- _integration-tests/testutils/image/image.go 1970-01-01 00:00:00 +0000 | |||
2613 | +++ _integration-tests/testutils/image/image.go 2015-08-02 12:28:18 +0000 | |||
2614 | @@ -0,0 +1,86 @@ | |||
2615 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
2616 | 2 | |||
2617 | 3 | /* | ||
2618 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
2619 | 5 | * | ||
2620 | 6 | * This program is free software: you can redistribute it and/or modify | ||
2621 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
2622 | 8 | * published by the Free Software Foundation. | ||
2623 | 9 | * | ||
2624 | 10 | * This program is distributed in the hope that it will be useful, | ||
2625 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2626 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2627 | 13 | * GNU General Public License for more details. | ||
2628 | 14 | * | ||
2629 | 15 | * You should have received a copy of the GNU General Public License | ||
2630 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2631 | 17 | * | ||
2632 | 18 | */ | ||
2633 | 19 | |||
2634 | 20 | package image | ||
2635 | 21 | |||
2636 | 22 | import ( | ||
2637 | 23 | "fmt" | ||
2638 | 24 | "path/filepath" | ||
2639 | 25 | "strings" | ||
2640 | 26 | |||
2641 | 27 | "launchpad.net/snappy/_integration-tests/testutils" | ||
2642 | 28 | ) | ||
2643 | 29 | |||
2644 | 30 | // Image type encapsulates image actions | ||
2645 | 31 | type Image struct { | ||
2646 | 32 | release string | ||
2647 | 33 | channel string | ||
2648 | 34 | revision string | ||
2649 | 35 | baseDir string | ||
2650 | 36 | } | ||
2651 | 37 | |||
2652 | 38 | // NewImage is the Image constructor | ||
2653 | 39 | func NewImage(release, channel, revision, baseDir string) *Image { | ||
2654 | 40 | return &Image{release: release, channel: channel, revision: revision, baseDir: baseDir} | ||
2655 | 41 | } | ||
2656 | 42 | |||
2657 | 43 | // UdfCreate forms and executes the UDF command for creating the image | ||
2658 | 44 | func (img Image) UdfCreate() (string, error) { | ||
2659 | 45 | fmt.Println("Creating image...") | ||
2660 | 46 | |||
2661 | 47 | imageDir := filepath.Join(img.baseDir, "image") | ||
2662 | 48 | |||
2663 | 49 | testutils.PrepareTargetDir(imageDir) | ||
2664 | 50 | |||
2665 | 51 | udfCommand := []string{"sudo", "ubuntu-device-flash", "--verbose"} | ||
2666 | 52 | |||
2667 | 53 | if img.revision != "" { | ||
2668 | 54 | udfCommand = append(udfCommand, "--revision", img.revision) | ||
2669 | 55 | } | ||
2670 | 56 | |||
2671 | 57 | imagePath := img.imagePath(imageDir) | ||
2672 | 58 | |||
2673 | 59 | coreOptions := []string{ | ||
2674 | 60 | "core", img.release, | ||
2675 | 61 | "--output", imagePath, | ||
2676 | 62 | "--channel", img.channel, | ||
2677 | 63 | "--developer-mode", | ||
2678 | 64 | } | ||
2679 | 65 | |||
2680 | 66 | err := testutils.ExecCommand(append(udfCommand, coreOptions...)...) | ||
2681 | 67 | |||
2682 | 68 | return imagePath, err | ||
2683 | 69 | } | ||
2684 | 70 | |||
2685 | 71 | func (img Image) imagePath(imageDir string) string { | ||
2686 | 72 | revisionTag := img.revision | ||
2687 | 73 | if revisionTag == "" { | ||
2688 | 74 | revisionTag = "latest" | ||
2689 | 75 | } | ||
2690 | 76 | |||
2691 | 77 | imageName := strings.Join( | ||
2692 | 78 | []string{"snappy", img.release, img.channel, revisionTag}, "-") + ".img" | ||
2693 | 79 | |||
2694 | 80 | return filepath.Join(imageDir, imageName) | ||
2695 | 81 | } | ||
2696 | 82 | |||
2697 | 83 | // SetRevision is the setter method for revision | ||
2698 | 84 | func (img Image) SetRevision(rev string) { | ||
2699 | 85 | img.revision = rev | ||
2700 | 86 | } | ||
2701 | 0 | 87 | ||
2702 | === added file '_integration-tests/testutils/testutils.go' | |||
2703 | --- _integration-tests/testutils/testutils.go 1970-01-01 00:00:00 +0000 | |||
2704 | +++ _integration-tests/testutils/testutils.go 2015-08-02 12:28:18 +0000 | |||
2705 | @@ -0,0 +1,61 @@ | |||
2706 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
2707 | 2 | |||
2708 | 3 | /* | ||
2709 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
2710 | 5 | * | ||
2711 | 6 | * This program is free software: you can redistribute it and/or modify | ||
2712 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
2713 | 8 | * published by the Free Software Foundation. | ||
2714 | 9 | * | ||
2715 | 10 | * This program is distributed in the hope that it will be useful, | ||
2716 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2717 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2718 | 13 | * GNU General Public License for more details. | ||
2719 | 14 | * | ||
2720 | 15 | * You should have received a copy of the GNU General Public License | ||
2721 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2722 | 17 | * | ||
2723 | 18 | */ | ||
2724 | 19 | |||
2725 | 20 | package testutils | ||
2726 | 21 | |||
2727 | 22 | import ( | ||
2728 | 23 | "fmt" | ||
2729 | 24 | "log" | ||
2730 | 25 | "os" | ||
2731 | 26 | "os/exec" | ||
2732 | 27 | "strings" | ||
2733 | 28 | ) | ||
2734 | 29 | |||
2735 | 30 | // PrepareTargetDir creates the given target directory, removing it previously if it didn't exist | ||
2736 | 31 | func PrepareTargetDir(targetDir string) { | ||
2737 | 32 | if _, err := os.Stat(targetDir); err == nil { | ||
2738 | 33 | // dir exists, remove it | ||
2739 | 34 | os.RemoveAll(targetDir) | ||
2740 | 35 | } | ||
2741 | 36 | os.MkdirAll(targetDir, 0777) | ||
2742 | 37 | } | ||
2743 | 38 | |||
2744 | 39 | // RootPath return the test current working directory. | ||
2745 | 40 | func RootPath() string { | ||
2746 | 41 | dir, err := os.Getwd() | ||
2747 | 42 | if err != nil { | ||
2748 | 43 | log.Panic(err) | ||
2749 | 44 | } | ||
2750 | 45 | return dir | ||
2751 | 46 | } | ||
2752 | 47 | |||
2753 | 48 | // ExecCommand executes the given command and pipes the results to os.Stdout and os.Stderr, returning the resulting error | ||
2754 | 49 | func ExecCommand(cmds ...string) error { | ||
2755 | 50 | fmt.Println(strings.Join(cmds, " ")) | ||
2756 | 51 | |||
2757 | 52 | cmd := exec.Command(cmds[0], cmds[1:]...) | ||
2758 | 53 | cmd.Stdout = os.Stdout | ||
2759 | 54 | cmd.Stderr = os.Stderr | ||
2760 | 55 | |||
2761 | 56 | err := cmd.Run() | ||
2762 | 57 | if err != nil { | ||
2763 | 58 | log.Panicf("Error while running %s: %s\n", cmd.Args, err) | ||
2764 | 59 | } | ||
2765 | 60 | return err | ||
2766 | 61 | } | ||
2767 | 0 | 62 | ||
2768 | === modified file 'clickdeb/deb_test.go' | |||
2769 | --- clickdeb/deb_test.go 2015-06-03 19:12:24 +0000 | |||
2770 | +++ clickdeb/deb_test.go 2015-08-02 12:28:18 +0000 | |||
2771 | @@ -27,11 +27,11 @@ | |||
2772 | 27 | "strings" | 27 | "strings" |
2773 | 28 | "testing" | 28 | "testing" |
2774 | 29 | 29 | ||
2776 | 30 | . "launchpad.net/gocheck" | 30 | . "gopkg.in/check.v1" |
2777 | 31 | "launchpad.net/snappy/helpers" | 31 | "launchpad.net/snappy/helpers" |
2778 | 32 | ) | 32 | ) |
2779 | 33 | 33 | ||
2781 | 34 | // Hook up gocheck into the "go test" runner. | 34 | // Hook up check.v1 into the "go test" runner. |
2782 | 35 | func Test(t *testing.T) { TestingT(t) } | 35 | func Test(t *testing.T) { TestingT(t) } |
2783 | 36 | 36 | ||
2784 | 37 | type ClickDebTestSuite struct { | 37 | type ClickDebTestSuite struct { |
2785 | 38 | 38 | ||
2786 | === modified file 'cmd/snappy/cmd_low_level_unpack_test.go' | |||
2787 | --- cmd/snappy/cmd_low_level_unpack_test.go 2015-07-06 18:50:29 +0000 | |||
2788 | +++ cmd/snappy/cmd_low_level_unpack_test.go 2015-08-02 12:28:18 +0000 | |||
2789 | @@ -21,7 +21,7 @@ | |||
2790 | 21 | "os" | 21 | "os" |
2791 | 22 | "path/filepath" | 22 | "path/filepath" |
2792 | 23 | 23 | ||
2794 | 24 | . "launchpad.net/gocheck" | 24 | . "gopkg.in/check.v1" |
2795 | 25 | ) | 25 | ) |
2796 | 26 | 26 | ||
2797 | 27 | func makeTempFile(c *C, content string) *os.File { | 27 | func makeTempFile(c *C, content string) *os.File { |
2798 | 28 | 28 | ||
2799 | === modified file 'cmd/snappy/cmd_set_test.go' | |||
2800 | --- cmd/snappy/cmd_set_test.go 2015-03-26 09:12:58 +0000 | |||
2801 | +++ cmd/snappy/cmd_set_test.go 2015-08-02 12:28:18 +0000 | |||
2802 | @@ -20,10 +20,10 @@ | |||
2803 | 20 | import ( | 20 | import ( |
2804 | 21 | "testing" | 21 | "testing" |
2805 | 22 | 22 | ||
2807 | 23 | . "launchpad.net/gocheck" | 23 | . "gopkg.in/check.v1" |
2808 | 24 | ) | 24 | ) |
2809 | 25 | 25 | ||
2811 | 26 | // Hook up gocheck into the "go test" runner | 26 | // Hook up check.v1 into the "go test" runner |
2812 | 27 | func Test(t *testing.T) { TestingT(t) } | 27 | func Test(t *testing.T) { TestingT(t) } |
2813 | 28 | 28 | ||
2814 | 29 | type CmdTestSuite struct { | 29 | type CmdTestSuite struct { |
2815 | 30 | 30 | ||
2816 | === modified file 'coreconfig/config_test.go' | |||
2817 | --- coreconfig/config_test.go 2015-04-14 16:46:57 +0000 | |||
2818 | +++ coreconfig/config_test.go 2015-08-02 12:28:18 +0000 | |||
2819 | @@ -24,10 +24,10 @@ | |||
2820 | 24 | "path/filepath" | 24 | "path/filepath" |
2821 | 25 | "testing" | 25 | "testing" |
2822 | 26 | 26 | ||
2824 | 27 | . "launchpad.net/gocheck" | 27 | . "gopkg.in/check.v1" |
2825 | 28 | ) | 28 | ) |
2826 | 29 | 29 | ||
2828 | 30 | // Hook up gocheck into the "go test" runner. | 30 | // Hook up check.v1 into the "go test" runner. |
2829 | 31 | func Test(t *testing.T) { TestingT(t) } | 31 | func Test(t *testing.T) { TestingT(t) } |
2830 | 32 | 32 | ||
2831 | 33 | var ( | 33 | var ( |
2832 | 34 | 34 | ||
2833 | === modified file 'debian/control' | |||
2834 | --- debian/control 2015-07-22 06:06:41 +0000 | |||
2835 | +++ debian/control 2015-08-02 12:28:18 +0000 | |||
2836 | @@ -8,10 +8,10 @@ | |||
2837 | 8 | dh-systemd, | 8 | dh-systemd, |
2838 | 9 | fakeroot, | 9 | fakeroot, |
2839 | 10 | golang-ar-dev, | 10 | golang-ar-dev, |
2840 | 11 | golang-check.v1-dev, | ||
2841 | 11 | golang-go, | 12 | golang-go, |
2842 | 12 | golang-go-flags-dev, | 13 | golang-go-flags-dev, |
2843 | 13 | golang-go.crypto-dev, | 14 | golang-go.crypto-dev, |
2844 | 14 | golang-gocheck-dev, | ||
2845 | 15 | golang-goconfigparser-dev, | 15 | golang-goconfigparser-dev, |
2846 | 16 | golang-juju-loggo-dev, | 16 | golang-juju-loggo-dev, |
2847 | 17 | golang-pb-dev, | 17 | golang-pb-dev, |
2848 | 18 | 18 | ||
2849 | === modified file 'dependencies.tsv' | |||
2850 | --- dependencies.tsv 2015-07-22 12:17:49 +0000 | |||
2851 | +++ dependencies.tsv 2015-08-02 12:28:18 +0000 | |||
2852 | @@ -5,5 +5,5 @@ | |||
2853 | 5 | github.com/juju/loggo git 4c7cbce140ca070eeb59a28f4bf9507e511711f9 2015-02-26T05:51:10Z | 5 | github.com/juju/loggo git 4c7cbce140ca070eeb59a28f4bf9507e511711f9 2015-02-26T05:51:10Z |
2854 | 6 | github.com/mvo5/goconfigparser git 26426272dda20cc76aa1fa44286dc743d2972fe8 2015-02-12T09:37:50Z | 6 | github.com/mvo5/goconfigparser git 26426272dda20cc76aa1fa44286dc743d2972fe8 2015-02-12T09:37:50Z |
2855 | 7 | github.com/mvo5/uboot-go git 361f6ebcbb54f389d15dc9faefa000e996ba3e37 2015-07-22T06:53:46Z | 7 | github.com/mvo5/uboot-go git 361f6ebcbb54f389d15dc9faefa000e996ba3e37 2015-07-22T06:53:46Z |
2856 | 8 | gopkg.in/check.v1 git 64131543e7896d5bcc6bd5a76287eb75ea96c673 2014-10-24T13:38:53Z | ||
2857 | 8 | gopkg.in/yaml.v2 git 49c95bdc21843256fb6c4e0d370a05f24a0bf213 2015-02-24T22:57:58Z | 9 | gopkg.in/yaml.v2 git 49c95bdc21843256fb6c4e0d370a05f24a0bf213 2015-02-24T22:57:58Z |
2858 | 9 | launchpad.net/gocheck bzr gustavo@niemeyer.net-20140225173054-xu9zlkf9kxhvow02 87 | ||
2859 | 10 | 10 | ||
2860 | === modified file 'helpers/cmp_test.go' | |||
2861 | --- helpers/cmp_test.go 2015-04-17 06:42:44 +0000 | |||
2862 | +++ helpers/cmp_test.go 2015-08-02 12:28:18 +0000 | |||
2863 | @@ -23,7 +23,7 @@ | |||
2864 | 23 | "path/filepath" | 23 | "path/filepath" |
2865 | 24 | "strings" | 24 | "strings" |
2866 | 25 | 25 | ||
2868 | 26 | . "launchpad.net/gocheck" | 26 | . "gopkg.in/check.v1" |
2869 | 27 | ) | 27 | ) |
2870 | 28 | 28 | ||
2871 | 29 | func (ts *HTestSuite) TestCmp(c *C) { | 29 | func (ts *HTestSuite) TestCmp(c *C) { |
2872 | 30 | 30 | ||
2873 | === modified file 'helpers/helpers_test.go' | |||
2874 | --- helpers/helpers_test.go 2015-06-04 15:00:44 +0000 | |||
2875 | +++ helpers/helpers_test.go 2015-08-02 12:28:18 +0000 | |||
2876 | @@ -27,7 +27,7 @@ | |||
2877 | 27 | "path/filepath" | 27 | "path/filepath" |
2878 | 28 | "testing" | 28 | "testing" |
2879 | 29 | 29 | ||
2881 | 30 | . "launchpad.net/gocheck" | 30 | . "gopkg.in/check.v1" |
2882 | 31 | ) | 31 | ) |
2883 | 32 | 32 | ||
2884 | 33 | func Test(t *testing.T) { TestingT(t) } | 33 | func Test(t *testing.T) { TestingT(t) } |
2885 | 34 | 34 | ||
2886 | === modified file 'helpers/touch_test.go' | |||
2887 | --- helpers/touch_test.go 2015-04-13 17:00:53 +0000 | |||
2888 | +++ helpers/touch_test.go 2015-08-02 12:28:18 +0000 | |||
2889 | @@ -22,7 +22,7 @@ | |||
2890 | 22 | "path/filepath" | 22 | "path/filepath" |
2891 | 23 | "time" | 23 | "time" |
2892 | 24 | 24 | ||
2894 | 25 | . "launchpad.net/gocheck" | 25 | . "gopkg.in/check.v1" |
2895 | 26 | ) | 26 | ) |
2896 | 27 | 27 | ||
2897 | 28 | func (ts *HTestSuite) TestUpdateTimestamp(c *C) { | 28 | func (ts *HTestSuite) TestUpdateTimestamp(c *C) { |
2898 | 29 | 29 | ||
2899 | === modified file 'logger/logger_test.go' | |||
2900 | --- logger/logger_test.go 2015-03-31 14:12:52 +0000 | |||
2901 | +++ logger/logger_test.go 2015-08-02 12:28:18 +0000 | |||
2902 | @@ -28,7 +28,7 @@ | |||
2903 | 28 | "time" | 28 | "time" |
2904 | 29 | 29 | ||
2905 | 30 | "github.com/juju/loggo" | 30 | "github.com/juju/loggo" |
2907 | 31 | . "launchpad.net/gocheck" | 31 | . "gopkg.in/check.v1" |
2908 | 32 | ) | 32 | ) |
2909 | 33 | 33 | ||
2910 | 34 | func Test(t *testing.T) { TestingT(t) } | 34 | func Test(t *testing.T) { TestingT(t) } |
2911 | 35 | 35 | ||
2912 | === modified file 'oauth/oauth_test.go' | |||
2913 | --- oauth/oauth_test.go 2015-07-06 18:59:53 +0000 | |||
2914 | +++ oauth/oauth_test.go 2015-08-02 12:28:18 +0000 | |||
2915 | @@ -22,7 +22,7 @@ | |||
2916 | 22 | import ( | 22 | import ( |
2917 | 23 | "testing" | 23 | "testing" |
2918 | 24 | 24 | ||
2920 | 25 | . "launchpad.net/gocheck" | 25 | . "gopkg.in/check.v1" |
2921 | 26 | ) | 26 | ) |
2922 | 27 | 27 | ||
2923 | 28 | func Test(t *testing.T) { TestingT(t) } | 28 | func Test(t *testing.T) { TestingT(t) } |
2924 | 29 | 29 | ||
2925 | === modified file 'partition/bootloader_grub_test.go' | |||
2926 | --- partition/bootloader_grub_test.go 2015-04-30 11:28:39 +0000 | |||
2927 | +++ partition/bootloader_grub_test.go 2015-08-02 12:28:18 +0000 | |||
2928 | @@ -22,7 +22,7 @@ | |||
2929 | 22 | "io/ioutil" | 22 | "io/ioutil" |
2930 | 23 | "os" | 23 | "os" |
2931 | 24 | 24 | ||
2933 | 25 | . "launchpad.net/gocheck" | 25 | . "gopkg.in/check.v1" |
2934 | 26 | ) | 26 | ) |
2935 | 27 | 27 | ||
2936 | 28 | func mockGrubFile(c *C, newPath string, mode os.FileMode) { | 28 | func mockGrubFile(c *C, newPath string, mode os.FileMode) { |
2937 | 29 | 29 | ||
2938 | === modified file 'partition/bootloader_uboot_test.go' | |||
2939 | --- partition/bootloader_uboot_test.go 2015-07-23 11:58:40 +0000 | |||
2940 | +++ partition/bootloader_uboot_test.go 2015-08-02 12:28:18 +0000 | |||
2941 | @@ -24,7 +24,7 @@ | |||
2942 | 24 | "strings" | 24 | "strings" |
2943 | 25 | "time" | 25 | "time" |
2944 | 26 | 26 | ||
2946 | 27 | . "launchpad.net/gocheck" | 27 | . "gopkg.in/check.v1" |
2947 | 28 | "launchpad.net/snappy/helpers" | 28 | "launchpad.net/snappy/helpers" |
2948 | 29 | 29 | ||
2949 | 30 | "github.com/mvo5/uboot-go/uenv" | 30 | "github.com/mvo5/uboot-go/uenv" |
2950 | 31 | 31 | ||
2951 | === modified file 'partition/partition_test.go' | |||
2952 | --- partition/partition_test.go 2015-07-22 06:06:41 +0000 | |||
2953 | +++ partition/partition_test.go 2015-08-02 12:28:18 +0000 | |||
2954 | @@ -25,10 +25,10 @@ | |||
2955 | 25 | "strings" | 25 | "strings" |
2956 | 26 | "testing" | 26 | "testing" |
2957 | 27 | 27 | ||
2959 | 28 | . "launchpad.net/gocheck" | 28 | . "gopkg.in/check.v1" |
2960 | 29 | ) | 29 | ) |
2961 | 30 | 30 | ||
2963 | 31 | // Hook up gocheck into the "go test" runner | 31 | // Hook up check.v1 into the "go test" runner |
2964 | 32 | func Test(t *testing.T) { TestingT(t) } | 32 | func Test(t *testing.T) { TestingT(t) } |
2965 | 33 | 33 | ||
2966 | 34 | // partition specific testsuite | 34 | // partition specific testsuite |
2967 | 35 | 35 | ||
2968 | === modified file 'partition/utils_test.go' | |||
2969 | --- partition/utils_test.go 2015-03-26 09:12:58 +0000 | |||
2970 | +++ partition/utils_test.go 2015-08-02 12:28:18 +0000 | |||
2971 | @@ -18,7 +18,7 @@ | |||
2972 | 18 | package partition | 18 | package partition |
2973 | 19 | 19 | ||
2974 | 20 | import ( | 20 | import ( |
2976 | 21 | . "launchpad.net/gocheck" | 21 | . "gopkg.in/check.v1" |
2977 | 22 | ) | 22 | ) |
2978 | 23 | 23 | ||
2979 | 24 | type UtilsTestSuite struct { | 24 | type UtilsTestSuite struct { |
2980 | 25 | 25 | ||
2981 | === modified file 'policy/policy_test.go' | |||
2982 | --- policy/policy_test.go 2015-04-17 06:42:44 +0000 | |||
2983 | +++ policy/policy_test.go 2015-08-02 12:28:18 +0000 | |||
2984 | @@ -24,11 +24,12 @@ | |||
2985 | 24 | "path/filepath" | 24 | "path/filepath" |
2986 | 25 | "testing" | 25 | "testing" |
2987 | 26 | 26 | ||
2988 | 27 | . "launchpad.net/gocheck" | ||
2989 | 28 | "sort" | 27 | "sort" |
2990 | 28 | |||
2991 | 29 | . "gopkg.in/check.v1" | ||
2992 | 29 | ) | 30 | ) |
2993 | 30 | 31 | ||
2995 | 31 | // Hook up gocheck into the "go test" runner. | 32 | // Hook up check.v1 into the "go test" runner. |
2996 | 32 | func Test(t *testing.T) { TestingT(t) } | 33 | func Test(t *testing.T) { TestingT(t) } |
2997 | 33 | 34 | ||
2998 | 34 | type policySuite struct { | 35 | type policySuite struct { |
2999 | 35 | 36 | ||
3000 | === modified file 'priv/priv_test.go' | |||
3001 | --- priv/priv_test.go 2015-03-26 09:12:58 +0000 | |||
3002 | +++ priv/priv_test.go 2015-08-02 12:28:18 +0000 | |||
3003 | @@ -23,7 +23,7 @@ | |||
3004 | 23 | "path/filepath" | 23 | "path/filepath" |
3005 | 24 | "testing" | 24 | "testing" |
3006 | 25 | 25 | ||
3008 | 26 | . "launchpad.net/gocheck" | 26 | . "gopkg.in/check.v1" |
3009 | 27 | ) | 27 | ) |
3010 | 28 | 28 | ||
3011 | 29 | func Test(t *testing.T) { TestingT(t) } | 29 | func Test(t *testing.T) { TestingT(t) } |
3012 | 30 | 30 | ||
3013 | === modified file 'progress/progress_test.go' | |||
3014 | --- progress/progress_test.go 2015-05-29 13:41:55 +0000 | |||
3015 | +++ progress/progress_test.go 2015-08-02 12:28:18 +0000 | |||
3016 | @@ -23,10 +23,10 @@ | |||
3017 | 23 | "os" | 23 | "os" |
3018 | 24 | "testing" | 24 | "testing" |
3019 | 25 | 25 | ||
3021 | 26 | . "launchpad.net/gocheck" | 26 | . "gopkg.in/check.v1" |
3022 | 27 | ) | 27 | ) |
3023 | 28 | 28 | ||
3025 | 29 | // Hook up gocheck into the "go test" runner | 29 | // Hook up check.v1 into the "go test" runner |
3026 | 30 | func Test(t *testing.T) { TestingT(t) } | 30 | func Test(t *testing.T) { TestingT(t) } |
3027 | 31 | 31 | ||
3028 | 32 | type ProgressTestSuite struct { | 32 | type ProgressTestSuite struct { |
3029 | 33 | 33 | ||
3030 | === modified file 'release/release_test.go' | |||
3031 | --- release/release_test.go 2015-04-18 19:10:25 +0000 | |||
3032 | +++ release/release_test.go 2015-08-02 12:28:18 +0000 | |||
3033 | @@ -24,10 +24,10 @@ | |||
3034 | 24 | "path/filepath" | 24 | "path/filepath" |
3035 | 25 | "testing" | 25 | "testing" |
3036 | 26 | 26 | ||
3038 | 27 | . "launchpad.net/gocheck" | 27 | . "gopkg.in/check.v1" |
3039 | 28 | ) | 28 | ) |
3040 | 29 | 29 | ||
3042 | 30 | // Hook up gocheck into the "go test" runner | 30 | // Hook up check.v1 into the "go test" runner |
3043 | 31 | func Test(t *testing.T) { TestingT(t) } | 31 | func Test(t *testing.T) { TestingT(t) } |
3044 | 32 | 32 | ||
3045 | 33 | type ReleaseTestSuite struct { | 33 | type ReleaseTestSuite struct { |
3046 | 34 | 34 | ||
3047 | === modified file 'run-checks' | |||
3048 | --- run-checks 2015-03-27 18:35:24 +0000 | |||
3049 | +++ run-checks 2015-08-02 12:28:18 +0000 | |||
3050 | @@ -13,7 +13,7 @@ | |||
3051 | 13 | 13 | ||
3052 | 14 | if [ -n "$fmt" ]; then | 14 | if [ -n "$fmt" ]; then |
3053 | 15 | echo "Formatting wrong in following files" | 15 | echo "Formatting wrong in following files" |
3055 | 16 | echo $fmt | 16 | echo "$fmt" |
3056 | 17 | exit 1 | 17 | exit 1 |
3057 | 18 | fi | 18 | fi |
3058 | 19 | 19 | ||
3059 | @@ -42,14 +42,30 @@ | |||
3060 | 42 | # go vet | 42 | # go vet |
3061 | 43 | echo Running vet | 43 | echo Running vet |
3062 | 44 | go vet ./... | 44 | go vet ./... |
3063 | 45 | go vet ./_integration-tests/tests/... | ||
3064 | 46 | go vet ./_integration-tests/testutils/... | ||
3065 | 45 | 47 | ||
3066 | 46 | # golint | 48 | # golint |
3067 | 47 | echo Running lint | 49 | echo Running lint |
3069 | 48 | lint=$(golint ./...) | 50 | lint=$(golint ./... && golint ./_integration-tests/testutils/... && golint ./_integration-tests/tests/...) |
3070 | 49 | if [ -n "$lint" ]; then | 51 | if [ -n "$lint" ]; then |
3071 | 50 | echo "Lint complains:" | 52 | echo "Lint complains:" |
3073 | 51 | echo $lint | 53 | echo "$lint" |
3074 | 52 | exit 1 | 54 | exit 1 |
3075 | 53 | fi | 55 | fi |
3076 | 54 | 56 | ||
3077 | 57 | # integration tests | ||
3078 | 58 | echo Building the integration tests | ||
3079 | 59 | go build _integration-tests/main.go | ||
3080 | 60 | |||
3081 | 61 | # the rabbit hole | ||
3082 | 62 | echo Running the tests for the integration testutils | ||
3083 | 63 | $goctest -v -cover ./_integration-tests/testutils/... | ||
3084 | 64 | |||
3085 | 65 | # integration suite in kvm | ||
3086 | 66 | if which adt-run >/dev/null 2>&1; then | ||
3087 | 67 | echo "Running integration tests on 15.04 edge" | ||
3088 | 68 | go run _integration-tests/main.go --snappy-from-branch --release=15.04 | ||
3089 | 69 | fi | ||
3090 | 70 | |||
3091 | 55 | echo "All good, what could possibly go wrong" | 71 | echo "All good, what could possibly go wrong" |
3092 | 56 | 72 | ||
3093 | === modified file 'snappy/auth_test.go' | |||
3094 | --- snappy/auth_test.go 2015-07-06 15:35:48 +0000 | |||
3095 | +++ snappy/auth_test.go 2015-08-02 12:28:18 +0000 | |||
3096 | @@ -28,14 +28,14 @@ | |||
3097 | 28 | "launchpad.net/snappy/helpers" | 28 | "launchpad.net/snappy/helpers" |
3098 | 29 | "launchpad.net/snappy/oauth" | 29 | "launchpad.net/snappy/oauth" |
3099 | 30 | 30 | ||
3101 | 31 | . "launchpad.net/gocheck" | 31 | . "gopkg.in/check.v1" |
3102 | 32 | ) | 32 | ) |
3103 | 33 | 33 | ||
3104 | 34 | const mockStoreInvalidLoginCode = 401 | 34 | const mockStoreInvalidLoginCode = 401 |
3105 | 35 | const mockStoreInvalidLogin = ` | 35 | const mockStoreInvalidLogin = ` |
3106 | 36 | { | 36 | { |
3109 | 37 | "message": "Provided email/password is not correct.", | 37 | "message": "Provided email/password is not correct.", |
3110 | 38 | "code": "INVALID_CREDENTIALS", | 38 | "code": "INVALID_CREDENTIALS", |
3111 | 39 | "extra": {} | 39 | "extra": {} |
3112 | 40 | } | 40 | } |
3113 | 41 | ` | 41 | ` |
3114 | @@ -43,22 +43,22 @@ | |||
3115 | 43 | const mockStoreNeeds2faHTTPCode = 401 | 43 | const mockStoreNeeds2faHTTPCode = 401 |
3116 | 44 | const mockStoreNeeds2fa = ` | 44 | const mockStoreNeeds2fa = ` |
3117 | 45 | { | 45 | { |
3120 | 46 | "message": "2-factor authentication required.", | 46 | "message": "2-factor authentication required.", |
3121 | 47 | "code": "TWOFACTOR_REQUIRED", | 47 | "code": "TWOFACTOR_REQUIRED", |
3122 | 48 | "extra": {} | 48 | "extra": {} |
3123 | 49 | } | 49 | } |
3124 | 50 | ` | 50 | ` |
3125 | 51 | 51 | ||
3126 | 52 | const mockStoreReturnToken = ` | 52 | const mockStoreReturnToken = ` |
3127 | 53 | { | 53 | { |
3136 | 54 | "openid": "the-open-id-string-that-is-also-the-consumer-key-in-our-store", | 54 | "openid": "the-open-id-string-that-is-also-the-consumer-key-in-our-store", |
3137 | 55 | "token_name": "some-token-name", | 55 | "token_name": "some-token-name", |
3138 | 56 | "date_updated": "2015-02-27T15:00:55.062", | 56 | "date_updated": "2015-02-27T15:00:55.062", |
3139 | 57 | "token_key": "the-token-key", | 57 | "token_key": "the-token-key", |
3140 | 58 | "consumer_secret": "the-consumer-secret", | 58 | "consumer_secret": "the-consumer-secret", |
3141 | 59 | "href": "/api/v2/tokens/oauth/something", | 59 | "href": "/api/v2/tokens/oauth/something", |
3142 | 60 | "date_created": "2015-02-27T14:54:30.863", | 60 | "date_created": "2015-02-27T14:54:30.863", |
3143 | 61 | "consumer_key": "the-consumer-key", | 61 | "consumer_key": "the-consumer-key", |
3144 | 62 | "token_secret": "the-token-secret" | 62 | "token_secret": "the-token-secret" |
3145 | 63 | } | 63 | } |
3146 | 64 | ` | 64 | ` |
3147 | 65 | 65 | ||
3148 | === modified file 'snappy/build_test.go' | |||
3149 | --- snappy/build_test.go 2015-05-07 08:28:03 +0000 | |||
3150 | +++ snappy/build_test.go 2015-08-02 12:28:18 +0000 | |||
3151 | @@ -24,7 +24,7 @@ | |||
3152 | 24 | "path/filepath" | 24 | "path/filepath" |
3153 | 25 | "strings" | 25 | "strings" |
3154 | 26 | 26 | ||
3156 | 27 | . "launchpad.net/gocheck" | 27 | . "gopkg.in/check.v1" |
3157 | 28 | ) | 28 | ) |
3158 | 29 | 29 | ||
3159 | 30 | func makeFakeDuCommand(c *C) string { | 30 | func makeFakeDuCommand(c *C) string { |
3160 | 31 | 31 | ||
3161 | === modified file 'snappy/click_test.go' | |||
3162 | --- snappy/click_test.go 2015-07-06 15:33:44 +0000 | |||
3163 | +++ snappy/click_test.go 2015-08-02 12:28:18 +0000 | |||
3164 | @@ -28,7 +28,7 @@ | |||
3165 | 28 | "strings" | 28 | "strings" |
3166 | 29 | 29 | ||
3167 | 30 | "github.com/mvo5/goconfigparser" | 30 | "github.com/mvo5/goconfigparser" |
3169 | 31 | . "launchpad.net/gocheck" | 31 | . "gopkg.in/check.v1" |
3170 | 32 | 32 | ||
3171 | 33 | "launchpad.net/snappy/clickdeb" | 33 | "launchpad.net/snappy/clickdeb" |
3172 | 34 | "launchpad.net/snappy/helpers" | 34 | "launchpad.net/snappy/helpers" |
3173 | @@ -1118,7 +1118,7 @@ | |||
3174 | 1118 | bins := []string{"hello", "goodbye", "missya"} | 1118 | bins := []string{"hello", "goodbye", "missya"} |
3175 | 1119 | for i := range verbs { | 1119 | for i := range verbs { |
3176 | 1120 | expected := fmt.Sprintf("Exec%s=/usr/bin/ubuntu-core-launcher hello-app.%s %s_svc1_1.10 %s/bin/%s", verbs[i], testNamespace, helloAppComposedName, baseDirWithoutRootPrefix, bins[i]) | 1120 | expected := fmt.Sprintf("Exec%s=/usr/bin/ubuntu-core-launcher hello-app.%s %s_svc1_1.10 %s/bin/%s", verbs[i], testNamespace, helloAppComposedName, baseDirWithoutRootPrefix, bins[i]) |
3178 | 1121 | c.Check(string(content), Matches, "(?ms).*^"+regexp.QuoteMeta(expected)) // gocheck adds ^ and $ around the regexp provided | 1121 | c.Check(string(content), Matches, "(?ms).*^"+regexp.QuoteMeta(expected)) // check.v1 adds ^ and $ around the regexp provided |
3179 | 1122 | } | 1122 | } |
3180 | 1123 | } | 1123 | } |
3181 | 1124 | 1124 | ||
3182 | 1125 | 1125 | ||
3183 | === modified file 'snappy/common_test.go' | |||
3184 | --- snappy/common_test.go 2015-04-30 16:56:15 +0000 | |||
3185 | +++ snappy/common_test.go 2015-08-02 12:28:18 +0000 | |||
3186 | @@ -26,9 +26,10 @@ | |||
3187 | 26 | 26 | ||
3188 | 27 | "launchpad.net/snappy/helpers" | 27 | "launchpad.net/snappy/helpers" |
3189 | 28 | 28 | ||
3190 | 29 | "strings" | ||
3191 | 30 | |||
3192 | 31 | . "gopkg.in/check.v1" | ||
3193 | 29 | "gopkg.in/yaml.v2" | 32 | "gopkg.in/yaml.v2" |
3194 | 30 | . "launchpad.net/gocheck" | ||
3195 | 31 | "strings" | ||
3196 | 32 | ) | 33 | ) |
3197 | 33 | 34 | ||
3198 | 34 | const ( | 35 | const ( |
3199 | 35 | 36 | ||
3200 | === modified file 'snappy/config_test.go' | |||
3201 | --- snappy/config_test.go 2015-04-17 20:32:02 +0000 | |||
3202 | +++ snappy/config_test.go 2015-08-02 12:28:18 +0000 | |||
3203 | @@ -23,7 +23,7 @@ | |||
3204 | 23 | "os" | 23 | "os" |
3205 | 24 | "path/filepath" | 24 | "path/filepath" |
3206 | 25 | 25 | ||
3208 | 26 | . "launchpad.net/gocheck" | 26 | . "gopkg.in/check.v1" |
3209 | 27 | ) | 27 | ) |
3210 | 28 | 28 | ||
3211 | 29 | const configPassthroughScript = `#!/bin/sh | 29 | const configPassthroughScript = `#!/bin/sh |
3212 | 30 | 30 | ||
3213 | === modified file 'snappy/datadir_test.go' | |||
3214 | --- snappy/datadir_test.go 2015-04-20 13:01:02 +0000 | |||
3215 | +++ snappy/datadir_test.go 2015-08-02 12:28:18 +0000 | |||
3216 | @@ -22,7 +22,7 @@ | |||
3217 | 22 | "path/filepath" | 22 | "path/filepath" |
3218 | 23 | "strings" | 23 | "strings" |
3219 | 24 | 24 | ||
3221 | 25 | . "launchpad.net/gocheck" | 25 | . "gopkg.in/check.v1" |
3222 | 26 | ) | 26 | ) |
3223 | 27 | 27 | ||
3224 | 28 | type DataDirSuite struct{} | 28 | type DataDirSuite struct{} |
3225 | 29 | 29 | ||
3226 | === modified file 'snappy/dbus_test.go' | |||
3227 | --- snappy/dbus_test.go 2015-04-19 01:24:03 +0000 | |||
3228 | +++ snappy/dbus_test.go 2015-08-02 12:28:18 +0000 | |||
3229 | @@ -1,7 +1,7 @@ | |||
3230 | 1 | package snappy | 1 | package snappy |
3231 | 2 | 2 | ||
3232 | 3 | import ( | 3 | import ( |
3234 | 4 | . "launchpad.net/gocheck" | 4 | . "gopkg.in/check.v1" |
3235 | 5 | ) | 5 | ) |
3236 | 6 | 6 | ||
3237 | 7 | // systemd's testsuite | 7 | // systemd's testsuite |
3238 | 8 | 8 | ||
3239 | === modified file 'snappy/firstboot_test.go' | |||
3240 | --- snappy/firstboot_test.go 2015-04-14 16:46:57 +0000 | |||
3241 | +++ snappy/firstboot_test.go 2015-08-02 12:28:18 +0000 | |||
3242 | @@ -22,7 +22,7 @@ | |||
3243 | 22 | "os" | 22 | "os" |
3244 | 23 | "path/filepath" | 23 | "path/filepath" |
3245 | 24 | 24 | ||
3247 | 25 | . "launchpad.net/gocheck" | 25 | . "gopkg.in/check.v1" |
3248 | 26 | ) | 26 | ) |
3249 | 27 | 27 | ||
3250 | 28 | type fakePart struct { | 28 | type fakePart struct { |
3251 | 29 | 29 | ||
3252 | === modified file 'snappy/hashes_test.go' | |||
3253 | --- snappy/hashes_test.go 2015-03-31 14:12:52 +0000 | |||
3254 | +++ snappy/hashes_test.go 2015-08-02 12:28:18 +0000 | |||
3255 | @@ -24,7 +24,7 @@ | |||
3256 | 24 | 24 | ||
3257 | 25 | "gopkg.in/yaml.v2" | 25 | "gopkg.in/yaml.v2" |
3258 | 26 | 26 | ||
3260 | 27 | . "launchpad.net/gocheck" | 27 | . "gopkg.in/check.v1" |
3261 | 28 | ) | 28 | ) |
3262 | 29 | 29 | ||
3263 | 30 | var fileHashYaml = `name: foo | 30 | var fileHashYaml = `name: foo |
3264 | 31 | 31 | ||
3265 | === modified file 'snappy/hwaccess_test.go' | |||
3266 | --- snappy/hwaccess_test.go 2015-05-01 12:32:42 +0000 | |||
3267 | +++ snappy/hwaccess_test.go 2015-08-02 12:28:18 +0000 | |||
3268 | @@ -23,7 +23,7 @@ | |||
3269 | 23 | 23 | ||
3270 | 24 | "launchpad.net/snappy/helpers" | 24 | "launchpad.net/snappy/helpers" |
3271 | 25 | 25 | ||
3273 | 26 | . "launchpad.net/gocheck" | 26 | . "gopkg.in/check.v1" |
3274 | 27 | ) | 27 | ) |
3275 | 28 | 28 | ||
3276 | 29 | func mockRegenerateAppArmorRules() *bool { | 29 | func mockRegenerateAppArmorRules() *bool { |
3277 | 30 | 30 | ||
3278 | === modified file 'snappy/install_test.go' | |||
3279 | --- snappy/install_test.go 2015-04-17 20:54:23 +0000 | |||
3280 | +++ snappy/install_test.go 2015-08-02 12:28:18 +0000 | |||
3281 | @@ -26,7 +26,7 @@ | |||
3282 | 26 | "os" | 26 | "os" |
3283 | 27 | "path/filepath" | 27 | "path/filepath" |
3284 | 28 | 28 | ||
3286 | 29 | . "launchpad.net/gocheck" | 29 | . "gopkg.in/check.v1" |
3287 | 30 | "launchpad.net/snappy/helpers" | 30 | "launchpad.net/snappy/helpers" |
3288 | 31 | "launchpad.net/snappy/progress" | 31 | "launchpad.net/snappy/progress" |
3289 | 32 | ) | 32 | ) |
3290 | 33 | 33 | ||
3291 | === modified file 'snappy/oem_test.go' | |||
3292 | --- snappy/oem_test.go 2015-04-22 12:55:07 +0000 | |||
3293 | +++ snappy/oem_test.go 2015-08-02 12:28:18 +0000 | |||
3294 | @@ -26,7 +26,7 @@ | |||
3295 | 26 | 26 | ||
3296 | 27 | "launchpad.net/snappy/helpers" | 27 | "launchpad.net/snappy/helpers" |
3297 | 28 | 28 | ||
3299 | 29 | . "launchpad.net/gocheck" | 29 | . "gopkg.in/check.v1" |
3300 | 30 | ) | 30 | ) |
3301 | 31 | 31 | ||
3302 | 32 | type OemSuite struct { | 32 | type OemSuite struct { |
3303 | 33 | 33 | ||
3304 | === modified file 'snappy/parts_test.go' | |||
3305 | --- snappy/parts_test.go 2015-04-21 12:05:22 +0000 | |||
3306 | +++ snappy/parts_test.go 2015-08-02 12:28:18 +0000 | |||
3307 | @@ -22,7 +22,7 @@ | |||
3308 | 22 | "os" | 22 | "os" |
3309 | 23 | "path/filepath" | 23 | "path/filepath" |
3310 | 24 | 24 | ||
3312 | 25 | . "launchpad.net/gocheck" | 25 | . "gopkg.in/check.v1" |
3313 | 26 | 26 | ||
3314 | 27 | "launchpad.net/snappy/progress" | 27 | "launchpad.net/snappy/progress" |
3315 | 28 | ) | 28 | ) |
3316 | 29 | 29 | ||
3317 | === modified file 'snappy/purge_test.go' | |||
3318 | --- snappy/purge_test.go 2015-04-20 19:26:04 +0000 | |||
3319 | +++ snappy/purge_test.go 2015-08-02 12:28:18 +0000 | |||
3320 | @@ -23,7 +23,7 @@ | |||
3321 | 23 | "os" | 23 | "os" |
3322 | 24 | "path/filepath" | 24 | "path/filepath" |
3323 | 25 | 25 | ||
3325 | 26 | . "launchpad.net/gocheck" | 26 | . "gopkg.in/check.v1" |
3326 | 27 | 27 | ||
3327 | 28 | "launchpad.net/snappy/helpers" | 28 | "launchpad.net/snappy/helpers" |
3328 | 29 | "launchpad.net/snappy/systemd" | 29 | "launchpad.net/snappy/systemd" |
3329 | 30 | 30 | ||
3330 | === modified file 'snappy/remove_test.go' | |||
3331 | --- snappy/remove_test.go 2015-04-15 13:17:22 +0000 | |||
3332 | +++ snappy/remove_test.go 2015-08-02 12:28:18 +0000 | |||
3333 | @@ -18,7 +18,7 @@ | |||
3334 | 18 | package snappy | 18 | package snappy |
3335 | 19 | 19 | ||
3336 | 20 | import ( | 20 | import ( |
3338 | 21 | . "launchpad.net/gocheck" | 21 | . "gopkg.in/check.v1" |
3339 | 22 | "launchpad.net/snappy/progress" | 22 | "launchpad.net/snappy/progress" |
3340 | 23 | ) | 23 | ) |
3341 | 24 | 24 | ||
3342 | 25 | 25 | ||
3343 | === modified file 'snappy/rollback_test.go' | |||
3344 | --- snappy/rollback_test.go 2015-04-30 16:56:15 +0000 | |||
3345 | +++ snappy/rollback_test.go 2015-08-02 12:28:18 +0000 | |||
3346 | @@ -18,7 +18,7 @@ | |||
3347 | 18 | package snappy | 18 | package snappy |
3348 | 19 | 19 | ||
3349 | 20 | import ( | 20 | import ( |
3351 | 21 | . "launchpad.net/gocheck" | 21 | . "gopkg.in/check.v1" |
3352 | 22 | ) | 22 | ) |
3353 | 23 | 23 | ||
3354 | 24 | func (s *SnapTestSuite) TestRollbackWithVersion(c *C) { | 24 | func (s *SnapTestSuite) TestRollbackWithVersion(c *C) { |
3355 | 25 | 25 | ||
3356 | === modified file 'snappy/security_test.go' | |||
3357 | --- snappy/security_test.go 2015-07-06 19:56:46 +0000 | |||
3358 | +++ snappy/security_test.go 2015-08-02 12:28:18 +0000 | |||
3359 | @@ -5,7 +5,7 @@ | |||
3360 | 5 | "os" | 5 | "os" |
3361 | 6 | "path/filepath" | 6 | "path/filepath" |
3362 | 7 | 7 | ||
3364 | 8 | . "launchpad.net/gocheck" | 8 | . "gopkg.in/check.v1" |
3365 | 9 | ) | 9 | ) |
3366 | 10 | 10 | ||
3367 | 11 | type SecurityTestSuite struct { | 11 | type SecurityTestSuite struct { |
3368 | 12 | 12 | ||
3369 | === modified file 'snappy/set_test.go' | |||
3370 | --- snappy/set_test.go 2015-04-30 16:56:15 +0000 | |||
3371 | +++ snappy/set_test.go 2015-08-02 12:28:18 +0000 | |||
3372 | @@ -22,7 +22,7 @@ | |||
3373 | 22 | "path/filepath" | 22 | "path/filepath" |
3374 | 23 | "strings" | 23 | "strings" |
3375 | 24 | 24 | ||
3377 | 25 | . "launchpad.net/gocheck" | 25 | . "gopkg.in/check.v1" |
3378 | 26 | 26 | ||
3379 | 27 | "launchpad.net/snappy/progress" | 27 | "launchpad.net/snappy/progress" |
3380 | 28 | ) | 28 | ) |
3381 | 29 | 29 | ||
3382 | === modified file 'snappy/snapp_test.go' | |||
3383 | --- snappy/snapp_test.go 2015-07-07 02:35:22 +0000 | |||
3384 | +++ snappy/snapp_test.go 2015-08-02 12:28:18 +0000 | |||
3385 | @@ -34,7 +34,7 @@ | |||
3386 | 34 | "launchpad.net/snappy/release" | 34 | "launchpad.net/snappy/release" |
3387 | 35 | "launchpad.net/snappy/systemd" | 35 | "launchpad.net/snappy/systemd" |
3388 | 36 | 36 | ||
3390 | 37 | . "launchpad.net/gocheck" | 37 | . "gopkg.in/check.v1" |
3391 | 38 | ) | 38 | ) |
3392 | 39 | 39 | ||
3393 | 40 | type SnapTestSuite struct { | 40 | type SnapTestSuite struct { |
3394 | 41 | 41 | ||
3395 | === modified file 'snappy/sort_test.go' | |||
3396 | --- snappy/sort_test.go 2015-03-26 09:12:58 +0000 | |||
3397 | +++ snappy/sort_test.go 2015-08-02 12:28:18 +0000 | |||
3398 | @@ -20,7 +20,7 @@ | |||
3399 | 20 | import ( | 20 | import ( |
3400 | 21 | "sort" | 21 | "sort" |
3401 | 22 | 22 | ||
3403 | 23 | . "launchpad.net/gocheck" | 23 | . "gopkg.in/check.v1" |
3404 | 24 | ) | 24 | ) |
3405 | 25 | 25 | ||
3406 | 26 | type SortTestSuite struct { | 26 | type SortTestSuite struct { |
3407 | 27 | 27 | ||
3408 | === modified file 'snappy/systemimage_native_test.go' | |||
3409 | --- snappy/systemimage_native_test.go 2015-03-26 09:12:58 +0000 | |||
3410 | +++ snappy/systemimage_native_test.go 2015-08-02 12:28:18 +0000 | |||
3411 | @@ -25,7 +25,7 @@ | |||
3412 | 25 | "path/filepath" | 25 | "path/filepath" |
3413 | 26 | "time" | 26 | "time" |
3414 | 27 | 27 | ||
3416 | 28 | . "launchpad.net/gocheck" | 28 | . "gopkg.in/check.v1" |
3417 | 29 | ) | 29 | ) |
3418 | 30 | 30 | ||
3419 | 31 | /* acquired via: | 31 | /* acquired via: |
3420 | 32 | 32 | ||
3421 | === modified file 'snappy/systemimage_test.go' | |||
3422 | --- snappy/systemimage_test.go 2015-07-15 07:37:44 +0000 | |||
3423 | +++ snappy/systemimage_test.go 2015-08-02 12:28:18 +0000 | |||
3424 | @@ -28,10 +28,10 @@ | |||
3425 | 28 | 28 | ||
3426 | 29 | partition "launchpad.net/snappy/partition" | 29 | partition "launchpad.net/snappy/partition" |
3427 | 30 | 30 | ||
3429 | 31 | . "launchpad.net/gocheck" | 31 | . "gopkg.in/check.v1" |
3430 | 32 | ) | 32 | ) |
3431 | 33 | 33 | ||
3433 | 34 | // Hook up gocheck into the "go test" runner | 34 | // Hook up check.v1 into the "go test" runner |
3434 | 35 | func Test(t *testing.T) { TestingT(t) } | 35 | func Test(t *testing.T) { TestingT(t) } |
3435 | 36 | 36 | ||
3436 | 37 | type SITestSuite struct { | 37 | type SITestSuite struct { |
3437 | 38 | 38 | ||
3438 | === modified file 'snappy/timeout_test.go' | |||
3439 | --- snappy/timeout_test.go 2015-04-13 22:20:58 +0000 | |||
3440 | +++ snappy/timeout_test.go 2015-08-02 12:28:18 +0000 | |||
3441 | @@ -21,7 +21,7 @@ | |||
3442 | 21 | "encoding/json" | 21 | "encoding/json" |
3443 | 22 | "time" | 22 | "time" |
3444 | 23 | 23 | ||
3446 | 24 | . "launchpad.net/gocheck" | 24 | . "gopkg.in/check.v1" |
3447 | 25 | ) | 25 | ) |
3448 | 26 | 26 | ||
3449 | 27 | func (s *SnapTestSuite) TestTimeoutMarshal(c *C) { | 27 | func (s *SnapTestSuite) TestTimeoutMarshal(c *C) { |
3450 | 28 | 28 | ||
3451 | === modified file 'snappy/udev_test.go' | |||
3452 | --- snappy/udev_test.go 2015-04-20 12:50:45 +0000 | |||
3453 | +++ snappy/udev_test.go 2015-08-02 12:28:18 +0000 | |||
3454 | @@ -18,7 +18,7 @@ | |||
3455 | 18 | package snappy | 18 | package snappy |
3456 | 19 | 19 | ||
3457 | 20 | import ( | 20 | import ( |
3459 | 21 | . "launchpad.net/gocheck" | 21 | . "gopkg.in/check.v1" |
3460 | 22 | ) | 22 | ) |
3461 | 23 | 23 | ||
3462 | 24 | func (s *SnapTestSuite) TestGetUdevPartName(c *C) { | 24 | func (s *SnapTestSuite) TestGetUdevPartName(c *C) { |
3463 | 25 | 25 | ||
3464 | === modified file 'systemd/systemd_test.go' | |||
3465 | --- systemd/systemd_test.go 2015-07-06 15:33:44 +0000 | |||
3466 | +++ systemd/systemd_test.go 2015-08-02 12:28:18 +0000 | |||
3467 | @@ -24,7 +24,7 @@ | |||
3468 | 24 | "testing" | 24 | "testing" |
3469 | 25 | "time" | 25 | "time" |
3470 | 26 | 26 | ||
3472 | 27 | . "launchpad.net/gocheck" | 27 | . "gopkg.in/check.v1" |
3473 | 28 | 28 | ||
3474 | 29 | "launchpad.net/snappy/helpers" | 29 | "launchpad.net/snappy/helpers" |
3475 | 30 | ) | 30 | ) |
3476 | @@ -37,7 +37,7 @@ | |||
3477 | 37 | tr.msgs = append(tr.msgs, msg) | 37 | tr.msgs = append(tr.msgs, msg) |
3478 | 38 | } | 38 | } |
3479 | 39 | 39 | ||
3481 | 40 | // Hook up gocheck into the "go test" runner | 40 | // Hook up check.v1 into the "go test" runner |
3482 | 41 | func Test(t *testing.T) { TestingT(t) } | 41 | func Test(t *testing.T) { TestingT(t) } |
3483 | 42 | 42 | ||
3484 | 43 | // systemd's testsuite | 43 | // systemd's testsuite |
Work in progress because we want to land this after the current release. But this is working, ready to be tested.