Merge lp:~elopio/snappy/one_tests_package into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by Leo Arias
Status: Merged
Approved by: Leo Arias
Approved revision: 597
Merged at revision: 598
Proposed branch: lp:~elopio/snappy/one_tests_package
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Diff against target: 440 lines (+56/-66)
18 files modified
_integration-tests/data/tpl/control (+2/-3)
_integration-tests/main.go (+22/-28)
_integration-tests/tests/apt_test.go (+2/-2)
_integration-tests/tests/base_test.go (+1/-1)
_integration-tests/tests/build_test.go (+2/-2)
_integration-tests/tests/failover_rclocal_crash_test.go (+2/-2)
_integration-tests/tests/failover_systemd_loop_test.go (+2/-2)
_integration-tests/tests/failover_test.go (+2/-7)
_integration-tests/tests/failover_zero_size_file_test.go (+2/-2)
_integration-tests/tests/info_test.go (+2/-2)
_integration-tests/tests/installApp_test.go (+2/-2)
_integration-tests/tests/installFramework_test.go (+2/-2)
_integration-tests/tests/list_test.go (+2/-2)
_integration-tests/tests/rollback_test.go (+3/-2)
_integration-tests/tests/search_test.go (+2/-2)
_integration-tests/tests/update_test.go (+3/-2)
_integration-tests/tests/writablePaths_test.go (+2/-2)
run-checks (+1/-1)
To merge this branch: bzr merge lp:~elopio/snappy/one_tests_package
Reviewer Review Type Date Requested Status
Federico Gimenez (community) Approve
Review via email: mp+265570@code.launchpad.net

Commit message

Refactored the integration tests: moved them all to the tests package.

To post a comment you must log in.
Revision history for this message
Federico Gimenez (fgimenez) wrote :

Nice Leo, we needed the proper import paths too. And now is more straightforward to use functionality from the common package in the rest of them.

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed directory '_integration-tests/tests/common' => '_integration-tests/common'
2=== modified file '_integration-tests/data/tpl/control'
3--- _integration-tests/data/tpl/control 2015-07-17 15:43:11 +0000
4+++ _integration-tests/data/tpl/control 2015-07-22 16:37:35 +0000
5@@ -1,5 +1,4 @@
6 {{ $filter := .Filter }}
7-{{ range $element := .Tests }}
8-Test-Command: ./_integration-tests/reboot-wrapper {{ $element }}.test {{ if $filter }}-gocheck.f {{ $filter }}{{ end }}
9+{{ $test := .Test }}
10+Test-Command: ./_integration-tests/reboot-wrapper {{ $test }} {{ if $filter }}-gocheck.f {{ $filter }}{{ end }}
11 Restrictions: allow-stderr
12-{{ end }}
13
14=== modified file '_integration-tests/main.go'
15--- _integration-tests/main.go 2015-07-22 15:12:24 +0000
16+++ _integration-tests/main.go 2015-07-22 16:37:35 +0000
17@@ -26,7 +26,6 @@
18 "os"
19 "path/filepath"
20 "strconv"
21- "strings"
22 "text/template"
23
24 config "./config"
25@@ -35,21 +34,21 @@
26 )
27
28 const (
29- baseDir = "/tmp/snappy-test"
30- testsBinDir = "_integration-tests/bin/"
31- defaultRelease = "rolling"
32- defaultChannel = "edge"
33- defaultSSHPort = 22
34- defaultGoArm = "7"
35- dataOutputDir = "_integration-tests/data/output/"
36- controlTpl = "_integration-tests/data/tpl/control"
37+ baseDir = "/tmp/snappy-test"
38+ testsBinDir = "_integration-tests/bin/"
39+ defaultRelease = "rolling"
40+ defaultChannel = "edge"
41+ defaultSSHPort = 22
42+ defaultGoArm = "7"
43+ dataOutputDir = "_integration-tests/data/output/"
44+ controlTpl = "_integration-tests/data/tpl/control"
45+ integrationTestName = "integration.test"
46 )
47
48 var (
49 commonSSHOptions = []string{"---", "ssh"}
50 configFileName = filepath.Join(dataOutputDir, "testconfig.json")
51 controlFile = filepath.Join(dataOutputDir, "control")
52- testPackages = []string{"cmd", "failover"}
53 )
54
55 func buildAssets(useSnappyFromBranch bool, arch string) {
56@@ -66,16 +65,14 @@
57 func setupAndRunLocalTests(rootPath, testFilter string, img image.Image) {
58 // Run the tests on the latest rolling edge image.
59 if imageName, err := img.UdfCreate(); err == nil {
60- adtRun(rootPath, testFilter, testPackages,
61- kvmSSHOptions(imageName))
62+ adtRun(rootPath, testFilter, kvmSSHOptions(imageName))
63 }
64 }
65
66 func setupAndRunRemoteTests(rootPath, testFilter, testbedIP string, testbedPort int) {
67 utils.ExecCommand("ssh-copy-id", "-p", strconv.Itoa(testbedPort),
68 "ubuntu@"+testbedIP)
69- adtRun(rootPath, testFilter, testPackages,
70- remoteTestbedSSHOptions(testbedIP, testbedPort))
71+ adtRun(rootPath, testFilter, remoteTestbedSSHOptions(testbedIP, testbedPort))
72 }
73
74 func buildSnappyCLI(arch string) {
75@@ -88,13 +85,10 @@
76 func buildTests(arch string) {
77 fmt.Println("Building tests...")
78
79- for _, testName := range testPackages {
80- goCall(arch, "test", "-c",
81- "./_integration-tests/tests/"+testName)
82- // XXX Go test 1.3 does not have the output flag, so we move the
83- // binaries after they are generated.
84- os.Rename(testName+".test", testsBinDir+testName+".test")
85- }
86+ goCall(arch, "test", "-c", "./_integration-tests/tests")
87+ // XXX Go test 1.3 does not have the output flag, so we move the
88+ // binaries after they are generated.
89+ os.Rename("tests.test", testsBinDir+integrationTestName)
90 }
91
92 func goCall(arch string, cmds ...string) {
93@@ -110,12 +104,11 @@
94 utils.ExecCommand(goCmd...)
95 }
96
97-func adtRun(rootPath, testFilter string, testList, testbedOptions []string) {
98- createControlFile(testFilter, testList)
99+func adtRun(rootPath, testFilter string, testbedOptions []string) {
100+ createControlFile(testFilter)
101
102 fmt.Println("Calling adt-run...")
103- outputSubdir := strings.Join(testList, "-")
104- outputDir := filepath.Join(baseDir, "output", outputSubdir)
105+ outputDir := filepath.Join(baseDir, "output")
106 utils.PrepareTargetDir(outputDir)
107
108 cmd := []string{
109@@ -136,10 +129,10 @@
110 "--", "-i", imagePath}...)
111 }
112
113-func createControlFile(testFilter string, testList []string) {
114+func createControlFile(testFilter string) {
115 type controlData struct {
116 Filter string
117- Tests []string
118+ Test string
119 }
120
121 tpl, err := template.ParseFiles(controlTpl)
122@@ -153,7 +146,8 @@
123 }
124 defer outputFile.Close()
125
126- err = tpl.Execute(outputFile, controlData{Filter: testFilter, Tests: testList})
127+ err = tpl.Execute(outputFile,
128+ controlData{Test: integrationTestName, Filter: testFilter})
129 if err != nil {
130 log.Fatalf("execution: %s", err)
131 }
132
133=== renamed file '_integration-tests/tests/cmd/apt_test.go' => '_integration-tests/tests/apt_test.go'
134--- _integration-tests/tests/cmd/apt_test.go 2015-07-21 00:41:05 +0000
135+++ _integration-tests/tests/apt_test.go 2015-07-22 16:37:35 +0000
136@@ -17,10 +17,10 @@
137 *
138 */
139
140-package cmd
141+package tests
142
143 import (
144- . "../common"
145+ . "launchpad.net/snappy/_integration-tests/common"
146
147 check "gopkg.in/check.v1"
148 )
149
150=== renamed file '_integration-tests/tests/cmd/base_test.go' => '_integration-tests/tests/base_test.go'
151--- _integration-tests/tests/cmd/base_test.go 2015-07-17 00:57:32 +0000
152+++ _integration-tests/tests/base_test.go 2015-07-22 16:37:35 +0000
153@@ -17,7 +17,7 @@
154 *
155 */
156
157-package cmd
158+package tests
159
160 import (
161 "testing"
162
163=== renamed file '_integration-tests/tests/cmd/build_test.go' => '_integration-tests/tests/build_test.go'
164--- _integration-tests/tests/cmd/build_test.go 2015-07-17 00:57:32 +0000
165+++ _integration-tests/tests/build_test.go 2015-07-22 16:37:35 +0000
166@@ -17,14 +17,14 @@
167 *
168 */
169
170-package cmd
171+package tests
172
173 import (
174 "fmt"
175 "os"
176 "os/exec"
177
178- . "../common"
179+ . "launchpad.net/snappy/_integration-tests/common"
180
181 . "gopkg.in/check.v1"
182 )
183
184=== removed directory '_integration-tests/tests/cmd'
185=== removed directory '_integration-tests/tests/failover'
186=== renamed file '_integration-tests/tests/failover/failover_rclocal_crash_test.go' => '_integration-tests/tests/failover_rclocal_crash_test.go'
187--- _integration-tests/tests/failover/failover_rclocal_crash_test.go 2015-07-06 19:01:48 +0000
188+++ _integration-tests/tests/failover_rclocal_crash_test.go 2015-07-22 16:37:35 +0000
189@@ -17,12 +17,12 @@
190 *
191 */
192
193-package failover
194+package tests
195
196 import (
197 "fmt"
198
199- . "../common"
200+ . "launchpad.net/snappy/_integration-tests/common"
201
202 check "gopkg.in/check.v1"
203 )
204
205=== renamed file '_integration-tests/tests/failover/failover_systemd_loop_test.go' => '_integration-tests/tests/failover_systemd_loop_test.go'
206--- _integration-tests/tests/failover/failover_systemd_loop_test.go 2015-07-06 19:01:48 +0000
207+++ _integration-tests/tests/failover_systemd_loop_test.go 2015-07-22 16:37:35 +0000
208@@ -17,12 +17,12 @@
209 *
210 */
211
212-package failover
213+package tests
214
215 import (
216 "fmt"
217
218- . "../common"
219+ . "launchpad.net/snappy/_integration-tests/common"
220
221 check "gopkg.in/check.v1"
222 )
223
224=== renamed file '_integration-tests/tests/failover/failover_test.go' => '_integration-tests/tests/failover_test.go'
225--- _integration-tests/tests/failover/failover_test.go 2015-07-16 00:30:07 +0000
226+++ _integration-tests/tests/failover_test.go 2015-07-22 16:37:35 +0000
227@@ -17,19 +17,14 @@
228 *
229 */
230
231-package failover
232+package tests
233
234 import (
235- "testing"
236-
237 check "gopkg.in/check.v1"
238
239- . "../common"
240+ . "launchpad.net/snappy/_integration-tests/common"
241 )
242
243-// Hook up gocheck into the "go test" runner.
244-func Test(t *testing.T) { check.TestingT(t) }
245-
246 var _ = check.Suite(&failoverSuite{})
247
248 type failoverSuite struct {
249
250=== renamed file '_integration-tests/tests/failover/failover_zero_size_file_test.go' => '_integration-tests/tests/failover_zero_size_file_test.go'
251--- _integration-tests/tests/failover/failover_zero_size_file_test.go 2015-07-06 19:01:48 +0000
252+++ _integration-tests/tests/failover_zero_size_file_test.go 2015-07-22 16:37:35 +0000
253@@ -17,7 +17,7 @@
254 *
255 */
256
257-package failover
258+package tests
259
260 import (
261 "fmt"
262@@ -25,7 +25,7 @@
263 "path/filepath"
264 "strings"
265
266- . "../common"
267+ . "launchpad.net/snappy/_integration-tests/common"
268
269 check "gopkg.in/check.v1"
270 )
271
272=== renamed file '_integration-tests/tests/cmd/info_test.go' => '_integration-tests/tests/info_test.go'
273--- _integration-tests/tests/cmd/info_test.go 2015-07-17 00:57:32 +0000
274+++ _integration-tests/tests/info_test.go 2015-07-22 16:37:35 +0000
275@@ -17,12 +17,12 @@
276 *
277 */
278
279-package cmd
280+package tests
281
282 import (
283 "fmt"
284
285- . "../common"
286+ . "launchpad.net/snappy/_integration-tests/common"
287
288 check "gopkg.in/check.v1"
289 )
290
291=== renamed file '_integration-tests/tests/cmd/installApp_test.go' => '_integration-tests/tests/installApp_test.go'
292--- _integration-tests/tests/cmd/installApp_test.go 2015-07-17 00:57:32 +0000
293+++ _integration-tests/tests/installApp_test.go 2015-07-22 16:37:35 +0000
294@@ -17,14 +17,14 @@
295 *
296 */
297
298-package cmd
299+package tests
300
301 import (
302 "net/http"
303 "os/exec"
304 "time"
305
306- . "../common"
307+ . "launchpad.net/snappy/_integration-tests/common"
308
309 check "gopkg.in/check.v1"
310 )
311
312=== renamed file '_integration-tests/tests/cmd/installFramework_test.go' => '_integration-tests/tests/installFramework_test.go'
313--- _integration-tests/tests/cmd/installFramework_test.go 2015-07-17 00:57:32 +0000
314+++ _integration-tests/tests/installFramework_test.go 2015-07-22 16:37:35 +0000
315@@ -17,13 +17,13 @@
316 *
317 */
318
319-package cmd
320+package tests
321
322 import (
323 "fmt"
324 "regexp"
325
326- . "../common"
327+ . "launchpad.net/snappy/_integration-tests/common"
328
329 check "gopkg.in/check.v1"
330 )
331
332=== renamed file '_integration-tests/tests/cmd/list_test.go' => '_integration-tests/tests/list_test.go'
333--- _integration-tests/tests/cmd/list_test.go 2015-07-21 00:40:00 +0000
334+++ _integration-tests/tests/list_test.go 2015-07-22 16:37:35 +0000
335@@ -17,13 +17,13 @@
336 *
337 */
338
339-package cmd
340+package tests
341
342 import (
343 "fmt"
344 "os"
345
346- . "../common"
347+ . "launchpad.net/snappy/_integration-tests/common"
348
349 "github.com/mvo5/goconfigparser"
350 check "gopkg.in/check.v1"
351
352=== renamed file '_integration-tests/tests/cmd/rollback_test.go' => '_integration-tests/tests/rollback_test.go'
353--- _integration-tests/tests/cmd/rollback_test.go 2015-07-21 00:41:05 +0000
354+++ _integration-tests/tests/rollback_test.go 2015-07-22 16:37:35 +0000
355@@ -17,12 +17,13 @@
356 *
357 */
358
359-package cmd
360+package tests
361
362 import (
363 "strconv"
364
365- . "../common"
366+ . "launchpad.net/snappy/_integration-tests/common"
367+
368 check "gopkg.in/check.v1"
369 )
370
371
372=== renamed file '_integration-tests/tests/cmd/search_test.go' => '_integration-tests/tests/search_test.go'
373--- _integration-tests/tests/cmd/search_test.go 2015-07-17 00:57:32 +0000
374+++ _integration-tests/tests/search_test.go 2015-07-22 16:37:35 +0000
375@@ -17,10 +17,10 @@
376 *
377 */
378
379-package cmd
380+package tests
381
382 import (
383- . "../common"
384+ . "launchpad.net/snappy/_integration-tests/common"
385
386 . "gopkg.in/check.v1"
387 )
388
389=== renamed file '_integration-tests/tests/cmd/update_test.go' => '_integration-tests/tests/update_test.go'
390--- _integration-tests/tests/cmd/update_test.go 2015-07-17 00:57:32 +0000
391+++ _integration-tests/tests/update_test.go 2015-07-22 16:37:35 +0000
392@@ -17,10 +17,11 @@
393 *
394 */
395
396-package cmd
397+package tests
398
399 import (
400- . "../common"
401+ . "launchpad.net/snappy/_integration-tests/common"
402+
403 check "gopkg.in/check.v1"
404 )
405
406
407=== renamed file '_integration-tests/tests/cmd/writablePaths_test.go' => '_integration-tests/tests/writablePaths_test.go'
408--- _integration-tests/tests/cmd/writablePaths_test.go 2015-07-21 00:41:05 +0000
409+++ _integration-tests/tests/writablePaths_test.go 2015-07-22 16:37:35 +0000
410@@ -17,7 +17,7 @@
411 *
412 */
413
414-package cmd
415+package tests
416
417 import (
418 "bufio"
419@@ -27,7 +27,7 @@
420 "path/filepath"
421 "strings"
422
423- . "../common"
424+ . "launchpad.net/snappy/_integration-tests/common"
425
426 check "gopkg.in/check.v1"
427 )
428
429=== modified file 'run-checks'
430--- run-checks 2015-07-21 15:21:08 +0000
431+++ run-checks 2015-07-22 16:37:35 +0000
432@@ -72,7 +72,7 @@
433
434 # the rabbit hole
435 echo Running the tests for the integration helpers
436-$goctest -v -cover ./_integration-tests/tests/common/...
437+$goctest -v -cover ./_integration-tests/common/...
438
439 # integration suite in kvm
440 if which adt-run >/dev/null 2>&1; then

Subscribers

People subscribed via source and target branches