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
=== renamed directory '_integration-tests/tests/common' => '_integration-tests/common'
=== modified file '_integration-tests/data/tpl/control'
--- _integration-tests/data/tpl/control 2015-07-17 15:43:11 +0000
+++ _integration-tests/data/tpl/control 2015-07-22 16:37:35 +0000
@@ -1,5 +1,4 @@
1{{ $filter := .Filter }}1{{ $filter := .Filter }}
2{{ range $element := .Tests }}2{{ $test := .Test }}
3Test-Command: ./_integration-tests/reboot-wrapper {{ $element }}.test {{ if $filter }}-gocheck.f {{ $filter }}{{ end }}3Test-Command: ./_integration-tests/reboot-wrapper {{ $test }} {{ if $filter }}-gocheck.f {{ $filter }}{{ end }}
4Restrictions: allow-stderr4Restrictions: allow-stderr
5{{ end }}
65
=== modified file '_integration-tests/main.go'
--- _integration-tests/main.go 2015-07-22 15:12:24 +0000
+++ _integration-tests/main.go 2015-07-22 16:37:35 +0000
@@ -26,7 +26,6 @@
26 "os"26 "os"
27 "path/filepath"27 "path/filepath"
28 "strconv"28 "strconv"
29 "strings"
30 "text/template"29 "text/template"
3130
32 config "./config"31 config "./config"
@@ -35,21 +34,21 @@
35)34)
3635
37const (36const (
38 baseDir = "/tmp/snappy-test"37 baseDir = "/tmp/snappy-test"
39 testsBinDir = "_integration-tests/bin/"38 testsBinDir = "_integration-tests/bin/"
40 defaultRelease = "rolling"39 defaultRelease = "rolling"
41 defaultChannel = "edge"40 defaultChannel = "edge"
42 defaultSSHPort = 2241 defaultSSHPort = 22
43 defaultGoArm = "7"42 defaultGoArm = "7"
44 dataOutputDir = "_integration-tests/data/output/"43 dataOutputDir = "_integration-tests/data/output/"
45 controlTpl = "_integration-tests/data/tpl/control"44 controlTpl = "_integration-tests/data/tpl/control"
45 integrationTestName = "integration.test"
46)46)
4747
48var (48var (
49 commonSSHOptions = []string{"---", "ssh"}49 commonSSHOptions = []string{"---", "ssh"}
50 configFileName = filepath.Join(dataOutputDir, "testconfig.json")50 configFileName = filepath.Join(dataOutputDir, "testconfig.json")
51 controlFile = filepath.Join(dataOutputDir, "control")51 controlFile = filepath.Join(dataOutputDir, "control")
52 testPackages = []string{"cmd", "failover"}
53)52)
5453
55func buildAssets(useSnappyFromBranch bool, arch string) {54func buildAssets(useSnappyFromBranch bool, arch string) {
@@ -66,16 +65,14 @@
66func setupAndRunLocalTests(rootPath, testFilter string, img image.Image) {65func setupAndRunLocalTests(rootPath, testFilter string, img image.Image) {
67 // Run the tests on the latest rolling edge image.66 // Run the tests on the latest rolling edge image.
68 if imageName, err := img.UdfCreate(); err == nil {67 if imageName, err := img.UdfCreate(); err == nil {
69 adtRun(rootPath, testFilter, testPackages,68 adtRun(rootPath, testFilter, kvmSSHOptions(imageName))
70 kvmSSHOptions(imageName))
71 }69 }
72}70}
7371
74func setupAndRunRemoteTests(rootPath, testFilter, testbedIP string, testbedPort int) {72func setupAndRunRemoteTests(rootPath, testFilter, testbedIP string, testbedPort int) {
75 utils.ExecCommand("ssh-copy-id", "-p", strconv.Itoa(testbedPort),73 utils.ExecCommand("ssh-copy-id", "-p", strconv.Itoa(testbedPort),
76 "ubuntu@"+testbedIP)74 "ubuntu@"+testbedIP)
77 adtRun(rootPath, testFilter, testPackages,75 adtRun(rootPath, testFilter, remoteTestbedSSHOptions(testbedIP, testbedPort))
78 remoteTestbedSSHOptions(testbedIP, testbedPort))
79}76}
8077
81func buildSnappyCLI(arch string) {78func buildSnappyCLI(arch string) {
@@ -88,13 +85,10 @@
88func buildTests(arch string) {85func buildTests(arch string) {
89 fmt.Println("Building tests...")86 fmt.Println("Building tests...")
9087
91 for _, testName := range testPackages {88 goCall(arch, "test", "-c", "./_integration-tests/tests")
92 goCall(arch, "test", "-c",89 // XXX Go test 1.3 does not have the output flag, so we move the
93 "./_integration-tests/tests/"+testName)90 // binaries after they are generated.
94 // XXX Go test 1.3 does not have the output flag, so we move the91 os.Rename("tests.test", testsBinDir+integrationTestName)
95 // binaries after they are generated.
96 os.Rename(testName+".test", testsBinDir+testName+".test")
97 }
98}92}
9993
100func goCall(arch string, cmds ...string) {94func goCall(arch string, cmds ...string) {
@@ -110,12 +104,11 @@
110 utils.ExecCommand(goCmd...)104 utils.ExecCommand(goCmd...)
111}105}
112106
113func adtRun(rootPath, testFilter string, testList, testbedOptions []string) {107func adtRun(rootPath, testFilter string, testbedOptions []string) {
114 createControlFile(testFilter, testList)108 createControlFile(testFilter)
115109
116 fmt.Println("Calling adt-run...")110 fmt.Println("Calling adt-run...")
117 outputSubdir := strings.Join(testList, "-")111 outputDir := filepath.Join(baseDir, "output")
118 outputDir := filepath.Join(baseDir, "output", outputSubdir)
119 utils.PrepareTargetDir(outputDir)112 utils.PrepareTargetDir(outputDir)
120113
121 cmd := []string{114 cmd := []string{
@@ -136,10 +129,10 @@
136 "--", "-i", imagePath}...)129 "--", "-i", imagePath}...)
137}130}
138131
139func createControlFile(testFilter string, testList []string) {132func createControlFile(testFilter string) {
140 type controlData struct {133 type controlData struct {
141 Filter string134 Filter string
142 Tests []string135 Test string
143 }136 }
144137
145 tpl, err := template.ParseFiles(controlTpl)138 tpl, err := template.ParseFiles(controlTpl)
@@ -153,7 +146,8 @@
153 }146 }
154 defer outputFile.Close()147 defer outputFile.Close()
155148
156 err = tpl.Execute(outputFile, controlData{Filter: testFilter, Tests: testList})149 err = tpl.Execute(outputFile,
150 controlData{Test: integrationTestName, Filter: testFilter})
157 if err != nil {151 if err != nil {
158 log.Fatalf("execution: %s", err)152 log.Fatalf("execution: %s", err)
159 }153 }
160154
=== renamed file '_integration-tests/tests/cmd/apt_test.go' => '_integration-tests/tests/apt_test.go'
--- _integration-tests/tests/cmd/apt_test.go 2015-07-21 00:41:05 +0000
+++ _integration-tests/tests/apt_test.go 2015-07-22 16:37:35 +0000
@@ -17,10 +17,10 @@
17 *17 *
18 */18 */
1919
20package cmd20package tests
2121
22import (22import (
23 . "../common"23 . "launchpad.net/snappy/_integration-tests/common"
2424
25 check "gopkg.in/check.v1"25 check "gopkg.in/check.v1"
26)26)
2727
=== renamed file '_integration-tests/tests/cmd/base_test.go' => '_integration-tests/tests/base_test.go'
--- _integration-tests/tests/cmd/base_test.go 2015-07-17 00:57:32 +0000
+++ _integration-tests/tests/base_test.go 2015-07-22 16:37:35 +0000
@@ -17,7 +17,7 @@
17 *17 *
18 */18 */
1919
20package cmd20package tests
2121
22import (22import (
23 "testing"23 "testing"
2424
=== renamed file '_integration-tests/tests/cmd/build_test.go' => '_integration-tests/tests/build_test.go'
--- _integration-tests/tests/cmd/build_test.go 2015-07-17 00:57:32 +0000
+++ _integration-tests/tests/build_test.go 2015-07-22 16:37:35 +0000
@@ -17,14 +17,14 @@
17 *17 *
18 */18 */
1919
20package cmd20package tests
2121
22import (22import (
23 "fmt"23 "fmt"
24 "os"24 "os"
25 "os/exec"25 "os/exec"
2626
27 . "../common"27 . "launchpad.net/snappy/_integration-tests/common"
2828
29 . "gopkg.in/check.v1"29 . "gopkg.in/check.v1"
30)30)
3131
=== removed directory '_integration-tests/tests/cmd'
=== removed directory '_integration-tests/tests/failover'
=== renamed file '_integration-tests/tests/failover/failover_rclocal_crash_test.go' => '_integration-tests/tests/failover_rclocal_crash_test.go'
--- _integration-tests/tests/failover/failover_rclocal_crash_test.go 2015-07-06 19:01:48 +0000
+++ _integration-tests/tests/failover_rclocal_crash_test.go 2015-07-22 16:37:35 +0000
@@ -17,12 +17,12 @@
17 *17 *
18 */18 */
1919
20package failover20package tests
2121
22import (22import (
23 "fmt"23 "fmt"
2424
25 . "../common"25 . "launchpad.net/snappy/_integration-tests/common"
2626
27 check "gopkg.in/check.v1"27 check "gopkg.in/check.v1"
28)28)
2929
=== renamed file '_integration-tests/tests/failover/failover_systemd_loop_test.go' => '_integration-tests/tests/failover_systemd_loop_test.go'
--- _integration-tests/tests/failover/failover_systemd_loop_test.go 2015-07-06 19:01:48 +0000
+++ _integration-tests/tests/failover_systemd_loop_test.go 2015-07-22 16:37:35 +0000
@@ -17,12 +17,12 @@
17 *17 *
18 */18 */
1919
20package failover20package tests
2121
22import (22import (
23 "fmt"23 "fmt"
2424
25 . "../common"25 . "launchpad.net/snappy/_integration-tests/common"
2626
27 check "gopkg.in/check.v1"27 check "gopkg.in/check.v1"
28)28)
2929
=== renamed file '_integration-tests/tests/failover/failover_test.go' => '_integration-tests/tests/failover_test.go'
--- _integration-tests/tests/failover/failover_test.go 2015-07-16 00:30:07 +0000
+++ _integration-tests/tests/failover_test.go 2015-07-22 16:37:35 +0000
@@ -17,19 +17,14 @@
17 *17 *
18 */18 */
1919
20package failover20package tests
2121
22import (22import (
23 "testing"
24
25 check "gopkg.in/check.v1"23 check "gopkg.in/check.v1"
2624
27 . "../common"25 . "launchpad.net/snappy/_integration-tests/common"
28)26)
2927
30// Hook up gocheck into the "go test" runner.
31func Test(t *testing.T) { check.TestingT(t) }
32
33var _ = check.Suite(&failoverSuite{})28var _ = check.Suite(&failoverSuite{})
3429
35type failoverSuite struct {30type failoverSuite struct {
3631
=== renamed file '_integration-tests/tests/failover/failover_zero_size_file_test.go' => '_integration-tests/tests/failover_zero_size_file_test.go'
--- _integration-tests/tests/failover/failover_zero_size_file_test.go 2015-07-06 19:01:48 +0000
+++ _integration-tests/tests/failover_zero_size_file_test.go 2015-07-22 16:37:35 +0000
@@ -17,7 +17,7 @@
17 *17 *
18 */18 */
1919
20package failover20package tests
2121
22import (22import (
23 "fmt"23 "fmt"
@@ -25,7 +25,7 @@
25 "path/filepath"25 "path/filepath"
26 "strings"26 "strings"
2727
28 . "../common"28 . "launchpad.net/snappy/_integration-tests/common"
2929
30 check "gopkg.in/check.v1"30 check "gopkg.in/check.v1"
31)31)
3232
=== renamed file '_integration-tests/tests/cmd/info_test.go' => '_integration-tests/tests/info_test.go'
--- _integration-tests/tests/cmd/info_test.go 2015-07-17 00:57:32 +0000
+++ _integration-tests/tests/info_test.go 2015-07-22 16:37:35 +0000
@@ -17,12 +17,12 @@
17 *17 *
18 */18 */
1919
20package cmd20package tests
2121
22import (22import (
23 "fmt"23 "fmt"
2424
25 . "../common"25 . "launchpad.net/snappy/_integration-tests/common"
2626
27 check "gopkg.in/check.v1"27 check "gopkg.in/check.v1"
28)28)
2929
=== renamed file '_integration-tests/tests/cmd/installApp_test.go' => '_integration-tests/tests/installApp_test.go'
--- _integration-tests/tests/cmd/installApp_test.go 2015-07-17 00:57:32 +0000
+++ _integration-tests/tests/installApp_test.go 2015-07-22 16:37:35 +0000
@@ -17,14 +17,14 @@
17 *17 *
18 */18 */
1919
20package cmd20package tests
2121
22import (22import (
23 "net/http"23 "net/http"
24 "os/exec"24 "os/exec"
25 "time"25 "time"
2626
27 . "../common"27 . "launchpad.net/snappy/_integration-tests/common"
2828
29 check "gopkg.in/check.v1"29 check "gopkg.in/check.v1"
30)30)
3131
=== renamed file '_integration-tests/tests/cmd/installFramework_test.go' => '_integration-tests/tests/installFramework_test.go'
--- _integration-tests/tests/cmd/installFramework_test.go 2015-07-17 00:57:32 +0000
+++ _integration-tests/tests/installFramework_test.go 2015-07-22 16:37:35 +0000
@@ -17,13 +17,13 @@
17 *17 *
18 */18 */
1919
20package cmd20package tests
2121
22import (22import (
23 "fmt"23 "fmt"
24 "regexp"24 "regexp"
2525
26 . "../common"26 . "launchpad.net/snappy/_integration-tests/common"
2727
28 check "gopkg.in/check.v1"28 check "gopkg.in/check.v1"
29)29)
3030
=== renamed file '_integration-tests/tests/cmd/list_test.go' => '_integration-tests/tests/list_test.go'
--- _integration-tests/tests/cmd/list_test.go 2015-07-21 00:40:00 +0000
+++ _integration-tests/tests/list_test.go 2015-07-22 16:37:35 +0000
@@ -17,13 +17,13 @@
17 *17 *
18 */18 */
1919
20package cmd20package tests
2121
22import (22import (
23 "fmt"23 "fmt"
24 "os"24 "os"
2525
26 . "../common"26 . "launchpad.net/snappy/_integration-tests/common"
2727
28 "github.com/mvo5/goconfigparser"28 "github.com/mvo5/goconfigparser"
29 check "gopkg.in/check.v1"29 check "gopkg.in/check.v1"
3030
=== renamed file '_integration-tests/tests/cmd/rollback_test.go' => '_integration-tests/tests/rollback_test.go'
--- _integration-tests/tests/cmd/rollback_test.go 2015-07-21 00:41:05 +0000
+++ _integration-tests/tests/rollback_test.go 2015-07-22 16:37:35 +0000
@@ -17,12 +17,13 @@
17 *17 *
18 */18 */
1919
20package cmd20package tests
2121
22import (22import (
23 "strconv"23 "strconv"
2424
25 . "../common"25 . "launchpad.net/snappy/_integration-tests/common"
26
26 check "gopkg.in/check.v1"27 check "gopkg.in/check.v1"
27)28)
2829
2930
=== renamed file '_integration-tests/tests/cmd/search_test.go' => '_integration-tests/tests/search_test.go'
--- _integration-tests/tests/cmd/search_test.go 2015-07-17 00:57:32 +0000
+++ _integration-tests/tests/search_test.go 2015-07-22 16:37:35 +0000
@@ -17,10 +17,10 @@
17 *17 *
18 */18 */
1919
20package cmd20package tests
2121
22import (22import (
23 . "../common"23 . "launchpad.net/snappy/_integration-tests/common"
2424
25 . "gopkg.in/check.v1"25 . "gopkg.in/check.v1"
26)26)
2727
=== renamed file '_integration-tests/tests/cmd/update_test.go' => '_integration-tests/tests/update_test.go'
--- _integration-tests/tests/cmd/update_test.go 2015-07-17 00:57:32 +0000
+++ _integration-tests/tests/update_test.go 2015-07-22 16:37:35 +0000
@@ -17,10 +17,11 @@
17 *17 *
18 */18 */
1919
20package cmd20package tests
2121
22import (22import (
23 . "../common"23 . "launchpad.net/snappy/_integration-tests/common"
24
24 check "gopkg.in/check.v1"25 check "gopkg.in/check.v1"
25)26)
2627
2728
=== renamed file '_integration-tests/tests/cmd/writablePaths_test.go' => '_integration-tests/tests/writablePaths_test.go'
--- _integration-tests/tests/cmd/writablePaths_test.go 2015-07-21 00:41:05 +0000
+++ _integration-tests/tests/writablePaths_test.go 2015-07-22 16:37:35 +0000
@@ -17,7 +17,7 @@
17 *17 *
18 */18 */
1919
20package cmd20package tests
2121
22import (22import (
23 "bufio"23 "bufio"
@@ -27,7 +27,7 @@
27 "path/filepath"27 "path/filepath"
28 "strings"28 "strings"
2929
30 . "../common"30 . "launchpad.net/snappy/_integration-tests/common"
3131
32 check "gopkg.in/check.v1"32 check "gopkg.in/check.v1"
33)33)
3434
=== modified file 'run-checks'
--- run-checks 2015-07-21 15:21:08 +0000
+++ run-checks 2015-07-22 16:37:35 +0000
@@ -72,7 +72,7 @@
7272
73# the rabbit hole73# the rabbit hole
74echo Running the tests for the integration helpers74echo Running the tests for the integration helpers
75$goctest -v -cover ./_integration-tests/tests/common/...75$goctest -v -cover ./_integration-tests/common/...
7676
77# integration suite in kvm77# integration suite in kvm
78if which adt-run >/dev/null 2>&1; then78if which adt-run >/dev/null 2>&1; then

Subscribers

People subscribed via source and target branches