Merge lp:~elopio/snappy/remote-ssh into lp:~fgimenez/snappy/cross-compile-debs

Proposed by Leo Arias
Status: Merged
Approved by: Federico Gimenez
Approved revision: 514
Merged at revision: 512
Proposed branch: lp:~elopio/snappy/remote-ssh
Merge into: lp:~fgimenez/snappy/cross-compile-debs
Diff against target: 140 lines (+41/-30)
1 file modified
_integration-tests/main.go (+41/-30)
To merge this branch: bzr merge lp:~elopio/snappy/remote-ssh
Reviewer Review Type Date Requested Status
Federico Gimenez Approve
Review via email: mp+262809@code.launchpad.net

Commit message

Got the remote ssh working.

Description of the change

Tests now can run in an running local kvm:
go run _integration-tests/main.go --ip localhost --port 8022

or in a remote beaglebone:
go run _integration-tests/main.go --installed-image --ip 192.168.2.196

Most of the test will fail because the images we prepare for kvm and beagle don't meet the prerequisites of the tests.

To post a comment you must log in.
lp:~elopio/snappy/remote-ssh updated
513. By Leo Arias

Also got the crossbuild working. It fails, but starts.

514. By Leo Arias

If we are using 15.04, that is vivid.

Revision history for this message
Federico Gimenez (fgimenez) wrote :

Great, 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 09:02:08 +0000
3+++ _integration-tests/main.go 2015-06-24 06:26:44 +0000
4@@ -7,6 +7,7 @@
5 "os"
6 "os/exec"
7 "path/filepath"
8+ "strconv"
9 )
10
11 const (
12@@ -15,6 +16,7 @@
13 defaultRelease = "15.04"
14 defaultChannel = "edge"
15 defaultArch = "amd64"
16+ defaultSSHPort = 22
17 )
18
19 var (
20@@ -28,17 +30,23 @@
21 []string{
22 "-s", "/usr/share/autopkgtest/ssh-setup/snappy",
23 "--", "-i", imageTarget}...)
24- useFlashedImage bool
25- debsDir string
26- arch string
27- testbedIP string
28 )
29
30-func init() {
31- flag.BoolVar(&useFlashedImage, "installed-image", false, "Wether we should install the snappy version from the branch or use the one installed on the image")
32- flag.StringVar(&debsDir, "debs-dir", defaultDebsDir, "Directory with the snappy debian packages.")
33- flag.StringVar(&arch, "arch", defaultArch, "Target architecture (amd64, armhf)")
34- flag.StringVar(&testbedIP, "ip", "", "IP of the testbed to run the tests in")
35+func setupAndRunTests(useFlashedImage bool, debsDir, arch, testbedIP string, testbedPort int) {
36+ rootPath := getRootPath()
37+ if useFlashedImage {
38+ // using the flashed image, so no debs must be installed.
39+ debsDir = ""
40+ } else if debsDir == defaultDebsDir {
41+ buildDebs(rootPath, debsDir, arch)
42+ }
43+ if testbedIP == "" {
44+ createImage(defaultRelease, defaultChannel, getArchForImage())
45+ adtRun(rootPath, debsDir, kvmSSHOptions)
46+ } else {
47+ execCommand("ssh-copy-id", "-p", strconv.Itoa(testbedPort), "ubuntu@"+testbedIP)
48+ adtRun(rootPath, debsDir, remoteTestbedSSHOptions(testbedIP, testbedPort))
49+ }
50 }
51
52 func execCommand(cmds ...string) {
53@@ -50,18 +58,18 @@
54 }
55 }
56
57-func buildDebs(rootPath, arch string) {
58+func buildDebs(rootPath, destDir, arch string) {
59 fmt.Println("Building debs...")
60- prepareTargetDir(debsDir)
61- buildCommand := []string{"bzr", "bd",
62- fmt.Sprintf("--result-dir=%s", debsDir),
63+ prepareTargetDir(destDir)
64+ buildCommand := []string{"bzr", "bd", "-v",
65+ fmt.Sprintf("--result-dir=%s", destDir),
66 "--split",
67 rootPath,
68 }
69 if arch != defaultArch {
70 builderOption := []string{
71- fmt.Sprintf(
72- "--builder=sbuild --build amd64 --host %s --dist wily", arch)}
73+ "--builder=sbuild", "--",
74+ fmt.Sprintf("--host=%s", arch), "--dist=vivid", "-v"}
75 buildCommand = append(buildCommand, builderOption...)
76 } else {
77 dontSignDebs := []string{"--", "-uc", "-us"}
78@@ -83,7 +91,7 @@
79 "--developer-mode")
80 }
81
82-func adtRun(rootPath string, testbedOptions []string) {
83+func adtRun(rootPath, debsDir string, testbedOptions []string) {
84 fmt.Println("Calling adt-run...")
85 prepareTargetDir(outputDir)
86 cmd := []string{
87@@ -92,7 +100,7 @@
88 "--built-tree", rootPath,
89 "--output-dir", outputDir}
90
91- if !useFlashedImage {
92+ if debsDir != "" {
93 debsSetup := []string{
94 "--setup-commands", "touch /run/autopkgtest_no_reboot.stamp",
95 "--setup-commands", "mount -o remount,rw /",
96@@ -107,9 +115,10 @@
97 execCommand(append(cmd, testbedOptions...)...)
98 }
99
100-func remoteTestbedSSHOptions(testbedIP string) []string {
101+func remoteTestbedSSHOptions(testbedIP string, testbedPort int) []string {
102 options := []string{
103 "-H", testbedIP,
104+ "-p", strconv.Itoa(testbedPort),
105 "-l", "ubuntu",
106 "-i", filepath.Join(os.Getenv("HOME"), ".ssh", "id_rsa")}
107 return append(commonSSHOptions, options...)
108@@ -136,18 +145,20 @@
109 }
110
111 func main() {
112+ var (
113+ useFlashedImage = flag.Bool("installed-image", false,
114+ "Wether we should install the snappy version from the branch or use the one installed on the image")
115+ debsDir = flag.String("debs-dir", defaultDebsDir,
116+ "Directory with th1e snappy debian packages.")
117+ arch = flag.String("arch", defaultArch,
118+ "Target architecture (amd64, armhf)")
119+ testbedIP = flag.String("ip", "",
120+ "IP of the testbed to run the tests in")
121+ testbedPort = flag.Int("port", defaultSSHPort,
122+ "SSH port of the testbed")
123+ )
124+
125 flag.Parse()
126
127- rootPath := getRootPath()
128-
129- if !useFlashedImage && debsDir == defaultDebsDir {
130- buildDebs(rootPath, arch)
131- }
132- if testbedIP == "" {
133- createImage(defaultRelease, defaultChannel, getArchForImage())
134- adtRun(rootPath, kvmSSHOptions)
135- } else {
136- execCommand("ssh-copy-id", "ubuntu@"+testbedIP)
137- adtRun(rootPath, remoteTestbedSSHOptions(testbedIP))
138- }
139+ setupAndRunTests(*useFlashedImage, *debsDir, *arch, *testbedIP, *testbedPort)
140 }

Subscribers

People subscribed via source and target branches

to all changes: