Merge lp:~fgimenez/snappy/cli-pkg into lp:~snappy-dev/snappy/snappy-moved-to-github
- cli-pkg
- Merge into snappy-moved-to-github
Proposed by
Federico Gimenez
Status: | Merged |
---|---|
Approved by: | Federico Gimenez |
Approved revision: | 722 |
Merged at revision: | 733 |
Proposed branch: | lp:~fgimenez/snappy/cli-pkg |
Merge into: | lp:~snappy-dev/snappy/snappy-moved-to-github |
Diff against target: |
1166 lines (+306/-175) 24 files modified
_integration-tests/tests/apt_test.go (+5/-4) _integration-tests/tests/config_test.go (+3/-2) _integration-tests/tests/failover_rclocal_crash_test.go (+12/-10) _integration-tests/tests/failover_systemd_loop_test.go (+18/-17) _integration-tests/tests/failover_test.go (+10/-10) _integration-tests/tests/failover_zero_size_file_test.go (+12/-11) _integration-tests/tests/helloDbus_test.go (+2/-1) _integration-tests/tests/info_test.go (+13/-12) _integration-tests/tests/installApp_test.go (+4/-3) _integration-tests/tests/installFramework_test.go (+3/-2) _integration-tests/tests/list_test.go (+8/-7) _integration-tests/tests/rollback_test.go (+18/-17) _integration-tests/tests/search_test.go (+8/-7) _integration-tests/tests/ubuntuFan_test.go (+10/-9) _integration-tests/tests/update_test.go (+8/-8) _integration-tests/tests/writablePaths_test.go (+3/-3) _integration-tests/testutils/build/snap.go (+3/-3) _integration-tests/testutils/build/snap_test.go (+3/-3) _integration-tests/testutils/cli/cli.go (+57/-0) _integration-tests/testutils/cli/cli_test.go (+85/-0) _integration-tests/testutils/common/common.go (+15/-41) _integration-tests/testutils/common/info.go (+2/-1) _integration-tests/testutils/runner/runner.go (+1/-1) _integration-tests/testutils/wait/wait.go (+3/-3) |
To merge this branch: | bzr merge lp:~fgimenez/snappy/cli-pkg |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Federico Gimenez (community) | Approve | ||
Leo Arias (community) | Needs Fixing | ||
Review via email: mp+272896@code.launchpad.net |
Commit message
cli package with ExecCommand functions
Description of the change
cli package with ExecCommand functions
The cli package unit tests have been implemented using the technique described in [1]. Also the remaining unnamed "common" package imports and the references to check when importing the gocheck package have been removed.
To post a comment you must log in.
lp:~fgimenez/snappy/cli-pkg
updated
- 721. By Federico Gimenez
-
merged trunk
- 722. By Federico Gimenez
-
config_test updated to cli
Revision history for this message
Federico Gimenez (fgimenez) wrote : | # |
Merged and working, thanks Leo
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '_integration-tests/tests/apt_test.go' | |||
2 | --- _integration-tests/tests/apt_test.go 2015-07-28 04:03:52 +0000 | |||
3 | +++ _integration-tests/tests/apt_test.go 2015-10-02 10:23:57 +0000 | |||
4 | @@ -20,19 +20,20 @@ | |||
5 | 20 | package tests | 20 | package tests |
6 | 21 | 21 | ||
7 | 22 | import ( | 22 | import ( |
9 | 23 | . "launchpad.net/snappy/_integration-tests/testutils/common" | 23 | "launchpad.net/snappy/_integration-tests/testutils/cli" |
10 | 24 | "launchpad.net/snappy/_integration-tests/testutils/common" | ||
11 | 24 | 25 | ||
13 | 25 | check "gopkg.in/check.v1" | 26 | "gopkg.in/check.v1" |
14 | 26 | ) | 27 | ) |
15 | 27 | 28 | ||
16 | 28 | var _ = check.Suite(&aptSuite{}) | 29 | var _ = check.Suite(&aptSuite{}) |
17 | 29 | 30 | ||
18 | 30 | type aptSuite struct { | 31 | type aptSuite struct { |
20 | 31 | SnappySuite | 32 | common.SnappySuite |
21 | 32 | } | 33 | } |
22 | 33 | 34 | ||
23 | 34 | func (s *aptSuite) TestAptGetMustPrintError(c *check.C) { | 35 | func (s *aptSuite) TestAptGetMustPrintError(c *check.C) { |
25 | 35 | aptOutput := ExecCommand(c, "apt-get", "update") | 36 | aptOutput := cli.ExecCommand(c, "apt-get", "update") |
26 | 36 | 37 | ||
27 | 37 | expected := "Ubuntu Core does not use apt-get, see 'snappy --help'!\n" | 38 | expected := "Ubuntu Core does not use apt-get, see 'snappy --help'!\n" |
28 | 38 | c.Assert(aptOutput, check.Equals, expected) | 39 | c.Assert(aptOutput, check.Equals, expected) |
29 | 39 | 40 | ||
30 | === modified file '_integration-tests/tests/config_test.go' | |||
31 | --- _integration-tests/tests/config_test.go 2015-09-30 08:07:52 +0000 | |||
32 | +++ _integration-tests/tests/config_test.go 2015-10-02 10:23:57 +0000 | |||
33 | @@ -24,6 +24,7 @@ | |||
34 | 24 | "os" | 24 | "os" |
35 | 25 | "strings" | 25 | "strings" |
36 | 26 | 26 | ||
37 | 27 | "launchpad.net/snappy/_integration-tests/testutils/cli" | ||
38 | 27 | "launchpad.net/snappy/_integration-tests/testutils/common" | 28 | "launchpad.net/snappy/_integration-tests/testutils/common" |
39 | 28 | 29 | ||
40 | 29 | "gopkg.in/check.v1" | 30 | "gopkg.in/check.v1" |
41 | @@ -97,13 +98,13 @@ | |||
42 | 97 | } | 98 | } |
43 | 98 | _, err = configFile.Write([]byte(config)) | 99 | _, err = configFile.Write([]byte(config)) |
44 | 99 | 100 | ||
46 | 100 | common.ExecCommand(c, "sudo", "snappy", "config", "ubuntu-core", configFile.Name()) | 101 | cli.ExecCommand(c, "sudo", "snappy", "config", "ubuntu-core", configFile.Name()) |
47 | 101 | 102 | ||
48 | 102 | return | 103 | return |
49 | 103 | } | 104 | } |
50 | 104 | 105 | ||
51 | 105 | func currentConfig(c *check.C) string { | 106 | func currentConfig(c *check.C) string { |
53 | 106 | return common.ExecCommand(c, "sudo", "snappy", "config", "ubuntu-core") | 107 | return cli.ExecCommand(c, "sudo", "snappy", "config", "ubuntu-core") |
54 | 107 | } | 108 | } |
55 | 108 | 109 | ||
56 | 109 | func configString(cfg string) string { | 110 | func configString(cfg string) string { |
57 | 110 | 111 | ||
58 | === modified file '_integration-tests/tests/failover_rclocal_crash_test.go' | |||
59 | --- _integration-tests/tests/failover_rclocal_crash_test.go 2015-09-09 06:56:19 +0000 | |||
60 | +++ _integration-tests/tests/failover_rclocal_crash_test.go 2015-10-02 10:23:57 +0000 | |||
61 | @@ -22,26 +22,28 @@ | |||
62 | 22 | import ( | 22 | import ( |
63 | 23 | "fmt" | 23 | "fmt" |
64 | 24 | 24 | ||
66 | 25 | . "launchpad.net/snappy/_integration-tests/testutils/common" | 25 | "launchpad.net/snappy/_integration-tests/testutils/cli" |
67 | 26 | "launchpad.net/snappy/_integration-tests/testutils/common" | ||
68 | 26 | 27 | ||
70 | 27 | check "gopkg.in/check.v1" | 28 | "gopkg.in/check.v1" |
71 | 28 | ) | 29 | ) |
72 | 29 | 30 | ||
73 | 30 | type rcLocalCrash struct{} | 31 | type rcLocalCrash struct{} |
74 | 31 | 32 | ||
75 | 32 | func (rcLocalCrash) set(c *check.C) { | 33 | func (rcLocalCrash) set(c *check.C) { |
81 | 33 | MakeWritable(c, BaseAltPartitionPath) | 34 | common.MakeWritable(c, common.BaseAltPartitionPath) |
82 | 34 | defer MakeReadonly(c, BaseAltPartitionPath) | 35 | defer common.MakeReadonly(c, common.BaseAltPartitionPath) |
83 | 35 | targetFile := fmt.Sprintf("%s/etc/rc.local", BaseAltPartitionPath) | 36 | targetFile := fmt.Sprintf("%s/etc/rc.local", common.BaseAltPartitionPath) |
84 | 36 | ExecCommand(c, "sudo", "chmod", "a+xw", targetFile) | 37 | cli.ExecCommand(c, "sudo", "chmod", "a+xw", targetFile) |
85 | 37 | ExecCommandToFile(c, targetFile, | 38 | |
86 | 39 | cli.ExecCommandToFile(c, targetFile, | ||
87 | 38 | "sudo", "echo", "#!bin/sh\nprintf c > /proc/sysrq-trigger") | 40 | "sudo", "echo", "#!bin/sh\nprintf c > /proc/sysrq-trigger") |
88 | 39 | } | 41 | } |
89 | 40 | 42 | ||
90 | 41 | func (rcLocalCrash) unset(c *check.C) { | 43 | func (rcLocalCrash) unset(c *check.C) { |
94 | 42 | MakeWritable(c, BaseAltPartitionPath) | 44 | common.MakeWritable(c, common.BaseAltPartitionPath) |
95 | 43 | defer MakeReadonly(c, BaseAltPartitionPath) | 45 | defer common.MakeReadonly(c, common.BaseAltPartitionPath) |
96 | 44 | ExecCommand(c, "sudo", "rm", fmt.Sprintf("%s/etc/rc.local", BaseAltPartitionPath)) | 46 | cli.ExecCommand(c, "sudo", "rm", fmt.Sprintf("%s/etc/rc.local", common.BaseAltPartitionPath)) |
97 | 45 | } | 47 | } |
98 | 46 | 48 | ||
99 | 47 | /* | 49 | /* |
100 | 48 | 50 | ||
101 | === modified file '_integration-tests/tests/failover_systemd_loop_test.go' | |||
102 | --- _integration-tests/tests/failover_systemd_loop_test.go 2015-07-30 16:22:30 +0000 | |||
103 | +++ _integration-tests/tests/failover_systemd_loop_test.go 2015-10-02 10:23:57 +0000 | |||
104 | @@ -22,9 +22,10 @@ | |||
105 | 22 | import ( | 22 | import ( |
106 | 23 | "fmt" | 23 | "fmt" |
107 | 24 | 24 | ||
109 | 25 | . "launchpad.net/snappy/_integration-tests/testutils/common" | 25 | "launchpad.net/snappy/_integration-tests/testutils/cli" |
110 | 26 | "launchpad.net/snappy/_integration-tests/testutils/common" | ||
111 | 26 | 27 | ||
113 | 27 | check "gopkg.in/check.v1" | 28 | "gopkg.in/check.v1" |
114 | 28 | ) | 29 | ) |
115 | 29 | 30 | ||
116 | 30 | const ( | 31 | const ( |
117 | @@ -61,51 +62,51 @@ | |||
118 | 61 | type systemdDependencyLoop struct{} | 62 | type systemdDependencyLoop struct{} |
119 | 62 | 63 | ||
120 | 63 | func (systemdDependencyLoop) set(c *check.C) { | 64 | func (systemdDependencyLoop) set(c *check.C) { |
123 | 64 | installService(c, "deadlock", deadlockService, BaseAltPartitionPath) | 65 | installService(c, "deadlock", deadlockService, common.BaseAltPartitionPath) |
124 | 65 | installService(c, "emerg-reboot", rebootService, BaseAltPartitionPath) | 66 | installService(c, "emerg-reboot", rebootService, common.BaseAltPartitionPath) |
125 | 66 | } | 67 | } |
126 | 67 | 68 | ||
127 | 68 | func (systemdDependencyLoop) unset(c *check.C) { | 69 | func (systemdDependencyLoop) unset(c *check.C) { |
130 | 69 | unInstallService(c, "deadlock", BaseAltPartitionPath) | 70 | unInstallService(c, "deadlock", common.BaseAltPartitionPath) |
131 | 70 | unInstallService(c, "emerg-reboot", BaseAltPartitionPath) | 71 | unInstallService(c, "emerg-reboot", common.BaseAltPartitionPath) |
132 | 71 | } | 72 | } |
133 | 72 | 73 | ||
134 | 73 | func installService(c *check.C, serviceName, serviceCfg, basePath string) { | 74 | func installService(c *check.C, serviceName, serviceCfg, basePath string) { |
137 | 74 | MakeWritable(c, basePath) | 75 | common.MakeWritable(c, basePath) |
138 | 75 | defer MakeReadonly(c, basePath) | 76 | defer common.MakeReadonly(c, basePath) |
139 | 76 | 77 | ||
140 | 77 | // Create service file | 78 | // Create service file |
141 | 78 | serviceFile := fmt.Sprintf("%s%s/%s.service", basePath, baseSystemdPath, serviceName) | 79 | serviceFile := fmt.Sprintf("%s%s/%s.service", basePath, baseSystemdPath, serviceName) |
144 | 79 | ExecCommand(c, "sudo", "chmod", "a+w", fmt.Sprintf("%s%s", basePath, baseSystemdPath)) | 80 | cli.ExecCommand(c, "sudo", "chmod", "a+w", fmt.Sprintf("%s%s", basePath, baseSystemdPath)) |
145 | 80 | ExecCommandToFile(c, serviceFile, "sudo", "echo", serviceCfg) | 81 | cli.ExecCommandToFile(c, serviceFile, "sudo", "echo", serviceCfg) |
146 | 81 | 82 | ||
147 | 82 | // Create requires directory | 83 | // Create requires directory |
148 | 83 | requiresDirPart := fmt.Sprintf("%s/%s", baseSystemdPath, systemdTargetRequiresDir) | 84 | requiresDirPart := fmt.Sprintf("%s/%s", baseSystemdPath, systemdTargetRequiresDir) |
149 | 84 | requiresDir := fmt.Sprintf("%s%s", basePath, requiresDirPart) | 85 | requiresDir := fmt.Sprintf("%s%s", basePath, requiresDirPart) |
151 | 85 | ExecCommand(c, "sudo", "mkdir", "-p", requiresDir) | 86 | cli.ExecCommand(c, "sudo", "mkdir", "-p", requiresDir) |
152 | 86 | 87 | ||
153 | 87 | // Symlink from the requires dir to the service file (with chroot for being | 88 | // Symlink from the requires dir to the service file (with chroot for being |
154 | 88 | // usable in the other partition) | 89 | // usable in the other partition) |
156 | 89 | ExecCommand(c, "sudo", "chroot", basePath, "ln", "-s", | 90 | cli.ExecCommand(c, "sudo", "chroot", basePath, "ln", "-s", |
157 | 90 | fmt.Sprintf("%s/%s.service", baseSystemdPath, serviceName), | 91 | fmt.Sprintf("%s/%s.service", baseSystemdPath, serviceName), |
158 | 91 | fmt.Sprintf("%s/%s.service", requiresDirPart, serviceName), | 92 | fmt.Sprintf("%s/%s.service", requiresDirPart, serviceName), |
159 | 92 | ) | 93 | ) |
160 | 93 | } | 94 | } |
161 | 94 | 95 | ||
162 | 95 | func unInstallService(c *check.C, serviceName, basePath string) { | 96 | func unInstallService(c *check.C, serviceName, basePath string) { |
165 | 96 | MakeWritable(c, basePath) | 97 | common.MakeWritable(c, basePath) |
166 | 97 | defer MakeReadonly(c, basePath) | 98 | defer common.MakeReadonly(c, basePath) |
167 | 98 | 99 | ||
168 | 99 | // Disable the service | 100 | // Disable the service |
170 | 100 | ExecCommand(c, "sudo", "chroot", basePath, | 101 | cli.ExecCommand(c, "sudo", "chroot", basePath, |
171 | 101 | "systemctl", "disable", fmt.Sprintf("%s.service", serviceName)) | 102 | "systemctl", "disable", fmt.Sprintf("%s.service", serviceName)) |
172 | 102 | 103 | ||
173 | 103 | // Remove the service file | 104 | // Remove the service file |
175 | 104 | ExecCommand(c, "sudo", "rm", | 105 | cli.ExecCommand(c, "sudo", "rm", |
176 | 105 | fmt.Sprintf("%s%s/%s.service", basePath, baseSystemdPath, serviceName)) | 106 | fmt.Sprintf("%s%s/%s.service", basePath, baseSystemdPath, serviceName)) |
177 | 106 | 107 | ||
178 | 107 | // Remove the requires symlink | 108 | // Remove the requires symlink |
180 | 108 | ExecCommand(c, "sudo", "rm", | 109 | cli.ExecCommand(c, "sudo", "rm", |
181 | 109 | fmt.Sprintf("%s%s/%s/%s.service", basePath, baseSystemdPath, systemdTargetRequiresDir, serviceName)) | 110 | fmt.Sprintf("%s%s/%s/%s.service", basePath, baseSystemdPath, systemdTargetRequiresDir, serviceName)) |
182 | 110 | } | 111 | } |
183 | 111 | 112 | ||
184 | 112 | 113 | ||
185 | === modified file '_integration-tests/tests/failover_test.go' | |||
186 | --- _integration-tests/tests/failover_test.go 2015-07-28 04:03:52 +0000 | |||
187 | +++ _integration-tests/tests/failover_test.go 2015-10-02 10:23:57 +0000 | |||
188 | @@ -20,15 +20,15 @@ | |||
189 | 20 | package tests | 20 | package tests |
190 | 21 | 21 | ||
191 | 22 | import ( | 22 | import ( |
193 | 23 | check "gopkg.in/check.v1" | 23 | "gopkg.in/check.v1" |
194 | 24 | 24 | ||
196 | 25 | . "launchpad.net/snappy/_integration-tests/testutils/common" | 25 | "launchpad.net/snappy/_integration-tests/testutils/common" |
197 | 26 | ) | 26 | ) |
198 | 27 | 27 | ||
199 | 28 | var _ = check.Suite(&failoverSuite{}) | 28 | var _ = check.Suite(&failoverSuite{}) |
200 | 29 | 29 | ||
201 | 30 | type failoverSuite struct { | 30 | type failoverSuite struct { |
203 | 31 | SnappySuite | 31 | common.SnappySuite |
204 | 32 | } | 32 | } |
205 | 33 | 33 | ||
206 | 34 | // The types that implement this interface can be used in the test logic | 34 | // The types that implement this interface can be used in the test logic |
207 | @@ -43,16 +43,16 @@ | |||
208 | 43 | // type implementing the failer interface and call this function with an instance | 43 | // type implementing the failer interface and call this function with an instance |
209 | 44 | // of it | 44 | // of it |
210 | 45 | func commonFailoverTest(c *check.C, f failer) { | 45 | func commonFailoverTest(c *check.C, f failer) { |
212 | 46 | currentVersion := GetCurrentUbuntuCoreVersion(c) | 46 | currentVersion := common.GetCurrentUbuntuCoreVersion(c) |
213 | 47 | 47 | ||
216 | 48 | if AfterReboot(c) { | 48 | if common.AfterReboot(c) { |
217 | 49 | RemoveRebootMark(c) | 49 | common.RemoveRebootMark(c) |
218 | 50 | f.unset(c) | 50 | f.unset(c) |
220 | 51 | c.Assert(GetSavedVersion(c), check.Equals, currentVersion) | 51 | c.Assert(common.GetSavedVersion(c), check.Equals, currentVersion) |
221 | 52 | } else { | 52 | } else { |
224 | 53 | SetSavedVersion(c, currentVersion-1) | 53 | common.SetSavedVersion(c, currentVersion-1) |
225 | 54 | CallFakeUpdate(c) | 54 | common.CallFakeUpdate(c) |
226 | 55 | f.set(c) | 55 | f.set(c) |
228 | 56 | Reboot(c) | 56 | common.Reboot(c) |
229 | 57 | } | 57 | } |
230 | 58 | } | 58 | } |
231 | 59 | 59 | ||
232 | === modified file '_integration-tests/tests/failover_zero_size_file_test.go' | |||
233 | --- _integration-tests/tests/failover_zero_size_file_test.go 2015-09-25 14:35:29 +0000 | |||
234 | +++ _integration-tests/tests/failover_zero_size_file_test.go 2015-10-02 10:23:57 +0000 | |||
235 | @@ -25,7 +25,8 @@ | |||
236 | 25 | "path/filepath" | 25 | "path/filepath" |
237 | 26 | "strings" | 26 | "strings" |
238 | 27 | 27 | ||
240 | 28 | . "launchpad.net/snappy/_integration-tests/testutils/common" | 28 | "launchpad.net/snappy/_integration-tests/testutils/cli" |
241 | 29 | "launchpad.net/snappy/_integration-tests/testutils/common" | ||
242 | 29 | "launchpad.net/snappy/_integration-tests/testutils/partition" | 30 | "launchpad.net/snappy/_integration-tests/testutils/partition" |
243 | 30 | 31 | ||
244 | 31 | "gopkg.in/check.v1" | 32 | "gopkg.in/check.v1" |
245 | @@ -45,11 +46,11 @@ | |||
246 | 45 | type zeroSizeSystemd struct{} | 46 | type zeroSizeSystemd struct{} |
247 | 46 | 47 | ||
248 | 47 | func (zeroSizeKernel) set(c *check.C) { | 48 | func (zeroSizeKernel) set(c *check.C) { |
250 | 48 | commonSet(c, BaseAltPartitionPath, origBootFilenamePattern, kernelFilename) | 49 | commonSet(c, common.BaseAltPartitionPath, origBootFilenamePattern, kernelFilename) |
251 | 49 | } | 50 | } |
252 | 50 | 51 | ||
253 | 51 | func (zeroSizeKernel) unset(c *check.C) { | 52 | func (zeroSizeKernel) unset(c *check.C) { |
255 | 52 | commonUnset(c, BaseAltPartitionPath, origBootFilenamePattern, kernelFilename) | 53 | commonUnset(c, common.BaseAltPartitionPath, origBootFilenamePattern, kernelFilename) |
256 | 53 | } | 54 | } |
257 | 54 | 55 | ||
258 | 55 | func (zeroSizeInitrd) set(c *check.C) { | 56 | func (zeroSizeInitrd) set(c *check.C) { |
259 | @@ -71,11 +72,11 @@ | |||
260 | 71 | } | 72 | } |
261 | 72 | 73 | ||
262 | 73 | func (zeroSizeSystemd) set(c *check.C) { | 74 | func (zeroSizeSystemd) set(c *check.C) { |
264 | 74 | commonSet(c, BaseAltPartitionPath, origSystemdFilenamePattern, systemdFilename) | 75 | commonSet(c, common.BaseAltPartitionPath, origSystemdFilenamePattern, systemdFilename) |
265 | 75 | } | 76 | } |
266 | 76 | 77 | ||
267 | 77 | func (zeroSizeSystemd) unset(c *check.C) { | 78 | func (zeroSizeSystemd) unset(c *check.C) { |
269 | 78 | commonUnset(c, BaseAltPartitionPath, origSystemdFilenamePattern, systemdFilename) | 79 | commonUnset(c, common.BaseAltPartitionPath, origSystemdFilenamePattern, systemdFilename) |
270 | 79 | } | 80 | } |
271 | 80 | 81 | ||
272 | 81 | func commonSet(c *check.C, baseOtherPath, origPattern, filename string) { | 82 | func commonSet(c *check.C, baseOtherPath, origPattern, filename string) { |
273 | @@ -105,17 +106,17 @@ | |||
274 | 105 | func renameFile(c *check.C, basePath, oldFilename, newFilename string, keepOld bool) { | 106 | func renameFile(c *check.C, basePath, oldFilename, newFilename string, keepOld bool) { |
275 | 106 | // Only need to make writable and revert for BaseAltPartitionPath, | 107 | // Only need to make writable and revert for BaseAltPartitionPath, |
276 | 107 | // kernel files' boot directory is writable | 108 | // kernel files' boot directory is writable |
280 | 108 | if basePath == BaseAltPartitionPath { | 109 | if basePath == common.BaseAltPartitionPath { |
281 | 109 | MakeWritable(c, basePath) | 110 | common.MakeWritable(c, basePath) |
282 | 110 | defer MakeReadonly(c, basePath) | 111 | defer common.MakeReadonly(c, basePath) |
283 | 111 | } | 112 | } |
284 | 112 | 113 | ||
286 | 113 | ExecCommand(c, "sudo", "mv", oldFilename, newFilename) | 114 | cli.ExecCommand(c, "sudo", "mv", oldFilename, newFilename) |
287 | 114 | 115 | ||
288 | 115 | if keepOld { | 116 | if keepOld { |
290 | 116 | ExecCommand(c, "sudo", "touch", oldFilename) | 117 | cli.ExecCommand(c, "sudo", "touch", oldFilename) |
291 | 117 | mode := getFileMode(c, newFilename) | 118 | mode := getFileMode(c, newFilename) |
293 | 118 | ExecCommand(c, "sudo", "chmod", fmt.Sprintf("%o", mode), oldFilename) | 119 | cli.ExecCommand(c, "sudo", "chmod", fmt.Sprintf("%o", mode), oldFilename) |
294 | 119 | } | 120 | } |
295 | 120 | } | 121 | } |
296 | 121 | 122 | ||
297 | 122 | 123 | ||
298 | === modified file '_integration-tests/tests/helloDbus_test.go' | |||
299 | --- _integration-tests/tests/helloDbus_test.go 2015-09-11 08:47:39 +0000 | |||
300 | +++ _integration-tests/tests/helloDbus_test.go 2015-10-02 10:23:57 +0000 | |||
301 | @@ -20,6 +20,7 @@ | |||
302 | 20 | package tests | 20 | package tests |
303 | 21 | 21 | ||
304 | 22 | import ( | 22 | import ( |
305 | 23 | "launchpad.net/snappy/_integration-tests/testutils/cli" | ||
306 | 23 | "launchpad.net/snappy/_integration-tests/testutils/common" | 24 | "launchpad.net/snappy/_integration-tests/testutils/common" |
307 | 24 | 25 | ||
308 | 25 | "gopkg.in/check.v1" | 26 | "gopkg.in/check.v1" |
309 | @@ -38,7 +39,7 @@ | |||
310 | 38 | common.InstallSnap(c, "hello-dbus-app.canonical") | 39 | common.InstallSnap(c, "hello-dbus-app.canonical") |
311 | 39 | defer common.RemoveSnap(c, "hello-dbus-app.canonical") | 40 | defer common.RemoveSnap(c, "hello-dbus-app.canonical") |
312 | 40 | 41 | ||
314 | 41 | output := common.ExecCommand(c, "hello-dbus-app.client") | 42 | output := cli.ExecCommand(c, "hello-dbus-app.client") |
315 | 42 | 43 | ||
316 | 43 | expected := "PASS\n" | 44 | expected := "PASS\n" |
317 | 44 | 45 | ||
318 | 45 | 46 | ||
319 | === modified file '_integration-tests/tests/info_test.go' | |||
320 | --- _integration-tests/tests/info_test.go 2015-07-31 07:55:33 +0000 | |||
321 | +++ _integration-tests/tests/info_test.go 2015-10-02 10:23:57 +0000 | |||
322 | @@ -22,41 +22,42 @@ | |||
323 | 22 | import ( | 22 | import ( |
324 | 23 | "fmt" | 23 | "fmt" |
325 | 24 | 24 | ||
327 | 25 | . "launchpad.net/snappy/_integration-tests/testutils/common" | 25 | "launchpad.net/snappy/_integration-tests/testutils/cli" |
328 | 26 | "launchpad.net/snappy/_integration-tests/testutils/common" | ||
329 | 26 | 27 | ||
331 | 27 | check "gopkg.in/check.v1" | 28 | "gopkg.in/check.v1" |
332 | 28 | ) | 29 | ) |
333 | 29 | 30 | ||
334 | 30 | var _ = check.Suite(&infoSuite{}) | 31 | var _ = check.Suite(&infoSuite{}) |
335 | 31 | 32 | ||
336 | 32 | type infoSuite struct { | 33 | type infoSuite struct { |
338 | 33 | SnappySuite | 34 | common.SnappySuite |
339 | 34 | } | 35 | } |
340 | 35 | 36 | ||
341 | 36 | func (s *infoSuite) TestInfoMustPrintReleaseAndChannel(c *check.C) { | 37 | func (s *infoSuite) TestInfoMustPrintReleaseAndChannel(c *check.C) { |
342 | 37 | // skip test when having a remote testbed (we can't know which the | 38 | // skip test when having a remote testbed (we can't know which the |
343 | 38 | // release and channels are) | 39 | // release and channels are) |
345 | 39 | if Cfg.RemoteTestbed { | 40 | if common.Cfg.RemoteTestbed { |
346 | 40 | c.Skip(fmt.Sprintf( | 41 | c.Skip(fmt.Sprintf( |
347 | 41 | "Skipping %s while testing in remote testbed", | 42 | "Skipping %s while testing in remote testbed", |
348 | 42 | c.TestName())) | 43 | c.TestName())) |
349 | 43 | } | 44 | } |
350 | 44 | 45 | ||
352 | 45 | infoOutput := ExecCommand(c, "snappy", "info") | 46 | infoOutput := cli.ExecCommand(c, "snappy", "info") |
353 | 46 | 47 | ||
354 | 47 | expected := "(?ms)" + | 48 | expected := "(?ms)" + |
356 | 48 | fmt.Sprintf("^release: ubuntu-core/%s/%s\n", Cfg.Release, Cfg.Channel) + | 49 | fmt.Sprintf("^release: ubuntu-core/%s/%s\n", common.Cfg.Release, common.Cfg.Channel) + |
357 | 49 | ".*" | 50 | ".*" |
358 | 50 | 51 | ||
359 | 51 | c.Assert(infoOutput, check.Matches, expected) | 52 | c.Assert(infoOutput, check.Matches, expected) |
360 | 52 | } | 53 | } |
361 | 53 | 54 | ||
362 | 54 | func (s *infoSuite) TestInfoMustPrintInstalledApps(c *check.C) { | 55 | func (s *infoSuite) TestInfoMustPrintInstalledApps(c *check.C) { |
364 | 55 | InstallSnap(c, "hello-world") | 56 | common.InstallSnap(c, "hello-world") |
365 | 56 | s.AddCleanup(func() { | 57 | s.AddCleanup(func() { |
367 | 57 | RemoveSnap(c, "hello-world") | 58 | common.RemoveSnap(c, "hello-world") |
368 | 58 | }) | 59 | }) |
370 | 59 | infoOutput := ExecCommand(c, "snappy", "info") | 60 | infoOutput := cli.ExecCommand(c, "snappy", "info") |
371 | 60 | 61 | ||
372 | 61 | expected := "(?ms)" + | 62 | expected := "(?ms)" + |
373 | 62 | ".*" + | 63 | ".*" + |
374 | @@ -65,11 +66,11 @@ | |||
375 | 65 | } | 66 | } |
376 | 66 | 67 | ||
377 | 67 | func (s *infoSuite) TestInfoMustPrintInstalledFrameworks(c *check.C) { | 68 | func (s *infoSuite) TestInfoMustPrintInstalledFrameworks(c *check.C) { |
379 | 68 | InstallSnap(c, "hello-dbus-fwk.canonical") | 69 | common.InstallSnap(c, "hello-dbus-fwk.canonical") |
380 | 69 | s.AddCleanup(func() { | 70 | s.AddCleanup(func() { |
382 | 70 | RemoveSnap(c, "hello-dbus-fwk.canonical") | 71 | common.RemoveSnap(c, "hello-dbus-fwk.canonical") |
383 | 71 | }) | 72 | }) |
385 | 72 | infoOutput := ExecCommand(c, "snappy", "info") | 73 | infoOutput := cli.ExecCommand(c, "snappy", "info") |
386 | 73 | 74 | ||
387 | 74 | expected := "(?ms)" + | 75 | expected := "(?ms)" + |
388 | 75 | ".*" + | 76 | ".*" + |
389 | 76 | 77 | ||
390 | === modified file '_integration-tests/tests/installApp_test.go' | |||
391 | --- _integration-tests/tests/installApp_test.go 2015-09-24 19:51:26 +0000 | |||
392 | +++ _integration-tests/tests/installApp_test.go 2015-10-02 10:23:57 +0000 | |||
393 | @@ -23,10 +23,11 @@ | |||
394 | 23 | "net/http" | 23 | "net/http" |
395 | 24 | "os/exec" | 24 | "os/exec" |
396 | 25 | 25 | ||
397 | 26 | "launchpad.net/snappy/_integration-tests/testutils/cli" | ||
398 | 26 | "launchpad.net/snappy/_integration-tests/testutils/common" | 27 | "launchpad.net/snappy/_integration-tests/testutils/common" |
399 | 27 | "launchpad.net/snappy/_integration-tests/testutils/wait" | 28 | "launchpad.net/snappy/_integration-tests/testutils/wait" |
400 | 28 | 29 | ||
402 | 29 | check "gopkg.in/check.v1" | 30 | "gopkg.in/check.v1" |
403 | 30 | ) | 31 | ) |
404 | 31 | 32 | ||
405 | 32 | var _ = check.Suite(&installAppSuite{}) | 33 | var _ = check.Suite(&installAppSuite{}) |
406 | @@ -57,7 +58,7 @@ | |||
407 | 57 | common.RemoveSnap(c, "hello-world") | 58 | common.RemoveSnap(c, "hello-world") |
408 | 58 | }) | 59 | }) |
409 | 59 | 60 | ||
411 | 60 | echoOutput := common.ExecCommand(c, "hello-world.echo") | 61 | echoOutput := cli.ExecCommand(c, "hello-world.echo") |
412 | 61 | 62 | ||
413 | 62 | c.Assert(echoOutput, check.Equals, "Hello World!\n") | 63 | c.Assert(echoOutput, check.Equals, "Hello World!\n") |
414 | 63 | } | 64 | } |
415 | @@ -89,7 +90,7 @@ | |||
416 | 89 | common.RemoveSnap(c, "hello-world") | 90 | common.RemoveSnap(c, "hello-world") |
417 | 90 | }) | 91 | }) |
418 | 91 | 92 | ||
420 | 92 | infoOutput := common.ExecCommand(c, "snappy", "info") | 93 | infoOutput := cli.ExecCommand(c, "snappy", "info") |
421 | 93 | 94 | ||
422 | 94 | expected := "(?ms).*^apps: hello-world.canonical\n" | 95 | expected := "(?ms).*^apps: hello-world.canonical\n" |
423 | 95 | c.Assert(infoOutput, check.Matches, expected) | 96 | c.Assert(infoOutput, check.Matches, expected) |
424 | 96 | 97 | ||
425 | === modified file '_integration-tests/tests/installFramework_test.go' | |||
426 | --- _integration-tests/tests/installFramework_test.go 2015-09-03 10:46:21 +0000 | |||
427 | +++ _integration-tests/tests/installFramework_test.go 2015-10-02 10:23:57 +0000 | |||
428 | @@ -23,10 +23,11 @@ | |||
429 | 23 | "fmt" | 23 | "fmt" |
430 | 24 | "regexp" | 24 | "regexp" |
431 | 25 | 25 | ||
432 | 26 | "launchpad.net/snappy/_integration-tests/testutils/cli" | ||
433 | 26 | "launchpad.net/snappy/_integration-tests/testutils/common" | 27 | "launchpad.net/snappy/_integration-tests/testutils/common" |
434 | 27 | "launchpad.net/snappy/_integration-tests/testutils/wait" | 28 | "launchpad.net/snappy/_integration-tests/testutils/wait" |
435 | 28 | 29 | ||
437 | 29 | check "gopkg.in/check.v1" | 30 | "gopkg.in/check.v1" |
438 | 30 | ) | 31 | ) |
439 | 31 | 32 | ||
440 | 32 | var _ = check.Suite(&installFrameworkSuite{}) | 33 | var _ = check.Suite(&installFrameworkSuite{}) |
441 | @@ -50,7 +51,7 @@ | |||
442 | 50 | err := wait.ForActiveService(c, dockerService) | 51 | err := wait.ForActiveService(c, dockerService) |
443 | 51 | c.Assert(err, check.IsNil) | 52 | c.Assert(err, check.IsNil) |
444 | 52 | 53 | ||
446 | 53 | statusOutput := common.ExecCommand( | 54 | statusOutput := cli.ExecCommand( |
447 | 54 | c, "systemctl", "status", | 55 | c, "systemctl", "status", |
448 | 55 | dockerService) | 56 | dockerService) |
449 | 56 | 57 | ||
450 | 57 | 58 | ||
451 | === modified file '_integration-tests/tests/list_test.go' | |||
452 | --- _integration-tests/tests/list_test.go 2015-07-28 04:03:52 +0000 | |||
453 | +++ _integration-tests/tests/list_test.go 2015-10-02 10:23:57 +0000 | |||
454 | @@ -23,16 +23,17 @@ | |||
455 | 23 | "fmt" | 23 | "fmt" |
456 | 24 | "os" | 24 | "os" |
457 | 25 | 25 | ||
459 | 26 | . "launchpad.net/snappy/_integration-tests/testutils/common" | 26 | "launchpad.net/snappy/_integration-tests/testutils/cli" |
460 | 27 | "launchpad.net/snappy/_integration-tests/testutils/common" | ||
461 | 27 | 28 | ||
462 | 28 | "github.com/mvo5/goconfigparser" | 29 | "github.com/mvo5/goconfigparser" |
464 | 29 | check "gopkg.in/check.v1" | 30 | "gopkg.in/check.v1" |
465 | 30 | ) | 31 | ) |
466 | 31 | 32 | ||
467 | 32 | var _ = check.Suite(&listSuite{}) | 33 | var _ = check.Suite(&listSuite{}) |
468 | 33 | 34 | ||
469 | 34 | type listSuite struct { | 35 | type listSuite struct { |
471 | 35 | SnappySuite | 36 | common.SnappySuite |
472 | 36 | } | 37 | } |
473 | 37 | 38 | ||
474 | 38 | func getVersionFromConfig(c *check.C) string { | 39 | func getVersionFromConfig(c *check.C) string { |
475 | @@ -51,7 +52,7 @@ | |||
476 | 51 | } | 52 | } |
477 | 52 | 53 | ||
478 | 53 | func (s *listSuite) TestListMustPrintCoreVersion(c *check.C) { | 54 | func (s *listSuite) TestListMustPrintCoreVersion(c *check.C) { |
480 | 54 | listOutput := ExecCommand(c, "snappy", "list") | 55 | listOutput := cli.ExecCommand(c, "snappy", "list") |
481 | 55 | 56 | ||
482 | 56 | expected := "(?ms)" + | 57 | expected := "(?ms)" + |
483 | 57 | "Name +Date +Version +Developer *\n" + | 58 | "Name +Date +Version +Developer *\n" + |
484 | @@ -62,12 +63,12 @@ | |||
485 | 62 | } | 63 | } |
486 | 63 | 64 | ||
487 | 64 | func (s *listSuite) TestListMustPrintAppVersion(c *check.C) { | 65 | func (s *listSuite) TestListMustPrintAppVersion(c *check.C) { |
489 | 65 | InstallSnap(c, "hello-world") | 66 | common.InstallSnap(c, "hello-world") |
490 | 66 | s.AddCleanup(func() { | 67 | s.AddCleanup(func() { |
492 | 67 | RemoveSnap(c, "hello-world") | 68 | common.RemoveSnap(c, "hello-world") |
493 | 68 | }) | 69 | }) |
494 | 69 | 70 | ||
496 | 70 | listOutput := ExecCommand(c, "snappy", "list") | 71 | listOutput := cli.ExecCommand(c, "snappy", "list") |
497 | 71 | expected := "(?ms)" + | 72 | expected := "(?ms)" + |
498 | 72 | "Name +Date +Version +Developer *\n" + | 73 | "Name +Date +Version +Developer *\n" + |
499 | 73 | ".*" + | 74 | ".*" + |
500 | 74 | 75 | ||
501 | === modified file '_integration-tests/tests/rollback_test.go' | |||
502 | --- _integration-tests/tests/rollback_test.go 2015-10-01 14:40:47 +0000 | |||
503 | +++ _integration-tests/tests/rollback_test.go 2015-10-02 10:23:57 +0000 | |||
504 | @@ -22,37 +22,38 @@ | |||
505 | 22 | import ( | 22 | import ( |
506 | 23 | "strconv" | 23 | "strconv" |
507 | 24 | 24 | ||
509 | 25 | . "launchpad.net/snappy/_integration-tests/testutils/common" | 25 | "launchpad.net/snappy/_integration-tests/testutils/cli" |
510 | 26 | "launchpad.net/snappy/_integration-tests/testutils/common" | ||
511 | 26 | "launchpad.net/snappy/_integration-tests/testutils/partition" | 27 | "launchpad.net/snappy/_integration-tests/testutils/partition" |
512 | 27 | "launchpad.net/snappy/_integration-tests/testutils/wait" | 28 | "launchpad.net/snappy/_integration-tests/testutils/wait" |
513 | 28 | 29 | ||
515 | 29 | check "gopkg.in/check.v1" | 30 | "gopkg.in/check.v1" |
516 | 30 | ) | 31 | ) |
517 | 31 | 32 | ||
518 | 32 | var _ = check.Suite(&rollbackSuite{}) | 33 | var _ = check.Suite(&rollbackSuite{}) |
519 | 33 | 34 | ||
520 | 34 | type rollbackSuite struct { | 35 | type rollbackSuite struct { |
522 | 35 | SnappySuite | 36 | common.SnappySuite |
523 | 36 | } | 37 | } |
524 | 37 | 38 | ||
525 | 38 | func (s *rollbackSuite) TestRollbackMustRebootToOtherVersion(c *check.C) { | 39 | func (s *rollbackSuite) TestRollbackMustRebootToOtherVersion(c *check.C) { |
531 | 39 | if BeforeReboot() { | 40 | if common.BeforeReboot() { |
532 | 40 | CallFakeUpdate(c) | 41 | common.CallFakeUpdate(c) |
533 | 41 | Reboot(c) | 42 | common.Reboot(c) |
534 | 42 | } else if CheckRebootMark(c.TestName()) { | 43 | } else if common.CheckRebootMark(c.TestName()) { |
535 | 43 | RemoveRebootMark(c) | 44 | common.RemoveRebootMark(c) |
536 | 44 | // Workaround for bug https://bugs.launchpad.net/snappy/+bug/1498293 | 45 | // Workaround for bug https://bugs.launchpad.net/snappy/+bug/1498293 |
537 | 45 | // TODO remove once the bug is fixed. --elopio - 2015-09-30 | 46 | // TODO remove once the bug is fixed. --elopio - 2015-09-30 |
538 | 46 | wait.ForFunction(c, "regular", partition.Mode) | 47 | wait.ForFunction(c, "regular", partition.Mode) |
547 | 47 | currentVersion := GetCurrentUbuntuCoreVersion(c) | 48 | currentVersion := common.GetCurrentUbuntuCoreVersion(c) |
548 | 48 | c.Assert(currentVersion > GetSavedVersion(c), check.Equals, true) | 49 | c.Assert(currentVersion > common.GetSavedVersion(c), check.Equals, true) |
549 | 49 | ExecCommand(c, "sudo", "snappy", "rollback", "ubuntu-core", | 50 | cli.ExecCommand(c, "sudo", "snappy", "rollback", "ubuntu-core", |
550 | 50 | strconv.Itoa(GetSavedVersion(c))) | 51 | strconv.Itoa(common.GetSavedVersion(c))) |
551 | 51 | SetSavedVersion(c, currentVersion) | 52 | common.SetSavedVersion(c, currentVersion) |
552 | 52 | RebootWithMark(c, c.TestName()+"-rollback") | 53 | common.RebootWithMark(c, c.TestName()+"-rollback") |
553 | 53 | } else if CheckRebootMark(c.TestName() + "-rollback") { | 54 | } else if common.CheckRebootMark(c.TestName() + "-rollback") { |
554 | 54 | RemoveRebootMark(c) | 55 | common.RemoveRebootMark(c) |
555 | 55 | c.Assert( | 56 | c.Assert( |
557 | 56 | GetCurrentUbuntuCoreVersion(c) < GetSavedVersion(c), check.Equals, true) | 57 | common.GetCurrentUbuntuCoreVersion(c) < common.GetSavedVersion(c), check.Equals, true) |
558 | 57 | } | 58 | } |
559 | 58 | } | 59 | } |
560 | 59 | 60 | ||
561 | === modified file '_integration-tests/tests/search_test.go' | |||
562 | --- _integration-tests/tests/search_test.go 2015-07-28 04:03:52 +0000 | |||
563 | +++ _integration-tests/tests/search_test.go 2015-10-02 10:23:57 +0000 | |||
564 | @@ -20,19 +20,20 @@ | |||
565 | 20 | package tests | 20 | package tests |
566 | 21 | 21 | ||
567 | 22 | import ( | 22 | import ( |
569 | 23 | . "launchpad.net/snappy/_integration-tests/testutils/common" | 23 | "launchpad.net/snappy/_integration-tests/testutils/cli" |
570 | 24 | "launchpad.net/snappy/_integration-tests/testutils/common" | ||
571 | 24 | 25 | ||
573 | 25 | . "gopkg.in/check.v1" | 26 | "gopkg.in/check.v1" |
574 | 26 | ) | 27 | ) |
575 | 27 | 28 | ||
577 | 28 | var _ = Suite(&searchSuite{}) | 29 | var _ = check.Suite(&searchSuite{}) |
578 | 29 | 30 | ||
579 | 30 | type searchSuite struct { | 31 | type searchSuite struct { |
581 | 31 | SnappySuite | 32 | common.SnappySuite |
582 | 32 | } | 33 | } |
583 | 33 | 34 | ||
586 | 34 | func (s *searchSuite) TestSearchFrameworkMustPrintMatch(c *C) { | 35 | func (s *searchSuite) TestSearchFrameworkMustPrintMatch(c *check.C) { |
587 | 35 | searchOutput := ExecCommand(c, "snappy", "search", "hello-dbus-fwk") | 36 | searchOutput := cli.ExecCommand(c, "snappy", "search", "hello-dbus-fwk") |
588 | 36 | 37 | ||
589 | 37 | expected := "(?ms)" + | 38 | expected := "(?ms)" + |
590 | 38 | "Name +Version +Summary *\n" + | 39 | "Name +Version +Summary *\n" + |
591 | @@ -40,5 +41,5 @@ | |||
592 | 40 | "^hello-dbus-fwk +.* +hello-dbus-fwk *\n" + | 41 | "^hello-dbus-fwk +.* +hello-dbus-fwk *\n" + |
593 | 41 | ".*" | 42 | ".*" |
594 | 42 | 43 | ||
596 | 43 | c.Assert(searchOutput, Matches, expected) | 44 | c.Assert(searchOutput, check.Matches, expected) |
597 | 44 | } | 45 | } |
598 | 45 | 46 | ||
599 | === modified file '_integration-tests/tests/ubuntuFan_test.go' | |||
600 | --- _integration-tests/tests/ubuntuFan_test.go 2015-09-24 21:06:01 +0000 | |||
601 | +++ _integration-tests/tests/ubuntuFan_test.go 2015-10-02 10:23:57 +0000 | |||
602 | @@ -25,6 +25,7 @@ | |||
603 | 25 | "os/exec" | 25 | "os/exec" |
604 | 26 | "strings" | 26 | "strings" |
605 | 27 | 27 | ||
606 | 28 | "launchpad.net/snappy/_integration-tests/testutils/cli" | ||
607 | 28 | "launchpad.net/snappy/_integration-tests/testutils/common" | 29 | "launchpad.net/snappy/_integration-tests/testutils/common" |
608 | 29 | "launchpad.net/snappy/_integration-tests/testutils/wait" | 30 | "launchpad.net/snappy/_integration-tests/testutils/wait" |
609 | 30 | 31 | ||
610 | @@ -75,7 +76,7 @@ | |||
611 | 75 | } | 76 | } |
612 | 76 | 77 | ||
613 | 77 | func (s *fanTestSuite) TestFanCommandCreatesFanBridge(c *check.C) { | 78 | func (s *fanTestSuite) TestFanCommandCreatesFanBridge(c *check.C) { |
615 | 78 | output := common.ExecCommand(c, "ifconfig") | 79 | output := cli.ExecCommand(c, "ifconfig") |
616 | 79 | 80 | ||
617 | 80 | expectedPattern := fmt.Sprintf("(?msi).*%s.*%s.*", s.fanName(), s.bridgeIP) | 81 | expectedPattern := fmt.Sprintf("(?msi).*%s.*%s.*", s.fanName(), s.bridgeIP) |
618 | 81 | 82 | ||
619 | @@ -89,7 +90,7 @@ | |||
620 | 89 | s.configureDockerToUseBridge(c) | 90 | s.configureDockerToUseBridge(c) |
621 | 90 | defer s.removeBridgeFromDockerConf(c) | 91 | defer s.removeBridgeFromDockerConf(c) |
622 | 91 | 92 | ||
624 | 92 | output := common.ExecCommand(c, "docker", "run", "-t", baseContainer, "ifconfig") | 93 | output := cli.ExecCommand(c, "docker", "run", "-t", baseContainer, "ifconfig") |
625 | 93 | 94 | ||
626 | 94 | expectedIP := strings.TrimRight(s.bridgeIP, ".1") + ".2" | 95 | expectedIP := strings.TrimRight(s.bridgeIP, ".1") + ".2" |
627 | 95 | expectedPattern := fmt.Sprintf("(?ms).*inet addr:%s.*", expectedIP) | 96 | expectedPattern := fmt.Sprintf("(?ms).*inet addr:%s.*", expectedIP) |
628 | @@ -105,12 +106,12 @@ | |||
629 | 105 | defer s.removeBridgeFromDockerConf(c) | 106 | defer s.removeBridgeFromDockerConf(c) |
630 | 106 | 107 | ||
631 | 107 | // spin up first container | 108 | // spin up first container |
633 | 108 | common.ExecCommand(c, "docker", "run", "-d", "-t", baseContainer) | 109 | cli.ExecCommand(c, "docker", "run", "-d", "-t", baseContainer) |
634 | 109 | // the first assigned IP in the fan will end with ".2" | 110 | // the first assigned IP in the fan will end with ".2" |
635 | 110 | firstIPAddr := strings.TrimRight(s.bridgeIP, ".1") + ".2" | 111 | firstIPAddr := strings.TrimRight(s.bridgeIP, ".1") + ".2" |
636 | 111 | 112 | ||
637 | 112 | // ping from a second container | 113 | // ping from a second container |
639 | 113 | output := common.ExecCommand(c, "docker", "run", "-t", baseContainer, "ping", firstIPAddr, "-c", "1") | 114 | output := cli.ExecCommand(c, "docker", "run", "-t", baseContainer, "ping", firstIPAddr, "-c", "1") |
640 | 114 | 115 | ||
641 | 115 | expectedPattern := "(?ms).*1 packets transmitted, 1 packets received, 0% packet loss.*" | 116 | expectedPattern := "(?ms).*1 packets transmitted, 1 packets received, 0% packet loss.*" |
642 | 116 | 117 | ||
643 | @@ -142,14 +143,14 @@ | |||
644 | 142 | } | 143 | } |
645 | 143 | 144 | ||
646 | 144 | func (s *fanTestSuite) fanCtl(c *check.C, cmd string) string { | 145 | func (s *fanTestSuite) fanCtl(c *check.C, cmd string) string { |
648 | 145 | return common.ExecCommand(c, | 146 | return cli.ExecCommand(c, |
649 | 146 | "sudo", "fanctl", cmd, firstOverlaySegment+".0.0.0/8", s.subjectIP+"/16") | 147 | "sudo", "fanctl", cmd, firstOverlaySegment+".0.0.0/8", s.subjectIP+"/16") |
650 | 147 | } | 148 | } |
651 | 148 | 149 | ||
652 | 149 | func (s *fanTestSuite) configureDockerToUseBridge(c *check.C) { | 150 | func (s *fanTestSuite) configureDockerToUseBridge(c *check.C) { |
653 | 150 | cfgFile := dockerCfgFile(c) | 151 | cfgFile := dockerCfgFile(c) |
654 | 151 | 152 | ||
656 | 152 | common.ExecCommand(c, "sudo", "sed", "-i", | 153 | cli.ExecCommand(c, "sudo", "sed", "-i", |
657 | 153 | fmt.Sprintf(`s/DOCKER_OPTIONS=\"\"/DOCKER_OPTIONS=\"%s\"/`, s.dockerOptions()), | 154 | fmt.Sprintf(`s/DOCKER_OPTIONS=\"\"/DOCKER_OPTIONS=\"%s\"/`, s.dockerOptions()), |
658 | 154 | cfgFile) | 155 | cfgFile) |
659 | 155 | 156 | ||
660 | @@ -159,7 +160,7 @@ | |||
661 | 159 | func (s *fanTestSuite) removeBridgeFromDockerConf(c *check.C) { | 160 | func (s *fanTestSuite) removeBridgeFromDockerConf(c *check.C) { |
662 | 160 | cfgFile := dockerCfgFile(c) | 161 | cfgFile := dockerCfgFile(c) |
663 | 161 | 162 | ||
665 | 162 | common.ExecCommand(c, "sudo", "sed", "-i", | 163 | cli.ExecCommand(c, "sudo", "sed", "-i", |
666 | 163 | `s/DOCKER_OPTIONS=\".*\"/DOCKER_OPTIONS=\"\"/`, | 164 | `s/DOCKER_OPTIONS=\".*\"/DOCKER_OPTIONS=\"\"/`, |
667 | 164 | cfgFile) | 165 | cfgFile) |
668 | 165 | 166 | ||
669 | @@ -175,7 +176,7 @@ | |||
670 | 175 | dockerVersion := common.GetCurrentVersion(c, "docker") | 176 | dockerVersion := common.GetCurrentVersion(c, "docker") |
671 | 176 | dockerService := fmt.Sprintf("docker_docker-daemon_%s.service", dockerVersion) | 177 | dockerService := fmt.Sprintf("docker_docker-daemon_%s.service", dockerVersion) |
672 | 177 | 178 | ||
674 | 178 | common.ExecCommand(c, "sudo", "systemctl", "restart", dockerService) | 179 | cli.ExecCommand(c, "sudo", "systemctl", "restart", dockerService) |
675 | 179 | 180 | ||
676 | 180 | // we need to wait until the socket is ready, an active systemctl status is not enough | 181 | // we need to wait until the socket is ready, an active systemctl status is not enough |
677 | 181 | err := wait.ForCommand(c, `(?ms).*docker\.sock\s.*`, "ls", "/run") | 182 | err := wait.ForCommand(c, `(?ms).*docker\.sock\s.*`, "ls", "/run") |
678 | @@ -199,7 +200,7 @@ | |||
679 | 199 | err := wait.ForActiveService(c, dockerService) | 200 | err := wait.ForActiveService(c, dockerService) |
680 | 200 | c.Assert(err, check.IsNil) | 201 | c.Assert(err, check.IsNil) |
681 | 201 | 202 | ||
683 | 202 | common.ExecCommand(c, "docker", "pull", baseContainer) | 203 | cli.ExecCommand(c, "docker", "pull", baseContainer) |
684 | 203 | } | 204 | } |
685 | 204 | 205 | ||
686 | 205 | func tearDownDocker(c *check.C) { | 206 | func tearDownDocker(c *check.C) { |
687 | 206 | 207 | ||
688 | === modified file '_integration-tests/tests/update_test.go' | |||
689 | --- _integration-tests/tests/update_test.go 2015-09-10 15:55:23 +0000 | |||
690 | +++ _integration-tests/tests/update_test.go 2015-10-02 10:23:57 +0000 | |||
691 | @@ -23,7 +23,7 @@ | |||
692 | 23 | "io/ioutil" | 23 | "io/ioutil" |
693 | 24 | "path" | 24 | "path" |
694 | 25 | 25 | ||
696 | 26 | . "launchpad.net/snappy/_integration-tests/testutils/common" | 26 | "launchpad.net/snappy/_integration-tests/testutils/common" |
697 | 27 | "launchpad.net/snappy/_integration-tests/testutils/partition" | 27 | "launchpad.net/snappy/_integration-tests/testutils/partition" |
698 | 28 | 28 | ||
699 | 29 | "gopkg.in/check.v1" | 29 | "gopkg.in/check.v1" |
700 | @@ -32,7 +32,7 @@ | |||
701 | 32 | var _ = check.Suite(&updateSuite{}) | 32 | var _ = check.Suite(&updateSuite{}) |
702 | 33 | 33 | ||
703 | 34 | type updateSuite struct { | 34 | type updateSuite struct { |
705 | 35 | SnappySuite | 35 | common.SnappySuite |
706 | 36 | } | 36 | } |
707 | 37 | 37 | ||
708 | 38 | func (s *updateSuite) assertBootDirContents(c *check.C) { | 38 | func (s *updateSuite) assertBootDirContents(c *check.C) { |
709 | @@ -62,17 +62,17 @@ | |||
710 | 62 | // modified to fake an update. If there is a version available, the image will | 62 | // modified to fake an update. If there is a version available, the image will |
711 | 63 | // be up-to-date after running this test. | 63 | // be up-to-date after running this test. |
712 | 64 | func (s *updateSuite) TestUpdateToSameReleaseAndChannel(c *check.C) { | 64 | func (s *updateSuite) TestUpdateToSameReleaseAndChannel(c *check.C) { |
715 | 65 | if BeforeReboot() { | 65 | if common.BeforeReboot() { |
716 | 66 | updateOutput := CallFakeUpdate(c) | 66 | updateOutput := common.CallFakeUpdate(c) |
717 | 67 | expected := "(?ms)" + | 67 | expected := "(?ms)" + |
718 | 68 | ".*" + | 68 | ".*" + |
719 | 69 | "^Reboot to use .*ubuntu-core.\n" | 69 | "^Reboot to use .*ubuntu-core.\n" |
720 | 70 | c.Assert(updateOutput, check.Matches, expected) | 70 | c.Assert(updateOutput, check.Matches, expected) |
721 | 71 | s.assertBootDirContents(c) | 71 | s.assertBootDirContents(c) |
726 | 72 | Reboot(c) | 72 | common.Reboot(c) |
727 | 73 | } else if AfterReboot(c) { | 73 | } else if common.AfterReboot(c) { |
728 | 74 | RemoveRebootMark(c) | 74 | common.RemoveRebootMark(c) |
729 | 75 | c.Assert(GetCurrentUbuntuCoreVersion(c) > GetSavedVersion(c), | 75 | c.Assert(common.GetCurrentUbuntuCoreVersion(c) > common.GetSavedVersion(c), |
730 | 76 | check.Equals, true) | 76 | check.Equals, true) |
731 | 77 | } | 77 | } |
732 | 78 | } | 78 | } |
733 | 79 | 79 | ||
734 | === modified file '_integration-tests/tests/writablePaths_test.go' | |||
735 | --- _integration-tests/tests/writablePaths_test.go 2015-07-28 04:03:52 +0000 | |||
736 | +++ _integration-tests/tests/writablePaths_test.go 2015-10-02 10:23:57 +0000 | |||
737 | @@ -27,9 +27,9 @@ | |||
738 | 27 | "path/filepath" | 27 | "path/filepath" |
739 | 28 | "strings" | 28 | "strings" |
740 | 29 | 29 | ||
742 | 30 | . "launchpad.net/snappy/_integration-tests/testutils/common" | 30 | "launchpad.net/snappy/_integration-tests/testutils/common" |
743 | 31 | 31 | ||
745 | 32 | check "gopkg.in/check.v1" | 32 | "gopkg.in/check.v1" |
746 | 33 | ) | 33 | ) |
747 | 34 | 34 | ||
748 | 35 | const writablePathsListFile = "/etc/system-image/writable-paths" | 35 | const writablePathsListFile = "/etc/system-image/writable-paths" |
749 | @@ -37,7 +37,7 @@ | |||
750 | 37 | var _ = check.Suite(&writablePathsSuite{}) | 37 | var _ = check.Suite(&writablePathsSuite{}) |
751 | 38 | 38 | ||
752 | 39 | type writablePathsSuite struct { | 39 | type writablePathsSuite struct { |
754 | 40 | SnappySuite | 40 | common.SnappySuite |
755 | 41 | } | 41 | } |
756 | 42 | 42 | ||
757 | 43 | var IsWritable check.Checker = &isWritable{} | 43 | var IsWritable check.Checker = &isWritable{} |
758 | 44 | 44 | ||
759 | === modified file '_integration-tests/testutils/build/snap.go' | |||
760 | --- _integration-tests/testutils/build/snap.go 2015-09-28 10:35:06 +0000 | |||
761 | +++ _integration-tests/testutils/build/snap.go 2015-10-02 10:23:57 +0000 | |||
762 | @@ -24,7 +24,7 @@ | |||
763 | 24 | "path/filepath" | 24 | "path/filepath" |
764 | 25 | 25 | ||
765 | 26 | "gopkg.in/check.v1" | 26 | "gopkg.in/check.v1" |
767 | 27 | "launchpad.net/snappy/_integration-tests/testutils/common" | 27 | "launchpad.net/snappy/_integration-tests/testutils/cli" |
768 | 28 | ) | 28 | ) |
769 | 29 | 29 | ||
770 | 30 | const ( | 30 | const ( |
771 | @@ -42,11 +42,11 @@ | |||
772 | 42 | 42 | ||
773 | 43 | var ( | 43 | var ( |
774 | 44 | // dependency aliasing | 44 | // dependency aliasing |
776 | 45 | commonExecCommand = common.ExecCommand | 45 | cliExecCommand = cli.ExecCommand |
777 | 46 | ) | 46 | ) |
778 | 47 | 47 | ||
779 | 48 | func buildSnap(c *check.C, snapPath string) string { | 48 | func buildSnap(c *check.C, snapPath string) string { |
781 | 49 | return commonExecCommand(c, "snappy", "build", snapPath, "-o", snapPath) | 49 | return cliExecCommand(c, "snappy", "build", snapPath, "-o", snapPath) |
782 | 50 | } | 50 | } |
783 | 51 | 51 | ||
784 | 52 | // LocalSnap issues the command to build a snap and returns the path of the generated file | 52 | // LocalSnap issues the command to build a snap and returns the path of the generated file |
785 | 53 | 53 | ||
786 | === modified file '_integration-tests/testutils/build/snap_test.go' | |||
787 | --- _integration-tests/testutils/build/snap_test.go 2015-09-28 10:44:44 +0000 | |||
788 | +++ _integration-tests/testutils/build/snap_test.go 2015-10-02 10:23:57 +0000 | |||
789 | @@ -37,13 +37,13 @@ | |||
790 | 37 | var _ = check.Suite(&snapBuildTestSuite{}) | 37 | var _ = check.Suite(&snapBuildTestSuite{}) |
791 | 38 | 38 | ||
792 | 39 | func (s *snapBuildTestSuite) SetUpSuite(c *check.C) { | 39 | func (s *snapBuildTestSuite) SetUpSuite(c *check.C) { |
795 | 40 | s.backExecCommand = commonExecCommand | 40 | s.backExecCommand = cliExecCommand |
796 | 41 | commonExecCommand = s.fakeExecCommand | 41 | cliExecCommand = s.fakeExecCommand |
797 | 42 | s.defaultSnapName = "mySnapName" | 42 | s.defaultSnapName = "mySnapName" |
798 | 43 | } | 43 | } |
799 | 44 | 44 | ||
800 | 45 | func (s *snapBuildTestSuite) TearDownSuite(c *check.C) { | 45 | func (s *snapBuildTestSuite) TearDownSuite(c *check.C) { |
802 | 46 | commonExecCommand = s.backExecCommand | 46 | cliExecCommand = s.backExecCommand |
803 | 47 | } | 47 | } |
804 | 48 | 48 | ||
805 | 49 | func (s *snapBuildTestSuite) SetUpTest(c *check.C) { | 49 | func (s *snapBuildTestSuite) SetUpTest(c *check.C) { |
806 | 50 | 50 | ||
807 | === added directory '_integration-tests/testutils/cli' | |||
808 | === added file '_integration-tests/testutils/cli/cli.go' | |||
809 | --- _integration-tests/testutils/cli/cli.go 1970-01-01 00:00:00 +0000 | |||
810 | +++ _integration-tests/testutils/cli/cli.go 2015-10-02 10:23:57 +0000 | |||
811 | @@ -0,0 +1,57 @@ | |||
812 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
813 | 2 | |||
814 | 3 | /* | ||
815 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
816 | 5 | * | ||
817 | 6 | * This program is free software: you can redistribute it and/or modify | ||
818 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
819 | 8 | * published by the Free Software Foundation. | ||
820 | 9 | * | ||
821 | 10 | * This program is distributed in the hope that it will be useful, | ||
822 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
823 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
824 | 13 | * GNU General Public License for more details. | ||
825 | 14 | * | ||
826 | 15 | * You should have received a copy of the GNU General Public License | ||
827 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
828 | 17 | * | ||
829 | 18 | */ | ||
830 | 19 | |||
831 | 20 | package cli | ||
832 | 21 | |||
833 | 22 | import ( | ||
834 | 23 | "fmt" | ||
835 | 24 | "os" | ||
836 | 25 | "os/exec" | ||
837 | 26 | "strings" | ||
838 | 27 | |||
839 | 28 | "gopkg.in/check.v1" | ||
840 | 29 | ) | ||
841 | 30 | |||
842 | 31 | var execCommand = exec.Command | ||
843 | 32 | |||
844 | 33 | // ExecCommand executes a shell command and returns a string with the output | ||
845 | 34 | // of the command. In case of error, it will fail the test. | ||
846 | 35 | func ExecCommand(c *check.C, cmds ...string) string { | ||
847 | 36 | fmt.Println(strings.Join(cmds, " ")) | ||
848 | 37 | cmd := execCommand(cmds[0], cmds[1:len(cmds)]...) | ||
849 | 38 | output, err := cmd.CombinedOutput() | ||
850 | 39 | stringOutput := string(output) | ||
851 | 40 | fmt.Print(stringOutput) | ||
852 | 41 | c.Assert(err, check.IsNil, check.Commentf("Error: %v", stringOutput)) | ||
853 | 42 | return stringOutput | ||
854 | 43 | } | ||
855 | 44 | |||
856 | 45 | // ExecCommandToFile executes a shell command and saves the output of the | ||
857 | 46 | // command to a file. In case of error, it will fail the test. | ||
858 | 47 | func ExecCommandToFile(c *check.C, filename string, cmds ...string) { | ||
859 | 48 | cmd := execCommand(cmds[0], cmds[1:len(cmds)]...) | ||
860 | 49 | outfile, err := os.Create(filename) | ||
861 | 50 | c.Assert(err, check.IsNil, check.Commentf("Error creating output file %s", filename)) | ||
862 | 51 | |||
863 | 52 | defer outfile.Close() | ||
864 | 53 | cmd.Stdout = outfile | ||
865 | 54 | |||
866 | 55 | err = cmd.Run() | ||
867 | 56 | c.Assert(err, check.IsNil, check.Commentf("Error executing command '%v': %v", cmds, err)) | ||
868 | 57 | } | ||
869 | 0 | 58 | ||
870 | === added file '_integration-tests/testutils/cli/cli_test.go' | |||
871 | --- _integration-tests/testutils/cli/cli_test.go 1970-01-01 00:00:00 +0000 | |||
872 | +++ _integration-tests/testutils/cli/cli_test.go 2015-10-02 10:23:57 +0000 | |||
873 | @@ -0,0 +1,85 @@ | |||
874 | 1 | // -*- Mode: Go; indent-tabs-mode: t -*- | ||
875 | 2 | |||
876 | 3 | /* | ||
877 | 4 | * Copyright (C) 2015 Canonical Ltd | ||
878 | 5 | * | ||
879 | 6 | * This program is free software: you can redistribute it and/or modify | ||
880 | 7 | * it under the terms of the GNU General Public License version 3 as | ||
881 | 8 | * published by the Free Software Foundation. | ||
882 | 9 | * | ||
883 | 10 | * This program is distributed in the hope that it will be useful, | ||
884 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
885 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
886 | 13 | * GNU General Public License for more details. | ||
887 | 14 | * | ||
888 | 15 | * You should have received a copy of the GNU General Public License | ||
889 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
890 | 17 | * | ||
891 | 18 | */ | ||
892 | 19 | |||
893 | 20 | package cli | ||
894 | 21 | |||
895 | 22 | import ( | ||
896 | 23 | "fmt" | ||
897 | 24 | "io/ioutil" | ||
898 | 25 | "os" | ||
899 | 26 | "os/exec" | ||
900 | 27 | "testing" | ||
901 | 28 | |||
902 | 29 | "gopkg.in/check.v1" | ||
903 | 30 | ) | ||
904 | 31 | |||
905 | 32 | const execOutput = "myoutput" | ||
906 | 33 | |||
907 | 34 | // Hook up check.v1 into the "go test" runner | ||
908 | 35 | func Test(t *testing.T) { check.TestingT(t) } | ||
909 | 36 | |||
910 | 37 | type cliTestSuite struct { | ||
911 | 38 | backExecCommand func(string, ...string) *exec.Cmd | ||
912 | 39 | } | ||
913 | 40 | |||
914 | 41 | var _ = check.Suite(&cliTestSuite{}) | ||
915 | 42 | |||
916 | 43 | func (s *cliTestSuite) SetUpSuite(c *check.C) { | ||
917 | 44 | s.backExecCommand = execCommand | ||
918 | 45 | execCommand = s.fakeExecCommand | ||
919 | 46 | } | ||
920 | 47 | |||
921 | 48 | func (s *cliTestSuite) TearDownSuite(c *check.C) { | ||
922 | 49 | execCommand = s.backExecCommand | ||
923 | 50 | } | ||
924 | 51 | |||
925 | 52 | func (s *cliTestSuite) fakeExecCommand(command string, args ...string) *exec.Cmd { | ||
926 | 53 | cs := []string{"-check.f=cliTestSuite.TestHelperProcess", "--", command} | ||
927 | 54 | cs = append(cs, args...) | ||
928 | 55 | cmd := exec.Command(os.Args[0], cs...) | ||
929 | 56 | cmd.Env = []string{"GO_WANT_HELPER_PROCESS=1"} | ||
930 | 57 | return cmd | ||
931 | 58 | } | ||
932 | 59 | |||
933 | 60 | func (s *cliTestSuite) TestHelperProcess(c *check.C) { | ||
934 | 61 | if os.Getenv("GO_WANT_HELPER_PROCESS") != "1" { | ||
935 | 62 | return | ||
936 | 63 | } | ||
937 | 64 | fmt.Fprintf(os.Stdout, execOutput) | ||
938 | 65 | os.Exit(0) | ||
939 | 66 | } | ||
940 | 67 | |||
941 | 68 | func (s *cliTestSuite) TestExecCommand(c *check.C) { | ||
942 | 69 | actualOutput := ExecCommand(c, "mycmd") | ||
943 | 70 | |||
944 | 71 | c.Assert(actualOutput, check.Equals, execOutput) | ||
945 | 72 | } | ||
946 | 73 | |||
947 | 74 | func (s *cliTestSuite) TestExecCommandToFile(c *check.C) { | ||
948 | 75 | outputFile, err := ioutil.TempFile("", "snappy-exec") | ||
949 | 76 | c.Assert(err, check.IsNil) | ||
950 | 77 | outputFile.Close() | ||
951 | 78 | defer os.Remove(outputFile.Name()) | ||
952 | 79 | |||
953 | 80 | ExecCommandToFile(c, outputFile.Name(), "mycmd") | ||
954 | 81 | |||
955 | 82 | actualFileContents, err := ioutil.ReadFile(outputFile.Name()) | ||
956 | 83 | c.Assert(err, check.IsNil) | ||
957 | 84 | c.Assert(string(actualFileContents), check.Equals, execOutput) | ||
958 | 85 | } | ||
959 | 0 | 86 | ||
960 | === modified file '_integration-tests/testutils/common/common.go' | |||
961 | --- _integration-tests/testutils/common/common.go 2015-09-28 14:42:52 +0000 | |||
962 | +++ _integration-tests/testutils/common/common.go 2015-10-02 10:23:57 +0000 | |||
963 | @@ -23,7 +23,6 @@ | |||
964 | 23 | "fmt" | 23 | "fmt" |
965 | 24 | "io/ioutil" | 24 | "io/ioutil" |
966 | 25 | "os" | 25 | "os" |
967 | 26 | "os/exec" | ||
968 | 27 | "path/filepath" | 26 | "path/filepath" |
969 | 28 | "regexp" | 27 | "regexp" |
970 | 29 | "strconv" | 28 | "strconv" |
971 | @@ -31,6 +30,7 @@ | |||
972 | 31 | 30 | ||
973 | 32 | "gopkg.in/check.v1" | 31 | "gopkg.in/check.v1" |
974 | 33 | 32 | ||
975 | 33 | "launchpad.net/snappy/_integration-tests/testutils/cli" | ||
976 | 34 | "launchpad.net/snappy/_integration-tests/testutils/config" | 34 | "launchpad.net/snappy/_integration-tests/testutils/config" |
977 | 35 | ) | 35 | ) |
978 | 36 | 36 | ||
979 | @@ -54,8 +54,8 @@ | |||
980 | 54 | // SetUpSuite disables the snappy autopilot. It will run before all the | 54 | // SetUpSuite disables the snappy autopilot. It will run before all the |
981 | 55 | // integration suites. | 55 | // integration suites. |
982 | 56 | func (s *SnappySuite) SetUpSuite(c *check.C) { | 56 | func (s *SnappySuite) SetUpSuite(c *check.C) { |
985 | 57 | ExecCommand(c, "sudo", "systemctl", "stop", "snappy-autopilot.timer") | 57 | cli.ExecCommand(c, "sudo", "systemctl", "stop", "snappy-autopilot.timer") |
986 | 58 | ExecCommand(c, "sudo", "systemctl", "disable", "snappy-autopilot.timer") | 58 | cli.ExecCommand(c, "sudo", "systemctl", "disable", "snappy-autopilot.timer") |
987 | 59 | var err error | 59 | var err error |
988 | 60 | Cfg, err = config.ReadConfig( | 60 | Cfg, err = config.ReadConfig( |
989 | 61 | "_integration-tests/data/output/testconfig.json") | 61 | "_integration-tests/data/output/testconfig.json") |
990 | @@ -66,7 +66,7 @@ | |||
991 | 66 | switchSystemImageConf(c, Cfg.TargetRelease, Cfg.TargetChannel, "0") | 66 | switchSystemImageConf(c, Cfg.TargetRelease, Cfg.TargetChannel, "0") |
992 | 67 | // Always use the installed snappy because we are updating from an old | 67 | // Always use the installed snappy because we are updating from an old |
993 | 68 | // image, so we should not use the snappy from the branch. | 68 | // image, so we should not use the snappy from the branch. |
995 | 69 | output := ExecCommand(c, "sudo", "/usr/bin/snappy", "update") | 69 | output := cli.ExecCommand(c, "sudo", "/usr/bin/snappy", "update") |
996 | 70 | if output != "" { | 70 | if output != "" { |
997 | 71 | RebootWithMark(c, "setupsuite-update") | 71 | RebootWithMark(c, "setupsuite-update") |
998 | 72 | } | 72 | } |
999 | @@ -77,7 +77,7 @@ | |||
1000 | 77 | Cfg.Update = false | 77 | Cfg.Update = false |
1001 | 78 | Cfg.Write() | 78 | Cfg.Write() |
1002 | 79 | if Cfg.Rollback { | 79 | if Cfg.Rollback { |
1004 | 80 | ExecCommand(c, "sudo", "snappy", "rollback", "ubuntu-core") | 80 | cli.ExecCommand(c, "sudo", "snappy", "rollback", "ubuntu-core") |
1005 | 81 | RebootWithMark(c, "setupsuite-rollback") | 81 | RebootWithMark(c, "setupsuite-rollback") |
1006 | 82 | } | 82 | } |
1007 | 83 | } else if CheckRebootMark("setupsuite-rollback") { | 83 | } else if CheckRebootMark("setupsuite-rollback") { |
1008 | @@ -131,7 +131,7 @@ | |||
1009 | 131 | defer MakeReadonly(c, target) | 131 | defer MakeReadonly(c, target) |
1010 | 132 | original := filepath.Join(target, channelCfgFile) | 132 | original := filepath.Join(target, channelCfgFile) |
1011 | 133 | c.Logf("Restoring %s...", original) | 133 | c.Logf("Restoring %s...", original) |
1013 | 134 | ExecCommand(c, "sudo", "mv", backup, original) | 134 | cli.ExecCommand(c, "sudo", "mv", backup, original) |
1014 | 135 | } | 135 | } |
1015 | 136 | } | 136 | } |
1016 | 137 | } | 137 | } |
1017 | @@ -169,12 +169,12 @@ | |||
1018 | 169 | } | 169 | } |
1019 | 170 | for value, regex := range replaceRegex { | 170 | for value, regex := range replaceRegex { |
1020 | 171 | if value != "" { | 171 | if value != "" { |
1022 | 172 | ExecCommand(c, | 172 | cli.ExecCommand(c, |
1023 | 173 | "sudo", "sed", "-i", fmt.Sprintf(regex, value), file) | 173 | "sudo", "sed", "-i", fmt.Sprintf(regex, value), file) |
1024 | 174 | } | 174 | } |
1025 | 175 | } | 175 | } |
1026 | 176 | // Leave the new file in the test log. | 176 | // Leave the new file in the test log. |
1028 | 177 | ExecCommand(c, "cat", file) | 177 | cli.ExecCommand(c, "cat", file) |
1029 | 178 | } | 178 | } |
1030 | 179 | 179 | ||
1031 | 180 | func channelCfgBackupFile() string { | 180 | func channelCfgBackupFile() string { |
1032 | @@ -185,35 +185,9 @@ | |||
1033 | 185 | return filepath.Join(os.Getenv("ADT_ARTIFACTS"), "channel.ini.other") | 185 | return filepath.Join(os.Getenv("ADT_ARTIFACTS"), "channel.ini.other") |
1034 | 186 | } | 186 | } |
1035 | 187 | 187 | ||
1036 | 188 | // ExecCommand executes a shell command and returns a string with the output | ||
1037 | 189 | // of the command. In case of error, it will fail the test. | ||
1038 | 190 | func ExecCommand(c *check.C, cmds ...string) string { | ||
1039 | 191 | fmt.Println(strings.Join(cmds, " ")) | ||
1040 | 192 | cmd := exec.Command(cmds[0], cmds[1:len(cmds)]...) | ||
1041 | 193 | output, err := cmd.CombinedOutput() | ||
1042 | 194 | stringOutput := string(output) | ||
1043 | 195 | fmt.Print(stringOutput) | ||
1044 | 196 | c.Assert(err, check.IsNil, check.Commentf("Error: %v", stringOutput)) | ||
1045 | 197 | return stringOutput | ||
1046 | 198 | } | ||
1047 | 199 | |||
1048 | 200 | // ExecCommandToFile executes a shell command and saves the output of the | ||
1049 | 201 | // command to a file. In case of error, it will fail the test. | ||
1050 | 202 | func ExecCommandToFile(c *check.C, filename string, cmds ...string) { | ||
1051 | 203 | cmd := exec.Command(cmds[0], cmds[1:len(cmds)]...) | ||
1052 | 204 | outfile, err := os.Create(filename) | ||
1053 | 205 | c.Assert(err, check.IsNil, check.Commentf("Error creating output file %s", filename)) | ||
1054 | 206 | |||
1055 | 207 | defer outfile.Close() | ||
1056 | 208 | cmd.Stdout = outfile | ||
1057 | 209 | |||
1058 | 210 | err = cmd.Run() | ||
1059 | 211 | c.Assert(err, check.IsNil, check.Commentf("Error executing command '%v': %v", cmds, err)) | ||
1060 | 212 | } | ||
1061 | 213 | |||
1062 | 214 | // GetCurrentVersion returns the version of the installed and active package. | 188 | // GetCurrentVersion returns the version of the installed and active package. |
1063 | 215 | func GetCurrentVersion(c *check.C, packageName string) string { | 189 | func GetCurrentVersion(c *check.C, packageName string) string { |
1065 | 216 | output := ExecCommand(c, "snappy", "list") | 190 | output := cli.ExecCommand(c, "snappy", "list") |
1066 | 217 | pattern := "(?mU)^" + packageName + " +(.*)$" | 191 | pattern := "(?mU)^" + packageName + " +(.*)$" |
1067 | 218 | re := regexp.MustCompile(pattern) | 192 | re := regexp.MustCompile(pattern) |
1068 | 219 | match := re.FindStringSubmatch(string(output)) | 193 | match := re.FindStringSubmatch(string(output)) |
1069 | @@ -237,7 +211,7 @@ | |||
1070 | 237 | func CallFakeUpdate(c *check.C) string { | 211 | func CallFakeUpdate(c *check.C) string { |
1071 | 238 | c.Log("Preparing fake and calling update.") | 212 | c.Log("Preparing fake and calling update.") |
1072 | 239 | fakeAvailableUpdate(c) | 213 | fakeAvailableUpdate(c) |
1074 | 240 | return ExecCommand(c, "sudo", "snappy", "update") | 214 | return cli.ExecCommand(c, "sudo", "snappy", "update") |
1075 | 241 | } | 215 | } |
1076 | 242 | 216 | ||
1077 | 243 | func fakeAvailableUpdate(c *check.C) { | 217 | func fakeAvailableUpdate(c *check.C) { |
1078 | @@ -257,7 +231,7 @@ | |||
1079 | 257 | MakeWritable(c, target) | 231 | MakeWritable(c, target) |
1080 | 258 | defer MakeReadonly(c, target) | 232 | defer MakeReadonly(c, target) |
1081 | 259 | // Back up the file. It will be restored during the test tear down. | 233 | // Back up the file. It will be restored during the test tear down. |
1083 | 260 | ExecCommand(c, "cp", file, backup) | 234 | cli.ExecCommand(c, "cp", file, backup) |
1084 | 261 | replaceSystemImageValues(c, file, "", "", strconv.Itoa(newVersion)) | 235 | replaceSystemImageValues(c, file, "", "", strconv.Itoa(newVersion)) |
1085 | 262 | } | 236 | } |
1086 | 263 | } | 237 | } |
1087 | @@ -265,12 +239,12 @@ | |||
1088 | 265 | 239 | ||
1089 | 266 | // MakeWritable remounts a path with read and write permissions. | 240 | // MakeWritable remounts a path with read and write permissions. |
1090 | 267 | func MakeWritable(c *check.C, path string) { | 241 | func MakeWritable(c *check.C, path string) { |
1092 | 268 | ExecCommand(c, "sudo", "mount", "-o", "remount,rw", path) | 242 | cli.ExecCommand(c, "sudo", "mount", "-o", "remount,rw", path) |
1093 | 269 | } | 243 | } |
1094 | 270 | 244 | ||
1095 | 271 | // MakeReadonly remounts a path with only read permissions. | 245 | // MakeReadonly remounts a path with only read permissions. |
1096 | 272 | func MakeReadonly(c *check.C, path string) { | 246 | func MakeReadonly(c *check.C, path string) { |
1098 | 273 | ExecCommand(c, "sudo", "mount", "-o", "remount,ro", path) | 247 | cli.ExecCommand(c, "sudo", "mount", "-o", "remount,ro", path) |
1099 | 274 | } | 248 | } |
1100 | 275 | 249 | ||
1101 | 276 | // Reboot requests a reboot using the test name as the mark. | 250 | // Reboot requests a reboot using the test name as the mark. |
1102 | @@ -346,10 +320,10 @@ | |||
1103 | 346 | 320 | ||
1104 | 347 | // InstallSnap executes the required command to install the specified snap | 321 | // InstallSnap executes the required command to install the specified snap |
1105 | 348 | func InstallSnap(c *check.C, packageName string) string { | 322 | func InstallSnap(c *check.C, packageName string) string { |
1107 | 349 | return ExecCommand(c, "sudo", "snappy", "install", packageName, "--allow-unauthenticated") | 323 | return cli.ExecCommand(c, "sudo", "snappy", "install", packageName, "--allow-unauthenticated") |
1108 | 350 | } | 324 | } |
1109 | 351 | 325 | ||
1110 | 352 | // RemoveSnap executes the required command to remove the specified snap | 326 | // RemoveSnap executes the required command to remove the specified snap |
1111 | 353 | func RemoveSnap(c *check.C, packageName string) string { | 327 | func RemoveSnap(c *check.C, packageName string) string { |
1113 | 354 | return ExecCommand(c, "sudo", "snappy", "remove", packageName) | 328 | return cli.ExecCommand(c, "sudo", "snappy", "remove", packageName) |
1114 | 355 | } | 329 | } |
1115 | 356 | 330 | ||
1116 | === modified file '_integration-tests/testutils/common/info.go' | |||
1117 | --- _integration-tests/testutils/common/info.go 2015-09-24 21:06:01 +0000 | |||
1118 | +++ _integration-tests/testutils/common/info.go 2015-10-02 10:23:57 +0000 | |||
1119 | @@ -24,10 +24,11 @@ | |||
1120 | 24 | "strings" | 24 | "strings" |
1121 | 25 | 25 | ||
1122 | 26 | "gopkg.in/check.v1" | 26 | "gopkg.in/check.v1" |
1123 | 27 | "launchpad.net/snappy/_integration-tests/testutils/cli" | ||
1124 | 27 | ) | 28 | ) |
1125 | 28 | 29 | ||
1126 | 29 | // dependency aliasing | 30 | // dependency aliasing |
1128 | 30 | var execCommand = ExecCommand | 31 | var execCommand = cli.ExecCommand |
1129 | 31 | 32 | ||
1130 | 32 | // Release returns the release of the current snappy image | 33 | // Release returns the release of the current snappy image |
1131 | 33 | func Release(c *check.C) string { | 34 | func Release(c *check.C) string { |
1132 | 34 | 35 | ||
1133 | === modified file '_integration-tests/testutils/runner/runner.go' | |||
1134 | --- _integration-tests/testutils/runner/runner.go 2015-08-12 15:50:33 +0000 | |||
1135 | +++ _integration-tests/testutils/runner/runner.go 2015-10-02 10:23:57 +0000 | |||
1136 | @@ -25,7 +25,7 @@ | |||
1137 | 25 | "strings" | 25 | "strings" |
1138 | 26 | "testing" | 26 | "testing" |
1139 | 27 | 27 | ||
1141 | 28 | check "gopkg.in/check.v1" | 28 | "gopkg.in/check.v1" |
1142 | 29 | ) | 29 | ) |
1143 | 30 | 30 | ||
1144 | 31 | var ( | 31 | var ( |
1145 | 32 | 32 | ||
1146 | === modified file '_integration-tests/testutils/wait/wait.go' | |||
1147 | --- _integration-tests/testutils/wait/wait.go 2015-09-28 10:54:40 +0000 | |||
1148 | +++ _integration-tests/testutils/wait/wait.go 2015-10-02 10:23:57 +0000 | |||
1149 | @@ -24,14 +24,14 @@ | |||
1150 | 24 | "regexp" | 24 | "regexp" |
1151 | 25 | "time" | 25 | "time" |
1152 | 26 | 26 | ||
1154 | 27 | check "gopkg.in/check.v1" | 27 | "gopkg.in/check.v1" |
1155 | 28 | 28 | ||
1157 | 29 | "launchpad.net/snappy/_integration-tests/testutils/common" | 29 | "launchpad.net/snappy/_integration-tests/testutils/cli" |
1158 | 30 | ) | 30 | ) |
1159 | 31 | 31 | ||
1160 | 32 | var ( | 32 | var ( |
1161 | 33 | // dependency aliasing | 33 | // dependency aliasing |
1163 | 34 | execCommand = common.ExecCommand | 34 | execCommand = cli.ExecCommand |
1164 | 35 | // ForCommand dep alias | 35 | // ForCommand dep alias |
1165 | 36 | ForCommand = forCommand | 36 | ForCommand = forCommand |
1166 | 37 | // ForFunction dep alias | 37 | // ForFunction dep alias |
needs a merge with trunk.
Feel free to top approve it after you get a full successful run.
Thanks!