TestServiceWithDefaultAddressPoolInit: avoid panic
Saw this in moby ci: > 00:22:07.582 === RUN TestServiceWithDefaultAddressPoolInit > 00:22:08.887 --- FAIL: TestServiceWithDefaultAddressPoolInit (1.30s) > 00:22:08.887 daemon.go:290: [d905878b35bb9] waiting for daemon to start > 00:22:08.887 daemon.go:322: [d905878b35bb9] daemon started > 00:22:08.888 panic: runtime error: index out of range [recovered] > 00:22:08.889 panic: runtime error: index out of range > 00:22:08.889 > 00:22:08.889 goroutine 360 [running]: > 00:22:08.889 testing.tRunner.func1(0xc42069d770) > 00:22:08.889 /usr/local/go/src/testing/testing.go:742 +0x29d > 00:22:08.890 panic(0x85d680, 0xb615f0) > 00:22:08.890 /usr/local/go/src/runtime/panic.go:502 +0x229 > 00:22:08.890 github.com/docker/docker/integration/network.TestServiceWithDefaultAddressPoolInit(0xc42069d770) > 00:22:08.891 /go/src/github.com/docker/docker/integration/network/service_test.go:348 +0xb53 > ..... Apparently `out.IPAM.Config[0]` is not there, so to avoid panic, let's check the size of `out.IPAM.Config` first. Fixes:f7ad95cab9
[v2: add logging of data returned by NetworkInspect()] [v3: use assert.Assert to fail immediately] Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> (cherry picked from commit69d3a8936b
) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
e988001872
commit
f43fc6650c
1 changed files with 2 additions and 0 deletions
|
@ -345,6 +345,8 @@ func TestServiceWithDefaultAddressPoolInit(t *testing.T) {
|
|||
|
||||
out, err := cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
t.Logf("%s: NetworkInspect: %+v", t.Name(), out)
|
||||
assert.Assert(t, len(out.IPAM.Config) > 0)
|
||||
assert.Equal(t, out.IPAM.Config[0].Subnet, "20.20.0.0/24")
|
||||
|
||||
err = cli.ServiceRemove(context.Background(), serviceID)
|
||||
|
|
Loading…
Add table
Reference in a new issue