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

Proposed by Leo Arias
Status: Merged
Approved by: Leo Arias
Approved revision: 528
Merged at revision: 545
Proposed branch: lp:~elopio/snappy/snappy_from_trunk
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Prerequisite: lp:~elopio/snappy/upgrade-test
Diff against target: 138 lines (+40/-15)
3 files modified
_integration-tests/main.go (+36/-13)
debian/integration-tests/snappy-test (+3/-1)
run-checks (+1/-1)
To merge this branch: bzr merge lp:~elopio/snappy/snappy_from_trunk
Reviewer Review Type Date Requested Status
Federico Gimenez (community) Approve
Review via email: mp+263304@code.launchpad.net

Commit message

Allow to run the integration tests using snappy from branch.

To post a comment you must log in.
lp:~elopio/snappy/snappy_from_trunk updated
523. By Leo Arias

Removed the print of the path.

524. By Leo Arias

Merged with prerequisite.

525. By Leo Arias

Rolled back the period to clean the diff.

526. By Leo Arias

Removed the duplicated print.

527. By Leo Arias

Merged with trun.k

528. By Leo Arias

Merged federico's branch.

Revision history for this message
Federico Gimenez (fgimenez) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '_integration-tests/main.go'
2--- _integration-tests/main.go 2015-06-30 01:04:05 +0000
3+++ _integration-tests/main.go 2015-07-01 14:43:33 +0000
4@@ -32,6 +32,7 @@
5
6 const (
7 baseDir = "/tmp/snappy-test"
8+ testsBinDir = "_integration-tests/bin/"
9 defaultRelease = "rolling"
10 defaultChannel = "edge"
11 latestRevision = ""
12@@ -44,9 +45,7 @@
13 )
14
15 var (
16- testsDir = filepath.Join(baseDir, "tests")
17 imageDir = filepath.Join(baseDir, "image")
18- outputDir = filepath.Join(baseDir, "output")
19 imageTarget = filepath.Join(imageDir, "snappy.img")
20 commonSSHOptions = []string{"---", "ssh"}
21 kvmSSHOptions = append(
22@@ -56,7 +55,14 @@
23 "--", "-i", imageTarget}...)
24 )
25
26-func setupAndRunTests(arch, testbedIP string, testbedPort int) {
27+func setupAndRunTests(useSnappyFromBranch bool, arch, testbedIP string, testbedPort int) {
28+ prepareTargetDir(testsBinDir)
29+
30+ if useSnappyFromBranch {
31+ // FIXME We need to build an image that has the snappy from the branch
32+ // installed. --elopio - 2015-06-25.
33+ buildSnappyCLI(arch)
34+ }
35 buildTests(arch)
36
37 rootPath := getRootPath()
38@@ -88,9 +94,27 @@
39 }
40 }
41
42+func buildSnappyCLI(arch string) {
43+ fmt.Println("Building snappy CLI...")
44+ // On the root of the project we have a directory called snappy, so we
45+ // output the binary for the tests in the tests directory.
46+ goCall(arch, "build", "-o", testsBinDir+"snappy", "./cmd/snappy")
47+}
48+
49 func buildTests(arch string) {
50- fmt.Println("Building tests")
51- prepareTargetDir(testsDir)
52+ fmt.Println("Building tests...")
53+ tests := []string{"latest", "failover", "update"}
54+ for i := range tests {
55+ testName := tests[i]
56+ goCall(arch, "test", "-c",
57+ "./_integration-tests/tests/"+testName)
58+ // XXX Go test 1.3 does not have the output flag, so we move the
59+ // binaries after they are generated.
60+ os.Rename(testName+".test", testsBinDir+testName+".test")
61+ }
62+}
63+
64+func goCall(arch string, cmds ...string) {
65 if arch != "" {
66 defer os.Setenv("GOARCH", os.Getenv("GOARCH"))
67 os.Setenv("GOARCH", arch)
68@@ -99,12 +123,8 @@
69 os.Setenv("GOARM", defaultGoArm)
70 }
71 }
72- tests := []string{"latest", "failover", "update"}
73- for i := range tests {
74- testName := tests[i]
75- execCommand("go", "test", "-c",
76- "./_integration-tests/tests/"+testName)
77- }
78+ goCmd := append([]string{"go"}, cmds...)
79+ execCommand(goCmd...)
80 }
81
82 func createImage(release, channel, revision string) {
83@@ -125,6 +145,7 @@
84
85 func adtRun(rootPath string, testbedOptions []string, testname string) {
86 fmt.Println("Calling adt-run...")
87+ outputDir := filepath.Join(baseDir, "output")
88 prepareTargetDir(outputDir)
89
90 cmd := []string{
91@@ -170,15 +191,17 @@
92
93 func main() {
94 var (
95+ useSnappyFromBranch = flag.Bool("snappy-from-branch", false,
96+ "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.")
97 arch = flag.String("arch", "",
98 "Architecture of the test bed. Defaults to use the same architecture as the host.")
99 testbedIP = flag.String("ip", "",
100 "IP of the testbed. If no IP is passed, a virtual machine will be created for the test.")
101 testbedPort = flag.Int("port", defaultSSHPort,
102- "SSH port of the testbed. Defaults to use port 22.")
103+ "SSH port of the testbed. Defaults to use port "+strconv.Itoa(defaultSSHPort))
104 )
105
106 flag.Parse()
107
108- setupAndRunTests(*arch, *testbedIP, *testbedPort)
109+ setupAndRunTests(*useSnappyFromBranch, *arch, *testbedIP, *testbedPort)
110 }
111
112=== modified file 'debian/integration-tests/snappy-test'
113--- debian/integration-tests/snappy-test 2015-06-29 16:12:00 +0000
114+++ debian/integration-tests/snappy-test 2015-07-01 14:43:33 +0000
115@@ -21,7 +21,9 @@
116 TEST=$1
117 NEEDS_REBOOT=/tmp/needs-reboot
118
119-./${TEST} -check.vv -test.outputdir=$ADT_ARTIFACTS-$ADT_REBOOT_MARK
120+export PATH=$(pwd)/_integration-tests/bin:$PATH
121+
122+${TEST} -check.vv -test.outputdir=$ADT_ARTIFACTS-$ADT_REBOOT_MARK
123
124 if [ -e ${NEEDS_REBOOT} ]; then
125 mark=`cat ${NEEDS_REBOOT}`
126
127=== modified file 'run-checks'
128--- run-checks 2015-07-01 08:13:27 +0000
129+++ run-checks 2015-07-01 14:43:33 +0000
130@@ -71,7 +71,7 @@
131 # integration tests
132 if which adt-run >/dev/null 2>&1; then
133 echo "Running integration tests"
134- go run _integration-tests/main.go
135+ go run _integration-tests/main.go --snappy-from-branch
136 fi
137
138 echo "All good, what could possibly go wrong"

Subscribers

People subscribed via source and target branches