1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Test: Replace NewClient() with NewClientT()

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2018-12-22 15:53:02 +01:00
parent 2cb26cfe9c
commit 2cb7b73a1b
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
19 changed files with 200 additions and 241 deletions

View file

@ -67,8 +67,7 @@ func (d *Daemon) CheckServiceUpdateState(service string) func(*check.C) (interfa
// CheckPluginRunning returns the runtime state of the plugin
func (d *Daemon) CheckPluginRunning(plugin string) func(c *check.C) (interface{}, check.CommentInterface) {
return func(c *check.C) (interface{}, check.CommentInterface) {
apiclient, err := d.NewClient()
assert.NilError(c, err)
apiclient := d.NewClientT(c)
resp, _, err := apiclient.PluginInspectWithRaw(context.Background(), plugin)
if client.IsErrNotFound(err) {
return false, check.Commentf("%v", err)
@ -81,8 +80,7 @@ func (d *Daemon) CheckPluginRunning(plugin string) func(c *check.C) (interface{}
// CheckPluginImage returns the runtime state of the plugin
func (d *Daemon) CheckPluginImage(plugin string) func(c *check.C) (interface{}, check.CommentInterface) {
return func(c *check.C) (interface{}, check.CommentInterface) {
apiclient, err := d.NewClient()
assert.NilError(c, err)
apiclient := d.NewClientT(c)
resp, _, err := apiclient.PluginInspectWithRaw(context.Background(), plugin)
if client.IsErrNotFound(err) {
return false, check.Commentf("%v", err)
@ -102,8 +100,7 @@ func (d *Daemon) CheckServiceTasks(service string) func(*check.C) (interface{},
// CheckRunningTaskNetworks returns the number of times each network is referenced from a task.
func (d *Daemon) CheckRunningTaskNetworks(c *check.C) (interface{}, check.CommentInterface) {
cli, err := d.NewClient()
c.Assert(err, checker.IsNil)
cli := d.NewClientT(c)
defer cli.Close()
filterArgs := filters.NewArgs()
@ -127,8 +124,7 @@ func (d *Daemon) CheckRunningTaskNetworks(c *check.C) (interface{}, check.Commen
// CheckRunningTaskImages returns the times each image is running as a task.
func (d *Daemon) CheckRunningTaskImages(c *check.C) (interface{}, check.CommentInterface) {
cli, err := d.NewClient()
c.Assert(err, checker.IsNil)
cli := d.NewClientT(c)
defer cli.Close()
filterArgs := filters.NewArgs()
@ -177,8 +173,7 @@ func (d *Daemon) CheckControlAvailable(c *check.C) (interface{}, check.CommentIn
// CheckLeader returns whether there is a leader on the swarm or not
func (d *Daemon) CheckLeader(c *check.C) (interface{}, check.CommentInterface) {
cli, err := d.NewClient()
c.Assert(err, checker.IsNil)
cli := d.NewClientT(c)
defer cli.Close()
errList := check.Commentf("could not get node list")

View file

@ -66,20 +66,19 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesCreate(c *check.C) {
id := d.CreateService(c, simpleTestService, setInstances(instances))
waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, instances)
cli, err := d.NewClient()
c.Assert(err, checker.IsNil)
defer cli.Close()
client := d.NewClientT(c)
defer client.Close()
options := types.ServiceInspectOptions{InsertDefaults: true}
// insertDefaults inserts UpdateConfig when service is fetched by ID
resp, _, err := cli.ServiceInspectWithRaw(context.Background(), id, options)
resp, _, err := client.ServiceInspectWithRaw(context.Background(), id, options)
out := fmt.Sprintf("%+v", resp)
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, "UpdateConfig")
// insertDefaults inserts UpdateConfig when service is fetched by ID
resp, _, err = cli.ServiceInspectWithRaw(context.Background(), "top", options)
resp, _, err = client.ServiceInspectWithRaw(context.Background(), "top", options)
out = fmt.Sprintf("%+v", resp)
c.Assert(err, checker.IsNil)
c.Assert(string(out), checker.Contains, "UpdateConfig")

View file

@ -377,13 +377,12 @@ func (s *DockerSwarmSuite) TestAPISwarmRaftQuorum(c *check.C) {
var service swarm.Service
simpleTestService(&service)
service.Spec.Name = "top2"
cli, err := d1.NewClient()
c.Assert(err, checker.IsNil)
cli := d1.NewClientT(c)
defer cli.Close()
// d1 will eventually step down from leader because there is no longer an active quorum, wait for that to happen
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
_, err = cli.ServiceCreate(context.Background(), service.Spec, types.ServiceCreateOptions{})
_, err := cli.ServiceCreate(context.Background(), service.Spec, types.ServiceCreateOptions{})
return err.Error(), nil
}, checker.Contains, "Make sure more than half of the managers are online.")
@ -849,10 +848,9 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesUpdateWithName(c *check.C) {
instances = 5
setInstances(instances)(service)
cli, err := d.NewClient()
c.Assert(err, checker.IsNil)
cli := d.NewClientT(c)
defer cli.Close()
_, err = cli.ServiceUpdate(context.Background(), service.Spec.Name, service.Version, service.Spec, types.ServiceUpdateOptions{})
_, err := cli.ServiceUpdate(context.Background(), service.Spec.Name, service.Version, service.Spec, types.ServiceUpdateOptions{})
c.Assert(err, checker.IsNil)
waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, instances)
}
@ -884,8 +882,7 @@ func (s *DockerSwarmSuite) TestAPISwarmErrorHandling(c *check.C) {
// This test makes sure the fixes correctly output scopes instead.
func (s *DockerSwarmSuite) TestAPIDuplicateNetworks(c *check.C) {
d := s.AddDaemon(c, true, true)
cli, err := d.NewClient()
c.Assert(err, checker.IsNil)
cli := d.NewClientT(c)
defer cli.Close()
name := "foo"
@ -1014,8 +1011,7 @@ func (s *DockerSwarmSuite) TestAPINetworkInspectWithScope(c *check.C) {
name := "test-scoped-network"
ctx := context.Background()
apiclient, err := d.NewClient()
assert.NilError(c, err)
apiclient := d.NewClientT(c)
resp, err := apiclient.NetworkCreate(ctx, name, types.NetworkCreate{Driver: "overlay"})
assert.NilError(c, err)

View file

@ -425,8 +425,7 @@ func (s *DockerSwarmSuite) TestOverlayAttachableOnSwarmLeave(c *check.C) {
c.Assert(err, checker.IsNil, check.Commentf("%s", out))
// Leave the swarm
err = d.SwarmLeave(true)
c.Assert(err, checker.IsNil)
c.Assert(d.SwarmLeave(true), checker.IsNil)
// Check the container is disconnected
out, err = d.Cmd("inspect", "c1", "--format", "{{.NetworkSettings.Networks."+nwName+"}}")
@ -1612,8 +1611,7 @@ func (s *DockerSwarmSuite) TestNetworkInspectWithDuplicateNames(c *check.C) {
Driver: "bridge",
}
cli, err := d.NewClient()
c.Assert(err, checker.IsNil)
cli := d.NewClientT(c)
defer cli.Close()
n1, err := cli.NetworkCreate(context.Background(), name, options)

View file

@ -36,18 +36,17 @@ func TestContainerStartOnDaemonRestart(t *testing.T) {
d.StartWithBusybox(t, "--iptables=false")
defer d.Stop(t)
client, err := d.NewClient()
assert.Check(t, err, "error creating client")
c := d.NewClientT(t)
ctx := context.Background()
cID := container.Create(t, ctx, client)
defer client.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true})
cID := container.Create(t, ctx, c)
defer c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true})
err = client.ContainerStart(ctx, cID, types.ContainerStartOptions{})
err := c.ContainerStart(ctx, cID, types.ContainerStartOptions{})
assert.Check(t, err, "error starting test container")
inspect, err := client.ContainerInspect(ctx, cID)
inspect, err := c.ContainerInspect(ctx, cID)
assert.Check(t, err, "error getting inspect data")
ppid := getContainerdShimPid(t, inspect)
@ -63,7 +62,7 @@ func TestContainerStartOnDaemonRestart(t *testing.T) {
d.Start(t, "--iptables=false")
err = client.ContainerStart(ctx, cID, types.ContainerStartOptions{})
err = c.ContainerStart(ctx, cID, types.ContainerStartOptions{})
assert.Check(t, err, "failed to start test container")
}

View file

@ -62,17 +62,16 @@ func TestExportContainerAfterDaemonRestart(t *testing.T) {
skip.If(t, testEnv.IsRemoteDaemon())
d := daemon.New(t)
client, err := d.NewClient()
assert.NilError(t, err)
c := d.NewClientT(t)
d.StartWithBusybox(t)
defer d.Stop(t)
ctx := context.Background()
ctrID := container.Create(t, ctx, client)
ctrID := container.Create(t, ctx, c)
d.Restart(t)
_, err = client.ContainerExport(ctx, ctrID)
_, err := c.ContainerExport(ctx, ctrID)
assert.NilError(t, err)
}

View file

@ -228,8 +228,7 @@ func testDaemonIpcPrivateShareable(t *testing.T, mustBeShared bool, arg ...strin
d.StartWithBusybox(t, arg...)
defer d.Stop(t)
client, err := d.NewClient()
assert.Check(t, err, "error creating client")
c := d.NewClientT(t)
cfg := containertypes.Config{
Image: "busybox",
@ -237,16 +236,16 @@ func testDaemonIpcPrivateShareable(t *testing.T, mustBeShared bool, arg ...strin
}
ctx := context.Background()
resp, err := client.ContainerCreate(ctx, &cfg, &containertypes.HostConfig{}, nil, "")
resp, err := c.ContainerCreate(ctx, &cfg, &containertypes.HostConfig{}, nil, "")
assert.NilError(t, err)
assert.Check(t, is.Equal(len(resp.Warnings), 0))
err = client.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{})
err = c.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{})
assert.NilError(t, err)
// get major:minor pair for /dev/shm from container's /proc/self/mountinfo
cmd := "awk '($5 == \"/dev/shm\") {printf $3}' /proc/self/mountinfo"
result, err := container.Exec(ctx, client, resp.ID, []string{"sh", "-c", cmd})
result, err := container.Exec(ctx, c, resp.ID, []string{"sh", "-c", cmd})
assert.NilError(t, err)
mm := result.Combined()
assert.Check(t, is.Equal(true, regexp.MustCompile("^[0-9]+:[0-9]+$").MatchString(mm)))

View file

@ -26,7 +26,7 @@ func TestDaemonRestartKillContainers(t *testing.T) {
xStart bool
}
for _, c := range []testCase{
for _, tc := range []testCase{
{
desc: "container without restart policy",
config: &container.Config{Image: "busybox", Cmd: []string{"top"}},
@ -57,16 +57,15 @@ func TestDaemonRestartKillContainers(t *testing.T) {
d.Stop(t)
},
} {
t.Run(fmt.Sprintf("live-restore=%v/%s/%s", liveRestoreEnabled, c.desc, fnName), func(t *testing.T) {
c := c
t.Run(fmt.Sprintf("live-restore=%v/%s/%s", liveRestoreEnabled, tc.desc, fnName), func(t *testing.T) {
c := tc
liveRestoreEnabled := liveRestoreEnabled
stopDaemon := stopDaemon
t.Parallel()
d := daemon.New(t)
client, err := d.NewClient()
assert.NilError(t, err)
client := d.NewClientT(t)
args := []string{"--iptables=false"}
if liveRestoreEnabled {

View file

@ -32,19 +32,18 @@ func TestDockerNetworkIpvlanPersistance(t *testing.T) {
n.CreateMasterDummy(t, master)
defer n.DeleteInterface(t, master)
client, err := d.NewClient()
assert.NilError(t, err)
c := d.NewClientT(t)
// create a network specifying the desired sub-interface name
netName := "di-persist"
net.CreateNoError(t, context.Background(), client, netName,
net.CreateNoError(t, context.Background(), c, netName,
net.WithIPvlan("di-dummy0.70", ""),
)
assert.Check(t, n.IsNetworkAvailable(client, netName))
assert.Check(t, n.IsNetworkAvailable(c, netName))
// Restart docker daemon to test the config has persisted to disk
d.Restart(t)
assert.Check(t, n.IsNetworkAvailable(client, netName))
assert.Check(t, n.IsNetworkAvailable(c, netName))
}
func TestDockerNetworkIpvlan(t *testing.T) {
@ -87,11 +86,9 @@ func TestDockerNetworkIpvlan(t *testing.T) {
} {
d := daemon.New(t, daemon.WithExperimental)
d.StartWithBusybox(t)
c := d.NewClientT(t)
client, err := d.NewClient()
assert.NilError(t, err)
t.Run(tc.name, tc.test(client))
t.Run(tc.name, tc.test(c))
d.Stop(t)
// FIXME(vdemeester) clean network

View file

@ -30,16 +30,15 @@ func TestDockerNetworkMacvlanPersistance(t *testing.T) {
n.CreateMasterDummy(t, master)
defer n.DeleteInterface(t, master)
client, err := d.NewClient()
assert.NilError(t, err)
c := d.NewClientT(t)
netName := "dm-persist"
net.CreateNoError(t, context.Background(), client, netName,
net.CreateNoError(t, context.Background(), c, netName,
net.WithMacvlan("dm-dummy0.60"),
)
assert.Check(t, n.IsNetworkAvailable(client, netName))
assert.Check(t, n.IsNetworkAvailable(c, netName))
d.Restart(t)
assert.Check(t, n.IsNetworkAvailable(client, netName))
assert.Check(t, n.IsNetworkAvailable(c, netName))
}
func TestDockerNetworkMacvlan(t *testing.T) {
@ -69,11 +68,9 @@ func TestDockerNetworkMacvlan(t *testing.T) {
} {
d := daemon.New(t)
d.StartWithBusybox(t)
c := d.NewClientT(t)
client, err := d.NewClient()
assert.NilError(t, err)
t.Run(tc.name, tc.test(client))
t.Run(tc.name, tc.test(c))
d.Stop(t)
// FIXME(vdemeester) clean network

View file

@ -26,21 +26,20 @@ func TestRunContainerWithBridgeNone(t *testing.T) {
d.StartWithBusybox(t, "-b", "none")
defer d.Stop(t)
client, err := d.NewClient()
assert.Check(t, err, "error creating client")
c := d.NewClientT(t)
ctx := context.Background()
id1 := container.Run(t, ctx, client)
defer client.ContainerRemove(ctx, id1, types.ContainerRemoveOptions{Force: true})
result, err := container.Exec(ctx, client, id1, []string{"ip", "l"})
id1 := container.Run(t, ctx, c)
defer c.ContainerRemove(ctx, id1, types.ContainerRemoveOptions{Force: true})
result, err := container.Exec(ctx, c, id1, []string{"ip", "l"})
assert.NilError(t, err)
assert.Check(t, is.Equal(false, strings.Contains(result.Combined(), "eth0")), "There shouldn't be eth0 in container in default(bridge) mode when bridge network is disabled")
id2 := container.Run(t, ctx, client, container.WithNetworkMode("bridge"))
defer client.ContainerRemove(ctx, id2, types.ContainerRemoveOptions{Force: true})
id2 := container.Run(t, ctx, c, container.WithNetworkMode("bridge"))
defer c.ContainerRemove(ctx, id2, types.ContainerRemoveOptions{Force: true})
result, err = container.Exec(ctx, client, id2, []string{"ip", "l"})
result, err = container.Exec(ctx, c, id2, []string{"ip", "l"})
assert.NilError(t, err)
assert.Check(t, is.Equal(false, strings.Contains(result.Combined(), "eth0")), "There shouldn't be eth0 in container in bridge mode when bridge network is disabled")
@ -51,10 +50,10 @@ func TestRunContainerWithBridgeNone(t *testing.T) {
err = cmd.Run()
assert.NilError(t, err, "Failed to get current process network namespace: %+v", err)
id3 := container.Run(t, ctx, client, container.WithNetworkMode("host"))
defer client.ContainerRemove(ctx, id3, types.ContainerRemoveOptions{Force: true})
id3 := container.Run(t, ctx, c, container.WithNetworkMode("host"))
defer c.ContainerRemove(ctx, id3, types.ContainerRemoveOptions{Force: true})
result, err = container.Exec(ctx, client, id3, []string{"sh", "-c", nsCommand})
result, err = container.Exec(ctx, c, id3, []string{"sh", "-c", nsCommand})
assert.NilError(t, err)
assert.Check(t, is.Equal(stdout.String(), result.Combined()), "The network namspace of container should be the same with host when --net=host and bridge network is disabled")
}

View file

@ -32,15 +32,16 @@ func TestDaemonRestartWithLiveRestore(t *testing.T) {
d := daemon.New(t)
defer d.Stop(t)
d.Start(t)
d.Restart(t, "--live-restore=true",
d.Restart(t,
"--live-restore=true",
"--default-address-pool", "base=175.30.0.0/16,size=16",
"--default-address-pool", "base=175.33.0.0/16,size=24")
"--default-address-pool", "base=175.33.0.0/16,size=24",
)
// Verify bridge network's subnet
cli, err := d.NewClient()
assert.Assert(t, err)
defer cli.Close()
out, err := cli.NetworkInspect(context.Background(), "bridge", types.NetworkInspectOptions{})
c := d.NewClientT(t)
defer c.Close()
out, err := c.NetworkInspect(context.Background(), "bridge", types.NetworkInspectOptions{})
assert.NilError(t, err)
// Make sure docker0 doesn't get override with new IP in live restore case
assert.Equal(t, out.IPAM.Config[0].Subnet, "172.18.0.0/16")
@ -57,31 +58,32 @@ func TestDaemonDefaultNetworkPools(t *testing.T) {
defer d.Stop(t)
d.Start(t,
"--default-address-pool", "base=175.30.0.0/16,size=16",
"--default-address-pool", "base=175.33.0.0/16,size=24")
"--default-address-pool", "base=175.33.0.0/16,size=24",
)
c := d.NewClientT(t)
defer c.Close()
// Verify bridge network's subnet
cli, err := d.NewClient()
assert.Assert(t, err)
defer cli.Close()
out, err := cli.NetworkInspect(context.Background(), "bridge", types.NetworkInspectOptions{})
out, err := c.NetworkInspect(context.Background(), "bridge", types.NetworkInspectOptions{})
assert.NilError(t, err)
assert.Equal(t, out.IPAM.Config[0].Subnet, "175.30.0.0/16")
// Create a bridge network and verify its subnet is the second default pool
name := "elango" + t.Name()
network.CreateNoError(t, context.Background(), cli, name,
network.CreateNoError(t, context.Background(), c, name,
network.WithDriver("bridge"),
)
out, err = cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
out, err = c.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
assert.NilError(t, err)
assert.Equal(t, out.IPAM.Config[0].Subnet, "175.33.0.0/24")
// Create a bridge network and verify its subnet is the third default pool
name = "saanvi" + t.Name()
network.CreateNoError(t, context.Background(), cli, name,
network.CreateNoError(t, context.Background(), c, name,
network.WithDriver("bridge"),
)
out, err = cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
out, err = c.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
assert.NilError(t, err)
assert.Equal(t, out.IPAM.Config[0].Subnet, "175.33.1.0/24")
delInterface(t, defaultNetworkBridge)
@ -96,17 +98,17 @@ func TestDaemonRestartWithExistingNetwork(t *testing.T) {
d := daemon.New(t)
d.Start(t)
defer d.Stop(t)
// Verify bridge network's subnet
cli, err := d.NewClient()
assert.Assert(t, err)
defer cli.Close()
c := d.NewClientT(t)
defer c.Close()
// Create a bridge network
name := "elango" + t.Name()
network.CreateNoError(t, context.Background(), cli, name,
network.CreateNoError(t, context.Background(), c, name,
network.WithDriver("bridge"),
)
out, err := cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
// Verify bridge network's subnet
out, err := c.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
assert.NilError(t, err)
networkip := out.IPAM.Config[0].Subnet
@ -115,7 +117,7 @@ func TestDaemonRestartWithExistingNetwork(t *testing.T) {
"--default-address-pool", "base=175.30.0.0/16,size=16",
"--default-address-pool", "base=175.33.0.0/16,size=24")
out1, err := cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
out1, err := c.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
assert.NilError(t, err)
assert.Equal(t, out1.IPAM.Config[0].Subnet, networkip)
delInterface(t, defaultNetworkBridge)
@ -129,40 +131,41 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) {
d := daemon.New(t)
d.Start(t)
defer d.Stop(t)
// Verify bridge network's subnet
cli, err := d.NewClient()
assert.Assert(t, err)
defer cli.Close()
c := d.NewClientT(t)
defer c.Close()
// Create a bridge network
name := "elango" + t.Name()
network.CreateNoError(t, context.Background(), cli, name,
network.CreateNoError(t, context.Background(), c, name,
network.WithDriver("bridge"),
)
out, err := cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
// Verify bridge network's subnet
out, err := c.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
assert.NilError(t, err)
networkip := out.IPAM.Config[0].Subnet
// Create a bridge network
name = "sthira" + t.Name()
network.CreateNoError(t, context.Background(), cli, name,
network.CreateNoError(t, context.Background(), c, name,
network.WithDriver("bridge"),
)
out, err = cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
out, err = c.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
assert.NilError(t, err)
networkip2 := out.IPAM.Config[0].Subnet
// Restart daemon with default address pool option
d.Restart(t,
"--default-address-pool", "base=175.18.0.0/16,size=16",
"--default-address-pool", "base=175.19.0.0/16,size=24")
"--default-address-pool", "base=175.19.0.0/16,size=24",
)
// Create a bridge network
name = "saanvi" + t.Name()
network.CreateNoError(t, context.Background(), cli, name,
network.CreateNoError(t, context.Background(), c, name,
network.WithDriver("bridge"),
)
out1, err := cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
out1, err := c.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
assert.NilError(t, err)
assert.Check(t, out1.IPAM.Config[0].Subnet != networkip)
@ -177,15 +180,17 @@ func TestDaemonWithBipAndDefaultNetworkPool(t *testing.T) {
defaultNetworkBridge := "docker0"
d := daemon.New(t)
defer d.Stop(t)
d.Start(t, "--bip=172.60.0.1/16",
d.Start(t,
"--bip=172.60.0.1/16",
"--default-address-pool", "base=175.30.0.0/16,size=16",
"--default-address-pool", "base=175.33.0.0/16,size=24")
"--default-address-pool", "base=175.33.0.0/16,size=24",
)
c := d.NewClientT(t)
defer c.Close()
// Verify bridge network's subnet
cli, err := d.NewClient()
assert.Assert(t, err)
defer cli.Close()
out, err := cli.NetworkInspect(context.Background(), "bridge", types.NetworkInspectOptions{})
out, err := c.NetworkInspect(context.Background(), "bridge", types.NetworkInspectOptions{})
assert.NilError(t, err)
// Make sure BIP IP doesn't get override with new default address pool .
assert.Equal(t, out.IPAM.Config[0].Subnet, "172.60.0.1/16")
@ -197,8 +202,8 @@ func TestServiceWithPredefinedNetwork(t *testing.T) {
defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t)
client := d.NewClientT(t)
defer client.Close()
c := d.NewClientT(t)
defer c.Close()
hostName := "host"
var instances uint64 = 1
@ -210,12 +215,12 @@ func TestServiceWithPredefinedNetwork(t *testing.T) {
swarm.ServiceWithNetwork(hostName),
)
poll.WaitOn(t, serviceRunningCount(client, serviceID, instances), swarm.ServicePoll)
poll.WaitOn(t, serviceRunningCount(c, serviceID, instances), swarm.ServicePoll)
_, _, err := client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
_, _, err := c.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
assert.NilError(t, err)
err = client.ServiceRemove(context.Background(), serviceID)
err = c.ServiceRemove(context.Background(), serviceID)
assert.NilError(t, err)
}
@ -226,10 +231,10 @@ func TestServiceRemoveKeepsIngressNetwork(t *testing.T) {
defer setupTest(t)()
d := swarm.NewSwarm(t, testEnv)
defer d.Stop(t)
client := d.NewClientT(t)
defer client.Close()
c := d.NewClientT(t)
defer c.Close()
poll.WaitOn(t, swarmIngressReady(client), swarm.NetworkPoll)
poll.WaitOn(t, swarmIngressReady(c), swarm.NetworkPoll)
var instances uint64 = 1
@ -247,20 +252,20 @@ func TestServiceRemoveKeepsIngressNetwork(t *testing.T) {
}),
)
poll.WaitOn(t, serviceRunningCount(client, serviceID, instances), swarm.ServicePoll)
poll.WaitOn(t, serviceRunningCount(c, serviceID, instances), swarm.ServicePoll)
_, _, err := client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
_, _, err := c.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
assert.NilError(t, err)
err = client.ServiceRemove(context.Background(), serviceID)
err = c.ServiceRemove(context.Background(), serviceID)
assert.NilError(t, err)
poll.WaitOn(t, serviceIsRemoved(client, serviceID), swarm.ServicePoll)
poll.WaitOn(t, noServices(client), swarm.ServicePoll)
poll.WaitOn(t, serviceIsRemoved(c, serviceID), swarm.ServicePoll)
poll.WaitOn(t, noServices(c), swarm.ServicePoll)
// Ensure that "ingress" is not removed or corrupted
time.Sleep(10 * time.Second)
netInfo, err := client.NetworkInspect(context.Background(), ingressNet, types.NetworkInspectOptions{
netInfo, err := c.NetworkInspect(context.Background(), ingressNet, types.NetworkInspectOptions{
Verbose: true,
Scope: "swarm",
})
@ -330,12 +335,12 @@ func TestServiceWithDataPathPortInit(t *testing.T) {
ops = append(ops, daemon.WithSwarmDataPathPort(datapathPort))
d := swarm.NewSwarm(t, testEnv, ops...)
cli := d.NewClientT(t)
defer cli.Close()
c := d.NewClientT(t)
defer c.Close()
// Create a overlay network
name := "saanvisthira" + t.Name()
network.CreateNoError(t, context.Background(), cli, name,
network.CreateNoError(t, context.Background(), c, name,
network.WithDriver("overlay"))
var instances uint64 = 1
@ -344,11 +349,11 @@ func TestServiceWithDataPathPortInit(t *testing.T) {
swarm.ServiceWithNetwork(name),
)
poll.WaitOn(t, serviceRunningCount(cli, serviceID, instances), swarm.ServicePoll)
poll.WaitOn(t, serviceRunningCount(c, serviceID, instances), swarm.ServicePoll)
info := d.Info(t)
assert.Equal(t, info.Swarm.Cluster.DataPathPort, datapathPort)
err := cli.ServiceRemove(context.Background(), serviceID)
err := c.ServiceRemove(context.Background(), serviceID)
assert.NilError(t, err)
d.SwarmLeave(true)
d.Stop(t)
@ -357,11 +362,11 @@ func TestServiceWithDataPathPortInit(t *testing.T) {
// call without datapath port option.
ops = []func(*daemon.Daemon){}
d = swarm.NewSwarm(t, testEnv, ops...)
cli = d.NewClientT(t)
c = d.NewClientT(t)
// Create a overlay network
name = "saanvisthira" + t.Name()
network.CreateNoError(t, context.Background(), cli, name,
network.CreateNoError(t, context.Background(), c, name,
network.WithDriver("overlay"))
serviceID = swarm.CreateService(t, d,
@ -369,12 +374,12 @@ func TestServiceWithDataPathPortInit(t *testing.T) {
swarm.ServiceWithNetwork(name),
)
poll.WaitOn(t, serviceRunningCount(cli, serviceID, instances), swarm.ServicePoll)
poll.WaitOn(t, serviceRunningCount(c, serviceID, instances), swarm.ServicePoll)
info = d.Info(t)
var defaultDataPathPort uint32 = 4789
assert.Equal(t, info.Swarm.Cluster.DataPathPort, defaultDataPathPort)
err = cli.ServiceRemove(context.Background(), serviceID)
err = c.ServiceRemove(context.Background(), serviceID)
assert.NilError(t, err)
d.SwarmLeave(true)
defer d.Stop(t)

View file

@ -87,18 +87,16 @@ func TestAuthZPluginAllowRequest(t *testing.T) {
ctrl.resRes.Allow = true
d.StartWithBusybox(t, "--authorization-plugin="+testAuthZPlugin)
client, err := d.NewClient()
assert.NilError(t, err)
c := d.NewClientT(t)
ctx := context.Background()
// Ensure command successful
cID := container.Run(t, ctx, client)
cID := container.Run(t, ctx, c)
assertURIRecorded(t, ctrl.requestsURIs, "/containers/create")
assertURIRecorded(t, ctrl.requestsURIs, fmt.Sprintf("/containers/%s/start", cID))
_, err = client.ServerVersion(ctx)
_, err := c.ServerVersion(ctx)
assert.NilError(t, err)
assert.Equal(t, 1, ctrl.versionReqCount)
assert.Equal(t, 1, ctrl.versionResCount)
@ -126,10 +124,10 @@ func TestAuthZPluginTLS(t *testing.T) {
ctrl.reqRes.Allow = true
ctrl.resRes.Allow = true
client, err := newTLSAPIClient(testDaemonHTTPSAddr, cacertPath, clientCertPath, clientKeyPath)
c, err := newTLSAPIClient(testDaemonHTTPSAddr, cacertPath, clientCertPath, clientKeyPath)
assert.NilError(t, err)
_, err = client.ServerVersion(context.Background())
_, err = c.ServerVersion(context.Background())
assert.NilError(t, err)
assert.Equal(t, "client", ctrl.reqUser)
@ -153,11 +151,10 @@ func TestAuthZPluginDenyRequest(t *testing.T) {
ctrl.reqRes.Allow = false
ctrl.reqRes.Msg = unauthorizedMessage
client, err := d.NewClient()
assert.NilError(t, err)
c := d.NewClientT(t)
// Ensure command is blocked
_, err = client.ServerVersion(context.Background())
_, err := c.ServerVersion(context.Background())
assert.Assert(t, err != nil)
assert.Equal(t, 1, ctrl.versionReqCount)
assert.Equal(t, 0, ctrl.versionResCount)
@ -179,10 +176,10 @@ func TestAuthZPluginAPIDenyResponse(t *testing.T) {
conn, err := net.DialTimeout(daemonURL.Scheme, daemonURL.Path, time.Second*10)
assert.NilError(t, err)
client := httputil.NewClientConn(conn, nil)
c := httputil.NewClientConn(conn, nil)
req, err := http.NewRequest("GET", "/version", nil)
assert.NilError(t, err)
resp, err := client.Do(req)
resp, err := c.Do(req)
assert.NilError(t, err)
assert.DeepEqual(t, http.StatusForbidden, resp.StatusCode)
@ -195,11 +192,10 @@ func TestAuthZPluginDenyResponse(t *testing.T) {
ctrl.resRes.Allow = false
ctrl.resRes.Msg = unauthorizedMessage
client, err := d.NewClient()
assert.NilError(t, err)
c := d.NewClientT(t)
// Ensure command is blocked
_, err = client.ServerVersion(context.Background())
_, err := c.ServerVersion(context.Background())
assert.Assert(t, err != nil)
assert.Equal(t, 1, ctrl.versionReqCount)
assert.Equal(t, 1, ctrl.versionResCount)
@ -219,20 +215,18 @@ func TestAuthZPluginAllowEventStream(t *testing.T) {
ctrl.resRes.Allow = true
d.StartWithBusybox(t, "--authorization-plugin="+testAuthZPlugin)
client, err := d.NewClient()
assert.NilError(t, err)
c := d.NewClientT(t)
ctx := context.Background()
startTime := strconv.FormatInt(systemTime(t, client, testEnv).Unix(), 10)
events, errs, cancel := systemEventsSince(client, startTime)
startTime := strconv.FormatInt(systemTime(t, c, testEnv).Unix(), 10)
events, errs, cancel := systemEventsSince(c, startTime)
defer cancel()
// Create a container and wait for the creation events
cID := container.Run(t, ctx, client)
cID := container.Run(t, ctx, c)
for i := 0; i < 100; i++ {
c, err := client.ContainerInspect(ctx, cID)
c, err := c.ContainerInspect(ctx, cID)
assert.NilError(t, err)
if c.State.Running {
break
@ -304,11 +298,10 @@ func TestAuthZPluginErrorResponse(t *testing.T) {
ctrl.reqRes.Allow = true
ctrl.resRes.Err = errorMessage
client, err := d.NewClient()
assert.NilError(t, err)
c := d.NewClientT(t)
// Ensure command is blocked
_, err = client.ServerVersion(context.Background())
_, err := c.ServerVersion(context.Background())
assert.Assert(t, err != nil)
assert.Equal(t, fmt.Sprintf("Error response from daemon: plugin %s failed with error: %s: %s", testAuthZPlugin, authorization.AuthZApiResponse, errorMessage), err.Error())
}
@ -318,11 +311,10 @@ func TestAuthZPluginErrorRequest(t *testing.T) {
d.Start(t, "--authorization-plugin="+testAuthZPlugin)
ctrl.reqRes.Err = errorMessage
client, err := d.NewClient()
assert.NilError(t, err)
c := d.NewClientT(t)
// Ensure command is blocked
_, err = client.ServerVersion(context.Background())
_, err := c.ServerVersion(context.Background())
assert.Assert(t, err != nil)
assert.Equal(t, fmt.Sprintf("Error response from daemon: plugin %s failed with error: %s: %s", testAuthZPlugin, authorization.AuthZApiRequest, errorMessage), err.Error())
}
@ -334,10 +326,9 @@ func TestAuthZPluginEnsureNoDuplicatePluginRegistration(t *testing.T) {
ctrl.reqRes.Allow = true
ctrl.resRes.Allow = true
client, err := d.NewClient()
assert.NilError(t, err)
c := d.NewClientT(t)
_, err = client.ServerVersion(context.Background())
_, err := c.ServerVersion(context.Background())
assert.NilError(t, err)
// assert plugin is only called once..
@ -351,9 +342,7 @@ func TestAuthZPluginEnsureLoadImportWorking(t *testing.T) {
ctrl.resRes.Allow = true
d.StartWithBusybox(t, "--authorization-plugin="+testAuthZPlugin, "--authorization-plugin="+testAuthZPlugin)
client, err := d.NewClient()
assert.NilError(t, err)
c := d.NewClientT(t)
ctx := context.Background()
tmp, err := ioutil.TempDir("", "test-authz-load-import")
@ -362,16 +351,16 @@ func TestAuthZPluginEnsureLoadImportWorking(t *testing.T) {
savedImagePath := filepath.Join(tmp, "save.tar")
err = imageSave(client, savedImagePath, "busybox")
err = imageSave(c, savedImagePath, "busybox")
assert.NilError(t, err)
err = imageLoad(client, savedImagePath)
err = imageLoad(c, savedImagePath)
assert.NilError(t, err)
exportedImagePath := filepath.Join(tmp, "export.tar")
cID := container.Run(t, ctx, client)
cID := container.Run(t, ctx, c)
responseReader, err := client.ContainerExport(context.Background(), cID)
responseReader, err := c.ContainerExport(context.Background(), cID)
assert.NilError(t, err)
defer responseReader.Close()
file, err := os.Create(exportedImagePath)
@ -380,7 +369,7 @@ func TestAuthZPluginEnsureLoadImportWorking(t *testing.T) {
_, err = io.Copy(file, responseReader)
assert.NilError(t, err)
err = imageImport(client, exportedImagePath)
err = imageImport(c, exportedImagePath)
assert.NilError(t, err)
}
@ -406,12 +395,11 @@ func TestAuthzPluginEnsureContainerCopyToFrom(t *testing.T) {
written += n
}
c := d.NewClientT(t)
ctx := context.Background()
client, err := d.NewClient()
assert.Assert(t, err)
cID := container.Run(t, ctx, client)
defer client.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true})
cID := container.Run(t, ctx, c)
defer c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true})
_, err = f.Seek(0, io.SeekStart)
assert.Assert(t, err)
@ -425,10 +413,10 @@ func TestAuthzPluginEnsureContainerCopyToFrom(t *testing.T) {
dstDir, preparedArchive, err := archive.PrepareArchiveCopy(srcArchive, srcInfo, archive.CopyInfo{Path: "/test"})
assert.Assert(t, err)
err = client.CopyToContainer(ctx, cID, dstDir, preparedArchive, types.CopyToContainerOptions{})
err = c.CopyToContainer(ctx, cID, dstDir, preparedArchive, types.CopyToContainerOptions{})
assert.Assert(t, err)
rdr, _, err := client.CopyFromContainer(ctx, cID, "/test")
rdr, _, err := c.CopyFromContainer(ctx, cID, "/test")
assert.Assert(t, err)
_, err = io.Copy(ioutil.Discard, rdr)
assert.Assert(t, err)

View file

@ -43,13 +43,11 @@ func TestAuthZPluginV2AllowNonVolumeRequest(t *testing.T) {
skip.If(t, os.Getenv("DOCKER_ENGINE_GOARCH") != "amd64")
defer setupTestV2(t)()
client, err := d.NewClient()
assert.NilError(t, err)
c := d.NewClientT(t)
ctx := context.Background()
// Install authz plugin
err = pluginInstallGrantAllPermissions(client, authzPluginNameWithTag)
err := pluginInstallGrantAllPermissions(c, authzPluginNameWithTag)
assert.NilError(t, err)
// start the daemon with the plugin and load busybox, --net=none build fails otherwise
// because it needs to pull busybox
@ -57,9 +55,9 @@ func TestAuthZPluginV2AllowNonVolumeRequest(t *testing.T) {
d.LoadBusybox(t)
// Ensure docker run command and accompanying docker ps are successful
cID := container.Run(t, ctx, client)
cID := container.Run(t, ctx, c)
_, err = client.ContainerInspect(ctx, cID)
_, err = c.ContainerInspect(ctx, cID)
assert.NilError(t, err)
}
@ -67,26 +65,25 @@ func TestAuthZPluginV2Disable(t *testing.T) {
skip.If(t, os.Getenv("DOCKER_ENGINE_GOARCH") != "amd64")
defer setupTestV2(t)()
client, err := d.NewClient()
assert.NilError(t, err)
c := d.NewClientT(t)
// Install authz plugin
err = pluginInstallGrantAllPermissions(client, authzPluginNameWithTag)
err := pluginInstallGrantAllPermissions(c, authzPluginNameWithTag)
assert.NilError(t, err)
d.Restart(t, "--authorization-plugin="+authzPluginNameWithTag)
d.LoadBusybox(t)
_, err = client.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{Driver: "local"})
_, err = c.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{Driver: "local"})
assert.Assert(t, err != nil)
assert.Assert(t, strings.Contains(err.Error(), fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag)))
// disable the plugin
err = client.PluginDisable(context.Background(), authzPluginNameWithTag, types.PluginDisableOptions{})
err = c.PluginDisable(context.Background(), authzPluginNameWithTag, types.PluginDisableOptions{})
assert.NilError(t, err)
// now test to see if the docker api works.
_, err = client.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{Driver: "local"})
_, err = c.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{Driver: "local"})
assert.NilError(t, err)
}
@ -94,34 +91,33 @@ func TestAuthZPluginV2RejectVolumeRequests(t *testing.T) {
skip.If(t, os.Getenv("DOCKER_ENGINE_GOARCH") != "amd64")
defer setupTestV2(t)()
client, err := d.NewClient()
assert.NilError(t, err)
c := d.NewClientT(t)
// Install authz plugin
err = pluginInstallGrantAllPermissions(client, authzPluginNameWithTag)
err := pluginInstallGrantAllPermissions(c, authzPluginNameWithTag)
assert.NilError(t, err)
// restart the daemon with the plugin
d.Restart(t, "--authorization-plugin="+authzPluginNameWithTag)
_, err = client.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{Driver: "local"})
_, err = c.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{Driver: "local"})
assert.Assert(t, err != nil)
assert.Assert(t, strings.Contains(err.Error(), fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag)))
_, err = client.VolumeList(context.Background(), filters.Args{})
_, err = c.VolumeList(context.Background(), filters.Args{})
assert.Assert(t, err != nil)
assert.Assert(t, strings.Contains(err.Error(), fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag)))
// The plugin will block the command before it can determine the volume does not exist
err = client.VolumeRemove(context.Background(), "test", false)
err = c.VolumeRemove(context.Background(), "test", false)
assert.Assert(t, err != nil)
assert.Assert(t, strings.Contains(err.Error(), fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag)))
_, err = client.VolumeInspect(context.Background(), "test")
_, err = c.VolumeInspect(context.Background(), "test")
assert.Assert(t, err != nil)
assert.Assert(t, strings.Contains(err.Error(), fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag)))
_, err = client.VolumesPrune(context.Background(), filters.Args{})
_, err = c.VolumesPrune(context.Background(), filters.Args{})
assert.Assert(t, err != nil)
assert.Assert(t, strings.Contains(err.Error(), fmt.Sprintf("Error response from daemon: plugin %s failed with error:", authzPluginNameWithTag)))
}
@ -130,11 +126,10 @@ func TestAuthZPluginV2BadManifestFailsDaemonStart(t *testing.T) {
skip.If(t, os.Getenv("DOCKER_ENGINE_GOARCH") != "amd64")
defer setupTestV2(t)()
client, err := d.NewClient()
assert.NilError(t, err)
c := d.NewClientT(t)
// Install authz plugin with bad manifest
err = pluginInstallGrantAllPermissions(client, authzPluginBadManifestName)
err := pluginInstallGrantAllPermissions(c, authzPluginBadManifestName)
assert.NilError(t, err)
// start the daemon with the plugin, it will error

View file

@ -24,14 +24,13 @@ func TestDaemonStartWithLogOpt(t *testing.T) {
d.Start(t, "--iptables=false")
defer d.Stop(t)
client, err := d.NewClient()
assert.Check(t, err)
c := d.NewClientT(t)
ctx := context.Background()
createPlugin(t, client, "test", "dummy", asLogDriver)
err = client.PluginEnable(ctx, "test", types.PluginEnableOptions{Timeout: 30})
createPlugin(t, c, "test", "dummy", asLogDriver)
err := c.PluginEnable(ctx, "test", types.PluginEnableOptions{Timeout: 30})
assert.Check(t, err)
defer client.PluginRemove(ctx, "test", types.PluginRemoveOptions{Force: true})
defer c.PluginRemove(ctx, "test", types.PluginRemoveOptions{Force: true})
d.Stop(t)
d.Start(t, "--iptables=false", "--log-driver=test", "--log-opt=foo=bar")

View file

@ -24,15 +24,14 @@ func TestPluginWithDevMounts(t *testing.T) {
d.Start(t, "--iptables=false")
defer d.Stop(t)
client, err := d.NewClient()
assert.Assert(t, err)
c := d.NewClientT(t)
ctx := context.Background()
testDir, err := ioutil.TempDir("", "test-dir")
assert.Assert(t, err)
defer os.RemoveAll(testDir)
createPlugin(t, client, "test", "dummy", asVolumeDriver, func(c *plugin.Config) {
createPlugin(t, c, "test", "dummy", asVolumeDriver, func(c *plugin.Config) {
root := "/"
dev := "/dev"
mounts := []types.PluginMount{
@ -46,14 +45,14 @@ func TestPluginWithDevMounts(t *testing.T) {
c.IpcHost = true
})
err = client.PluginEnable(ctx, "test", types.PluginEnableOptions{Timeout: 30})
err = c.PluginEnable(ctx, "test", types.PluginEnableOptions{Timeout: 30})
assert.Assert(t, err)
defer func() {
err := client.PluginRemove(ctx, "test", types.PluginRemoveOptions{Force: true})
err := c.PluginRemove(ctx, "test", types.PluginRemoveOptions{Force: true})
assert.Check(t, err)
}()
p, _, err := client.PluginInspectWithRaw(ctx, "test")
p, _, err := c.PluginInspectWithRaw(ctx, "test")
assert.Assert(t, err)
assert.Assert(t, p.Enabled)
}

View file

@ -36,23 +36,23 @@ func TestCgroupDriverSystemdMemoryLimit(t *testing.T) {
}
d := daemon.New(t)
client, err := d.NewClient()
assert.NilError(t, err)
c := d.NewClientT(t)
d.StartWithBusybox(t, "--exec-opt", "native.cgroupdriver=systemd", "--iptables=false")
defer d.Stop(t)
const mem = 64 * 1024 * 1024 // 64 MB
ctx := context.Background()
ctrID := container.Create(t, ctx, client, func(c *container.TestContainerConfig) {
c.HostConfig.Resources.Memory = mem
ctrID := container.Create(t, ctx, c, func(ctr *container.TestContainerConfig) {
ctr.HostConfig.Resources.Memory = mem
})
defer client.ContainerRemove(ctx, ctrID, types.ContainerRemoveOptions{Force: true})
defer c.ContainerRemove(ctx, ctrID, types.ContainerRemoveOptions{Force: true})
err = client.ContainerStart(ctx, ctrID, types.ContainerStartOptions{})
err := c.ContainerStart(ctx, ctrID, types.ContainerStartOptions{})
assert.NilError(t, err)
s, err := client.ContainerInspect(ctx, ctrID)
s, err := c.ContainerInspect(ctx, ctrID)
assert.NilError(t, err)
assert.Equal(t, s.HostConfig.Memory, mem)
}

View file

@ -46,14 +46,12 @@ func TestInfoAPI(t *testing.T) {
func TestInfoAPIWarnings(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME")
d := daemon.New(t)
client, err := d.NewClient()
assert.NilError(t, err)
c := d.NewClientT(t)
d.StartWithBusybox(t, "-H=0.0.0.0:23756", "-H="+d.Sock())
defer d.Stop(t)
info, err := client.Info(context.Background())
info, err := c.Info(context.Background())
assert.NilError(t, err)
stringsToCheck := []string{

View file

@ -568,11 +568,10 @@ func (d *Daemon) LoadBusybox(t assert.TestingT) {
assert.NilError(t, err, "failed to download busybox")
defer reader.Close()
client, err := d.NewClient()
assert.NilError(t, err, "failed to create client")
defer client.Close()
c := d.NewClientT(t)
defer c.Close()
resp, err := client.ImageLoad(ctx, reader, true)
resp, err := c.ImageLoad(ctx, reader, true)
assert.NilError(t, err, "failed to load busybox")
defer resp.Body.Close()
}
@ -632,7 +631,7 @@ func (d *Daemon) queryRootDir() (string, error) {
return "", err
}
client := &http.Client{
c := &http.Client{
Transport: clientConfig.transport,
}
@ -644,7 +643,7 @@ func (d *Daemon) queryRootDir() (string, error) {
req.URL.Host = clientConfig.addr
req.URL.Scheme = clientConfig.scheme
resp, err := client.Do(req)
resp, err := c.Do(req)
if err != nil {
return "", err
}
@ -672,9 +671,8 @@ func (d *Daemon) Info(t assert.TestingT) types.Info {
if ht, ok := t.(test.HelperT); ok {
ht.Helper()
}
apiclient, err := d.NewClient()
assert.NilError(t, err)
info, err := apiclient.Info(context.Background())
c := d.NewClientT(t)
info, err := c.Info(context.Background())
assert.NilError(t, err)
return info
}