Merge lp:~elopio/snappy/go-tests6 into lp:~fgimenez/snappy/cross-compile-debs

Proposed by Leo Arias
Status: Merged
Approved by: Federico Gimenez
Approved revision: 513
Merged at revision: 509
Proposed branch: lp:~elopio/snappy/go-tests6
Merge into: lp:~fgimenez/snappy/cross-compile-debs
Diff against target: 98 lines (+35/-23)
1 file modified
_integration-tests/main.go (+35/-23)
To merge this branch: bzr merge lp:~elopio/snappy/go-tests6
Reviewer Review Type Date Requested Status
Federico Gimenez Approve
Snappy Developers Pending
Review via email: mp+262453@code.launchpad.net

This proposal supersedes a proposal from 2015-06-19.

Commit message

Allow to execute the tests in a remote install through ssh.

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

Thanks!

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-19 06:58:19 +0000
3+++ _integration-tests/main.go 2015-06-19 14:43:00 +0000
4@@ -22,15 +22,20 @@
5 imageDir = filepath.Join(baseDir, "image")
6 outputDir = filepath.Join(baseDir, "output")
7 imageTarget = filepath.Join(imageDir, "snappy.img")
8- commonSSHOptions = []string{
9- "ssh", "-s", "/usr/share/autopkgtest/ssh-setup/snappy"}
10- kvmSSHOptions = append(commonSSHOptions, []string{"--", "-i", imageTarget}...)
11- debsDir string
12- arch string
13- testbedIP string
14+ commonSSHOptions = []string{"---", "ssh"}
15+ kvmSSHOptions = append(
16+ commonSSHOptions,
17+ []string{
18+ "-s", "/usr/share/autopkgtest/ssh-setup/snappy",
19+ "--", "-i", imageTarget}...)
20+ useFlashedImage bool
21+ debsDir string
22+ arch string
23+ testbedIP string
24 )
25
26 func init() {
27+ flag.BoolVar(&useFlashedImage, "installed-image", false, "Wether we should install the snappy version from the branch or use the one installed on the image")
28 flag.StringVar(&debsDir, "debs-dir", defaultDebsDir, "Directory with the snappy debian packages.")
29 flag.StringVar(&arch, "arch", defaultArch, "Target architecture (amd64, armhf)")
30 flag.StringVar(&testbedIP, "ip", "", "IP of the testbed to run the tests in")
31@@ -78,29 +83,35 @@
32 "--developer-mode")
33 }
34
35-func adtRun(rootPath string, sshOptions []string) {
36+func adtRun(rootPath string, testbedOptions []string) {
37 fmt.Println("Calling adt-run...")
38 prepareTargetDir(outputDir)
39- cmd := []string{"adt-run",
40- "-B",
41- "--setup-commands", "touch /run/autopkgtest_no_reboot.stamp",
42- "--setup-commands", "mount -o remount,rw /",
43- "--setup-commands",
44- fmt.Sprintf("dpkg -i %s/*deb", debsTestBedPath),
45- "--setup-commands",
46- "sync; sleep 2; mount -o remount,ro /",
47+ cmd := []string{
48+ "adt-run", "-B",
49 "--override-control", "debian/integration-tests/control",
50 "--built-tree", rootPath,
51- "--output-dir", outputDir,
52- fmt.Sprintf("--copy=%s:%s", debsDir, debsTestBedPath),
53- "---"}
54- execCommand(append(cmd, sshOptions...)...)
55+ "--output-dir", outputDir}
56+
57+ if !useFlashedImage {
58+ debsSetup := []string{
59+ "--setup-commands", "touch /run/autopkgtest_no_reboot.stamp",
60+ "--setup-commands", "mount -o remount,rw /",
61+ "--setup-commands",
62+ fmt.Sprintf("dpkg -i %s/*deb", debsTestBedPath),
63+ "--setup-commands",
64+ "sync; sleep 2; mount -o remount,ro /",
65+ fmt.Sprintf("--copy=%s:%s", debsDir, debsTestBedPath)}
66+ cmd = append(cmd, debsSetup...)
67+ }
68+
69+ execCommand(append(cmd, testbedOptions...)...)
70 }
71
72 func remoteTestbedSSHOptions(testbedIP string) []string {
73 options := []string{
74 "-H", testbedIP,
75- }
76+ "-l", "ubuntu",
77+ "-i", filepath.Join(os.Getenv("HOME"), ".ssh", "id_rsa")}
78 return append(commonSSHOptions, options...)
79 }
80
81@@ -129,13 +140,14 @@
82
83 rootPath := getRootPath()
84
85- if debsDir == defaultDebsDir {
86+ if !useFlashedImage && debsDir == defaultDebsDir {
87 buildDebs(rootPath, arch)
88 }
89- if arch == defaultArch {
90+ if testbedIP == "" {
91 createImage(defaultRelease, defaultChannel, getArchForImage())
92 adtRun(rootPath, kvmSSHOptions)
93 } else {
94- //adtRun(rootPath, remoteTestbedSSHOptions(testbedIP))
95+ execCommand("ssh-copy-id", "ubuntu@"+testbedIP)
96+ adtRun(rootPath, remoteTestbedSSHOptions(testbedIP))
97 }
98 }

Subscribers

People subscribed via source and target branches

to all changes: