TestDaemonRestartWithNames in the DockerDaemonSuite has been broken
since commit 72ec7cd6cc193f9054d1a58b8de244bd99c1d841. The test takes
the combined output of a `docker run` command as the ID of the created
container. This works fine so long as the command emits no warnings,
otherwise it will corrupt the ID that the test captures. Modify the test
to read the ID from the command's stdout to make the test robust to
warnings being printed.
Signed-off-by: Cory Snider <csnider@mirantis.com>
| ... | ... |
@@ -37,10 +37,16 @@ func New(t testing.TB, dockerBinary string, dockerdBinary string, ops ...daemon. |
| 37 | 37 |
// Cmd executes a docker CLI command against this daemon. |
| 38 | 38 |
// Example: d.Cmd("version") will run docker -H unix://path/to/unix.sock version
|
| 39 | 39 |
func (d *Daemon) Cmd(args ...string) (string, error) {
|
| 40 |
- result := icmd.RunCmd(d.Command(args...)) |
|
| 40 |
+ result := d.RunCmd(args...) |
|
| 41 | 41 |
return result.Combined(), result.Error |
| 42 | 42 |
} |
| 43 | 43 |
|
| 44 |
+// RunCmd executes a docker CLI command against this daemon and returns the result. |
|
| 45 |
+// Example: d.RunCmd("version") will run docker -H unix://path/to/unix.sock version
|
|
| 46 |
+func (d *Daemon) RunCmd(args ...string) *icmd.Result {
|
|
| 47 |
+ return icmd.RunCmd(d.Command(args...)) |
|
| 48 |
+} |
|
| 49 |
+ |
|
| 44 | 50 |
// Command creates a docker CLI command against this daemon, to be executed later. |
| 45 | 51 |
// Example: d.Command("version") creates a command to run "docker -H unix://path/to/unix.sock version"
|
| 46 | 52 |
func (d *Daemon) Command(args ...string) icmd.Cmd {
|
| ... | ... |
@@ -1238,9 +1238,10 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithNames(c *testing.T) {
|
| 1238 | 1238 |
assert.NilError(c, err, out) |
| 1239 | 1239 |
test2ID := strings.TrimSpace(out) |
| 1240 | 1240 |
|
| 1241 |
- out, err = s.d.Cmd("run", "-d", "--name=test3", "--link", "test2:abc", "busybox", "top")
|
|
| 1242 |
- assert.NilError(c, err) |
|
| 1243 |
- test3ID := strings.TrimSpace(out) |
|
| 1241 |
+ res := s.d.RunCmd("run", "-d", "--name=test3", "--link", "test2:abc", "busybox", "top")
|
|
| 1242 |
+ assert.NilError(c, res.Error) |
|
| 1243 |
+ // Discard any warnings about legacy links, which are emitted on stderr. |
|
| 1244 |
+ test3ID := strings.TrimSpace(res.Stdout()) |
|
| 1244 | 1245 |
|
| 1245 | 1246 |
s.d.Restart(c) |
| 1246 | 1247 |
|