rm-gocheck: check.C -> testing.T

sed -E -i 's#\bcheck\.C\b#testing.T#g' \
-- "integration-cli/check_test.go" "integration-cli/daemon/daemon.go" "integration-cli/daemon/daemon_swarm.go" "integration-cli/daemon_swarm_hack_test.go" "integration-cli/docker_api_attach_test.go" "integration-cli/docker_api_build_test.go" "integration-cli/docker_api_build_windows_test.go" "integration-cli/docker_api_containers_test.go" "integration-cli/docker_api_containers_windows_test.go" "integration-cli/docker_api_exec_resize_test.go" "integration-cli/docker_api_exec_test.go" "integration-cli/docker_api_images_test.go" "integration-cli/docker_api_inspect_test.go" "integration-cli/docker_api_logs_test.go" "integration-cli/docker_api_network_test.go" "integration-cli/docker_api_stats_test.go" "integration-cli/docker_api_swarm_node_test.go" "integration-cli/docker_api_swarm_service_test.go" "integration-cli/docker_api_swarm_test.go" "integration-cli/docker_api_test.go" "integration-cli/docker_cli_attach_test.go" "integration-cli/docker_cli_attach_unix_test.go" "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_build_unix_test.go" "integration-cli/docker_cli_by_digest_test.go" "integration-cli/docker_cli_commit_test.go" "integration-cli/docker_cli_cp_from_container_test.go" "integration-cli/docker_cli_cp_test.go" "integration-cli/docker_cli_cp_to_container_test.go" "integration-cli/docker_cli_cp_to_container_unix_test.go" "integration-cli/docker_cli_cp_utils_test.go" "integration-cli/docker_cli_create_test.go" "integration-cli/docker_cli_daemon_plugins_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_events_test.go" "integration-cli/docker_cli_events_unix_test.go" "integration-cli/docker_cli_exec_test.go" "integration-cli/docker_cli_exec_unix_test.go" "integration-cli/docker_cli_external_volume_driver_unix_test.go" "integration-cli/docker_cli_health_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_images_test.go" "integration-cli/docker_cli_import_test.go" "integration-cli/docker_cli_info_test.go" "integration-cli/docker_cli_info_unix_test.go" "integration-cli/docker_cli_inspect_test.go" "integration-cli/docker_cli_links_test.go" "integration-cli/docker_cli_login_test.go" "integration-cli/docker_cli_logout_test.go" "integration-cli/docker_cli_logs_test.go" "integration-cli/docker_cli_netmode_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_plugins_logdriver_test.go" "integration-cli/docker_cli_plugins_test.go" "integration-cli/docker_cli_port_test.go" "integration-cli/docker_cli_proxy_test.go" "integration-cli/docker_cli_prune_unix_test.go" "integration-cli/docker_cli_ps_test.go" "integration-cli/docker_cli_pull_local_test.go" "integration-cli/docker_cli_pull_test.go" "integration-cli/docker_cli_push_test.go" "integration-cli/docker_cli_registry_user_agent_test.go" "integration-cli/docker_cli_restart_test.go" "integration-cli/docker_cli_rmi_test.go" "integration-cli/docker_cli_run_test.go" "integration-cli/docker_cli_run_unix_test.go" "integration-cli/docker_cli_save_load_test.go" "integration-cli/docker_cli_save_load_unix_test.go" "integration-cli/docker_cli_search_test.go" "integration-cli/docker_cli_service_create_test.go" "integration-cli/docker_cli_service_health_test.go" "integration-cli/docker_cli_service_logs_test.go" "integration-cli/docker_cli_service_scale_test.go" "integration-cli/docker_cli_sni_test.go" "integration-cli/docker_cli_start_test.go" "integration-cli/docker_cli_stats_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_swarm_unix_test.go" "integration-cli/docker_cli_top_test.go" "integration-cli/docker_cli_update_unix_test.go" "integration-cli/docker_cli_userns_test.go" "integration-cli/docker_cli_v2_only_test.go" "integration-cli/docker_cli_volume_test.go" "integration-cli/docker_deprecated_api_v124_test.go" "integration-cli/docker_deprecated_api_v124_unix_test.go" "integration-cli/docker_hub_pull_suite_test.go" "integration-cli/docker_utils_test.go" "integration-cli/events_utils_test.go" "integration-cli/fixtures_linux_daemon_test.go" "integration-cli/utils_test.go" "pkg/discovery/discovery_test.go" "pkg/discovery/file/file_test.go" "pkg/discovery/generator_test.go" "pkg/discovery/kv/kv_test.go" "pkg/discovery/memory/memory_test.go" "pkg/discovery/nodes/nodes_test.go"

Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
Tibor Vass 2019-09-09 21:05:55 +00:00
parent 6ecff64d03
commit 1d92789b4f
96 changed files with 1792 additions and 1792 deletions

View file

@ -83,7 +83,7 @@ func init() {
type DockerSuite struct { type DockerSuite struct {
} }
func (s *DockerSuite) OnTimeout(c *check.C) { func (s *DockerSuite) OnTimeout(c *testing.T) {
if testEnv.IsRemoteDaemon() { if testEnv.IsRemoteDaemon() {
return return
} }
@ -104,7 +104,7 @@ func (s *DockerSuite) OnTimeout(c *check.C) {
} }
} }
func (s *DockerSuite) TearDownTest(c *check.C) { func (s *DockerSuite) TearDownTest(c *testing.T) {
testEnv.Clean(c) testEnv.Clean(c)
} }
@ -120,18 +120,18 @@ type DockerRegistrySuite struct {
d *daemon.Daemon d *daemon.Daemon
} }
func (s *DockerRegistrySuite) OnTimeout(c *check.C) { func (s *DockerRegistrySuite) OnTimeout(c *testing.T) {
s.d.DumpStackAndQuit() s.d.DumpStackAndQuit()
} }
func (s *DockerRegistrySuite) SetUpTest(c *check.C) { func (s *DockerRegistrySuite) SetUpTest(c *testing.T) {
testRequires(c, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon)
s.reg = registry.NewV2(c) s.reg = registry.NewV2(c)
s.reg.WaitReady(c) s.reg.WaitReady(c)
s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
} }
func (s *DockerRegistrySuite) TearDownTest(c *check.C) { func (s *DockerRegistrySuite) TearDownTest(c *testing.T) {
if s.reg != nil { if s.reg != nil {
s.reg.Close() s.reg.Close()
} }
@ -153,18 +153,18 @@ type DockerSchema1RegistrySuite struct {
d *daemon.Daemon d *daemon.Daemon
} }
func (s *DockerSchema1RegistrySuite) OnTimeout(c *check.C) { func (s *DockerSchema1RegistrySuite) OnTimeout(c *testing.T) {
s.d.DumpStackAndQuit() s.d.DumpStackAndQuit()
} }
func (s *DockerSchema1RegistrySuite) SetUpTest(c *check.C) { func (s *DockerSchema1RegistrySuite) SetUpTest(c *testing.T) {
testRequires(c, DaemonIsLinux, RegistryHosting, NotArm64, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, RegistryHosting, NotArm64, testEnv.IsLocalDaemon)
s.reg = registry.NewV2(c, registry.Schema1) s.reg = registry.NewV2(c, registry.Schema1)
s.reg.WaitReady(c) s.reg.WaitReady(c)
s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
} }
func (s *DockerSchema1RegistrySuite) TearDownTest(c *check.C) { func (s *DockerSchema1RegistrySuite) TearDownTest(c *testing.T) {
if s.reg != nil { if s.reg != nil {
s.reg.Close() s.reg.Close()
} }
@ -186,18 +186,18 @@ type DockerRegistryAuthHtpasswdSuite struct {
d *daemon.Daemon d *daemon.Daemon
} }
func (s *DockerRegistryAuthHtpasswdSuite) OnTimeout(c *check.C) { func (s *DockerRegistryAuthHtpasswdSuite) OnTimeout(c *testing.T) {
s.d.DumpStackAndQuit() s.d.DumpStackAndQuit()
} }
func (s *DockerRegistryAuthHtpasswdSuite) SetUpTest(c *check.C) { func (s *DockerRegistryAuthHtpasswdSuite) SetUpTest(c *testing.T) {
testRequires(c, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon)
s.reg = registry.NewV2(c, registry.Htpasswd) s.reg = registry.NewV2(c, registry.Htpasswd)
s.reg.WaitReady(c) s.reg.WaitReady(c)
s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
} }
func (s *DockerRegistryAuthHtpasswdSuite) TearDownTest(c *check.C) { func (s *DockerRegistryAuthHtpasswdSuite) TearDownTest(c *testing.T) {
if s.reg != nil { if s.reg != nil {
out, err := s.d.Cmd("logout", privateRegistryURL) out, err := s.d.Cmd("logout", privateRegistryURL)
assert.NilError(c, err, out) assert.NilError(c, err, out)
@ -221,16 +221,16 @@ type DockerRegistryAuthTokenSuite struct {
d *daemon.Daemon d *daemon.Daemon
} }
func (s *DockerRegistryAuthTokenSuite) OnTimeout(c *check.C) { func (s *DockerRegistryAuthTokenSuite) OnTimeout(c *testing.T) {
s.d.DumpStackAndQuit() s.d.DumpStackAndQuit()
} }
func (s *DockerRegistryAuthTokenSuite) SetUpTest(c *check.C) { func (s *DockerRegistryAuthTokenSuite) SetUpTest(c *testing.T) {
testRequires(c, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon)
s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
} }
func (s *DockerRegistryAuthTokenSuite) TearDownTest(c *check.C) { func (s *DockerRegistryAuthTokenSuite) TearDownTest(c *testing.T) {
if s.reg != nil { if s.reg != nil {
out, err := s.d.Cmd("logout", privateRegistryURL) out, err := s.d.Cmd("logout", privateRegistryURL)
assert.NilError(c, err, out) assert.NilError(c, err, out)
@ -242,7 +242,7 @@ func (s *DockerRegistryAuthTokenSuite) TearDownTest(c *check.C) {
s.ds.TearDownTest(c) s.ds.TearDownTest(c)
} }
func (s *DockerRegistryAuthTokenSuite) setupRegistryWithTokenService(c *check.C, tokenURL string) { func (s *DockerRegistryAuthTokenSuite) setupRegistryWithTokenService(c *testing.T, tokenURL string) {
if s == nil { if s == nil {
c.Fatal("registry suite isn't initialized") c.Fatal("registry suite isn't initialized")
} }
@ -261,16 +261,16 @@ type DockerDaemonSuite struct {
d *daemon.Daemon d *daemon.Daemon
} }
func (s *DockerDaemonSuite) OnTimeout(c *check.C) { func (s *DockerDaemonSuite) OnTimeout(c *testing.T) {
s.d.DumpStackAndQuit() s.d.DumpStackAndQuit()
} }
func (s *DockerDaemonSuite) SetUpTest(c *check.C) { func (s *DockerDaemonSuite) SetUpTest(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
} }
func (s *DockerDaemonSuite) TearDownTest(c *check.C) { func (s *DockerDaemonSuite) TearDownTest(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
if s.d != nil { if s.d != nil {
s.d.Stop(c) s.d.Stop(c)
@ -278,7 +278,7 @@ func (s *DockerDaemonSuite) TearDownTest(c *check.C) {
s.ds.TearDownTest(c) s.ds.TearDownTest(c)
} }
func (s *DockerDaemonSuite) TearDownSuite(c *check.C) { func (s *DockerDaemonSuite) TearDownSuite(c *testing.T) {
filepath.Walk(testdaemon.SockRoot, func(path string, fi os.FileInfo, err error) error { filepath.Walk(testdaemon.SockRoot, func(path string, fi os.FileInfo, err error) error {
if err != nil { if err != nil {
// ignore errors here // ignore errors here
@ -309,7 +309,7 @@ type DockerSwarmSuite struct {
portIndex int portIndex int
} }
func (s *DockerSwarmSuite) OnTimeout(c *check.C) { func (s *DockerSwarmSuite) OnTimeout(c *testing.T) {
s.daemonsLock.Lock() s.daemonsLock.Lock()
defer s.daemonsLock.Unlock() defer s.daemonsLock.Unlock()
for _, d := range s.daemons { for _, d := range s.daemons {
@ -317,11 +317,11 @@ func (s *DockerSwarmSuite) OnTimeout(c *check.C) {
} }
} }
func (s *DockerSwarmSuite) SetUpTest(c *check.C) { func (s *DockerSwarmSuite) SetUpTest(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
} }
func (s *DockerSwarmSuite) AddDaemon(c *check.C, joinSwarm, manager bool) *daemon.Daemon { func (s *DockerSwarmSuite) AddDaemon(c *testing.T, joinSwarm, manager bool) *daemon.Daemon {
d := daemon.New(c, dockerBinary, dockerdBinary, d := daemon.New(c, dockerBinary, dockerdBinary,
testdaemon.WithEnvironment(testEnv.Execution), testdaemon.WithEnvironment(testEnv.Execution),
testdaemon.WithSwarmPort(defaultSwarmPort+s.portIndex), testdaemon.WithSwarmPort(defaultSwarmPort+s.portIndex),
@ -344,7 +344,7 @@ func (s *DockerSwarmSuite) AddDaemon(c *check.C, joinSwarm, manager bool) *daemo
return d return d
} }
func (s *DockerSwarmSuite) TearDownTest(c *check.C) { func (s *DockerSwarmSuite) TearDownTest(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
s.daemonsLock.Lock() s.daemonsLock.Lock()
for _, d := range s.daemons { for _, d := range s.daemons {
@ -381,7 +381,7 @@ func (ps *DockerPluginSuite) getPluginRepoWithTag() string {
return ps.getPluginRepo() + ":" + "latest" return ps.getPluginRepo() + ":" + "latest"
} }
func (ps *DockerPluginSuite) SetUpSuite(c *check.C) { func (ps *DockerPluginSuite) SetUpSuite(c *testing.T) {
testRequires(c, DaemonIsLinux, RegistryHosting) testRequires(c, DaemonIsLinux, RegistryHosting)
ps.registry = registry.NewV2(c) ps.registry = registry.NewV2(c)
ps.registry.WaitReady(c) ps.registry.WaitReady(c)
@ -393,16 +393,16 @@ func (ps *DockerPluginSuite) SetUpSuite(c *check.C) {
assert.NilError(c, err, "failed to create plugin") assert.NilError(c, err, "failed to create plugin")
} }
func (ps *DockerPluginSuite) TearDownSuite(c *check.C) { func (ps *DockerPluginSuite) TearDownSuite(c *testing.T) {
if ps.registry != nil { if ps.registry != nil {
ps.registry.Close() ps.registry.Close()
} }
} }
func (ps *DockerPluginSuite) TearDownTest(c *check.C) { func (ps *DockerPluginSuite) TearDownTest(c *testing.T) {
ps.ds.TearDownTest(c) ps.ds.TearDownTest(c)
} }
func (ps *DockerPluginSuite) OnTimeout(c *check.C) { func (ps *DockerPluginSuite) OnTimeout(c *testing.T) {
ps.ds.OnTimeout(c) ps.ds.OnTimeout(c)
} }

View file

@ -88,7 +88,7 @@ func (d *Daemon) inspectFieldWithError(name, field string) (string, error) {
// CheckActiveContainerCount returns the number of active containers // CheckActiveContainerCount returns the number of active containers
// FIXME(vdemeester) should re-use ActivateContainers in some way // FIXME(vdemeester) should re-use ActivateContainers in some way
func (d *Daemon) CheckActiveContainerCount(c *check.C) (interface{}, check.CommentInterface) { func (d *Daemon) CheckActiveContainerCount(c *testing.T) (interface{}, check.CommentInterface) {
out, err := d.Cmd("ps", "-q") out, err := d.Cmd("ps", "-q")
assert.NilError(c, err) assert.NilError(c, err)
if len(strings.TrimSpace(out)) == 0 { if len(strings.TrimSpace(out)) == 0 {

View file

@ -15,8 +15,8 @@ import (
// CheckServiceTasksInState returns the number of tasks with a matching state, // CheckServiceTasksInState returns the number of tasks with a matching state,
// and optional message substring. // and optional message substring.
func (d *Daemon) CheckServiceTasksInState(service string, state swarm.TaskState, message string) func(*check.C) (interface{}, check.CommentInterface) { func (d *Daemon) CheckServiceTasksInState(service string, state swarm.TaskState, message string) func(*testing.T) (interface{}, check.CommentInterface) {
return func(c *check.C) (interface{}, check.CommentInterface) { return func(c *testing.T) (interface{}, check.CommentInterface) {
tasks := d.GetServiceTasks(c, service) tasks := d.GetServiceTasks(c, service)
var count int var count int
for _, task := range tasks { for _, task := range tasks {
@ -32,8 +32,8 @@ func (d *Daemon) CheckServiceTasksInState(service string, state swarm.TaskState,
// CheckServiceTasksInStateWithError returns the number of tasks with a matching state, // CheckServiceTasksInStateWithError returns the number of tasks with a matching state,
// and optional message substring. // and optional message substring.
func (d *Daemon) CheckServiceTasksInStateWithError(service string, state swarm.TaskState, errorMessage string) func(*check.C) (interface{}, check.CommentInterface) { func (d *Daemon) CheckServiceTasksInStateWithError(service string, state swarm.TaskState, errorMessage string) func(*testing.T) (interface{}, check.CommentInterface) {
return func(c *check.C) (interface{}, check.CommentInterface) { return func(c *testing.T) (interface{}, check.CommentInterface) {
tasks := d.GetServiceTasks(c, service) tasks := d.GetServiceTasks(c, service)
var count int var count int
for _, task := range tasks { for _, task := range tasks {
@ -48,13 +48,13 @@ func (d *Daemon) CheckServiceTasksInStateWithError(service string, state swarm.T
} }
// CheckServiceRunningTasks returns the number of running tasks for the specified service // CheckServiceRunningTasks returns the number of running tasks for the specified service
func (d *Daemon) CheckServiceRunningTasks(service string) func(*check.C) (interface{}, check.CommentInterface) { func (d *Daemon) CheckServiceRunningTasks(service string) func(*testing.T) (interface{}, check.CommentInterface) {
return d.CheckServiceTasksInState(service, swarm.TaskStateRunning, "") return d.CheckServiceTasksInState(service, swarm.TaskStateRunning, "")
} }
// CheckServiceUpdateState returns the current update state for the specified service // CheckServiceUpdateState returns the current update state for the specified service
func (d *Daemon) CheckServiceUpdateState(service string) func(*check.C) (interface{}, check.CommentInterface) { func (d *Daemon) CheckServiceUpdateState(service string) func(*testing.T) (interface{}, check.CommentInterface) {
return func(c *check.C) (interface{}, check.CommentInterface) { return func(c *testing.T) (interface{}, check.CommentInterface) {
service := d.GetService(c, service) service := d.GetService(c, service)
if service.UpdateStatus == nil { if service.UpdateStatus == nil {
return "", nil return "", nil
@ -64,8 +64,8 @@ func (d *Daemon) CheckServiceUpdateState(service string) func(*check.C) (interfa
} }
// CheckPluginRunning returns the runtime state of the plugin // CheckPluginRunning returns the runtime state of the plugin
func (d *Daemon) CheckPluginRunning(plugin string) func(c *check.C) (interface{}, check.CommentInterface) { func (d *Daemon) CheckPluginRunning(plugin string) func(c *testing.T) (interface{}, check.CommentInterface) {
return func(c *check.C) (interface{}, check.CommentInterface) { return func(c *testing.T) (interface{}, check.CommentInterface) {
apiclient := d.NewClientT(c) apiclient := d.NewClientT(c)
resp, _, err := apiclient.PluginInspectWithRaw(context.Background(), plugin) resp, _, err := apiclient.PluginInspectWithRaw(context.Background(), plugin)
if client.IsErrNotFound(err) { if client.IsErrNotFound(err) {
@ -77,8 +77,8 @@ func (d *Daemon) CheckPluginRunning(plugin string) func(c *check.C) (interface{}
} }
// CheckPluginImage returns the runtime state of the plugin // CheckPluginImage returns the runtime state of the plugin
func (d *Daemon) CheckPluginImage(plugin string) func(c *check.C) (interface{}, check.CommentInterface) { func (d *Daemon) CheckPluginImage(plugin string) func(c *testing.T) (interface{}, check.CommentInterface) {
return func(c *check.C) (interface{}, check.CommentInterface) { return func(c *testing.T) (interface{}, check.CommentInterface) {
apiclient := d.NewClientT(c) apiclient := d.NewClientT(c)
resp, _, err := apiclient.PluginInspectWithRaw(context.Background(), plugin) resp, _, err := apiclient.PluginInspectWithRaw(context.Background(), plugin)
if client.IsErrNotFound(err) { if client.IsErrNotFound(err) {
@ -90,15 +90,15 @@ func (d *Daemon) CheckPluginImage(plugin string) func(c *check.C) (interface{},
} }
// CheckServiceTasks returns the number of tasks for the specified service // CheckServiceTasks returns the number of tasks for the specified service
func (d *Daemon) CheckServiceTasks(service string) func(*check.C) (interface{}, check.CommentInterface) { func (d *Daemon) CheckServiceTasks(service string) func(*testing.T) (interface{}, check.CommentInterface) {
return func(c *check.C) (interface{}, check.CommentInterface) { return func(c *testing.T) (interface{}, check.CommentInterface) {
tasks := d.GetServiceTasks(c, service) tasks := d.GetServiceTasks(c, service)
return len(tasks), nil return len(tasks), nil
} }
} }
// CheckRunningTaskNetworks returns the number of times each network is referenced from a task. // CheckRunningTaskNetworks returns the number of times each network is referenced from a task.
func (d *Daemon) CheckRunningTaskNetworks(c *check.C) (interface{}, check.CommentInterface) { func (d *Daemon) CheckRunningTaskNetworks(c *testing.T) (interface{}, check.CommentInterface) {
cli := d.NewClientT(c) cli := d.NewClientT(c)
defer cli.Close() defer cli.Close()
@ -122,7 +122,7 @@ func (d *Daemon) CheckRunningTaskNetworks(c *check.C) (interface{}, check.Commen
} }
// CheckRunningTaskImages returns the times each image is running as a task. // CheckRunningTaskImages returns the times each image is running as a task.
func (d *Daemon) CheckRunningTaskImages(c *check.C) (interface{}, check.CommentInterface) { func (d *Daemon) CheckRunningTaskImages(c *testing.T) (interface{}, check.CommentInterface) {
cli := d.NewClientT(c) cli := d.NewClientT(c)
defer cli.Close() defer cli.Close()
@ -146,7 +146,7 @@ func (d *Daemon) CheckRunningTaskImages(c *check.C) (interface{}, check.CommentI
} }
// CheckNodeReadyCount returns the number of ready node on the swarm // CheckNodeReadyCount returns the number of ready node on the swarm
func (d *Daemon) CheckNodeReadyCount(c *check.C) (interface{}, check.CommentInterface) { func (d *Daemon) CheckNodeReadyCount(c *testing.T) (interface{}, check.CommentInterface) {
nodes := d.ListNodes(c) nodes := d.ListNodes(c)
var readyCount int var readyCount int
for _, node := range nodes { for _, node := range nodes {
@ -158,20 +158,20 @@ func (d *Daemon) CheckNodeReadyCount(c *check.C) (interface{}, check.CommentInte
} }
// CheckLocalNodeState returns the current swarm node state // CheckLocalNodeState returns the current swarm node state
func (d *Daemon) CheckLocalNodeState(c *check.C) (interface{}, check.CommentInterface) { func (d *Daemon) CheckLocalNodeState(c *testing.T) (interface{}, check.CommentInterface) {
info := d.SwarmInfo(c) info := d.SwarmInfo(c)
return info.LocalNodeState, nil return info.LocalNodeState, nil
} }
// CheckControlAvailable returns the current swarm control available // CheckControlAvailable returns the current swarm control available
func (d *Daemon) CheckControlAvailable(c *check.C) (interface{}, check.CommentInterface) { func (d *Daemon) CheckControlAvailable(c *testing.T) (interface{}, check.CommentInterface) {
info := d.SwarmInfo(c) info := d.SwarmInfo(c)
assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateActive) assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateActive)
return info.ControlAvailable, nil return info.ControlAvailable, nil
} }
// CheckLeader returns whether there is a leader on the swarm or not // CheckLeader returns whether there is a leader on the swarm or not
func (d *Daemon) CheckLeader(c *check.C) (interface{}, check.CommentInterface) { func (d *Daemon) CheckLeader(c *testing.T) (interface{}, check.CommentInterface) {
cli := d.NewClientT(c) cli := d.NewClientT(c)
defer cli.Close() defer cli.Close()

View file

@ -5,7 +5,7 @@ import (
"github.com/go-check/check" "github.com/go-check/check"
) )
func (s *DockerSwarmSuite) getDaemon(c *check.C, nodeID string) *daemon.Daemon { func (s *DockerSwarmSuite) getDaemon(c *testing.T, nodeID string) *daemon.Daemon {
s.daemonsLock.Lock() s.daemonsLock.Lock()
defer s.daemonsLock.Unlock() defer s.daemonsLock.Unlock()
for _, d := range s.daemons { for _, d := range s.daemons {
@ -18,6 +18,6 @@ func (s *DockerSwarmSuite) getDaemon(c *check.C, nodeID string) *daemon.Daemon {
} }
// nodeCmd executes a command on a given node via the normal docker socket // nodeCmd executes a command on a given node via the normal docker socket
func (s *DockerSwarmSuite) nodeCmd(c *check.C, id string, args ...string) (string, error) { func (s *DockerSwarmSuite) nodeCmd(c *testing.T, id string, args ...string) (string, error) {
return s.getDaemon(c, id).Cmd(args...) return s.getDaemon(c, id).Cmd(args...)
} }

View file

@ -23,7 +23,7 @@ import (
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
) )
func (s *DockerSuite) TestGetContainersAttachWebsocket(c *check.C) { func (s *DockerSuite) TestGetContainersAttachWebsocket(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-dit", "busybox", "cat") out, _ := dockerCmd(c, "run", "-dit", "busybox", "cat")
@ -76,7 +76,7 @@ func (s *DockerSuite) TestGetContainersAttachWebsocket(c *check.C) {
} }
// regression gh14320 // regression gh14320
func (s *DockerSuite) TestPostContainersAttachContainerNotFound(c *check.C) { func (s *DockerSuite) TestPostContainersAttachContainerNotFound(c *testing.T) {
resp, _, err := request.Post("/containers/doesnotexist/attach") resp, _, err := request.Post("/containers/doesnotexist/attach")
assert.NilError(c, err) assert.NilError(c, err)
// connection will shutdown, err should be "persistent connection closed" // connection will shutdown, err should be "persistent connection closed"
@ -87,7 +87,7 @@ func (s *DockerSuite) TestPostContainersAttachContainerNotFound(c *check.C) {
assert.Equal(c, string(content), expected) assert.Equal(c, string(content), expected)
} }
func (s *DockerSuite) TestGetContainersWsAttachContainerNotFound(c *check.C) { func (s *DockerSuite) TestGetContainersWsAttachContainerNotFound(c *testing.T) {
res, body, err := request.Get("/containers/doesnotexist/attach/ws") res, body, err := request.Get("/containers/doesnotexist/attach/ws")
assert.Equal(c, res.StatusCode, http.StatusNotFound) assert.Equal(c, res.StatusCode, http.StatusNotFound)
assert.NilError(c, err) assert.NilError(c, err)
@ -97,7 +97,7 @@ func (s *DockerSuite) TestGetContainersWsAttachContainerNotFound(c *check.C) {
assert.Assert(c, strings.Contains(getErrorMessage(c, b), expected)) assert.Assert(c, strings.Contains(getErrorMessage(c, b), expected))
} }
func (s *DockerSuite) TestPostContainersAttach(c *check.C) { func (s *DockerSuite) TestPostContainersAttach(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
expectSuccess := func(conn net.Conn, br *bufio.Reader, stream string, tty bool) { expectSuccess := func(conn net.Conn, br *bufio.Reader, stream string, tty bool) {

View file

@ -22,7 +22,7 @@ import (
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
) )
func (s *DockerSuite) TestBuildAPIDockerFileRemote(c *check.C) { func (s *DockerSuite) TestBuildAPIDockerFileRemote(c *testing.T) {
testRequires(c, NotUserNamespace) testRequires(c, NotUserNamespace)
var testD string var testD string
@ -53,7 +53,7 @@ RUN find /tmp/`
assert.Assert(c, !strings.Contains(out, "baz")) assert.Assert(c, !strings.Contains(out, "baz"))
} }
func (s *DockerSuite) TestBuildAPIRemoteTarballContext(c *check.C) { func (s *DockerSuite) TestBuildAPIRemoteTarballContext(c *testing.T) {
buffer := new(bytes.Buffer) buffer := new(bytes.Buffer)
tw := tar.NewWriter(buffer) tw := tar.NewWriter(buffer)
defer tw.Close() defer tw.Close()
@ -80,7 +80,7 @@ func (s *DockerSuite) TestBuildAPIRemoteTarballContext(c *check.C) {
b.Close() b.Close()
} }
func (s *DockerSuite) TestBuildAPIRemoteTarballContextWithCustomDockerfile(c *check.C) { func (s *DockerSuite) TestBuildAPIRemoteTarballContextWithCustomDockerfile(c *testing.T) {
buffer := new(bytes.Buffer) buffer := new(bytes.Buffer)
tw := tar.NewWriter(buffer) tw := tar.NewWriter(buffer)
defer tw.Close() defer tw.Close()
@ -134,7 +134,7 @@ RUN echo 'right'
assert.Assert(c, !strings.Contains(string(content), "wrong")) assert.Assert(c, !strings.Contains(string(content), "wrong"))
} }
func (s *DockerSuite) TestBuildAPILowerDockerfile(c *check.C) { func (s *DockerSuite) TestBuildAPILowerDockerfile(c *testing.T) {
git := fakegit.New(c, "repo", map[string]string{ git := fakegit.New(c, "repo", map[string]string{
"dockerfile": `FROM busybox "dockerfile": `FROM busybox
RUN echo from dockerfile`, RUN echo from dockerfile`,
@ -152,7 +152,7 @@ RUN echo from dockerfile`,
assert.Assert(c, is.Contains(out, "from dockerfile")) assert.Assert(c, is.Contains(out, "from dockerfile"))
} }
func (s *DockerSuite) TestBuildAPIBuildGitWithF(c *check.C) { func (s *DockerSuite) TestBuildAPIBuildGitWithF(c *testing.T) {
git := fakegit.New(c, "repo", map[string]string{ git := fakegit.New(c, "repo", map[string]string{
"baz": `FROM busybox "baz": `FROM busybox
RUN echo from baz`, RUN echo from baz`,
@ -173,7 +173,7 @@ RUN echo from Dockerfile`,
assert.Assert(c, is.Contains(out, "from baz")) assert.Assert(c, is.Contains(out, "from baz"))
} }
func (s *DockerSuite) TestBuildAPIDoubleDockerfile(c *check.C) { func (s *DockerSuite) TestBuildAPIDoubleDockerfile(c *testing.T) {
testRequires(c, UnixCli) // dockerfile overwrites Dockerfile on Windows testRequires(c, UnixCli) // dockerfile overwrites Dockerfile on Windows
git := fakegit.New(c, "repo", map[string]string{ git := fakegit.New(c, "repo", map[string]string{
"Dockerfile": `FROM busybox "Dockerfile": `FROM busybox
@ -195,7 +195,7 @@ RUN echo from dockerfile`,
assert.Assert(c, is.Contains(out, "from Dockerfile")) assert.Assert(c, is.Contains(out, "from Dockerfile"))
} }
func (s *DockerSuite) TestBuildAPIUnnormalizedTarPaths(c *check.C) { func (s *DockerSuite) TestBuildAPIUnnormalizedTarPaths(c *testing.T) {
// Make sure that build context tars with entries of the form // Make sure that build context tars with entries of the form
// x/./y don't cause caching false positives. // x/./y don't cause caching false positives.
@ -254,7 +254,7 @@ func (s *DockerSuite) TestBuildAPIUnnormalizedTarPaths(c *check.C) {
assert.Assert(c, imageA != imageB) assert.Assert(c, imageA != imageB)
} }
func (s *DockerSuite) TestBuildOnBuildWithCopy(c *check.C) { func (s *DockerSuite) TestBuildOnBuildWithCopy(c *testing.T) {
dockerfile := ` dockerfile := `
FROM ` + minimalBaseImage() + ` as onbuildbase FROM ` + minimalBaseImage() + ` as onbuildbase
ONBUILD COPY file /file ONBUILD COPY file /file
@ -279,7 +279,7 @@ func (s *DockerSuite) TestBuildOnBuildWithCopy(c *check.C) {
assert.Assert(c, is.Contains(string(out), "Successfully built")) assert.Assert(c, is.Contains(string(out), "Successfully built"))
} }
func (s *DockerSuite) TestBuildOnBuildCache(c *check.C) { func (s *DockerSuite) TestBuildOnBuildCache(c *testing.T) {
build := func(dockerfile string) []byte { build := func(dockerfile string) []byte {
ctx := fakecontext.New(c, "", ctx := fakecontext.New(c, "",
fakecontext.WithDockerfile(dockerfile), fakecontext.WithDockerfile(dockerfile),
@ -321,7 +321,7 @@ func (s *DockerSuite) TestBuildOnBuildCache(c *check.C) {
assert.Check(c, is.Equal(parentID, image.Parent)) assert.Check(c, is.Equal(parentID, image.Parent))
} }
func (s *DockerRegistrySuite) TestBuildCopyFromForcePull(c *check.C) { func (s *DockerRegistrySuite) TestBuildCopyFromForcePull(c *testing.T) {
client := testEnv.APIClient() client := testEnv.APIClient()
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL) repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
@ -358,7 +358,7 @@ func (s *DockerRegistrySuite) TestBuildCopyFromForcePull(c *check.C) {
assert.Check(c, is.Contains(string(out), "Successfully built")) assert.Check(c, is.Contains(string(out), "Successfully built"))
} }
func (s *DockerSuite) TestBuildAddRemoteNoDecompress(c *check.C) { func (s *DockerSuite) TestBuildAddRemoteNoDecompress(c *testing.T) {
buffer := new(bytes.Buffer) buffer := new(bytes.Buffer)
tw := tar.NewWriter(buffer) tw := tar.NewWriter(buffer)
dt := []byte("contents") dt := []byte("contents")
@ -402,7 +402,7 @@ func (s *DockerSuite) TestBuildAddRemoteNoDecompress(c *check.C) {
assert.Check(c, is.Contains(string(out), "Successfully built")) assert.Check(c, is.Contains(string(out), "Successfully built"))
} }
func (s *DockerSuite) TestBuildChownOnCopy(c *check.C) { func (s *DockerSuite) TestBuildChownOnCopy(c *testing.T) {
// new feature added in 1.31 - https://github.com/moby/moby/pull/34263 // new feature added in 1.31 - https://github.com/moby/moby/pull/34263
testRequires(c, DaemonIsLinux, MinimumAPIVersion("1.31")) testRequires(c, DaemonIsLinux, MinimumAPIVersion("1.31"))
dockerfile := `FROM busybox dockerfile := `FROM busybox
@ -432,7 +432,7 @@ func (s *DockerSuite) TestBuildChownOnCopy(c *check.C) {
assert.Check(c, is.Contains(string(out), "Successfully built")) assert.Check(c, is.Contains(string(out), "Successfully built"))
} }
func (s *DockerSuite) TestBuildCopyCacheOnFileChange(c *check.C) { func (s *DockerSuite) TestBuildCopyCacheOnFileChange(c *testing.T) {
dockerfile := `FROM busybox dockerfile := `FROM busybox
COPY file /file` COPY file /file`
@ -473,7 +473,7 @@ COPY file /file`
} }
} }
func (s *DockerSuite) TestBuildAddCacheOnFileChange(c *check.C) { func (s *DockerSuite) TestBuildAddCacheOnFileChange(c *testing.T) {
dockerfile := `FROM busybox dockerfile := `FROM busybox
ADD file /file` ADD file /file`
@ -514,7 +514,7 @@ ADD file /file`
} }
} }
func (s *DockerSuite) TestBuildScratchCopy(c *check.C) { func (s *DockerSuite) TestBuildScratchCopy(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerfile := `FROM scratch dockerfile := `FROM scratch
ADD Dockerfile / ADD Dockerfile /
@ -543,7 +543,7 @@ type buildLine struct {
} }
} }
func getImageIDsFromBuild(c *check.C, output []byte) []string { func getImageIDsFromBuild(c *testing.T, output []byte) []string {
var ids []string var ids []string
for _, line := range bytes.Split(output, []byte("\n")) { for _, line := range bytes.Split(output, []byte("\n")) {
if len(line) == 0 { if len(line) == 0 {

View file

@ -12,7 +12,7 @@ import (
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
) )
func (s *DockerSuite) TestBuildWithRecycleBin(c *check.C) { func (s *DockerSuite) TestBuildWithRecycleBin(c *testing.T) {
testRequires(c, DaemonIsWindows) testRequires(c, DaemonIsWindows)
dockerfile := "" + dockerfile := "" +

View file

@ -37,7 +37,7 @@ import (
"gotest.tools/poll" "gotest.tools/poll"
) )
func (s *DockerSuite) TestContainerAPIGetAll(c *check.C) { func (s *DockerSuite) TestContainerAPIGetAll(c *testing.T) {
startCount := getContainerCount(c) startCount := getContainerCount(c)
name := "getall" name := "getall"
dockerCmd(c, "run", "--name", name, "busybox", "true") dockerCmd(c, "run", "--name", name, "busybox", "true")
@ -57,7 +57,7 @@ func (s *DockerSuite) TestContainerAPIGetAll(c *check.C) {
} }
// regression test for empty json field being omitted #13691 // regression test for empty json field being omitted #13691
func (s *DockerSuite) TestContainerAPIGetJSONNoFieldsOmitted(c *check.C) { func (s *DockerSuite) TestContainerAPIGetJSONNoFieldsOmitted(c *testing.T) {
startCount := getContainerCount(c) startCount := getContainerCount(c)
dockerCmd(c, "run", "busybox", "true") dockerCmd(c, "run", "busybox", "true")
@ -97,7 +97,7 @@ func (s *DockerSuite) TestContainerAPIGetJSONNoFieldsOmitted(c *check.C) {
} }
} }
func (s *DockerSuite) TestContainerAPIGetExport(c *check.C) { func (s *DockerSuite) TestContainerAPIGetExport(c *testing.T) {
// Not supported on Windows as Windows does not support docker export // Not supported on Windows as Windows does not support docker export
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "exportcontainer" name := "exportcontainer"
@ -124,7 +124,7 @@ func (s *DockerSuite) TestContainerAPIGetExport(c *check.C) {
assert.Assert(c, found, checker.True, check.Commentf("The created test file has not been found in the exported image")) assert.Assert(c, found, checker.True, check.Commentf("The created test file has not been found in the exported image"))
} }
func (s *DockerSuite) TestContainerAPIGetChanges(c *check.C) { func (s *DockerSuite) TestContainerAPIGetChanges(c *testing.T) {
// Not supported on Windows as Windows does not support docker diff (/containers/name/changes) // Not supported on Windows as Windows does not support docker diff (/containers/name/changes)
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "changescontainer" name := "changescontainer"
@ -147,7 +147,7 @@ func (s *DockerSuite) TestContainerAPIGetChanges(c *check.C) {
assert.Assert(c, success, checker.True, check.Commentf("/etc/passwd has been removed but is not present in the diff")) assert.Assert(c, success, checker.True, check.Commentf("/etc/passwd has been removed but is not present in the diff"))
} }
func (s *DockerSuite) TestGetContainerStats(c *check.C) { func (s *DockerSuite) TestGetContainerStats(c *testing.T) {
var ( var (
name = "statscontainer" name = "statscontainer"
) )
@ -187,7 +187,7 @@ func (s *DockerSuite) TestGetContainerStats(c *check.C) {
} }
} }
func (s *DockerSuite) TestGetContainerStatsRmRunning(c *check.C) { func (s *DockerSuite) TestGetContainerStatsRmRunning(c *testing.T) {
out := runSleepingContainer(c) out := runSleepingContainer(c)
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
@ -254,7 +254,7 @@ func (c *ChannelBuffer) ReadTimeout(p []byte, n time.Duration) (int, error) {
// regression test for gh13421 // regression test for gh13421
// previous test was just checking one stat entry so it didn't fail (stats with // previous test was just checking one stat entry so it didn't fail (stats with
// stream false always return one stat) // stream false always return one stat)
func (s *DockerSuite) TestGetContainerStatsStream(c *check.C) { func (s *DockerSuite) TestGetContainerStatsStream(c *testing.T) {
name := "statscontainer" name := "statscontainer"
runSleepingContainer(c, "--name", name) runSleepingContainer(c, "--name", name)
@ -295,7 +295,7 @@ func (s *DockerSuite) TestGetContainerStatsStream(c *check.C) {
} }
} }
func (s *DockerSuite) TestGetContainerStatsNoStream(c *check.C) { func (s *DockerSuite) TestGetContainerStatsNoStream(c *testing.T) {
name := "statscontainer" name := "statscontainer"
runSleepingContainer(c, "--name", name) runSleepingContainer(c, "--name", name)
@ -335,7 +335,7 @@ func (s *DockerSuite) TestGetContainerStatsNoStream(c *check.C) {
} }
} }
func (s *DockerSuite) TestGetStoppedContainerStats(c *check.C) { func (s *DockerSuite) TestGetStoppedContainerStats(c *testing.T) {
name := "statscontainer" name := "statscontainer"
dockerCmd(c, "create", "--name", name, "busybox", "ps") dockerCmd(c, "create", "--name", name, "busybox", "ps")
@ -361,11 +361,11 @@ func (s *DockerSuite) TestGetStoppedContainerStats(c *check.C) {
} }
} }
func (s *DockerSuite) TestContainerAPIPause(c *check.C) { func (s *DockerSuite) TestContainerAPIPause(c *testing.T) {
// Problematic on Windows as Windows does not support pause // Problematic on Windows as Windows does not support pause
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
getPaused := func(c *check.C) []string { getPaused := func(c *testing.T) []string {
return strings.Fields(cli.DockerCmd(c, "ps", "-f", "status=paused", "-q", "-a").Combined()) return strings.Fields(cli.DockerCmd(c, "ps", "-f", "status=paused", "-q", "-a").Combined())
} }
@ -392,7 +392,7 @@ func (s *DockerSuite) TestContainerAPIPause(c *check.C) {
assert.Assert(c, pausedContainers, checker.HasLen, 0, check.Commentf("There should be no paused container.")) assert.Assert(c, pausedContainers, checker.HasLen, 0, check.Commentf("There should be no paused container."))
} }
func (s *DockerSuite) TestContainerAPITop(c *check.C) { func (s *DockerSuite) TestContainerAPITop(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "top") out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "top")
id := strings.TrimSpace(string(out)) id := strings.TrimSpace(string(out))
@ -415,7 +415,7 @@ func (s *DockerSuite) TestContainerAPITop(c *check.C) {
assert.Assert(c, top.Processes[1][10], checker.Equals, "top") assert.Assert(c, top.Processes[1][10], checker.Equals, "top")
} }
func (s *DockerSuite) TestContainerAPITopWindows(c *check.C) { func (s *DockerSuite) TestContainerAPITopWindows(c *testing.T) {
testRequires(c, DaemonIsWindows) testRequires(c, DaemonIsWindows)
out := runSleepingContainer(c, "-d") out := runSleepingContainer(c, "-d")
id := strings.TrimSpace(string(out)) id := strings.TrimSpace(string(out))
@ -446,7 +446,7 @@ func (s *DockerSuite) TestContainerAPITopWindows(c *check.C) {
assert.Assert(c, foundProcess, "expected to find %s: %v", expectedProcess, top.Processes) assert.Assert(c, foundProcess, "expected to find %s: %v", expectedProcess, top.Processes)
} }
func (s *DockerSuite) TestContainerAPICommit(c *check.C) { func (s *DockerSuite) TestContainerAPICommit(c *testing.T) {
cName := "testapicommit" cName := "testapicommit"
dockerCmd(c, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test") dockerCmd(c, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test")
@ -468,7 +468,7 @@ func (s *DockerSuite) TestContainerAPICommit(c *check.C) {
dockerCmd(c, "run", img.ID, "ls", "/test") dockerCmd(c, "run", img.ID, "ls", "/test")
} }
func (s *DockerSuite) TestContainerAPICommitWithLabelInConfig(c *check.C) { func (s *DockerSuite) TestContainerAPICommitWithLabelInConfig(c *testing.T) {
cName := "testapicommitwithconfig" cName := "testapicommitwithconfig"
dockerCmd(c, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test") dockerCmd(c, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test")
@ -500,7 +500,7 @@ func (s *DockerSuite) TestContainerAPICommitWithLabelInConfig(c *check.C) {
dockerCmd(c, "run", img.ID, "ls", "/test") dockerCmd(c, "run", img.ID, "ls", "/test")
} }
func (s *DockerSuite) TestContainerAPIBadPort(c *check.C) { func (s *DockerSuite) TestContainerAPIBadPort(c *testing.T) {
// TODO Windows to Windows CI - Port this test // TODO Windows to Windows CI - Port this test
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -527,7 +527,7 @@ func (s *DockerSuite) TestContainerAPIBadPort(c *check.C) {
assert.ErrorContains(c, err, `invalid port specification: "aa80"`) assert.ErrorContains(c, err, `invalid port specification: "aa80"`)
} }
func (s *DockerSuite) TestContainerAPICreate(c *check.C) { func (s *DockerSuite) TestContainerAPICreate(c *testing.T) {
config := containertypes.Config{ config := containertypes.Config{
Image: "busybox", Image: "busybox",
Cmd: []string{"/bin/sh", "-c", "touch /test && ls /test"}, Cmd: []string{"/bin/sh", "-c", "touch /test && ls /test"},
@ -544,7 +544,7 @@ func (s *DockerSuite) TestContainerAPICreate(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "/test") assert.Equal(c, strings.TrimSpace(out), "/test")
} }
func (s *DockerSuite) TestContainerAPICreateEmptyConfig(c *check.C) { func (s *DockerSuite) TestContainerAPICreateEmptyConfig(c *testing.T) {
cli, err := client.NewClientWithOpts(client.FromEnv) cli, err := client.NewClientWithOpts(client.FromEnv)
assert.NilError(c, err) assert.NilError(c, err)
@ -556,7 +556,7 @@ func (s *DockerSuite) TestContainerAPICreateEmptyConfig(c *check.C) {
assert.ErrorContains(c, err, expected) assert.ErrorContains(c, err, expected)
} }
func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *check.C) { func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *testing.T) {
// Container creation must fail if client specified configurations for more than one network // Container creation must fail if client specified configurations for more than one network
config := containertypes.Config{ config := containertypes.Config{
Image: "busybox", Image: "busybox",
@ -583,20 +583,20 @@ func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *check.C) {
assert.Assert(c, msg, checker.Contains, "net3") assert.Assert(c, msg, checker.Contains, "net3")
} }
func (s *DockerSuite) TestContainerAPICreateBridgeNetworkMode(c *check.C) { func (s *DockerSuite) TestContainerAPICreateBridgeNetworkMode(c *testing.T) {
// Windows does not support bridge // Windows does not support bridge
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
UtilCreateNetworkMode(c, "bridge") UtilCreateNetworkMode(c, "bridge")
} }
func (s *DockerSuite) TestContainerAPICreateOtherNetworkModes(c *check.C) { func (s *DockerSuite) TestContainerAPICreateOtherNetworkModes(c *testing.T) {
// Windows does not support these network modes // Windows does not support these network modes
testRequires(c, DaemonIsLinux, NotUserNamespace) testRequires(c, DaemonIsLinux, NotUserNamespace)
UtilCreateNetworkMode(c, "host") UtilCreateNetworkMode(c, "host")
UtilCreateNetworkMode(c, "container:web1") UtilCreateNetworkMode(c, "container:web1")
} }
func UtilCreateNetworkMode(c *check.C, networkMode containertypes.NetworkMode) { func UtilCreateNetworkMode(c *testing.T, networkMode containertypes.NetworkMode) {
config := containertypes.Config{ config := containertypes.Config{
Image: "busybox", Image: "busybox",
} }
@ -618,7 +618,7 @@ func UtilCreateNetworkMode(c *check.C, networkMode containertypes.NetworkMode) {
assert.Assert(c, containerJSON.HostConfig.NetworkMode, checker.Equals, containertypes.NetworkMode(networkMode), check.Commentf("Mismatched NetworkMode")) assert.Assert(c, containerJSON.HostConfig.NetworkMode, checker.Equals, containertypes.NetworkMode(networkMode), check.Commentf("Mismatched NetworkMode"))
} }
func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *check.C) { func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T) {
// TODO Windows to Windows CI. The CpuShares part could be ported. // TODO Windows to Windows CI. The CpuShares part could be ported.
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
config := containertypes.Config{ config := containertypes.Config{
@ -649,7 +649,7 @@ func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *check.C) {
assert.Assert(c, outCpuset, checker.Equals, "0") assert.Assert(c, outCpuset, checker.Equals, "0")
} }
func (s *DockerSuite) TestContainerAPIVerifyHeader(c *check.C) { func (s *DockerSuite) TestContainerAPIVerifyHeader(c *testing.T) {
config := map[string]interface{}{ config := map[string]interface{}{
"Image": "busybox", "Image": "busybox",
} }
@ -690,7 +690,7 @@ func (s *DockerSuite) TestContainerAPIVerifyHeader(c *check.C) {
} }
//Issue 14230. daemon should return 500 for invalid port syntax //Issue 14230. daemon should return 500 for invalid port syntax
func (s *DockerSuite) TestContainerAPIInvalidPortSyntax(c *check.C) { func (s *DockerSuite) TestContainerAPIInvalidPortSyntax(c *testing.T) {
config := `{ config := `{
"Image": "busybox", "Image": "busybox",
"HostConfig": { "HostConfig": {
@ -716,7 +716,7 @@ func (s *DockerSuite) TestContainerAPIInvalidPortSyntax(c *check.C) {
assert.Assert(c, string(b[:]), checker.Contains, "invalid port") assert.Assert(c, string(b[:]), checker.Contains, "invalid port")
} }
func (s *DockerSuite) TestContainerAPIRestartPolicyInvalidPolicyName(c *check.C) { func (s *DockerSuite) TestContainerAPIRestartPolicyInvalidPolicyName(c *testing.T) {
config := `{ config := `{
"Image": "busybox", "Image": "busybox",
"HostConfig": { "HostConfig": {
@ -740,7 +740,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyInvalidPolicyName(c *check.C)
assert.Assert(c, string(b[:]), checker.Contains, "invalid restart policy") assert.Assert(c, string(b[:]), checker.Contains, "invalid restart policy")
} }
func (s *DockerSuite) TestContainerAPIRestartPolicyRetryMismatch(c *check.C) { func (s *DockerSuite) TestContainerAPIRestartPolicyRetryMismatch(c *testing.T) {
config := `{ config := `{
"Image": "busybox", "Image": "busybox",
"HostConfig": { "HostConfig": {
@ -764,7 +764,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyRetryMismatch(c *check.C) {
assert.Assert(c, string(b[:]), checker.Contains, "maximum retry count cannot be used with restart policy") assert.Assert(c, string(b[:]), checker.Contains, "maximum retry count cannot be used with restart policy")
} }
func (s *DockerSuite) TestContainerAPIRestartPolicyNegativeRetryCount(c *check.C) { func (s *DockerSuite) TestContainerAPIRestartPolicyNegativeRetryCount(c *testing.T) {
config := `{ config := `{
"Image": "busybox", "Image": "busybox",
"HostConfig": { "HostConfig": {
@ -788,7 +788,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyNegativeRetryCount(c *check.C
assert.Assert(c, string(b[:]), checker.Contains, "maximum retry count cannot be negative") assert.Assert(c, string(b[:]), checker.Contains, "maximum retry count cannot be negative")
} }
func (s *DockerSuite) TestContainerAPIRestartPolicyDefaultRetryCount(c *check.C) { func (s *DockerSuite) TestContainerAPIRestartPolicyDefaultRetryCount(c *testing.T) {
config := `{ config := `{
"Image": "busybox", "Image": "busybox",
"HostConfig": { "HostConfig": {
@ -806,7 +806,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyDefaultRetryCount(c *check.C)
// Issue 7941 - test to make sure a "null" in JSON is just ignored. // Issue 7941 - test to make sure a "null" in JSON is just ignored.
// W/o this fix a null in JSON would be parsed into a string var as "null" // W/o this fix a null in JSON would be parsed into a string var as "null"
func (s *DockerSuite) TestContainerAPIPostCreateNull(c *check.C) { func (s *DockerSuite) TestContainerAPIPostCreateNull(c *testing.T) {
config := `{ config := `{
"Hostname":"", "Hostname":"",
"Domainname":"", "Domainname":"",
@ -850,7 +850,7 @@ func (s *DockerSuite) TestContainerAPIPostCreateNull(c *check.C) {
assert.Assert(c, outMemorySwap, checker.Equals, "0") assert.Assert(c, outMemorySwap, checker.Equals, "0")
} }
func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *check.C) { func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *testing.T) {
// TODO Windows: Port once memory is supported // TODO Windows: Port once memory is supported
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
config := `{ config := `{
@ -874,7 +874,7 @@ func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *check.C) {
assert.Assert(c, string(b), checker.Contains, "Minimum memory limit allowed is 4MB") assert.Assert(c, string(b), checker.Contains, "Minimum memory limit allowed is 4MB")
} }
func (s *DockerSuite) TestContainerAPIRename(c *check.C) { func (s *DockerSuite) TestContainerAPIRename(c *testing.T) {
out, _ := dockerCmd(c, "run", "--name", "TestContainerAPIRename", "-d", "busybox", "sh") out, _ := dockerCmd(c, "run", "--name", "TestContainerAPIRename", "-d", "busybox", "sh")
containerID := strings.TrimSpace(out) containerID := strings.TrimSpace(out)
@ -891,7 +891,7 @@ func (s *DockerSuite) TestContainerAPIRename(c *check.C) {
assert.Assert(c, name, checker.Equals, "/"+newName, check.Commentf("Failed to rename container")) assert.Assert(c, name, checker.Equals, "/"+newName, check.Commentf("Failed to rename container"))
} }
func (s *DockerSuite) TestContainerAPIKill(c *check.C) { func (s *DockerSuite) TestContainerAPIKill(c *testing.T) {
name := "test-api-kill" name := "test-api-kill"
runSleepingContainer(c, "-i", "--name", name) runSleepingContainer(c, "-i", "--name", name)
@ -906,7 +906,7 @@ func (s *DockerSuite) TestContainerAPIKill(c *check.C) {
assert.Assert(c, state, checker.Equals, "false", check.Commentf("got wrong State from container %s: %q", name, state)) assert.Assert(c, state, checker.Equals, "false", check.Commentf("got wrong State from container %s: %q", name, state))
} }
func (s *DockerSuite) TestContainerAPIRestart(c *check.C) { func (s *DockerSuite) TestContainerAPIRestart(c *testing.T) {
name := "test-api-restart" name := "test-api-restart"
runSleepingContainer(c, "-di", "--name", name) runSleepingContainer(c, "-di", "--name", name)
cli, err := client.NewClientWithOpts(client.FromEnv) cli, err := client.NewClientWithOpts(client.FromEnv)
@ -920,7 +920,7 @@ func (s *DockerSuite) TestContainerAPIRestart(c *check.C) {
assert.Assert(c, waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second), checker.IsNil) assert.Assert(c, waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second), checker.IsNil)
} }
func (s *DockerSuite) TestContainerAPIRestartNotimeoutParam(c *check.C) { func (s *DockerSuite) TestContainerAPIRestartNotimeoutParam(c *testing.T) {
name := "test-api-restart-no-timeout-param" name := "test-api-restart-no-timeout-param"
out := runSleepingContainer(c, "-di", "--name", name) out := runSleepingContainer(c, "-di", "--name", name)
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
@ -936,7 +936,7 @@ func (s *DockerSuite) TestContainerAPIRestartNotimeoutParam(c *check.C) {
assert.Assert(c, waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second), checker.IsNil) assert.Assert(c, waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second), checker.IsNil)
} }
func (s *DockerSuite) TestContainerAPIStart(c *check.C) { func (s *DockerSuite) TestContainerAPIStart(c *testing.T) {
name := "testing-start" name := "testing-start"
config := containertypes.Config{ config := containertypes.Config{
Image: "busybox", Image: "busybox",
@ -962,7 +962,7 @@ func (s *DockerSuite) TestContainerAPIStart(c *check.C) {
// TODO(tibor): figure out why this doesn't work on windows // TODO(tibor): figure out why this doesn't work on windows
} }
func (s *DockerSuite) TestContainerAPIStop(c *check.C) { func (s *DockerSuite) TestContainerAPIStop(c *testing.T) {
name := "test-api-stop" name := "test-api-stop"
runSleepingContainer(c, "-i", "--name", name) runSleepingContainer(c, "-i", "--name", name)
timeout := 30 * time.Second timeout := 30 * time.Second
@ -981,7 +981,7 @@ func (s *DockerSuite) TestContainerAPIStop(c *check.C) {
assert.NilError(c, err) assert.NilError(c, err)
} }
func (s *DockerSuite) TestContainerAPIWait(c *check.C) { func (s *DockerSuite) TestContainerAPIWait(c *testing.T) {
name := "test-api-wait" name := "test-api-wait"
sleepCmd := "/bin/sleep" sleepCmd := "/bin/sleep"
@ -1004,7 +1004,7 @@ func (s *DockerSuite) TestContainerAPIWait(c *check.C) {
} }
} }
func (s *DockerSuite) TestContainerAPICopyNotExistsAnyMore(c *check.C) { func (s *DockerSuite) TestContainerAPICopyNotExistsAnyMore(c *testing.T) {
name := "test-container-api-copy" name := "test-container-api-copy"
dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test.txt") dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test.txt")
@ -1017,7 +1017,7 @@ func (s *DockerSuite) TestContainerAPICopyNotExistsAnyMore(c *check.C) {
assert.Equal(c, res.StatusCode, http.StatusNotFound) assert.Equal(c, res.StatusCode, http.StatusNotFound)
} }
func (s *DockerSuite) TestContainerAPICopyPre124(c *check.C) { func (s *DockerSuite) TestContainerAPICopyPre124(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
name := "test-container-api-copy" name := "test-container-api-copy"
dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test.txt") dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test.txt")
@ -1047,7 +1047,7 @@ func (s *DockerSuite) TestContainerAPICopyPre124(c *check.C) {
assert.Assert(c, found, checker.True) assert.Assert(c, found, checker.True)
} }
func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPre124(c *check.C) { func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPre124(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
name := "test-container-api-copy-resource-empty" name := "test-container-api-copy-resource-empty"
dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test.txt") dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test.txt")
@ -1068,7 +1068,7 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPre124(c *check.C) {
assert.Assert(c, string(b), checker.Matches, "Path cannot be empty\n") assert.Assert(c, string(b), checker.Matches, "Path cannot be empty\n")
} }
func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *check.C) { func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
name := "test-container-api-copy-resource-not-found" name := "test-container-api-copy-resource-not-found"
dockerCmd(c, "run", "--name", name, "busybox") dockerCmd(c, "run", "--name", name, "busybox")
@ -1089,7 +1089,7 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *check.C)
assert.Assert(c, string(b), checker.Matches, "Could not find the file /notexist in container "+name+"\n") assert.Assert(c, string(b), checker.Matches, "Could not find the file /notexist in container "+name+"\n")
} }
func (s *DockerSuite) TestContainerAPICopyContainerNotFoundPr124(c *check.C) { func (s *DockerSuite) TestContainerAPICopyContainerNotFoundPr124(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
postData := types.CopyConfig{ postData := types.CopyConfig{
Resource: "/something", Resource: "/something",
@ -1100,7 +1100,7 @@ func (s *DockerSuite) TestContainerAPICopyContainerNotFoundPr124(c *check.C) {
assert.Equal(c, res.StatusCode, http.StatusNotFound) assert.Equal(c, res.StatusCode, http.StatusNotFound)
} }
func (s *DockerSuite) TestContainerAPIDelete(c *check.C) { func (s *DockerSuite) TestContainerAPIDelete(c *testing.T) {
out := runSleepingContainer(c) out := runSleepingContainer(c)
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
@ -1116,7 +1116,7 @@ func (s *DockerSuite) TestContainerAPIDelete(c *check.C) {
assert.NilError(c, err) assert.NilError(c, err)
} }
func (s *DockerSuite) TestContainerAPIDeleteNotExist(c *check.C) { func (s *DockerSuite) TestContainerAPIDeleteNotExist(c *testing.T) {
cli, err := client.NewClientWithOpts(client.FromEnv) cli, err := client.NewClientWithOpts(client.FromEnv)
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
@ -1125,7 +1125,7 @@ func (s *DockerSuite) TestContainerAPIDeleteNotExist(c *check.C) {
assert.ErrorContains(c, err, "No such container: doesnotexist") assert.ErrorContains(c, err, "No such container: doesnotexist")
} }
func (s *DockerSuite) TestContainerAPIDeleteForce(c *check.C) { func (s *DockerSuite) TestContainerAPIDeleteForce(c *testing.T) {
out := runSleepingContainer(c) out := runSleepingContainer(c)
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
assert.NilError(c, waitRun(id)) assert.NilError(c, waitRun(id))
@ -1142,7 +1142,7 @@ func (s *DockerSuite) TestContainerAPIDeleteForce(c *check.C) {
assert.NilError(c, err) assert.NilError(c, err)
} }
func (s *DockerSuite) TestContainerAPIDeleteRemoveLinks(c *check.C) { func (s *DockerSuite) TestContainerAPIDeleteRemoveLinks(c *testing.T) {
// Windows does not support links // Windows does not support links
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "--name", "tlink1", "busybox", "top") out, _ := dockerCmd(c, "run", "-d", "--name", "tlink1", "busybox", "top")
@ -1173,7 +1173,7 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveLinks(c *check.C) {
assert.Assert(c, linksPostRm, checker.Equals, "null", check.Commentf("call to api deleteContainer links should have removed the specified links")) assert.Assert(c, linksPostRm, checker.Equals, "null", check.Commentf("call to api deleteContainer links should have removed the specified links"))
} }
func (s *DockerSuite) TestContainerAPIDeleteConflict(c *check.C) { func (s *DockerSuite) TestContainerAPIDeleteConflict(c *testing.T) {
out := runSleepingContainer(c) out := runSleepingContainer(c)
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
@ -1188,7 +1188,7 @@ func (s *DockerSuite) TestContainerAPIDeleteConflict(c *check.C) {
assert.ErrorContains(c, err, expected) assert.ErrorContains(c, err, expected)
} }
func (s *DockerSuite) TestContainerAPIDeleteRemoveVolume(c *check.C) { func (s *DockerSuite) TestContainerAPIDeleteRemoveVolume(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
vol := "/testvolume" vol := "/testvolume"
@ -1223,7 +1223,7 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveVolume(c *check.C) {
} }
// Regression test for https://github.com/docker/docker/issues/6231 // Regression test for https://github.com/docker/docker/issues/6231
func (s *DockerSuite) TestContainerAPIChunkedEncoding(c *check.C) { func (s *DockerSuite) TestContainerAPIChunkedEncoding(c *testing.T) {
config := map[string]interface{}{ config := map[string]interface{}{
"Image": "busybox", "Image": "busybox",
@ -1243,7 +1243,7 @@ func (s *DockerSuite) TestContainerAPIChunkedEncoding(c *check.C) {
assert.Equal(c, resp.StatusCode, http.StatusCreated) assert.Equal(c, resp.StatusCode, http.StatusCreated)
} }
func (s *DockerSuite) TestContainerAPIPostContainerStop(c *check.C) { func (s *DockerSuite) TestContainerAPIPostContainerStop(c *testing.T) {
out := runSleepingContainer(c) out := runSleepingContainer(c)
containerID := strings.TrimSpace(out) containerID := strings.TrimSpace(out)
@ -1259,7 +1259,7 @@ func (s *DockerSuite) TestContainerAPIPostContainerStop(c *check.C) {
} }
// #14170 // #14170
func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *check.C) { func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *testing.T) {
config := containertypes.Config{ config := containertypes.Config{
Image: "busybox", Image: "busybox",
Entrypoint: []string{"echo"}, Entrypoint: []string{"echo"},
@ -1287,7 +1287,7 @@ func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *c
} }
// #14170 // #14170
func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *check.C) { func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *testing.T) {
config := containertypes.Config{ config := containertypes.Config{
Image: "busybox", Image: "busybox",
Cmd: []string{"echo", "hello", "world"}, Cmd: []string{"echo", "hello", "world"},
@ -1316,7 +1316,7 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *check.C) {
// regression #14318 // regression #14318
// for backward compatibility testing with and without CAP_ prefix // for backward compatibility testing with and without CAP_ prefix
// and with upper and lowercase // and with upper and lowercase
func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *check.C) { func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *testing.T) {
// Windows doesn't support CapAdd/CapDrop // Windows doesn't support CapAdd/CapDrop
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
config := struct { config := struct {
@ -1345,7 +1345,7 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *che
} }
// #14915 // #14915
func (s *DockerSuite) TestContainerAPICreateNoHostConfig118(c *check.C) { func (s *DockerSuite) TestContainerAPICreateNoHostConfig118(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows only support 1.25 or later testRequires(c, DaemonIsLinux) // Windows only support 1.25 or later
config := containertypes.Config{ config := containertypes.Config{
Image: "busybox", Image: "busybox",
@ -1361,7 +1361,7 @@ func (s *DockerSuite) TestContainerAPICreateNoHostConfig118(c *check.C) {
// Ensure an error occurs when you have a container read-only rootfs but you // Ensure an error occurs when you have a container read-only rootfs but you
// extract an archive to a symlink in a writable volume which points to a // extract an archive to a symlink in a writable volume which points to a
// directory outside of the volume. // directory outside of the volume.
func (s *DockerSuite) TestPutContainerArchiveErrSymlinkInVolumeToReadOnlyRootfs(c *check.C) { func (s *DockerSuite) TestPutContainerArchiveErrSymlinkInVolumeToReadOnlyRootfs(c *testing.T) {
// Windows does not support read-only rootfs // Windows does not support read-only rootfs
// Requires local volume mount bind. // Requires local volume mount bind.
// --read-only + userns has remount issues // --read-only + userns has remount issues
@ -1387,7 +1387,7 @@ func (s *DockerSuite) TestPutContainerArchiveErrSymlinkInVolumeToReadOnlyRootfs(
assert.ErrorContains(c, err, "container rootfs is marked read-only") assert.ErrorContains(c, err, "container rootfs is marked read-only")
} }
func (s *DockerSuite) TestPostContainersCreateWithWrongCpusetValues(c *check.C) { func (s *DockerSuite) TestPostContainersCreateWithWrongCpusetValues(c *testing.T) {
// Not supported on Windows // Not supported on Windows
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -1420,7 +1420,7 @@ func (s *DockerSuite) TestPostContainersCreateWithWrongCpusetValues(c *check.C)
assert.ErrorContains(c, err, expected) assert.ErrorContains(c, err, expected)
} }
func (s *DockerSuite) TestPostContainersCreateShmSizeNegative(c *check.C) { func (s *DockerSuite) TestPostContainersCreateShmSizeNegative(c *testing.T) {
// ShmSize is not supported on Windows // ShmSize is not supported on Windows
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
config := containertypes.Config{ config := containertypes.Config{
@ -1438,7 +1438,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeNegative(c *check.C) {
assert.ErrorContains(c, err, "SHM size can not be less than 0") assert.ErrorContains(c, err, "SHM size can not be less than 0")
} }
func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *check.C) { func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *testing.T) {
// ShmSize is not supported on Windows // ShmSize is not supported on Windows
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
var defaultSHMSize int64 = 67108864 var defaultSHMSize int64 = 67108864
@ -1466,7 +1466,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *check.
} }
} }
func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *check.C) { func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *testing.T) {
// ShmSize is not supported on Windows // ShmSize is not supported on Windows
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
config := containertypes.Config{ config := containertypes.Config{
@ -1493,7 +1493,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *check.C) {
} }
} }
func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *check.C) { func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *testing.T) {
// ShmSize is not supported on Windows // ShmSize is not supported on Windows
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
config := containertypes.Config{ config := containertypes.Config{
@ -1524,7 +1524,7 @@ func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *check.C) {
} }
} }
func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(c *check.C) { func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(c *testing.T) {
// Swappiness is not supported on Windows // Swappiness is not supported on Windows
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
config := containertypes.Config{ config := containertypes.Config{
@ -1549,7 +1549,7 @@ func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(
} }
// check validation is done daemon side and not only in cli // check validation is done daemon side and not only in cli
func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *check.C) { func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *testing.T) {
// OomScoreAdj is not supported on Windows // OomScoreAdj is not supported on Windows
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -1583,7 +1583,7 @@ func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *che
} }
// test case for #22210 where an empty container name caused panic. // test case for #22210 where an empty container name caused panic.
func (s *DockerSuite) TestContainerAPIDeleteWithEmptyName(c *check.C) { func (s *DockerSuite) TestContainerAPIDeleteWithEmptyName(c *testing.T) {
cli, err := client.NewClientWithOpts(client.FromEnv) cli, err := client.NewClientWithOpts(client.FromEnv)
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
@ -1592,7 +1592,7 @@ func (s *DockerSuite) TestContainerAPIDeleteWithEmptyName(c *check.C) {
assert.ErrorContains(c, err, "No such container") assert.ErrorContains(c, err, "No such container")
} }
func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *check.C) { func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) {
// Problematic on Windows as Windows does not support stats // Problematic on Windows as Windows does not support stats
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -1641,7 +1641,7 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *check.C) {
} }
} }
func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *check.C) { func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
type testCase struct { type testCase struct {
config containertypes.Config config containertypes.Config
hostConfig containertypes.HostConfig hostConfig containertypes.HostConfig
@ -1932,7 +1932,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *check.C) {
} }
} }
func (s *DockerSuite) TestContainerAPICreateMountsBindRead(c *check.C) { func (s *DockerSuite) TestContainerAPICreateMountsBindRead(c *testing.T) {
testRequires(c, NotUserNamespace, testEnv.IsLocalDaemon) testRequires(c, NotUserNamespace, testEnv.IsLocalDaemon)
// also with data in the host side // also with data in the host side
prefix, slash := getPrefixAndSlashFromDaemonPlatform() prefix, slash := getPrefixAndSlashFromDaemonPlatform()
@ -1963,7 +1963,7 @@ func (s *DockerSuite) TestContainerAPICreateMountsBindRead(c *check.C) {
} }
// Test Mounts comes out as expected for the MountPoint // Test Mounts comes out as expected for the MountPoint
func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *check.C) { func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) {
prefix, slash := getPrefixAndSlashFromDaemonPlatform() prefix, slash := getPrefixAndSlashFromDaemonPlatform()
destPath := prefix + slash + "foo" destPath := prefix + slash + "foo"
@ -2177,7 +2177,7 @@ func containerExit(apiclient client.APIClient, name string) func(poll.LogT) poll
} }
} }
func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *check.C) { func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
type testCase struct { type testCase struct {
cfg mounttypes.Mount cfg mounttypes.Mount
@ -2227,7 +2227,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *check.C) {
// Regression test for #33334 // Regression test for #33334
// Makes sure that when a container which has a custom stop signal + restart=always // Makes sure that when a container which has a custom stop signal + restart=always
// gets killed (with SIGKILL) by the kill API, that the restart policy is cancelled. // gets killed (with SIGKILL) by the kill API, that the restart policy is cancelled.
func (s *DockerSuite) TestContainerKillCustomStopSignal(c *check.C) { func (s *DockerSuite) TestContainerKillCustomStopSignal(c *testing.T) {
id := strings.TrimSpace(runSleepingContainer(c, "--stop-signal=SIGTERM", "--restart=always")) id := strings.TrimSpace(runSleepingContainer(c, "--stop-signal=SIGTERM", "--restart=always"))
res, _, err := request.Post("/containers/" + id + "/kill") res, _, err := request.Post("/containers/" + id + "/kill")
assert.NilError(c, err) assert.NilError(c, err)

View file

@ -18,7 +18,7 @@ import (
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
) )
func (s *DockerSuite) TestContainersAPICreateMountsBindNamedPipe(c *check.C) { func (s *DockerSuite) TestContainersAPICreateMountsBindNamedPipe(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsWindowsAtLeastBuild(16299)) // Named pipe support was added in RS3 testRequires(c, testEnv.IsLocalDaemon, DaemonIsWindowsAtLeastBuild(16299)) // Named pipe support was added in RS3
// Create a host pipe to map into the container // Create a host pipe to map into the container

View file

@ -15,7 +15,7 @@ import (
"gotest.tools/assert" "gotest.tools/assert"
) )
func (s *DockerSuite) TestExecResizeAPIHeightWidthNoInt(c *check.C) { func (s *DockerSuite) TestExecResizeAPIHeightWidthNoInt(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "top") out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
@ -31,7 +31,7 @@ func (s *DockerSuite) TestExecResizeAPIHeightWidthNoInt(c *check.C) {
} }
// Part of #14845 // Part of #14845
func (s *DockerSuite) TestExecResizeImmediatelyAfterExecStart(c *check.C) { func (s *DockerSuite) TestExecResizeImmediatelyAfterExecStart(c *testing.T) {
name := "exec_resize_test" name := "exec_resize_test"
dockerCmd(c, "run", "-d", "-i", "-t", "--name", name, "--restart", "always", "busybox", "/bin/sh") dockerCmd(c, "run", "-d", "-i", "-t", "--name", name, "--restart", "always", "busybox", "/bin/sh")

View file

@ -21,7 +21,7 @@ import (
) )
// Regression test for #9414 // Regression test for #9414
func (s *DockerSuite) TestExecAPICreateNoCmd(c *check.C) { func (s *DockerSuite) TestExecAPICreateNoCmd(c *testing.T) {
name := "exec_test" name := "exec_test"
dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh") dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
@ -37,7 +37,7 @@ func (s *DockerSuite) TestExecAPICreateNoCmd(c *check.C) {
assert.Assert(c, strings.Contains(getErrorMessage(c, b), "No exec command specified"), "Expected message when creating exec command with no Cmd specified") assert.Assert(c, strings.Contains(getErrorMessage(c, b), "No exec command specified"), "Expected message when creating exec command with no Cmd specified")
} }
func (s *DockerSuite) TestExecAPICreateNoValidContentType(c *check.C) { func (s *DockerSuite) TestExecAPICreateNoValidContentType(c *testing.T) {
name := "exec_test" name := "exec_test"
dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh") dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
@ -58,7 +58,7 @@ func (s *DockerSuite) TestExecAPICreateNoValidContentType(c *check.C) {
assert.Assert(c, strings.Contains(getErrorMessage(c, b), "Content-Type specified"), "Expected message when creating exec command with invalid Content-Type specified") assert.Assert(c, strings.Contains(getErrorMessage(c, b), "Content-Type specified"), "Expected message when creating exec command with invalid Content-Type specified")
} }
func (s *DockerSuite) TestExecAPICreateContainerPaused(c *check.C) { func (s *DockerSuite) TestExecAPICreateContainerPaused(c *testing.T) {
// Not relevant on Windows as Windows containers cannot be paused // Not relevant on Windows as Windows containers cannot be paused
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "exec_create_test" name := "exec_create_test"
@ -77,7 +77,7 @@ func (s *DockerSuite) TestExecAPICreateContainerPaused(c *check.C) {
assert.ErrorContains(c, err, "Container "+name+" is paused, unpause the container before exec", "Expected message when creating exec command with Container %s is paused", name) assert.ErrorContains(c, err, "Container "+name+" is paused, unpause the container before exec", "Expected message when creating exec command with Container %s is paused", name)
} }
func (s *DockerSuite) TestExecAPIStart(c *check.C) { func (s *DockerSuite) TestExecAPIStart(c *testing.T) {
testRequires(c, DaemonIsLinux) // Uses pause/unpause but bits may be salvageable to Windows to Windows CI testRequires(c, DaemonIsLinux) // Uses pause/unpause but bits may be salvageable to Windows to Windows CI
dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top") dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top")
@ -104,7 +104,7 @@ func (s *DockerSuite) TestExecAPIStart(c *check.C) {
startExec(c, id, http.StatusOK) startExec(c, id, http.StatusOK)
} }
func (s *DockerSuite) TestExecAPIStartEnsureHeaders(c *check.C) { func (s *DockerSuite) TestExecAPIStartEnsureHeaders(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top") dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top")
@ -114,7 +114,7 @@ func (s *DockerSuite) TestExecAPIStartEnsureHeaders(c *check.C) {
assert.Assert(c, resp.Header.Get("Server") != "") assert.Assert(c, resp.Header.Get("Server") != "")
} }
func (s *DockerSuite) TestExecAPIStartBackwardsCompatible(c *check.C) { func (s *DockerSuite) TestExecAPIStartBackwardsCompatible(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
runSleepingContainer(c, "-d", "--name", "test") runSleepingContainer(c, "-d", "--name", "test")
id := createExec(c, "test") id := createExec(c, "test")
@ -129,7 +129,7 @@ func (s *DockerSuite) TestExecAPIStartBackwardsCompatible(c *check.C) {
} }
// #19362 // #19362
func (s *DockerSuite) TestExecAPIStartMultipleTimesError(c *check.C) { func (s *DockerSuite) TestExecAPIStartMultipleTimesError(c *testing.T) {
runSleepingContainer(c, "-d", "--name", "test") runSleepingContainer(c, "-d", "--name", "test")
execID := createExec(c, "test") execID := createExec(c, "test")
startExec(c, execID, http.StatusOK) startExec(c, execID, http.StatusOK)
@ -139,7 +139,7 @@ func (s *DockerSuite) TestExecAPIStartMultipleTimesError(c *check.C) {
} }
// #20638 // #20638
func (s *DockerSuite) TestExecAPIStartWithDetach(c *check.C) { func (s *DockerSuite) TestExecAPIStartWithDetach(c *testing.T) {
name := "foo" name := "foo"
runSleepingContainer(c, "-d", "-t", "--name", name) runSleepingContainer(c, "-d", "-t", "--name", name)
@ -170,7 +170,7 @@ func (s *DockerSuite) TestExecAPIStartWithDetach(c *check.C) {
} }
// #30311 // #30311
func (s *DockerSuite) TestExecAPIStartValidCommand(c *check.C) { func (s *DockerSuite) TestExecAPIStartValidCommand(c *testing.T) {
name := "exec_test" name := "exec_test"
dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh") dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
@ -186,7 +186,7 @@ func (s *DockerSuite) TestExecAPIStartValidCommand(c *check.C) {
} }
// #30311 // #30311
func (s *DockerSuite) TestExecAPIStartInvalidCommand(c *check.C) { func (s *DockerSuite) TestExecAPIStartInvalidCommand(c *testing.T) {
name := "exec_test" name := "exec_test"
dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh") dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
@ -204,7 +204,7 @@ func (s *DockerSuite) TestExecAPIStartInvalidCommand(c *check.C) {
assert.Assert(c, inspectJSON.ExecIDs == nil) assert.Assert(c, inspectJSON.ExecIDs == nil)
} }
func (s *DockerSuite) TestExecStateCleanup(c *check.C) { func (s *DockerSuite) TestExecStateCleanup(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
// This test checks accidental regressions. Not part of stable API. // This test checks accidental regressions. Not part of stable API.
@ -215,7 +215,7 @@ func (s *DockerSuite) TestExecStateCleanup(c *check.C) {
stateDir := "/var/run/docker/containerd/" + cid stateDir := "/var/run/docker/containerd/" + cid
checkReadDir := func(c *check.C) (interface{}, check.CommentInterface) { checkReadDir := func(c *testing.T) (interface{}, check.CommentInterface) {
fi, err := ioutil.ReadDir(stateDir) fi, err := ioutil.ReadDir(stateDir)
assert.NilError(c, err) assert.NilError(c, err)
return len(fi), nil return len(fi), nil
@ -243,11 +243,11 @@ func (s *DockerSuite) TestExecStateCleanup(c *check.C) {
assert.Assert(c, os.IsNotExist(err)) assert.Assert(c, os.IsNotExist(err))
} }
func createExec(c *check.C, name string) string { func createExec(c *testing.T, name string) string {
return createExecCmd(c, name, "true") return createExecCmd(c, name, "true")
} }
func createExecCmd(c *check.C, name string, cmd string) string { func createExecCmd(c *testing.T, name string, cmd string) string {
_, reader, err := request.Post(fmt.Sprintf("/containers/%s/exec", name), request.JSONBody(map[string]interface{}{"Cmd": []string{cmd}})) _, reader, err := request.Post(fmt.Sprintf("/containers/%s/exec", name), request.JSONBody(map[string]interface{}{"Cmd": []string{cmd}}))
assert.NilError(c, err) assert.NilError(c, err)
b, err := ioutil.ReadAll(reader) b, err := ioutil.ReadAll(reader)
@ -260,7 +260,7 @@ func createExecCmd(c *check.C, name string, cmd string) string {
return createResp.ID return createResp.ID
} }
func startExec(c *check.C, id string, code int) { func startExec(c *testing.T, id string, code int) {
resp, body, err := request.Post(fmt.Sprintf("/exec/%s/start", id), request.RawString(`{"Detach": true}`), request.JSON) resp, body, err := request.Post(fmt.Sprintf("/exec/%s/start", id), request.RawString(`{"Detach": true}`), request.JSON)
assert.NilError(c, err) assert.NilError(c, err)
@ -269,7 +269,7 @@ func startExec(c *check.C, id string, code int) {
assert.Equal(c, resp.StatusCode, code, "response body: %s", b) assert.Equal(c, resp.StatusCode, code, "response body: %s", b)
} }
func inspectExec(c *check.C, id string, out interface{}) { func inspectExec(c *testing.T, id string, out interface{}) {
resp, body, err := request.Get(fmt.Sprintf("/exec/%s/json", id)) resp, body, err := request.Get(fmt.Sprintf("/exec/%s/json", id))
assert.NilError(c, err) assert.NilError(c, err)
defer body.Close() defer body.Close()
@ -278,7 +278,7 @@ func inspectExec(c *check.C, id string, out interface{}) {
assert.NilError(c, err) assert.NilError(c, err)
} }
func waitForExec(c *check.C, id string) { func waitForExec(c *testing.T, id string) {
timeout := time.After(60 * time.Second) timeout := time.After(60 * time.Second)
var execJSON struct{ Running bool } var execJSON struct{ Running bool }
for { for {
@ -295,7 +295,7 @@ func waitForExec(c *check.C, id string) {
} }
} }
func inspectContainer(c *check.C, id string, out interface{}) { func inspectContainer(c *testing.T, id string, out interface{}) {
resp, body, err := request.Get(fmt.Sprintf("/containers/%s/json", id)) resp, body, err := request.Get(fmt.Sprintf("/containers/%s/json", id))
assert.NilError(c, err) assert.NilError(c, err)
defer body.Close() defer body.Close()

View file

@ -19,7 +19,7 @@ import (
"gotest.tools/assert" "gotest.tools/assert"
) )
func (s *DockerSuite) TestAPIImagesFilter(c *check.C) { func (s *DockerSuite) TestAPIImagesFilter(c *testing.T) {
cli, err := client.NewClientWithOpts(client.FromEnv) cli, err := client.NewClientWithOpts(client.FromEnv)
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
@ -57,7 +57,7 @@ func (s *DockerSuite) TestAPIImagesFilter(c *check.C) {
assert.Equal(c, len(images[0].RepoTags), 1) assert.Equal(c, len(images[0].RepoTags), 1)
} }
func (s *DockerSuite) TestAPIImagesSaveAndLoad(c *check.C) { func (s *DockerSuite) TestAPIImagesSaveAndLoad(c *testing.T) {
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
v, err := kernel.GetKernelVersion() v, err := kernel.GetKernelVersion()
assert.NilError(c, err) assert.NilError(c, err)
@ -87,7 +87,7 @@ func (s *DockerSuite) TestAPIImagesSaveAndLoad(c *check.C) {
assert.Equal(c, strings.TrimSpace(string(inspectOut)), id, "load did not work properly") assert.Equal(c, strings.TrimSpace(string(inspectOut)), id, "load did not work properly")
} }
func (s *DockerSuite) TestAPIImagesDelete(c *check.C) { func (s *DockerSuite) TestAPIImagesDelete(c *testing.T) {
cli, err := client.NewClientWithOpts(client.FromEnv) cli, err := client.NewClientWithOpts(client.FromEnv)
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
@ -111,7 +111,7 @@ func (s *DockerSuite) TestAPIImagesDelete(c *check.C) {
assert.NilError(c, err) assert.NilError(c, err)
} }
func (s *DockerSuite) TestAPIImagesHistory(c *check.C) { func (s *DockerSuite) TestAPIImagesHistory(c *testing.T) {
cli, err := client.NewClientWithOpts(client.FromEnv) cli, err := client.NewClientWithOpts(client.FromEnv)
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
@ -137,7 +137,7 @@ func (s *DockerSuite) TestAPIImagesHistory(c *check.C) {
assert.Assert(c, found) assert.Assert(c, found)
} }
func (s *DockerSuite) TestAPIImagesImportBadSrc(c *check.C) { func (s *DockerSuite) TestAPIImagesImportBadSrc(c *testing.T) {
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
v, err := kernel.GetKernelVersion() v, err := kernel.GetKernelVersion()
assert.NilError(c, err) assert.NilError(c, err)
@ -172,7 +172,7 @@ func (s *DockerSuite) TestAPIImagesImportBadSrc(c *check.C) {
} }
// #14846 // #14846
func (s *DockerSuite) TestAPIImagesSearchJSONContentType(c *check.C) { func (s *DockerSuite) TestAPIImagesSearchJSONContentType(c *testing.T) {
testRequires(c, Network) testRequires(c, Network)
res, b, err := request.Get("/images/search?term=test", request.JSON) res, b, err := request.Get("/images/search?term=test", request.JSON)
@ -184,7 +184,7 @@ func (s *DockerSuite) TestAPIImagesSearchJSONContentType(c *check.C) {
// Test case for 30027: image size reported as -1 in v1.12 client against v1.13 daemon. // Test case for 30027: image size reported as -1 in v1.12 client against v1.13 daemon.
// This test checks to make sure both v1.12 and v1.13 client against v1.13 daemon get correct `Size` after the fix. // This test checks to make sure both v1.12 and v1.13 client against v1.13 daemon get correct `Size` after the fix.
func (s *DockerSuite) TestAPIImagesSizeCompatibility(c *check.C) { func (s *DockerSuite) TestAPIImagesSizeCompatibility(c *testing.T) {
apiclient := testEnv.APIClient() apiclient := testEnv.APIClient()
defer apiclient.Close() defer apiclient.Close()

View file

@ -13,7 +13,7 @@ import (
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
) )
func (s *DockerSuite) TestInspectAPIContainerResponse(c *check.C) { func (s *DockerSuite) TestInspectAPIContainerResponse(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "busybox", "true") out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
@ -57,7 +57,7 @@ func (s *DockerSuite) TestInspectAPIContainerResponse(c *check.C) {
} }
} }
func (s *DockerSuite) TestInspectAPIContainerVolumeDriverLegacy(c *check.C) { func (s *DockerSuite) TestInspectAPIContainerVolumeDriverLegacy(c *testing.T) {
// No legacy implications for Windows // No legacy implications for Windows
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "true") out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
@ -80,7 +80,7 @@ func (s *DockerSuite) TestInspectAPIContainerVolumeDriverLegacy(c *check.C) {
} }
} }
func (s *DockerSuite) TestInspectAPIContainerVolumeDriver(c *check.C) { func (s *DockerSuite) TestInspectAPIContainerVolumeDriver(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "--volume-driver", "local", "busybox", "true") out, _ := dockerCmd(c, "run", "-d", "--volume-driver", "local", "busybox", "true")
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
@ -104,7 +104,7 @@ func (s *DockerSuite) TestInspectAPIContainerVolumeDriver(c *check.C) {
assert.Assert(c, ok, "API version 1.25 expected to include VolumeDriver in 'HostConfig'") assert.Assert(c, ok, "API version 1.25 expected to include VolumeDriver in 'HostConfig'")
} }
func (s *DockerSuite) TestInspectAPIImageResponse(c *check.C) { func (s *DockerSuite) TestInspectAPIImageResponse(c *testing.T) {
dockerCmd(c, "tag", "busybox:latest", "busybox:mytag") dockerCmd(c, "tag", "busybox:latest", "busybox:mytag")
cli, err := client.NewClientWithOpts(client.FromEnv) cli, err := client.NewClientWithOpts(client.FromEnv)
assert.NilError(c, err) assert.NilError(c, err)
@ -119,7 +119,7 @@ func (s *DockerSuite) TestInspectAPIImageResponse(c *check.C) {
} }
// #17131, #17139, #17173 // #17131, #17139, #17173
func (s *DockerSuite) TestInspectAPIEmptyFieldsInConfigPre121(c *check.C) { func (s *DockerSuite) TestInspectAPIEmptyFieldsInConfigPre121(c *testing.T) {
// Not relevant on Windows // Not relevant on Windows
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "true") out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
@ -143,7 +143,7 @@ func (s *DockerSuite) TestInspectAPIEmptyFieldsInConfigPre121(c *check.C) {
} }
} }
func (s *DockerSuite) TestInspectAPIBridgeNetworkSettings120(c *check.C) { func (s *DockerSuite) TestInspectAPIBridgeNetworkSettings120(c *testing.T) {
// Not relevant on Windows, and besides it doesn't have any bridge network settings // Not relevant on Windows, and besides it doesn't have any bridge network settings
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "top") out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
@ -160,7 +160,7 @@ func (s *DockerSuite) TestInspectAPIBridgeNetworkSettings120(c *check.C) {
assert.Assert(c, len(settings.IPAddress) != 0) assert.Assert(c, len(settings.IPAddress) != 0)
} }
func (s *DockerSuite) TestInspectAPIBridgeNetworkSettings121(c *check.C) { func (s *DockerSuite) TestInspectAPIBridgeNetworkSettings121(c *testing.T) {
// Windows doesn't have any bridge network settings // Windows doesn't have any bridge network settings
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "top") out, _ := dockerCmd(c, "run", "-d", "busybox", "top")

View file

@ -20,7 +20,7 @@ import (
"gotest.tools/assert" "gotest.tools/assert"
) )
func (s *DockerSuite) TestLogsAPIWithStdout(c *check.C) { func (s *DockerSuite) TestLogsAPIWithStdout(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "-t", "busybox", "/bin/sh", "-c", "while true; do echo hello; sleep 1; done") out, _ := dockerCmd(c, "run", "-d", "-t", "busybox", "/bin/sh", "-c", "while true; do echo hello; sleep 1; done")
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
assert.NilError(c, waitRun(id)) assert.NilError(c, waitRun(id))
@ -56,7 +56,7 @@ func (s *DockerSuite) TestLogsAPIWithStdout(c *check.C) {
} }
} }
func (s *DockerSuite) TestLogsAPINoStdoutNorStderr(c *check.C) { func (s *DockerSuite) TestLogsAPINoStdoutNorStderr(c *testing.T) {
name := "logs_test" name := "logs_test"
dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh") dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
cli, err := client.NewClientWithOpts(client.FromEnv) cli, err := client.NewClientWithOpts(client.FromEnv)
@ -68,7 +68,7 @@ func (s *DockerSuite) TestLogsAPINoStdoutNorStderr(c *check.C) {
} }
// Regression test for #12704 // Regression test for #12704
func (s *DockerSuite) TestLogsAPIFollowEmptyOutput(c *check.C) { func (s *DockerSuite) TestLogsAPIFollowEmptyOutput(c *testing.T) {
name := "logs_test" name := "logs_test"
t0 := time.Now() t0 := time.Now()
dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "sleep", "10") dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "sleep", "10")
@ -83,14 +83,14 @@ func (s *DockerSuite) TestLogsAPIFollowEmptyOutput(c *check.C) {
} }
} }
func (s *DockerSuite) TestLogsAPIContainerNotFound(c *check.C) { func (s *DockerSuite) TestLogsAPIContainerNotFound(c *testing.T) {
name := "nonExistentContainer" name := "nonExistentContainer"
resp, _, err := request.Get(fmt.Sprintf("/containers/%s/logs?follow=1&stdout=1&stderr=1&tail=all", name)) resp, _, err := request.Get(fmt.Sprintf("/containers/%s/logs?follow=1&stdout=1&stderr=1&tail=all", name))
assert.NilError(c, err) assert.NilError(c, err)
assert.Equal(c, resp.StatusCode, http.StatusNotFound) assert.Equal(c, resp.StatusCode, http.StatusNotFound)
} }
func (s *DockerSuite) TestLogsAPIUntilFutureFollow(c *check.C) { func (s *DockerSuite) TestLogsAPIUntilFutureFollow(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "logsuntilfuturefollow" name := "logsuntilfuturefollow"
dockerCmd(c, "run", "-d", "--name", name, "busybox", "/bin/sh", "-c", "while true; do date +%s; sleep 1; done") dockerCmd(c, "run", "-d", "--name", name, "busybox", "/bin/sh", "-c", "while true; do date +%s; sleep 1; done")
@ -147,7 +147,7 @@ func (s *DockerSuite) TestLogsAPIUntilFutureFollow(c *check.C) {
} }
} }
func (s *DockerSuite) TestLogsAPIUntil(c *check.C) { func (s *DockerSuite) TestLogsAPIUntil(c *testing.T) {
testRequires(c, MinimumAPIVersion("1.34")) testRequires(c, MinimumAPIVersion("1.34"))
name := "logsuntil" name := "logsuntil"
dockerCmd(c, "run", "--name", name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do echo log$i; sleep 1; done") dockerCmd(c, "run", "--name", name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do echo log$i; sleep 1; done")
@ -157,7 +157,7 @@ func (s *DockerSuite) TestLogsAPIUntil(c *check.C) {
c.Fatal(err) c.Fatal(err)
} }
extractBody := func(c *check.C, cfg types.ContainerLogsOptions) []string { extractBody := func(c *testing.T, cfg types.ContainerLogsOptions) []string {
reader, err := client.ContainerLogs(context.Background(), name, cfg) reader, err := client.ContainerLogs(context.Background(), name, cfg)
assert.NilError(c, err) assert.NilError(c, err)
@ -185,7 +185,7 @@ func (s *DockerSuite) TestLogsAPIUntil(c *check.C) {
assert.Assert(c, !strings.Contains(logsString, "log3"), "unexpected log message returned, until=%v", until) assert.Assert(c, !strings.Contains(logsString, "log3"), "unexpected log message returned, until=%v", until)
} }
func (s *DockerSuite) TestLogsAPIUntilDefaultValue(c *check.C) { func (s *DockerSuite) TestLogsAPIUntilDefaultValue(c *testing.T) {
name := "logsuntildefaultval" name := "logsuntildefaultval"
dockerCmd(c, "run", "--name", name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do echo log$i; done") dockerCmd(c, "run", "--name", name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do echo log$i; done")
@ -194,7 +194,7 @@ func (s *DockerSuite) TestLogsAPIUntilDefaultValue(c *check.C) {
c.Fatal(err) c.Fatal(err)
} }
extractBody := func(c *check.C, cfg types.ContainerLogsOptions) []string { extractBody := func(c *testing.T, cfg types.ContainerLogsOptions) []string {
reader, err := client.ContainerLogs(context.Background(), name, cfg) reader, err := client.ContainerLogs(context.Background(), name, cfg)
assert.NilError(c, err) assert.NilError(c, err)

View file

@ -17,7 +17,7 @@ import (
"gotest.tools/assert" "gotest.tools/assert"
) )
func (s *DockerSuite) TestAPINetworkGetDefaults(c *check.C) { func (s *DockerSuite) TestAPINetworkGetDefaults(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
// By default docker daemon creates 3 networks. check if they are present // By default docker daemon creates 3 networks. check if they are present
defaults := []string{"bridge", "host", "none"} defaults := []string{"bridge", "host", "none"}
@ -26,7 +26,7 @@ func (s *DockerSuite) TestAPINetworkGetDefaults(c *check.C) {
} }
} }
func (s *DockerSuite) TestAPINetworkCreateCheckDuplicate(c *check.C) { func (s *DockerSuite) TestAPINetworkCreateCheckDuplicate(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "testcheckduplicate" name := "testcheckduplicate"
configOnCheck := types.NetworkCreateRequest{ configOnCheck := types.NetworkCreateRequest{
@ -64,13 +64,13 @@ func (s *DockerSuite) TestAPINetworkCreateCheckDuplicate(c *check.C) {
createNetwork(c, configNotCheck, http.StatusCreated) createNetwork(c, configNotCheck, http.StatusCreated)
} }
func (s *DockerSuite) TestAPINetworkFilter(c *check.C) { func (s *DockerSuite) TestAPINetworkFilter(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
nr := getNetworkResource(c, getNetworkIDByName(c, "bridge")) nr := getNetworkResource(c, getNetworkIDByName(c, "bridge"))
assert.Equal(c, nr.Name, "bridge") assert.Equal(c, nr.Name, "bridge")
} }
func (s *DockerSuite) TestAPINetworkInspectBridge(c *check.C) { func (s *DockerSuite) TestAPINetworkInspectBridge(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
// Inspect default bridge network // Inspect default bridge network
nr := getNetworkResource(c, "bridge") nr := getNetworkResource(c, "bridge")
@ -96,7 +96,7 @@ func (s *DockerSuite) TestAPINetworkInspectBridge(c *check.C) {
assert.Equal(c, ip.String(), containerIP) assert.Equal(c, ip.String(), containerIP)
} }
func (s *DockerSuite) TestAPINetworkInspectUserDefinedNetwork(c *check.C) { func (s *DockerSuite) TestAPINetworkInspectUserDefinedNetwork(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
// IPAM configuration inspect // IPAM configuration inspect
ipam := &network.IPAM{ ipam := &network.IPAM{
@ -127,7 +127,7 @@ func (s *DockerSuite) TestAPINetworkInspectUserDefinedNetwork(c *check.C) {
assert.Assert(c, !isNetworkAvailable(c, "br0")) assert.Assert(c, !isNetworkAvailable(c, "br0"))
} }
func (s *DockerSuite) TestAPINetworkConnectDisconnect(c *check.C) { func (s *DockerSuite) TestAPINetworkConnectDisconnect(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
// Create test network // Create test network
name := "testnetwork" name := "testnetwork"
@ -169,7 +169,7 @@ func (s *DockerSuite) TestAPINetworkConnectDisconnect(c *check.C) {
deleteNetwork(c, nr.ID, true) deleteNetwork(c, nr.ID, true)
} }
func (s *DockerSuite) TestAPINetworkIPAMMultipleBridgeNetworks(c *check.C) { func (s *DockerSuite) TestAPINetworkIPAMMultipleBridgeNetworks(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
// test0 bridge network // test0 bridge network
ipam0 := &network.IPAM{ ipam0 := &network.IPAM{
@ -238,14 +238,14 @@ func (s *DockerSuite) TestAPINetworkIPAMMultipleBridgeNetworks(c *check.C) {
} }
} }
func (s *DockerSuite) TestAPICreateDeletePredefinedNetworks(c *check.C) { func (s *DockerSuite) TestAPICreateDeletePredefinedNetworks(c *testing.T) {
testRequires(c, DaemonIsLinux, SwarmInactive) testRequires(c, DaemonIsLinux, SwarmInactive)
createDeletePredefinedNetwork(c, "bridge") createDeletePredefinedNetwork(c, "bridge")
createDeletePredefinedNetwork(c, "none") createDeletePredefinedNetwork(c, "none")
createDeletePredefinedNetwork(c, "host") createDeletePredefinedNetwork(c, "host")
} }
func createDeletePredefinedNetwork(c *check.C, name string) { func createDeletePredefinedNetwork(c *testing.T, name string) {
// Create pre-defined network // Create pre-defined network
config := types.NetworkCreateRequest{ config := types.NetworkCreateRequest{
Name: name, Name: name,
@ -267,7 +267,7 @@ func createDeletePredefinedNetwork(c *check.C, name string) {
deleteNetwork(c, name, false) deleteNetwork(c, name, false)
} }
func isNetworkAvailable(c *check.C, name string) bool { func isNetworkAvailable(c *testing.T, name string) bool {
resp, body, err := request.Get("/networks") resp, body, err := request.Get("/networks")
assert.NilError(c, err) assert.NilError(c, err)
defer resp.Body.Close() defer resp.Body.Close()
@ -285,7 +285,7 @@ func isNetworkAvailable(c *check.C, name string) bool {
return false return false
} }
func getNetworkIDByName(c *check.C, name string) string { func getNetworkIDByName(c *testing.T, name string) string {
var ( var (
v = url.Values{} v = url.Values{}
filterArgs = filters.NewArgs() filterArgs = filters.NewArgs()
@ -314,7 +314,7 @@ func getNetworkIDByName(c *check.C, name string) string {
return res return res
} }
func getNetworkResource(c *check.C, id string) *types.NetworkResource { func getNetworkResource(c *testing.T, id string) *types.NetworkResource {
_, obj, err := request.Get("/networks/" + id) _, obj, err := request.Get("/networks/" + id)
assert.NilError(c, err) assert.NilError(c, err)
@ -325,7 +325,7 @@ func getNetworkResource(c *check.C, id string) *types.NetworkResource {
return &nr return &nr
} }
func createNetwork(c *check.C, config types.NetworkCreateRequest, expectedStatusCode int) string { func createNetwork(c *testing.T, config types.NetworkCreateRequest, expectedStatusCode int) string {
resp, body, err := request.Post("/networks/create", request.JSONBody(config)) resp, body, err := request.Post("/networks/create", request.JSONBody(config))
assert.NilError(c, err) assert.NilError(c, err)
defer resp.Body.Close() defer resp.Body.Close()
@ -346,7 +346,7 @@ func createNetwork(c *check.C, config types.NetworkCreateRequest, expectedStatus
return "" return ""
} }
func connectNetwork(c *check.C, nid, cid string) { func connectNetwork(c *testing.T, nid, cid string) {
config := types.NetworkConnect{ config := types.NetworkConnect{
Container: cid, Container: cid,
} }
@ -356,7 +356,7 @@ func connectNetwork(c *check.C, nid, cid string) {
assert.NilError(c, err) assert.NilError(c, err)
} }
func disconnectNetwork(c *check.C, nid, cid string) { func disconnectNetwork(c *testing.T, nid, cid string) {
config := types.NetworkConnect{ config := types.NetworkConnect{
Container: cid, Container: cid,
} }
@ -366,7 +366,7 @@ func disconnectNetwork(c *check.C, nid, cid string) {
assert.NilError(c, err) assert.NilError(c, err)
} }
func deleteNetwork(c *check.C, id string, shouldSucceed bool) { func deleteNetwork(c *testing.T, id string, shouldSucceed bool) {
resp, _, err := request.Delete("/networks/" + id) resp, _, err := request.Delete("/networks/" + id)
assert.NilError(c, err) assert.NilError(c, err)
defer resp.Body.Close() defer resp.Body.Close()

View file

@ -22,7 +22,7 @@ import (
var expectedNetworkInterfaceStats = strings.Split("rx_bytes rx_dropped rx_errors rx_packets tx_bytes tx_dropped tx_errors tx_packets", " ") var expectedNetworkInterfaceStats = strings.Split("rx_bytes rx_dropped rx_errors rx_packets tx_bytes tx_dropped tx_errors tx_packets", " ")
func (s *DockerSuite) TestAPIStatsNoStreamGetCpu(c *check.C) { func (s *DockerSuite) TestAPIStatsNoStreamGetCpu(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "while true;usleep 100; do echo 'Hello'; done") out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "while true;usleep 100; do echo 'Hello'; done")
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
@ -62,7 +62,7 @@ func (s *DockerSuite) TestAPIStatsNoStreamGetCpu(c *check.C) {
assert.Assert(c, cpuPercent != 0.0, "docker stats with no-stream get cpu usage failed: was %v", cpuPercent) assert.Assert(c, cpuPercent != 0.0, "docker stats with no-stream get cpu usage failed: was %v", cpuPercent)
} }
func (s *DockerSuite) TestAPIStatsStoppedContainerInGoroutines(c *check.C) { func (s *DockerSuite) TestAPIStatsStoppedContainerInGoroutines(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "echo 1") out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "echo 1")
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
@ -97,7 +97,7 @@ func (s *DockerSuite) TestAPIStatsStoppedContainerInGoroutines(c *check.C) {
} }
} }
func (s *DockerSuite) TestAPIStatsNetworkStats(c *check.C) { func (s *DockerSuite) TestAPIStatsNetworkStats(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
out := runSleepingContainer(c) out := runSleepingContainer(c)
@ -162,7 +162,7 @@ func (s *DockerSuite) TestAPIStatsNetworkStats(c *check.C) {
assert.Assert(c, postRxPackets >= expRxPkts, "Reported less RxPackets than expected. Expected >= %d. Found %d. %s", expRxPkts, postRxPackets, pingouts) assert.Assert(c, postRxPackets >= expRxPkts, "Reported less RxPackets than expected. Expected >= %d. Found %d. %s", expRxPkts, postRxPackets, pingouts)
} }
func (s *DockerSuite) TestAPIStatsNetworkStatsVersioning(c *check.C) { func (s *DockerSuite) TestAPIStatsNetworkStatsVersioning(c *testing.T) {
// Windows doesn't support API versions less than 1.25, so no point testing 1.17 .. 1.21 // Windows doesn't support API versions less than 1.25, so no point testing 1.17 .. 1.21
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
@ -187,7 +187,7 @@ func (s *DockerSuite) TestAPIStatsNetworkStatsVersioning(c *check.C) {
wg.Wait() wg.Wait()
} }
func getNetworkStats(c *check.C, id string) map[string]types.NetworkStats { func getNetworkStats(c *testing.T, id string) map[string]types.NetworkStats {
var st *types.StatsJSON var st *types.StatsJSON
_, body, err := request.Get(fmt.Sprintf("/containers/%s/stats?stream=false", id)) _, body, err := request.Get(fmt.Sprintf("/containers/%s/stats?stream=false", id))
@ -204,7 +204,7 @@ func getNetworkStats(c *check.C, id string) map[string]types.NetworkStats {
// container with id using an API call with version apiVersion. Since the // container with id using an API call with version apiVersion. Since the
// stats result type differs between API versions, we simply return // stats result type differs between API versions, we simply return
// map[string]interface{}. // map[string]interface{}.
func getVersionedStats(c *check.C, id string, apiVersion string) map[string]interface{} { func getVersionedStats(c *testing.T, id string, apiVersion string) map[string]interface{} {
stats := make(map[string]interface{}) stats := make(map[string]interface{})
_, body, err := request.Get(fmt.Sprintf("/%s/containers/%s/stats?stream=false", apiVersion, id)) _, body, err := request.Get(fmt.Sprintf("/%s/containers/%s/stats?stream=false", apiVersion, id))
@ -257,7 +257,7 @@ func jsonBlobHasGTE121NetworkStats(blob map[string]interface{}) bool {
return true return true
} }
func (s *DockerSuite) TestAPIStatsContainerNotFound(c *check.C) { func (s *DockerSuite) TestAPIStatsContainerNotFound(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
cli, err := client.NewClientWithOpts(client.FromEnv) cli, err := client.NewClientWithOpts(client.FromEnv)
assert.NilError(c, err) assert.NilError(c, err)
@ -271,7 +271,7 @@ func (s *DockerSuite) TestAPIStatsContainerNotFound(c *check.C) {
assert.ErrorContains(c, err, expected) assert.ErrorContains(c, err, expected)
} }
func (s *DockerSuite) TestAPIStatsNoStreamConnectedContainers(c *check.C) { func (s *DockerSuite) TestAPIStatsNoStreamConnectedContainers(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out1 := runSleepingContainer(c) out1 := runSleepingContainer(c)

View file

@ -11,7 +11,7 @@ import (
"github.com/go-check/check" "github.com/go-check/check"
) )
func (s *DockerSwarmSuite) TestAPISwarmListNodes(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmListNodes(c *testing.T) {
d1 := s.AddDaemon(c, true, true) d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, false) d2 := s.AddDaemon(c, true, false)
d3 := s.AddDaemon(c, true, false) d3 := s.AddDaemon(c, true, false)
@ -30,7 +30,7 @@ loop0:
} }
} }
func (s *DockerSwarmSuite) TestAPISwarmNodeUpdate(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmNodeUpdate(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
nodes := d.ListNodes(c) nodes := d.ListNodes(c)
@ -43,7 +43,7 @@ func (s *DockerSwarmSuite) TestAPISwarmNodeUpdate(c *check.C) {
assert.Assert(c, n.Spec.Availability, checker.Equals, swarm.NodeAvailabilityPause) assert.Assert(c, n.Spec.Availability, checker.Equals, swarm.NodeAvailabilityPause)
} }
func (s *DockerSwarmSuite) TestAPISwarmNodeRemove(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmNodeRemove(c *testing.T) {
testRequires(c, Network) testRequires(c, Network)
d1 := s.AddDaemon(c, true, true) d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, false) d2 := s.AddDaemon(c, true, false)
@ -72,7 +72,7 @@ func (s *DockerSwarmSuite) TestAPISwarmNodeRemove(c *check.C) {
assert.Assert(c, len(nodes), checker.Equals, 2, check.Commentf("nodes: %#v", nodes)) assert.Assert(c, len(nodes), checker.Equals, 2, check.Commentf("nodes: %#v", nodes))
} }
func (s *DockerSwarmSuite) TestAPISwarmNodeDrainPause(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmNodeDrainPause(c *testing.T) {
d1 := s.AddDaemon(c, true, true) d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, false) d2 := s.AddDaemon(c, true, false)

View file

@ -31,7 +31,7 @@ func setPortConfig(portConfig []swarm.PortConfig) testdaemon.ServiceConstructor
} }
} }
func (s *DockerSwarmSuite) TestAPIServiceUpdatePort(c *check.C) { func (s *DockerSwarmSuite) TestAPIServiceUpdatePort(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
// Create a service with a port mapping of 8080:8081. // Create a service with a port mapping of 8080:8081.
@ -52,7 +52,7 @@ func (s *DockerSwarmSuite) TestAPIServiceUpdatePort(c *check.C) {
assert.Equal(c, updatedService.Spec.EndpointSpec.Ports[0].PublishedPort, uint32(8082)) assert.Equal(c, updatedService.Spec.EndpointSpec.Ports[0].PublishedPort, uint32(8082))
} }
func (s *DockerSwarmSuite) TestAPISwarmServicesEmptyList(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmServicesEmptyList(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
services := d.ListServices(c) services := d.ListServices(c)
@ -60,7 +60,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesEmptyList(c *check.C) {
assert.Assert(c, len(services) == 0, "services: %#v", services) assert.Assert(c, len(services) == 0, "services: %#v", services)
} }
func (s *DockerSwarmSuite) TestAPISwarmServicesCreate(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmServicesCreate(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
instances := 2 instances := 2
@ -93,7 +93,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesCreate(c *check.C) {
waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 0) waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 0)
} }
func (s *DockerSwarmSuite) TestAPISwarmServicesMultipleAgents(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmServicesMultipleAgents(c *testing.T) {
d1 := s.AddDaemon(c, true, true) d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, false) d2 := s.AddDaemon(c, true, false)
d3 := s.AddDaemon(c, true, false) d3 := s.AddDaemon(c, true, false)
@ -121,7 +121,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesMultipleAgents(c *check.C) {
} }
func (s *DockerSwarmSuite) TestAPISwarmServicesCreateGlobal(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmServicesCreateGlobal(c *testing.T) {
d1 := s.AddDaemon(c, true, true) d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, false) d2 := s.AddDaemon(c, true, false)
d3 := s.AddDaemon(c, true, false) d3 := s.AddDaemon(c, true, false)
@ -139,7 +139,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesCreateGlobal(c *check.C) {
waitAndAssert(c, defaultReconciliationTimeout, d5.CheckActiveContainerCount, checker.Equals, 1) waitAndAssert(c, defaultReconciliationTimeout, d5.CheckActiveContainerCount, checker.Equals, 1)
} }
func (s *DockerSwarmSuite) TestAPISwarmServicesUpdate(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmServicesUpdate(c *testing.T) {
const nodeCount = 3 const nodeCount = 3
var daemons [nodeCount]*daemon.Daemon var daemons [nodeCount]*daemon.Daemon
for i := 0; i < nodeCount; i++ { for i := 0; i < nodeCount; i++ {
@ -199,7 +199,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesUpdate(c *check.C) {
map[string]int{image1: instances}) map[string]int{image1: instances})
} }
func (s *DockerSwarmSuite) TestAPISwarmServicesUpdateStartFirst(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmServicesUpdateStartFirst(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
// service image at start // service image at start
@ -223,7 +223,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesUpdateStartFirst(c *check.C) {
checkStartingTasks := func(expected int) []swarm.Task { checkStartingTasks := func(expected int) []swarm.Task {
var startingTasks []swarm.Task var startingTasks []swarm.Task
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
tasks := d.GetServiceTasks(c, id) tasks := d.GetServiceTasks(c, id)
startingTasks = nil startingTasks = nil
for _, t := range tasks { for _, t := range tasks {
@ -308,7 +308,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesUpdateStartFirst(c *check.C) {
map[string]int{image1: instances}) map[string]int{image1: instances})
} }
func (s *DockerSwarmSuite) TestAPISwarmServicesFailedUpdate(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmServicesFailedUpdate(c *testing.T) {
const nodeCount = 3 const nodeCount = 3
var daemons [nodeCount]*daemon.Daemon var daemons [nodeCount]*daemon.Daemon
for i := 0; i < nodeCount; i++ { for i := 0; i < nodeCount; i++ {
@ -348,7 +348,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesFailedUpdate(c *check.C) {
map[string]int{image1: instances}) map[string]int{image1: instances})
} }
func (s *DockerSwarmSuite) TestAPISwarmServiceConstraintRole(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmServiceConstraintRole(c *testing.T) {
const nodeCount = 3 const nodeCount = 3
var daemons [nodeCount]*daemon.Daemon var daemons [nodeCount]*daemon.Daemon
for i := 0; i < nodeCount; i++ { for i := 0; i < nodeCount; i++ {
@ -400,7 +400,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServiceConstraintRole(c *check.C) {
} }
} }
func (s *DockerSwarmSuite) TestAPISwarmServiceConstraintLabel(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmServiceConstraintLabel(c *testing.T) {
const nodeCount = 3 const nodeCount = 3
var daemons [nodeCount]*daemon.Daemon var daemons [nodeCount]*daemon.Daemon
for i := 0; i < nodeCount; i++ { for i := 0; i < nodeCount; i++ {
@ -495,7 +495,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServiceConstraintLabel(c *check.C) {
} }
} }
func (s *DockerSwarmSuite) TestAPISwarmServicePlacementPrefs(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmServicePlacementPrefs(c *testing.T) {
const nodeCount = 3 const nodeCount = 3
var daemons [nodeCount]*daemon.Daemon var daemons [nodeCount]*daemon.Daemon
for i := 0; i < nodeCount; i++ { for i := 0; i < nodeCount; i++ {
@ -537,7 +537,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServicePlacementPrefs(c *check.C) {
assert.Assert(c, tasksOnNode[nodes[2].ID] == 1) assert.Assert(c, tasksOnNode[nodes[2].ID] == 1)
} }
func (s *DockerSwarmSuite) TestAPISwarmServicesStateReporting(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmServicesStateReporting(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)

View file

@ -34,7 +34,7 @@ import (
var defaultReconciliationTimeout = 30 * time.Second var defaultReconciliationTimeout = 30 * time.Second
func (s *DockerSwarmSuite) TestAPISwarmInit(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmInit(c *testing.T) {
// todo: should find a better way to verify that components are running than /info // todo: should find a better way to verify that components are running than /info
d1 := s.AddDaemon(c, true, true) d1 := s.AddDaemon(c, true, true)
info := d1.SwarmInfo(c) info := d1.SwarmInfo(c)
@ -80,7 +80,7 @@ func (s *DockerSwarmSuite) TestAPISwarmInit(c *check.C) {
assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateActive) assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateActive)
} }
func (s *DockerSwarmSuite) TestAPISwarmJoinToken(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmJoinToken(c *testing.T) {
d1 := s.AddDaemon(c, false, false) d1 := s.AddDaemon(c, false, false)
d1.SwarmInit(c, swarm.InitRequest{}) d1.SwarmInit(c, swarm.InitRequest{})
@ -158,7 +158,7 @@ func (s *DockerSwarmSuite) TestAPISwarmJoinToken(c *check.C) {
assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateInactive) assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateInactive)
} }
func (s *DockerSwarmSuite) TestUpdateSwarmAddExternalCA(c *check.C) { func (s *DockerSwarmSuite) TestUpdateSwarmAddExternalCA(c *testing.T) {
d1 := s.AddDaemon(c, false, false) d1 := s.AddDaemon(c, false, false)
d1.SwarmInit(c, swarm.InitRequest{}) d1.SwarmInit(c, swarm.InitRequest{})
d1.UpdateSwarm(c, func(s *swarm.Spec) { d1.UpdateSwarm(c, func(s *swarm.Spec) {
@ -180,7 +180,7 @@ func (s *DockerSwarmSuite) TestUpdateSwarmAddExternalCA(c *check.C) {
assert.Equal(c, info.Cluster.Spec.CAConfig.ExternalCAs[1].CACert, "cacert") assert.Equal(c, info.Cluster.Spec.CAConfig.ExternalCAs[1].CACert, "cacert")
} }
func (s *DockerSwarmSuite) TestAPISwarmCAHash(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmCAHash(c *testing.T) {
d1 := s.AddDaemon(c, true, true) d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, false, false) d2 := s.AddDaemon(c, false, false)
splitToken := strings.Split(d1.JoinTokens(c).Worker, "-") splitToken := strings.Split(d1.JoinTokens(c).Worker, "-")
@ -195,7 +195,7 @@ func (s *DockerSwarmSuite) TestAPISwarmCAHash(c *check.C) {
assert.ErrorContains(c, err, "remote CA does not match fingerprint") assert.ErrorContains(c, err, "remote CA does not match fingerprint")
} }
func (s *DockerSwarmSuite) TestAPISwarmPromoteDemote(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmPromoteDemote(c *testing.T) {
d1 := s.AddDaemon(c, false, false) d1 := s.AddDaemon(c, false, false)
d1.SwarmInit(c, swarm.InitRequest{}) d1.SwarmInit(c, swarm.InitRequest{})
d2 := s.AddDaemon(c, true, false) d2 := s.AddDaemon(c, true, false)
@ -222,7 +222,7 @@ func (s *DockerSwarmSuite) TestAPISwarmPromoteDemote(c *check.C) {
// back to manager quickly might cause the node to pause for awhile // back to manager quickly might cause the node to pause for awhile
// while waiting for the role to change to worker, and the test can // while waiting for the role to change to worker, and the test can
// time out during this interval. // time out during this interval.
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
certBytes, err := ioutil.ReadFile(filepath.Join(d2.Folder, "root", "swarm", "certificates", "swarm-node.crt")) certBytes, err := ioutil.ReadFile(filepath.Join(d2.Folder, "root", "swarm", "certificates", "swarm-node.crt"))
if err != nil { if err != nil {
return "", check.Commentf("error: %v", err) return "", check.Commentf("error: %v", err)
@ -265,7 +265,7 @@ func (s *DockerSwarmSuite) TestAPISwarmPromoteDemote(c *check.C) {
waitAndAssert(c, defaultReconciliationTimeout, d2.CheckControlAvailable, checker.True) waitAndAssert(c, defaultReconciliationTimeout, d2.CheckControlAvailable, checker.True)
} }
func (s *DockerSwarmSuite) TestAPISwarmLeaderProxy(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmLeaderProxy(c *testing.T) {
// add three managers, one of these is leader // add three managers, one of these is leader
d1 := s.AddDaemon(c, true, true) d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, true) d2 := s.AddDaemon(c, true, true)
@ -290,7 +290,7 @@ func (s *DockerSwarmSuite) TestAPISwarmLeaderProxy(c *check.C) {
} }
} }
func (s *DockerSwarmSuite) TestAPISwarmLeaderElection(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmLeaderElection(c *testing.T) {
if runtime.GOARCH == "s390x" { if runtime.GOARCH == "s390x" {
c.Skip("Disabled on s390x") c.Skip("Disabled on s390x")
} }
@ -316,7 +316,7 @@ func (s *DockerSwarmSuite) TestAPISwarmLeaderElection(c *check.C) {
) )
var lastErr error var lastErr error
checkLeader := func(nodes ...*daemon.Daemon) checkF { checkLeader := func(nodes ...*daemon.Daemon) checkF {
return func(c *check.C) (interface{}, check.CommentInterface) { return func(c *testing.T) (interface{}, check.CommentInterface) {
// clear these out before each run // clear these out before each run
leader = nil leader = nil
followers = nil followers = nil
@ -371,7 +371,7 @@ func (s *DockerSwarmSuite) TestAPISwarmLeaderElection(c *check.C) {
assert.Equal(c, leader.NodeID(), stableleader.NodeID()) assert.Equal(c, leader.NodeID(), stableleader.NodeID())
} }
func (s *DockerSwarmSuite) TestAPISwarmRaftQuorum(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmRaftQuorum(c *testing.T) {
if runtime.GOARCH == "s390x" { if runtime.GOARCH == "s390x" {
c.Skip("Disabled on s390x") c.Skip("Disabled on s390x")
} }
@ -403,7 +403,7 @@ func (s *DockerSwarmSuite) TestAPISwarmRaftQuorum(c *check.C) {
defer cli.Close() defer cli.Close()
// d1 will eventually step down from leader because there is no longer an active quorum, wait for that to happen // d1 will eventually step down from leader because there is no longer an active quorum, wait for that to happen
waitAndAssert(c, defaultReconciliationTimeout*2, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout*2, func(c *testing.T) (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 return err.Error(), nil
}, checker.Contains, "Make sure more than half of the managers are online.") }, checker.Contains, "Make sure more than half of the managers are online.")
@ -418,7 +418,7 @@ func (s *DockerSwarmSuite) TestAPISwarmRaftQuorum(c *check.C) {
}) })
} }
func (s *DockerSwarmSuite) TestAPISwarmLeaveRemovesContainer(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmLeaveRemovesContainer(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
instances := 2 instances := 2
@ -441,7 +441,7 @@ func (s *DockerSwarmSuite) TestAPISwarmLeaveRemovesContainer(c *check.C) {
} }
// #23629 // #23629
func (s *DockerSwarmSuite) TestAPISwarmLeaveOnPendingJoin(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmLeaveOnPendingJoin(c *testing.T) {
testRequires(c, Network) testRequires(c, Network)
s.AddDaemon(c, true, true) s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, false, false) d2 := s.AddDaemon(c, false, false)
@ -470,7 +470,7 @@ func (s *DockerSwarmSuite) TestAPISwarmLeaveOnPendingJoin(c *check.C) {
} }
// #23705 // #23705
func (s *DockerSwarmSuite) TestAPISwarmRestoreOnPendingJoin(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmRestoreOnPendingJoin(c *testing.T) {
testRequires(c, Network) testRequires(c, Network)
d := s.AddDaemon(c, false, false) d := s.AddDaemon(c, false, false)
client := d.NewClientT(c) client := d.NewClientT(c)
@ -488,7 +488,7 @@ func (s *DockerSwarmSuite) TestAPISwarmRestoreOnPendingJoin(c *check.C) {
assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateInactive) assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateInactive)
} }
func (s *DockerSwarmSuite) TestAPISwarmManagerRestore(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmManagerRestore(c *testing.T) {
d1 := s.AddDaemon(c, true, true) d1 := s.AddDaemon(c, true, true)
instances := 2 instances := 2
@ -515,7 +515,7 @@ func (s *DockerSwarmSuite) TestAPISwarmManagerRestore(c *check.C) {
d3.GetService(c, id) d3.GetService(c, id)
} }
func (s *DockerSwarmSuite) TestAPISwarmScaleNoRollingUpdate(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmScaleNoRollingUpdate(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
instances := 2 instances := 2
@ -539,7 +539,7 @@ loop0:
} }
} }
func (s *DockerSwarmSuite) TestAPISwarmInvalidAddress(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmInvalidAddress(c *testing.T) {
d := s.AddDaemon(c, false, false) d := s.AddDaemon(c, false, false)
req := swarm.InitRequest{ req := swarm.InitRequest{
ListenAddr: "", ListenAddr: "",
@ -557,7 +557,7 @@ func (s *DockerSwarmSuite) TestAPISwarmInvalidAddress(c *check.C) {
assert.Equal(c, res.StatusCode, http.StatusBadRequest) assert.Equal(c, res.StatusCode, http.StatusBadRequest)
} }
func (s *DockerSwarmSuite) TestAPISwarmForceNewCluster(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmForceNewCluster(c *testing.T) {
d1 := s.AddDaemon(c, true, true) d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, true) d2 := s.AddDaemon(c, true, true)
@ -728,7 +728,7 @@ func setGlobalMode(s *swarm.Service) {
} }
} }
func checkClusterHealth(c *check.C, cl []*daemon.Daemon, managerCount, workerCount int) { func checkClusterHealth(c *testing.T, cl []*daemon.Daemon, managerCount, workerCount int) {
var totalMCount, totalWCount int var totalMCount, totalWCount int
for _, d := range cl { for _, d := range cl {
@ -737,7 +737,7 @@ func checkClusterHealth(c *check.C, cl []*daemon.Daemon, managerCount, workerCou
) )
// check info in a waitAndAssert, because if the cluster doesn't have a leader, `info` will return an error // check info in a waitAndAssert, because if the cluster doesn't have a leader, `info` will return an error
checkInfo := func(c *check.C) (interface{}, check.CommentInterface) { checkInfo := func(c *testing.T) (interface{}, check.CommentInterface) {
client := d.NewClientT(c) client := d.NewClientT(c)
daemonInfo, err := client.Info(context.Background()) daemonInfo, err := client.Info(context.Background())
info = daemonInfo.Swarm info = daemonInfo.Swarm
@ -754,7 +754,7 @@ func checkClusterHealth(c *check.C, cl []*daemon.Daemon, managerCount, workerCou
var mCount, wCount int var mCount, wCount int
for _, n := range d.ListNodes(c) { for _, n := range d.ListNodes(c) {
waitReady := func(c *check.C) (interface{}, check.CommentInterface) { waitReady := func(c *testing.T) (interface{}, check.CommentInterface) {
if n.Status.State == swarm.NodeStateReady { if n.Status.State == swarm.NodeStateReady {
return true, nil return true, nil
} }
@ -764,7 +764,7 @@ func checkClusterHealth(c *check.C, cl []*daemon.Daemon, managerCount, workerCou
} }
waitAndAssert(c, defaultReconciliationTimeout, waitReady, checker.True) waitAndAssert(c, defaultReconciliationTimeout, waitReady, checker.True)
waitActive := func(c *check.C) (interface{}, check.CommentInterface) { waitActive := func(c *testing.T) (interface{}, check.CommentInterface) {
if n.Spec.Availability == swarm.NodeAvailabilityActive { if n.Spec.Availability == swarm.NodeAvailabilityActive {
return true, nil return true, nil
} }
@ -793,7 +793,7 @@ func checkClusterHealth(c *check.C, cl []*daemon.Daemon, managerCount, workerCou
assert.Equal(c, totalWCount, workerCount) assert.Equal(c, totalWCount, workerCount)
} }
func (s *DockerSwarmSuite) TestAPISwarmRestartCluster(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmRestartCluster(c *testing.T) {
mCount, wCount := 5, 1 mCount, wCount := 5, 1
var nodes []*daemon.Daemon var nodes []*daemon.Daemon
@ -858,7 +858,7 @@ func (s *DockerSwarmSuite) TestAPISwarmRestartCluster(c *check.C) {
checkClusterHealth(c, nodes, mCount, wCount) checkClusterHealth(c, nodes, mCount, wCount)
} }
func (s *DockerSwarmSuite) TestAPISwarmServicesUpdateWithName(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmServicesUpdateWithName(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
instances := 2 instances := 2
@ -877,14 +877,14 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesUpdateWithName(c *check.C) {
} }
// Unlocking an unlocked swarm results in an error // Unlocking an unlocked swarm results in an error
func (s *DockerSwarmSuite) TestAPISwarmUnlockNotLocked(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmUnlockNotLocked(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
err := d.SwarmUnlock(c, swarm.UnlockRequest{UnlockKey: "wrong-key"}) err := d.SwarmUnlock(c, swarm.UnlockRequest{UnlockKey: "wrong-key"})
assert.ErrorContains(c, err, "swarm is not locked") assert.ErrorContains(c, err, "swarm is not locked")
} }
// #29885 // #29885
func (s *DockerSwarmSuite) TestAPISwarmErrorHandling(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmErrorHandling(c *testing.T) {
ln, err := net.Listen("tcp", fmt.Sprintf(":%d", defaultSwarmPort)) ln, err := net.Listen("tcp", fmt.Sprintf(":%d", defaultSwarmPort))
assert.NilError(c, err) assert.NilError(c, err)
defer ln.Close() defer ln.Close()
@ -899,7 +899,7 @@ func (s *DockerSwarmSuite) TestAPISwarmErrorHandling(c *check.C) {
// Test case for 30242, where duplicate networks, with different drivers `bridge` and `overlay`, // Test case for 30242, where duplicate networks, with different drivers `bridge` and `overlay`,
// caused both scopes to be `swarm` for `docker network inspect` and `docker network ls`. // caused both scopes to be `swarm` for `docker network inspect` and `docker network ls`.
// This test makes sure the fixes correctly output scopes instead. // This test makes sure the fixes correctly output scopes instead.
func (s *DockerSwarmSuite) TestAPIDuplicateNetworks(c *check.C) { func (s *DockerSwarmSuite) TestAPIDuplicateNetworks(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
cli := d.NewClientT(c) cli := d.NewClientT(c)
defer cli.Close() defer cli.Close()
@ -929,7 +929,7 @@ func (s *DockerSwarmSuite) TestAPIDuplicateNetworks(c *check.C) {
} }
// Test case for 30178 // Test case for 30178
func (s *DockerSwarmSuite) TestAPISwarmHealthcheckNone(c *check.C) { func (s *DockerSwarmSuite) TestAPISwarmHealthcheckNone(c *testing.T) {
// Issue #36386 can be a independent one, which is worth further investigation. // Issue #36386 can be a independent one, which is worth further investigation.
c.Skip("Root cause of Issue #36386 is needed") c.Skip("Root cause of Issue #36386 is needed")
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
@ -956,7 +956,7 @@ func (s *DockerSwarmSuite) TestAPISwarmHealthcheckNone(c *check.C) {
assert.NilError(c, err, out) assert.NilError(c, err, out)
} }
func (s *DockerSwarmSuite) TestSwarmRepeatedRootRotation(c *check.C) { func (s *DockerSwarmSuite) TestSwarmRepeatedRootRotation(c *testing.T) {
m := s.AddDaemon(c, true, true) m := s.AddDaemon(c, true, true)
w := s.AddDaemon(c, true, false) w := s.AddDaemon(c, true, false)
@ -1025,7 +1025,7 @@ func (s *DockerSwarmSuite) TestSwarmRepeatedRootRotation(c *check.C) {
} }
} }
func (s *DockerSwarmSuite) TestAPINetworkInspectWithScope(c *check.C) { func (s *DockerSwarmSuite) TestAPINetworkInspectWithScope(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
name := "test-scoped-network" name := "test-scoped-network"

View file

@ -15,13 +15,13 @@ import (
"gotest.tools/assert" "gotest.tools/assert"
) )
func (s *DockerSuite) TestAPIOptionsRoute(c *check.C) { func (s *DockerSuite) TestAPIOptionsRoute(c *testing.T) {
resp, _, err := request.Do("/", request.Method(http.MethodOptions)) resp, _, err := request.Do("/", request.Method(http.MethodOptions))
assert.NilError(c, err) assert.NilError(c, err)
assert.Equal(c, resp.StatusCode, http.StatusOK) assert.Equal(c, resp.StatusCode, http.StatusOK)
} }
func (s *DockerSuite) TestAPIGetEnabledCORS(c *check.C) { func (s *DockerSuite) TestAPIGetEnabledCORS(c *testing.T) {
res, body, err := request.Get("/version") res, body, err := request.Get("/version")
assert.NilError(c, err) assert.NilError(c, err)
assert.Equal(c, res.StatusCode, http.StatusOK) assert.Equal(c, res.StatusCode, http.StatusOK)
@ -33,7 +33,7 @@ func (s *DockerSuite) TestAPIGetEnabledCORS(c *check.C) {
//assert.Equal(c, res.Header.Get("Access-Control-Allow-Headers"), "Origin, X-Requested-With, Content-Type, Accept, X-Registry-Auth") //assert.Equal(c, res.Header.Get("Access-Control-Allow-Headers"), "Origin, X-Requested-With, Content-Type, Accept, X-Registry-Auth")
} }
func (s *DockerSuite) TestAPIClientVersionOldNotSupported(c *check.C) { func (s *DockerSuite) TestAPIClientVersionOldNotSupported(c *testing.T) {
if testEnv.OSType != runtime.GOOS { if testEnv.OSType != runtime.GOOS {
c.Skip("Daemon platform doesn't match test platform") c.Skip("Daemon platform doesn't match test platform")
} }
@ -57,7 +57,7 @@ func (s *DockerSuite) TestAPIClientVersionOldNotSupported(c *check.C) {
assert.Equal(c, strings.TrimSpace(string(content)), expected) assert.Equal(c, strings.TrimSpace(string(content)), expected)
} }
func (s *DockerSuite) TestAPIErrorJSON(c *check.C) { func (s *DockerSuite) TestAPIErrorJSON(c *testing.T) {
httpResp, body, err := request.Post("/containers/create", request.JSONBody(struct{}{})) httpResp, body, err := request.Post("/containers/create", request.JSONBody(struct{}{}))
assert.NilError(c, err) assert.NilError(c, err)
if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") {
@ -71,7 +71,7 @@ func (s *DockerSuite) TestAPIErrorJSON(c *check.C) {
assert.Equal(c, getErrorMessage(c, b), "Config cannot be empty in order to create a container") assert.Equal(c, getErrorMessage(c, b), "Config cannot be empty in order to create a container")
} }
func (s *DockerSuite) TestAPIErrorPlainText(c *check.C) { func (s *DockerSuite) TestAPIErrorPlainText(c *testing.T) {
// Windows requires API 1.25 or later. This test is validating a behaviour which was present // Windows requires API 1.25 or later. This test is validating a behaviour which was present
// in v1.23, but changed in 1.24, hence not applicable on Windows. See apiVersionSupportsJSONErrors // in v1.23, but changed in 1.24, hence not applicable on Windows. See apiVersionSupportsJSONErrors
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -88,7 +88,7 @@ func (s *DockerSuite) TestAPIErrorPlainText(c *check.C) {
assert.Equal(c, strings.TrimSpace(string(b)), "Config cannot be empty in order to create a container") assert.Equal(c, strings.TrimSpace(string(b)), "Config cannot be empty in order to create a container")
} }
func (s *DockerSuite) TestAPIErrorNotFoundJSON(c *check.C) { func (s *DockerSuite) TestAPIErrorNotFoundJSON(c *testing.T) {
// 404 is a different code path to normal errors, so test separately // 404 is a different code path to normal errors, so test separately
httpResp, body, err := request.Get("/notfound", request.JSON) httpResp, body, err := request.Get("/notfound", request.JSON)
assert.NilError(c, err) assert.NilError(c, err)
@ -99,7 +99,7 @@ func (s *DockerSuite) TestAPIErrorNotFoundJSON(c *check.C) {
assert.Equal(c, getErrorMessage(c, b), "page not found") assert.Equal(c, getErrorMessage(c, b), "page not found")
} }
func (s *DockerSuite) TestAPIErrorNotFoundPlainText(c *check.C) { func (s *DockerSuite) TestAPIErrorNotFoundPlainText(c *testing.T) {
httpResp, body, err := request.Get("/v1.23/notfound", request.JSON) httpResp, body, err := request.Get("/v1.23/notfound", request.JSON)
assert.NilError(c, err) assert.NilError(c, err)
assert.Equal(c, httpResp.StatusCode, http.StatusNotFound) assert.Equal(c, httpResp.StatusCode, http.StatusNotFound)

View file

@ -18,7 +18,7 @@ import (
const attachWait = 5 * time.Second const attachWait = 5 * time.Second
func (s *DockerSuite) TestAttachMultipleAndRestart(c *check.C) { func (s *DockerSuite) TestAttachMultipleAndRestart(c *testing.T) {
endGroup := &sync.WaitGroup{} endGroup := &sync.WaitGroup{}
startGroup := &sync.WaitGroup{} startGroup := &sync.WaitGroup{}
endGroup.Add(3) endGroup.Add(3)
@ -88,7 +88,7 @@ func (s *DockerSuite) TestAttachMultipleAndRestart(c *check.C) {
} }
} }
func (s *DockerSuite) TestAttachTTYWithoutStdin(c *check.C) { func (s *DockerSuite) TestAttachTTYWithoutStdin(c *testing.T) {
// TODO @jhowardmsft. Figure out how to get this running again reliable on Windows. // TODO @jhowardmsft. Figure out how to get this running again reliable on Windows.
// It works by accident at the moment. Sometimes. I've gone back to v1.13.0 and see the same. // It works by accident at the moment. Sometimes. I've gone back to v1.13.0 and see the same.
// On Windows, docker run -d -ti busybox causes the container to exit immediately. // On Windows, docker run -d -ti busybox causes the container to exit immediately.
@ -133,7 +133,7 @@ func (s *DockerSuite) TestAttachTTYWithoutStdin(c *check.C) {
} }
} }
func (s *DockerSuite) TestAttachDisconnect(c *check.C) { func (s *DockerSuite) TestAttachDisconnect(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-di", "busybox", "/bin/cat") out, _ := dockerCmd(c, "run", "-di", "busybox", "/bin/cat")
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
@ -166,7 +166,7 @@ func (s *DockerSuite) TestAttachDisconnect(c *check.C) {
assert.Assert(c, running, check.Equals, "true") assert.Assert(c, running, check.Equals, "true")
} }
func (s *DockerSuite) TestAttachPausedContainer(c *check.C) { func (s *DockerSuite) TestAttachPausedContainer(c *testing.T) {
testRequires(c, IsPausable) testRequires(c, IsPausable)
runSleepingContainer(c, "-d", "--name=test") runSleepingContainer(c, "-d", "--name=test")
dockerCmd(c, "pause", "test") dockerCmd(c, "pause", "test")

View file

@ -15,7 +15,7 @@ import (
) )
// #9860 Make sure attach ends when container ends (with no errors) // #9860 Make sure attach ends when container ends (with no errors)
func (s *DockerSuite) TestAttachClosedOnContainerStop(c *check.C) { func (s *DockerSuite) TestAttachClosedOnContainerStop(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
out, _ := dockerCmd(c, "run", "-dti", "busybox", "/bin/sh", "-c", `trap 'exit 0' SIGTERM; while true; do sleep 1; done`) out, _ := dockerCmd(c, "run", "-dti", "busybox", "/bin/sh", "-c", `trap 'exit 0' SIGTERM; while true; do sleep 1; done`)
@ -58,7 +58,7 @@ func (s *DockerSuite) TestAttachClosedOnContainerStop(c *check.C) {
} }
func (s *DockerSuite) TestAttachAfterDetach(c *check.C) { func (s *DockerSuite) TestAttachAfterDetach(c *testing.T) {
name := "detachtest" name := "detachtest"
cpty, tty, err := pty.Open() cpty, tty, err := pty.Open()
@ -123,7 +123,7 @@ func (s *DockerSuite) TestAttachAfterDetach(c *check.C) {
} }
// TestAttachDetach checks that attach in tty mode can be detached using the long container ID // TestAttachDetach checks that attach in tty mode can be detached using the long container ID
func (s *DockerSuite) TestAttachDetach(c *check.C) { func (s *DockerSuite) TestAttachDetach(c *testing.T) {
out, _ := dockerCmd(c, "run", "-itd", "busybox", "cat") out, _ := dockerCmd(c, "run", "-itd", "busybox", "cat")
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
assert.NilError(c, waitRun(id)) assert.NilError(c, waitRun(id))

File diff suppressed because it is too large Load diff

View file

@ -25,7 +25,7 @@ import (
"gotest.tools/icmd" "gotest.tools/icmd"
) )
func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *check.C) { func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *testing.T) {
testRequires(c, cpuCfsQuota) testRequires(c, cpuCfsQuota)
name := "testbuildresourceconstraints" name := "testbuildresourceconstraints"
buildLabel := "DockerSuite.TestBuildResourceConstraintsAreUsed" buildLabel := "DockerSuite.TestBuildResourceConstraintsAreUsed"
@ -85,7 +85,7 @@ func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *check.C) {
assert.Assert(c, c2.Ulimits, checker.IsNil, check.Commentf("resource leaked from build for Ulimits")) assert.Assert(c, c2.Ulimits, checker.IsNil, check.Commentf("resource leaked from build for Ulimits"))
} }
func (s *DockerSuite) TestBuildAddChangeOwnership(c *check.C) { func (s *DockerSuite) TestBuildAddChangeOwnership(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "testbuildaddown" name := "testbuildaddown"
@ -131,7 +131,7 @@ func (s *DockerSuite) TestBuildAddChangeOwnership(c *check.C) {
// TODO(buildkit): this test needs to be rewritten for buildkit. // TODO(buildkit): this test needs to be rewritten for buildkit.
// It has been manually tested positive. Confirmed issue: docker build output parsing. // It has been manually tested positive. Confirmed issue: docker build output parsing.
// Potential issue: newEventObserver uses docker events, which is not hooked up to buildkit. // Potential issue: newEventObserver uses docker events, which is not hooked up to buildkit.
func (s *DockerSuite) TestBuildCancellationKillsSleep(c *check.C) { func (s *DockerSuite) TestBuildCancellationKillsSleep(c *testing.T) {
testRequires(c, DaemonIsLinux, TODOBuildkit) testRequires(c, DaemonIsLinux, TODOBuildkit)
name := "testbuildcancellation" name := "testbuildcancellation"

View file

@ -27,11 +27,11 @@ var (
digestRegex = regexp.MustCompile("Digest: ([\\S]+)") digestRegex = regexp.MustCompile("Digest: ([\\S]+)")
) )
func setupImage(c *check.C) (digest.Digest, error) { func setupImage(c *testing.T) (digest.Digest, error) {
return setupImageWithTag(c, "latest") return setupImageWithTag(c, "latest")
} }
func setupImageWithTag(c *check.C, tag string) (digest.Digest, error) { func setupImageWithTag(c *testing.T, tag string) (digest.Digest, error) {
containerName := "busyboxbydigest" containerName := "busyboxbydigest"
// new file is committed because this layer is used for detecting malicious // new file is committed because this layer is used for detecting malicious
@ -59,7 +59,7 @@ func setupImageWithTag(c *check.C, tag string) (digest.Digest, error) {
return digest.Digest(pushDigest), nil return digest.Digest(pushDigest), nil
} }
func testPullByTagDisplaysDigest(c *check.C) { func testPullByTagDisplaysDigest(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
pushDigest, err := setupImage(c) pushDigest, err := setupImage(c)
assert.NilError(c, err, "error setting up image") assert.NilError(c, err, "error setting up image")
@ -76,15 +76,15 @@ func testPullByTagDisplaysDigest(c *check.C) {
assert.Assert(c, pushDigest.String(), checker.Equals, pullDigest) assert.Assert(c, pushDigest.String(), checker.Equals, pullDigest)
} }
func (s *DockerRegistrySuite) TestPullByTagDisplaysDigest(c *check.C) { func (s *DockerRegistrySuite) TestPullByTagDisplaysDigest(c *testing.T) {
testPullByTagDisplaysDigest(c) testPullByTagDisplaysDigest(c)
} }
func (s *DockerSchema1RegistrySuite) TestPullByTagDisplaysDigest(c *check.C) { func (s *DockerSchema1RegistrySuite) TestPullByTagDisplaysDigest(c *testing.T) {
testPullByTagDisplaysDigest(c) testPullByTagDisplaysDigest(c)
} }
func testPullByDigest(c *check.C) { func testPullByDigest(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
pushDigest, err := setupImage(c) pushDigest, err := setupImage(c)
assert.NilError(c, err, "error setting up image") assert.NilError(c, err, "error setting up image")
@ -102,15 +102,15 @@ func testPullByDigest(c *check.C) {
assert.Assert(c, pushDigest.String(), checker.Equals, pullDigest) assert.Assert(c, pushDigest.String(), checker.Equals, pullDigest)
} }
func (s *DockerRegistrySuite) TestPullByDigest(c *check.C) { func (s *DockerRegistrySuite) TestPullByDigest(c *testing.T) {
testPullByDigest(c) testPullByDigest(c)
} }
func (s *DockerSchema1RegistrySuite) TestPullByDigest(c *check.C) { func (s *DockerSchema1RegistrySuite) TestPullByDigest(c *testing.T) {
testPullByDigest(c) testPullByDigest(c)
} }
func testPullByDigestNoFallback(c *check.C) { func testPullByDigestNoFallback(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
// pull from the registry using the <name>@<digest> reference // pull from the registry using the <name>@<digest> reference
imageReference := fmt.Sprintf("%s@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", repoName) imageReference := fmt.Sprintf("%s@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", repoName)
@ -119,15 +119,15 @@ func testPullByDigestNoFallback(c *check.C) {
assert.Assert(c, out, checker.Contains, fmt.Sprintf("manifest for %s not found", imageReference), check.Commentf("expected non-zero exit status and correct error message when pulling non-existing image")) assert.Assert(c, out, checker.Contains, fmt.Sprintf("manifest for %s not found", imageReference), check.Commentf("expected non-zero exit status and correct error message when pulling non-existing image"))
} }
func (s *DockerRegistrySuite) TestPullByDigestNoFallback(c *check.C) { func (s *DockerRegistrySuite) TestPullByDigestNoFallback(c *testing.T) {
testPullByDigestNoFallback(c) testPullByDigestNoFallback(c)
} }
func (s *DockerSchema1RegistrySuite) TestPullByDigestNoFallback(c *check.C) { func (s *DockerSchema1RegistrySuite) TestPullByDigestNoFallback(c *testing.T) {
testPullByDigestNoFallback(c) testPullByDigestNoFallback(c)
} }
func (s *DockerRegistrySuite) TestCreateByDigest(c *check.C) { func (s *DockerRegistrySuite) TestCreateByDigest(c *testing.T) {
pushDigest, err := setupImage(c) pushDigest, err := setupImage(c)
assert.NilError(c, err, "error setting up image") assert.NilError(c, err, "error setting up image")
@ -140,7 +140,7 @@ func (s *DockerRegistrySuite) TestCreateByDigest(c *check.C) {
assert.Equal(c, res, imageReference) assert.Equal(c, res, imageReference)
} }
func (s *DockerRegistrySuite) TestRunByDigest(c *check.C) { func (s *DockerRegistrySuite) TestRunByDigest(c *testing.T) {
pushDigest, err := setupImage(c) pushDigest, err := setupImage(c)
assert.NilError(c, err) assert.NilError(c, err)
@ -158,7 +158,7 @@ func (s *DockerRegistrySuite) TestRunByDigest(c *check.C) {
assert.Equal(c, res, imageReference) assert.Equal(c, res, imageReference)
} }
func (s *DockerRegistrySuite) TestRemoveImageByDigest(c *check.C) { func (s *DockerRegistrySuite) TestRemoveImageByDigest(c *testing.T) {
digest, err := setupImage(c) digest, err := setupImage(c)
assert.NilError(c, err, "error setting up image") assert.NilError(c, err, "error setting up image")
@ -180,7 +180,7 @@ func (s *DockerRegistrySuite) TestRemoveImageByDigest(c *check.C) {
assert.ErrorContains(c, err, "No such object") assert.ErrorContains(c, err, "No such object")
} }
func (s *DockerRegistrySuite) TestBuildByDigest(c *check.C) { func (s *DockerRegistrySuite) TestBuildByDigest(c *testing.T) {
digest, err := setupImage(c) digest, err := setupImage(c)
assert.NilError(c, err, "error setting up image") assert.NilError(c, err, "error setting up image")
@ -205,7 +205,7 @@ func (s *DockerRegistrySuite) TestBuildByDigest(c *check.C) {
assert.Equal(c, res, imageID) assert.Equal(c, res, imageID)
} }
func (s *DockerRegistrySuite) TestTagByDigest(c *check.C) { func (s *DockerRegistrySuite) TestTagByDigest(c *testing.T) {
digest, err := setupImage(c) digest, err := setupImage(c)
assert.NilError(c, err, "error setting up image") assert.NilError(c, err, "error setting up image")
@ -224,7 +224,7 @@ func (s *DockerRegistrySuite) TestTagByDigest(c *check.C) {
assert.Equal(c, tagID, expectedID) assert.Equal(c, tagID, expectedID)
} }
func (s *DockerRegistrySuite) TestListImagesWithoutDigests(c *check.C) { func (s *DockerRegistrySuite) TestListImagesWithoutDigests(c *testing.T) {
digest, err := setupImage(c) digest, err := setupImage(c)
assert.NilError(c, err, "error setting up image") assert.NilError(c, err, "error setting up image")
@ -237,7 +237,7 @@ func (s *DockerRegistrySuite) TestListImagesWithoutDigests(c *check.C) {
assert.Assert(c, out, checker.Not(checker.Contains), "DIGEST", check.Commentf("list output should not have contained DIGEST header")) assert.Assert(c, out, checker.Not(checker.Contains), "DIGEST", check.Commentf("list output should not have contained DIGEST header"))
} }
func (s *DockerRegistrySuite) TestListImagesWithDigests(c *check.C) { func (s *DockerRegistrySuite) TestListImagesWithDigests(c *testing.T) {
// setup image1 // setup image1
digest1, err := setupImageWithTag(c, "tag1") digest1, err := setupImageWithTag(c, "tag1")
@ -314,7 +314,7 @@ func (s *DockerRegistrySuite) TestListImagesWithDigests(c *check.C) {
assert.Assert(c, busyboxRe.MatchString(out), checker.True, check.Commentf("expected %q: %s", busyboxRe.String(), out)) assert.Assert(c, busyboxRe.MatchString(out), checker.True, check.Commentf("expected %q: %s", busyboxRe.String(), out))
} }
func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *check.C) { func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *testing.T) {
// setup image1 // setup image1
digest1, err := setupImageWithTag(c, "dangle1") digest1, err := setupImageWithTag(c, "dangle1")
assert.NilError(c, err, "error setting up image") assert.NilError(c, err, "error setting up image")
@ -387,7 +387,7 @@ func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *check.C) {
assert.Assert(c, reWithDigest2.MatchString(out), checker.False, check.Commentf("unexpected %q: %s", reWithDigest2.String(), out)) assert.Assert(c, reWithDigest2.MatchString(out), checker.False, check.Commentf("unexpected %q: %s", reWithDigest2.String(), out))
} }
func (s *DockerRegistrySuite) TestInspectImageWithDigests(c *check.C) { func (s *DockerRegistrySuite) TestInspectImageWithDigests(c *testing.T) {
digest, err := setupImage(c) digest, err := setupImage(c)
assert.Assert(c, err, check.IsNil, check.Commentf("error setting up image")) assert.Assert(c, err, check.IsNil, check.Commentf("error setting up image"))
@ -406,7 +406,7 @@ func (s *DockerRegistrySuite) TestInspectImageWithDigests(c *check.C) {
assert.Check(c, is.Contains(imageJSON[0].RepoDigests, imageReference)) assert.Check(c, is.Contains(imageJSON[0].RepoDigests, imageReference))
} }
func (s *DockerRegistrySuite) TestPsListContainersFilterAncestorImageByDigest(c *check.C) { func (s *DockerRegistrySuite) TestPsListContainersFilterAncestorImageByDigest(c *testing.T) {
existingContainers := ExistingContainerIDs(c) existingContainers := ExistingContainerIDs(c)
digest, err := setupImage(c) digest, err := setupImage(c)
@ -442,7 +442,7 @@ func (s *DockerRegistrySuite) TestPsListContainersFilterAncestorImageByDigest(c
checkPsAncestorFilterOutput(c, RemoveOutputForExistingElements(out, existingContainers), imageReference, expectedIDs) checkPsAncestorFilterOutput(c, RemoveOutputForExistingElements(out, existingContainers), imageReference, expectedIDs)
} }
func (s *DockerRegistrySuite) TestDeleteImageByIDOnlyPulledByDigest(c *check.C) { func (s *DockerRegistrySuite) TestDeleteImageByIDOnlyPulledByDigest(c *testing.T) {
pushDigest, err := setupImage(c) pushDigest, err := setupImage(c)
assert.NilError(c, err, "error setting up image") assert.NilError(c, err, "error setting up image")
@ -461,7 +461,7 @@ func (s *DockerRegistrySuite) TestDeleteImageByIDOnlyPulledByDigest(c *check.C)
assert.ErrorContains(c, err, "", "image should have been deleted") assert.ErrorContains(c, err, "", "image should have been deleted")
} }
func (s *DockerRegistrySuite) TestDeleteImageWithDigestAndTag(c *check.C) { func (s *DockerRegistrySuite) TestDeleteImageWithDigestAndTag(c *testing.T) {
pushDigest, err := setupImage(c) pushDigest, err := setupImage(c)
assert.NilError(c, err, "error setting up image") assert.NilError(c, err, "error setting up image")
@ -488,7 +488,7 @@ func (s *DockerRegistrySuite) TestDeleteImageWithDigestAndTag(c *check.C) {
assert.ErrorContains(c, err, "", "image should have been deleted") assert.ErrorContains(c, err, "", "image should have been deleted")
} }
func (s *DockerRegistrySuite) TestDeleteImageWithDigestAndMultiRepoTag(c *check.C) { func (s *DockerRegistrySuite) TestDeleteImageWithDigestAndMultiRepoTag(c *testing.T) {
pushDigest, err := setupImage(c) pushDigest, err := setupImage(c)
assert.NilError(c, err, "error setting up image") assert.NilError(c, err, "error setting up image")
@ -525,7 +525,7 @@ func (s *DockerRegistrySuite) TestDeleteImageWithDigestAndMultiRepoTag(c *check.
// TestPullFailsWithAlteredManifest tests that a `docker pull` fails when // TestPullFailsWithAlteredManifest tests that a `docker pull` fails when
// we have modified a manifest blob and its digest cannot be verified. // we have modified a manifest blob and its digest cannot be verified.
// This is the schema2 version of the test. // This is the schema2 version of the test.
func (s *DockerRegistrySuite) TestPullFailsWithAlteredManifest(c *check.C) { func (s *DockerRegistrySuite) TestPullFailsWithAlteredManifest(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
manifestDigest, err := setupImage(c) manifestDigest, err := setupImage(c)
assert.NilError(c, err, "error setting up image") assert.NilError(c, err, "error setting up image")
@ -565,7 +565,7 @@ func (s *DockerRegistrySuite) TestPullFailsWithAlteredManifest(c *check.C) {
// TestPullFailsWithAlteredManifest tests that a `docker pull` fails when // TestPullFailsWithAlteredManifest tests that a `docker pull` fails when
// we have modified a manifest blob and its digest cannot be verified. // we have modified a manifest blob and its digest cannot be verified.
// This is the schema1 version of the test. // This is the schema1 version of the test.
func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredManifest(c *check.C) { func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredManifest(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
manifestDigest, err := setupImage(c) manifestDigest, err := setupImage(c)
assert.Assert(c, err, checker.IsNil, check.Commentf("error setting up image")) assert.Assert(c, err, checker.IsNil, check.Commentf("error setting up image"))
@ -607,7 +607,7 @@ func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredManifest(c *check.C
// TestPullFailsWithAlteredLayer tests that a `docker pull` fails when // TestPullFailsWithAlteredLayer tests that a `docker pull` fails when
// we have modified a layer blob and its digest cannot be verified. // we have modified a layer blob and its digest cannot be verified.
// This is the schema2 version of the test. // This is the schema2 version of the test.
func (s *DockerRegistrySuite) TestPullFailsWithAlteredLayer(c *check.C) { func (s *DockerRegistrySuite) TestPullFailsWithAlteredLayer(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
manifestDigest, err := setupImage(c) manifestDigest, err := setupImage(c)
assert.Assert(c, err, checker.IsNil) assert.Assert(c, err, checker.IsNil)
@ -650,7 +650,7 @@ func (s *DockerRegistrySuite) TestPullFailsWithAlteredLayer(c *check.C) {
// TestPullFailsWithAlteredLayer tests that a `docker pull` fails when // TestPullFailsWithAlteredLayer tests that a `docker pull` fails when
// we have modified a layer blob and its digest cannot be verified. // we have modified a layer blob and its digest cannot be verified.
// This is the schema1 version of the test. // This is the schema1 version of the test.
func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredLayer(c *check.C) { func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredLayer(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
manifestDigest, err := setupImage(c) manifestDigest, err := setupImage(c)
assert.Assert(c, err, checker.IsNil) assert.Assert(c, err, checker.IsNil)

View file

@ -9,7 +9,7 @@ import (
"github.com/go-check/check" "github.com/go-check/check"
) )
func (s *DockerSuite) TestCommitAfterContainerIsDone(c *check.C) { func (s *DockerSuite) TestCommitAfterContainerIsDone(c *testing.T) {
out := cli.DockerCmd(c, "run", "-i", "-a", "stdin", "busybox", "echo", "foo").Combined() out := cli.DockerCmd(c, "run", "-i", "-a", "stdin", "busybox", "echo", "foo").Combined()
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
@ -23,7 +23,7 @@ func (s *DockerSuite) TestCommitAfterContainerIsDone(c *check.C) {
cli.DockerCmd(c, "inspect", cleanedImageID) cli.DockerCmd(c, "inspect", cleanedImageID)
} }
func (s *DockerSuite) TestCommitWithoutPause(c *check.C) { func (s *DockerSuite) TestCommitWithoutPause(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-i", "-a", "stdin", "busybox", "echo", "foo") out, _ := dockerCmd(c, "run", "-i", "-a", "stdin", "busybox", "echo", "foo")
@ -39,7 +39,7 @@ func (s *DockerSuite) TestCommitWithoutPause(c *check.C) {
} }
//test commit a paused container should not unpause it after commit //test commit a paused container should not unpause it after commit
func (s *DockerSuite) TestCommitPausedContainer(c *check.C) { func (s *DockerSuite) TestCommitPausedContainer(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-i", "-d", "busybox") out, _ := dockerCmd(c, "run", "-i", "-d", "busybox")
@ -53,7 +53,7 @@ func (s *DockerSuite) TestCommitPausedContainer(c *check.C) {
assert.Assert(c, out, checker.Contains, "true") assert.Assert(c, out, checker.Contains, "true")
} }
func (s *DockerSuite) TestCommitNewFile(c *check.C) { func (s *DockerSuite) TestCommitNewFile(c *testing.T) {
dockerCmd(c, "run", "--name", "committer", "busybox", "/bin/sh", "-c", "echo koye > /foo") dockerCmd(c, "run", "--name", "committer", "busybox", "/bin/sh", "-c", "echo koye > /foo")
imageID, _ := dockerCmd(c, "commit", "committer") imageID, _ := dockerCmd(c, "commit", "committer")
@ -64,7 +64,7 @@ func (s *DockerSuite) TestCommitNewFile(c *check.C) {
assert.Assert(c, actual, checker.Equals, "koye") assert.Assert(c, actual, checker.Equals, "koye")
} }
func (s *DockerSuite) TestCommitHardlink(c *check.C) { func (s *DockerSuite) TestCommitHardlink(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
firstOutput, _ := dockerCmd(c, "run", "-t", "--name", "hardlinks", "busybox", "sh", "-c", "touch file1 && ln file1 file2 && ls -di file1 file2") firstOutput, _ := dockerCmd(c, "run", "-t", "--name", "hardlinks", "busybox", "sh", "-c", "touch file1 && ln file1 file2 && ls -di file1 file2")
@ -84,7 +84,7 @@ func (s *DockerSuite) TestCommitHardlink(c *check.C) {
assert.Assert(c, chunks[1], checker.Contains, chunks[0], check.Commentf("Failed to create hardlink in a container. Expected to find %q in %q", inode, chunks[1:])) assert.Assert(c, chunks[1], checker.Contains, chunks[0], check.Commentf("Failed to create hardlink in a container. Expected to find %q in %q", inode, chunks[1:]))
} }
func (s *DockerSuite) TestCommitTTY(c *check.C) { func (s *DockerSuite) TestCommitTTY(c *testing.T) {
dockerCmd(c, "run", "-t", "--name", "tty", "busybox", "/bin/ls") dockerCmd(c, "run", "-t", "--name", "tty", "busybox", "/bin/ls")
imageID, _ := dockerCmd(c, "commit", "tty", "ttytest") imageID, _ := dockerCmd(c, "commit", "tty", "ttytest")
@ -93,7 +93,7 @@ func (s *DockerSuite) TestCommitTTY(c *check.C) {
dockerCmd(c, "run", imageID, "/bin/ls") dockerCmd(c, "run", imageID, "/bin/ls")
} }
func (s *DockerSuite) TestCommitWithHostBindMount(c *check.C) { func (s *DockerSuite) TestCommitWithHostBindMount(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "--name", "bind-commit", "-v", "/dev/null:/winning", "busybox", "true") dockerCmd(c, "run", "--name", "bind-commit", "-v", "/dev/null:/winning", "busybox", "true")
@ -103,7 +103,7 @@ func (s *DockerSuite) TestCommitWithHostBindMount(c *check.C) {
dockerCmd(c, "run", imageID, "true") dockerCmd(c, "run", imageID, "true")
} }
func (s *DockerSuite) TestCommitChange(c *check.C) { func (s *DockerSuite) TestCommitChange(c *testing.T) {
dockerCmd(c, "run", "--name", "test", "busybox", "true") dockerCmd(c, "run", "--name", "test", "busybox", "true")
imageID, _ := dockerCmd(c, "commit", imageID, _ := dockerCmd(c, "commit",
@ -153,7 +153,7 @@ func (s *DockerSuite) TestCommitChange(c *check.C) {
} }
} }
func (s *DockerSuite) TestCommitChangeLabels(c *check.C) { func (s *DockerSuite) TestCommitChangeLabels(c *testing.T) {
dockerCmd(c, "run", "--name", "test", "--label", "some=label", "busybox", "true") dockerCmd(c, "run", "--name", "test", "--label", "some=label", "busybox", "true")
imageID, _ := dockerCmd(c, "commit", imageID, _ := dockerCmd(c, "commit",

View file

@ -22,7 +22,7 @@ import (
// Check that copying from a container to a local symlink copies to the symlink // Check that copying from a container to a local symlink copies to the symlink
// target and does not overwrite the local symlink itself. // target and does not overwrite the local symlink itself.
// TODO: move to docker/cli and/or integration/container/copy_test.go // TODO: move to docker/cli and/or integration/container/copy_test.go
func (s *DockerSuite) TestCpFromSymlinkDestination(c *check.C) { func (s *DockerSuite) TestCpFromSymlinkDestination(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{addContent: true}) containerID := makeTestContainer(c, testContainerOptions{addContent: true})
@ -117,7 +117,7 @@ func (s *DockerSuite) TestCpFromSymlinkDestination(c *check.C) {
// A. SRC specifies a file and DST (no trailing path separator) doesn't // A. SRC specifies a file and DST (no trailing path separator) doesn't
// exist. This should create a file with the name DST and copy the // exist. This should create a file with the name DST and copy the
// contents of the source file into it. // contents of the source file into it.
func (s *DockerSuite) TestCpFromCaseA(c *check.C) { func (s *DockerSuite) TestCpFromCaseA(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{ containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root", addContent: true, workDir: "/root",
@ -137,7 +137,7 @@ func (s *DockerSuite) TestCpFromCaseA(c *check.C) {
// B. SRC specifies a file and DST (with trailing path separator) doesn't // B. SRC specifies a file and DST (with trailing path separator) doesn't
// exist. This should cause an error because the copy operation cannot // exist. This should cause an error because the copy operation cannot
// create a directory when copying a single file. // create a directory when copying a single file.
func (s *DockerSuite) TestCpFromCaseB(c *check.C) { func (s *DockerSuite) TestCpFromCaseB(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{addContent: true}) containerID := makeTestContainer(c, testContainerOptions{addContent: true})
@ -155,7 +155,7 @@ func (s *DockerSuite) TestCpFromCaseB(c *check.C) {
// C. SRC specifies a file and DST exists as a file. This should overwrite // C. SRC specifies a file and DST exists as a file. This should overwrite
// the file at DST with the contents of the source file. // the file at DST with the contents of the source file.
func (s *DockerSuite) TestCpFromCaseC(c *check.C) { func (s *DockerSuite) TestCpFromCaseC(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{ containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root", addContent: true, workDir: "/root",
@ -180,7 +180,7 @@ func (s *DockerSuite) TestCpFromCaseC(c *check.C) {
// D. SRC specifies a file and DST exists as a directory. This should place // D. SRC specifies a file and DST exists as a directory. This should place
// a copy of the source file inside it using the basename from SRC. Ensure // a copy of the source file inside it using the basename from SRC. Ensure
// this works whether DST has a trailing path separator or not. // this works whether DST has a trailing path separator or not.
func (s *DockerSuite) TestCpFromCaseD(c *check.C) { func (s *DockerSuite) TestCpFromCaseD(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{addContent: true}) containerID := makeTestContainer(c, testContainerOptions{addContent: true})
@ -220,7 +220,7 @@ func (s *DockerSuite) TestCpFromCaseD(c *check.C) {
// directory at DST and copy the contents of the SRC directory into the DST // directory at DST and copy the contents of the SRC directory into the DST
// directory. Ensure this works whether DST has a trailing path separator or // directory. Ensure this works whether DST has a trailing path separator or
// not. // not.
func (s *DockerSuite) TestCpFromCaseE(c *check.C) { func (s *DockerSuite) TestCpFromCaseE(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{addContent: true}) containerID := makeTestContainer(c, testContainerOptions{addContent: true})
@ -249,7 +249,7 @@ func (s *DockerSuite) TestCpFromCaseE(c *check.C) {
// F. SRC specifies a directory and DST exists as a file. This should cause an // F. SRC specifies a directory and DST exists as a file. This should cause an
// error as it is not possible to overwrite a file with a directory. // error as it is not possible to overwrite a file with a directory.
func (s *DockerSuite) TestCpFromCaseF(c *check.C) { func (s *DockerSuite) TestCpFromCaseF(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{ containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root", addContent: true, workDir: "/root",
@ -272,7 +272,7 @@ func (s *DockerSuite) TestCpFromCaseF(c *check.C) {
// G. SRC specifies a directory and DST exists as a directory. This should copy // G. SRC specifies a directory and DST exists as a directory. This should copy
// the SRC directory and all its contents to the DST directory. Ensure this // the SRC directory and all its contents to the DST directory. Ensure this
// works whether DST has a trailing path separator or not. // works whether DST has a trailing path separator or not.
func (s *DockerSuite) TestCpFromCaseG(c *check.C) { func (s *DockerSuite) TestCpFromCaseG(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{ containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root", addContent: true, workDir: "/root",
@ -311,7 +311,7 @@ func (s *DockerSuite) TestCpFromCaseG(c *check.C) {
// should create a directory at DST and copy the contents of the SRC // should create a directory at DST and copy the contents of the SRC
// directory (but not the directory itself) into the DST directory. Ensure // directory (but not the directory itself) into the DST directory. Ensure
// this works whether DST has a trailing path separator or not. // this works whether DST has a trailing path separator or not.
func (s *DockerSuite) TestCpFromCaseH(c *check.C) { func (s *DockerSuite) TestCpFromCaseH(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{addContent: true}) containerID := makeTestContainer(c, testContainerOptions{addContent: true})
@ -341,7 +341,7 @@ func (s *DockerSuite) TestCpFromCaseH(c *check.C) {
// I. SRC specifies a directory's contents only and DST exists as a file. This // I. SRC specifies a directory's contents only and DST exists as a file. This
// should cause an error as it is not possible to overwrite a file with a // should cause an error as it is not possible to overwrite a file with a
// directory. // directory.
func (s *DockerSuite) TestCpFromCaseI(c *check.C) { func (s *DockerSuite) TestCpFromCaseI(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{ containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root", addContent: true, workDir: "/root",
@ -365,7 +365,7 @@ func (s *DockerSuite) TestCpFromCaseI(c *check.C) {
// This should copy the contents of the SRC directory (but not the directory // This should copy the contents of the SRC directory (but not the directory
// itself) into the DST directory. Ensure this works whether DST has a // itself) into the DST directory. Ensure this works whether DST has a
// trailing path separator or not. // trailing path separator or not.
func (s *DockerSuite) TestCpFromCaseJ(c *check.C) { func (s *DockerSuite) TestCpFromCaseJ(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{ containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root", addContent: true, workDir: "/root",

View file

@ -27,14 +27,14 @@ const (
) )
// Ensure that an all-local path case returns an error. // Ensure that an all-local path case returns an error.
func (s *DockerSuite) TestCpLocalOnly(c *check.C) { func (s *DockerSuite) TestCpLocalOnly(c *testing.T) {
err := runDockerCp(c, "foo", "bar", nil) err := runDockerCp(c, "foo", "bar", nil)
assert.ErrorContains(c, err, "must specify at least one container source") assert.ErrorContains(c, err, "must specify at least one container source")
} }
// Test for #5656 // Test for #5656
// Check that garbage paths don't escape the container's rootfs // Check that garbage paths don't escape the container's rootfs
func (s *DockerSuite) TestCpGarbagePath(c *check.C) { func (s *DockerSuite) TestCpGarbagePath(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath) out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath)
containerID := strings.TrimSpace(out) containerID := strings.TrimSpace(out)
@ -70,7 +70,7 @@ func (s *DockerSuite) TestCpGarbagePath(c *check.C) {
} }
// Check that relative paths are relative to the container's rootfs // Check that relative paths are relative to the container's rootfs
func (s *DockerSuite) TestCpRelativePath(c *check.C) { func (s *DockerSuite) TestCpRelativePath(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath) out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath)
containerID := strings.TrimSpace(out) containerID := strings.TrimSpace(out)
@ -112,7 +112,7 @@ func (s *DockerSuite) TestCpRelativePath(c *check.C) {
} }
// Check that absolute paths are relative to the container's rootfs // Check that absolute paths are relative to the container's rootfs
func (s *DockerSuite) TestCpAbsolutePath(c *check.C) { func (s *DockerSuite) TestCpAbsolutePath(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath) out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath)
containerID := strings.TrimSpace(out) containerID := strings.TrimSpace(out)
@ -149,7 +149,7 @@ func (s *DockerSuite) TestCpAbsolutePath(c *check.C) {
// Test for #5619 // Test for #5619
// Check that absolute symlinks are still relative to the container's rootfs // Check that absolute symlinks are still relative to the container's rootfs
func (s *DockerSuite) TestCpAbsoluteSymlink(c *check.C) { func (s *DockerSuite) TestCpAbsoluteSymlink(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpFullPath+" container_path") out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpFullPath+" container_path")
@ -185,7 +185,7 @@ func (s *DockerSuite) TestCpAbsoluteSymlink(c *check.C) {
// Check that symlinks to a directory behave as expected when copying one from // Check that symlinks to a directory behave as expected when copying one from
// a container. // a container.
func (s *DockerSuite) TestCpFromSymlinkToDirectory(c *check.C) { func (s *DockerSuite) TestCpFromSymlinkToDirectory(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpTestPathParent+" /dir_link") out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpTestPathParent+" /dir_link")
@ -231,7 +231,7 @@ func (s *DockerSuite) TestCpFromSymlinkToDirectory(c *check.C) {
// Check that symlinks to a directory behave as expected when copying one to a // Check that symlinks to a directory behave as expected when copying one to a
// container. // container.
func (s *DockerSuite) TestCpToSymlinkToDirectory(c *check.C) { func (s *DockerSuite) TestCpToSymlinkToDirectory(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, testEnv.IsLocalDaemon) // Requires local volume mount bind. testRequires(c, testEnv.IsLocalDaemon) // Requires local volume mount bind.
@ -308,7 +308,7 @@ func (s *DockerSuite) TestCpToSymlinkToDirectory(c *check.C) {
// Test for #5619 // Test for #5619
// Check that symlinks which are part of the resource path are still relative to the container's rootfs // Check that symlinks which are part of the resource path are still relative to the container's rootfs
func (s *DockerSuite) TestCpSymlinkComponent(c *check.C) { func (s *DockerSuite) TestCpSymlinkComponent(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpTestPath+" container_path") out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpTestPath+" container_path")
@ -347,7 +347,7 @@ func (s *DockerSuite) TestCpSymlinkComponent(c *check.C) {
} }
// Check that cp with unprivileged user doesn't return any error // Check that cp with unprivileged user doesn't return any error
func (s *DockerSuite) TestCpUnprivilegedUser(c *check.C) { func (s *DockerSuite) TestCpUnprivilegedUser(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
testRequires(c, UnixCli) // uses chmod/su: not available on windows testRequires(c, UnixCli) // uses chmod/su: not available on windows
@ -371,7 +371,7 @@ func (s *DockerSuite) TestCpUnprivilegedUser(c *check.C) {
result.Assert(c, icmd.Expected{}) result.Assert(c, icmd.Expected{})
} }
func (s *DockerSuite) TestCpSpecialFiles(c *check.C) { func (s *DockerSuite) TestCpSpecialFiles(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
@ -411,7 +411,7 @@ func (s *DockerSuite) TestCpSpecialFiles(c *check.C) {
assert.Assert(c, bytes.Equal(actual, expected), "Expected copied file to be duplicate of the container hostname") assert.Assert(c, bytes.Equal(actual, expected), "Expected copied file to be duplicate of the container hostname")
} }
func (s *DockerSuite) TestCpVolumePath(c *check.C) { func (s *DockerSuite) TestCpVolumePath(c *testing.T) {
// stat /tmp/cp-test-volumepath851508420/test gets permission denied for the user // stat /tmp/cp-test-volumepath851508420/test gets permission denied for the user
testRequires(c, NotUserNamespace) testRequires(c, NotUserNamespace)
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -474,7 +474,7 @@ func (s *DockerSuite) TestCpVolumePath(c *check.C) {
assert.Assert(c, bytes.Equal(fb, fb2), "Expected copied file to be duplicate of bind-mounted file") assert.Assert(c, bytes.Equal(fb, fb2), "Expected copied file to be duplicate of bind-mounted file")
} }
func (s *DockerSuite) TestCpToDot(c *check.C) { func (s *DockerSuite) TestCpToDot(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /test") out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /test")
containerID := strings.TrimSpace(out) containerID := strings.TrimSpace(out)
@ -497,7 +497,7 @@ func (s *DockerSuite) TestCpToDot(c *check.C) {
assert.Equal(c, string(content), "lololol\n") assert.Equal(c, string(content), "lololol\n")
} }
func (s *DockerSuite) TestCpToStdout(c *check.C) { func (s *DockerSuite) TestCpToStdout(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /test") out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /test")
containerID := strings.TrimSpace(out) containerID := strings.TrimSpace(out)
@ -514,7 +514,7 @@ func (s *DockerSuite) TestCpToStdout(c *check.C) {
assert.Check(c, is.Contains(out, "-rw")) assert.Check(c, is.Contains(out, "-rw"))
} }
func (s *DockerSuite) TestCpNameHasColon(c *check.C) { func (s *DockerSuite) TestCpNameHasColon(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /te:s:t") out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /te:s:t")
@ -533,7 +533,7 @@ func (s *DockerSuite) TestCpNameHasColon(c *check.C) {
assert.Equal(c, string(content), "lololol\n") assert.Equal(c, string(content), "lololol\n")
} }
func (s *DockerSuite) TestCopyAndRestart(c *check.C) { func (s *DockerSuite) TestCopyAndRestart(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
expectedMsg := "hello" expectedMsg := "hello"
out, _ := dockerCmd(c, "run", "-d", "busybox", "echo", expectedMsg) out, _ := dockerCmd(c, "run", "-d", "busybox", "echo", expectedMsg)
@ -552,7 +552,7 @@ func (s *DockerSuite) TestCopyAndRestart(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), expectedMsg) assert.Equal(c, strings.TrimSpace(out), expectedMsg)
} }
func (s *DockerSuite) TestCopyCreatedContainer(c *check.C) { func (s *DockerSuite) TestCopyCreatedContainer(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "create", "--name", "test_cp", "-v", "/test", "busybox") dockerCmd(c, "create", "--name", "test_cp", "-v", "/test", "busybox")
@ -565,7 +565,7 @@ func (s *DockerSuite) TestCopyCreatedContainer(c *check.C) {
// test copy with option `-L`: following symbol link // test copy with option `-L`: following symbol link
// Check that symlinks to a file behave as expected when copying one from // Check that symlinks to a file behave as expected when copying one from
// a container to host following symbol link // a container to host following symbol link
func (s *DockerSuite) TestCpSymlinkFromConToHostFollowSymlink(c *check.C) { func (s *DockerSuite) TestCpSymlinkFromConToHostFollowSymlink(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, exitCode := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpFullPath+" /dir_link") out, exitCode := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpFullPath+" /dir_link")
assert.Equal(c, exitCode, 0, "failed to set up container: %s", out) assert.Equal(c, exitCode, 0, "failed to set up container: %s", out)

View file

@ -20,7 +20,7 @@ import (
// Check that copying from a local path to a symlink in a container copies to // Check that copying from a local path to a symlink in a container copies to
// the symlink target and does not overwrite the container symlink itself. // the symlink target and does not overwrite the container symlink itself.
func (s *DockerSuite) TestCpToSymlinkDestination(c *check.C) { func (s *DockerSuite) TestCpToSymlinkDestination(c *testing.T) {
// stat /tmp/test-cp-to-symlink-destination-262430901/vol3 gets permission denied for the user // stat /tmp/test-cp-to-symlink-destination-262430901/vol3 gets permission denied for the user
testRequires(c, NotUserNamespace) testRequires(c, NotUserNamespace)
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -121,7 +121,7 @@ func (s *DockerSuite) TestCpToSymlinkDestination(c *check.C) {
// A. SRC specifies a file and DST (no trailing path separator) doesn't // A. SRC specifies a file and DST (no trailing path separator) doesn't
// exist. This should create a file with the name DST and copy the // exist. This should create a file with the name DST and copy the
// contents of the source file into it. // contents of the source file into it.
func (s *DockerSuite) TestCpToCaseA(c *check.C) { func (s *DockerSuite) TestCpToCaseA(c *testing.T) {
containerID := makeTestContainer(c, testContainerOptions{ containerID := makeTestContainer(c, testContainerOptions{
workDir: "/root", command: makeCatFileCommand("itWorks.txt"), workDir: "/root", command: makeCatFileCommand("itWorks.txt"),
}) })
@ -142,7 +142,7 @@ func (s *DockerSuite) TestCpToCaseA(c *check.C) {
// B. SRC specifies a file and DST (with trailing path separator) doesn't // B. SRC specifies a file and DST (with trailing path separator) doesn't
// exist. This should cause an error because the copy operation cannot // exist. This should cause an error because the copy operation cannot
// create a directory when copying a single file. // create a directory when copying a single file.
func (s *DockerSuite) TestCpToCaseB(c *check.C) { func (s *DockerSuite) TestCpToCaseB(c *testing.T) {
containerID := makeTestContainer(c, testContainerOptions{ containerID := makeTestContainer(c, testContainerOptions{
command: makeCatFileCommand("testDir/file1"), command: makeCatFileCommand("testDir/file1"),
}) })
@ -163,7 +163,7 @@ func (s *DockerSuite) TestCpToCaseB(c *check.C) {
// C. SRC specifies a file and DST exists as a file. This should overwrite // C. SRC specifies a file and DST exists as a file. This should overwrite
// the file at DST with the contents of the source file. // the file at DST with the contents of the source file.
func (s *DockerSuite) TestCpToCaseC(c *check.C) { func (s *DockerSuite) TestCpToCaseC(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{ containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root", addContent: true, workDir: "/root",
@ -190,7 +190,7 @@ func (s *DockerSuite) TestCpToCaseC(c *check.C) {
// D. SRC specifies a file and DST exists as a directory. This should place // D. SRC specifies a file and DST exists as a directory. This should place
// a copy of the source file inside it using the basename from SRC. Ensure // a copy of the source file inside it using the basename from SRC. Ensure
// this works whether DST has a trailing path separator or not. // this works whether DST has a trailing path separator or not.
func (s *DockerSuite) TestCpToCaseD(c *check.C) { func (s *DockerSuite) TestCpToCaseD(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{ containerID := makeTestContainer(c, testContainerOptions{
addContent: true, addContent: true,
@ -236,7 +236,7 @@ func (s *DockerSuite) TestCpToCaseD(c *check.C) {
// directory at DST and copy the contents of the SRC directory into the DST // directory at DST and copy the contents of the SRC directory into the DST
// directory. Ensure this works whether DST has a trailing path separator or // directory. Ensure this works whether DST has a trailing path separator or
// not. // not.
func (s *DockerSuite) TestCpToCaseE(c *check.C) { func (s *DockerSuite) TestCpToCaseE(c *testing.T) {
containerID := makeTestContainer(c, testContainerOptions{ containerID := makeTestContainer(c, testContainerOptions{
command: makeCatFileCommand("/testDir/file1-1"), command: makeCatFileCommand("/testDir/file1-1"),
}) })
@ -271,7 +271,7 @@ func (s *DockerSuite) TestCpToCaseE(c *check.C) {
// F. SRC specifies a directory and DST exists as a file. This should cause an // F. SRC specifies a directory and DST exists as a file. This should cause an
// error as it is not possible to overwrite a file with a directory. // error as it is not possible to overwrite a file with a directory.
func (s *DockerSuite) TestCpToCaseF(c *check.C) { func (s *DockerSuite) TestCpToCaseF(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{ containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root", addContent: true, workDir: "/root",
@ -294,7 +294,7 @@ func (s *DockerSuite) TestCpToCaseF(c *check.C) {
// G. SRC specifies a directory and DST exists as a directory. This should copy // G. SRC specifies a directory and DST exists as a directory. This should copy
// the SRC directory and all its contents to the DST directory. Ensure this // the SRC directory and all its contents to the DST directory. Ensure this
// works whether DST has a trailing path separator or not. // works whether DST has a trailing path separator or not.
func (s *DockerSuite) TestCpToCaseG(c *check.C) { func (s *DockerSuite) TestCpToCaseG(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{ containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root", addContent: true, workDir: "/root",
@ -340,7 +340,7 @@ func (s *DockerSuite) TestCpToCaseG(c *check.C) {
// should create a directory at DST and copy the contents of the SRC // should create a directory at DST and copy the contents of the SRC
// directory (but not the directory itself) into the DST directory. Ensure // directory (but not the directory itself) into the DST directory. Ensure
// this works whether DST has a trailing path separator or not. // this works whether DST has a trailing path separator or not.
func (s *DockerSuite) TestCpToCaseH(c *check.C) { func (s *DockerSuite) TestCpToCaseH(c *testing.T) {
containerID := makeTestContainer(c, testContainerOptions{ containerID := makeTestContainer(c, testContainerOptions{
command: makeCatFileCommand("/testDir/file1-1"), command: makeCatFileCommand("/testDir/file1-1"),
}) })
@ -376,7 +376,7 @@ func (s *DockerSuite) TestCpToCaseH(c *check.C) {
// I. SRC specifies a directory's contents only and DST exists as a file. This // I. SRC specifies a directory's contents only and DST exists as a file. This
// should cause an error as it is not possible to overwrite a file with a // should cause an error as it is not possible to overwrite a file with a
// directory. // directory.
func (s *DockerSuite) TestCpToCaseI(c *check.C) { func (s *DockerSuite) TestCpToCaseI(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{ containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root", addContent: true, workDir: "/root",
@ -400,7 +400,7 @@ func (s *DockerSuite) TestCpToCaseI(c *check.C) {
// This should copy the contents of the SRC directory (but not the directory // This should copy the contents of the SRC directory (but not the directory
// itself) into the DST directory. Ensure this works whether DST has a // itself) into the DST directory. Ensure this works whether DST has a
// trailing path separator or not. // trailing path separator or not.
func (s *DockerSuite) TestCpToCaseJ(c *check.C) { func (s *DockerSuite) TestCpToCaseJ(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{ containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root", addContent: true, workDir: "/root",
@ -443,7 +443,7 @@ func (s *DockerSuite) TestCpToCaseJ(c *check.C) {
// The `docker cp` command should also ensure that you cannot // The `docker cp` command should also ensure that you cannot
// write to a container rootfs that is marked as read-only. // write to a container rootfs that is marked as read-only.
func (s *DockerSuite) TestCpToErrReadOnlyRootfs(c *check.C) { func (s *DockerSuite) TestCpToErrReadOnlyRootfs(c *testing.T) {
// --read-only + userns has remount issues // --read-only + userns has remount issues
testRequires(c, DaemonIsLinux, NotUserNamespace) testRequires(c, DaemonIsLinux, NotUserNamespace)
tmpDir := getTestDir(c, "test-cp-to-err-read-only-rootfs") tmpDir := getTestDir(c, "test-cp-to-err-read-only-rootfs")
@ -470,7 +470,7 @@ func (s *DockerSuite) TestCpToErrReadOnlyRootfs(c *check.C) {
// The `docker cp` command should also ensure that you // The `docker cp` command should also ensure that you
// cannot write to a volume that is mounted as read-only. // cannot write to a volume that is mounted as read-only.
func (s *DockerSuite) TestCpToErrReadOnlyVolume(c *check.C) { func (s *DockerSuite) TestCpToErrReadOnlyVolume(c *testing.T) {
// --read-only + userns has remount issues // --read-only + userns has remount issues
testRequires(c, DaemonIsLinux, NotUserNamespace) testRequires(c, DaemonIsLinux, NotUserNamespace)
tmpDir := getTestDir(c, "test-cp-to-err-read-only-volume") tmpDir := getTestDir(c, "test-cp-to-err-read-only-volume")

View file

@ -14,7 +14,7 @@ import (
"gotest.tools/assert" "gotest.tools/assert"
) )
func (s *DockerSuite) TestCpToContainerWithPermissions(c *check.C) { func (s *DockerSuite) TestCpToContainerWithPermissions(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
tmpDir := getTestDir(c, "test-cp-to-host-with-permissions") tmpDir := getTestDir(c, "test-cp-to-host-with-permissions")
@ -38,7 +38,7 @@ func (s *DockerSuite) TestCpToContainerWithPermissions(c *check.C) {
} }
// Check ownership is root, both in non-userns and userns enabled modes // Check ownership is root, both in non-userns and userns enabled modes
func (s *DockerSuite) TestCpCheckDestOwnership(c *check.C) { func (s *DockerSuite) TestCpCheckDestOwnership(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
tmpVolDir := getTestDir(c, "test-cp-tmpvol") tmpVolDir := getTestDir(c, "test-cp-tmpvol")
containerID := makeTestContainer(c, containerID := makeTestContainer(c,

View file

@ -92,7 +92,7 @@ func defaultMkContentCommand() string {
return mkFilesCommand(defaultFileData) return mkFilesCommand(defaultFileData)
} }
func makeTestContentInDir(c *check.C, dir string) { func makeTestContentInDir(c *testing.T, dir string) {
for _, fd := range defaultFileData { for _, fd := range defaultFileData {
path := filepath.Join(dir, filepath.FromSlash(fd.path)) path := filepath.Join(dir, filepath.FromSlash(fd.path))
switch fd.filetype { switch fd.filetype {
@ -118,7 +118,7 @@ type testContainerOptions struct {
command string command string
} }
func makeTestContainer(c *check.C, options testContainerOptions) (containerID string) { func makeTestContainer(c *testing.T, options testContainerOptions) (containerID string) {
if options.addContent { if options.addContent {
mkContentCmd := defaultMkContentCommand() mkContentCmd := defaultMkContentCommand()
if options.command == "" { if options.command == "" {
@ -188,7 +188,7 @@ func containerCpPathTrailingSep(containerID string, pathElements ...string) stri
return fmt.Sprintf("%s/", containerCpPath(containerID, pathElements...)) return fmt.Sprintf("%s/", containerCpPath(containerID, pathElements...))
} }
func runDockerCp(c *check.C, src, dst string, params []string) (err error) { func runDockerCp(c *testing.T, src, dst string, params []string) (err error) {
c.Logf("running `docker cp %s %s %s`", strings.Join(params, " "), src, dst) c.Logf("running `docker cp %s %s %s`", strings.Join(params, " "), src, dst)
args := []string{"cp"} args := []string{"cp"}
@ -205,7 +205,7 @@ func runDockerCp(c *check.C, src, dst string, params []string) (err error) {
return return
} }
func startContainerGetOutput(c *check.C, containerID string) (out string, err error) { func startContainerGetOutput(c *testing.T, containerID string) (out string, err error) {
c.Logf("running `docker start -a %s`", containerID) c.Logf("running `docker start -a %s`", containerID)
args := []string{"start", "-a", containerID} args := []string{"start", "-a", containerID}
@ -218,7 +218,7 @@ func startContainerGetOutput(c *check.C, containerID string) (out string, err er
return return
} }
func getTestDir(c *check.C, label string) (tmpDir string) { func getTestDir(c *testing.T, label string) (tmpDir string) {
var err error var err error
tmpDir, err = ioutil.TempDir("", label) tmpDir, err = ioutil.TempDir("", label)
@ -240,7 +240,7 @@ func isCpCannotCopyReadOnly(err error) bool {
return strings.Contains(err.Error(), "marked read-only") return strings.Contains(err.Error(), "marked read-only")
} }
func fileContentEquals(c *check.C, filename, contents string) (err error) { func fileContentEquals(c *testing.T, filename, contents string) (err error) {
c.Logf("checking that file %q contains %q\n", filename, contents) c.Logf("checking that file %q contains %q\n", filename, contents)
fileBytes, err := ioutil.ReadFile(filename) fileBytes, err := ioutil.ReadFile(filename)
@ -260,7 +260,7 @@ func fileContentEquals(c *check.C, filename, contents string) (err error) {
return return
} }
func symlinkTargetEquals(c *check.C, symlink, expectedTarget string) (err error) { func symlinkTargetEquals(c *testing.T, symlink, expectedTarget string) (err error) {
c.Logf("checking that the symlink %q points to %q\n", symlink, expectedTarget) c.Logf("checking that the symlink %q points to %q\n", symlink, expectedTarget)
actualTarget, err := os.Readlink(symlink) actualTarget, err := os.Readlink(symlink)
@ -275,7 +275,7 @@ func symlinkTargetEquals(c *check.C, symlink, expectedTarget string) (err error)
return return
} }
func containerStartOutputEquals(c *check.C, containerID, contents string) (err error) { func containerStartOutputEquals(c *testing.T, containerID, contents string) (err error) {
c.Logf("checking that container %q start output contains %q\n", containerID, contents) c.Logf("checking that container %q start output contains %q\n", containerID, contents)
out, err := startContainerGetOutput(c, containerID) out, err := startContainerGetOutput(c, containerID)

View file

@ -20,7 +20,7 @@ import (
) )
// Make sure we can create a simple container with some args // Make sure we can create a simple container with some args
func (s *DockerSuite) TestCreateArgs(c *check.C) { func (s *DockerSuite) TestCreateArgs(c *testing.T) {
// Intentionally clear entrypoint, as the Windows busybox image needs an entrypoint, which breaks this test // Intentionally clear entrypoint, as the Windows busybox image needs an entrypoint, which breaks this test
out, _ := dockerCmd(c, "create", "--entrypoint=", "busybox", "command", "arg1", "arg2", "arg with space", "-c", "flags") out, _ := dockerCmd(c, "create", "--entrypoint=", "busybox", "command", "arg1", "arg2", "arg with space", "-c", "flags")
@ -58,7 +58,7 @@ func (s *DockerSuite) TestCreateArgs(c *check.C) {
} }
// Make sure we can grow the container's rootfs at creation time. // Make sure we can grow the container's rootfs at creation time.
func (s *DockerSuite) TestCreateGrowRootfs(c *check.C) { func (s *DockerSuite) TestCreateGrowRootfs(c *testing.T) {
// Windows and Devicemapper support growing the rootfs // Windows and Devicemapper support growing the rootfs
if testEnv.OSType != "windows" { if testEnv.OSType != "windows" {
testRequires(c, Devicemapper) testRequires(c, Devicemapper)
@ -72,7 +72,7 @@ func (s *DockerSuite) TestCreateGrowRootfs(c *check.C) {
} }
// Make sure we cannot shrink the container's rootfs at creation time. // Make sure we cannot shrink the container's rootfs at creation time.
func (s *DockerSuite) TestCreateShrinkRootfs(c *check.C) { func (s *DockerSuite) TestCreateShrinkRootfs(c *testing.T) {
testRequires(c, Devicemapper) testRequires(c, Devicemapper)
// Ensure this fails because of the defaultBaseFsSize is 10G // Ensure this fails because of the defaultBaseFsSize is 10G
@ -82,7 +82,7 @@ func (s *DockerSuite) TestCreateShrinkRootfs(c *check.C) {
} }
// Make sure we can set hostconfig options too // Make sure we can set hostconfig options too
func (s *DockerSuite) TestCreateHostConfig(c *check.C) { func (s *DockerSuite) TestCreateHostConfig(c *testing.T) {
out, _ := dockerCmd(c, "create", "-P", "busybox", "echo") out, _ := dockerCmd(c, "create", "-P", "busybox", "echo")
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
@ -104,7 +104,7 @@ func (s *DockerSuite) TestCreateHostConfig(c *check.C) {
assert.Assert(c, cont.HostConfig.PublishAllPorts, checker.True, check.Commentf("Expected PublishAllPorts, got false")) assert.Assert(c, cont.HostConfig.PublishAllPorts, checker.True, check.Commentf("Expected PublishAllPorts, got false"))
} }
func (s *DockerSuite) TestCreateWithPortRange(c *check.C) { func (s *DockerSuite) TestCreateWithPortRange(c *testing.T) {
out, _ := dockerCmd(c, "create", "-p", "3300-3303:3300-3303/tcp", "busybox", "echo") out, _ := dockerCmd(c, "create", "-p", "3300-3303:3300-3303/tcp", "busybox", "echo")
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
@ -133,7 +133,7 @@ func (s *DockerSuite) TestCreateWithPortRange(c *check.C) {
} }
func (s *DockerSuite) TestCreateWithLargePortRange(c *check.C) { func (s *DockerSuite) TestCreateWithLargePortRange(c *testing.T) {
out, _ := dockerCmd(c, "create", "-p", "1-65535:1-65535/tcp", "busybox", "echo") out, _ := dockerCmd(c, "create", "-p", "1-65535:1-65535/tcp", "busybox", "echo")
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
@ -162,7 +162,7 @@ func (s *DockerSuite) TestCreateWithLargePortRange(c *check.C) {
} }
// "test123" should be printed by docker create + start // "test123" should be printed by docker create + start
func (s *DockerSuite) TestCreateEchoStdout(c *check.C) { func (s *DockerSuite) TestCreateEchoStdout(c *testing.T) {
out, _ := dockerCmd(c, "create", "busybox", "echo", "test123") out, _ := dockerCmd(c, "create", "busybox", "echo", "test123")
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
@ -171,7 +171,7 @@ func (s *DockerSuite) TestCreateEchoStdout(c *check.C) {
assert.Equal(c, out, "test123\n", "container should've printed 'test123', got %q", out) assert.Equal(c, out, "test123\n", "container should've printed 'test123', got %q", out)
} }
func (s *DockerSuite) TestCreateVolumesCreated(c *check.C) { func (s *DockerSuite) TestCreateVolumesCreated(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
prefix, slash := getPrefixAndSlashFromDaemonPlatform() prefix, slash := getPrefixAndSlashFromDaemonPlatform()
@ -190,7 +190,7 @@ func (s *DockerSuite) TestCreateVolumesCreated(c *check.C) {
} }
func (s *DockerSuite) TestCreateLabels(c *check.C) { func (s *DockerSuite) TestCreateLabels(c *testing.T) {
name := "test_create_labels" name := "test_create_labels"
expected := map[string]string{"k1": "v1", "k2": "v2"} expected := map[string]string{"k1": "v1", "k2": "v2"}
dockerCmd(c, "create", "--name", name, "-l", "k1=v1", "--label", "k2=v2", "busybox") dockerCmd(c, "create", "--name", name, "-l", "k1=v1", "--label", "k2=v2", "busybox")
@ -203,7 +203,7 @@ func (s *DockerSuite) TestCreateLabels(c *check.C) {
} }
} }
func (s *DockerSuite) TestCreateLabelFromImage(c *check.C) { func (s *DockerSuite) TestCreateLabelFromImage(c *testing.T) {
imageName := "testcreatebuildlabel" imageName := "testcreatebuildlabel"
buildImageSuccessfully(c, imageName, build.WithDockerfile(`FROM busybox buildImageSuccessfully(c, imageName, build.WithDockerfile(`FROM busybox
LABEL k1=v1 k2=v2`)) LABEL k1=v1 k2=v2`))
@ -220,7 +220,7 @@ func (s *DockerSuite) TestCreateLabelFromImage(c *check.C) {
} }
} }
func (s *DockerSuite) TestCreateHostnameWithNumber(c *check.C) { func (s *DockerSuite) TestCreateHostnameWithNumber(c *testing.T) {
image := "busybox" image := "busybox"
// Busybox on Windows does not implement hostname command // Busybox on Windows does not implement hostname command
if testEnv.OSType == "windows" { if testEnv.OSType == "windows" {
@ -230,7 +230,7 @@ func (s *DockerSuite) TestCreateHostnameWithNumber(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "web.0", "hostname not set, expected `web.0`, got: %s", out) assert.Equal(c, strings.TrimSpace(out), "web.0", "hostname not set, expected `web.0`, got: %s", out)
} }
func (s *DockerSuite) TestCreateRM(c *check.C) { func (s *DockerSuite) TestCreateRM(c *testing.T) {
// Test to make sure we can 'rm' a new container that is in // Test to make sure we can 'rm' a new container that is in
// "Created" state, and has ever been run. Test "rm -f" too. // "Created" state, and has ever been run. Test "rm -f" too.
@ -247,7 +247,7 @@ func (s *DockerSuite) TestCreateRM(c *check.C) {
dockerCmd(c, "rm", "-f", cID) dockerCmd(c, "rm", "-f", cID)
} }
func (s *DockerSuite) TestCreateModeIpcContainer(c *check.C) { func (s *DockerSuite) TestCreateModeIpcContainer(c *testing.T) {
// Uses Linux specific functionality (--ipc) // Uses Linux specific functionality (--ipc)
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
@ -257,7 +257,7 @@ func (s *DockerSuite) TestCreateModeIpcContainer(c *check.C) {
dockerCmd(c, "create", fmt.Sprintf("--ipc=container:%s", id), "busybox") dockerCmd(c, "create", fmt.Sprintf("--ipc=container:%s", id), "busybox")
} }
func (s *DockerSuite) TestCreateByImageID(c *check.C) { func (s *DockerSuite) TestCreateByImageID(c *testing.T) {
imageName := "testcreatebyimageid" imageName := "testcreatebyimageid"
buildImageSuccessfully(c, imageName, build.WithDockerfile(`FROM busybox buildImageSuccessfully(c, imageName, build.WithDockerfile(`FROM busybox
MAINTAINER dockerio`)) MAINTAINER dockerio`))
@ -290,7 +290,7 @@ func (s *DockerSuite) TestCreateByImageID(c *check.C) {
} }
} }
func (s *DockerSuite) TestCreateStopSignal(c *check.C) { func (s *DockerSuite) TestCreateStopSignal(c *testing.T) {
name := "test_create_stop_signal" name := "test_create_stop_signal"
dockerCmd(c, "create", "--name", name, "--stop-signal", "9", "busybox") dockerCmd(c, "create", "--name", name, "--stop-signal", "9", "busybox")
@ -299,7 +299,7 @@ func (s *DockerSuite) TestCreateStopSignal(c *check.C) {
} }
func (s *DockerSuite) TestCreateWithWorkdir(c *check.C) { func (s *DockerSuite) TestCreateWithWorkdir(c *testing.T) {
name := "foo" name := "foo"
prefix, slash := getPrefixAndSlashFromDaemonPlatform() prefix, slash := getPrefixAndSlashFromDaemonPlatform()
@ -313,7 +313,7 @@ func (s *DockerSuite) TestCreateWithWorkdir(c *check.C) {
dockerCmd(c, "cp", fmt.Sprintf("%s:%s", name, dir), prefix+slash+"tmp") dockerCmd(c, "cp", fmt.Sprintf("%s:%s", name, dir), prefix+slash+"tmp")
} }
func (s *DockerSuite) TestCreateWithInvalidLogOpts(c *check.C) { func (s *DockerSuite) TestCreateWithInvalidLogOpts(c *testing.T) {
name := "test-invalidate-log-opts" name := "test-invalidate-log-opts"
out, _, err := dockerCmdWithError("create", "--name", name, "--log-opt", "invalid=true", "busybox") out, _, err := dockerCmdWithError("create", "--name", name, "--log-opt", "invalid=true", "busybox")
assert.ErrorContains(c, err, "") assert.ErrorContains(c, err, "")
@ -325,7 +325,7 @@ func (s *DockerSuite) TestCreateWithInvalidLogOpts(c *check.C) {
} }
// #20972 // #20972
func (s *DockerSuite) TestCreate64ByteHexID(c *check.C) { func (s *DockerSuite) TestCreate64ByteHexID(c *testing.T) {
out := inspectField(c, "busybox", "Id") out := inspectField(c, "busybox", "Id")
imageID := strings.TrimPrefix(strings.TrimSpace(string(out)), "sha256:") imageID := strings.TrimPrefix(strings.TrimSpace(string(out)), "sha256:")
@ -333,7 +333,7 @@ func (s *DockerSuite) TestCreate64ByteHexID(c *check.C) {
} }
// Test case for #23498 // Test case for #23498
func (s *DockerSuite) TestCreateUnsetEntrypoint(c *check.C) { func (s *DockerSuite) TestCreateUnsetEntrypoint(c *testing.T) {
name := "test-entrypoint" name := "test-entrypoint"
dockerfile := `FROM busybox dockerfile := `FROM busybox
ADD entrypoint.sh /entrypoint.sh ADD entrypoint.sh /entrypoint.sh
@ -360,7 +360,7 @@ exec "$@"`,
} }
// #22471 // #22471
func (s *DockerSuite) TestCreateStopTimeout(c *check.C) { func (s *DockerSuite) TestCreateStopTimeout(c *testing.T) {
name1 := "test_create_stop_timeout_1" name1 := "test_create_stop_timeout_1"
dockerCmd(c, "create", "--name", name1, "--stop-timeout", "15", "busybox") dockerCmd(c, "create", "--name", name1, "--stop-timeout", "15", "busybox")

View file

@ -13,7 +13,7 @@ import (
) )
// TestDaemonRestartWithPluginEnabled tests state restore for an enabled plugin // TestDaemonRestartWithPluginEnabled tests state restore for an enabled plugin
func (s *DockerDaemonSuite) TestDaemonRestartWithPluginEnabled(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartWithPluginEnabled(c *testing.T) {
testRequires(c, IsAmd64, Network) testRequires(c, IsAmd64, Network)
s.d.Start(c) s.d.Start(c)
@ -42,7 +42,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithPluginEnabled(c *check.C) {
} }
// TestDaemonRestartWithPluginDisabled tests state restore for a disabled plugin // TestDaemonRestartWithPluginDisabled tests state restore for a disabled plugin
func (s *DockerDaemonSuite) TestDaemonRestartWithPluginDisabled(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartWithPluginDisabled(c *testing.T) {
testRequires(c, IsAmd64, Network) testRequires(c, IsAmd64, Network)
s.d.Start(c) s.d.Start(c)
@ -69,7 +69,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithPluginDisabled(c *check.C) {
// TestDaemonKillLiveRestoreWithPlugins SIGKILLs daemon started with --live-restore. // TestDaemonKillLiveRestoreWithPlugins SIGKILLs daemon started with --live-restore.
// Plugins should continue to run. // Plugins should continue to run.
func (s *DockerDaemonSuite) TestDaemonKillLiveRestoreWithPlugins(c *check.C) { func (s *DockerDaemonSuite) TestDaemonKillLiveRestoreWithPlugins(c *testing.T) {
testRequires(c, IsAmd64, Network) testRequires(c, IsAmd64, Network)
s.d.Start(c, "--live-restore") s.d.Start(c, "--live-restore")
@ -95,7 +95,7 @@ func (s *DockerDaemonSuite) TestDaemonKillLiveRestoreWithPlugins(c *check.C) {
// TestDaemonShutdownLiveRestoreWithPlugins SIGTERMs daemon started with --live-restore. // TestDaemonShutdownLiveRestoreWithPlugins SIGTERMs daemon started with --live-restore.
// Plugins should continue to run. // Plugins should continue to run.
func (s *DockerDaemonSuite) TestDaemonShutdownLiveRestoreWithPlugins(c *check.C) { func (s *DockerDaemonSuite) TestDaemonShutdownLiveRestoreWithPlugins(c *testing.T) {
testRequires(c, IsAmd64, Network) testRequires(c, IsAmd64, Network)
s.d.Start(c, "--live-restore") s.d.Start(c, "--live-restore")
@ -120,7 +120,7 @@ func (s *DockerDaemonSuite) TestDaemonShutdownLiveRestoreWithPlugins(c *check.C)
} }
// TestDaemonShutdownWithPlugins shuts down running plugins. // TestDaemonShutdownWithPlugins shuts down running plugins.
func (s *DockerDaemonSuite) TestDaemonShutdownWithPlugins(c *check.C) { func (s *DockerDaemonSuite) TestDaemonShutdownWithPlugins(c *testing.T) {
testRequires(c, IsAmd64, Network) testRequires(c, IsAmd64, Network)
s.d.Start(c) s.d.Start(c)
@ -158,7 +158,7 @@ func (s *DockerDaemonSuite) TestDaemonShutdownWithPlugins(c *check.C) {
} }
// TestDaemonKillWithPlugins leaves plugins running. // TestDaemonKillWithPlugins leaves plugins running.
func (s *DockerDaemonSuite) TestDaemonKillWithPlugins(c *check.C) { func (s *DockerDaemonSuite) TestDaemonKillWithPlugins(c *testing.T) {
testRequires(c, IsAmd64, Network) testRequires(c, IsAmd64, Network)
s.d.Start(c) s.d.Start(c)
@ -185,7 +185,7 @@ func (s *DockerDaemonSuite) TestDaemonKillWithPlugins(c *check.C) {
} }
// TestVolumePlugin tests volume creation using a plugin. // TestVolumePlugin tests volume creation using a plugin.
func (s *DockerDaemonSuite) TestVolumePlugin(c *check.C) { func (s *DockerDaemonSuite) TestVolumePlugin(c *testing.T) {
testRequires(c, IsAmd64, Network) testRequires(c, IsAmd64, Network)
volName := "plugin-volume" volName := "plugin-volume"
@ -231,7 +231,7 @@ func (s *DockerDaemonSuite) TestVolumePlugin(c *check.C) {
assert.NilError(c, err, out) assert.NilError(c, err, out)
} }
func (s *DockerDaemonSuite) TestPluginVolumeRemoveOnRestart(c *check.C) { func (s *DockerDaemonSuite) TestPluginVolumeRemoveOnRestart(c *testing.T) {
testRequires(c, IsAmd64, Network) testRequires(c, IsAmd64, Network)
s.d.Start(c, "--live-restore=true") s.d.Start(c, "--live-restore=true")
@ -272,7 +272,7 @@ func existsMountpointWithPrefix(mountpointPrefix string) (bool, error) {
return false, nil return false, nil
} }
func (s *DockerDaemonSuite) TestPluginListFilterEnabled(c *check.C) { func (s *DockerDaemonSuite) TestPluginListFilterEnabled(c *testing.T) {
testRequires(c, IsAmd64, Network) testRequires(c, IsAmd64, Network)
s.d.Start(c) s.d.Start(c)
@ -300,7 +300,7 @@ func (s *DockerDaemonSuite) TestPluginListFilterEnabled(c *check.C) {
assert.Assert(c, strings.Contains(out, pName)) assert.Assert(c, strings.Contains(out, pName))
} }
func (s *DockerDaemonSuite) TestPluginListFilterCapability(c *check.C) { func (s *DockerDaemonSuite) TestPluginListFilterCapability(c *testing.T) {
testRequires(c, IsAmd64, Network) testRequires(c, IsAmd64, Network)
s.d.Start(c) s.d.Start(c)

View file

@ -46,7 +46,7 @@ const containerdSocket = "/var/run/docker/containerd/containerd.sock"
// TestLegacyDaemonCommand test starting docker daemon using "deprecated" docker daemon // TestLegacyDaemonCommand test starting docker daemon using "deprecated" docker daemon
// command. Remove this test when we remove this. // command. Remove this test when we remove this.
func (s *DockerDaemonSuite) TestLegacyDaemonCommand(c *check.C) { func (s *DockerDaemonSuite) TestLegacyDaemonCommand(c *testing.T) {
cmd := exec.Command(dockerBinary, "daemon", "--storage-driver=vfs", "--debug") cmd := exec.Command(dockerBinary, "daemon", "--storage-driver=vfs", "--debug")
err := cmd.Start() err := cmd.Start()
go cmd.Wait() go cmd.Wait()
@ -54,7 +54,7 @@ func (s *DockerDaemonSuite) TestLegacyDaemonCommand(c *check.C) {
assert.NilError(c, cmd.Process.Kill()) assert.NilError(c, cmd.Process.Kill())
} }
func (s *DockerDaemonSuite) TestDaemonRestartWithRunningContainersPorts(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartWithRunningContainersPorts(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
cli.Docker( cli.Docker(
@ -88,7 +88,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithRunningContainersPorts(c *check
testRun(map[string]bool{"top1": true, "top2": false}, "After daemon restart: ") testRun(map[string]bool{"top1": true, "top2": false}, "After daemon restart: ")
} }
func (s *DockerDaemonSuite) TestDaemonRestartWithVolumesRefs(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartWithVolumesRefs(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
if out, err := s.d.Cmd("run", "--name", "volrestarttest1", "-v", "/foo", "busybox"); err != nil { if out, err := s.d.Cmd("run", "--name", "volrestarttest1", "-v", "/foo", "busybox"); err != nil {
@ -114,7 +114,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithVolumesRefs(c *check.C) {
} }
// #11008 // #11008
func (s *DockerDaemonSuite) TestDaemonRestartUnlessStopped(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartUnlessStopped(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "-d", "--name", "top1", "--restart", "always", "busybox:latest", "top") out, err := s.d.Cmd("run", "-d", "--name", "top1", "--restart", "always", "busybox:latest", "top")
@ -173,7 +173,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartUnlessStopped(c *check.C) {
} }
func (s *DockerDaemonSuite) TestDaemonRestartOnFailure(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartOnFailure(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "-d", "--name", "test1", "--restart", "on-failure:3", "busybox:latest", "false") out, err := s.d.Cmd("run", "-d", "--name", "test1", "--restart", "on-failure:3", "busybox:latest", "false")
@ -202,12 +202,12 @@ func (s *DockerDaemonSuite) TestDaemonRestartOnFailure(c *check.C) {
assert.Equal(c, out, lastStartTime, "test1 shouldn't start after daemon restarts") assert.Equal(c, out, lastStartTime, "test1 shouldn't start after daemon restarts")
} }
func (s *DockerDaemonSuite) TestDaemonStartIptablesFalse(c *check.C) { func (s *DockerDaemonSuite) TestDaemonStartIptablesFalse(c *testing.T) {
s.d.Start(c, "--iptables=false") s.d.Start(c, "--iptables=false")
} }
// Make sure we cannot shrink base device at daemon restart. // Make sure we cannot shrink base device at daemon restart.
func (s *DockerDaemonSuite) TestDaemonRestartWithInvalidBasesize(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartWithInvalidBasesize(c *testing.T) {
testRequires(c, Devicemapper) testRequires(c, Devicemapper)
s.d.Start(c) s.d.Start(c)
@ -227,7 +227,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithInvalidBasesize(c *check.C) {
} }
// Make sure we can grow base device at daemon restart. // Make sure we can grow base device at daemon restart.
func (s *DockerDaemonSuite) TestDaemonRestartWithIncreasedBasesize(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartWithIncreasedBasesize(c *testing.T) {
testRequires(c, Devicemapper) testRequires(c, Devicemapper)
s.d.Start(c) s.d.Start(c)
@ -249,7 +249,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithIncreasedBasesize(c *check.C) {
s.d.Stop(c) s.d.Stop(c)
} }
func getBaseDeviceSize(c *check.C, d *daemon.Daemon) int64 { func getBaseDeviceSize(c *testing.T, d *daemon.Daemon) int64 {
info := d.Info(c) info := d.Info(c)
for _, statusLine := range info.DriverStatus { for _, statusLine := range info.DriverStatus {
key, value := statusLine[0], statusLine[1] key, value := statusLine[0], statusLine[1]
@ -261,7 +261,7 @@ func getBaseDeviceSize(c *check.C, d *daemon.Daemon) int64 {
return int64(0) return int64(0)
} }
func parseDeviceSize(c *check.C, raw string) int64 { func parseDeviceSize(c *testing.T, raw string) int64 {
size, err := units.RAMInBytes(strings.TrimSpace(raw)) size, err := units.RAMInBytes(strings.TrimSpace(raw))
assert.NilError(c, err) assert.NilError(c, err)
return size return size
@ -280,7 +280,7 @@ func convertBasesize(basesizeBytes int64) (int64, error) {
// Issue #8444: If docker0 bridge is modified (intentionally or unintentionally) and // Issue #8444: If docker0 bridge is modified (intentionally or unintentionally) and
// no longer has an IP associated, we should gracefully handle that case and associate // no longer has an IP associated, we should gracefully handle that case and associate
// an IP with it rather than fail daemon start // an IP with it rather than fail daemon start
func (s *DockerDaemonSuite) TestDaemonStartBridgeWithoutIPAssociation(c *check.C) { func (s *DockerDaemonSuite) TestDaemonStartBridgeWithoutIPAssociation(c *testing.T) {
// rather than depending on brctl commands to verify docker0 is created and up // rather than depending on brctl commands to verify docker0 is created and up
// let's start the daemon and stop it, and then make a modification to run the // let's start the daemon and stop it, and then make a modification to run the
// actual test // actual test
@ -296,7 +296,7 @@ func (s *DockerDaemonSuite) TestDaemonStartBridgeWithoutIPAssociation(c *check.C
} }
} }
func (s *DockerDaemonSuite) TestDaemonIptablesClean(c *check.C) { func (s *DockerDaemonSuite) TestDaemonIptablesClean(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
if out, err := s.d.Cmd("run", "-d", "--name", "top", "-p", "80", "busybox:latest", "top"); err != nil { if out, err := s.d.Cmd("run", "-d", "--name", "top", "-p", "80", "busybox:latest", "top"); err != nil {
@ -314,7 +314,7 @@ func (s *DockerDaemonSuite) TestDaemonIptablesClean(c *check.C) {
verifyIPTablesDoesNotContains(c, ipTablesSearchString) verifyIPTablesDoesNotContains(c, ipTablesSearchString)
} }
func (s *DockerDaemonSuite) TestDaemonIptablesCreate(c *check.C) { func (s *DockerDaemonSuite) TestDaemonIptablesCreate(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
if out, err := s.d.Cmd("run", "-d", "--name", "top", "--restart=always", "-p", "80", "busybox:latest", "top"); err != nil { if out, err := s.d.Cmd("run", "-d", "--name", "top", "--restart=always", "-p", "80", "busybox:latest", "top"); err != nil {
@ -340,7 +340,7 @@ func (s *DockerDaemonSuite) TestDaemonIptablesCreate(c *check.C) {
verifyIPTablesContains(c, ipTablesSearchString) verifyIPTablesContains(c, ipTablesSearchString)
} }
func verifyIPTablesContains(c *check.C, ipTablesSearchString string) { func verifyIPTablesContains(c *testing.T, ipTablesSearchString string) {
result := icmd.RunCommand("iptables", "-nvL") result := icmd.RunCommand("iptables", "-nvL")
result.Assert(c, icmd.Success) result.Assert(c, icmd.Success)
if !strings.Contains(result.Combined(), ipTablesSearchString) { if !strings.Contains(result.Combined(), ipTablesSearchString) {
@ -348,7 +348,7 @@ func verifyIPTablesContains(c *check.C, ipTablesSearchString string) {
} }
} }
func verifyIPTablesDoesNotContains(c *check.C, ipTablesSearchString string) { func verifyIPTablesDoesNotContains(c *testing.T, ipTablesSearchString string) {
result := icmd.RunCommand("iptables", "-nvL") result := icmd.RunCommand("iptables", "-nvL")
result.Assert(c, icmd.Success) result.Assert(c, icmd.Success)
if strings.Contains(result.Combined(), ipTablesSearchString) { if strings.Contains(result.Combined(), ipTablesSearchString) {
@ -358,7 +358,7 @@ func verifyIPTablesDoesNotContains(c *check.C, ipTablesSearchString string) {
// TestDaemonIPv6Enabled checks that when the daemon is started with --ipv6=true that the docker0 bridge // TestDaemonIPv6Enabled checks that when the daemon is started with --ipv6=true that the docker0 bridge
// has the fe80::1 address and that a container is assigned a link-local address // has the fe80::1 address and that a container is assigned a link-local address
func (s *DockerDaemonSuite) TestDaemonIPv6Enabled(c *check.C) { func (s *DockerDaemonSuite) TestDaemonIPv6Enabled(c *testing.T) {
testRequires(c, IPv6) testRequires(c, IPv6)
setupV6(c) setupV6(c)
@ -417,7 +417,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6Enabled(c *check.C) {
// TestDaemonIPv6FixedCIDR checks that when the daemon is started with --ipv6=true and a fixed CIDR // TestDaemonIPv6FixedCIDR checks that when the daemon is started with --ipv6=true and a fixed CIDR
// that running containers are given a link-local and global IPv6 address // that running containers are given a link-local and global IPv6 address
func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDR(c *check.C) { func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDR(c *testing.T) {
// IPv6 setup is messing with local bridge address. // IPv6 setup is messing with local bridge address.
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
// Delete the docker0 bridge if its left around from previous daemon. It has to be recreated with // Delete the docker0 bridge if its left around from previous daemon. It has to be recreated with
@ -444,7 +444,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDR(c *check.C) {
// TestDaemonIPv6FixedCIDRAndMac checks that when the daemon is started with ipv6 fixed CIDR // TestDaemonIPv6FixedCIDRAndMac checks that when the daemon is started with ipv6 fixed CIDR
// the running containers are given an IPv6 address derived from the MAC address and the ipv6 fixed CIDR // the running containers are given an IPv6 address derived from the MAC address and the ipv6 fixed CIDR
func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDRAndMac(c *check.C) { func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDRAndMac(c *testing.T) {
// IPv6 setup is messing with local bridge address. // IPv6 setup is messing with local bridge address.
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
// Delete the docker0 bridge if its left around from previous daemon. It has to be recreated with // Delete the docker0 bridge if its left around from previous daemon. It has to be recreated with
@ -463,7 +463,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDRAndMac(c *check.C) {
// TestDaemonIPv6HostMode checks that when the running a container with // TestDaemonIPv6HostMode checks that when the running a container with
// network=host the host ipv6 addresses are not removed // network=host the host ipv6 addresses are not removed
func (s *DockerDaemonSuite) TestDaemonIPv6HostMode(c *check.C) { func (s *DockerDaemonSuite) TestDaemonIPv6HostMode(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
deleteInterface(c, "docker0") deleteInterface(c, "docker0")
@ -476,11 +476,11 @@ func (s *DockerDaemonSuite) TestDaemonIPv6HostMode(c *check.C) {
assert.Assert(c, strings.Trim(out, " \r\n'"), checker.Contains, "2001:db8:2::1") assert.Assert(c, strings.Trim(out, " \r\n'"), checker.Contains, "2001:db8:2::1")
} }
func (s *DockerDaemonSuite) TestDaemonLogLevelWrong(c *check.C) { func (s *DockerDaemonSuite) TestDaemonLogLevelWrong(c *testing.T) {
assert.Assert(c, s.d.StartWithError("--log-level=bogus"), check.NotNil, check.Commentf("Daemon shouldn't start with wrong log level")) assert.Assert(c, s.d.StartWithError("--log-level=bogus"), check.NotNil, check.Commentf("Daemon shouldn't start with wrong log level"))
} }
func (s *DockerDaemonSuite) TestDaemonLogLevelDebug(c *check.C) { func (s *DockerDaemonSuite) TestDaemonLogLevelDebug(c *testing.T) {
s.d.Start(c, "--log-level=debug") s.d.Start(c, "--log-level=debug")
content, err := s.d.ReadLogFile() content, err := s.d.ReadLogFile()
assert.NilError(c, err) assert.NilError(c, err)
@ -489,7 +489,7 @@ func (s *DockerDaemonSuite) TestDaemonLogLevelDebug(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonLogLevelFatal(c *check.C) { func (s *DockerDaemonSuite) TestDaemonLogLevelFatal(c *testing.T) {
// we creating new daemons to create new logFile // we creating new daemons to create new logFile
s.d.Start(c, "--log-level=fatal") s.d.Start(c, "--log-level=fatal")
content, err := s.d.ReadLogFile() content, err := s.d.ReadLogFile()
@ -499,7 +499,7 @@ func (s *DockerDaemonSuite) TestDaemonLogLevelFatal(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonFlagD(c *check.C) { func (s *DockerDaemonSuite) TestDaemonFlagD(c *testing.T) {
s.d.Start(c, "-D") s.d.Start(c, "-D")
content, err := s.d.ReadLogFile() content, err := s.d.ReadLogFile()
assert.NilError(c, err) assert.NilError(c, err)
@ -508,7 +508,7 @@ func (s *DockerDaemonSuite) TestDaemonFlagD(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonFlagDebug(c *check.C) { func (s *DockerDaemonSuite) TestDaemonFlagDebug(c *testing.T) {
s.d.Start(c, "--debug") s.d.Start(c, "--debug")
content, err := s.d.ReadLogFile() content, err := s.d.ReadLogFile()
assert.NilError(c, err) assert.NilError(c, err)
@ -517,7 +517,7 @@ func (s *DockerDaemonSuite) TestDaemonFlagDebug(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonFlagDebugLogLevelFatal(c *check.C) { func (s *DockerDaemonSuite) TestDaemonFlagDebugLogLevelFatal(c *testing.T) {
s.d.Start(c, "--debug", "--log-level=fatal") s.d.Start(c, "--debug", "--log-level=fatal")
content, err := s.d.ReadLogFile() content, err := s.d.ReadLogFile()
assert.NilError(c, err) assert.NilError(c, err)
@ -526,7 +526,7 @@ func (s *DockerDaemonSuite) TestDaemonFlagDebugLogLevelFatal(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonAllocatesListeningPort(c *check.C) { func (s *DockerDaemonSuite) TestDaemonAllocatesListeningPort(c *testing.T) {
listeningPorts := [][]string{ listeningPorts := [][]string{
{"0.0.0.0", "0.0.0.0", "5678"}, {"0.0.0.0", "0.0.0.0", "5678"},
{"127.0.0.1", "127.0.0.1", "1234"}, {"127.0.0.1", "127.0.0.1", "1234"},
@ -550,7 +550,7 @@ func (s *DockerDaemonSuite) TestDaemonAllocatesListeningPort(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonKeyGeneration(c *check.C) { func (s *DockerDaemonSuite) TestDaemonKeyGeneration(c *testing.T) {
// TODO: skip or update for Windows daemon // TODO: skip or update for Windows daemon
os.Remove("/etc/docker/key.json") os.Remove("/etc/docker/key.json")
s.d.Start(c) s.d.Start(c)
@ -570,7 +570,7 @@ func (s *DockerDaemonSuite) TestDaemonKeyGeneration(c *check.C) {
// GH#11320 - verify that the daemon exits on failure properly // GH#11320 - verify that the daemon exits on failure properly
// Note that this explicitly tests the conflict of {-b,--bridge} and {--bip} options as the means // Note that this explicitly tests the conflict of {-b,--bridge} and {--bip} options as the means
// to get a daemon init failure; no other tests for -b/--bip conflict are therefore required // to get a daemon init failure; no other tests for -b/--bip conflict are therefore required
func (s *DockerDaemonSuite) TestDaemonExitOnFailure(c *check.C) { func (s *DockerDaemonSuite) TestDaemonExitOnFailure(c *testing.T) {
//attempt to start daemon with incorrect flags (we know -b and --bip conflict) //attempt to start daemon with incorrect flags (we know -b and --bip conflict)
if err := s.d.StartWithError("--bridge", "nosuchbridge", "--bip", "1.1.1.1"); err != nil { if err := s.d.StartWithError("--bridge", "nosuchbridge", "--bip", "1.1.1.1"); err != nil {
//verify we got the right error //verify we got the right error
@ -585,7 +585,7 @@ func (s *DockerDaemonSuite) TestDaemonExitOnFailure(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonBridgeExternal(c *check.C) { func (s *DockerDaemonSuite) TestDaemonBridgeExternal(c *testing.T) {
d := s.d d := s.d
err := d.StartWithError("--bridge", "nosuchbridge") err := d.StartWithError("--bridge", "nosuchbridge")
assert.ErrorContains(c, err, "", `--bridge option with an invalid bridge should cause the daemon to fail`) assert.ErrorContains(c, err, "", `--bridge option with an invalid bridge should cause the daemon to fail`)
@ -613,7 +613,7 @@ func (s *DockerDaemonSuite) TestDaemonBridgeExternal(c *check.C) {
assert.Assert(c, bridgeIPNet.Contains(ip), "Container IP-Address must be in the same subnet range : %s", containerIP) assert.Assert(c, bridgeIPNet.Contains(ip), "Container IP-Address must be in the same subnet range : %s", containerIP)
} }
func (s *DockerDaemonSuite) TestDaemonBridgeNone(c *check.C) { func (s *DockerDaemonSuite) TestDaemonBridgeNone(c *testing.T) {
// start with bridge none // start with bridge none
d := s.d d := s.d
d.StartWithBusybox(c, "--bridge", "none") d.StartWithBusybox(c, "--bridge", "none")
@ -632,18 +632,18 @@ func (s *DockerDaemonSuite) TestDaemonBridgeNone(c *check.C) {
assert.Assert(c, strings.Contains(out, "No such network")) assert.Assert(c, strings.Contains(out, "No such network"))
} }
func createInterface(c *check.C, ifType string, ifName string, ipNet string) { func createInterface(c *testing.T, ifType string, ifName string, ipNet string) {
icmd.RunCommand("ip", "link", "add", "name", ifName, "type", ifType).Assert(c, icmd.Success) icmd.RunCommand("ip", "link", "add", "name", ifName, "type", ifType).Assert(c, icmd.Success)
icmd.RunCommand("ifconfig", ifName, ipNet, "up").Assert(c, icmd.Success) icmd.RunCommand("ifconfig", ifName, ipNet, "up").Assert(c, icmd.Success)
} }
func deleteInterface(c *check.C, ifName string) { func deleteInterface(c *testing.T, ifName string) {
icmd.RunCommand("ip", "link", "delete", ifName).Assert(c, icmd.Success) icmd.RunCommand("ip", "link", "delete", ifName).Assert(c, icmd.Success)
icmd.RunCommand("iptables", "-t", "nat", "--flush").Assert(c, icmd.Success) icmd.RunCommand("iptables", "-t", "nat", "--flush").Assert(c, icmd.Success)
icmd.RunCommand("iptables", "--flush").Assert(c, icmd.Success) icmd.RunCommand("iptables", "--flush").Assert(c, icmd.Success)
} }
func (s *DockerDaemonSuite) TestDaemonBridgeIP(c *check.C) { func (s *DockerDaemonSuite) TestDaemonBridgeIP(c *testing.T) {
// TestDaemonBridgeIP Steps // TestDaemonBridgeIP Steps
// 1. Delete the existing docker0 Bridge // 1. Delete the existing docker0 Bridge
// 2. Set --bip daemon configuration and start the new Docker Daemon // 2. Set --bip daemon configuration and start the new Docker Daemon
@ -683,7 +683,7 @@ func (s *DockerDaemonSuite) TestDaemonBridgeIP(c *check.C) {
deleteInterface(c, defaultNetworkBridge) deleteInterface(c, defaultNetworkBridge)
} }
func (s *DockerDaemonSuite) TestDaemonRestartWithBridgeIPChange(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartWithBridgeIPChange(c *testing.T) {
s.d.Start(c) s.d.Start(c)
defer s.d.Restart(c) defer s.d.Restart(c)
s.d.Stop(c) s.d.Stop(c)
@ -703,7 +703,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithBridgeIPChange(c *check.C) {
}) })
} }
func (s *DockerDaemonSuite) TestDaemonBridgeFixedCidr(c *check.C) { func (s *DockerDaemonSuite) TestDaemonBridgeFixedCidr(c *testing.T) {
d := s.d d := s.d
bridgeName := "external-bridge" bridgeName := "external-bridge"
@ -725,7 +725,7 @@ func (s *DockerDaemonSuite) TestDaemonBridgeFixedCidr(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonBridgeFixedCidr2(c *check.C) { func (s *DockerDaemonSuite) TestDaemonBridgeFixedCidr2(c *testing.T) {
d := s.d d := s.d
bridgeName := "external-bridge" bridgeName := "external-bridge"
@ -750,7 +750,7 @@ func (s *DockerDaemonSuite) TestDaemonBridgeFixedCidr2(c *check.C) {
assert.Equal(c, out, "10.2.2.2\n") assert.Equal(c, out, "10.2.2.2\n")
} }
func (s *DockerDaemonSuite) TestDaemonBridgeFixedCIDREqualBridgeNetwork(c *check.C) { func (s *DockerDaemonSuite) TestDaemonBridgeFixedCIDREqualBridgeNetwork(c *testing.T) {
d := s.d d := s.d
bridgeName := "external-bridge" bridgeName := "external-bridge"
@ -768,7 +768,7 @@ func (s *DockerDaemonSuite) TestDaemonBridgeFixedCIDREqualBridgeNetwork(c *check
defer d.Cmd("stop", cid1) defer d.Cmd("stop", cid1)
} }
func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4Implicit(c *check.C) { func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4Implicit(c *testing.T) {
defaultNetworkBridge := "docker0" defaultNetworkBridge := "docker0"
deleteInterface(c, defaultNetworkBridge) deleteInterface(c, defaultNetworkBridge)
@ -787,7 +787,7 @@ func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4Implicit(c *check.C) {
deleteInterface(c, defaultNetworkBridge) deleteInterface(c, defaultNetworkBridge)
} }
func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4Explicit(c *check.C) { func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4Explicit(c *testing.T) {
defaultNetworkBridge := "docker0" defaultNetworkBridge := "docker0"
deleteInterface(c, defaultNetworkBridge) deleteInterface(c, defaultNetworkBridge)
@ -807,7 +807,7 @@ func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4Explicit(c *check.C) {
deleteInterface(c, defaultNetworkBridge) deleteInterface(c, defaultNetworkBridge)
} }
func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4ExplicitOutsideContainerSubnet(c *check.C) { func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4ExplicitOutsideContainerSubnet(c *testing.T) {
defaultNetworkBridge := "docker0" defaultNetworkBridge := "docker0"
deleteInterface(c, defaultNetworkBridge) deleteInterface(c, defaultNetworkBridge)
@ -818,7 +818,7 @@ func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4ExplicitOutsideContainer
s.d.Restart(c) s.d.Restart(c)
} }
func (s *DockerDaemonSuite) TestDaemonDefaultNetworkInvalidClusterConfig(c *check.C) { func (s *DockerDaemonSuite) TestDaemonDefaultNetworkInvalidClusterConfig(c *testing.T) {
// Start daemon without docker0 bridge // Start daemon without docker0 bridge
defaultNetworkBridge := "docker0" defaultNetworkBridge := "docker0"
@ -834,7 +834,7 @@ func (s *DockerDaemonSuite) TestDaemonDefaultNetworkInvalidClusterConfig(c *chec
s.d.Restart(c, fmt.Sprintf("--cluster-store=%s", discoveryBackend)) s.d.Restart(c, fmt.Sprintf("--cluster-store=%s", discoveryBackend))
} }
func (s *DockerDaemonSuite) TestDaemonIP(c *check.C) { func (s *DockerDaemonSuite) TestDaemonIP(c *testing.T) {
d := s.d d := s.d
ipStr := "192.170.1.1/24" ipStr := "192.170.1.1/24"
@ -861,7 +861,7 @@ func (s *DockerDaemonSuite) TestDaemonIP(c *check.C) {
assert.Assert(c, matched, check.Equals, true, check.Commentf("iptables output should have contained %q, but was %q", regex, result.Combined())) assert.Assert(c, matched, check.Equals, true, check.Commentf("iptables output should have contained %q, but was %q", regex, result.Combined()))
} }
func (s *DockerDaemonSuite) TestDaemonICCPing(c *check.C) { func (s *DockerDaemonSuite) TestDaemonICCPing(c *testing.T) {
testRequires(c, bridgeNfIptables) testRequires(c, bridgeNfIptables)
d := s.d d := s.d
@ -895,7 +895,7 @@ func (s *DockerDaemonSuite) TestDaemonICCPing(c *check.C) {
assert.NilError(c, err, out) assert.NilError(c, err, out)
} }
func (s *DockerDaemonSuite) TestDaemonICCLinkExpose(c *check.C) { func (s *DockerDaemonSuite) TestDaemonICCLinkExpose(c *testing.T) {
d := s.d d := s.d
bridgeName := "external-bridge" bridgeName := "external-bridge"
@ -919,7 +919,7 @@ func (s *DockerDaemonSuite) TestDaemonICCLinkExpose(c *check.C) {
assert.NilError(c, err, out) assert.NilError(c, err, out)
} }
func (s *DockerDaemonSuite) TestDaemonLinksIpTablesRulesWhenLinkAndUnlink(c *check.C) { func (s *DockerDaemonSuite) TestDaemonLinksIpTablesRulesWhenLinkAndUnlink(c *testing.T) {
bridgeName := "external-bridge" bridgeName := "external-bridge"
bridgeIP := "192.169.1.1/24" bridgeIP := "192.169.1.1/24"
@ -952,7 +952,7 @@ func (s *DockerDaemonSuite) TestDaemonLinksIpTablesRulesWhenLinkAndUnlink(c *che
s.d.Cmd("kill", "parent") s.d.Cmd("kill", "parent")
} }
func (s *DockerDaemonSuite) TestDaemonUlimitDefaults(c *check.C) { func (s *DockerDaemonSuite) TestDaemonUlimitDefaults(c *testing.T) {
s.d.StartWithBusybox(c, "--default-ulimit", "nofile=42:42", "--default-ulimit", "nproc=1024:1024") s.d.StartWithBusybox(c, "--default-ulimit", "nofile=42:42", "--default-ulimit", "nproc=1024:1024")
@ -999,7 +999,7 @@ func (s *DockerDaemonSuite) TestDaemonUlimitDefaults(c *check.C) {
} }
// #11315 // #11315
func (s *DockerDaemonSuite) TestDaemonRestartRenameContainer(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartRenameContainer(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
if out, err := s.d.Cmd("run", "--name=test", "busybox"); err != nil { if out, err := s.d.Cmd("run", "--name=test", "busybox"); err != nil {
@ -1017,7 +1017,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartRenameContainer(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonLoggingDriverDefault(c *check.C) { func (s *DockerDaemonSuite) TestDaemonLoggingDriverDefault(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "--name=test", "busybox", "echo", "testline") out, err := s.d.Cmd("run", "--name=test", "busybox", "echo", "testline")
@ -1055,7 +1055,7 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverDefault(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonLoggingDriverDefaultOverride(c *check.C) { func (s *DockerDaemonSuite) TestDaemonLoggingDriverDefaultOverride(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "--name=test", "--log-driver=none", "busybox", "echo", "testline") out, err := s.d.Cmd("run", "--name=test", "--log-driver=none", "busybox", "echo", "testline")
@ -1072,7 +1072,7 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverDefaultOverride(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonLoggingDriverNone(c *check.C) { func (s *DockerDaemonSuite) TestDaemonLoggingDriverNone(c *testing.T) {
s.d.StartWithBusybox(c, "--log-driver=none") s.d.StartWithBusybox(c, "--log-driver=none")
out, err := s.d.Cmd("run", "--name=test", "busybox", "echo", "testline") out, err := s.d.Cmd("run", "--name=test", "busybox", "echo", "testline")
@ -1089,7 +1089,7 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverNone(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneOverride(c *check.C) { func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneOverride(c *testing.T) {
s.d.StartWithBusybox(c, "--log-driver=none") s.d.StartWithBusybox(c, "--log-driver=none")
out, err := s.d.Cmd("run", "--name=test", "--log-driver=json-file", "busybox", "echo", "testline") out, err := s.d.Cmd("run", "--name=test", "--log-driver=json-file", "busybox", "echo", "testline")
@ -1129,7 +1129,7 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneOverride(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneLogsError(c *check.C) { func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneLogsError(c *testing.T) {
s.d.StartWithBusybox(c, "--log-driver=none") s.d.StartWithBusybox(c, "--log-driver=none")
out, err := s.d.Cmd("run", "--name=test", "busybox", "echo", "testline") out, err := s.d.Cmd("run", "--name=test", "busybox", "echo", "testline")
@ -1141,7 +1141,7 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneLogsError(c *check.C) {
assert.Assert(c, strings.Contains(out, expected)) assert.Assert(c, strings.Contains(out, expected))
} }
func (s *DockerDaemonSuite) TestDaemonLoggingDriverShouldBeIgnoredForBuild(c *check.C) { func (s *DockerDaemonSuite) TestDaemonLoggingDriverShouldBeIgnoredForBuild(c *testing.T) {
s.d.StartWithBusybox(c, "--log-driver=splunk") s.d.StartWithBusybox(c, "--log-driver=splunk")
result := cli.BuildCmd(c, "busyboxs", cli.Daemon(s.d), result := cli.BuildCmd(c, "busyboxs", cli.Daemon(s.d),
@ -1156,7 +1156,7 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverShouldBeIgnoredForBuild(c *ch
assert.Assert(c, result.Combined(), checker.Contains, "foo", comment) assert.Assert(c, result.Combined(), checker.Contains, "foo", comment)
} }
func (s *DockerDaemonSuite) TestDaemonUnixSockCleanedUp(c *check.C) { func (s *DockerDaemonSuite) TestDaemonUnixSockCleanedUp(c *testing.T) {
dir, err := ioutil.TempDir("", "socket-cleanup-test") dir, err := ioutil.TempDir("", "socket-cleanup-test")
if err != nil { if err != nil {
c.Fatal(err) c.Fatal(err)
@ -1177,7 +1177,7 @@ func (s *DockerDaemonSuite) TestDaemonUnixSockCleanedUp(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonWithWrongkey(c *check.C) { func (s *DockerDaemonSuite) TestDaemonWithWrongkey(c *testing.T) {
type Config struct { type Config struct {
Crv string `json:"crv"` Crv string `json:"crv"`
D string `json:"d"` D string `json:"d"`
@ -1230,7 +1230,7 @@ func (s *DockerDaemonSuite) TestDaemonWithWrongkey(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonRestartKillWait(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartKillWait(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "-id", "busybox", "/bin/cat") out, err := s.d.Cmd("run", "-id", "busybox", "/bin/cat")
@ -1264,7 +1264,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartKillWait(c *check.C) {
} }
// TestHTTPSInfo connects via two-way authenticated HTTPS to the info endpoint // TestHTTPSInfo connects via two-way authenticated HTTPS to the info endpoint
func (s *DockerDaemonSuite) TestHTTPSInfo(c *check.C) { func (s *DockerDaemonSuite) TestHTTPSInfo(c *testing.T) {
const ( const (
testDaemonHTTPSAddr = "tcp://localhost:4271" testDaemonHTTPSAddr = "tcp://localhost:4271"
) )
@ -1292,7 +1292,7 @@ func (s *DockerDaemonSuite) TestHTTPSInfo(c *check.C) {
// TestHTTPSRun connects via two-way authenticated HTTPS to the create, attach, start, and wait endpoints. // TestHTTPSRun connects via two-way authenticated HTTPS to the create, attach, start, and wait endpoints.
// https://github.com/docker/docker/issues/19280 // https://github.com/docker/docker/issues/19280
func (s *DockerDaemonSuite) TestHTTPSRun(c *check.C) { func (s *DockerDaemonSuite) TestHTTPSRun(c *testing.T) {
const ( const (
testDaemonHTTPSAddr = "tcp://localhost:4271" testDaemonHTTPSAddr = "tcp://localhost:4271"
) )
@ -1318,7 +1318,7 @@ func (s *DockerDaemonSuite) TestHTTPSRun(c *check.C) {
} }
// TestTLSVerify verifies that --tlsverify=false turns on tls // TestTLSVerify verifies that --tlsverify=false turns on tls
func (s *DockerDaemonSuite) TestTLSVerify(c *check.C) { func (s *DockerDaemonSuite) TestTLSVerify(c *testing.T) {
out, err := exec.Command(dockerdBinary, "--tlsverify=false").CombinedOutput() out, err := exec.Command(dockerdBinary, "--tlsverify=false").CombinedOutput()
if err == nil || !strings.Contains(string(out), "Could not load X509 key pair") { if err == nil || !strings.Contains(string(out), "Could not load X509 key pair") {
c.Fatalf("Daemon should not have started due to missing certs: %v\n%s", err, string(out)) c.Fatalf("Daemon should not have started due to missing certs: %v\n%s", err, string(out))
@ -1327,7 +1327,7 @@ func (s *DockerDaemonSuite) TestTLSVerify(c *check.C) {
// TestHTTPSInfoRogueCert connects via two-way authenticated HTTPS to the info endpoint // TestHTTPSInfoRogueCert connects via two-way authenticated HTTPS to the info endpoint
// by using a rogue client certificate and checks that it fails with the expected error. // by using a rogue client certificate and checks that it fails with the expected error.
func (s *DockerDaemonSuite) TestHTTPSInfoRogueCert(c *check.C) { func (s *DockerDaemonSuite) TestHTTPSInfoRogueCert(c *testing.T) {
const ( const (
errBadCertificate = "bad certificate" errBadCertificate = "bad certificate"
testDaemonHTTPSAddr = "tcp://localhost:4271" testDaemonHTTPSAddr = "tcp://localhost:4271"
@ -1356,7 +1356,7 @@ func (s *DockerDaemonSuite) TestHTTPSInfoRogueCert(c *check.C) {
// TestHTTPSInfoRogueServerCert connects via two-way authenticated HTTPS to the info endpoint // TestHTTPSInfoRogueServerCert connects via two-way authenticated HTTPS to the info endpoint
// which provides a rogue server certificate and checks that it fails with the expected error // which provides a rogue server certificate and checks that it fails with the expected error
func (s *DockerDaemonSuite) TestHTTPSInfoRogueServerCert(c *check.C) { func (s *DockerDaemonSuite) TestHTTPSInfoRogueServerCert(c *testing.T) {
const ( const (
errCaUnknown = "x509: certificate signed by unknown authority" errCaUnknown = "x509: certificate signed by unknown authority"
testDaemonRogueHTTPSAddr = "tcp://localhost:4272" testDaemonRogueHTTPSAddr = "tcp://localhost:4272"
@ -1382,7 +1382,7 @@ func (s *DockerDaemonSuite) TestHTTPSInfoRogueServerCert(c *check.C) {
} }
} }
func pingContainers(c *check.C, d *daemon.Daemon, expectFailure bool) { func pingContainers(c *testing.T, d *daemon.Daemon, expectFailure bool) {
var dargs []string var dargs []string
if d != nil { if d != nil {
dargs = []string{"--host", d.Sock()} dargs = []string{"--host", d.Sock()}
@ -1406,7 +1406,7 @@ func pingContainers(c *check.C, d *daemon.Daemon, expectFailure bool) {
dockerCmd(c, args...) dockerCmd(c, args...)
} }
func (s *DockerDaemonSuite) TestDaemonRestartWithSocketAsVolume(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartWithSocketAsVolume(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
socket := filepath.Join(s.d.Folder, "docker.sock") socket := filepath.Join(s.d.Folder, "docker.sock")
@ -1418,7 +1418,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithSocketAsVolume(c *check.C) {
// os.Kill should kill daemon ungracefully, leaving behind container mounts. // os.Kill should kill daemon ungracefully, leaving behind container mounts.
// A subsequent daemon restart should clean up said mounts. // A subsequent daemon restart should clean up said mounts.
func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *check.C) { func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *testing.T) {
d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
d.StartWithBusybox(c) d.StartWithBusybox(c)
@ -1456,7 +1456,7 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *chec
} }
// os.Interrupt should perform a graceful daemon shutdown and hence cleanup mounts. // os.Interrupt should perform a graceful daemon shutdown and hence cleanup mounts.
func (s *DockerDaemonSuite) TestCleanupMountsAfterGracefulShutdown(c *check.C) { func (s *DockerDaemonSuite) TestCleanupMountsAfterGracefulShutdown(c *testing.T) {
d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
d.StartWithBusybox(c) d.StartWithBusybox(c)
@ -1475,7 +1475,7 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterGracefulShutdown(c *check.C) {
assert.Assert(c, !strings.Contains(string(mountOut), id), "%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, d.Root, mountOut) assert.Assert(c, !strings.Contains(string(mountOut), id), "%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, d.Root, mountOut)
} }
func (s *DockerDaemonSuite) TestDaemonRestartWithContainerRunning(t *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartWithContainerRunning(t *testing.T) {
s.d.StartWithBusybox(t) s.d.StartWithBusybox(t)
if out, err := s.d.Cmd("run", "-d", "--name", "test", "busybox", "top"); err != nil { if out, err := s.d.Cmd("run", "-d", "--name", "test", "busybox", "top"); err != nil {
t.Fatal(out, err) t.Fatal(out, err)
@ -1488,7 +1488,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithContainerRunning(t *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonRestartCleanupNetns(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartCleanupNetns(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "--name", "netns", "-d", "busybox", "top") out, err := s.d.Cmd("run", "--name", "netns", "-d", "busybox", "top")
if err != nil { if err != nil {
@ -1526,7 +1526,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartCleanupNetns(c *check.C) {
} }
// tests regression detailed in #13964 where DOCKER_TLS_VERIFY env is ignored // tests regression detailed in #13964 where DOCKER_TLS_VERIFY env is ignored
func (s *DockerDaemonSuite) TestDaemonTLSVerifyIssue13964(c *check.C) { func (s *DockerDaemonSuite) TestDaemonTLSVerifyIssue13964(c *testing.T) {
host := "tcp://localhost:4271" host := "tcp://localhost:4271"
s.d.Start(c, "-H", host) s.d.Start(c, "-H", host)
icmd.RunCmd(icmd.Cmd{ icmd.RunCmd(icmd.Cmd{
@ -1538,18 +1538,18 @@ func (s *DockerDaemonSuite) TestDaemonTLSVerifyIssue13964(c *check.C) {
}) })
} }
func setupV6(c *check.C) { func setupV6(c *testing.T) {
// Hack to get the right IPv6 address on docker0, which has already been created // Hack to get the right IPv6 address on docker0, which has already been created
result := icmd.RunCommand("ip", "addr", "add", "fe80::1/64", "dev", "docker0") result := icmd.RunCommand("ip", "addr", "add", "fe80::1/64", "dev", "docker0")
result.Assert(c, icmd.Success) result.Assert(c, icmd.Success)
} }
func teardownV6(c *check.C) { func teardownV6(c *testing.T) {
result := icmd.RunCommand("ip", "addr", "del", "fe80::1/64", "dev", "docker0") result := icmd.RunCommand("ip", "addr", "del", "fe80::1/64", "dev", "docker0")
result.Assert(c, icmd.Success) result.Assert(c, icmd.Success)
} }
func (s *DockerDaemonSuite) TestDaemonRestartWithContainerWithRestartPolicyAlways(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartWithContainerWithRestartPolicyAlways(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "-d", "--restart", "always", "busybox", "top") out, err := s.d.Cmd("run", "-d", "--restart", "always", "busybox", "top")
@ -1572,7 +1572,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithContainerWithRestartPolicyAlway
assert.Assert(c, strings.TrimSpace(out), check.Equals, id[:12]) assert.Assert(c, strings.TrimSpace(out), check.Equals, id[:12])
} }
func (s *DockerDaemonSuite) TestDaemonWideLogConfig(c *check.C) { func (s *DockerDaemonSuite) TestDaemonWideLogConfig(c *testing.T) {
s.d.StartWithBusybox(c, "--log-opt=max-size=1k") s.d.StartWithBusybox(c, "--log-opt=max-size=1k")
name := "logtest" name := "logtest"
out, err := s.d.Cmd("run", "-d", "--log-opt=max-file=5", "--name", name, "busybox", "top") out, err := s.d.Cmd("run", "-d", "--log-opt=max-file=5", "--name", name, "busybox", "top")
@ -1588,7 +1588,7 @@ func (s *DockerDaemonSuite) TestDaemonWideLogConfig(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "json-file") assert.Equal(c, strings.TrimSpace(out), "json-file")
} }
func (s *DockerDaemonSuite) TestDaemonRestartWithPausedContainer(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartWithPausedContainer(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
if out, err := s.d.Cmd("run", "-i", "-d", "--name", "test", "busybox", "top"); err != nil { if out, err := s.d.Cmd("run", "-i", "-d", "--name", "test", "busybox", "top"); err != nil {
c.Fatal(err, out) c.Fatal(err, out)
@ -1621,7 +1621,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithPausedContainer(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonRestartRmVolumeInUse(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartRmVolumeInUse(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
out, err := s.d.Cmd("create", "-v", "test:/foo", "busybox") out, err := s.d.Cmd("create", "-v", "test:/foo", "busybox")
@ -1634,7 +1634,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartRmVolumeInUse(c *check.C) {
assert.Assert(c, out, checker.Contains, "in use") assert.Assert(c, out, checker.Contains, "in use")
} }
func (s *DockerDaemonSuite) TestDaemonRestartLocalVolumes(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartLocalVolumes(c *testing.T) {
s.d.Start(c) s.d.Start(c)
out, err := s.d.Cmd("volume", "create", "test") out, err := s.d.Cmd("volume", "create", "test")
@ -1646,7 +1646,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartLocalVolumes(c *check.C) {
} }
// FIXME(vdemeester) should be a unit test // FIXME(vdemeester) should be a unit test
func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *check.C) { func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *testing.T) {
d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
assert.Assert(c, d.StartWithError("--log-driver=syslog", "--log-opt", "syslog-address=corrupted:42"), check.NotNil) assert.Assert(c, d.StartWithError("--log-driver=syslog", "--log-opt", "syslog-address=corrupted:42"), check.NotNil)
expected := "syslog-address should be in form proto://address" expected := "syslog-address should be in form proto://address"
@ -1654,7 +1654,7 @@ func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *check.C) {
} }
// FIXME(vdemeester) should be a unit test // FIXME(vdemeester) should be a unit test
func (s *DockerDaemonSuite) TestDaemonCorruptedFluentdAddress(c *check.C) { func (s *DockerDaemonSuite) TestDaemonCorruptedFluentdAddress(c *testing.T) {
d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
assert.Assert(c, d.StartWithError("--log-driver=fluentd", "--log-opt", "fluentd-address=corrupted:c"), check.NotNil) assert.Assert(c, d.StartWithError("--log-driver=fluentd", "--log-opt", "fluentd-address=corrupted:c"), check.NotNil)
expected := "invalid fluentd-address corrupted:c: " expected := "invalid fluentd-address corrupted:c: "
@ -1662,7 +1662,7 @@ func (s *DockerDaemonSuite) TestDaemonCorruptedFluentdAddress(c *check.C) {
} }
// FIXME(vdemeester) Use a new daemon instance instead of the Suite one // FIXME(vdemeester) Use a new daemon instance instead of the Suite one
func (s *DockerDaemonSuite) TestDaemonStartWithoutHost(c *check.C) { func (s *DockerDaemonSuite) TestDaemonStartWithoutHost(c *testing.T) {
s.d.UseDefaultHost = true s.d.UseDefaultHost = true
defer func() { defer func() {
s.d.UseDefaultHost = false s.d.UseDefaultHost = false
@ -1671,7 +1671,7 @@ func (s *DockerDaemonSuite) TestDaemonStartWithoutHost(c *check.C) {
} }
// FIXME(vdemeester) Use a new daemon instance instead of the Suite one // FIXME(vdemeester) Use a new daemon instance instead of the Suite one
func (s *DockerDaemonSuite) TestDaemonStartWithDefaultTLSHost(c *check.C) { func (s *DockerDaemonSuite) TestDaemonStartWithDefaultTLSHost(c *testing.T) {
s.d.UseDefaultTLSHost = true s.d.UseDefaultTLSHost = true
defer func() { defer func() {
s.d.UseDefaultTLSHost = false s.d.UseDefaultTLSHost = false
@ -1730,7 +1730,7 @@ func (s *DockerDaemonSuite) TestDaemonStartWithDefaultTLSHost(c *check.C) {
assert.Assert(c, certRequestInfo.AcceptableCAs[0], checker.DeepEquals, rootCert.RawSubject) assert.Assert(c, certRequestInfo.AcceptableCAs[0], checker.DeepEquals, rootCert.RawSubject)
} }
func (s *DockerDaemonSuite) TestBridgeIPIsExcludedFromAllocatorPool(c *check.C) { func (s *DockerDaemonSuite) TestBridgeIPIsExcludedFromAllocatorPool(c *testing.T) {
defaultNetworkBridge := "docker0" defaultNetworkBridge := "docker0"
deleteInterface(c, defaultNetworkBridge) deleteInterface(c, defaultNetworkBridge)
@ -1757,7 +1757,7 @@ func (s *DockerDaemonSuite) TestBridgeIPIsExcludedFromAllocatorPool(c *check.C)
} }
// Test daemon for no space left on device error // Test daemon for no space left on device error
func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *check.C) { func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, Network) testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, Network)
testDir, err := ioutil.TempDir("", "no-space-left-on-device-test") testDir, err := ioutil.TempDir("", "no-space-left-on-device-test")
@ -1784,7 +1784,7 @@ func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *check.C) {
} }
// Test daemon restart with container links + auto restart // Test daemon restart with container links + auto restart
func (s *DockerDaemonSuite) TestDaemonRestartContainerLinksRestart(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartContainerLinksRestart(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
var parent1Args []string var parent1Args []string
@ -1842,7 +1842,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartContainerLinksRestart(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonCgroupParent(c *check.C) { func (s *DockerDaemonSuite) TestDaemonCgroupParent(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
cgroupParent := "test" cgroupParent := "test"
@ -1869,7 +1869,7 @@ func (s *DockerDaemonSuite) TestDaemonCgroupParent(c *check.C) {
assert.Assert(c, found, checker.True, check.Commentf("Cgroup path for container (%s) doesn't found in cgroups file: %s", expectedCgroup, cgroupPaths)) assert.Assert(c, found, checker.True, check.Commentf("Cgroup path for container (%s) doesn't found in cgroups file: %s", expectedCgroup, cgroupPaths))
} }
func (s *DockerDaemonSuite) TestDaemonRestartWithLinks(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartWithLinks(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows does not support links testRequires(c, DaemonIsLinux) // Windows does not support links
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
@ -1892,7 +1892,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithLinks(c *check.C) {
assert.Assert(c, strings.Contains(out, "1 packets transmitted, 1 packets received"), check.Equals, true, check.Commentf("%s", out)) assert.Assert(c, strings.Contains(out, "1 packets transmitted, 1 packets received"), check.Equals, true, check.Commentf("%s", out))
} }
func (s *DockerDaemonSuite) TestDaemonRestartWithNames(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartWithNames(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows does not support links testRequires(c, DaemonIsLinux) // Windows does not support links
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
@ -1940,7 +1940,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithNames(c *check.C) {
} }
// TestDaemonRestartWithKilledRunningContainer requires live restore of running containers // TestDaemonRestartWithKilledRunningContainer requires live restore of running containers
func (s *DockerDaemonSuite) TestDaemonRestartWithKilledRunningContainer(t *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartWithKilledRunningContainer(t *testing.T) {
testRequires(t, DaemonIsLinux) testRequires(t, DaemonIsLinux)
s.d.StartWithBusybox(t) s.d.StartWithBusybox(t)
@ -1990,7 +1990,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithKilledRunningContainer(t *check
// os.Kill should kill daemon ungracefully, leaving behind live containers. // os.Kill should kill daemon ungracefully, leaving behind live containers.
// The live containers should be known to the restarted daemon. Stopping // The live containers should be known to the restarted daemon. Stopping
// them now, should remove the mounts. // them now, should remove the mounts.
func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonCrash(c *check.C) { func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonCrash(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
s.d.StartWithBusybox(c, "--live-restore") s.d.StartWithBusybox(c, "--live-restore")
@ -2037,7 +2037,7 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonCrash(c *check.C) {
} }
// TestDaemonRestartWithUnpausedRunningContainer requires live restore of running containers. // TestDaemonRestartWithUnpausedRunningContainer requires live restore of running containers.
func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *testing.T) {
testRequires(t, DaemonIsLinux) testRequires(t, DaemonIsLinux)
s.d.StartWithBusybox(t, "--live-restore") s.d.StartWithBusybox(t, "--live-restore")
@ -2071,7 +2071,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *che
// Give time to containerd to process the command if we don't // Give time to containerd to process the command if we don't
// the resume event might be received after we do the inspect // the resume event might be received after we do the inspect
waitAndAssert(t, defaultReconciliationTimeout, func(*check.C) (interface{}, check.CommentInterface) { waitAndAssert(t, defaultReconciliationTimeout, func(*testing.T) (interface{}, check.CommentInterface) {
result := icmd.RunCommand("kill", "-0", strings.TrimSpace(pid)) result := icmd.RunCommand("kill", "-0", strings.TrimSpace(pid))
return result.ExitCode, nil return result.ExitCode, nil
}, checker.Equals, 0) }, checker.Equals, 0)
@ -2094,7 +2094,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *che
// TestRunLinksChanged checks that creating a new container with the same name does not update links // TestRunLinksChanged checks that creating a new container with the same name does not update links
// this ensures that the old, pre gh#16032 functionality continues on // this ensures that the old, pre gh#16032 functionality continues on
func (s *DockerDaemonSuite) TestRunLinksChanged(c *check.C) { func (s *DockerDaemonSuite) TestRunLinksChanged(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows does not support links testRequires(c, DaemonIsLinux) // Windows does not support links
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
@ -2120,7 +2120,7 @@ func (s *DockerDaemonSuite) TestRunLinksChanged(c *check.C) {
assert.Assert(c, out, check.Not(checker.Contains), "1 packets transmitted, 1 packets received") assert.Assert(c, out, check.Not(checker.Contains), "1 packets transmitted, 1 packets received")
} }
func (s *DockerDaemonSuite) TestDaemonStartWithoutColors(c *check.C) { func (s *DockerDaemonSuite) TestDaemonStartWithoutColors(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
infoLog := "\x1b[36mINFO\x1b" infoLog := "\x1b[36mINFO\x1b"
@ -2170,7 +2170,7 @@ func (s *DockerDaemonSuite) TestDaemonStartWithoutColors(c *check.C) {
assert.Assert(c, b.String(), check.Not(checker.Contains), infoLog) assert.Assert(c, b.String(), check.Not(checker.Contains), infoLog)
} }
func (s *DockerDaemonSuite) TestDaemonDebugLog(c *check.C) { func (s *DockerDaemonSuite) TestDaemonDebugLog(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
debugLog := "\x1b[37mDEBU\x1b" debugLog := "\x1b[37mDEBU\x1b"
@ -2190,7 +2190,7 @@ func (s *DockerDaemonSuite) TestDaemonDebugLog(c *check.C) {
assert.Assert(c, b.String(), checker.Contains, debugLog) assert.Assert(c, b.String(), checker.Contains, debugLog)
} }
func (s *DockerDaemonSuite) TestDaemonDiscoveryBackendConfigReload(c *check.C) { func (s *DockerDaemonSuite) TestDaemonDiscoveryBackendConfigReload(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
// daemon config file // daemon config file
@ -2236,7 +2236,7 @@ func (s *DockerDaemonSuite) TestDaemonDiscoveryBackendConfigReload(c *check.C) {
} }
// Test for #21956 // Test for #21956
func (s *DockerDaemonSuite) TestDaemonLogOptions(c *check.C) { func (s *DockerDaemonSuite) TestDaemonLogOptions(c *testing.T) {
s.d.StartWithBusybox(c, "--log-driver=syslog", "--log-opt=syslog-address=udp://127.0.0.1:514") s.d.StartWithBusybox(c, "--log-driver=syslog", "--log-opt=syslog-address=udp://127.0.0.1:514")
out, err := s.d.Cmd("run", "-d", "--log-driver=json-file", "busybox", "top") out, err := s.d.Cmd("run", "-d", "--log-driver=json-file", "busybox", "top")
@ -2249,7 +2249,7 @@ func (s *DockerDaemonSuite) TestDaemonLogOptions(c *check.C) {
} }
// Test case for #20936, #22443 // Test case for #20936, #22443
func (s *DockerDaemonSuite) TestDaemonMaxConcurrency(c *check.C) { func (s *DockerDaemonSuite) TestDaemonMaxConcurrency(c *testing.T) {
s.d.Start(c, "--max-concurrent-uploads=6", "--max-concurrent-downloads=8") s.d.Start(c, "--max-concurrent-uploads=6", "--max-concurrent-downloads=8")
expectedMaxConcurrentUploads := `level=debug msg="Max Concurrent Uploads: 6"` expectedMaxConcurrentUploads := `level=debug msg="Max Concurrent Uploads: 6"`
@ -2261,7 +2261,7 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrency(c *check.C) {
} }
// Test case for #20936, #22443 // Test case for #20936, #22443
func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFile(c *check.C) { func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFile(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
// daemon config file // daemon config file
@ -2302,7 +2302,7 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFile(c *check.C) {
} }
// Test case for #20936, #22443 // Test case for #20936, #22443
func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *check.C) { func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
// daemon config file // daemon config file
@ -2359,7 +2359,7 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *chec
assert.Assert(c, string(content), checker.Contains, expectedMaxConcurrentDownloads) assert.Assert(c, string(content), checker.Contains, expectedMaxConcurrentDownloads)
} }
func (s *DockerDaemonSuite) TestBuildOnDisabledBridgeNetworkDaemon(c *check.C) { func (s *DockerDaemonSuite) TestBuildOnDisabledBridgeNetworkDaemon(c *testing.T) {
s.d.StartWithBusybox(c, "-b=none", "--iptables=false") s.d.StartWithBusybox(c, "-b=none", "--iptables=false")
result := cli.BuildCmd(c, "busyboxs", cli.Daemon(s.d), result := cli.BuildCmd(c, "busyboxs", cli.Daemon(s.d),
@ -2374,7 +2374,7 @@ func (s *DockerDaemonSuite) TestBuildOnDisabledBridgeNetworkDaemon(c *check.C) {
} }
// Test case for #21976 // Test case for #21976
func (s *DockerDaemonSuite) TestDaemonDNSFlagsInHostMode(c *check.C) { func (s *DockerDaemonSuite) TestDaemonDNSFlagsInHostMode(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
s.d.StartWithBusybox(c, "--dns", "1.2.3.4", "--dns-search", "example.com", "--dns-opt", "timeout:3") s.d.StartWithBusybox(c, "--dns", "1.2.3.4", "--dns-search", "example.com", "--dns-opt", "timeout:3")
@ -2388,7 +2388,7 @@ func (s *DockerDaemonSuite) TestDaemonDNSFlagsInHostMode(c *check.C) {
assert.Assert(c, out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out)) assert.Assert(c, out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
} }
func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *check.C) { func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) {
conf, err := ioutil.TempFile("", "config-file-") conf, err := ioutil.TempFile("", "config-file-")
assert.NilError(c, err) assert.NilError(c, err)
configName := conf.Name() configName := conf.Name()
@ -2506,7 +2506,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *check.C) {
assert.NilError(c, err, out) assert.NilError(c, err, out)
} }
func (s *DockerDaemonSuite) TestRunWithRuntimeFromCommandLine(c *check.C) { func (s *DockerDaemonSuite) TestRunWithRuntimeFromCommandLine(c *testing.T) {
s.d.StartWithBusybox(c, "--add-runtime", "oci=runc", "--add-runtime", "vm=/usr/local/bin/vm-manager") s.d.StartWithBusybox(c, "--add-runtime", "oci=runc", "--add-runtime", "vm=/usr/local/bin/vm-manager")
// Run with default runtime // Run with default runtime
@ -2565,7 +2565,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromCommandLine(c *check.C) {
assert.NilError(c, err, out) assert.NilError(c, err, out)
} }
func (s *DockerDaemonSuite) TestDaemonRestartWithAutoRemoveContainer(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartWithAutoRemoveContainer(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
// top1 will exist after daemon restarts // top1 will exist after daemon restarts
@ -2589,7 +2589,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithAutoRemoveContainer(c *check.C)
assert.Assert(c, out, checker.Not(checker.Contains), "top2", check.Commentf("top2 should be removed after daemon restarts")) assert.Assert(c, out, checker.Not(checker.Contains), "top2", check.Commentf("top2 should be removed after daemon restarts"))
} }
func (s *DockerDaemonSuite) TestDaemonRestartSaveContainerExitCode(c *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartSaveContainerExitCode(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
containerName := "error-values" containerName := "error-values"
@ -2630,7 +2630,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartSaveContainerExitCode(c *check.C) {
assert.Equal(c, out, errMsg1) assert.Equal(c, out, errMsg1)
} }
func (s *DockerDaemonSuite) TestDaemonWithUserlandProxyPath(c *check.C) { func (s *DockerDaemonSuite) TestDaemonWithUserlandProxyPath(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
dockerProxyPath, err := exec.LookPath("docker-proxy") dockerProxyPath, err := exec.LookPath("docker-proxy")
@ -2661,7 +2661,7 @@ func (s *DockerDaemonSuite) TestDaemonWithUserlandProxyPath(c *check.C) {
} }
// Test case for #22471 // Test case for #22471
func (s *DockerDaemonSuite) TestDaemonShutdownTimeout(c *check.C) { func (s *DockerDaemonSuite) TestDaemonShutdownTimeout(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
s.d.StartWithBusybox(c, "--shutdown-timeout=3") s.d.StartWithBusybox(c, "--shutdown-timeout=3")
@ -2682,7 +2682,7 @@ func (s *DockerDaemonSuite) TestDaemonShutdownTimeout(c *check.C) {
} }
// Test case for #22471 // Test case for #22471
func (s *DockerDaemonSuite) TestDaemonShutdownTimeoutWithConfigFile(c *check.C) { func (s *DockerDaemonSuite) TestDaemonShutdownTimeoutWithConfigFile(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
// daemon config file // daemon config file
@ -2716,7 +2716,7 @@ func (s *DockerDaemonSuite) TestDaemonShutdownTimeoutWithConfigFile(c *check.C)
} }
// Test case for 29342 // Test case for 29342
func (s *DockerDaemonSuite) TestExecWithUserAfterLiveRestore(c *check.C) { func (s *DockerDaemonSuite) TestExecWithUserAfterLiveRestore(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
s.d.StartWithBusybox(c, "--live-restore") s.d.StartWithBusybox(c, "--live-restore")
@ -2744,7 +2744,7 @@ func (s *DockerDaemonSuite) TestExecWithUserAfterLiveRestore(c *check.C) {
assert.NilError(c, err, "Output: %s", out) assert.NilError(c, err, "Output: %s", out)
} }
func (s *DockerDaemonSuite) TestRemoveContainerAfterLiveRestore(c *check.C) { func (s *DockerDaemonSuite) TestRemoveContainerAfterLiveRestore(c *testing.T) {
testRequires(c, DaemonIsLinux, overlayFSSupported, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, overlayFSSupported, testEnv.IsLocalDaemon)
s.d.StartWithBusybox(c, "--live-restore", "--storage-driver", "overlay") s.d.StartWithBusybox(c, "--live-restore", "--storage-driver", "overlay")
out, err := s.d.Cmd("run", "-d", "--name=top", "busybox", "top") out, err := s.d.Cmd("run", "-d", "--name=top", "busybox", "top")
@ -2777,7 +2777,7 @@ func (s *DockerDaemonSuite) TestRemoveContainerAfterLiveRestore(c *check.C) {
} }
// #29598 // #29598
func (s *DockerDaemonSuite) TestRestartPolicyWithLiveRestore(c *check.C) { func (s *DockerDaemonSuite) TestRestartPolicyWithLiveRestore(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
s.d.StartWithBusybox(c, "--live-restore") s.d.StartWithBusybox(c, "--live-restore")
@ -2834,7 +2834,7 @@ func (s *DockerDaemonSuite) TestRestartPolicyWithLiveRestore(c *check.C) {
assert.NilError(c, err, "Output: %s", out) assert.NilError(c, err, "Output: %s", out)
} }
func (s *DockerDaemonSuite) TestShmSize(c *check.C) { func (s *DockerDaemonSuite) TestShmSize(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
size := 67108864 * 2 size := 67108864 * 2
@ -2851,7 +2851,7 @@ func (s *DockerDaemonSuite) TestShmSize(c *check.C) {
assert.Assert(c, strings.TrimSpace(out), check.Equals, fmt.Sprintf("%v", size)) assert.Assert(c, strings.TrimSpace(out), check.Equals, fmt.Sprintf("%v", size))
} }
func (s *DockerDaemonSuite) TestShmSizeReload(c *check.C) { func (s *DockerDaemonSuite) TestShmSizeReload(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
configPath, err := ioutil.TempDir("", "test-daemon-shm-size-reload-config") configPath, err := ioutil.TempDir("", "test-daemon-shm-size-reload-config")
@ -2891,7 +2891,7 @@ func (s *DockerDaemonSuite) TestShmSizeReload(c *check.C) {
assert.Assert(c, strings.TrimSpace(out), check.Equals, fmt.Sprintf("%v", size)) assert.Assert(c, strings.TrimSpace(out), check.Equals, fmt.Sprintf("%v", size))
} }
func testDaemonStartIpcMode(c *check.C, from, mode string, valid bool) { func testDaemonStartIpcMode(c *testing.T, from, mode string, valid bool) {
d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
c.Logf("Checking IpcMode %s set from %s\n", mode, from) c.Logf("Checking IpcMode %s set from %s\n", mode, from)
var serr error var serr error
@ -2926,7 +2926,7 @@ func testDaemonStartIpcMode(c *check.C, from, mode string, valid bool) {
// TestDaemonStartWithIpcModes checks that daemon starts fine given correct // TestDaemonStartWithIpcModes checks that daemon starts fine given correct
// arguments for default IPC mode, and bails out with incorrect ones. // arguments for default IPC mode, and bails out with incorrect ones.
// Both CLI option (--default-ipc-mode) and config parameter are tested. // Both CLI option (--default-ipc-mode) and config parameter are tested.
func (s *DockerDaemonSuite) TestDaemonStartWithIpcModes(c *check.C) { func (s *DockerDaemonSuite) TestDaemonStartWithIpcModes(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
ipcModes := []struct { ipcModes := []struct {
@ -2950,7 +2950,7 @@ func (s *DockerDaemonSuite) TestDaemonStartWithIpcModes(c *check.C) {
// TestFailedPluginRemove makes sure that a failed plugin remove does not block // TestFailedPluginRemove makes sure that a failed plugin remove does not block
// the daemon from starting // the daemon from starting
func (s *DockerDaemonSuite) TestFailedPluginRemove(c *check.C) { func (s *DockerDaemonSuite) TestFailedPluginRemove(c *testing.T) {
testRequires(c, DaemonIsLinux, IsAmd64, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, IsAmd64, testEnv.IsLocalDaemon)
d := daemon.New(c, dockerBinary, dockerdBinary) d := daemon.New(c, dockerBinary, dockerdBinary)
d.Start(c) d.Start(c)

View file

@ -25,7 +25,7 @@ import (
"gotest.tools/icmd" "gotest.tools/icmd"
) )
func (s *DockerSuite) TestEventsTimestampFormats(c *check.C) { func (s *DockerSuite) TestEventsTimestampFormats(c *testing.T) {
name := "events-time-format-test" name := "events-time-format-test"
// Start stopwatch, generate an event // Start stopwatch, generate an event
@ -54,7 +54,7 @@ func (s *DockerSuite) TestEventsTimestampFormats(c *check.C) {
} }
} }
func (s *DockerSuite) TestEventsUntag(c *check.C) { func (s *DockerSuite) TestEventsUntag(c *testing.T) {
image := "busybox" image := "busybox"
dockerCmd(c, "tag", image, "utest:tag1") dockerCmd(c, "tag", image, "utest:tag1")
dockerCmd(c, "tag", image, "utest:tag2") dockerCmd(c, "tag", image, "utest:tag2")
@ -77,7 +77,7 @@ func (s *DockerSuite) TestEventsUntag(c *check.C) {
} }
} }
func (s *DockerSuite) TestEventsContainerEvents(c *check.C) { func (s *DockerSuite) TestEventsContainerEvents(c *testing.T) {
dockerCmd(c, "run", "--rm", "--name", "container-events-test", "busybox", "true") dockerCmd(c, "run", "--rm", "--name", "container-events-test", "busybox", "true")
out, _ := dockerCmd(c, "events", "--until", daemonUnixTime(c)) out, _ := dockerCmd(c, "events", "--until", daemonUnixTime(c))
@ -89,7 +89,7 @@ func (s *DockerSuite) TestEventsContainerEvents(c *check.C) {
assert.Assert(c, is.DeepEqual(containerEvents[:5], []string{"create", "attach", "start", "die", "destroy"}), out) assert.Assert(c, is.DeepEqual(containerEvents[:5], []string{"create", "attach", "start", "die", "destroy"}), out)
} }
func (s *DockerSuite) TestEventsContainerEventsAttrSort(c *check.C) { func (s *DockerSuite) TestEventsContainerEventsAttrSort(c *testing.T) {
since := daemonUnixTime(c) since := daemonUnixTime(c)
dockerCmd(c, "run", "--rm", "--name", "container-events-test", "busybox", "true") dockerCmd(c, "run", "--rm", "--name", "container-events-test", "busybox", "true")
@ -113,7 +113,7 @@ func (s *DockerSuite) TestEventsContainerEventsAttrSort(c *check.C) {
assert.Equal(c, matchedEvents, 2, "missing events for container container-events-test:\n%s", out) assert.Equal(c, matchedEvents, 2, "missing events for container container-events-test:\n%s", out)
} }
func (s *DockerSuite) TestEventsContainerEventsSinceUnixEpoch(c *check.C) { func (s *DockerSuite) TestEventsContainerEventsSinceUnixEpoch(c *testing.T) {
dockerCmd(c, "run", "--rm", "--name", "since-epoch-test", "busybox", "true") dockerCmd(c, "run", "--rm", "--name", "since-epoch-test", "busybox", "true")
timeBeginning := time.Unix(0, 0).Format(time.RFC3339Nano) timeBeginning := time.Unix(0, 0).Format(time.RFC3339Nano)
timeBeginning = strings.Replace(timeBeginning, "Z", ".000000000Z", -1) timeBeginning = strings.Replace(timeBeginning, "Z", ".000000000Z", -1)
@ -127,7 +127,7 @@ func (s *DockerSuite) TestEventsContainerEventsSinceUnixEpoch(c *check.C) {
assert.Assert(c, is.DeepEqual(containerEvents, []string{"create", "attach", "start", "die", "destroy"}), out) assert.Assert(c, is.DeepEqual(containerEvents, []string{"create", "attach", "start", "die", "destroy"}), out)
} }
func (s *DockerSuite) TestEventsImageTag(c *check.C) { func (s *DockerSuite) TestEventsImageTag(c *testing.T) {
time.Sleep(1 * time.Second) // because API has seconds granularity time.Sleep(1 * time.Second) // because API has seconds granularity
since := daemonUnixTime(c) since := daemonUnixTime(c)
image := "testimageevents:tag" image := "testimageevents:tag"
@ -145,7 +145,7 @@ func (s *DockerSuite) TestEventsImageTag(c *check.C) {
assert.Equal(c, matches["action"], "tag") assert.Equal(c, matches["action"], "tag")
} }
func (s *DockerSuite) TestEventsImagePull(c *check.C) { func (s *DockerSuite) TestEventsImagePull(c *testing.T) {
// TODO Windows: Enable this test once pull and reliable image names are available // TODO Windows: Enable this test once pull and reliable image names are available
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
since := daemonUnixTime(c) since := daemonUnixTime(c)
@ -163,7 +163,7 @@ func (s *DockerSuite) TestEventsImagePull(c *check.C) {
assert.Equal(c, matches["action"], "pull") assert.Equal(c, matches["action"], "pull")
} }
func (s *DockerSuite) TestEventsImageImport(c *check.C) { func (s *DockerSuite) TestEventsImageImport(c *testing.T) {
// TODO Windows CI. This should be portable once export/import are // TODO Windows CI. This should be portable once export/import are
// more reliable (@swernli) // more reliable (@swernli)
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -187,7 +187,7 @@ func (s *DockerSuite) TestEventsImageImport(c *check.C) {
assert.Equal(c, matches["action"], "import", "matches: %v\nout:\n%s\n", matches, out) assert.Equal(c, matches["action"], "import", "matches: %v\nout:\n%s\n", matches, out)
} }
func (s *DockerSuite) TestEventsImageLoad(c *check.C) { func (s *DockerSuite) TestEventsImageLoad(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
myImageName := "footest:v1" myImageName := "footest:v1"
dockerCmd(c, "tag", "busybox", myImageName) dockerCmd(c, "tag", "busybox", myImageName)
@ -226,7 +226,7 @@ func (s *DockerSuite) TestEventsImageLoad(c *check.C) {
assert.Equal(c, matches["action"], "save", "matches: %v\nout:\n%s\n", matches, out) assert.Equal(c, matches["action"], "save", "matches: %v\nout:\n%s\n", matches, out)
} }
func (s *DockerSuite) TestEventsPluginOps(c *check.C) { func (s *DockerSuite) TestEventsPluginOps(c *testing.T) {
testRequires(c, DaemonIsLinux, IsAmd64, Network) testRequires(c, DaemonIsLinux, IsAmd64, Network)
since := daemonUnixTime(c) since := daemonUnixTime(c)
@ -245,7 +245,7 @@ func (s *DockerSuite) TestEventsPluginOps(c *check.C) {
assert.Assert(c, is.DeepEqual(pluginEvents, []string{"pull", "enable", "disable", "remove"}), out) assert.Assert(c, is.DeepEqual(pluginEvents, []string{"pull", "enable", "disable", "remove"}), out)
} }
func (s *DockerSuite) TestEventsFilters(c *check.C) { func (s *DockerSuite) TestEventsFilters(c *testing.T) {
since := daemonUnixTime(c) since := daemonUnixTime(c)
dockerCmd(c, "run", "--rm", "busybox", "true") dockerCmd(c, "run", "--rm", "busybox", "true")
dockerCmd(c, "run", "--rm", "busybox", "true") dockerCmd(c, "run", "--rm", "busybox", "true")
@ -260,7 +260,7 @@ func (s *DockerSuite) TestEventsFilters(c *check.C) {
assert.Assert(c, count >= 2, "should have had 2 start events but had %d, out: %s", count, out) assert.Assert(c, count >= 2, "should have had 2 start events but had %d, out: %s", count, out)
} }
func (s *DockerSuite) TestEventsFilterImageName(c *check.C) { func (s *DockerSuite) TestEventsFilterImageName(c *testing.T) {
since := daemonUnixTime(c) since := daemonUnixTime(c)
out, _ := dockerCmd(c, "run", "--name", "container_1", "-d", "busybox:latest", "true") out, _ := dockerCmd(c, "run", "--name", "container_1", "-d", "busybox:latest", "true")
@ -288,7 +288,7 @@ func (s *DockerSuite) TestEventsFilterImageName(c *check.C) {
assert.Assert(c, count2 != 0, "Expected event from container but got %d from %s", count2, container2) assert.Assert(c, count2 != 0, "Expected event from container but got %d from %s", count2, container2)
} }
func (s *DockerSuite) TestEventsFilterLabels(c *check.C) { func (s *DockerSuite) TestEventsFilterLabels(c *testing.T) {
since := strconv.FormatUint(uint64(daemonTime(c).Unix()), 10) since := strconv.FormatUint(uint64(daemonTime(c).Unix()), 10)
label := "io.docker.testing=foo" label := "io.docker.testing=foo"
@ -323,7 +323,7 @@ func (s *DockerSuite) TestEventsFilterLabels(c *check.C) {
assert.Assert(c, found) assert.Assert(c, found)
} }
func (s *DockerSuite) TestEventsFilterImageLabels(c *check.C) { func (s *DockerSuite) TestEventsFilterImageLabels(c *testing.T) {
since := daemonUnixTime(c) since := daemonUnixTime(c)
name := "labelfiltertest" name := "labelfiltertest"
label := "io.docker.testing=image" label := "io.docker.testing=image"
@ -353,7 +353,7 @@ func (s *DockerSuite) TestEventsFilterImageLabels(c *check.C) {
} }
} }
func (s *DockerSuite) TestEventsFilterContainer(c *check.C) { func (s *DockerSuite) TestEventsFilterContainer(c *testing.T) {
since := daemonUnixTime(c) since := daemonUnixTime(c)
nameID := make(map[string]string) nameID := make(map[string]string)
@ -391,7 +391,7 @@ func (s *DockerSuite) TestEventsFilterContainer(c *check.C) {
} }
} }
func (s *DockerSuite) TestEventsCommit(c *check.C) { func (s *DockerSuite) TestEventsCommit(c *testing.T) {
// Problematic on Windows as cannot commit a running container // Problematic on Windows as cannot commit a running container
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -408,7 +408,7 @@ func (s *DockerSuite) TestEventsCommit(c *check.C) {
assert.Assert(c, strings.Contains(out, "commit"), "Missing 'commit' log event") assert.Assert(c, strings.Contains(out, "commit"), "Missing 'commit' log event")
} }
func (s *DockerSuite) TestEventsCopy(c *check.C) { func (s *DockerSuite) TestEventsCopy(c *testing.T) {
// Build a test image. // Build a test image.
buildImageSuccessfully(c, "cpimg", build.WithDockerfile(` buildImageSuccessfully(c, "cpimg", build.WithDockerfile(`
FROM busybox FROM busybox
@ -437,7 +437,7 @@ func (s *DockerSuite) TestEventsCopy(c *check.C) {
assert.Assert(c, strings.Contains(out, "extract-to-dir"), "Missing 'extract-to-dir' log event") assert.Assert(c, strings.Contains(out, "extract-to-dir"), "Missing 'extract-to-dir' log event")
} }
func (s *DockerSuite) TestEventsResize(c *check.C) { func (s *DockerSuite) TestEventsResize(c *testing.T) {
out := runSleepingContainer(c, "-d") out := runSleepingContainer(c, "-d")
cID := strings.TrimSpace(out) cID := strings.TrimSpace(out)
assert.NilError(c, waitRun(cID)) assert.NilError(c, waitRun(cID))
@ -460,7 +460,7 @@ func (s *DockerSuite) TestEventsResize(c *check.C) {
assert.Assert(c, strings.Contains(out, "resize"), "Missing 'resize' log event") assert.Assert(c, strings.Contains(out, "resize"), "Missing 'resize' log event")
} }
func (s *DockerSuite) TestEventsAttach(c *check.C) { func (s *DockerSuite) TestEventsAttach(c *testing.T) {
// TODO Windows CI: Figure out why this test fails intermittently (TP5). // TODO Windows CI: Figure out why this test fails intermittently (TP5).
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -498,7 +498,7 @@ func (s *DockerSuite) TestEventsAttach(c *check.C) {
assert.Assert(c, strings.Contains(out, "attach"), "Missing 'attach' log event") assert.Assert(c, strings.Contains(out, "attach"), "Missing 'attach' log event")
} }
func (s *DockerSuite) TestEventsRename(c *check.C) { func (s *DockerSuite) TestEventsRename(c *testing.T) {
out, _ := dockerCmd(c, "run", "--name", "oldName", "busybox", "true") out, _ := dockerCmd(c, "run", "--name", "oldName", "busybox", "true")
cID := strings.TrimSpace(out) cID := strings.TrimSpace(out)
dockerCmd(c, "rename", "oldName", "newName") dockerCmd(c, "rename", "oldName", "newName")
@ -509,7 +509,7 @@ func (s *DockerSuite) TestEventsRename(c *check.C) {
assert.Assert(c, strings.Contains(out, "rename"), "Missing 'rename' log event") assert.Assert(c, strings.Contains(out, "rename"), "Missing 'rename' log event")
} }
func (s *DockerSuite) TestEventsTop(c *check.C) { func (s *DockerSuite) TestEventsTop(c *testing.T) {
// Problematic on Windows as Windows does not support top // Problematic on Windows as Windows does not support top
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -526,7 +526,7 @@ func (s *DockerSuite) TestEventsTop(c *check.C) {
} }
// #14316 // #14316
func (s *DockerRegistrySuite) TestEventsImageFilterPush(c *check.C) { func (s *DockerRegistrySuite) TestEventsImageFilterPush(c *testing.T) {
// Problematic to port for Windows CI during TP5 timeframe until // Problematic to port for Windows CI during TP5 timeframe until
// supporting push // supporting push
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -546,7 +546,7 @@ func (s *DockerRegistrySuite) TestEventsImageFilterPush(c *check.C) {
assert.Assert(c, strings.Contains(out, repoName), "Missing 'push' log event for %s", repoName) assert.Assert(c, strings.Contains(out, repoName), "Missing 'push' log event for %s", repoName)
} }
func (s *DockerSuite) TestEventsFilterType(c *check.C) { func (s *DockerSuite) TestEventsFilterType(c *testing.T) {
// FIXME(vdemeester) fails on e2e run // FIXME(vdemeester) fails on e2e run
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
since := daemonUnixTime(c) since := daemonUnixTime(c)
@ -600,7 +600,7 @@ func (s *DockerSuite) TestEventsFilterType(c *check.C) {
} }
// #25798 // #25798
func (s *DockerSuite) TestEventsSpecialFiltersWithExecCreate(c *check.C) { func (s *DockerSuite) TestEventsSpecialFiltersWithExecCreate(c *testing.T) {
since := daemonUnixTime(c) since := daemonUnixTime(c)
runSleepingContainer(c, "--name", "test-container", "-d") runSleepingContainer(c, "--name", "test-container", "-d")
waitRun("test-container") waitRun("test-container")
@ -630,7 +630,7 @@ func (s *DockerSuite) TestEventsSpecialFiltersWithExecCreate(c *check.C) {
assert.Equal(c, len(events), 1, out) assert.Equal(c, len(events), 1, out)
} }
func (s *DockerSuite) TestEventsFilterImageInContainerAction(c *check.C) { func (s *DockerSuite) TestEventsFilterImageInContainerAction(c *testing.T) {
since := daemonUnixTime(c) since := daemonUnixTime(c)
dockerCmd(c, "run", "--name", "test-container", "-d", "busybox", "true") dockerCmd(c, "run", "--name", "test-container", "-d", "busybox", "true")
waitRun("test-container") waitRun("test-container")
@ -640,7 +640,7 @@ func (s *DockerSuite) TestEventsFilterImageInContainerAction(c *check.C) {
assert.Assert(c, len(events) > 1, out) assert.Assert(c, len(events) > 1, out)
} }
func (s *DockerSuite) TestEventsContainerRestart(c *check.C) { func (s *DockerSuite) TestEventsContainerRestart(c *testing.T) {
dockerCmd(c, "run", "-d", "--name=testEvent", "--restart=on-failure:3", "busybox", "false") dockerCmd(c, "run", "-d", "--name=testEvent", "--restart=on-failure:3", "busybox", "false")
// wait until test2 is auto removed. // wait until test2 is auto removed.
@ -680,7 +680,7 @@ func (s *DockerSuite) TestEventsContainerRestart(c *check.C) {
assert.Equal(c, dieCount, 4, "testEvent should die 4 times: %v", actions) assert.Equal(c, dieCount, 4, "testEvent should die 4 times: %v", actions)
} }
func (s *DockerSuite) TestEventsSinceInTheFuture(c *check.C) { func (s *DockerSuite) TestEventsSinceInTheFuture(c *testing.T) {
dockerCmd(c, "run", "--name", "test-container", "-d", "busybox", "true") dockerCmd(c, "run", "--name", "test-container", "-d", "busybox", "true")
waitRun("test-container") waitRun("test-container")
@ -692,7 +692,7 @@ func (s *DockerSuite) TestEventsSinceInTheFuture(c *check.C) {
assert.Assert(c, strings.Contains(out, "cannot be after `until`")) assert.Assert(c, strings.Contains(out, "cannot be after `until`"))
} }
func (s *DockerSuite) TestEventsUntilInThePast(c *check.C) { func (s *DockerSuite) TestEventsUntilInThePast(c *testing.T) {
since := daemonUnixTime(c) since := daemonUnixTime(c)
dockerCmd(c, "run", "--name", "test-container", "-d", "busybox", "true") dockerCmd(c, "run", "--name", "test-container", "-d", "busybox", "true")
@ -709,7 +709,7 @@ func (s *DockerSuite) TestEventsUntilInThePast(c *check.C) {
assert.Assert(c, strings.Contains(out, "test-container")) assert.Assert(c, strings.Contains(out, "test-container"))
} }
func (s *DockerSuite) TestEventsFormat(c *check.C) { func (s *DockerSuite) TestEventsFormat(c *testing.T) {
since := daemonUnixTime(c) since := daemonUnixTime(c)
dockerCmd(c, "run", "--rm", "busybox", "true") dockerCmd(c, "run", "--rm", "busybox", "true")
dockerCmd(c, "run", "--rm", "busybox", "true") dockerCmd(c, "run", "--rm", "busybox", "true")
@ -732,7 +732,7 @@ func (s *DockerSuite) TestEventsFormat(c *check.C) {
assert.Equal(c, startCount, 2, "should have had 2 start events but had %d, out: %s", startCount, out) assert.Equal(c, startCount, 2, "should have had 2 start events but had %d, out: %s", startCount, out)
} }
func (s *DockerSuite) TestEventsFormatBadFunc(c *check.C) { func (s *DockerSuite) TestEventsFormatBadFunc(c *testing.T) {
// make sure it fails immediately, without receiving any event // make sure it fails immediately, without receiving any event
result := dockerCmdWithResult("events", "--format", "{{badFuncString .}}") result := dockerCmdWithResult("events", "--format", "{{badFuncString .}}")
result.Assert(c, icmd.Expected{ result.Assert(c, icmd.Expected{
@ -742,7 +742,7 @@ func (s *DockerSuite) TestEventsFormatBadFunc(c *check.C) {
}) })
} }
func (s *DockerSuite) TestEventsFormatBadField(c *check.C) { func (s *DockerSuite) TestEventsFormatBadField(c *testing.T) {
// make sure it fails immediately, without receiving any event // make sure it fails immediately, without receiving any event
result := dockerCmdWithResult("events", "--format", "{{.badFieldString}}") result := dockerCmdWithResult("events", "--format", "{{.badFieldString}}")
result.Assert(c, icmd.Expected{ result.Assert(c, icmd.Expected{

View file

@ -21,7 +21,7 @@ import (
) )
// #5979 // #5979
func (s *DockerSuite) TestEventsRedirectStdout(c *check.C) { func (s *DockerSuite) TestEventsRedirectStdout(c *testing.T) {
since := daemonUnixTime(c) since := daemonUnixTime(c)
dockerCmd(c, "run", "busybox", "true") dockerCmd(c, "run", "busybox", "true")
@ -47,7 +47,7 @@ func (s *DockerSuite) TestEventsRedirectStdout(c *check.C) {
assert.NilError(c, scanner.Err(), "Scan err for command %q", command) assert.NilError(c, scanner.Err(), "Scan err for command %q", command)
} }
func (s *DockerSuite) TestEventsOOMDisableFalse(c *check.C) { func (s *DockerSuite) TestEventsOOMDisableFalse(c *testing.T) {
testRequires(c, DaemonIsLinux, oomControl, memoryLimitSupport, swapMemorySupport, NotPpc64le) testRequires(c, DaemonIsLinux, oomControl, memoryLimitSupport, swapMemorySupport, NotPpc64le)
errChan := make(chan error) errChan := make(chan error)
@ -77,7 +77,7 @@ func (s *DockerSuite) TestEventsOOMDisableFalse(c *check.C) {
assert.Equal(c, parseEventAction(c, events[nEvents-1]), "die") assert.Equal(c, parseEventAction(c, events[nEvents-1]), "die")
} }
func (s *DockerSuite) TestEventsOOMDisableTrue(c *check.C) { func (s *DockerSuite) TestEventsOOMDisableTrue(c *testing.T) {
testRequires(c, DaemonIsLinux, oomControl, memoryLimitSupport, NotArm, swapMemorySupport, NotPpc64le) testRequires(c, DaemonIsLinux, oomControl, memoryLimitSupport, NotArm, swapMemorySupport, NotPpc64le)
errChan := make(chan error) errChan := make(chan error)
@ -125,7 +125,7 @@ func (s *DockerSuite) TestEventsOOMDisableTrue(c *check.C) {
} }
// #18453 // #18453
func (s *DockerSuite) TestEventsContainerFilterByName(c *check.C) { func (s *DockerSuite) TestEventsContainerFilterByName(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
cOut, _ := dockerCmd(c, "run", "--name=foo", "-d", "busybox", "top") cOut, _ := dockerCmd(c, "run", "--name=foo", "-d", "busybox", "top")
c1 := strings.TrimSpace(cOut) c1 := strings.TrimSpace(cOut)
@ -139,7 +139,7 @@ func (s *DockerSuite) TestEventsContainerFilterByName(c *check.C) {
} }
// #18453 // #18453
func (s *DockerSuite) TestEventsContainerFilterBeforeCreate(c *check.C) { func (s *DockerSuite) TestEventsContainerFilterBeforeCreate(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
cmd := exec.Command(dockerBinary, "events", "-f", "container=foo", "--since=0") cmd := exec.Command(dockerBinary, "events", "-f", "container=foo", "--since=0")
@ -164,7 +164,7 @@ func (s *DockerSuite) TestEventsContainerFilterBeforeCreate(c *check.C) {
} }
} }
func (s *DockerSuite) TestVolumeEvents(c *check.C) { func (s *DockerSuite) TestVolumeEvents(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
since := daemonUnixTime(c) since := daemonUnixTime(c)
@ -192,7 +192,7 @@ func (s *DockerSuite) TestVolumeEvents(c *check.C) {
assert.Equal(c, volumeEvents[4], "destroy") assert.Equal(c, volumeEvents[4], "destroy")
} }
func (s *DockerSuite) TestNetworkEvents(c *check.C) { func (s *DockerSuite) TestNetworkEvents(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
since := daemonUnixTime(c) since := daemonUnixTime(c)
@ -219,7 +219,7 @@ func (s *DockerSuite) TestNetworkEvents(c *check.C) {
assert.Equal(c, netEvents[3], "destroy") assert.Equal(c, netEvents[3], "destroy")
} }
func (s *DockerSuite) TestEventsContainerWithMultiNetwork(c *check.C) { func (s *DockerSuite) TestEventsContainerWithMultiNetwork(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
// Observe create/connect network actions // Observe create/connect network actions
@ -247,7 +247,7 @@ func (s *DockerSuite) TestEventsContainerWithMultiNetwork(c *check.C) {
assert.Assert(c, strings.Contains(out, "test-event-network-local-2")) assert.Assert(c, strings.Contains(out, "test-event-network-local-2"))
} }
func (s *DockerSuite) TestEventsStreaming(c *check.C) { func (s *DockerSuite) TestEventsStreaming(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
observer, err := newEventObserver(c) observer, err := newEventObserver(c)
@ -301,7 +301,7 @@ func (s *DockerSuite) TestEventsStreaming(c *check.C) {
} }
} }
func (s *DockerSuite) TestEventsImageUntagDelete(c *check.C) { func (s *DockerSuite) TestEventsImageUntagDelete(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
observer, err := newEventObserver(c) observer, err := newEventObserver(c)
@ -340,7 +340,7 @@ func (s *DockerSuite) TestEventsImageUntagDelete(c *check.C) {
} }
} }
func (s *DockerSuite) TestEventsFilterVolumeAndNetworkType(c *check.C) { func (s *DockerSuite) TestEventsFilterVolumeAndNetworkType(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
since := daemonUnixTime(c) since := daemonUnixTime(c)
@ -359,7 +359,7 @@ func (s *DockerSuite) TestEventsFilterVolumeAndNetworkType(c *check.C) {
assert.Equal(c, networkActions[0], "create") assert.Equal(c, networkActions[0], "create")
} }
func (s *DockerSuite) TestEventsFilterVolumeID(c *check.C) { func (s *DockerSuite) TestEventsFilterVolumeID(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
since := daemonUnixTime(c) since := daemonUnixTime(c)
@ -374,7 +374,7 @@ func (s *DockerSuite) TestEventsFilterVolumeID(c *check.C) {
assert.Assert(c, strings.Contains(events[0], "driver=local")) assert.Assert(c, strings.Contains(events[0], "driver=local"))
} }
func (s *DockerSuite) TestEventsFilterNetworkID(c *check.C) { func (s *DockerSuite) TestEventsFilterNetworkID(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
since := daemonUnixTime(c) since := daemonUnixTime(c)
@ -387,7 +387,7 @@ func (s *DockerSuite) TestEventsFilterNetworkID(c *check.C) {
assert.Assert(c, strings.Contains(events[0], "type=bridge")) assert.Assert(c, strings.Contains(events[0], "type=bridge"))
} }
func (s *DockerDaemonSuite) TestDaemonEvents(c *check.C) { func (s *DockerDaemonSuite) TestDaemonEvents(c *testing.T) {
// daemon config file // daemon config file
configFilePath := "test.json" configFilePath := "test.json"
@ -455,7 +455,7 @@ func (s *DockerDaemonSuite) TestDaemonEvents(c *check.C) {
} }
} }
func (s *DockerDaemonSuite) TestDaemonEventsWithFilters(c *check.C) { func (s *DockerDaemonSuite) TestDaemonEventsWithFilters(c *testing.T) {
// daemon config file // daemon config file
configFilePath := "test.json" configFilePath := "test.json"

View file

@ -22,7 +22,7 @@ import (
"gotest.tools/icmd" "gotest.tools/icmd"
) )
func (s *DockerSuite) TestExec(c *check.C) { func (s *DockerSuite) TestExec(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "sh", "-c", "echo test > /tmp/file && top") out, _ := dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "sh", "-c", "echo test > /tmp/file && top")
assert.NilError(c, waitRun(strings.TrimSpace(out))) assert.NilError(c, waitRun(strings.TrimSpace(out)))
@ -31,7 +31,7 @@ func (s *DockerSuite) TestExec(c *check.C) {
assert.Equal(c, strings.Trim(out, "\r\n"), "test") assert.Equal(c, strings.Trim(out, "\r\n"), "test")
} }
func (s *DockerSuite) TestExecInteractive(c *check.C) { func (s *DockerSuite) TestExecInteractive(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "sh", "-c", "echo test > /tmp/file && top") dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "sh", "-c", "echo test > /tmp/file && top")
@ -67,7 +67,7 @@ func (s *DockerSuite) TestExecInteractive(c *check.C) {
} }
func (s *DockerSuite) TestExecAfterContainerRestart(c *check.C) { func (s *DockerSuite) TestExecAfterContainerRestart(c *testing.T) {
out := runSleepingContainer(c) out := runSleepingContainer(c)
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
assert.NilError(c, waitRun(cleanedContainerID)) assert.NilError(c, waitRun(cleanedContainerID))
@ -78,7 +78,7 @@ func (s *DockerSuite) TestExecAfterContainerRestart(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "hello") assert.Equal(c, strings.TrimSpace(out), "hello")
} }
func (s *DockerDaemonSuite) TestExecAfterDaemonRestart(c *check.C) { func (s *DockerDaemonSuite) TestExecAfterDaemonRestart(c *testing.T) {
// TODO Windows CI: DockerDaemonSuite doesn't run on Windows, and requires a little work to get this ported. // TODO Windows CI: DockerDaemonSuite doesn't run on Windows, and requires a little work to get this ported.
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
@ -96,7 +96,7 @@ func (s *DockerDaemonSuite) TestExecAfterDaemonRestart(c *check.C) {
} }
// Regression test for #9155, #9044 // Regression test for #9155, #9044
func (s *DockerSuite) TestExecEnv(c *check.C) { func (s *DockerSuite) TestExecEnv(c *testing.T) {
// TODO Windows CI: This one is interesting and may just end up being a feature // TODO Windows CI: This one is interesting and may just end up being a feature
// difference between Windows and Linux. On Windows, the environment is passed // difference between Windows and Linux. On Windows, the environment is passed
// into the process that is launched, not into the machine environment. Hence // into the process that is launched, not into the machine environment. Hence
@ -111,7 +111,7 @@ func (s *DockerSuite) TestExecEnv(c *check.C) {
assert.Check(c, strings.Contains(out, "HOME=/root")) assert.Check(c, strings.Contains(out, "HOME=/root"))
} }
func (s *DockerSuite) TestExecSetEnv(c *check.C) { func (s *DockerSuite) TestExecSetEnv(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
runSleepingContainer(c, "-e", "HOME=/root", "-d", "--name", "testing") runSleepingContainer(c, "-e", "HOME=/root", "-d", "--name", "testing")
assert.NilError(c, waitRun("testing")) assert.NilError(c, waitRun("testing"))
@ -122,14 +122,14 @@ func (s *DockerSuite) TestExecSetEnv(c *check.C) {
assert.Check(c, strings.Contains(out, "ABC=xyz")) assert.Check(c, strings.Contains(out, "ABC=xyz"))
} }
func (s *DockerSuite) TestExecExitStatus(c *check.C) { func (s *DockerSuite) TestExecExitStatus(c *testing.T) {
runSleepingContainer(c, "-d", "--name", "top") runSleepingContainer(c, "-d", "--name", "top")
result := icmd.RunCommand(dockerBinary, "exec", "top", "sh", "-c", "exit 23") result := icmd.RunCommand(dockerBinary, "exec", "top", "sh", "-c", "exit 23")
result.Assert(c, icmd.Expected{ExitCode: 23, Error: "exit status 23"}) result.Assert(c, icmd.Expected{ExitCode: 23, Error: "exit status 23"})
} }
func (s *DockerSuite) TestExecPausedContainer(c *check.C) { func (s *DockerSuite) TestExecPausedContainer(c *testing.T) {
testRequires(c, IsPausable) testRequires(c, IsPausable)
out := runSleepingContainer(c, "-d", "--name", "testing") out := runSleepingContainer(c, "-d", "--name", "testing")
@ -144,7 +144,7 @@ func (s *DockerSuite) TestExecPausedContainer(c *check.C) {
} }
// regression test for #9476 // regression test for #9476
func (s *DockerSuite) TestExecTTYCloseStdin(c *check.C) { func (s *DockerSuite) TestExecTTYCloseStdin(c *testing.T) {
// TODO Windows CI: This requires some work to port to Windows. // TODO Windows CI: This requires some work to port to Windows.
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "-it", "--name", "exec_tty_stdin", "busybox") dockerCmd(c, "run", "-d", "-it", "--name", "exec_tty_stdin", "busybox")
@ -165,7 +165,7 @@ func (s *DockerSuite) TestExecTTYCloseStdin(c *check.C) {
assert.Assert(c, !strings.Contains(out, "nsenter-exec")) assert.Assert(c, !strings.Contains(out, "nsenter-exec"))
} }
func (s *DockerSuite) TestExecTTYWithoutStdin(c *check.C) { func (s *DockerSuite) TestExecTTYWithoutStdin(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "-ti", "busybox") out, _ := dockerCmd(c, "run", "-d", "-ti", "busybox")
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
assert.NilError(c, waitRun(id)) assert.NilError(c, waitRun(id))
@ -202,7 +202,7 @@ func (s *DockerSuite) TestExecTTYWithoutStdin(c *check.C) {
} }
// FIXME(vdemeester) this should be a unit tests on cli/command/container package // FIXME(vdemeester) this should be a unit tests on cli/command/container package
func (s *DockerSuite) TestExecParseError(c *check.C) { func (s *DockerSuite) TestExecParseError(c *testing.T) {
// TODO Windows CI: Requires some extra work. Consider copying the // TODO Windows CI: Requires some extra work. Consider copying the
// runSleepingContainer helper to have an exec version. // runSleepingContainer helper to have an exec version.
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -216,7 +216,7 @@ func (s *DockerSuite) TestExecParseError(c *check.C) {
}) })
} }
func (s *DockerSuite) TestExecStopNotHanging(c *check.C) { func (s *DockerSuite) TestExecStopNotHanging(c *testing.T) {
// TODO Windows CI: Requires some extra work. Consider copying the // TODO Windows CI: Requires some extra work. Consider copying the
// runSleepingContainer helper to have an exec version. // runSleepingContainer helper to have an exec version.
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -244,7 +244,7 @@ func (s *DockerSuite) TestExecStopNotHanging(c *check.C) {
} }
} }
func (s *DockerSuite) TestExecCgroup(c *check.C) { func (s *DockerSuite) TestExecCgroup(c *testing.T) {
// Not applicable on Windows - using Linux specific functionality // Not applicable on Windows - using Linux specific functionality
testRequires(c, NotUserNamespace) testRequires(c, NotUserNamespace)
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -297,7 +297,7 @@ func (s *DockerSuite) TestExecCgroup(c *check.C) {
} }
} }
func (s *DockerSuite) TestExecInspectID(c *check.C) { func (s *DockerSuite) TestExecInspectID(c *testing.T) {
out := runSleepingContainer(c, "-d") out := runSleepingContainer(c, "-d")
id := strings.TrimSuffix(out, "\n") id := strings.TrimSuffix(out, "\n")
@ -364,7 +364,7 @@ func (s *DockerSuite) TestExecInspectID(c *check.C) {
assert.ErrorContains(c, err, "No such exec instance") assert.ErrorContains(c, err, "No such exec instance")
} }
func (s *DockerSuite) TestLinksPingLinkedContainersOnRename(c *check.C) { func (s *DockerSuite) TestLinksPingLinkedContainersOnRename(c *testing.T) {
// Problematic on Windows as Windows does not support links // Problematic on Windows as Windows does not support links
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
var out string var out string
@ -380,7 +380,7 @@ func (s *DockerSuite) TestLinksPingLinkedContainersOnRename(c *check.C) {
dockerCmd(c, "exec", "container2", "ping", "-c", "1", "alias1", "-W", "1") dockerCmd(c, "exec", "container2", "ping", "-c", "1", "alias1", "-W", "1")
} }
func (s *DockerSuite) TestRunMutableNetworkFiles(c *check.C) { func (s *DockerSuite) TestRunMutableNetworkFiles(c *testing.T) {
// Not applicable on Windows to Windows CI. // Not applicable on Windows to Windows CI.
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
for _, fn := range []string{"resolv.conf", "hosts"} { for _, fn := range []string{"resolv.conf", "hosts"} {
@ -421,7 +421,7 @@ func (s *DockerSuite) TestRunMutableNetworkFiles(c *check.C) {
} }
} }
func (s *DockerSuite) TestExecWithUser(c *check.C) { func (s *DockerSuite) TestExecWithUser(c *testing.T) {
// TODO Windows CI: This may be fixable in the future once Windows // TODO Windows CI: This may be fixable in the future once Windows
// supports users // supports users
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -434,7 +434,7 @@ func (s *DockerSuite) TestExecWithUser(c *check.C) {
assert.Assert(c, strings.Contains(out, "uid=0(root) gid=0(root)"), "exec with user by id expected daemon user got %s", out) assert.Assert(c, strings.Contains(out, "uid=0(root) gid=0(root)"), "exec with user by id expected daemon user got %s", out)
} }
func (s *DockerSuite) TestExecWithPrivileged(c *check.C) { func (s *DockerSuite) TestExecWithPrivileged(c *testing.T) {
// Not applicable on Windows // Not applicable on Windows
testRequires(c, DaemonIsLinux, NotUserNamespace) testRequires(c, DaemonIsLinux, NotUserNamespace)
// Start main loop which attempts mknod repeatedly // Start main loop which attempts mknod repeatedly
@ -464,7 +464,7 @@ func (s *DockerSuite) TestExecWithPrivileged(c *check.C) {
assert.Assert(c, !strings.Contains(result.Combined(), "Success")) assert.Assert(c, !strings.Contains(result.Combined(), "Success"))
} }
func (s *DockerSuite) TestExecWithImageUser(c *check.C) { func (s *DockerSuite) TestExecWithImageUser(c *testing.T) {
// Not applicable on Windows // Not applicable on Windows
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "testbuilduser" name := "testbuilduser"
@ -477,7 +477,7 @@ func (s *DockerSuite) TestExecWithImageUser(c *check.C) {
assert.Assert(c, strings.Contains(out, "dockerio"), "exec with user by id expected dockerio user got %s", out) assert.Assert(c, strings.Contains(out, "dockerio"), "exec with user by id expected dockerio user got %s", out)
} }
func (s *DockerSuite) TestExecOnReadonlyContainer(c *check.C) { func (s *DockerSuite) TestExecOnReadonlyContainer(c *testing.T) {
// Windows does not support read-only // Windows does not support read-only
// --read-only + userns has remount issues // --read-only + userns has remount issues
testRequires(c, DaemonIsLinux, NotUserNamespace) testRequires(c, DaemonIsLinux, NotUserNamespace)
@ -485,7 +485,7 @@ func (s *DockerSuite) TestExecOnReadonlyContainer(c *check.C) {
dockerCmd(c, "exec", "parent", "true") dockerCmd(c, "exec", "parent", "true")
} }
func (s *DockerSuite) TestExecUlimits(c *check.C) { func (s *DockerSuite) TestExecUlimits(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "testexeculimits" name := "testexeculimits"
runSleepingContainer(c, "-d", "--ulimit", "nofile=511:511", "--name", name) runSleepingContainer(c, "-d", "--ulimit", "nofile=511:511", "--name", name)
@ -497,7 +497,7 @@ func (s *DockerSuite) TestExecUlimits(c *check.C) {
} }
// #15750 // #15750
func (s *DockerSuite) TestExecStartFails(c *check.C) { func (s *DockerSuite) TestExecStartFails(c *testing.T) {
// TODO Windows CI. This test should be portable. Figure out why it fails // TODO Windows CI. This test should be portable. Figure out why it fails
// currently. // currently.
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -511,7 +511,7 @@ func (s *DockerSuite) TestExecStartFails(c *check.C) {
} }
// Fix regression in https://github.com/docker/docker/pull/26461#issuecomment-250287297 // Fix regression in https://github.com/docker/docker/pull/26461#issuecomment-250287297
func (s *DockerSuite) TestExecWindowsPathNotWiped(c *check.C) { func (s *DockerSuite) TestExecWindowsPathNotWiped(c *testing.T) {
testRequires(c, DaemonIsWindows) testRequires(c, DaemonIsWindows)
out, _ := dockerCmd(c, "run", "-d", "--name", "testing", minimalBaseImage(), "powershell", "start-sleep", "60") out, _ := dockerCmd(c, "run", "-d", "--name", "testing", minimalBaseImage(), "powershell", "start-sleep", "60")
assert.NilError(c, waitRun(strings.TrimSpace(out))) assert.NilError(c, waitRun(strings.TrimSpace(out)))
@ -521,7 +521,7 @@ func (s *DockerSuite) TestExecWindowsPathNotWiped(c *check.C) {
assert.Assert(c, strings.Contains(out, `windowspowershell\v1.0`)) assert.Assert(c, strings.Contains(out, `windowspowershell\v1.0`))
} }
func (s *DockerSuite) TestExecEnvLinksHost(c *check.C) { func (s *DockerSuite) TestExecEnvLinksHost(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
runSleepingContainer(c, "-d", "--name", "foo") runSleepingContainer(c, "-d", "--name", "foo")
runSleepingContainer(c, "-d", "--link", "foo:db", "--hostname", "myhost", "--name", "bar") runSleepingContainer(c, "-d", "--link", "foo:db", "--hostname", "myhost", "--name", "bar")

View file

@ -15,7 +15,7 @@ import (
) )
// regression test for #12546 // regression test for #12546
func (s *DockerSuite) TestExecInteractiveStdinClose(c *check.C) { func (s *DockerSuite) TestExecInteractiveStdinClose(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-itd", "busybox", "/bin/cat") out, _ := dockerCmd(c, "run", "-itd", "busybox", "/bin/cat")
contID := strings.TrimSpace(out) contID := strings.TrimSpace(out)
@ -44,7 +44,7 @@ func (s *DockerSuite) TestExecInteractiveStdinClose(c *check.C) {
} }
} }
func (s *DockerSuite) TestExecTTY(c *check.C) { func (s *DockerSuite) TestExecTTY(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
dockerCmd(c, "run", "-d", "--name=test", "busybox", "sh", "-c", "echo hello > /foo && top") dockerCmd(c, "run", "-d", "--name=test", "busybox", "sh", "-c", "echo hello > /foo && top")
@ -74,7 +74,7 @@ func (s *DockerSuite) TestExecTTY(c *check.C) {
} }
// Test the TERM env var is set when -t is provided on exec // Test the TERM env var is set when -t is provided on exec
func (s *DockerSuite) TestExecWithTERM(c *check.C) { func (s *DockerSuite) TestExecWithTERM(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
out, _ := dockerCmd(c, "run", "-id", "busybox", "/bin/cat") out, _ := dockerCmd(c, "run", "-id", "busybox", "/bin/cat")
contID := strings.TrimSpace(out) contID := strings.TrimSpace(out)
@ -86,7 +86,7 @@ func (s *DockerSuite) TestExecWithTERM(c *check.C) {
// Test that the TERM env var is not set on exec when -t is not provided, even if it was set // Test that the TERM env var is not set on exec when -t is not provided, even if it was set
// on run // on run
func (s *DockerSuite) TestExecWithNoTERM(c *check.C) { func (s *DockerSuite) TestExecWithNoTERM(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
out, _ := dockerCmd(c, "run", "-itd", "busybox", "/bin/cat") out, _ := dockerCmd(c, "run", "-itd", "busybox", "/bin/cat")
contID := strings.TrimSpace(out) contID := strings.TrimSpace(out)

View file

@ -51,20 +51,20 @@ type DockerExternalVolumeSuite struct {
*volumePlugin *volumePlugin
} }
func (s *DockerExternalVolumeSuite) SetUpTest(c *check.C) { func (s *DockerExternalVolumeSuite) SetUpTest(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
s.ec = &eventCounter{} s.ec = &eventCounter{}
} }
func (s *DockerExternalVolumeSuite) TearDownTest(c *check.C) { func (s *DockerExternalVolumeSuite) TearDownTest(c *testing.T) {
if s.d != nil { if s.d != nil {
s.d.Stop(c) s.d.Stop(c)
s.ds.TearDownTest(c) s.ds.TearDownTest(c)
} }
} }
func (s *DockerExternalVolumeSuite) SetUpSuite(c *check.C) { func (s *DockerExternalVolumeSuite) SetUpSuite(c *testing.T) {
s.volumePlugin = newVolumePlugin(c, volumePluginName) s.volumePlugin = newVolumePlugin(c, volumePluginName)
} }
@ -86,7 +86,7 @@ func (p *volumePlugin) Close() {
p.Server.Close() p.Server.Close()
} }
func newVolumePlugin(c *check.C, name string) *volumePlugin { func newVolumePlugin(c *testing.T, name string) *volumePlugin {
mux := http.NewServeMux() mux := http.NewServeMux()
s := &volumePlugin{Server: httptest.NewServer(mux), ec: &eventCounter{}, vols: make(map[string]vol)} s := &volumePlugin{Server: httptest.NewServer(mux), ec: &eventCounter{}, vols: make(map[string]vol)}
@ -276,14 +276,14 @@ func newVolumePlugin(c *check.C, name string) *volumePlugin {
return s return s
} }
func (s *DockerExternalVolumeSuite) TearDownSuite(c *check.C) { func (s *DockerExternalVolumeSuite) TearDownSuite(c *testing.T) {
s.volumePlugin.Close() s.volumePlugin.Close()
err := os.RemoveAll("/etc/docker/plugins") err := os.RemoveAll("/etc/docker/plugins")
assert.NilError(c, err) assert.NilError(c, err)
} }
func (s *DockerExternalVolumeSuite) TestVolumeCLICreateOptionConflict(c *check.C) { func (s *DockerExternalVolumeSuite) TestVolumeCLICreateOptionConflict(c *testing.T) {
dockerCmd(c, "volume", "create", "test") dockerCmd(c, "volume", "create", "test")
out, _, err := dockerCmdWithError("volume", "create", "test", "--driver", volumePluginName) out, _, err := dockerCmdWithError("volume", "create", "test", "--driver", volumePluginName)
@ -295,7 +295,7 @@ func (s *DockerExternalVolumeSuite) TestVolumeCLICreateOptionConflict(c *check.C
assert.NilError(c, err) assert.NilError(c, err)
} }
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverNamed(c *check.C) { func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverNamed(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "--rm", "--name", "test-data", "-v", "external-volume-test:/tmp/external-volume-test", "--volume-driver", volumePluginName, "busybox:latest", "cat", "/tmp/external-volume-test/test") out, err := s.d.Cmd("run", "--rm", "--name", "test-data", "-v", "external-volume-test:/tmp/external-volume-test", "--volume-driver", volumePluginName, "busybox:latest", "cat", "/tmp/external-volume-test/test")
@ -317,7 +317,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverNamed(c *check.C) {
assert.Assert(c, s.ec.unmounts, checker.Equals, 1) assert.Assert(c, s.ec.unmounts, checker.Equals, 1)
} }
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnnamed(c *check.C) { func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnnamed(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "--rm", "--name", "test-data", "-v", "/tmp/external-volume-test", "--volume-driver", volumePluginName, "busybox:latest", "cat", "/tmp/external-volume-test/test") out, err := s.d.Cmd("run", "--rm", "--name", "test-data", "-v", "/tmp/external-volume-test", "--volume-driver", volumePluginName, "busybox:latest", "cat", "/tmp/external-volume-test/test")
@ -331,7 +331,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnnamed(c *check.C)
assert.Assert(c, s.ec.unmounts, checker.Equals, 1) assert.Assert(c, s.ec.unmounts, checker.Equals, 1)
} }
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverVolumesFrom(c *check.C) { func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverVolumesFrom(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "--name", "vol-test1", "-v", "/foo", "--volume-driver", volumePluginName, "busybox:latest") out, err := s.d.Cmd("run", "--name", "vol-test1", "-v", "/foo", "--volume-driver", volumePluginName, "busybox:latest")
@ -350,7 +350,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverVolumesFrom(c *check
assert.Assert(c, s.ec.unmounts, checker.Equals, 2) assert.Assert(c, s.ec.unmounts, checker.Equals, 2)
} }
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverDeleteContainer(c *check.C) { func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverDeleteContainer(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "--name", "vol-test1", "-v", "/foo", "--volume-driver", volumePluginName, "busybox:latest") out, err := s.d.Cmd("run", "--name", "vol-test1", "-v", "/foo", "--volume-driver", volumePluginName, "busybox:latest")
@ -371,7 +371,7 @@ func hostVolumePath(name string) string {
} }
// Make sure a request to use a down driver doesn't block other requests // Make sure a request to use a down driver doesn't block other requests
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverLookupNotBlocked(c *check.C) { func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverLookupNotBlocked(c *testing.T) {
specPath := "/etc/docker/plugins/down-driver.spec" specPath := "/etc/docker/plugins/down-driver.spec"
err := ioutil.WriteFile(specPath, []byte("tcp://127.0.0.7:9999"), 0644) err := ioutil.WriteFile(specPath, []byte("tcp://127.0.0.7:9999"), 0644)
assert.NilError(c, err) assert.NilError(c, err)
@ -407,7 +407,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverLookupNotBlocked(c *
} }
} }
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverRetryNotImmediatelyExists(c *check.C) { func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverRetryNotImmediatelyExists(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
driverName := "test-external-volume-driver-retry" driverName := "test-external-volume-driver-retry"
@ -444,7 +444,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverRetryNotImmediatelyE
assert.Assert(c, p.ec.unmounts, checker.Equals, 1) assert.Assert(c, p.ec.unmounts, checker.Equals, 1)
} }
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverBindExternalVolume(c *check.C) { func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverBindExternalVolume(c *testing.T) {
dockerCmd(c, "volume", "create", "-d", volumePluginName, "foo") dockerCmd(c, "volume", "create", "-d", volumePluginName, "foo")
dockerCmd(c, "run", "-d", "--name", "testing", "-v", "foo:/bar", "busybox", "top") dockerCmd(c, "run", "-d", "--name", "testing", "-v", "foo:/bar", "busybox", "top")
@ -459,7 +459,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverBindExternalVolume(c
assert.Assert(c, mounts[0].Driver, checker.Equals, volumePluginName) assert.Assert(c, mounts[0].Driver, checker.Equals, volumePluginName)
} }
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverList(c *check.C) { func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverList(c *testing.T) {
dockerCmd(c, "volume", "create", "-d", volumePluginName, "abc3") dockerCmd(c, "volume", "create", "-d", volumePluginName, "abc3")
out, _ := dockerCmd(c, "volume", "ls") out, _ := dockerCmd(c, "volume", "ls")
ls := strings.Split(strings.TrimSpace(out), "\n") ls := strings.Split(strings.TrimSpace(out), "\n")
@ -473,7 +473,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverList(c *check.C) {
assert.Assert(c, s.ec.lists, check.Equals, 1) assert.Assert(c, s.ec.lists, check.Equals, 1)
} }
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGet(c *check.C) { func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGet(c *testing.T) {
out, _, err := dockerCmdWithError("volume", "inspect", "dummy") out, _, err := dockerCmdWithError("volume", "inspect", "dummy")
assert.ErrorContains(c, err, "", out) assert.ErrorContains(c, err, "", out)
assert.Assert(c, out, checker.Contains, "No such volume") assert.Assert(c, out, checker.Contains, "No such volume")
@ -493,7 +493,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGet(c *check.C) {
assert.Assert(c, st[0].Status["Hello"], checker.Equals, "world", check.Commentf("%v", st[0].Status)) assert.Assert(c, st[0].Status["Hello"], checker.Equals, "world", check.Commentf("%v", st[0].Status))
} }
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverWithDaemonRestart(c *check.C) { func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverWithDaemonRestart(c *testing.T) {
dockerCmd(c, "volume", "create", "-d", volumePluginName, "abc1") dockerCmd(c, "volume", "create", "-d", volumePluginName, "abc1")
s.d.Restart(c) s.d.Restart(c)
@ -506,7 +506,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverWithDaemonRestart(c
// Ensures that the daemon handles when the plugin responds to a `Get` request with a null volume and a null error. // Ensures that the daemon handles when the plugin responds to a `Get` request with a null volume and a null error.
// Prior the daemon would panic in this scenario. // Prior the daemon would panic in this scenario.
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGetEmptyResponse(c *check.C) { func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGetEmptyResponse(c *testing.T) {
s.d.Start(c) s.d.Start(c)
out, err := s.d.Cmd("volume", "create", "-d", volumePluginName, "abc2", "--opt", "ninja=1") out, err := s.d.Cmd("volume", "create", "-d", volumePluginName, "abc2", "--opt", "ninja=1")
@ -521,7 +521,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGetEmptyResponse(c *
// //
// TODO(@cpuguy83): This test is testing internal implementation. In all the cases here, there may not even be a path // TODO(@cpuguy83): This test is testing internal implementation. In all the cases here, there may not even be a path
// available because the volume is not even mounted. Consider removing this test. // available because the volume is not even mounted. Consider removing this test.
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverPathCalls(c *check.C) { func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverPathCalls(c *testing.T) {
s.d.Start(c) s.d.Start(c)
assert.Assert(c, s.ec.paths, checker.Equals, 0) assert.Assert(c, s.ec.paths, checker.Equals, 0)
@ -534,7 +534,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverPathCalls(c *check.C
assert.Assert(c, s.ec.paths, checker.Equals, 0) assert.Assert(c, s.ec.paths, checker.Equals, 0)
} }
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverMountID(c *check.C) { func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverMountID(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "--rm", "-v", "external-volume-test:/tmp/external-volume-test", "--volume-driver", volumePluginName, "busybox:latest", "cat", "/tmp/external-volume-test/test") out, err := s.d.Cmd("run", "--rm", "-v", "external-volume-test:/tmp/external-volume-test", "--volume-driver", volumePluginName, "busybox:latest", "cat", "/tmp/external-volume-test/test")
@ -543,7 +543,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverMountID(c *check.C)
} }
// Check that VolumeDriver.Capabilities gets called, and only called once // Check that VolumeDriver.Capabilities gets called, and only called once
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverCapabilities(c *check.C) { func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverCapabilities(c *testing.T) {
s.d.Start(c) s.d.Start(c)
assert.Assert(c, s.ec.caps, checker.Equals, 0) assert.Assert(c, s.ec.caps, checker.Equals, 0)
@ -557,7 +557,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverCapabilities(c *chec
} }
} }
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverOutOfBandDelete(c *check.C) { func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverOutOfBandDelete(c *testing.T) {
driverName := stringid.GenerateRandomID() driverName := stringid.GenerateRandomID()
p := newVolumePlugin(c, driverName) p := newVolumePlugin(c, driverName)
defer p.Close() defer p.Close()
@ -606,7 +606,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverOutOfBandDelete(c *c
assert.Assert(c, vs[0].Driver, checker.Equals, "local") assert.Assert(c, vs[0].Driver, checker.Equals, "local")
} }
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnmountOnMountFail(c *check.C) { func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnmountOnMountFail(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
s.d.Cmd("volume", "create", "-d", "test-external-volume-driver", "--opt=invalidOption=1", "--name=testumount") s.d.Cmd("volume", "create", "-d", "test-external-volume-driver", "--opt=invalidOption=1", "--name=testumount")
@ -616,7 +616,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnmountOnMountFail(c
assert.Assert(c, s.ec.unmounts, checker.Equals, 0, check.Commentf("%s", out)) assert.Assert(c, s.ec.unmounts, checker.Equals, 0, check.Commentf("%s", out))
} }
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnmountOnCp(c *check.C) { func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnmountOnCp(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
s.d.Cmd("volume", "create", "-d", "test-external-volume-driver", "--name=test") s.d.Cmd("volume", "create", "-d", "test-external-volume-driver", "--name=test")

View file

@ -12,7 +12,7 @@ import (
"github.com/go-check/check" "github.com/go-check/check"
) )
func waitForHealthStatus(c *check.C, name string, prev string, expected string) { func waitForHealthStatus(c *testing.T, name string, prev string, expected string) {
prev = prev + "\n" prev = prev + "\n"
expected = expected + "\n" expected = expected + "\n"
for { for {
@ -28,7 +28,7 @@ func waitForHealthStatus(c *check.C, name string, prev string, expected string)
} }
} }
func getHealth(c *check.C, name string) *types.Health { func getHealth(c *testing.T, name string) *types.Health {
out, _ := dockerCmd(c, "inspect", "--format={{json .State.Health}}", name) out, _ := dockerCmd(c, "inspect", "--format={{json .State.Health}}", name)
var health types.Health var health types.Health
err := json.Unmarshal([]byte(out), &health) err := json.Unmarshal([]byte(out), &health)
@ -36,7 +36,7 @@ func getHealth(c *check.C, name string) *types.Health {
return &health return &health
} }
func (s *DockerSuite) TestHealth(c *check.C) { func (s *DockerSuite) TestHealth(c *testing.T) {
testRequires(c, DaemonIsLinux) // busybox doesn't work on Windows testRequires(c, DaemonIsLinux) // busybox doesn't work on Windows
existingContainers := ExistingContainerIDs(c) existingContainers := ExistingContainerIDs(c)
@ -144,7 +144,7 @@ func (s *DockerSuite) TestHealth(c *check.C) {
} }
// GitHub #33021 // GitHub #33021
func (s *DockerSuite) TestUnsetEnvVarHealthCheck(c *check.C) { func (s *DockerSuite) TestUnsetEnvVarHealthCheck(c *testing.T) {
testRequires(c, DaemonIsLinux) // busybox doesn't work on Windows testRequires(c, DaemonIsLinux) // busybox doesn't work on Windows
imageName := "testhealth" imageName := "testhealth"

View file

@ -13,7 +13,7 @@ import (
// This is a heisen-test. Because the created timestamp of images and the behavior of // This is a heisen-test. Because the created timestamp of images and the behavior of
// sort is not predictable it doesn't always fail. // sort is not predictable it doesn't always fail.
func (s *DockerSuite) TestBuildHistory(c *check.C) { func (s *DockerSuite) TestBuildHistory(c *testing.T) {
name := "testbuildhistory" name := "testbuildhistory"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+`
LABEL label.A="A" LABEL label.A="A"
@ -55,16 +55,16 @@ LABEL label.Z="Z"`))
} }
func (s *DockerSuite) TestHistoryExistentImage(c *check.C) { func (s *DockerSuite) TestHistoryExistentImage(c *testing.T) {
dockerCmd(c, "history", "busybox") dockerCmd(c, "history", "busybox")
} }
func (s *DockerSuite) TestHistoryNonExistentImage(c *check.C) { func (s *DockerSuite) TestHistoryNonExistentImage(c *testing.T) {
_, _, err := dockerCmdWithError("history", "testHistoryNonExistentImage") _, _, err := dockerCmdWithError("history", "testHistoryNonExistentImage")
assert.Assert(c, err, checker.NotNil, check.Commentf("history on a non-existent image should fail.")) assert.Assert(c, err, checker.NotNil, check.Commentf("history on a non-existent image should fail."))
} }
func (s *DockerSuite) TestHistoryImageWithComment(c *check.C) { func (s *DockerSuite) TestHistoryImageWithComment(c *testing.T) {
name := "testhistoryimagewithcomment" name := "testhistoryimagewithcomment"
// make an image through docker commit <container id> [ -m messages ] // make an image through docker commit <container id> [ -m messages ]
@ -83,7 +83,7 @@ func (s *DockerSuite) TestHistoryImageWithComment(c *check.C) {
assert.Assert(c, actualValue, checker.Contains, comment) assert.Assert(c, actualValue, checker.Contains, comment)
} }
func (s *DockerSuite) TestHistoryHumanOptionFalse(c *check.C) { func (s *DockerSuite) TestHistoryHumanOptionFalse(c *testing.T) {
out, _ := dockerCmd(c, "history", "--human=false", "busybox") out, _ := dockerCmd(c, "history", "--human=false", "busybox")
lines := strings.Split(out, "\n") lines := strings.Split(out, "\n")
sizeColumnRegex, _ := regexp.Compile("SIZE +") sizeColumnRegex, _ := regexp.Compile("SIZE +")
@ -101,7 +101,7 @@ func (s *DockerSuite) TestHistoryHumanOptionFalse(c *check.C) {
} }
} }
func (s *DockerSuite) TestHistoryHumanOptionTrue(c *check.C) { func (s *DockerSuite) TestHistoryHumanOptionTrue(c *testing.T) {
out, _ := dockerCmd(c, "history", "--human=true", "busybox") out, _ := dockerCmd(c, "history", "--human=true", "busybox")
lines := strings.Split(out, "\n") lines := strings.Split(out, "\n")
sizeColumnRegex, _ := regexp.Compile("SIZE +") sizeColumnRegex, _ := regexp.Compile("SIZE +")

View file

@ -19,12 +19,12 @@ import (
"gotest.tools/icmd" "gotest.tools/icmd"
) )
func (s *DockerSuite) TestImagesEnsureImageIsListed(c *check.C) { func (s *DockerSuite) TestImagesEnsureImageIsListed(c *testing.T) {
imagesOut, _ := dockerCmd(c, "images") imagesOut, _ := dockerCmd(c, "images")
assert.Assert(c, imagesOut, checker.Contains, "busybox") assert.Assert(c, imagesOut, checker.Contains, "busybox")
} }
func (s *DockerSuite) TestImagesEnsureImageWithTagIsListed(c *check.C) { func (s *DockerSuite) TestImagesEnsureImageWithTagIsListed(c *testing.T) {
name := "imagewithtag" name := "imagewithtag"
dockerCmd(c, "tag", "busybox", name+":v1") dockerCmd(c, "tag", "busybox", name+":v1")
dockerCmd(c, "tag", "busybox", name+":v1v1") dockerCmd(c, "tag", "busybox", name+":v1v1")
@ -43,12 +43,12 @@ func (s *DockerSuite) TestImagesEnsureImageWithTagIsListed(c *check.C) {
assert.Assert(c, imagesOut, checker.Contains, "v2") assert.Assert(c, imagesOut, checker.Contains, "v2")
} }
func (s *DockerSuite) TestImagesEnsureImageWithBadTagIsNotListed(c *check.C) { func (s *DockerSuite) TestImagesEnsureImageWithBadTagIsNotListed(c *testing.T) {
imagesOut, _ := dockerCmd(c, "images", "busybox:nonexistent") imagesOut, _ := dockerCmd(c, "images", "busybox:nonexistent")
assert.Assert(c, imagesOut, checker.Not(checker.Contains), "busybox") assert.Assert(c, imagesOut, checker.Not(checker.Contains), "busybox")
} }
func (s *DockerSuite) TestImagesOrderedByCreationDate(c *check.C) { func (s *DockerSuite) TestImagesOrderedByCreationDate(c *testing.T) {
buildImageSuccessfully(c, "order:test_a", build.WithDockerfile(`FROM busybox buildImageSuccessfully(c, "order:test_a", build.WithDockerfile(`FROM busybox
MAINTAINER dockerio1`)) MAINTAINER dockerio1`))
id1 := getIDByName(c, "order:test_a") id1 := getIDByName(c, "order:test_a")
@ -68,13 +68,13 @@ func (s *DockerSuite) TestImagesOrderedByCreationDate(c *check.C) {
assert.Assert(c, imgs[2], checker.Equals, id1, check.Commentf("First image must be %s, got %s", id1, imgs[2])) assert.Assert(c, imgs[2], checker.Equals, id1, check.Commentf("First image must be %s, got %s", id1, imgs[2]))
} }
func (s *DockerSuite) TestImagesErrorWithInvalidFilterNameTest(c *check.C) { func (s *DockerSuite) TestImagesErrorWithInvalidFilterNameTest(c *testing.T) {
out, _, err := dockerCmdWithError("images", "-f", "FOO=123") out, _, err := dockerCmdWithError("images", "-f", "FOO=123")
assert.ErrorContains(c, err, "") assert.ErrorContains(c, err, "")
assert.Assert(c, out, checker.Contains, "Invalid filter") assert.Assert(c, out, checker.Contains, "Invalid filter")
} }
func (s *DockerSuite) TestImagesFilterLabelMatch(c *check.C) { func (s *DockerSuite) TestImagesFilterLabelMatch(c *testing.T) {
imageName1 := "images_filter_test1" imageName1 := "images_filter_test1"
imageName2 := "images_filter_test2" imageName2 := "images_filter_test2"
imageName3 := "images_filter_test3" imageName3 := "images_filter_test3"
@ -102,7 +102,7 @@ func (s *DockerSuite) TestImagesFilterLabelMatch(c *check.C) {
} }
// Regression : #15659 // Regression : #15659
func (s *DockerSuite) TestCommitWithFilterLabel(c *check.C) { func (s *DockerSuite) TestCommitWithFilterLabel(c *testing.T) {
// Create a container // Create a container
dockerCmd(c, "run", "--name", "bar", "busybox", "/bin/sh") dockerCmd(c, "run", "--name", "bar", "busybox", "/bin/sh")
// Commit with labels "using changes" // Commit with labels "using changes"
@ -114,7 +114,7 @@ func (s *DockerSuite) TestCommitWithFilterLabel(c *check.C) {
assert.Equal(c, out, imageID) assert.Equal(c, out, imageID)
} }
func (s *DockerSuite) TestImagesFilterSinceAndBefore(c *check.C) { func (s *DockerSuite) TestImagesFilterSinceAndBefore(c *testing.T) {
buildImageSuccessfully(c, "image:1", build.WithDockerfile(`FROM `+minimalBaseImage()+` buildImageSuccessfully(c, "image:1", build.WithDockerfile(`FROM `+minimalBaseImage()+`
LABEL number=1`)) LABEL number=1`))
imageID1 := getIDByName(c, "image:1") imageID1 := getIDByName(c, "image:1")
@ -184,7 +184,7 @@ func assertImageList(out string, expected []string) bool {
} }
// FIXME(vdemeester) should be a unit test on `docker image ls` // FIXME(vdemeester) should be a unit test on `docker image ls`
func (s *DockerSuite) TestImagesFilterSpaceTrimCase(c *check.C) { func (s *DockerSuite) TestImagesFilterSpaceTrimCase(c *testing.T) {
imageName := "images_filter_test" imageName := "images_filter_test"
// Build a image and fail to build so that we have dangling images ? // Build a image and fail to build so that we have dangling images ?
buildImage(imageName, build.WithDockerfile(`FROM busybox buildImage(imageName, build.WithDockerfile(`FROM busybox
@ -224,7 +224,7 @@ func (s *DockerSuite) TestImagesFilterSpaceTrimCase(c *check.C) {
} }
} }
func (s *DockerSuite) TestImagesEnsureDanglingImageOnlyListedOnce(c *check.C) { func (s *DockerSuite) TestImagesEnsureDanglingImageOnlyListedOnce(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
// create container 1 // create container 1
out, _ := dockerCmd(c, "run", "-d", "busybox", "true") out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
@ -252,13 +252,13 @@ func (s *DockerSuite) TestImagesEnsureDanglingImageOnlyListedOnce(c *check.C) {
} }
// FIXME(vdemeester) should be a unit test for `docker image ls` // FIXME(vdemeester) should be a unit test for `docker image ls`
func (s *DockerSuite) TestImagesWithIncorrectFilter(c *check.C) { func (s *DockerSuite) TestImagesWithIncorrectFilter(c *testing.T) {
out, _, err := dockerCmdWithError("images", "-f", "dangling=invalid") out, _, err := dockerCmdWithError("images", "-f", "dangling=invalid")
assert.ErrorContains(c, err, "") assert.ErrorContains(c, err, "")
assert.Assert(c, out, checker.Contains, "Invalid filter") assert.Assert(c, out, checker.Contains, "Invalid filter")
} }
func (s *DockerSuite) TestImagesEnsureOnlyHeadsImagesShown(c *check.C) { func (s *DockerSuite) TestImagesEnsureOnlyHeadsImagesShown(c *testing.T) {
dockerfile := ` dockerfile := `
FROM busybox FROM busybox
MAINTAINER docker MAINTAINER docker
@ -281,7 +281,7 @@ func (s *DockerSuite) TestImagesEnsureOnlyHeadsImagesShown(c *check.C) {
assert.Assert(c, out, checker.Contains, stringid.TruncateID(id)) assert.Assert(c, out, checker.Contains, stringid.TruncateID(id))
} }
func (s *DockerSuite) TestImagesEnsureImagesFromScratchShown(c *check.C) { func (s *DockerSuite) TestImagesEnsureImagesFromScratchShown(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows does not support FROM scratch testRequires(c, DaemonIsLinux) // Windows does not support FROM scratch
dockerfile := ` dockerfile := `
FROM scratch FROM scratch
@ -298,7 +298,7 @@ func (s *DockerSuite) TestImagesEnsureImagesFromScratchShown(c *check.C) {
// For W2W - equivalent to TestImagesEnsureImagesFromScratchShown but Windows // For W2W - equivalent to TestImagesEnsureImagesFromScratchShown but Windows
// doesn't support from scratch // doesn't support from scratch
func (s *DockerSuite) TestImagesEnsureImagesFromBusyboxShown(c *check.C) { func (s *DockerSuite) TestImagesEnsureImagesFromBusyboxShown(c *testing.T) {
dockerfile := ` dockerfile := `
FROM busybox FROM busybox
MAINTAINER docker` MAINTAINER docker`
@ -313,7 +313,7 @@ func (s *DockerSuite) TestImagesEnsureImagesFromBusyboxShown(c *check.C) {
} }
// #18181 // #18181
func (s *DockerSuite) TestImagesFilterNameWithPort(c *check.C) { func (s *DockerSuite) TestImagesFilterNameWithPort(c *testing.T) {
tag := "a.b.c.d:5000/hello" tag := "a.b.c.d:5000/hello"
dockerCmd(c, "tag", "busybox", tag) dockerCmd(c, "tag", "busybox", tag)
out, _ := dockerCmd(c, "images", tag) out, _ := dockerCmd(c, "images", tag)
@ -326,7 +326,7 @@ func (s *DockerSuite) TestImagesFilterNameWithPort(c *check.C) {
assert.Assert(c, out, checker.Not(checker.Contains), tag) assert.Assert(c, out, checker.Not(checker.Contains), tag)
} }
func (s *DockerSuite) TestImagesFormat(c *check.C) { func (s *DockerSuite) TestImagesFormat(c *testing.T) {
// testRequires(c, DaemonIsLinux) // testRequires(c, DaemonIsLinux)
tag := "myimage" tag := "myimage"
dockerCmd(c, "tag", "busybox", tag+":v1") dockerCmd(c, "tag", "busybox", tag+":v1")
@ -342,7 +342,7 @@ func (s *DockerSuite) TestImagesFormat(c *check.C) {
} }
// ImagesDefaultFormatAndQuiet // ImagesDefaultFormatAndQuiet
func (s *DockerSuite) TestImagesFormatDefaultFormat(c *check.C) { func (s *DockerSuite) TestImagesFormatDefaultFormat(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
// create container 1 // create container 1

View file

@ -16,7 +16,7 @@ import (
"gotest.tools/icmd" "gotest.tools/icmd"
) )
func (s *DockerSuite) TestImportDisplay(c *check.C) { func (s *DockerSuite) TestImportDisplay(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "true") out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
@ -34,7 +34,7 @@ func (s *DockerSuite) TestImportDisplay(c *check.C) {
assert.Equal(c, out, "", "command output should've been nothing.") assert.Equal(c, out, "", "command output should've been nothing.")
} }
func (s *DockerSuite) TestImportBadURL(c *check.C) { func (s *DockerSuite) TestImportBadURL(c *testing.T) {
out, _, err := dockerCmdWithError("import", "http://nourl/bad") out, _, err := dockerCmdWithError("import", "http://nourl/bad")
assert.Assert(c, err, checker.NotNil, check.Commentf("import was supposed to fail but didn't")) assert.Assert(c, err, checker.NotNil, check.Commentf("import was supposed to fail but didn't"))
// Depending on your system you can get either of these errors // Depending on your system you can get either of these errors
@ -45,7 +45,7 @@ func (s *DockerSuite) TestImportBadURL(c *check.C) {
} }
} }
func (s *DockerSuite) TestImportFile(c *check.C) { func (s *DockerSuite) TestImportFile(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "--name", "test-import", "busybox", "true") dockerCmd(c, "run", "--name", "test-import", "busybox", "true")
@ -66,7 +66,7 @@ func (s *DockerSuite) TestImportFile(c *check.C) {
assert.Equal(c, out, "", "command output should've been nothing.") assert.Equal(c, out, "", "command output should've been nothing.")
} }
func (s *DockerSuite) TestImportGzipped(c *check.C) { func (s *DockerSuite) TestImportGzipped(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "--name", "test-import", "busybox", "true") dockerCmd(c, "run", "--name", "test-import", "busybox", "true")
@ -89,7 +89,7 @@ func (s *DockerSuite) TestImportGzipped(c *check.C) {
assert.Equal(c, out, "", "command output should've been nothing.") assert.Equal(c, out, "", "command output should've been nothing.")
} }
func (s *DockerSuite) TestImportFileWithMessage(c *check.C) { func (s *DockerSuite) TestImportFileWithMessage(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "--name", "test-import", "busybox", "true") dockerCmd(c, "run", "--name", "test-import", "busybox", "true")
@ -120,12 +120,12 @@ func (s *DockerSuite) TestImportFileWithMessage(c *check.C) {
assert.Equal(c, out, "", "command output should've been nothing") assert.Equal(c, out, "", "command output should've been nothing")
} }
func (s *DockerSuite) TestImportFileNonExistentFile(c *check.C) { func (s *DockerSuite) TestImportFileNonExistentFile(c *testing.T) {
_, _, err := dockerCmdWithError("import", "example.com/myImage.tar") _, _, err := dockerCmdWithError("import", "example.com/myImage.tar")
assert.Assert(c, err, checker.NotNil, check.Commentf("import non-existing file must failed")) assert.Assert(c, err, checker.NotNil, check.Commentf("import non-existing file must failed"))
} }
func (s *DockerSuite) TestImportWithQuotedChanges(c *check.C) { func (s *DockerSuite) TestImportWithQuotedChanges(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
cli.DockerCmd(c, "run", "--name", "test-import", "busybox", "true") cli.DockerCmd(c, "run", "--name", "test-import", "busybox", "true")

View file

@ -14,7 +14,7 @@ import (
) )
// ensure docker info succeeds // ensure docker info succeeds
func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) { func (s *DockerSuite) TestInfoEnsureSucceeds(c *testing.T) {
out, _ := dockerCmd(c, "info") out, _ := dockerCmd(c, "info")
// always shown fields // always shown fields
@ -58,7 +58,7 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) {
} }
// TestInfoFormat tests `docker info --format` // TestInfoFormat tests `docker info --format`
func (s *DockerSuite) TestInfoFormat(c *check.C) { func (s *DockerSuite) TestInfoFormat(c *testing.T) {
out, status := dockerCmd(c, "info", "--format", "{{json .}}") out, status := dockerCmd(c, "info", "--format", "{{json .}}")
assert.Assert(c, status, checker.Equals, 0) assert.Assert(c, status, checker.Equals, 0)
var m map[string]interface{} var m map[string]interface{}
@ -70,7 +70,7 @@ func (s *DockerSuite) TestInfoFormat(c *check.C) {
// TestInfoDiscoveryBackend verifies that a daemon run with `--cluster-advertise` and // TestInfoDiscoveryBackend verifies that a daemon run with `--cluster-advertise` and
// `--cluster-store` properly show the backend's endpoint in info output. // `--cluster-store` properly show the backend's endpoint in info output.
func (s *DockerSuite) TestInfoDiscoveryBackend(c *check.C) { func (s *DockerSuite) TestInfoDiscoveryBackend(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
@ -87,7 +87,7 @@ func (s *DockerSuite) TestInfoDiscoveryBackend(c *check.C) {
// TestInfoDiscoveryInvalidAdvertise verifies that a daemon run with // TestInfoDiscoveryInvalidAdvertise verifies that a daemon run with
// an invalid `--cluster-advertise` configuration // an invalid `--cluster-advertise` configuration
func (s *DockerSuite) TestInfoDiscoveryInvalidAdvertise(c *check.C) { func (s *DockerSuite) TestInfoDiscoveryInvalidAdvertise(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
@ -104,7 +104,7 @@ func (s *DockerSuite) TestInfoDiscoveryInvalidAdvertise(c *check.C) {
// TestInfoDiscoveryAdvertiseInterfaceName verifies that a daemon run with `--cluster-advertise` // TestInfoDiscoveryAdvertiseInterfaceName verifies that a daemon run with `--cluster-advertise`
// configured with interface name properly show the advertise ip-address in info output. // configured with interface name properly show the advertise ip-address in info output.
func (s *DockerSuite) TestInfoDiscoveryAdvertiseInterfaceName(c *check.C) { func (s *DockerSuite) TestInfoDiscoveryAdvertiseInterfaceName(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, Network, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon, Network, DaemonIsLinux)
d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
@ -128,7 +128,7 @@ func (s *DockerSuite) TestInfoDiscoveryAdvertiseInterfaceName(c *check.C) {
assert.Assert(c, out, checker.Contains, fmt.Sprintf("Cluster Advertise: %s:2375\n", ip.String())) assert.Assert(c, out, checker.Contains, fmt.Sprintf("Cluster Advertise: %s:2375\n", ip.String()))
} }
func (s *DockerSuite) TestInfoDisplaysRunningContainers(c *check.C) { func (s *DockerSuite) TestInfoDisplaysRunningContainers(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
existing := existingContainerStates(c) existing := existingContainerStates(c)
@ -141,7 +141,7 @@ func (s *DockerSuite) TestInfoDisplaysRunningContainers(c *check.C) {
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"])) assert.Assert(c, out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"]))
} }
func (s *DockerSuite) TestInfoDisplaysPausedContainers(c *check.C) { func (s *DockerSuite) TestInfoDisplaysPausedContainers(c *testing.T) {
testRequires(c, IsPausable) testRequires(c, IsPausable)
existing := existingContainerStates(c) existing := existingContainerStates(c)
@ -158,7 +158,7 @@ func (s *DockerSuite) TestInfoDisplaysPausedContainers(c *check.C) {
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"])) assert.Assert(c, out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"]))
} }
func (s *DockerSuite) TestInfoDisplaysStoppedContainers(c *check.C) { func (s *DockerSuite) TestInfoDisplaysStoppedContainers(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
existing := existingContainerStates(c) existing := existingContainerStates(c)
@ -175,7 +175,7 @@ func (s *DockerSuite) TestInfoDisplaysStoppedContainers(c *check.C) {
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"]+1)) assert.Assert(c, out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"]+1))
} }
func (s *DockerSuite) TestInfoDebug(c *check.C) { func (s *DockerSuite) TestInfoDebug(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
@ -193,7 +193,7 @@ func (s *DockerSuite) TestInfoDebug(c *check.C) {
assert.Assert(c, out, checker.Contains, "Docker Root Dir") assert.Assert(c, out, checker.Contains, "Docker Root Dir")
} }
func (s *DockerSuite) TestInsecureRegistries(c *check.C) { func (s *DockerSuite) TestInsecureRegistries(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
registryCIDR := "192.168.1.0/24" registryCIDR := "192.168.1.0/24"
@ -210,7 +210,7 @@ func (s *DockerSuite) TestInsecureRegistries(c *check.C) {
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" %s\n", registryCIDR)) assert.Assert(c, out, checker.Contains, fmt.Sprintf(" %s\n", registryCIDR))
} }
func (s *DockerDaemonSuite) TestRegistryMirrors(c *check.C) { func (s *DockerDaemonSuite) TestRegistryMirrors(c *testing.T) {
registryMirror1 := "https://192.168.1.2" registryMirror1 := "https://192.168.1.2"
registryMirror2 := "http://registry.mirror.com:5000" registryMirror2 := "http://registry.mirror.com:5000"
@ -224,7 +224,7 @@ func (s *DockerDaemonSuite) TestRegistryMirrors(c *check.C) {
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" %s", registryMirror2)) assert.Assert(c, out, checker.Contains, fmt.Sprintf(" %s", registryMirror2))
} }
func existingContainerStates(c *check.C) map[string]int { func existingContainerStates(c *testing.T) map[string]int {
out, _ := dockerCmd(c, "info", "--format", "{{json .}}") out, _ := dockerCmd(c, "info", "--format", "{{json .}}")
var m map[string]interface{} var m map[string]interface{}
err := json.Unmarshal([]byte(out), &m) err := json.Unmarshal([]byte(out), &m)

View file

@ -7,7 +7,7 @@ import (
"github.com/go-check/check" "github.com/go-check/check"
) )
func (s *DockerSuite) TestInfoSecurityOptions(c *check.C) { func (s *DockerSuite) TestInfoSecurityOptions(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, Apparmor, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, Apparmor, DaemonIsLinux)
out, _ := dockerCmd(c, "info") out, _ := dockerCmd(c, "info")

View file

@ -16,13 +16,13 @@ import (
"gotest.tools/icmd" "gotest.tools/icmd"
) )
func checkValidGraphDriver(c *check.C, name string) { func checkValidGraphDriver(c *testing.T, name string) {
if name != "devicemapper" && name != "overlay" && name != "vfs" && name != "zfs" && name != "btrfs" && name != "aufs" { if name != "devicemapper" && name != "overlay" && name != "vfs" && name != "zfs" && name != "btrfs" && name != "aufs" {
c.Fatalf("%v is not a valid graph driver name", name) c.Fatalf("%v is not a valid graph driver name", name)
} }
} }
func (s *DockerSuite) TestInspectImage(c *check.C) { func (s *DockerSuite) TestInspectImage(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
imageTest := "emptyfs" imageTest := "emptyfs"
// It is important that this ID remain stable. If a code change causes // It is important that this ID remain stable. If a code change causes
@ -36,13 +36,13 @@ func (s *DockerSuite) TestInspectImage(c *check.C) {
assert.Assert(c, id, checker.Equals, imageTestID) assert.Assert(c, id, checker.Equals, imageTestID)
} }
func (s *DockerSuite) TestInspectInt64(c *check.C) { func (s *DockerSuite) TestInspectInt64(c *testing.T) {
dockerCmd(c, "run", "-d", "-m=300M", "--name", "inspectTest", "busybox", "true") dockerCmd(c, "run", "-d", "-m=300M", "--name", "inspectTest", "busybox", "true")
inspectOut := inspectField(c, "inspectTest", "HostConfig.Memory") inspectOut := inspectField(c, "inspectTest", "HostConfig.Memory")
assert.Assert(c, inspectOut, checker.Equals, "314572800") assert.Assert(c, inspectOut, checker.Equals, "314572800")
} }
func (s *DockerSuite) TestInspectDefault(c *check.C) { func (s *DockerSuite) TestInspectDefault(c *testing.T) {
//Both the container and image are named busybox. docker inspect will fetch the container JSON. //Both the container and image are named busybox. docker inspect will fetch the container JSON.
//If the container JSON is not available, it will go for the image JSON. //If the container JSON is not available, it will go for the image JSON.
@ -53,7 +53,7 @@ func (s *DockerSuite) TestInspectDefault(c *check.C) {
assert.Assert(c, strings.TrimSpace(inspectOut), checker.Equals, containerID) assert.Assert(c, strings.TrimSpace(inspectOut), checker.Equals, containerID)
} }
func (s *DockerSuite) TestInspectStatus(c *check.C) { func (s *DockerSuite) TestInspectStatus(c *testing.T) {
out := runSleepingContainer(c, "-d") out := runSleepingContainer(c, "-d")
out = strings.TrimSpace(out) out = strings.TrimSpace(out)
@ -78,7 +78,7 @@ func (s *DockerSuite) TestInspectStatus(c *check.C) {
} }
func (s *DockerSuite) TestInspectTypeFlagContainer(c *check.C) { func (s *DockerSuite) TestInspectTypeFlagContainer(c *testing.T) {
//Both the container and image are named busybox. docker inspect will fetch container //Both the container and image are named busybox. docker inspect will fetch container
//JSON State.Running field. If the field is true, it's a container. //JSON State.Running field. If the field is true, it's a container.
runSleepingContainer(c, "--name=busybox", "-d") runSleepingContainer(c, "--name=busybox", "-d")
@ -88,7 +88,7 @@ func (s *DockerSuite) TestInspectTypeFlagContainer(c *check.C) {
assert.Equal(c, out, "true\n") // not a container JSON assert.Equal(c, out, "true\n") // not a container JSON
} }
func (s *DockerSuite) TestInspectTypeFlagWithNoContainer(c *check.C) { func (s *DockerSuite) TestInspectTypeFlagWithNoContainer(c *testing.T) {
//Run this test on an image named busybox. docker inspect will try to fetch container //Run this test on an image named busybox. docker inspect will try to fetch container
//JSON. Since there is no container named busybox and --type=container, docker inspect will //JSON. Since there is no container named busybox and --type=container, docker inspect will
//not try to get the image JSON. It will throw an error. //not try to get the image JSON. It will throw an error.
@ -100,7 +100,7 @@ func (s *DockerSuite) TestInspectTypeFlagWithNoContainer(c *check.C) {
assert.ErrorContains(c, err, "") assert.ErrorContains(c, err, "")
} }
func (s *DockerSuite) TestInspectTypeFlagWithImage(c *check.C) { func (s *DockerSuite) TestInspectTypeFlagWithImage(c *testing.T) {
//Both the container and image are named busybox. docker inspect will fetch image //Both the container and image are named busybox. docker inspect will fetch image
//JSON as --type=image. if there is no image with name busybox, docker inspect //JSON as --type=image. if there is no image with name busybox, docker inspect
//will throw an error. //will throw an error.
@ -112,7 +112,7 @@ func (s *DockerSuite) TestInspectTypeFlagWithImage(c *check.C) {
assert.Assert(c, out, checker.Not(checker.Contains), "State") assert.Assert(c, out, checker.Not(checker.Contains), "State")
} }
func (s *DockerSuite) TestInspectTypeFlagWithInvalidValue(c *check.C) { func (s *DockerSuite) TestInspectTypeFlagWithInvalidValue(c *testing.T) {
//Both the container and image are named busybox. docker inspect will fail //Both the container and image are named busybox. docker inspect will fail
//as --type=foobar is not a valid value for the flag. //as --type=foobar is not a valid value for the flag.
@ -124,7 +124,7 @@ func (s *DockerSuite) TestInspectTypeFlagWithInvalidValue(c *check.C) {
assert.Assert(c, out, checker.Contains, "not a valid value for --type") assert.Assert(c, out, checker.Contains, "not a valid value for --type")
} }
func (s *DockerSuite) TestInspectImageFilterInt(c *check.C) { func (s *DockerSuite) TestInspectImageFilterInt(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
imageTest := "emptyfs" imageTest := "emptyfs"
out := inspectField(c, imageTest, "Size") out := inspectField(c, imageTest, "Size")
@ -140,7 +140,7 @@ func (s *DockerSuite) TestInspectImageFilterInt(c *check.C) {
assert.Assert(c, result, checker.Equals, true) assert.Assert(c, result, checker.Equals, true)
} }
func (s *DockerSuite) TestInspectContainerFilterInt(c *check.C) { func (s *DockerSuite) TestInspectContainerFilterInt(c *testing.T) {
result := icmd.RunCmd(icmd.Cmd{ result := icmd.RunCmd(icmd.Cmd{
Command: []string{dockerBinary, "run", "-i", "-a", "stdin", "busybox", "cat"}, Command: []string{dockerBinary, "run", "-i", "-a", "stdin", "busybox", "cat"},
Stdin: strings.NewReader("blahblah"), Stdin: strings.NewReader("blahblah"),
@ -162,7 +162,7 @@ func (s *DockerSuite) TestInspectContainerFilterInt(c *check.C) {
assert.Assert(c, inspectResult, checker.Equals, true) assert.Assert(c, inspectResult, checker.Equals, true)
} }
func (s *DockerSuite) TestInspectImageGraphDriver(c *check.C) { func (s *DockerSuite) TestInspectImageGraphDriver(c *testing.T) {
testRequires(c, DaemonIsLinux, Devicemapper) testRequires(c, DaemonIsLinux, Devicemapper)
imageTest := "emptyfs" imageTest := "emptyfs"
name := inspectField(c, imageTest, "GraphDriver.Name") name := inspectField(c, imageTest, "GraphDriver.Name")
@ -180,7 +180,7 @@ func (s *DockerSuite) TestInspectImageGraphDriver(c *check.C) {
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to inspect DeviceSize of the image: %s, %v", deviceSize, err)) assert.Assert(c, err, checker.IsNil, check.Commentf("failed to inspect DeviceSize of the image: %s, %v", deviceSize, err))
} }
func (s *DockerSuite) TestInspectContainerGraphDriver(c *check.C) { func (s *DockerSuite) TestInspectContainerGraphDriver(c *testing.T) {
testRequires(c, DaemonIsLinux, Devicemapper) testRequires(c, DaemonIsLinux, Devicemapper)
out, _ := dockerCmd(c, "run", "-d", "busybox", "true") out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
@ -205,7 +205,7 @@ func (s *DockerSuite) TestInspectContainerGraphDriver(c *check.C) {
assert.Assert(c, err, checker.IsNil, check.Commentf("failed to inspect DeviceSize of the image: %s, %v", deviceSize, err)) assert.Assert(c, err, checker.IsNil, check.Commentf("failed to inspect DeviceSize of the image: %s, %v", deviceSize, err))
} }
func (s *DockerSuite) TestInspectBindMountPoint(c *check.C) { func (s *DockerSuite) TestInspectBindMountPoint(c *testing.T) {
modifier := ",z" modifier := ",z"
prefix, slash := getPrefixAndSlashFromDaemonPlatform() prefix, slash := getPrefixAndSlashFromDaemonPlatform()
if testEnv.OSType == "windows" { if testEnv.OSType == "windows" {
@ -237,7 +237,7 @@ func (s *DockerSuite) TestInspectBindMountPoint(c *check.C) {
assert.Assert(c, m.RW, checker.Equals, false) assert.Assert(c, m.RW, checker.Equals, false)
} }
func (s *DockerSuite) TestInspectNamedMountPoint(c *check.C) { func (s *DockerSuite) TestInspectNamedMountPoint(c *testing.T) {
prefix, slash := getPrefixAndSlashFromDaemonPlatform() prefix, slash := getPrefixAndSlashFromDaemonPlatform()
dockerCmd(c, "run", "-d", "--name", "test", "-v", "data:"+prefix+slash+"data", "busybox", "cat") dockerCmd(c, "run", "-d", "--name", "test", "-v", "data:"+prefix+slash+"data", "busybox", "cat")
@ -261,7 +261,7 @@ func (s *DockerSuite) TestInspectNamedMountPoint(c *check.C) {
} }
// #14947 // #14947
func (s *DockerSuite) TestInspectTimesAsRFC3339Nano(c *check.C) { func (s *DockerSuite) TestInspectTimesAsRFC3339Nano(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "busybox", "true") out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
startedAt := inspectField(c, id, "State.StartedAt") startedAt := inspectField(c, id, "State.StartedAt")
@ -282,7 +282,7 @@ func (s *DockerSuite) TestInspectTimesAsRFC3339Nano(c *check.C) {
} }
// #15633 // #15633
func (s *DockerSuite) TestInspectLogConfigNoType(c *check.C) { func (s *DockerSuite) TestInspectLogConfigNoType(c *testing.T) {
dockerCmd(c, "create", "--name=test", "--log-opt", "max-file=42", "busybox") dockerCmd(c, "create", "--name=test", "--log-opt", "max-file=42", "busybox")
var logConfig container.LogConfig var logConfig container.LogConfig
@ -295,7 +295,7 @@ func (s *DockerSuite) TestInspectLogConfigNoType(c *check.C) {
assert.Assert(c, logConfig.Config["max-file"], checker.Equals, "42", check.Commentf("%v", logConfig)) assert.Assert(c, logConfig.Config["max-file"], checker.Equals, "42", check.Commentf("%v", logConfig))
} }
func (s *DockerSuite) TestInspectNoSizeFlagContainer(c *check.C) { func (s *DockerSuite) TestInspectNoSizeFlagContainer(c *testing.T) {
//Both the container and image are named busybox. docker inspect will fetch container //Both the container and image are named busybox. docker inspect will fetch container
//JSON SizeRw and SizeRootFs field. If there is no flag --size/-s, there are no size fields. //JSON SizeRw and SizeRootFs field. If there is no flag --size/-s, there are no size fields.
@ -307,7 +307,7 @@ func (s *DockerSuite) TestInspectNoSizeFlagContainer(c *check.C) {
assert.Assert(c, strings.TrimSpace(out), check.Equals, "<nil>,<nil>", check.Commentf("Expected not to display size info: %s", out)) assert.Assert(c, strings.TrimSpace(out), check.Equals, "<nil>,<nil>", check.Commentf("Expected not to display size info: %s", out))
} }
func (s *DockerSuite) TestInspectSizeFlagContainer(c *check.C) { func (s *DockerSuite) TestInspectSizeFlagContainer(c *testing.T) {
runSleepingContainer(c, "--name=busybox", "-d") runSleepingContainer(c, "--name=busybox", "-d")
formatStr := "--format='{{.SizeRw}},{{.SizeRootFs}}'" formatStr := "--format='{{.SizeRw}},{{.SizeRootFs}}'"
@ -318,7 +318,7 @@ func (s *DockerSuite) TestInspectSizeFlagContainer(c *check.C) {
assert.Assert(c, strings.TrimSpace(sz[1]), check.Not(check.Equals), "<nil>") assert.Assert(c, strings.TrimSpace(sz[1]), check.Not(check.Equals), "<nil>")
} }
func (s *DockerSuite) TestInspectTemplateError(c *check.C) { func (s *DockerSuite) TestInspectTemplateError(c *testing.T) {
// Template parsing error for both the container and image. // Template parsing error for both the container and image.
runSleepingContainer(c, "--name=container1", "-d") runSleepingContainer(c, "--name=container1", "-d")
@ -332,7 +332,7 @@ func (s *DockerSuite) TestInspectTemplateError(c *check.C) {
assert.Assert(c, out, checker.Contains, "Template parsing error") assert.Assert(c, out, checker.Contains, "Template parsing error")
} }
func (s *DockerSuite) TestInspectJSONFields(c *check.C) { func (s *DockerSuite) TestInspectJSONFields(c *testing.T) {
runSleepingContainer(c, "--name=busybox", "-d") runSleepingContainer(c, "--name=busybox", "-d")
out, _, err := dockerCmdWithError("inspect", "--type=container", "--format={{.HostConfig.Dns}}", "busybox") out, _, err := dockerCmdWithError("inspect", "--type=container", "--format={{.HostConfig.Dns}}", "busybox")
@ -340,7 +340,7 @@ func (s *DockerSuite) TestInspectJSONFields(c *check.C) {
assert.Equal(c, out, "[]\n") assert.Equal(c, out, "[]\n")
} }
func (s *DockerSuite) TestInspectByPrefix(c *check.C) { func (s *DockerSuite) TestInspectByPrefix(c *testing.T) {
id := inspectField(c, "busybox", "Id") id := inspectField(c, "busybox", "Id")
assert.Assert(c, strings.HasPrefix(id, "sha256:")) assert.Assert(c, strings.HasPrefix(id, "sha256:"))
@ -351,7 +351,7 @@ func (s *DockerSuite) TestInspectByPrefix(c *check.C) {
assert.Assert(c, id, checker.Equals, id3) assert.Assert(c, id, checker.Equals, id3)
} }
func (s *DockerSuite) TestInspectStopWhenNotFound(c *check.C) { func (s *DockerSuite) TestInspectStopWhenNotFound(c *testing.T) {
runSleepingContainer(c, "--name=busybox1", "-d") runSleepingContainer(c, "--name=busybox1", "-d")
runSleepingContainer(c, "--name=busybox2", "-d") runSleepingContainer(c, "--name=busybox2", "-d")
result := dockerCmdWithResult("inspect", "--type=container", "--format='{{.Name}}'", "busybox1", "busybox2", "missing") result := dockerCmdWithResult("inspect", "--type=container", "--format='{{.Name}}'", "busybox1", "busybox2", "missing")
@ -370,7 +370,7 @@ func (s *DockerSuite) TestInspectStopWhenNotFound(c *check.C) {
assert.Assert(c, result.Stderr(), checker.Contains, "Error: No such container: missing") assert.Assert(c, result.Stderr(), checker.Contains, "Error: No such container: missing")
} }
func (s *DockerSuite) TestInspectHistory(c *check.C) { func (s *DockerSuite) TestInspectHistory(c *testing.T) {
dockerCmd(c, "run", "--name=testcont", "busybox", "echo", "hello") dockerCmd(c, "run", "--name=testcont", "busybox", "echo", "hello")
dockerCmd(c, "commit", "-m", "test comment", "testcont", "testimg") dockerCmd(c, "commit", "-m", "test comment", "testcont", "testimg")
out, _, err := dockerCmdWithError("inspect", "--format='{{.Comment}}'", "testimg") out, _, err := dockerCmdWithError("inspect", "--format='{{.Comment}}'", "testimg")
@ -378,7 +378,7 @@ func (s *DockerSuite) TestInspectHistory(c *check.C) {
assert.Assert(c, out, checker.Contains, "test comment") assert.Assert(c, out, checker.Contains, "test comment")
} }
func (s *DockerSuite) TestInspectContainerNetworkDefault(c *check.C) { func (s *DockerSuite) TestInspectContainerNetworkDefault(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
contName := "test1" contName := "test1"
@ -390,7 +390,7 @@ func (s *DockerSuite) TestInspectContainerNetworkDefault(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), strings.TrimSpace(netOut)) assert.Equal(c, strings.TrimSpace(out), strings.TrimSpace(netOut))
} }
func (s *DockerSuite) TestInspectContainerNetworkCustom(c *check.C) { func (s *DockerSuite) TestInspectContainerNetworkCustom(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
netOut, _ := dockerCmd(c, "network", "create", "net1") netOut, _ := dockerCmd(c, "network", "create", "net1")
@ -401,7 +401,7 @@ func (s *DockerSuite) TestInspectContainerNetworkCustom(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), strings.TrimSpace(netOut)) assert.Equal(c, strings.TrimSpace(out), strings.TrimSpace(netOut))
} }
func (s *DockerSuite) TestInspectRootFS(c *check.C) { func (s *DockerSuite) TestInspectRootFS(c *testing.T) {
out, _, err := dockerCmdWithError("inspect", "busybox") out, _, err := dockerCmdWithError("inspect", "busybox")
assert.NilError(c, err) assert.NilError(c, err)
@ -411,7 +411,7 @@ func (s *DockerSuite) TestInspectRootFS(c *check.C) {
assert.Assert(c, len(imageJSON[0].RootFS.Layers) >= 1) assert.Assert(c, len(imageJSON[0].RootFS.Layers) >= 1)
} }
func (s *DockerSuite) TestInspectAmpersand(c *check.C) { func (s *DockerSuite) TestInspectAmpersand(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "test" name := "test"
@ -421,7 +421,7 @@ func (s *DockerSuite) TestInspectAmpersand(c *check.C) {
assert.Assert(c, out, checker.Contains, `soanni&rtr`) assert.Assert(c, out, checker.Contains, `soanni&rtr`)
} }
func (s *DockerSuite) TestInspectPlugin(c *check.C) { func (s *DockerSuite) TestInspectPlugin(c *testing.T) {
testRequires(c, DaemonIsLinux, IsAmd64, Network) testRequires(c, DaemonIsLinux, IsAmd64, Network)
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag) _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
assert.NilError(c, err) assert.NilError(c, err)
@ -452,7 +452,7 @@ func (s *DockerSuite) TestInspectPlugin(c *check.C) {
} }
// Test case for 29185 // Test case for 29185
func (s *DockerSuite) TestInspectUnknownObject(c *check.C) { func (s *DockerSuite) TestInspectUnknownObject(c *testing.T) {
// This test should work on both Windows and Linux // This test should work on both Windows and Linux
out, _, err := dockerCmdWithError("inspect", "foobar") out, _, err := dockerCmdWithError("inspect", "foobar")
assert.ErrorContains(c, err, "") assert.ErrorContains(c, err, "")

View file

@ -13,7 +13,7 @@ import (
"gotest.tools/assert" "gotest.tools/assert"
) )
func (s *DockerSuite) TestLinksPingUnlinkedContainers(c *check.C) { func (s *DockerSuite) TestLinksPingUnlinkedContainers(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
_, exitCode, err := dockerCmdWithError("run", "--rm", "busybox", "sh", "-c", "ping -c 1 alias1 -W 1 && ping -c 1 alias2 -W 1") _, exitCode, err := dockerCmdWithError("run", "--rm", "busybox", "sh", "-c", "ping -c 1 alias1 -W 1 && ping -c 1 alias2 -W 1")
@ -22,7 +22,7 @@ func (s *DockerSuite) TestLinksPingUnlinkedContainers(c *check.C) {
} }
// Test for appropriate error when calling --link with an invalid target container // Test for appropriate error when calling --link with an invalid target container
func (s *DockerSuite) TestLinksInvalidContainerTarget(c *check.C) { func (s *DockerSuite) TestLinksInvalidContainerTarget(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _, err := dockerCmdWithError("run", "--link", "bogus:alias", "busybox", "true") out, _, err := dockerCmdWithError("run", "--link", "bogus:alias", "busybox", "true")
@ -34,7 +34,7 @@ func (s *DockerSuite) TestLinksInvalidContainerTarget(c *check.C) {
assert.Assert(c, strings.ToLower(out), checker.Contains, "could not get container") assert.Assert(c, strings.ToLower(out), checker.Contains, "could not get container")
} }
func (s *DockerSuite) TestLinksPingLinkedContainers(c *check.C) { func (s *DockerSuite) TestLinksPingLinkedContainers(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
// Test with the three different ways of specifying the default network on Linux // Test with the three different ways of specifying the default network on Linux
testLinkPingOnNetwork(c, "") testLinkPingOnNetwork(c, "")
@ -42,7 +42,7 @@ func (s *DockerSuite) TestLinksPingLinkedContainers(c *check.C) {
testLinkPingOnNetwork(c, "bridge") testLinkPingOnNetwork(c, "bridge")
} }
func testLinkPingOnNetwork(c *check.C, network string) { func testLinkPingOnNetwork(c *testing.T, network string) {
var postArgs []string var postArgs []string
if network != "" { if network != "" {
postArgs = append(postArgs, []string{"--net", network}...) postArgs = append(postArgs, []string{"--net", network}...)
@ -78,7 +78,7 @@ func testLinkPingOnNetwork(c *check.C, network string) {
dockerCmd(c, "rm", "-f", "container2") dockerCmd(c, "rm", "-f", "container2")
} }
func (s *DockerSuite) TestLinksPingLinkedContainersAfterRename(c *check.C) { func (s *DockerSuite) TestLinksPingLinkedContainersAfterRename(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top") out, _ := dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
idA := strings.TrimSpace(out) idA := strings.TrimSpace(out)
@ -91,7 +91,7 @@ func (s *DockerSuite) TestLinksPingLinkedContainersAfterRename(c *check.C) {
} }
func (s *DockerSuite) TestLinksInspectLinksStarted(c *check.C) { func (s *DockerSuite) TestLinksInspectLinksStarted(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top") dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
dockerCmd(c, "run", "-d", "--name", "container2", "busybox", "top") dockerCmd(c, "run", "-d", "--name", "container2", "busybox", "top")
@ -110,7 +110,7 @@ func (s *DockerSuite) TestLinksInspectLinksStarted(c *check.C) {
assert.DeepEqual(c, result, expected) assert.DeepEqual(c, result, expected)
} }
func (s *DockerSuite) TestLinksInspectLinksStopped(c *check.C) { func (s *DockerSuite) TestLinksInspectLinksStopped(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top") dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
@ -130,7 +130,7 @@ func (s *DockerSuite) TestLinksInspectLinksStopped(c *check.C) {
assert.DeepEqual(c, result, expected) assert.DeepEqual(c, result, expected)
} }
func (s *DockerSuite) TestLinksNotStartedParentNotFail(c *check.C) { func (s *DockerSuite) TestLinksNotStartedParentNotFail(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "create", "--name=first", "busybox", "top") dockerCmd(c, "create", "--name=first", "busybox", "top")
dockerCmd(c, "create", "--name=second", "--link=first:first", "busybox", "top") dockerCmd(c, "create", "--name=second", "--link=first:first", "busybox", "top")
@ -138,7 +138,7 @@ func (s *DockerSuite) TestLinksNotStartedParentNotFail(c *check.C) {
} }
func (s *DockerSuite) TestLinksHostsFilesInject(c *check.C) { func (s *DockerSuite) TestLinksHostsFilesInject(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
@ -156,7 +156,7 @@ func (s *DockerSuite) TestLinksHostsFilesInject(c *check.C) {
assert.Assert(c, string(contentTwo), checker.Contains, "onetwo") assert.Assert(c, string(contentTwo), checker.Contains, "onetwo")
} }
func (s *DockerSuite) TestLinksUpdateOnRestart(c *check.C) { func (s *DockerSuite) TestLinksUpdateOnRestart(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
dockerCmd(c, "run", "-d", "--name", "one", "busybox", "top") dockerCmd(c, "run", "-d", "--name", "one", "busybox", "top")
@ -189,7 +189,7 @@ func (s *DockerSuite) TestLinksUpdateOnRestart(c *check.C) {
assert.Assert(c, ip, checker.Equals, realIP) assert.Assert(c, ip, checker.Equals, realIP)
} }
func (s *DockerSuite) TestLinksEnvs(c *check.C) { func (s *DockerSuite) TestLinksEnvs(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "-e", "e1=", "-e", "e2=v2", "-e", "e3=v3=v3", "--name=first", "busybox", "top") dockerCmd(c, "run", "-d", "-e", "e1=", "-e", "e2=v2", "-e", "e3=v3=v3", "--name=first", "busybox", "top")
out, _ := dockerCmd(c, "run", "--name=second", "--link=first:first", "busybox", "env") out, _ := dockerCmd(c, "run", "--name=second", "--link=first:first", "busybox", "env")
@ -198,7 +198,7 @@ func (s *DockerSuite) TestLinksEnvs(c *check.C) {
assert.Assert(c, out, checker.Contains, "FIRST_ENV_e3=v3=v3") assert.Assert(c, out, checker.Contains, "FIRST_ENV_e3=v3=v3")
} }
func (s *DockerSuite) TestLinkShortDefinition(c *check.C) { func (s *DockerSuite) TestLinkShortDefinition(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "--name", "shortlinkdef", "busybox", "top") out, _ := dockerCmd(c, "run", "-d", "--name", "shortlinkdef", "busybox", "top")
@ -214,7 +214,7 @@ func (s *DockerSuite) TestLinkShortDefinition(c *check.C) {
assert.Assert(c, links, checker.Equals, "[\"/shortlinkdef:/link2/shortlinkdef\"]") assert.Assert(c, links, checker.Equals, "[\"/shortlinkdef:/link2/shortlinkdef\"]")
} }
func (s *DockerSuite) TestLinksNetworkHostContainer(c *check.C) { func (s *DockerSuite) TestLinksNetworkHostContainer(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace) testRequires(c, DaemonIsLinux, NotUserNamespace)
dockerCmd(c, "run", "-d", "--net", "host", "--name", "host_container", "busybox", "top") dockerCmd(c, "run", "-d", "--net", "host", "--name", "host_container", "busybox", "top")
out, _, err := dockerCmdWithError("run", "--name", "should_fail", "--link", "host_container:tester", "busybox", "true") out, _, err := dockerCmdWithError("run", "--name", "should_fail", "--link", "host_container:tester", "busybox", "true")
@ -225,14 +225,14 @@ func (s *DockerSuite) TestLinksNetworkHostContainer(c *check.C) {
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetworkAndLinks.Error()) assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetworkAndLinks.Error())
} }
func (s *DockerSuite) TestLinksEtcHostsRegularFile(c *check.C) { func (s *DockerSuite) TestLinksEtcHostsRegularFile(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace) testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmd(c, "run", "--net=host", "busybox", "ls", "-la", "/etc/hosts") out, _ := dockerCmd(c, "run", "--net=host", "busybox", "ls", "-la", "/etc/hosts")
// /etc/hosts should be a regular file // /etc/hosts should be a regular file
assert.Assert(c, out, checker.Matches, "^-.+\n") assert.Assert(c, out, checker.Matches, "^-.+\n")
} }
func (s *DockerSuite) TestLinksMultipleWithSameName(c *check.C) { func (s *DockerSuite) TestLinksMultipleWithSameName(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--name=upstream-a", "busybox", "top") dockerCmd(c, "run", "-d", "--name=upstream-a", "busybox", "top")
dockerCmd(c, "run", "-d", "--name=upstream-b", "busybox", "top") dockerCmd(c, "run", "-d", "--name=upstream-b", "busybox", "top")

View file

@ -9,7 +9,7 @@ import (
"gotest.tools/assert" "gotest.tools/assert"
) )
func (s *DockerSuite) TestLoginWithoutTTY(c *check.C) { func (s *DockerSuite) TestLoginWithoutTTY(c *testing.T) {
cmd := exec.Command(dockerBinary, "login") cmd := exec.Command(dockerBinary, "login")
// Send to stdin so the process does not get the TTY // Send to stdin so the process does not get the TTY
@ -20,7 +20,7 @@ func (s *DockerSuite) TestLoginWithoutTTY(c *check.C) {
assert.ErrorContains(c, err, "") //"Expected non nil err when logging in & TTY not available" assert.ErrorContains(c, err, "") //"Expected non nil err when logging in & TTY not available"
} }
func (s *DockerRegistryAuthHtpasswdSuite) TestLoginToPrivateRegistry(c *check.C) { func (s *DockerRegistryAuthHtpasswdSuite) TestLoginToPrivateRegistry(c *testing.T) {
// wrong credentials // wrong credentials
out, _, err := dockerCmdWithError("login", "-u", s.reg.Username(), "-p", "WRONGPASSWORD", privateRegistryURL) out, _, err := dockerCmdWithError("login", "-u", s.reg.Username(), "-p", "WRONGPASSWORD", privateRegistryURL)
assert.ErrorContains(c, err, "", out) assert.ErrorContains(c, err, "", out)

View file

@ -13,7 +13,7 @@ import (
"gotest.tools/assert" "gotest.tools/assert"
) )
func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithExternalAuth(c *check.C) { func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithExternalAuth(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
osPath := os.Getenv("PATH") osPath := os.Getenv("PATH")
@ -65,7 +65,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithExternalAuth(c *check.C)
} }
// #23100 // #23100
func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithWrongHostnamesStored(c *check.C) { func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithWrongHostnamesStored(c *testing.T) {
osPath := os.Getenv("PATH") osPath := os.Getenv("PATH")
defer os.Setenv("PATH", osPath) defer os.Setenv("PATH", osPath)

View file

@ -16,21 +16,21 @@ import (
) )
// This used to work, it test a log of PageSize-1 (gh#4851) // This used to work, it test a log of PageSize-1 (gh#4851)
func (s *DockerSuite) TestLogsContainerSmallerThanPage(c *check.C) { func (s *DockerSuite) TestLogsContainerSmallerThanPage(c *testing.T) {
testLogsContainerPagination(c, 32767) testLogsContainerPagination(c, 32767)
} }
// Regression test: When going over the PageSize, it used to panic (gh#4851) // Regression test: When going over the PageSize, it used to panic (gh#4851)
func (s *DockerSuite) TestLogsContainerBiggerThanPage(c *check.C) { func (s *DockerSuite) TestLogsContainerBiggerThanPage(c *testing.T) {
testLogsContainerPagination(c, 32768) testLogsContainerPagination(c, 32768)
} }
// Regression test: When going much over the PageSize, it used to block (gh#4851) // Regression test: When going much over the PageSize, it used to block (gh#4851)
func (s *DockerSuite) TestLogsContainerMuchBiggerThanPage(c *check.C) { func (s *DockerSuite) TestLogsContainerMuchBiggerThanPage(c *testing.T) {
testLogsContainerPagination(c, 33000) testLogsContainerPagination(c, 33000)
} }
func testLogsContainerPagination(c *check.C, testLen int) { func testLogsContainerPagination(c *testing.T, testLen int) {
out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo -n = >> a.a; done; echo >> a.a; cat a.a", testLen)) out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo -n = >> a.a; done; echo >> a.a; cat a.a", testLen))
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
dockerCmd(c, "wait", id) dockerCmd(c, "wait", id)
@ -38,7 +38,7 @@ func testLogsContainerPagination(c *check.C, testLen int) {
assert.Equal(c, len(out), testLen+1) assert.Equal(c, len(out), testLen+1)
} }
func (s *DockerSuite) TestLogsTimestamps(c *check.C) { func (s *DockerSuite) TestLogsTimestamps(c *testing.T) {
testLen := 100 testLen := 100
out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo = >> a.a; done; cat a.a", testLen)) out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo = >> a.a; done; cat a.a", testLen))
@ -63,7 +63,7 @@ func (s *DockerSuite) TestLogsTimestamps(c *check.C) {
} }
} }
func (s *DockerSuite) TestLogsSeparateStderr(c *check.C) { func (s *DockerSuite) TestLogsSeparateStderr(c *testing.T) {
msg := "stderr_log" msg := "stderr_log"
out := cli.DockerCmd(c, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("echo %s 1>&2", msg)).Combined() out := cli.DockerCmd(c, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("echo %s 1>&2", msg)).Combined()
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
@ -74,7 +74,7 @@ func (s *DockerSuite) TestLogsSeparateStderr(c *check.C) {
}) })
} }
func (s *DockerSuite) TestLogsStderrInStdout(c *check.C) { func (s *DockerSuite) TestLogsStderrInStdout(c *testing.T) {
// TODO Windows: Needs investigation why this fails. Obtained string includes // TODO Windows: Needs investigation why this fails. Obtained string includes
// a bunch of ANSI escape sequences before the "stderr_log" message. // a bunch of ANSI escape sequences before the "stderr_log" message.
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -89,7 +89,7 @@ func (s *DockerSuite) TestLogsStderrInStdout(c *check.C) {
}) })
} }
func (s *DockerSuite) TestLogsTail(c *check.C) { func (s *DockerSuite) TestLogsTail(c *testing.T) {
testLen := 100 testLen := 100
out := cli.DockerCmd(c, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo =; done;", testLen)).Combined() out := cli.DockerCmd(c, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo =; done;", testLen)).Combined()
@ -121,7 +121,7 @@ func (s *DockerSuite) TestLogsTail(c *check.C) {
assert.Equal(c, len(lines), testLen+1) assert.Equal(c, len(lines), testLen+1)
} }
func (s *DockerSuite) TestLogsFollowStopped(c *check.C) { func (s *DockerSuite) TestLogsFollowStopped(c *testing.T) {
dockerCmd(c, "run", "--name=test", "busybox", "echo", "hello") dockerCmd(c, "run", "--name=test", "busybox", "echo", "hello")
id := getIDByName(c, "test") id := getIDByName(c, "test")
@ -142,7 +142,7 @@ func (s *DockerSuite) TestLogsFollowStopped(c *check.C) {
} }
} }
func (s *DockerSuite) TestLogsSince(c *check.C) { func (s *DockerSuite) TestLogsSince(c *testing.T) {
name := "testlogssince" name := "testlogssince"
dockerCmd(c, "run", "--name="+name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do sleep 2; echo log$i; done") dockerCmd(c, "run", "--name="+name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do sleep 2; echo log$i; done")
out, _ := dockerCmd(c, "logs", "-t", name) out, _ := dockerCmd(c, "logs", "-t", name)
@ -177,7 +177,7 @@ func (s *DockerSuite) TestLogsSince(c *check.C) {
} }
} }
func (s *DockerSuite) TestLogsSinceFutureFollow(c *check.C) { func (s *DockerSuite) TestLogsSinceFutureFollow(c *testing.T) {
// TODO Windows TP5 - Figure out why this test is so flakey. Disabled for now. // TODO Windows TP5 - Figure out why this test is so flakey. Disabled for now.
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "testlogssincefuturefollow" name := "testlogssincefuturefollow"
@ -211,7 +211,7 @@ func (s *DockerSuite) TestLogsSinceFutureFollow(c *check.C) {
} }
// Regression test for #8832 // Regression test for #8832
func (s *DockerSuite) TestLogsFollowSlowStdoutConsumer(c *check.C) { func (s *DockerSuite) TestLogsFollowSlowStdoutConsumer(c *testing.T) {
// TODO Windows: Fix this test for TP5. // TODO Windows: Fix this test for TP5.
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
expected := 150000 expected := 150000
@ -269,7 +269,7 @@ func ConsumeWithSpeed(reader io.Reader, chunkSize int, interval time.Duration, s
} }
} }
func (s *DockerSuite) TestLogsFollowGoroutinesWithStdout(c *check.C) { func (s *DockerSuite) TestLogsFollowGoroutinesWithStdout(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "while true; do echo hello; sleep 2; done") out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "while true; do echo hello; sleep 2; done")
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
assert.NilError(c, waitRun(id)) assert.NilError(c, waitRun(id))
@ -297,7 +297,7 @@ func (s *DockerSuite) TestLogsFollowGoroutinesWithStdout(c *check.C) {
assert.NilError(c, waitForGoroutines(nroutines)) assert.NilError(c, waitForGoroutines(nroutines))
} }
func (s *DockerSuite) TestLogsFollowGoroutinesNoOutput(c *check.C) { func (s *DockerSuite) TestLogsFollowGoroutinesNoOutput(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "while true; do sleep 2; done") out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "while true; do sleep 2; done")
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
assert.NilError(c, waitRun(id)) assert.NilError(c, waitRun(id))
@ -315,14 +315,14 @@ func (s *DockerSuite) TestLogsFollowGoroutinesNoOutput(c *check.C) {
assert.NilError(c, waitForGoroutines(nroutines)) assert.NilError(c, waitForGoroutines(nroutines))
} }
func (s *DockerSuite) TestLogsCLIContainerNotFound(c *check.C) { func (s *DockerSuite) TestLogsCLIContainerNotFound(c *testing.T) {
name := "testlogsnocontainer" name := "testlogsnocontainer"
out, _, _ := dockerCmdWithError("logs", name) out, _, _ := dockerCmdWithError("logs", name)
message := fmt.Sprintf("No such container: %s\n", name) message := fmt.Sprintf("No such container: %s\n", name)
assert.Assert(c, strings.Contains(out, message)) assert.Assert(c, strings.Contains(out, message))
} }
func (s *DockerSuite) TestLogsWithDetails(c *check.C) { func (s *DockerSuite) TestLogsWithDetails(c *testing.T) {
dockerCmd(c, "run", "--name=test", "--label", "foo=bar", "-e", "baz=qux", "--log-opt", "labels=foo", "--log-opt", "env=baz", "busybox", "echo", "hello") dockerCmd(c, "run", "--name=test", "--label", "foo=bar", "-e", "baz=qux", "--log-opt", "labels=foo", "--log-opt", "env=baz", "busybox", "echo", "hello")
out, _ := dockerCmd(c, "logs", "--details", "--timestamps", "test") out, _ := dockerCmd(c, "logs", "--details", "--timestamps", "test")

View file

@ -17,20 +17,20 @@ const stringCheckPS = "PID USER"
// DockerCmdWithFail executes a docker command that is supposed to fail and returns // DockerCmdWithFail executes a docker command that is supposed to fail and returns
// the output, the exit code. If the command returns a Nil error, it will fail and // the output, the exit code. If the command returns a Nil error, it will fail and
// stop the tests. // stop the tests.
func dockerCmdWithFail(c *check.C, args ...string) (string, int) { func dockerCmdWithFail(c *testing.T, args ...string) (string, int) {
out, status, err := dockerCmdWithError(args...) out, status, err := dockerCmdWithError(args...)
assert.Assert(c, err, check.NotNil, check.Commentf("%v", out)) assert.Assert(c, err, check.NotNil, check.Commentf("%v", out))
return out, status return out, status
} }
func (s *DockerSuite) TestNetHostnameWithNetHost(c *check.C) { func (s *DockerSuite) TestNetHostnameWithNetHost(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace) testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmd(c, "run", "--net=host", "busybox", "ps") out, _ := dockerCmd(c, "run", "--net=host", "busybox", "ps")
assert.Assert(c, out, checker.Contains, stringCheckPS) assert.Assert(c, out, checker.Contains, stringCheckPS)
} }
func (s *DockerSuite) TestNetHostname(c *check.C) { func (s *DockerSuite) TestNetHostname(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-h=name", "busybox", "ps") out, _ := dockerCmd(c, "run", "-h=name", "busybox", "ps")
@ -52,28 +52,28 @@ func (s *DockerSuite) TestNetHostname(c *check.C) {
assert.Assert(c, strings.ToLower(out), checker.Contains, "not found") assert.Assert(c, strings.ToLower(out), checker.Contains, "not found")
} }
func (s *DockerSuite) TestConflictContainerNetworkAndLinks(c *check.C) { func (s *DockerSuite) TestConflictContainerNetworkAndLinks(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmdWithFail(c, "run", "--net=container:other", "--link=zip:zap", "busybox", "ps") out, _ := dockerCmdWithFail(c, "run", "--net=container:other", "--link=zip:zap", "busybox", "ps")
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictContainerNetworkAndLinks.Error()) assert.Assert(c, out, checker.Contains, runconfig.ErrConflictContainerNetworkAndLinks.Error())
} }
func (s *DockerSuite) TestConflictContainerNetworkHostAndLinks(c *check.C) { func (s *DockerSuite) TestConflictContainerNetworkHostAndLinks(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace) testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmdWithFail(c, "run", "--net=host", "--link=zip:zap", "busybox", "ps") out, _ := dockerCmdWithFail(c, "run", "--net=host", "--link=zip:zap", "busybox", "ps")
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetworkAndLinks.Error()) assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetworkAndLinks.Error())
} }
func (s *DockerSuite) TestConflictNetworkModeNetHostAndOptions(c *check.C) { func (s *DockerSuite) TestConflictNetworkModeNetHostAndOptions(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace) testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmdWithFail(c, "run", "--net=host", "--mac-address=92:d0:c6:0a:29:33", "busybox", "ps") out, _ := dockerCmdWithFail(c, "run", "--net=host", "--mac-address=92:d0:c6:0a:29:33", "busybox", "ps")
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictContainerNetworkAndMac.Error()) assert.Assert(c, out, checker.Contains, runconfig.ErrConflictContainerNetworkAndMac.Error())
} }
func (s *DockerSuite) TestConflictNetworkModeAndOptions(c *check.C) { func (s *DockerSuite) TestConflictNetworkModeAndOptions(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmdWithFail(c, "run", "--net=container:other", "--dns=8.8.8.8", "busybox", "ps") out, _ := dockerCmdWithFail(c, "run", "--net=container:other", "--dns=8.8.8.8", "busybox", "ps")

View file

@ -50,25 +50,25 @@ type DockerNetworkSuite struct {
d *daemon.Daemon d *daemon.Daemon
} }
func (s *DockerNetworkSuite) SetUpTest(c *check.C) { func (s *DockerNetworkSuite) SetUpTest(c *testing.T) {
s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
} }
func (s *DockerNetworkSuite) TearDownTest(c *check.C) { func (s *DockerNetworkSuite) TearDownTest(c *testing.T) {
if s.d != nil { if s.d != nil {
s.d.Stop(c) s.d.Stop(c)
s.ds.TearDownTest(c) s.ds.TearDownTest(c)
} }
} }
func (s *DockerNetworkSuite) SetUpSuite(c *check.C) { func (s *DockerNetworkSuite) SetUpSuite(c *testing.T) {
mux := http.NewServeMux() mux := http.NewServeMux()
s.server = httptest.NewServer(mux) s.server = httptest.NewServer(mux)
assert.Assert(c, s.server, check.NotNil, check.Commentf("Failed to start an HTTP Server")) assert.Assert(c, s.server, check.NotNil, check.Commentf("Failed to start an HTTP Server"))
setupRemoteNetworkDrivers(c, mux, s.server.URL, dummyNetworkDriver, dummyIPAMDriver) setupRemoteNetworkDrivers(c, mux, s.server.URL, dummyNetworkDriver, dummyIPAMDriver)
} }
func setupRemoteNetworkDrivers(c *check.C, mux *http.ServeMux, url, netDrv, ipamDrv string) { func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ipamDrv string) {
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json") w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
@ -221,7 +221,7 @@ func setupRemoteNetworkDrivers(c *check.C, mux *http.ServeMux, url, netDrv, ipam
assert.NilError(c, err) assert.NilError(c, err)
} }
func (s *DockerNetworkSuite) TearDownSuite(c *check.C) { func (s *DockerNetworkSuite) TearDownSuite(c *testing.T) {
if s.server == nil { if s.server == nil {
return return
} }
@ -232,19 +232,19 @@ func (s *DockerNetworkSuite) TearDownSuite(c *check.C) {
assert.NilError(c, err) assert.NilError(c, err)
} }
func assertNwIsAvailable(c *check.C, name string) { func assertNwIsAvailable(c *testing.T, name string) {
if !isNwPresent(c, name) { if !isNwPresent(c, name) {
c.Fatalf("Network %s not found in network ls o/p", name) c.Fatalf("Network %s not found in network ls o/p", name)
} }
} }
func assertNwNotAvailable(c *check.C, name string) { func assertNwNotAvailable(c *testing.T, name string) {
if isNwPresent(c, name) { if isNwPresent(c, name) {
c.Fatalf("Found network %s in network ls o/p", name) c.Fatalf("Found network %s in network ls o/p", name)
} }
} }
func isNwPresent(c *check.C, name string) bool { func isNwPresent(c *testing.T, name string) bool {
out, _ := dockerCmd(c, "network", "ls") out, _ := dockerCmd(c, "network", "ls")
lines := strings.Split(out, "\n") lines := strings.Split(out, "\n")
for i := 1; i < len(lines)-1; i++ { for i := 1; i < len(lines)-1; i++ {
@ -259,7 +259,7 @@ func isNwPresent(c *check.C, name string) bool {
// assertNwList checks network list retrieved with ls command // assertNwList checks network list retrieved with ls command
// equals to expected network list // equals to expected network list
// note: out should be `network ls [option]` result // note: out should be `network ls [option]` result
func assertNwList(c *check.C, out string, expectNws []string) { func assertNwList(c *testing.T, out string, expectNws []string) {
lines := strings.Split(out, "\n") lines := strings.Split(out, "\n")
var nwList []string var nwList []string
for _, line := range lines[1 : len(lines)-1] { for _, line := range lines[1 : len(lines)-1] {
@ -272,7 +272,7 @@ func assertNwList(c *check.C, out string, expectNws []string) {
assert.DeepEqual(c, nwList, expectNws) assert.DeepEqual(c, nwList, expectNws)
} }
func getNwResource(c *check.C, name string) *types.NetworkResource { func getNwResource(c *testing.T, name string) *types.NetworkResource {
out, _ := dockerCmd(c, "network", "inspect", name) out, _ := dockerCmd(c, "network", "inspect", name)
var nr []types.NetworkResource var nr []types.NetworkResource
err := json.Unmarshal([]byte(out), &nr) err := json.Unmarshal([]byte(out), &nr)
@ -280,14 +280,14 @@ func getNwResource(c *check.C, name string) *types.NetworkResource {
return &nr[0] return &nr[0]
} }
func (s *DockerNetworkSuite) TestDockerNetworkLsDefault(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkLsDefault(c *testing.T) {
defaults := []string{"bridge", "host", "none"} defaults := []string{"bridge", "host", "none"}
for _, nn := range defaults { for _, nn := range defaults {
assertNwIsAvailable(c, nn) assertNwIsAvailable(c, nn)
} }
} }
func (s *DockerNetworkSuite) TestDockerNetworkCreatePredefined(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkCreatePredefined(c *testing.T) {
predefined := []string{"bridge", "host", "none", "default"} predefined := []string{"bridge", "host", "none", "default"}
for _, net := range predefined { for _, net := range predefined {
// predefined networks can't be created again // predefined networks can't be created again
@ -296,7 +296,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkCreatePredefined(c *check.C) {
} }
} }
func (s *DockerNetworkSuite) TestDockerNetworkCreateHostBind(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkCreateHostBind(c *testing.T) {
dockerCmd(c, "network", "create", "--subnet=192.168.10.0/24", "--gateway=192.168.10.1", "-o", "com.docker.network.bridge.host_binding_ipv4=192.168.10.1", "testbind") dockerCmd(c, "network", "create", "--subnet=192.168.10.0/24", "--gateway=192.168.10.1", "-o", "com.docker.network.bridge.host_binding_ipv4=192.168.10.1", "testbind")
assertNwIsAvailable(c, "testbind") assertNwIsAvailable(c, "testbind")
@ -307,7 +307,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkCreateHostBind(c *check.C) {
assert.Assert(c, out, checker.Contains, "192.168.10.1:5000->5000/tcp") assert.Assert(c, out, checker.Contains, "192.168.10.1:5000->5000/tcp")
} }
func (s *DockerNetworkSuite) TestDockerNetworkRmPredefined(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkRmPredefined(c *testing.T) {
predefined := []string{"bridge", "host", "none", "default"} predefined := []string{"bridge", "host", "none", "default"}
for _, net := range predefined { for _, net := range predefined {
// predefined networks can't be removed // predefined networks can't be removed
@ -316,7 +316,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkRmPredefined(c *check.C) {
} }
} }
func (s *DockerNetworkSuite) TestDockerNetworkLsFilter(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkLsFilter(c *testing.T) {
testRequires(c, OnlyDefaultNetworks) testRequires(c, OnlyDefaultNetworks)
testNet := "testnet1" testNet := "testnet1"
testLabel := "foo" testLabel := "foo"
@ -372,7 +372,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkLsFilter(c *check.C) {
assertNwList(c, out, []string{"bridge", "dev", testNet}) assertNwList(c, out, []string{"bridge", "dev", testNet})
} }
func (s *DockerNetworkSuite) TestDockerNetworkCreateDelete(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkCreateDelete(c *testing.T) {
dockerCmd(c, "network", "create", "test") dockerCmd(c, "network", "create", "test")
assertNwIsAvailable(c, "test") assertNwIsAvailable(c, "test")
@ -380,7 +380,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkCreateDelete(c *check.C) {
assertNwNotAvailable(c, "test") assertNwNotAvailable(c, "test")
} }
func (s *DockerNetworkSuite) TestDockerNetworkCreateLabel(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkCreateLabel(c *testing.T) {
testNet := "testnetcreatelabel" testNet := "testnetcreatelabel"
testLabel := "foo" testLabel := "foo"
testValue := "bar" testValue := "bar"
@ -396,12 +396,12 @@ func (s *DockerNetworkSuite) TestDockerNetworkCreateLabel(c *check.C) {
assertNwNotAvailable(c, testNet) assertNwNotAvailable(c, testNet)
} }
func (s *DockerSuite) TestDockerNetworkDeleteNotExists(c *check.C) { func (s *DockerSuite) TestDockerNetworkDeleteNotExists(c *testing.T) {
out, _, err := dockerCmdWithError("network", "rm", "test") out, _, err := dockerCmdWithError("network", "rm", "test")
assert.ErrorContains(c, err, "", out) assert.ErrorContains(c, err, "", out)
} }
func (s *DockerSuite) TestDockerNetworkDeleteMultiple(c *check.C) { func (s *DockerSuite) TestDockerNetworkDeleteMultiple(c *testing.T) {
dockerCmd(c, "network", "create", "testDelMulti0") dockerCmd(c, "network", "create", "testDelMulti0")
assertNwIsAvailable(c, "testDelMulti0") assertNwIsAvailable(c, "testDelMulti0")
dockerCmd(c, "network", "create", "testDelMulti1") dockerCmd(c, "network", "create", "testDelMulti1")
@ -425,7 +425,7 @@ func (s *DockerSuite) TestDockerNetworkDeleteMultiple(c *check.C) {
assertNwIsAvailable(c, "testDelMulti2") assertNwIsAvailable(c, "testDelMulti2")
} }
func (s *DockerSuite) TestDockerNetworkInspect(c *check.C) { func (s *DockerSuite) TestDockerNetworkInspect(c *testing.T) {
out, _ := dockerCmd(c, "network", "inspect", "host") out, _ := dockerCmd(c, "network", "inspect", "host")
var networkResources []types.NetworkResource var networkResources []types.NetworkResource
err := json.Unmarshal([]byte(out), &networkResources) err := json.Unmarshal([]byte(out), &networkResources)
@ -436,7 +436,7 @@ func (s *DockerSuite) TestDockerNetworkInspect(c *check.C) {
assert.Assert(c, strings.TrimSpace(out), check.Equals, "host") assert.Assert(c, strings.TrimSpace(out), check.Equals, "host")
} }
func (s *DockerSuite) TestDockerNetworkInspectWithID(c *check.C) { func (s *DockerSuite) TestDockerNetworkInspectWithID(c *testing.T) {
out, _ := dockerCmd(c, "network", "create", "test2") out, _ := dockerCmd(c, "network", "create", "test2")
networkID := strings.TrimSpace(out) networkID := strings.TrimSpace(out)
assertNwIsAvailable(c, "test2") assertNwIsAvailable(c, "test2")
@ -447,7 +447,7 @@ func (s *DockerSuite) TestDockerNetworkInspectWithID(c *check.C) {
assert.Assert(c, strings.TrimSpace(out), check.Equals, networkID) assert.Assert(c, strings.TrimSpace(out), check.Equals, networkID)
} }
func (s *DockerSuite) TestDockerInspectMultipleNetwork(c *check.C) { func (s *DockerSuite) TestDockerInspectMultipleNetwork(c *testing.T) {
result := dockerCmdWithResult("network", "inspect", "host", "none") result := dockerCmdWithResult("network", "inspect", "host", "none")
result.Assert(c, icmd.Success) result.Assert(c, icmd.Success)
@ -457,7 +457,7 @@ func (s *DockerSuite) TestDockerInspectMultipleNetwork(c *check.C) {
assert.Equal(c, len(networkResources), 2) assert.Equal(c, len(networkResources), 2)
} }
func (s *DockerSuite) TestDockerInspectMultipleNetworksIncludingNonexistent(c *check.C) { func (s *DockerSuite) TestDockerInspectMultipleNetworksIncludingNonexistent(c *testing.T) {
// non-existent network was not at the beginning of the inspect list // non-existent network was not at the beginning of the inspect list
// This should print an error, return an exitCode 1 and print the host network // This should print an error, return an exitCode 1 and print the host network
result := dockerCmdWithResult("network", "inspect", "host", "nonexistent") result := dockerCmdWithResult("network", "inspect", "host", "nonexistent")
@ -496,7 +496,7 @@ func (s *DockerSuite) TestDockerInspectMultipleNetworksIncludingNonexistent(c *c
assert.Equal(c, len(networkResources), 1) assert.Equal(c, len(networkResources), 1)
} }
func (s *DockerSuite) TestDockerInspectNetworkWithContainerName(c *check.C) { func (s *DockerSuite) TestDockerInspectNetworkWithContainerName(c *testing.T) {
dockerCmd(c, "network", "create", "brNetForInspect") dockerCmd(c, "network", "create", "brNetForInspect")
assertNwIsAvailable(c, "brNetForInspect") assertNwIsAvailable(c, "brNetForInspect")
defer func() { defer func() {
@ -536,7 +536,7 @@ func (s *DockerSuite) TestDockerInspectNetworkWithContainerName(c *check.C) {
assert.Equal(c, container1.Name, newName) assert.Equal(c, container1.Name, newName)
} }
func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnect(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnect(c *testing.T) {
dockerCmd(c, "network", "create", "test") dockerCmd(c, "network", "create", "test")
assertNwIsAvailable(c, "test") assertNwIsAvailable(c, "test")
nr := getNwResource(c, "test") nr := getNwResource(c, "test")
@ -588,7 +588,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnect(c *check.C) {
assertNwNotAvailable(c, "test") assertNwNotAvailable(c, "test")
} }
func (s *DockerNetworkSuite) TestDockerNetworkIPAMMultipleNetworks(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkIPAMMultipleNetworks(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
// test0 bridge network // test0 bridge network
dockerCmd(c, "network", "create", "--subnet=192.168.0.0/16", "test1") dockerCmd(c, "network", "create", "--subnet=192.168.0.0/16", "test1")
@ -629,7 +629,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkIPAMMultipleNetworks(c *check.C) {
} }
} }
func (s *DockerNetworkSuite) TestDockerNetworkCustomIPAM(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkCustomIPAM(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
// Create a bridge network using custom ipam driver // Create a bridge network using custom ipam driver
dockerCmd(c, "network", "create", "--ipam-driver", dummyIPAMDriver, "br0") dockerCmd(c, "network", "create", "--ipam-driver", dummyIPAMDriver, "br0")
@ -645,7 +645,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkCustomIPAM(c *check.C) {
assertNwNotAvailable(c, "br0") assertNwNotAvailable(c, "br0")
} }
func (s *DockerNetworkSuite) TestDockerNetworkIPAMOptions(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkIPAMOptions(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
// Create a bridge network using custom ipam driver and options // Create a bridge network using custom ipam driver and options
dockerCmd(c, "network", "create", "--ipam-driver", dummyIPAMDriver, "--ipam-opt", "opt1=drv1", "--ipam-opt", "opt2=drv2", "br0") dockerCmd(c, "network", "create", "--ipam-driver", dummyIPAMDriver, "--ipam-opt", "opt1=drv1", "--ipam-opt", "opt2=drv2", "br0")
@ -658,7 +658,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkIPAMOptions(c *check.C) {
assert.Assert(c, opts["opt2"], checker.Equals, "drv2") assert.Assert(c, opts["opt2"], checker.Equals, "drv2")
} }
func (s *DockerNetworkSuite) TestDockerNetworkNullIPAMDriver(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkNullIPAMDriver(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
// Create a network with null ipam driver // Create a network with null ipam driver
_, _, err := dockerCmdWithError("network", "create", "-d", dummyNetworkDriver, "--ipam-driver", "null", "test000") _, _, err := dockerCmdWithError("network", "create", "-d", dummyNetworkDriver, "--ipam-driver", "null", "test000")
@ -674,7 +674,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkNullIPAMDriver(c *check.C) {
assert.Assert(c, nr.IPAM.Config[0].Gateway, checker.Equals, "") assert.Assert(c, nr.IPAM.Config[0].Gateway, checker.Equals, "")
} }
func (s *DockerNetworkSuite) TestDockerNetworkInspectDefault(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkInspectDefault(c *testing.T) {
nr := getNetworkResource(c, "none") nr := getNetworkResource(c, "none")
assert.Assert(c, nr.Driver, checker.Equals, "null") assert.Assert(c, nr.Driver, checker.Equals, "null")
assert.Assert(c, nr.Scope, checker.Equals, "local") assert.Assert(c, nr.Scope, checker.Equals, "local")
@ -700,7 +700,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkInspectDefault(c *check.C) {
assert.Assert(c, len(nr.IPAM.Config), checker.Equals, 1) assert.Assert(c, len(nr.IPAM.Config), checker.Equals, 1)
} }
func (s *DockerNetworkSuite) TestDockerNetworkInspectCustomUnspecified(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkInspectCustomUnspecified(c *testing.T) {
// if unspecified, network subnet will be selected from inside preferred pool // if unspecified, network subnet will be selected from inside preferred pool
dockerCmd(c, "network", "create", "test01") dockerCmd(c, "network", "create", "test01")
assertNwIsAvailable(c, "test01") assertNwIsAvailable(c, "test01")
@ -717,7 +717,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkInspectCustomUnspecified(c *check.
assertNwNotAvailable(c, "test01") assertNwNotAvailable(c, "test01")
} }
func (s *DockerNetworkSuite) TestDockerNetworkInspectCustomSpecified(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkInspectCustomSpecified(c *testing.T) {
dockerCmd(c, "network", "create", "--driver=bridge", "--ipv6", "--subnet=fd80:24e2:f998:72d6::/64", "--subnet=172.28.0.0/16", "--ip-range=172.28.5.0/24", "--gateway=172.28.5.254", "br0") dockerCmd(c, "network", "create", "--driver=bridge", "--ipv6", "--subnet=fd80:24e2:f998:72d6::/64", "--subnet=172.28.0.0/16", "--ip-range=172.28.5.0/24", "--gateway=172.28.5.254", "br0")
assertNwIsAvailable(c, "br0") assertNwIsAvailable(c, "br0")
@ -736,7 +736,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkInspectCustomSpecified(c *check.C)
assertNwNotAvailable(c, "br0") assertNwNotAvailable(c, "br0")
} }
func (s *DockerNetworkSuite) TestDockerNetworkIPAMInvalidCombinations(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkIPAMInvalidCombinations(c *testing.T) {
// network with ip-range out of subnet range // network with ip-range out of subnet range
_, _, err := dockerCmdWithError("network", "create", "--subnet=192.168.0.0/16", "--ip-range=192.170.0.0/16", "test") _, _, err := dockerCmdWithError("network", "create", "--subnet=192.168.0.0/16", "--ip-range=192.170.0.0/16", "test")
assert.ErrorContains(c, err, "") assert.ErrorContains(c, err, "")
@ -760,7 +760,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkIPAMInvalidCombinations(c *check.C
assertNwNotAvailable(c, "test0") assertNwNotAvailable(c, "test0")
} }
func (s *DockerNetworkSuite) TestDockerNetworkDriverOptions(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkDriverOptions(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
dockerCmd(c, "network", "create", "-d", dummyNetworkDriver, "-o", "opt1=drv1", "-o", "opt2=drv2", "testopt") dockerCmd(c, "network", "create", "-d", dummyNetworkDriver, "-o", "opt1=drv1", "-o", "opt2=drv2", "testopt")
assertNwIsAvailable(c, "testopt") assertNwIsAvailable(c, "testopt")
@ -775,7 +775,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDriverOptions(c *check.C) {
} }
func (s *DockerNetworkSuite) TestDockerPluginV2NetworkDriver(c *check.C) { func (s *DockerNetworkSuite) TestDockerPluginV2NetworkDriver(c *testing.T) {
testRequires(c, DaemonIsLinux, IsAmd64, Network) testRequires(c, DaemonIsLinux, IsAmd64, Network)
var ( var (
@ -799,7 +799,7 @@ func (s *DockerNetworkSuite) TestDockerPluginV2NetworkDriver(c *check.C) {
} }
func (s *DockerDaemonSuite) TestDockerNetworkNoDiscoveryDefaultBridgeNetwork(c *check.C) { func (s *DockerDaemonSuite) TestDockerNetworkNoDiscoveryDefaultBridgeNetwork(c *testing.T) {
// On default bridge network built-in service discovery should not happen // On default bridge network built-in service discovery should not happen
hostsFile := "/etc/hosts" hostsFile := "/etc/hosts"
bridgeName := "external-bridge" bridgeName := "external-bridge"
@ -851,7 +851,7 @@ func (s *DockerDaemonSuite) TestDockerNetworkNoDiscoveryDefaultBridgeNetwork(c *
assert.Assert(c, string(hosts), checker.Equals, string(hostsPost), check.Commentf("Unexpected %s change on second network connection", hostsFile)) assert.Assert(c, string(hosts), checker.Equals, string(hostsPost), check.Commentf("Unexpected %s change on second network connection", hostsFile))
} }
func (s *DockerNetworkSuite) TestDockerNetworkAnonymousEndpoint(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkAnonymousEndpoint(c *testing.T) {
testRequires(c, NotArm) testRequires(c, NotArm)
hostsFile := "/etc/hosts" hostsFile := "/etc/hosts"
cstmBridgeNw := "custom-bridge-nw" cstmBridgeNw := "custom-bridge-nw"
@ -904,7 +904,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkAnonymousEndpoint(c *check.C) {
assert.ErrorContains(c, err, "") assert.ErrorContains(c, err, "")
} }
func (s *DockerNetworkSuite) TestDockerNetworkLinkOnDefaultNetworkOnly(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkLinkOnDefaultNetworkOnly(c *testing.T) {
// Legacy Link feature must work only on default network, and not across networks // Legacy Link feature must work only on default network, and not across networks
cnt1 := "container1" cnt1 := "container1"
cnt2 := "container2" cnt2 := "container2"
@ -930,7 +930,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkLinkOnDefaultNetworkOnly(c *check.
dockerCmd(c, "run", "-d", "--link", fmt.Sprintf("%s:%s", cnt2, cnt2), "busybox", "top") dockerCmd(c, "run", "-d", "--link", fmt.Sprintf("%s:%s", cnt2, cnt2), "busybox", "top")
} }
func (s *DockerNetworkSuite) TestDockerNetworkOverlayPortMapping(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkOverlayPortMapping(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
// Verify exposed ports are present in ps output when running a container on // Verify exposed ports are present in ps output when running a container on
// a network managed by a driver which does not provide the default gateway // a network managed by a driver which does not provide the default gateway
@ -957,7 +957,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkOverlayPortMapping(c *check.C) {
assert.Assert(c, out, checker.Contains, unpPort2) assert.Assert(c, out, checker.Contains, unpPort2)
} }
func (s *DockerNetworkSuite) TestDockerNetworkDriverUngracefulRestart(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkDriverUngracefulRestart(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, NotUserNamespace, testEnv.IsLocalDaemon)
dnd := "dnd" dnd := "dnd"
did := "did" did := "did"
@ -998,7 +998,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDriverUngracefulRestart(c *check.C
assert.NilError(c, err) assert.NilError(c, err)
} }
func (s *DockerNetworkSuite) TestDockerNetworkMacInspect(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkMacInspect(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
// Verify endpoint MAC address is correctly populated in container's network settings // Verify endpoint MAC address is correctly populated in container's network settings
nwn := "ov" nwn := "ov"
@ -1013,7 +1013,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkMacInspect(c *check.C) {
assert.Assert(c, mac, checker.Equals, "a0:b1:c2:d3:e4:f5") assert.Assert(c, mac, checker.Equals, "a0:b1:c2:d3:e4:f5")
} }
func (s *DockerSuite) TestInspectAPIMultipleNetworks(c *check.C) { func (s *DockerSuite) TestInspectAPIMultipleNetworks(c *testing.T) {
dockerCmd(c, "network", "create", "mybridge1") dockerCmd(c, "network", "create", "mybridge1")
dockerCmd(c, "network", "create", "mybridge2") dockerCmd(c, "network", "create", "mybridge2")
out, _ := dockerCmd(c, "run", "-d", "busybox", "top") out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
@ -1041,7 +1041,7 @@ func (s *DockerSuite) TestInspectAPIMultipleNetworks(c *check.C) {
assert.Assert(c, bridge.IPAddress, checker.Equals, inspect121.NetworkSettings.IPAddress) assert.Assert(c, bridge.IPAddress, checker.Equals, inspect121.NetworkSettings.IPAddress)
} }
func connectContainerToNetworks(c *check.C, d *daemon.Daemon, cName string, nws []string) { func connectContainerToNetworks(c *testing.T, d *daemon.Daemon, cName string, nws []string) {
// Run a container on the default network // Run a container on the default network
out, err := d.Cmd("run", "-d", "--name", cName, "busybox", "top") out, err := d.Cmd("run", "-d", "--name", cName, "busybox", "top")
assert.NilError(c, err, out) assert.NilError(c, err, out)
@ -1055,7 +1055,7 @@ func connectContainerToNetworks(c *check.C, d *daemon.Daemon, cName string, nws
} }
} }
func verifyContainerIsConnectedToNetworks(c *check.C, d *daemon.Daemon, cName string, nws []string) { func verifyContainerIsConnectedToNetworks(c *testing.T, d *daemon.Daemon, cName string, nws []string) {
// Verify container is connected to all the networks // Verify container is connected to all the networks
for _, nw := range nws { for _, nw := range nws {
out, err := d.Cmd("inspect", "-f", fmt.Sprintf("{{.NetworkSettings.Networks.%s}}", nw), cName) out, err := d.Cmd("inspect", "-f", fmt.Sprintf("{{.NetworkSettings.Networks.%s}}", nw), cName)
@ -1064,7 +1064,7 @@ func verifyContainerIsConnectedToNetworks(c *check.C, d *daemon.Daemon, cName st
} }
} }
func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksGracefulDaemonRestart(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksGracefulDaemonRestart(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
cName := "bb" cName := "bb"
nwList := []string{"nw1", "nw2", "nw3"} nwList := []string{"nw1", "nw2", "nw3"}
@ -1083,7 +1083,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksGracefulDaemonRest
verifyContainerIsConnectedToNetworks(c, s.d, cName, nwList) verifyContainerIsConnectedToNetworks(c, s.d, cName, nwList)
} }
func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksUngracefulDaemonRestart(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksUngracefulDaemonRestart(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
cName := "cc" cName := "cc"
nwList := []string{"nw1", "nw2", "nw3"} nwList := []string{"nw1", "nw2", "nw3"}
@ -1104,13 +1104,13 @@ func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksUngracefulDaemonRe
verifyContainerIsConnectedToNetworks(c, s.d, cName, nwList) verifyContainerIsConnectedToNetworks(c, s.d, cName, nwList)
} }
func (s *DockerNetworkSuite) TestDockerNetworkRunNetByID(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkRunNetByID(c *testing.T) {
out, _ := dockerCmd(c, "network", "create", "one") out, _ := dockerCmd(c, "network", "create", "one")
containerOut, _, err := dockerCmdWithError("run", "-d", "--net", strings.TrimSpace(out), "busybox", "top") containerOut, _, err := dockerCmdWithError("run", "-d", "--net", strings.TrimSpace(out), "busybox", "top")
assert.Assert(c, err, checker.IsNil, check.Commentf(containerOut)) assert.Assert(c, err, checker.IsNil, check.Commentf(containerOut))
} }
func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, NotUserNamespace, testEnv.IsLocalDaemon)
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
@ -1136,7 +1136,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c
} }
} }
func (s *DockerNetworkSuite) TestDockerNetworkConnectToHostFromOtherNetwork(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkConnectToHostFromOtherNetwork(c *testing.T) {
dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top") dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
assert.Assert(c, waitRun("container1"), check.IsNil) assert.Assert(c, waitRun("container1"), check.IsNil)
dockerCmd(c, "network", "disconnect", "bridge", "container1") dockerCmd(c, "network", "disconnect", "bridge", "container1")
@ -1145,7 +1145,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectToHostFromOtherNetwork(c *c
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetwork.Error()) assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetwork.Error())
} }
func (s *DockerNetworkSuite) TestDockerNetworkDisconnectFromHost(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkDisconnectFromHost(c *testing.T) {
dockerCmd(c, "run", "-d", "--name", "container1", "--net=host", "busybox", "top") dockerCmd(c, "run", "-d", "--name", "container1", "--net=host", "busybox", "top")
assert.Assert(c, waitRun("container1"), check.IsNil) assert.Assert(c, waitRun("container1"), check.IsNil)
out, _, err := dockerCmdWithError("network", "disconnect", "host", "container1") out, _, err := dockerCmdWithError("network", "disconnect", "host", "container1")
@ -1153,7 +1153,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDisconnectFromHost(c *check.C) {
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetwork.Error()) assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetwork.Error())
} }
func (s *DockerNetworkSuite) TestDockerNetworkConnectWithPortMapping(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkConnectWithPortMapping(c *testing.T) {
testRequires(c, NotArm) testRequires(c, NotArm)
dockerCmd(c, "network", "create", "test1") dockerCmd(c, "network", "create", "test1")
dockerCmd(c, "run", "-d", "--name", "c1", "-p", "5000:5000", "busybox", "top") dockerCmd(c, "run", "-d", "--name", "c1", "-p", "5000:5000", "busybox", "top")
@ -1161,7 +1161,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectWithPortMapping(c *check.C)
dockerCmd(c, "network", "connect", "test1", "c1") dockerCmd(c, "network", "connect", "test1", "c1")
} }
func verifyPortMap(c *check.C, container, port, originalMapping string, mustBeEqual bool) { func verifyPortMap(c *testing.T, container, port, originalMapping string, mustBeEqual bool) {
currentMapping, _ := dockerCmd(c, "port", container, port) currentMapping, _ := dockerCmd(c, "port", container, port)
if mustBeEqual { if mustBeEqual {
assert.Assert(c, currentMapping, checker.Equals, originalMapping) assert.Assert(c, currentMapping, checker.Equals, originalMapping)
@ -1170,7 +1170,7 @@ func verifyPortMap(c *check.C, container, port, originalMapping string, mustBeEq
} }
} }
func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectWithPortMapping(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectWithPortMapping(c *testing.T) {
// Connect and disconnect a container with explicit and non-explicit // Connect and disconnect a container with explicit and non-explicit
// host port mapping to/from networks which do cause and do not cause // host port mapping to/from networks which do cause and do not cause
// the container default gateway to change, and verify docker port cmd // the container default gateway to change, and verify docker port cmd
@ -1207,7 +1207,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectWithPortMapping(c
verifyPortMap(c, cnt, "90", curExplPortMap, true) verifyPortMap(c, cnt, "90", curExplPortMap, true)
} }
func (s *DockerNetworkSuite) TestDockerNetworkConnectWithMac(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkConnectWithMac(c *testing.T) {
macAddress := "02:42:ac:11:00:02" macAddress := "02:42:ac:11:00:02"
dockerCmd(c, "network", "create", "mynetwork") dockerCmd(c, "network", "create", "mynetwork")
dockerCmd(c, "run", "--name=test", "-d", "--mac-address", macAddress, "busybox", "top") dockerCmd(c, "run", "--name=test", "-d", "--mac-address", macAddress, "busybox", "top")
@ -1219,13 +1219,13 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectWithMac(c *check.C) {
assert.Assert(c, strings.TrimSpace(mac2), checker.Not(checker.Equals), strings.TrimSpace(mac1)) assert.Assert(c, strings.TrimSpace(mac2), checker.Not(checker.Equals), strings.TrimSpace(mac1))
} }
func (s *DockerNetworkSuite) TestDockerNetworkInspectCreatedContainer(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkInspectCreatedContainer(c *testing.T) {
dockerCmd(c, "create", "--name", "test", "busybox") dockerCmd(c, "create", "--name", "test", "busybox")
networks := inspectField(c, "test", "NetworkSettings.Networks") networks := inspectField(c, "test", "NetworkSettings.Networks")
assert.Assert(c, networks, checker.Contains, "bridge", check.Commentf("Should return 'bridge' network")) assert.Assert(c, networks, checker.Contains, "bridge", check.Commentf("Should return 'bridge' network"))
} }
func (s *DockerNetworkSuite) TestDockerNetworkRestartWithMultipleNetworks(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkRestartWithMultipleNetworks(c *testing.T) {
dockerCmd(c, "network", "create", "test") dockerCmd(c, "network", "create", "test")
dockerCmd(c, "run", "--name=foo", "-d", "busybox", "top") dockerCmd(c, "run", "--name=foo", "-d", "busybox", "top")
assert.Assert(c, waitRun("foo"), checker.IsNil) assert.Assert(c, waitRun("foo"), checker.IsNil)
@ -1236,7 +1236,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkRestartWithMultipleNetworks(c *che
assert.Assert(c, networks, checker.Contains, "test", check.Commentf("Should contain 'test' network")) assert.Assert(c, networks, checker.Contains, "test", check.Commentf("Should contain 'test' network"))
} }
func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectToStoppedContainer(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectToStoppedContainer(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon) testRequires(c, testEnv.IsLocalDaemon)
dockerCmd(c, "network", "create", "test") dockerCmd(c, "network", "create", "test")
dockerCmd(c, "create", "--name=foo", "busybox", "top") dockerCmd(c, "create", "--name=foo", "busybox", "top")
@ -1270,7 +1270,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectToStoppedContaine
} }
func (s *DockerNetworkSuite) TestDockerNetworkDisconnectContainerNonexistingNetwork(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkDisconnectContainerNonexistingNetwork(c *testing.T) {
dockerCmd(c, "network", "create", "test") dockerCmd(c, "network", "create", "test")
dockerCmd(c, "run", "--net=test", "-d", "--name=foo", "busybox", "top") dockerCmd(c, "run", "--net=test", "-d", "--name=foo", "busybox", "top")
networks := inspectField(c, "foo", "NetworkSettings.Networks") networks := inspectField(c, "foo", "NetworkSettings.Networks")
@ -1286,7 +1286,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDisconnectContainerNonexistingNetw
assert.Assert(c, networks, checker.Not(checker.Contains), "test", check.Commentf("Should not contain 'test' network")) assert.Assert(c, networks, checker.Not(checker.Contains), "test", check.Commentf("Should not contain 'test' network"))
} }
func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIP(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIP(c *testing.T) {
// create two networks // create two networks
dockerCmd(c, "network", "create", "--ipv6", "--subnet=172.28.0.0/16", "--subnet=2001:db8:1234::/64", "n0") dockerCmd(c, "network", "create", "--ipv6", "--subnet=172.28.0.0/16", "--subnet=2001:db8:1234::/64", "n0")
assertNwIsAvailable(c, "n0") assertNwIsAvailable(c, "n0")
@ -1322,7 +1322,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIP(c *check.C) {
} }
func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIPStoppedContainer(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIPStoppedContainer(c *testing.T) {
// create a container // create a container
dockerCmd(c, "create", "--name", "c0", "busybox", "top") dockerCmd(c, "create", "--name", "c0", "busybox", "top")
@ -1345,7 +1345,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIPStoppedContainer
verifyIPAddressConfig(c, "c0", "n0", "172.30.55.44", "2001:db8:abcd::5544") verifyIPAddressConfig(c, "c0", "n0", "172.30.55.44", "2001:db8:abcd::5544")
} }
func (s *DockerNetworkSuite) TestDockerNetworkUnsupportedRequiredIP(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkUnsupportedRequiredIP(c *testing.T) {
// requested IP is not supported on predefined networks // requested IP is not supported on predefined networks
for _, mode := range []string{"none", "host", "bridge", "default"} { for _, mode := range []string{"none", "host", "bridge", "default"} {
checkUnsupportedNetworkAndIP(c, mode) checkUnsupportedNetworkAndIP(c, mode)
@ -1367,13 +1367,13 @@ func (s *DockerNetworkSuite) TestDockerNetworkUnsupportedRequiredIP(c *check.C)
assertNwNotAvailable(c, "n0") assertNwNotAvailable(c, "n0")
} }
func checkUnsupportedNetworkAndIP(c *check.C, nwMode string) { func checkUnsupportedNetworkAndIP(c *testing.T, nwMode string) {
out, _, err := dockerCmdWithError("run", "-d", "--net", nwMode, "--ip", "172.28.99.88", "--ip6", "2001:db8:1234::9988", "busybox", "top") out, _, err := dockerCmdWithError("run", "-d", "--net", nwMode, "--ip", "172.28.99.88", "--ip6", "2001:db8:1234::9988", "busybox", "top")
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out))
assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkAndIP.Error()) assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkAndIP.Error())
} }
func verifyIPAddressConfig(c *check.C, cName, nwname, ipv4, ipv6 string) { func verifyIPAddressConfig(c *testing.T, cName, nwname, ipv4, ipv6 string) {
if ipv4 != "" { if ipv4 != "" {
out := inspectField(c, cName, fmt.Sprintf("NetworkSettings.Networks.%s.IPAMConfig.IPv4Address", nwname)) out := inspectField(c, cName, fmt.Sprintf("NetworkSettings.Networks.%s.IPAMConfig.IPv4Address", nwname))
assert.Assert(c, strings.TrimSpace(out), check.Equals, ipv4) assert.Assert(c, strings.TrimSpace(out), check.Equals, ipv4)
@ -1385,7 +1385,7 @@ func verifyIPAddressConfig(c *check.C, cName, nwname, ipv4, ipv6 string) {
} }
} }
func verifyIPAddresses(c *check.C, cName, nwname, ipv4, ipv6 string) { func verifyIPAddresses(c *testing.T, cName, nwname, ipv4, ipv6 string) {
out := inspectField(c, cName, fmt.Sprintf("NetworkSettings.Networks.%s.IPAddress", nwname)) out := inspectField(c, cName, fmt.Sprintf("NetworkSettings.Networks.%s.IPAddress", nwname))
assert.Assert(c, strings.TrimSpace(out), check.Equals, ipv4) assert.Assert(c, strings.TrimSpace(out), check.Equals, ipv4)
@ -1393,7 +1393,7 @@ func verifyIPAddresses(c *check.C, cName, nwname, ipv4, ipv6 string) {
assert.Assert(c, strings.TrimSpace(out), check.Equals, ipv6) assert.Assert(c, strings.TrimSpace(out), check.Equals, ipv6)
} }
func (s *DockerNetworkSuite) TestDockerNetworkConnectLinkLocalIP(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkConnectLinkLocalIP(c *testing.T) {
// create one test network // create one test network
dockerCmd(c, "network", "create", "--ipv6", "--subnet=2001:db8:1234::/64", "n0") dockerCmd(c, "network", "create", "--ipv6", "--subnet=2001:db8:1234::/64", "n0")
assertNwIsAvailable(c, "n0") assertNwIsAvailable(c, "n0")
@ -1440,7 +1440,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectLinkLocalIP(c *check.C) {
assert.NilError(c, err) assert.NilError(c, err)
} }
func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectLink(c *check.C) { func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectLink(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
dockerCmd(c, "network", "create", "-d", "bridge", "foo1") dockerCmd(c, "network", "create", "-d", "bridge", "foo1")
dockerCmd(c, "network", "create", "-d", "bridge", "foo2") dockerCmd(c, "network", "create", "-d", "bridge", "foo2")
@ -1481,7 +1481,7 @@ func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectLink(c *check.C) {
assert.NilError(c, err) assert.NilError(c, err)
} }
func (s *DockerNetworkSuite) TestDockerNetworkDisconnectDefault(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkDisconnectDefault(c *testing.T) {
netWorkName1 := "test1" netWorkName1 := "test1"
netWorkName2 := "test2" netWorkName2 := "test2"
containerName := "foo" containerName := "foo"
@ -1501,7 +1501,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDisconnectDefault(c *check.C) {
assert.Assert(c, networks, checker.Not(checker.Contains), "bridge", check.Commentf("Should not contain 'bridge' network")) assert.Assert(c, networks, checker.Not(checker.Contains), "bridge", check.Commentf("Should not contain 'bridge' network"))
} }
func (s *DockerNetworkSuite) TestDockerNetworkConnectWithAliasOnDefaultNetworks(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkConnectWithAliasOnDefaultNetworks(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
defaults := []string{"bridge", "host", "none"} defaults := []string{"bridge", "host", "none"}
@ -1514,7 +1514,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectWithAliasOnDefaultNetworks(
} }
} }
func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *check.C) { func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
dockerCmd(c, "network", "create", "-d", "bridge", "net1") dockerCmd(c, "network", "create", "-d", "bridge", "net1")
dockerCmd(c, "network", "create", "-d", "bridge", "net2") dockerCmd(c, "network", "create", "-d", "bridge", "net2")
@ -1569,7 +1569,7 @@ func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *check.C) {
assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error()) assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error())
} }
func (s *DockerSuite) TestUserDefinedNetworkConnectivity(c *check.C) { func (s *DockerSuite) TestUserDefinedNetworkConnectivity(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace) testRequires(c, DaemonIsLinux, NotUserNamespace)
dockerCmd(c, "network", "create", "-d", "bridge", "br.net1") dockerCmd(c, "network", "create", "-d", "bridge", "br.net1")
@ -1592,7 +1592,7 @@ func (s *DockerSuite) TestUserDefinedNetworkConnectivity(c *check.C) {
assert.ErrorContains(c, err, "") assert.ErrorContains(c, err, "")
} }
func (s *DockerSuite) TestEmbeddedDNSInvalidInput(c *check.C) { func (s *DockerSuite) TestEmbeddedDNSInvalidInput(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace) testRequires(c, DaemonIsLinux, NotUserNamespace)
dockerCmd(c, "network", "create", "-d", "bridge", "nw1") dockerCmd(c, "network", "create", "-d", "bridge", "nw1")
@ -1600,7 +1600,7 @@ func (s *DockerSuite) TestEmbeddedDNSInvalidInput(c *check.C) {
dockerCmd(c, "run", "-i", "--net=nw1", "--name=c1", "debian:jessie", "bash", "-c", "echo InvalidQuery > /dev/udp/127.0.0.11/53") dockerCmd(c, "run", "-i", "--net=nw1", "--name=c1", "debian:jessie", "bash", "-c", "echo InvalidQuery > /dev/udp/127.0.0.11/53")
} }
func (s *DockerSuite) TestDockerNetworkConnectFailsNoInspectChange(c *check.C) { func (s *DockerSuite) TestDockerNetworkConnectFailsNoInspectChange(c *testing.T) {
dockerCmd(c, "run", "-d", "--name=bb", "busybox", "top") dockerCmd(c, "run", "-d", "--name=bb", "busybox", "top")
assert.Assert(c, waitRun("bb"), check.IsNil) assert.Assert(c, waitRun("bb"), check.IsNil)
defer dockerCmd(c, "stop", "bb") defer dockerCmd(c, "stop", "bb")
@ -1615,7 +1615,7 @@ func (s *DockerSuite) TestDockerNetworkConnectFailsNoInspectChange(c *check.C) {
assert.Assert(c, ns1, check.Equals, ns0) assert.Assert(c, ns1, check.Equals, ns0)
} }
func (s *DockerSuite) TestDockerNetworkInternalMode(c *check.C) { func (s *DockerSuite) TestDockerNetworkInternalMode(c *testing.T) {
dockerCmd(c, "network", "create", "--driver=bridge", "--internal", "internal") dockerCmd(c, "network", "create", "--driver=bridge", "--internal", "internal")
assertNwIsAvailable(c, "internal") assertNwIsAvailable(c, "internal")
nr := getNetworkResource(c, "internal") nr := getNetworkResource(c, "internal")
@ -1633,7 +1633,7 @@ func (s *DockerSuite) TestDockerNetworkInternalMode(c *check.C) {
} }
// Test for #21401 // Test for #21401
func (s *DockerNetworkSuite) TestDockerNetworkCreateDeleteSpecialCharacters(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkCreateDeleteSpecialCharacters(c *testing.T) {
dockerCmd(c, "network", "create", "test@#$") dockerCmd(c, "network", "create", "test@#$")
assertNwIsAvailable(c, "test@#$") assertNwIsAvailable(c, "test@#$")
dockerCmd(c, "network", "rm", "test@#$") dockerCmd(c, "network", "rm", "test@#$")
@ -1645,7 +1645,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkCreateDeleteSpecialCharacters(c *c
assertNwNotAvailable(c, "kiwl$%^") assertNwNotAvailable(c, "kiwl$%^")
} }
func (s *DockerDaemonSuite) TestDaemonRestartRestoreBridgeNetwork(t *check.C) { func (s *DockerDaemonSuite) TestDaemonRestartRestoreBridgeNetwork(t *testing.T) {
s.d.StartWithBusybox(t, "--live-restore") s.d.StartWithBusybox(t, "--live-restore")
defer s.d.Stop(t) defer s.d.Stop(t)
oldCon := "old" oldCon := "old"
@ -1714,7 +1714,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartRestoreBridgeNetwork(t *check.C) {
} }
} }
func (s *DockerNetworkSuite) TestDockerNetworkFlagAlias(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkFlagAlias(c *testing.T) {
dockerCmd(c, "network", "create", "user") dockerCmd(c, "network", "create", "user")
output, status := dockerCmd(c, "run", "--rm", "--network=user", "--network-alias=foo", "busybox", "true") output, status := dockerCmd(c, "run", "--rm", "--network=user", "--network-alias=foo", "busybox", "true")
assert.Assert(c, status, checker.Equals, 0, check.Commentf("unexpected status code %d (%s)", status, output)) assert.Assert(c, status, checker.Equals, 0, check.Commentf("unexpected status code %d (%s)", status, output))
@ -1726,7 +1726,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkFlagAlias(c *check.C) {
assert.Assert(c, status, checker.Equals, 0, check.Commentf("unexpected status code %d (%s)", status, output)) assert.Assert(c, status, checker.Equals, 0, check.Commentf("unexpected status code %d (%s)", status, output))
} }
func (s *DockerNetworkSuite) TestDockerNetworkValidateIP(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkValidateIP(c *testing.T) {
_, _, err := dockerCmdWithError("network", "create", "--ipv6", "--subnet=172.28.0.0/16", "--subnet=2001:db8:1234::/64", "mynet") _, _, err := dockerCmdWithError("network", "create", "--ipv6", "--subnet=172.28.0.0/16", "--subnet=2001:db8:1234::/64", "mynet")
assert.NilError(c, err) assert.NilError(c, err)
assertNwIsAvailable(c, "mynet") assertNwIsAvailable(c, "mynet")
@ -1751,7 +1751,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkValidateIP(c *check.C) {
} }
// Test case for 26220 // Test case for 26220
func (s *DockerNetworkSuite) TestDockerNetworkDisconnectFromBridge(c *check.C) { func (s *DockerNetworkSuite) TestDockerNetworkDisconnectFromBridge(c *testing.T) {
out, _ := dockerCmd(c, "network", "inspect", "--format", "{{.Id}}", "bridge") out, _ := dockerCmd(c, "network", "inspect", "--format", "{{.Id}}", "bridge")
network := strings.TrimSpace(out) network := strings.TrimSpace(out)
@ -1765,7 +1765,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDisconnectFromBridge(c *check.C) {
// TestConntrackFlowsLeak covers the failure scenario of ticket: https://github.com/docker/docker/issues/8795 // TestConntrackFlowsLeak covers the failure scenario of ticket: https://github.com/docker/docker/issues/8795
// Validates that conntrack is correctly cleaned once a container is destroyed // Validates that conntrack is correctly cleaned once a container is destroyed
func (s *DockerNetworkSuite) TestConntrackFlowsLeak(c *check.C) { func (s *DockerNetworkSuite) TestConntrackFlowsLeak(c *testing.T) {
testRequires(c, IsAmd64, DaemonIsLinux, Network, testEnv.IsLocalDaemon) testRequires(c, IsAmd64, DaemonIsLinux, Network, testEnv.IsLocalDaemon)
// Create a new network // Create a new network

View file

@ -9,7 +9,7 @@ import (
"gotest.tools/assert" "gotest.tools/assert"
) )
func (s *DockerSuite) TestPluginLogDriver(c *check.C) { func (s *DockerSuite) TestPluginLogDriver(c *testing.T) {
testRequires(c, IsAmd64, DaemonIsLinux) testRequires(c, IsAmd64, DaemonIsLinux)
pluginName := "cpuguy83/docker-logdriver-test:latest" pluginName := "cpuguy83/docker-logdriver-test:latest"
@ -29,7 +29,7 @@ func (s *DockerSuite) TestPluginLogDriver(c *check.C) {
} }
// Make sure log drivers are listed in info, and v2 plugins are not. // Make sure log drivers are listed in info, and v2 plugins are not.
func (s *DockerSuite) TestPluginLogDriverInfoList(c *check.C) { func (s *DockerSuite) TestPluginLogDriverInfoList(c *testing.T) {
testRequires(c, IsAmd64, DaemonIsLinux) testRequires(c, IsAmd64, DaemonIsLinux)
pluginName := "cpuguy83/docker-logdriver-test" pluginName := "cpuguy83/docker-logdriver-test"

View file

@ -29,7 +29,7 @@ var (
npNameWithTag = npName + ":" + pTag npNameWithTag = npName + ":" + pTag
) )
func (ps *DockerPluginSuite) TestPluginBasicOps(c *check.C) { func (ps *DockerPluginSuite) TestPluginBasicOps(c *testing.T) {
plugin := ps.getPluginRepoWithTag() plugin := ps.getPluginRepoWithTag()
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", plugin) _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", plugin)
assert.NilError(c, err) assert.NilError(c, err)
@ -60,7 +60,7 @@ func (ps *DockerPluginSuite) TestPluginBasicOps(c *check.C) {
} }
} }
func (ps *DockerPluginSuite) TestPluginForceRemove(c *check.C) { func (ps *DockerPluginSuite) TestPluginForceRemove(c *testing.T) {
pNameWithTag := ps.getPluginRepoWithTag() pNameWithTag := ps.getPluginRepoWithTag()
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag) _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
@ -74,7 +74,7 @@ func (ps *DockerPluginSuite) TestPluginForceRemove(c *check.C) {
assert.Assert(c, out, checker.Contains, pNameWithTag) assert.Assert(c, out, checker.Contains, pNameWithTag)
} }
func (s *DockerSuite) TestPluginActive(c *check.C) { func (s *DockerSuite) TestPluginActive(c *testing.T) {
testRequires(c, DaemonIsLinux, IsAmd64, Network) testRequires(c, DaemonIsLinux, IsAmd64, Network)
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag) _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
@ -97,7 +97,7 @@ func (s *DockerSuite) TestPluginActive(c *check.C) {
assert.Assert(c, out, checker.Contains, pNameWithTag) assert.Assert(c, out, checker.Contains, pNameWithTag)
} }
func (s *DockerSuite) TestPluginActiveNetwork(c *check.C) { func (s *DockerSuite) TestPluginActiveNetwork(c *testing.T) {
testRequires(c, DaemonIsLinux, IsAmd64, Network) testRequires(c, DaemonIsLinux, IsAmd64, Network)
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", npNameWithTag) _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", npNameWithTag)
assert.NilError(c, err) assert.NilError(c, err)
@ -124,7 +124,7 @@ func (s *DockerSuite) TestPluginActiveNetwork(c *check.C) {
assert.Assert(c, out, checker.Contains, npNameWithTag) assert.Assert(c, out, checker.Contains, npNameWithTag)
} }
func (ps *DockerPluginSuite) TestPluginInstallDisable(c *check.C) { func (ps *DockerPluginSuite) TestPluginInstallDisable(c *testing.T) {
pName := ps.getPluginRepoWithTag() pName := ps.getPluginRepoWithTag()
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName) out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName)
@ -148,7 +148,7 @@ func (ps *DockerPluginSuite) TestPluginInstallDisable(c *check.C) {
assert.Assert(c, strings.TrimSpace(out), checker.Contains, pName) assert.Assert(c, strings.TrimSpace(out), checker.Contains, pName)
} }
func (s *DockerSuite) TestPluginInstallDisableVolumeLs(c *check.C) { func (s *DockerSuite) TestPluginInstallDisableVolumeLs(c *testing.T) {
testRequires(c, DaemonIsLinux, IsAmd64, Network) testRequires(c, DaemonIsLinux, IsAmd64, Network)
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName) out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName)
assert.NilError(c, err) assert.NilError(c, err)
@ -157,7 +157,7 @@ func (s *DockerSuite) TestPluginInstallDisableVolumeLs(c *check.C) {
dockerCmd(c, "volume", "ls") dockerCmd(c, "volume", "ls")
} }
func (ps *DockerPluginSuite) TestPluginSet(c *check.C) { func (ps *DockerPluginSuite) TestPluginSet(c *testing.T) {
client := testEnv.APIClient() client := testEnv.APIClient()
name := "test" name := "test"
@ -208,7 +208,7 @@ func (ps *DockerPluginSuite) TestPluginSet(c *check.C) {
} }
func (ps *DockerPluginSuite) TestPluginInstallArgs(c *check.C) { func (ps *DockerPluginSuite) TestPluginInstallArgs(c *testing.T) {
pName := path.Join(ps.registryHost(), "plugin", "testplugininstallwithargs") pName := path.Join(ps.registryHost(), "plugin", "testplugininstallwithargs")
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel() defer cancel()
@ -224,7 +224,7 @@ func (ps *DockerPluginSuite) TestPluginInstallArgs(c *check.C) {
assert.Assert(c, strings.TrimSpace(env), checker.Equals, "[DEBUG=1]") assert.Assert(c, strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
} }
func (ps *DockerPluginSuite) TestPluginInstallImage(c *check.C) { func (ps *DockerPluginSuite) TestPluginInstallImage(c *testing.T) {
testRequires(c, IsAmd64) testRequires(c, IsAmd64)
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL) repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
@ -238,7 +238,7 @@ func (ps *DockerPluginSuite) TestPluginInstallImage(c *check.C) {
assert.Assert(c, out, checker.Contains, `Encountered remote "application/vnd.docker.container.image.v1+json"(image) when fetching`) assert.Assert(c, out, checker.Contains, `Encountered remote "application/vnd.docker.container.image.v1+json"(image) when fetching`)
} }
func (ps *DockerPluginSuite) TestPluginEnableDisableNegative(c *check.C) { func (ps *DockerPluginSuite) TestPluginEnableDisableNegative(c *testing.T) {
pName := ps.getPluginRepoWithTag() pName := ps.getPluginRepoWithTag()
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pName) out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pName)
@ -260,7 +260,7 @@ func (ps *DockerPluginSuite) TestPluginEnableDisableNegative(c *check.C) {
assert.NilError(c, err) assert.NilError(c, err)
} }
func (ps *DockerPluginSuite) TestPluginCreate(c *check.C) { func (ps *DockerPluginSuite) TestPluginCreate(c *testing.T) {
name := "foo/bar-driver" name := "foo/bar-driver"
temp, err := ioutil.TempDir("", "foo") temp, err := ioutil.TempDir("", "foo")
assert.NilError(c, err) assert.NilError(c, err)
@ -292,7 +292,7 @@ func (ps *DockerPluginSuite) TestPluginCreate(c *check.C) {
assert.Assert(c, len(strings.Split(strings.TrimSpace(out), "\n")), checker.Equals, 2) assert.Assert(c, len(strings.Split(strings.TrimSpace(out), "\n")), checker.Equals, 2)
} }
func (ps *DockerPluginSuite) TestPluginInspect(c *check.C) { func (ps *DockerPluginSuite) TestPluginInspect(c *testing.T) {
pNameWithTag := ps.getPluginRepoWithTag() pNameWithTag := ps.getPluginRepoWithTag()
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag) _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
@ -342,7 +342,7 @@ func (ps *DockerPluginSuite) TestPluginInspect(c *check.C) {
} }
// Test case for https://github.com/docker/docker/pull/29186#discussion_r91277345 // Test case for https://github.com/docker/docker/pull/29186#discussion_r91277345
func (s *DockerSuite) TestPluginInspectOnWindows(c *check.C) { func (s *DockerSuite) TestPluginInspectOnWindows(c *testing.T) {
// This test should work on Windows only // This test should work on Windows only
testRequires(c, DaemonIsWindows) testRequires(c, DaemonIsWindows)
@ -352,7 +352,7 @@ func (s *DockerSuite) TestPluginInspectOnWindows(c *check.C) {
assert.ErrorContains(c, err, "plugins are not supported on this platform") assert.ErrorContains(c, err, "plugins are not supported on this platform")
} }
func (ps *DockerPluginSuite) TestPluginIDPrefix(c *check.C) { func (ps *DockerPluginSuite) TestPluginIDPrefix(c *testing.T) {
name := "test" name := "test"
client := testEnv.APIClient() client := testEnv.APIClient()
@ -409,7 +409,7 @@ func (ps *DockerPluginSuite) TestPluginIDPrefix(c *check.C) {
assert.Assert(c, out, checker.Not(checker.Contains), name) assert.Assert(c, out, checker.Not(checker.Contains), name)
} }
func (ps *DockerPluginSuite) TestPluginListDefaultFormat(c *check.C) { func (ps *DockerPluginSuite) TestPluginListDefaultFormat(c *testing.T) {
config, err := ioutil.TempDir("", "config-file-") config, err := ioutil.TempDir("", "config-file-")
assert.NilError(c, err) assert.NilError(c, err)
defer os.RemoveAll(config) defer os.RemoveAll(config)
@ -440,7 +440,7 @@ enabled: false`, id, name)
assert.Assert(c, strings.TrimSpace(out), checker.Contains, expectedOutput) assert.Assert(c, strings.TrimSpace(out), checker.Contains, expectedOutput)
} }
func (s *DockerSuite) TestPluginUpgrade(c *check.C) { func (s *DockerSuite) TestPluginUpgrade(c *testing.T) {
testRequires(c, DaemonIsLinux, Network, testEnv.IsLocalDaemon, IsAmd64, NotUserNamespace) testRequires(c, DaemonIsLinux, Network, testEnv.IsLocalDaemon, IsAmd64, NotUserNamespace)
plugin := "cpuguy83/docker-volume-driver-plugin-local:latest" plugin := "cpuguy83/docker-volume-driver-plugin-local:latest"
pluginV2 := "cpuguy83/docker-volume-driver-plugin-local:v2" pluginV2 := "cpuguy83/docker-volume-driver-plugin-local:v2"
@ -472,7 +472,7 @@ func (s *DockerSuite) TestPluginUpgrade(c *check.C) {
dockerCmd(c, "run", "--rm", "-v", "bananas:/apple", "busybox", "sh", "-c", "ls -lh /apple/core") dockerCmd(c, "run", "--rm", "-v", "bananas:/apple", "busybox", "sh", "-c", "ls -lh /apple/core")
} }
func (s *DockerSuite) TestPluginMetricsCollector(c *check.C) { func (s *DockerSuite) TestPluginMetricsCollector(c *testing.T) {
testRequires(c, DaemonIsLinux, Network, testEnv.IsLocalDaemon, IsAmd64) testRequires(c, DaemonIsLinux, Network, testEnv.IsLocalDaemon, IsAmd64)
d := daemon.New(c, dockerBinary, dockerdBinary) d := daemon.New(c, dockerBinary, dockerdBinary)
d.Start(c) d.Start(c)

View file

@ -13,7 +13,7 @@ import (
"gotest.tools/assert" "gotest.tools/assert"
) )
func (s *DockerSuite) TestPortList(c *check.C) { func (s *DockerSuite) TestPortList(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
// one port // one port
out, _ := dockerCmd(c, "run", "-d", "-p", "9876:80", "busybox", "top") out, _ := dockerCmd(c, "run", "-d", "-p", "9876:80", "busybox", "top")
@ -157,7 +157,7 @@ func (s *DockerSuite) TestPortList(c *check.C) {
dockerCmd(c, "rm", "-f", ID) dockerCmd(c, "rm", "-f", ID)
} }
func assertPortList(c *check.C, out string, expected []string) error { func assertPortList(c *testing.T, out string, expected []string) error {
lines := strings.Split(strings.Trim(out, "\n "), "\n") lines := strings.Split(strings.Trim(out, "\n "), "\n")
if len(lines) != len(expected) { if len(lines) != len(expected) {
return fmt.Errorf("different size lists %s, %d, %d", out, len(lines), len(expected)) return fmt.Errorf("different size lists %s, %d, %d", out, len(lines), len(expected))
@ -174,7 +174,7 @@ func assertPortList(c *check.C, out string, expected []string) error {
return nil return nil
} }
func assertPortRange(c *check.C, out string, expectedTcp, expectedUdp []int) error { func assertPortRange(c *testing.T, out string, expectedTcp, expectedUdp []int) error {
lines := strings.Split(strings.Trim(out, "\n "), "\n") lines := strings.Split(strings.Trim(out, "\n "), "\n")
var validTcp, validUdp bool var validTcp, validUdp bool
@ -206,11 +206,11 @@ func assertPortRange(c *check.C, out string, expectedTcp, expectedUdp []int) err
return nil return nil
} }
func stopRemoveContainer(id string, c *check.C) { func stopRemoveContainer(id string, c *testing.T) {
dockerCmd(c, "rm", "-f", id) dockerCmd(c, "rm", "-f", id)
} }
func (s *DockerSuite) TestUnpublishedPortsInPsOutput(c *check.C) { func (s *DockerSuite) TestUnpublishedPortsInPsOutput(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
// Run busybox with command line expose (equivalent to EXPOSE in image's Dockerfile) for the following ports // Run busybox with command line expose (equivalent to EXPOSE in image's Dockerfile) for the following ports
port1 := 80 port1 := 80
@ -283,7 +283,7 @@ func (s *DockerSuite) TestUnpublishedPortsInPsOutput(c *check.C) {
assert.Assert(c, out, checker.Contains, expBnd2) assert.Assert(c, out, checker.Contains, expBnd2)
} }
func (s *DockerSuite) TestPortHostBinding(c *check.C) { func (s *DockerSuite) TestPortHostBinding(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace) testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmd(c, "run", "-d", "-p", "9876:80", "busybox", out, _ := dockerCmd(c, "run", "-d", "-p", "9876:80", "busybox",
"nc", "-l", "-p", "80") "nc", "-l", "-p", "80")
@ -305,7 +305,7 @@ func (s *DockerSuite) TestPortHostBinding(c *check.C) {
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out))
} }
func (s *DockerSuite) TestPortExposeHostBinding(c *check.C) { func (s *DockerSuite) TestPortExposeHostBinding(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace) testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmd(c, "run", "-d", "-P", "--expose", "80", "busybox", out, _ := dockerCmd(c, "run", "-d", "-P", "--expose", "80", "busybox",
"nc", "-l", "-p", "80") "nc", "-l", "-p", "80")
@ -327,7 +327,7 @@ func (s *DockerSuite) TestPortExposeHostBinding(c *check.C) {
assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out)) assert.Assert(c, err, checker.NotNil, check.Commentf("out: %s", out))
} }
func (s *DockerSuite) TestPortBindingOnSandbox(c *check.C) { func (s *DockerSuite) TestPortBindingOnSandbox(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace) testRequires(c, DaemonIsLinux, NotUserNamespace)
dockerCmd(c, "network", "create", "--internal", "-d", "bridge", "internal-net") dockerCmd(c, "network", "create", "--internal", "-d", "bridge", "internal-net")
nr := getNetworkResource(c, "internal-net") nr := getNetworkResource(c, "internal-net")

View file

@ -9,7 +9,7 @@ import (
"gotest.tools/icmd" "gotest.tools/icmd"
) )
func (s *DockerSuite) TestCLIProxyDisableProxyUnixSock(c *check.C) { func (s *DockerSuite) TestCLIProxyDisableProxyUnixSock(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
icmd.RunCmd(icmd.Cmd{ icmd.RunCmd(icmd.Cmd{
@ -20,7 +20,7 @@ func (s *DockerSuite) TestCLIProxyDisableProxyUnixSock(c *check.C) {
// Can't use localhost here since go has a special case to not use proxy if connecting to localhost // Can't use localhost here since go has a special case to not use proxy if connecting to localhost
// See https://golang.org/pkg/net/http/#ProxyFromEnvironment // See https://golang.org/pkg/net/http/#ProxyFromEnvironment
func (s *DockerDaemonSuite) TestCLIProxyProxyTCPSock(c *check.C) { func (s *DockerDaemonSuite) TestCLIProxyProxyTCPSock(c *testing.T) {
// get the IP to use to connect since we can't use localhost // get the IP to use to connect since we can't use localhost
addrs, err := net.InterfaceAddrs() addrs, err := net.InterfaceAddrs()
assert.NilError(c, err) assert.NilError(c, err)

View file

@ -19,12 +19,12 @@ import (
"gotest.tools/icmd" "gotest.tools/icmd"
) )
func pruneNetworkAndVerify(c *check.C, d *daemon.Daemon, kept, pruned []string) { func pruneNetworkAndVerify(c *testing.T, d *daemon.Daemon, kept, pruned []string) {
_, err := d.Cmd("network", "prune", "--force") _, err := d.Cmd("network", "prune", "--force")
assert.NilError(c, err) assert.NilError(c, err)
for _, s := range kept { for _, s := range kept {
waitAndAssert(c, defaultReconciliationTimeout, func(*check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(*testing.T) (interface{}, check.CommentInterface) {
out, err := d.Cmd("network", "ls", "--format", "{{.Name}}") out, err := d.Cmd("network", "ls", "--format", "{{.Name}}")
assert.NilError(c, err) assert.NilError(c, err)
return out, nil return out, nil
@ -32,7 +32,7 @@ func pruneNetworkAndVerify(c *check.C, d *daemon.Daemon, kept, pruned []string)
} }
for _, s := range pruned { for _, s := range pruned {
waitAndAssert(c, defaultReconciliationTimeout, func(*check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(*testing.T) (interface{}, check.CommentInterface) {
out, err := d.Cmd("network", "ls", "--format", "{{.Name}}") out, err := d.Cmd("network", "ls", "--format", "{{.Name}}")
assert.NilError(c, err) assert.NilError(c, err)
return out, nil return out, nil
@ -40,7 +40,7 @@ func pruneNetworkAndVerify(c *check.C, d *daemon.Daemon, kept, pruned []string)
} }
} }
func (s *DockerSwarmSuite) TestPruneNetwork(c *check.C) { func (s *DockerSwarmSuite) TestPruneNetwork(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
_, err := d.Cmd("network", "create", "n1") // used by container (testprune) _, err := d.Cmd("network", "create", "n1") // used by container (testprune)
assert.NilError(c, err) assert.NilError(c, err)
@ -79,7 +79,7 @@ func (s *DockerSwarmSuite) TestPruneNetwork(c *check.C) {
pruneNetworkAndVerify(c, d, []string{}, []string{"n1", "n3"}) pruneNetworkAndVerify(c, d, []string{}, []string{"n1", "n3"})
} }
func (s *DockerDaemonSuite) TestPruneImageDangling(c *check.C) { func (s *DockerDaemonSuite) TestPruneImageDangling(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
result := cli.BuildCmd(c, "test", cli.Daemon(s.d), result := cli.BuildCmd(c, "test", cli.Daemon(s.d),
@ -111,7 +111,7 @@ func (s *DockerDaemonSuite) TestPruneImageDangling(c *check.C) {
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id) assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id)
} }
func (s *DockerSuite) TestPruneContainerUntil(c *check.C) { func (s *DockerSuite) TestPruneContainerUntil(c *testing.T) {
out := cli.DockerCmd(c, "run", "-d", "busybox").Combined() out := cli.DockerCmd(c, "run", "-d", "busybox").Combined()
id1 := strings.TrimSpace(out) id1 := strings.TrimSpace(out)
cli.WaitExited(c, id1, 5*time.Second) cli.WaitExited(c, id1, 5*time.Second)
@ -131,7 +131,7 @@ func (s *DockerSuite) TestPruneContainerUntil(c *check.C) {
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2) assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
} }
func (s *DockerSuite) TestPruneContainerLabel(c *check.C) { func (s *DockerSuite) TestPruneContainerLabel(c *testing.T) {
out := cli.DockerCmd(c, "run", "-d", "--label", "foo", "busybox").Combined() out := cli.DockerCmd(c, "run", "-d", "--label", "foo", "busybox").Combined()
id1 := strings.TrimSpace(out) id1 := strings.TrimSpace(out)
cli.WaitExited(c, id1, 5*time.Second) cli.WaitExited(c, id1, 5*time.Second)
@ -189,7 +189,7 @@ func (s *DockerSuite) TestPruneContainerLabel(c *check.C) {
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id2) assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id2)
} }
func (s *DockerSuite) TestPruneVolumeLabel(c *check.C) { func (s *DockerSuite) TestPruneVolumeLabel(c *testing.T) {
out, _ := dockerCmd(c, "volume", "create", "--label", "foo") out, _ := dockerCmd(c, "volume", "create", "--label", "foo")
id1 := strings.TrimSpace(out) id1 := strings.TrimSpace(out)
assert.Assert(c, id1, checker.Not(checker.Equals), "") assert.Assert(c, id1, checker.Not(checker.Equals), "")
@ -247,7 +247,7 @@ func (s *DockerSuite) TestPruneVolumeLabel(c *check.C) {
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id2) assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), id2)
} }
func (s *DockerSuite) TestPruneNetworkLabel(c *check.C) { func (s *DockerSuite) TestPruneNetworkLabel(c *testing.T) {
dockerCmd(c, "network", "create", "--label", "foo", "n1") dockerCmd(c, "network", "create", "--label", "foo", "n1")
dockerCmd(c, "network", "create", "--label", "bar", "n2") dockerCmd(c, "network", "create", "--label", "bar", "n2")
dockerCmd(c, "network", "create", "n3") dockerCmd(c, "network", "create", "n3")
@ -268,7 +268,7 @@ func (s *DockerSuite) TestPruneNetworkLabel(c *check.C) {
assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), "n3") assert.Assert(c, strings.TrimSpace(out), checker.Not(checker.Contains), "n3")
} }
func (s *DockerDaemonSuite) TestPruneImageLabel(c *check.C) { func (s *DockerDaemonSuite) TestPruneImageLabel(c *testing.T) {
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
result := cli.BuildCmd(c, "test1", cli.Daemon(s.d), result := cli.BuildCmd(c, "test1", cli.Daemon(s.d),

View file

@ -18,7 +18,7 @@ import (
"gotest.tools/icmd" "gotest.tools/icmd"
) )
func (s *DockerSuite) TestPsListContainersBase(c *check.C) { func (s *DockerSuite) TestPsListContainersBase(c *testing.T) {
existingContainers := ExistingContainerIDs(c) existingContainers := ExistingContainerIDs(c)
out := runSleepingContainer(c, "-d") out := runSleepingContainer(c, "-d")
@ -139,7 +139,7 @@ func assertContainerList(out string, expected []string) bool {
return true return true
} }
func (s *DockerSuite) TestPsListContainersSize(c *check.C) { func (s *DockerSuite) TestPsListContainersSize(c *testing.T) {
// Problematic on Windows as it doesn't report the size correctly @swernli // Problematic on Windows as it doesn't report the size correctly @swernli
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "busybox") dockerCmd(c, "run", "-d", "busybox")
@ -179,7 +179,7 @@ func (s *DockerSuite) TestPsListContainersSize(c *check.C) {
assert.Assert(c, foundSize, checker.Contains, expectedSize, check.Commentf("Expected size %q, got %q", expectedSize, foundSize)) assert.Assert(c, foundSize, checker.Contains, expectedSize, check.Commentf("Expected size %q, got %q", expectedSize, foundSize))
} }
func (s *DockerSuite) TestPsListContainersFilterStatus(c *check.C) { func (s *DockerSuite) TestPsListContainersFilterStatus(c *testing.T) {
existingContainers := ExistingContainerIDs(c) existingContainers := ExistingContainerIDs(c)
// start exited container // start exited container
@ -226,7 +226,7 @@ func (s *DockerSuite) TestPsListContainersFilterStatus(c *check.C) {
} }
} }
func (s *DockerSuite) TestPsListContainersFilterHealth(c *check.C) { func (s *DockerSuite) TestPsListContainersFilterHealth(c *testing.T) {
existingContainers := ExistingContainerIDs(c) existingContainers := ExistingContainerIDs(c)
// Test legacy no health check // Test legacy no health check
out := runSleepingContainer(c, "--name=none_legacy") out := runSleepingContainer(c, "--name=none_legacy")
@ -269,7 +269,7 @@ func (s *DockerSuite) TestPsListContainersFilterHealth(c *check.C) {
assert.Assert(c, containerOut, checker.Equals, containerID, check.Commentf("Expected containerID %s, got %s for healthy filter, output: %q", containerID, containerOut, out)) assert.Assert(c, containerOut, checker.Equals, containerID, check.Commentf("Expected containerID %s, got %s for healthy filter, output: %q", containerID, containerOut, out))
} }
func (s *DockerSuite) TestPsListContainersFilterID(c *check.C) { func (s *DockerSuite) TestPsListContainersFilterID(c *testing.T) {
// start container // start container
out, _ := dockerCmd(c, "run", "-d", "busybox") out, _ := dockerCmd(c, "run", "-d", "busybox")
firstID := strings.TrimSpace(out) firstID := strings.TrimSpace(out)
@ -283,7 +283,7 @@ func (s *DockerSuite) TestPsListContainersFilterID(c *check.C) {
assert.Assert(c, containerOut, checker.Equals, firstID[:12], check.Commentf("Expected id %s, got %s for exited filter, output: %q", firstID[:12], containerOut, out)) assert.Assert(c, containerOut, checker.Equals, firstID[:12], check.Commentf("Expected id %s, got %s for exited filter, output: %q", firstID[:12], containerOut, out))
} }
func (s *DockerSuite) TestPsListContainersFilterName(c *check.C) { func (s *DockerSuite) TestPsListContainersFilterName(c *testing.T) {
// start container // start container
dockerCmd(c, "run", "--name=a_name_to_match", "busybox") dockerCmd(c, "run", "--name=a_name_to_match", "busybox")
id := getIDByName(c, "a_name_to_match") id := getIDByName(c, "a_name_to_match")
@ -305,7 +305,7 @@ func (s *DockerSuite) TestPsListContainersFilterName(c *check.C) {
// - Create an image based on the previous image (images_ps_filter_test2) // - Create an image based on the previous image (images_ps_filter_test2)
// - Run containers for each of those image (busybox, images_ps_filter_test1, images_ps_filter_test2) // - Run containers for each of those image (busybox, images_ps_filter_test1, images_ps_filter_test2)
// - Filter them out :P // - Filter them out :P
func (s *DockerSuite) TestPsListContainersFilterAncestorImage(c *check.C) { func (s *DockerSuite) TestPsListContainersFilterAncestorImage(c *testing.T) {
existingContainers := ExistingContainerIDs(c) existingContainers := ExistingContainerIDs(c)
// Build images // Build images
@ -378,7 +378,7 @@ func (s *DockerSuite) TestPsListContainersFilterAncestorImage(c *check.C) {
checkPsAncestorFilterOutput(c, RemoveOutputForExistingElements(out, existingContainers), imageName2+","+imageName1Tagged, []string{fourthID, fifthID}) checkPsAncestorFilterOutput(c, RemoveOutputForExistingElements(out, existingContainers), imageName2+","+imageName1Tagged, []string{fourthID, fifthID})
} }
func checkPsAncestorFilterOutput(c *check.C, out string, filterName string, expectedIDs []string) { func checkPsAncestorFilterOutput(c *testing.T, out string, filterName string, expectedIDs []string) {
var actualIDs []string var actualIDs []string
if out != "" { if out != "" {
actualIDs = strings.Split(out[:len(out)-1], "\n") actualIDs = strings.Split(out[:len(out)-1], "\n")
@ -400,7 +400,7 @@ func checkPsAncestorFilterOutput(c *check.C, out string, filterName string, expe
} }
} }
func (s *DockerSuite) TestPsListContainersFilterLabel(c *check.C) { func (s *DockerSuite) TestPsListContainersFilterLabel(c *testing.T) {
// start container // start container
dockerCmd(c, "run", "--name=first", "-l", "match=me", "-l", "second=tag", "busybox") dockerCmd(c, "run", "--name=first", "-l", "match=me", "-l", "second=tag", "busybox")
firstID := getIDByName(c, "first") firstID := getIDByName(c, "first")
@ -436,7 +436,7 @@ func (s *DockerSuite) TestPsListContainersFilterLabel(c *check.C) {
assert.Assert(c, containerOut, checker.Not(checker.Contains), thirdID) assert.Assert(c, containerOut, checker.Not(checker.Contains), thirdID)
} }
func (s *DockerSuite) TestPsListContainersFilterExited(c *check.C) { func (s *DockerSuite) TestPsListContainersFilterExited(c *testing.T) {
runSleepingContainer(c, "--name=sleep") runSleepingContainer(c, "--name=sleep")
firstZero, _ := dockerCmd(c, "run", "-d", "busybox", "true") firstZero, _ := dockerCmd(c, "run", "-d", "busybox", "true")
@ -464,7 +464,7 @@ func (s *DockerSuite) TestPsListContainersFilterExited(c *check.C) {
assert.Assert(c, out, checker.Not(checker.Contains), strings.TrimSpace(secondZero)) assert.Assert(c, out, checker.Not(checker.Contains), strings.TrimSpace(secondZero))
} }
func (s *DockerSuite) TestPsRightTagName(c *check.C) { func (s *DockerSuite) TestPsRightTagName(c *testing.T) {
// TODO Investigate further why this fails on Windows to Windows CI // TODO Investigate further why this fails on Windows to Windows CI
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -510,7 +510,7 @@ func (s *DockerSuite) TestPsRightTagName(c *check.C) {
} }
} }
func (s *DockerSuite) TestPsListContainersFilterCreated(c *check.C) { func (s *DockerSuite) TestPsListContainersFilterCreated(c *testing.T) {
// create a container // create a container
out, _ := dockerCmd(c, "create", "busybox") out, _ := dockerCmd(c, "create", "busybox")
cID := strings.TrimSpace(out) cID := strings.TrimSpace(out)
@ -541,7 +541,7 @@ func (s *DockerSuite) TestPsListContainersFilterCreated(c *check.C) {
} }
// Test for GitHub issue #12595 // Test for GitHub issue #12595
func (s *DockerSuite) TestPsImageIDAfterUpdate(c *check.C) { func (s *DockerSuite) TestPsImageIDAfterUpdate(c *testing.T) {
// TODO: Investigate why this fails on Windows to Windows CI further. // TODO: Investigate why this fails on Windows to Windows CI further.
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
originalImageName := "busybox:TestPsImageIDAfterUpdate-original" originalImageName := "busybox:TestPsImageIDAfterUpdate-original"
@ -590,7 +590,7 @@ func (s *DockerSuite) TestPsImageIDAfterUpdate(c *check.C) {
} }
func (s *DockerSuite) TestPsNotShowPortsOfStoppedContainer(c *check.C) { func (s *DockerSuite) TestPsNotShowPortsOfStoppedContainer(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "--name=foo", "-d", "-p", "5000:5000", "busybox", "top") dockerCmd(c, "run", "--name=foo", "-d", "-p", "5000:5000", "busybox", "top")
assert.Assert(c, waitRun("foo"), checker.IsNil) assert.Assert(c, waitRun("foo"), checker.IsNil)
@ -608,7 +608,7 @@ func (s *DockerSuite) TestPsNotShowPortsOfStoppedContainer(c *check.C) {
assert.Assert(c, fields[len(fields)-2], checker.Not(checker.Equals), expected, check.Commentf("Should not got %v", expected)) assert.Assert(c, fields[len(fields)-2], checker.Not(checker.Equals), expected, check.Commentf("Should not got %v", expected))
} }
func (s *DockerSuite) TestPsShowMounts(c *check.C) { func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
existingContainers := ExistingContainerNames(c) existingContainers := ExistingContainerNames(c)
prefix, slash := getPrefixAndSlashFromDaemonPlatform() prefix, slash := getPrefixAndSlashFromDaemonPlatform()
@ -708,7 +708,7 @@ func (s *DockerSuite) TestPsShowMounts(c *check.C) {
assert.Assert(c, strings.TrimSpace(string(out)), checker.HasLen, 0) assert.Assert(c, strings.TrimSpace(string(out)), checker.HasLen, 0)
} }
func (s *DockerSuite) TestPsListContainersFilterNetwork(c *check.C) { func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
existing := ExistingContainerIDs(c) existing := ExistingContainerIDs(c)
// TODO default network on Windows is not called "bridge", and creating a // TODO default network on Windows is not called "bridge", and creating a
@ -788,7 +788,7 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *check.C) {
} }
func (s *DockerSuite) TestPsByOrder(c *check.C) { func (s *DockerSuite) TestPsByOrder(c *testing.T) {
out := runSleepingContainer(c, "--name", "xyz-abc") out := runSleepingContainer(c, "--name", "xyz-abc")
container1 := strings.TrimSpace(out) container1 := strings.TrimSpace(out)
@ -807,7 +807,7 @@ func (s *DockerSuite) TestPsByOrder(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), fmt.Sprintf("%s\n%s", container2, container1)) assert.Equal(c, strings.TrimSpace(out), fmt.Sprintf("%s\n%s", container2, container1))
} }
func (s *DockerSuite) TestPsListContainersFilterPorts(c *check.C) { func (s *DockerSuite) TestPsListContainersFilterPorts(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
existingContainers := ExistingContainerIDs(c) existingContainers := ExistingContainerIDs(c)
@ -843,7 +843,7 @@ func (s *DockerSuite) TestPsListContainersFilterPorts(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), id2) assert.Equal(c, strings.TrimSpace(out), id2)
} }
func (s *DockerSuite) TestPsNotShowLinknamesOfDeletedContainer(c *check.C) { func (s *DockerSuite) TestPsNotShowLinknamesOfDeletedContainer(c *testing.T) {
testRequires(c, DaemonIsLinux, MinimumAPIVersion("1.31")) testRequires(c, DaemonIsLinux, MinimumAPIVersion("1.31"))
existingContainers := ExistingContainerNames(c) existingContainers := ExistingContainerNames(c)

View file

@ -25,7 +25,7 @@ import (
// tags for the same image) are not also pulled down. // tags for the same image) are not also pulled down.
// //
// Ref: docker/docker#8141 // Ref: docker/docker#8141
func testPullImageWithAliases(c *check.C) { func testPullImageWithAliases(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL) repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
var repos []string var repos []string
@ -52,16 +52,16 @@ func testPullImageWithAliases(c *check.C) {
} }
} }
func (s *DockerRegistrySuite) TestPullImageWithAliases(c *check.C) { func (s *DockerRegistrySuite) TestPullImageWithAliases(c *testing.T) {
testPullImageWithAliases(c) testPullImageWithAliases(c)
} }
func (s *DockerSchema1RegistrySuite) TestPullImageWithAliases(c *check.C) { func (s *DockerSchema1RegistrySuite) TestPullImageWithAliases(c *testing.T) {
testPullImageWithAliases(c) testPullImageWithAliases(c)
} }
// testConcurrentPullWholeRepo pulls the same repo concurrently. // testConcurrentPullWholeRepo pulls the same repo concurrently.
func testConcurrentPullWholeRepo(c *check.C) { func testConcurrentPullWholeRepo(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL) repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
var repos []string var repos []string
@ -108,16 +108,16 @@ func testConcurrentPullWholeRepo(c *check.C) {
} }
} }
func (s *DockerRegistrySuite) testConcurrentPullWholeRepo(c *check.C) { func (s *DockerRegistrySuite) testConcurrentPullWholeRepo(c *testing.T) {
testConcurrentPullWholeRepo(c) testConcurrentPullWholeRepo(c)
} }
func (s *DockerSchema1RegistrySuite) testConcurrentPullWholeRepo(c *check.C) { func (s *DockerSchema1RegistrySuite) testConcurrentPullWholeRepo(c *testing.T) {
testConcurrentPullWholeRepo(c) testConcurrentPullWholeRepo(c)
} }
// testConcurrentFailingPull tries a concurrent pull that doesn't succeed. // testConcurrentFailingPull tries a concurrent pull that doesn't succeed.
func testConcurrentFailingPull(c *check.C) { func testConcurrentFailingPull(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL) repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
// Run multiple pulls concurrently // Run multiple pulls concurrently
@ -139,17 +139,17 @@ func testConcurrentFailingPull(c *check.C) {
} }
} }
func (s *DockerRegistrySuite) testConcurrentFailingPull(c *check.C) { func (s *DockerRegistrySuite) testConcurrentFailingPull(c *testing.T) {
testConcurrentFailingPull(c) testConcurrentFailingPull(c)
} }
func (s *DockerSchema1RegistrySuite) testConcurrentFailingPull(c *check.C) { func (s *DockerSchema1RegistrySuite) testConcurrentFailingPull(c *testing.T) {
testConcurrentFailingPull(c) testConcurrentFailingPull(c)
} }
// testConcurrentPullMultipleTags pulls multiple tags from the same repo // testConcurrentPullMultipleTags pulls multiple tags from the same repo
// concurrently. // concurrently.
func testConcurrentPullMultipleTags(c *check.C) { func testConcurrentPullMultipleTags(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL) repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
var repos []string var repos []string
@ -195,17 +195,17 @@ func testConcurrentPullMultipleTags(c *check.C) {
} }
} }
func (s *DockerRegistrySuite) TestConcurrentPullMultipleTags(c *check.C) { func (s *DockerRegistrySuite) TestConcurrentPullMultipleTags(c *testing.T) {
testConcurrentPullMultipleTags(c) testConcurrentPullMultipleTags(c)
} }
func (s *DockerSchema1RegistrySuite) TestConcurrentPullMultipleTags(c *check.C) { func (s *DockerSchema1RegistrySuite) TestConcurrentPullMultipleTags(c *testing.T) {
testConcurrentPullMultipleTags(c) testConcurrentPullMultipleTags(c)
} }
// testPullIDStability verifies that pushing an image and pulling it back // testPullIDStability verifies that pushing an image and pulling it back
// preserves the image ID. // preserves the image ID.
func testPullIDStability(c *check.C) { func testPullIDStability(c *testing.T) {
derivedImage := privateRegistryURL + "/dockercli/id-stability" derivedImage := privateRegistryURL + "/dockercli/id-stability"
baseImage := "busybox" baseImage := "busybox"
@ -256,16 +256,16 @@ func testPullIDStability(c *check.C) {
} }
} }
func (s *DockerRegistrySuite) TestPullIDStability(c *check.C) { func (s *DockerRegistrySuite) TestPullIDStability(c *testing.T) {
testPullIDStability(c) testPullIDStability(c)
} }
func (s *DockerSchema1RegistrySuite) TestPullIDStability(c *check.C) { func (s *DockerSchema1RegistrySuite) TestPullIDStability(c *testing.T) {
testPullIDStability(c) testPullIDStability(c)
} }
// #21213 // #21213
func testPullNoLayers(c *check.C) { func testPullNoLayers(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/scratch", privateRegistryURL) repoName := fmt.Sprintf("%v/dockercli/scratch", privateRegistryURL)
buildImageSuccessfully(c, repoName, build.WithDockerfile(` buildImageSuccessfully(c, repoName, build.WithDockerfile(`
@ -276,15 +276,15 @@ func testPullNoLayers(c *check.C) {
dockerCmd(c, "pull", repoName) dockerCmd(c, "pull", repoName)
} }
func (s *DockerRegistrySuite) TestPullNoLayers(c *check.C) { func (s *DockerRegistrySuite) TestPullNoLayers(c *testing.T) {
testPullNoLayers(c) testPullNoLayers(c)
} }
func (s *DockerSchema1RegistrySuite) TestPullNoLayers(c *check.C) { func (s *DockerSchema1RegistrySuite) TestPullNoLayers(c *testing.T) {
testPullNoLayers(c) testPullNoLayers(c)
} }
func (s *DockerRegistrySuite) TestPullManifestList(c *check.C) { func (s *DockerRegistrySuite) TestPullManifestList(c *testing.T) {
testRequires(c, NotArm) testRequires(c, NotArm)
pushDigest, err := setupImage(c) pushDigest, err := setupImage(c)
assert.NilError(c, err, "error setting up image") assert.NilError(c, err, "error setting up image")
@ -368,7 +368,7 @@ func (s *DockerRegistrySuite) TestPullManifestList(c *check.C) {
} }
// #23100 // #23100
func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuthLoginWithScheme(c *check.C) { func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuthLoginWithScheme(c *testing.T) {
osPath := os.Getenv("PATH") osPath := os.Getenv("PATH")
defer os.Setenv("PATH", osPath) defer os.Setenv("PATH", osPath)
@ -413,7 +413,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuthLoginWithSchem
dockerCmd(c, "--config", tmp, "logout", "https://"+privateRegistryURL) dockerCmd(c, "--config", tmp, "logout", "https://"+privateRegistryURL)
} }
func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuth(c *check.C) { func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuth(c *testing.T) {
osPath := os.Getenv("PATH") osPath := os.Getenv("PATH")
defer os.Setenv("PATH", osPath) defer os.Setenv("PATH", osPath)
@ -449,7 +449,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuth(c *check.C) {
} }
// TestRunImplicitPullWithNoTag should pull implicitly only the default tag (latest) // TestRunImplicitPullWithNoTag should pull implicitly only the default tag (latest)
func (s *DockerRegistrySuite) TestRunImplicitPullWithNoTag(c *check.C) { func (s *DockerRegistrySuite) TestRunImplicitPullWithNoTag(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
repo := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL) repo := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
repoTag1 := fmt.Sprintf("%v:latest", repo) repoTag1 := fmt.Sprintf("%v:latest", repo)

View file

@ -15,7 +15,7 @@ import (
// TestPullFromCentralRegistry pulls an image from the central registry and verifies that the client // TestPullFromCentralRegistry pulls an image from the central registry and verifies that the client
// prints all expected output. // prints all expected output.
func (s *DockerHubPullSuite) TestPullFromCentralRegistry(c *check.C) { func (s *DockerHubPullSuite) TestPullFromCentralRegistry(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out := s.Cmd(c, "pull", "hello-world") out := s.Cmd(c, "pull", "hello-world")
defer deleteImages("hello-world") defer deleteImages("hello-world")
@ -40,7 +40,7 @@ func (s *DockerHubPullSuite) TestPullFromCentralRegistry(c *check.C) {
// TestPullNonExistingImage pulls non-existing images from the central registry, with different // TestPullNonExistingImage pulls non-existing images from the central registry, with different
// combinations of implicit tag and library prefix. // combinations of implicit tag and library prefix.
func (s *DockerHubPullSuite) TestPullNonExistingImage(c *check.C) { func (s *DockerHubPullSuite) TestPullNonExistingImage(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
type entry struct { type entry struct {
@ -115,7 +115,7 @@ func (s *DockerHubPullSuite) TestPullNonExistingImage(c *check.C) {
// that pulling the same image with different combinations of implicit elements of the image // that pulling the same image with different combinations of implicit elements of the image
// reference (tag, repository, central registry url, ...) doesn't trigger a new pull nor leads to // reference (tag, repository, central registry url, ...) doesn't trigger a new pull nor leads to
// multiple images. // multiple images.
func (s *DockerHubPullSuite) TestPullFromCentralRegistryImplicitRefParts(c *check.C) { func (s *DockerHubPullSuite) TestPullFromCentralRegistryImplicitRefParts(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
// Pull hello-world from v2 // Pull hello-world from v2
@ -184,7 +184,7 @@ func (s *DockerHubPullSuite) TestPullFromCentralRegistryImplicitRefParts(c *chec
} }
// TestPullScratchNotAllowed verifies that pulling 'scratch' is rejected. // TestPullScratchNotAllowed verifies that pulling 'scratch' is rejected.
func (s *DockerHubPullSuite) TestPullScratchNotAllowed(c *check.C) { func (s *DockerHubPullSuite) TestPullScratchNotAllowed(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, err := s.CmdWithError("pull", "scratch") out, err := s.CmdWithError("pull", "scratch")
assert.ErrorContains(c, err, "", "expected pull of scratch to fail") assert.ErrorContains(c, err, "", "expected pull of scratch to fail")
@ -194,7 +194,7 @@ func (s *DockerHubPullSuite) TestPullScratchNotAllowed(c *check.C) {
// TestPullAllTagsFromCentralRegistry pulls using `all-tags` for a given image and verifies that it // TestPullAllTagsFromCentralRegistry pulls using `all-tags` for a given image and verifies that it
// results in more images than a naked pull. // results in more images than a naked pull.
func (s *DockerHubPullSuite) TestPullAllTagsFromCentralRegistry(c *check.C) { func (s *DockerHubPullSuite) TestPullAllTagsFromCentralRegistry(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
s.Cmd(c, "pull", "dockercore/engine-pull-all-test-fixture") s.Cmd(c, "pull", "dockercore/engine-pull-all-test-fixture")
outImageCmd := s.Cmd(c, "images", "dockercore/engine-pull-all-test-fixture") outImageCmd := s.Cmd(c, "images", "dockercore/engine-pull-all-test-fixture")
@ -238,7 +238,7 @@ func (s *DockerHubPullSuite) TestPullAllTagsFromCentralRegistry(c *check.C) {
// gets cancelled. // gets cancelled.
// //
// Ref: docker/docker#15589 // Ref: docker/docker#15589
func (s *DockerHubPullSuite) TestPullClientDisconnect(c *check.C) { func (s *DockerHubPullSuite) TestPullClientDisconnect(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
repoName := "hello-world:latest" repoName := "hello-world:latest"
@ -263,14 +263,14 @@ func (s *DockerHubPullSuite) TestPullClientDisconnect(c *check.C) {
} }
// Regression test for https://github.com/docker/docker/issues/26429 // Regression test for https://github.com/docker/docker/issues/26429
func (s *DockerSuite) TestPullLinuxImageFailsOnWindows(c *check.C) { func (s *DockerSuite) TestPullLinuxImageFailsOnWindows(c *testing.T) {
testRequires(c, DaemonIsWindows, Network) testRequires(c, DaemonIsWindows, Network)
_, _, err := dockerCmdWithError("pull", "ubuntu") _, _, err := dockerCmdWithError("pull", "ubuntu")
assert.ErrorContains(c, err, "no matching manifest for windows") assert.ErrorContains(c, err, "no matching manifest for windows")
} }
// Regression test for https://github.com/docker/docker/issues/28892 // Regression test for https://github.com/docker/docker/issues/28892
func (s *DockerSuite) TestPullWindowsImageFailsOnLinux(c *check.C) { func (s *DockerSuite) TestPullWindowsImageFailsOnLinux(c *testing.T) {
testRequires(c, DaemonIsLinux, Network) testRequires(c, DaemonIsLinux, Network)
_, _, err := dockerCmdWithError("pull", "mcr.microsoft.com/windows/servercore:ltsc2019") _, _, err := dockerCmdWithError("pull", "mcr.microsoft.com/windows/servercore:ltsc2019")
assert.ErrorContains(c, err, "no matching manifest for linux") assert.ErrorContains(c, err, "no matching manifest for linux")

View file

@ -18,7 +18,7 @@ import (
) )
// Pushing an image to a private registry. // Pushing an image to a private registry.
func testPushBusyboxImage(c *check.C) { func testPushBusyboxImage(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL) repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
// tag the image to upload it to the private registry // tag the image to upload it to the private registry
dockerCmd(c, "tag", "busybox", repoName) dockerCmd(c, "tag", "busybox", repoName)
@ -26,21 +26,21 @@ func testPushBusyboxImage(c *check.C) {
dockerCmd(c, "push", repoName) dockerCmd(c, "push", repoName)
} }
func (s *DockerRegistrySuite) TestPushBusyboxImage(c *check.C) { func (s *DockerRegistrySuite) TestPushBusyboxImage(c *testing.T) {
testPushBusyboxImage(c) testPushBusyboxImage(c)
} }
func (s *DockerSchema1RegistrySuite) TestPushBusyboxImage(c *check.C) { func (s *DockerSchema1RegistrySuite) TestPushBusyboxImage(c *testing.T) {
testPushBusyboxImage(c) testPushBusyboxImage(c)
} }
// pushing an image without a prefix should throw an error // pushing an image without a prefix should throw an error
func (s *DockerSuite) TestPushUnprefixedRepo(c *check.C) { func (s *DockerSuite) TestPushUnprefixedRepo(c *testing.T) {
out, _, err := dockerCmdWithError("push", "busybox") out, _, err := dockerCmdWithError("push", "busybox")
assert.ErrorContains(c, err, "", "pushing an unprefixed repo didn't result in a non-zero exit status: %s", out) assert.ErrorContains(c, err, "", "pushing an unprefixed repo didn't result in a non-zero exit status: %s", out)
} }
func testPushUntagged(c *check.C) { func testPushUntagged(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL) repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
expected := "An image does not exist locally with the tag" expected := "An image does not exist locally with the tag"
@ -49,15 +49,15 @@ func testPushUntagged(c *check.C) {
assert.Assert(c, strings.Contains(out, expected), "pushing the image failed") assert.Assert(c, strings.Contains(out, expected), "pushing the image failed")
} }
func (s *DockerRegistrySuite) TestPushUntagged(c *check.C) { func (s *DockerRegistrySuite) TestPushUntagged(c *testing.T) {
testPushUntagged(c) testPushUntagged(c)
} }
func (s *DockerSchema1RegistrySuite) TestPushUntagged(c *check.C) { func (s *DockerSchema1RegistrySuite) TestPushUntagged(c *testing.T) {
testPushUntagged(c) testPushUntagged(c)
} }
func testPushBadTag(c *check.C) { func testPushBadTag(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/busybox:latest", privateRegistryURL) repoName := fmt.Sprintf("%v/dockercli/busybox:latest", privateRegistryURL)
expected := "does not exist" expected := "does not exist"
@ -66,15 +66,15 @@ func testPushBadTag(c *check.C) {
assert.Assert(c, strings.Contains(out, expected), "pushing the image failed") assert.Assert(c, strings.Contains(out, expected), "pushing the image failed")
} }
func (s *DockerRegistrySuite) TestPushBadTag(c *check.C) { func (s *DockerRegistrySuite) TestPushBadTag(c *testing.T) {
testPushBadTag(c) testPushBadTag(c)
} }
func (s *DockerSchema1RegistrySuite) TestPushBadTag(c *check.C) { func (s *DockerSchema1RegistrySuite) TestPushBadTag(c *testing.T) {
testPushBadTag(c) testPushBadTag(c)
} }
func testPushMultipleTags(c *check.C) { func testPushMultipleTags(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL) repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
repoTag1 := fmt.Sprintf("%v/dockercli/busybox:t1", privateRegistryURL) repoTag1 := fmt.Sprintf("%v/dockercli/busybox:t1", privateRegistryURL)
repoTag2 := fmt.Sprintf("%v/dockercli/busybox:t2", privateRegistryURL) repoTag2 := fmt.Sprintf("%v/dockercli/busybox:t2", privateRegistryURL)
@ -111,15 +111,15 @@ func testPushMultipleTags(c *check.C) {
} }
} }
func (s *DockerRegistrySuite) TestPushMultipleTags(c *check.C) { func (s *DockerRegistrySuite) TestPushMultipleTags(c *testing.T) {
testPushMultipleTags(c) testPushMultipleTags(c)
} }
func (s *DockerSchema1RegistrySuite) TestPushMultipleTags(c *check.C) { func (s *DockerSchema1RegistrySuite) TestPushMultipleTags(c *testing.T) {
testPushMultipleTags(c) testPushMultipleTags(c)
} }
func testPushEmptyLayer(c *check.C) { func testPushEmptyLayer(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/emptylayer", privateRegistryURL) repoName := fmt.Sprintf("%v/dockercli/emptylayer", privateRegistryURL)
emptyTarball, err := ioutil.TempFile("", "empty_tarball") emptyTarball, err := ioutil.TempFile("", "empty_tarball")
assert.NilError(c, err, "Unable to create test file") assert.NilError(c, err, "Unable to create test file")
@ -142,17 +142,17 @@ func testPushEmptyLayer(c *check.C) {
assert.NilError(c, err, "pushing the image to the private registry has failed: %s", out) assert.NilError(c, err, "pushing the image to the private registry has failed: %s", out)
} }
func (s *DockerRegistrySuite) TestPushEmptyLayer(c *check.C) { func (s *DockerRegistrySuite) TestPushEmptyLayer(c *testing.T) {
testPushEmptyLayer(c) testPushEmptyLayer(c)
} }
func (s *DockerSchema1RegistrySuite) TestPushEmptyLayer(c *check.C) { func (s *DockerSchema1RegistrySuite) TestPushEmptyLayer(c *testing.T) {
testPushEmptyLayer(c) testPushEmptyLayer(c)
} }
// testConcurrentPush pushes multiple tags to the same repo // testConcurrentPush pushes multiple tags to the same repo
// concurrently. // concurrently.
func testConcurrentPush(c *check.C) { func testConcurrentPush(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL) repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
var repos []string var repos []string
@ -196,15 +196,15 @@ func testConcurrentPush(c *check.C) {
} }
} }
func (s *DockerRegistrySuite) TestConcurrentPush(c *check.C) { func (s *DockerRegistrySuite) TestConcurrentPush(c *testing.T) {
testConcurrentPush(c) testConcurrentPush(c)
} }
func (s *DockerSchema1RegistrySuite) TestConcurrentPush(c *check.C) { func (s *DockerSchema1RegistrySuite) TestConcurrentPush(c *testing.T) {
testConcurrentPush(c) testConcurrentPush(c)
} }
func (s *DockerRegistrySuite) TestCrossRepositoryLayerPush(c *check.C) { func (s *DockerRegistrySuite) TestCrossRepositoryLayerPush(c *testing.T) {
sourceRepoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL) sourceRepoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
// tag the image to upload it to the private registry // tag the image to upload it to the private registry
dockerCmd(c, "tag", "busybox", sourceRepoName) dockerCmd(c, "tag", "busybox", sourceRepoName)
@ -246,7 +246,7 @@ func (s *DockerRegistrySuite) TestCrossRepositoryLayerPush(c *check.C) {
assert.Equal(c, out4, "hello world") assert.Equal(c, out4, "hello world")
} }
func (s *DockerSchema1RegistrySuite) TestCrossRepositoryLayerPushNotSupported(c *check.C) { func (s *DockerSchema1RegistrySuite) TestCrossRepositoryLayerPushNotSupported(c *testing.T) {
sourceRepoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL) sourceRepoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
// tag the image to upload it to the private registry // tag the image to upload it to the private registry
dockerCmd(c, "tag", "busybox", sourceRepoName) dockerCmd(c, "tag", "busybox", sourceRepoName)
@ -279,7 +279,7 @@ func (s *DockerSchema1RegistrySuite) TestCrossRepositoryLayerPushNotSupported(c
assert.Assert(c, out3 == "hello world") assert.Assert(c, out3 == "hello world")
} }
func (s *DockerRegistryAuthHtpasswdSuite) TestPushNoCredentialsNoRetry(c *check.C) { func (s *DockerRegistryAuthHtpasswdSuite) TestPushNoCredentialsNoRetry(c *testing.T) {
repoName := fmt.Sprintf("%s/busybox", privateRegistryURL) repoName := fmt.Sprintf("%s/busybox", privateRegistryURL)
dockerCmd(c, "tag", "busybox", repoName) dockerCmd(c, "tag", "busybox", repoName)
out, _, err := dockerCmdWithError("push", repoName) out, _, err := dockerCmdWithError("push", repoName)
@ -289,7 +289,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPushNoCredentialsNoRetry(c *check.
} }
// This may be flaky but it's needed not to regress on unauthorized push, see #21054 // This may be flaky but it's needed not to regress on unauthorized push, see #21054
func (s *DockerSuite) TestPushToCentralRegistryUnauthorized(c *check.C) { func (s *DockerSuite) TestPushToCentralRegistryUnauthorized(c *testing.T) {
testRequires(c, Network) testRequires(c, Network)
repoName := "test/busybox" repoName := "test/busybox"
dockerCmd(c, "tag", "busybox", repoName) dockerCmd(c, "tag", "busybox", repoName)
@ -316,7 +316,7 @@ func getTestTokenService(status int, body string, retries int) *httptest.Server
})) }))
} }
func (s *DockerRegistryAuthTokenSuite) TestPushTokenServiceUnauthResponse(c *check.C) { func (s *DockerRegistryAuthTokenSuite) TestPushTokenServiceUnauthResponse(c *testing.T) {
ts := getTestTokenService(http.StatusUnauthorized, `{"errors": [{"Code":"UNAUTHORIZED", "message": "a message", "detail": null}]}`, 0) ts := getTestTokenService(http.StatusUnauthorized, `{"errors": [{"Code":"UNAUTHORIZED", "message": "a message", "detail": null}]}`, 0)
defer ts.Close() defer ts.Close()
s.setupRegistryWithTokenService(c, ts.URL) s.setupRegistryWithTokenService(c, ts.URL)
@ -328,7 +328,7 @@ func (s *DockerRegistryAuthTokenSuite) TestPushTokenServiceUnauthResponse(c *che
assert.Assert(c, strings.Contains(out, "unauthorized: a message")) assert.Assert(c, strings.Contains(out, "unauthorized: a message"))
} }
func (s *DockerRegistryAuthTokenSuite) TestPushMisconfiguredTokenServiceResponseUnauthorized(c *check.C) { func (s *DockerRegistryAuthTokenSuite) TestPushMisconfiguredTokenServiceResponseUnauthorized(c *testing.T) {
ts := getTestTokenService(http.StatusUnauthorized, `{"error": "unauthorized"}`, 0) ts := getTestTokenService(http.StatusUnauthorized, `{"error": "unauthorized"}`, 0)
defer ts.Close() defer ts.Close()
s.setupRegistryWithTokenService(c, ts.URL) s.setupRegistryWithTokenService(c, ts.URL)
@ -341,7 +341,7 @@ func (s *DockerRegistryAuthTokenSuite) TestPushMisconfiguredTokenServiceResponse
assert.Equal(c, split[len(split)-2], "unauthorized: authentication required") assert.Equal(c, split[len(split)-2], "unauthorized: authentication required")
} }
func (s *DockerRegistryAuthTokenSuite) TestPushMisconfiguredTokenServiceResponseError(c *check.C) { func (s *DockerRegistryAuthTokenSuite) TestPushMisconfiguredTokenServiceResponseError(c *testing.T) {
ts := getTestTokenService(http.StatusTooManyRequests, `{"errors": [{"code":"TOOMANYREQUESTS","message":"out of tokens"}]}`, 3) ts := getTestTokenService(http.StatusTooManyRequests, `{"errors": [{"code":"TOOMANYREQUESTS","message":"out of tokens"}]}`, 3)
defer ts.Close() defer ts.Close()
s.setupRegistryWithTokenService(c, ts.URL) s.setupRegistryWithTokenService(c, ts.URL)
@ -356,7 +356,7 @@ func (s *DockerRegistryAuthTokenSuite) TestPushMisconfiguredTokenServiceResponse
assert.Equal(c, split[len(split)-2], "toomanyrequests: out of tokens") assert.Equal(c, split[len(split)-2], "toomanyrequests: out of tokens")
} }
func (s *DockerRegistryAuthTokenSuite) TestPushMisconfiguredTokenServiceResponseUnparsable(c *check.C) { func (s *DockerRegistryAuthTokenSuite) TestPushMisconfiguredTokenServiceResponseUnparsable(c *testing.T) {
ts := getTestTokenService(http.StatusForbidden, `no way`, 0) ts := getTestTokenService(http.StatusForbidden, `no way`, 0)
defer ts.Close() defer ts.Close()
s.setupRegistryWithTokenService(c, ts.URL) s.setupRegistryWithTokenService(c, ts.URL)
@ -369,7 +369,7 @@ func (s *DockerRegistryAuthTokenSuite) TestPushMisconfiguredTokenServiceResponse
assert.Assert(c, strings.Contains(split[len(split)-2], "error parsing HTTP 403 response body: ")) assert.Assert(c, strings.Contains(split[len(split)-2], "error parsing HTTP 403 response body: "))
} }
func (s *DockerRegistryAuthTokenSuite) TestPushMisconfiguredTokenServiceResponseNoToken(c *check.C) { func (s *DockerRegistryAuthTokenSuite) TestPushMisconfiguredTokenServiceResponseNoToken(c *testing.T) {
ts := getTestTokenService(http.StatusOK, `{"something": "wrong"}`, 0) ts := getTestTokenService(http.StatusOK, `{"something": "wrong"}`, 0)
defer ts.Close() defer ts.Close()
s.setupRegistryWithTokenService(c, ts.URL) s.setupRegistryWithTokenService(c, ts.URL)

View file

@ -29,7 +29,7 @@ func unescapeBackslashSemicolonParens(s string) string {
return string(ret) return string(ret)
} }
func regexpCheckUA(c *check.C, ua string) { func regexpCheckUA(c *testing.T, ua string) {
re := regexp.MustCompile("(?P<dockerUA>.+) UpstreamClient(?P<upstreamUA>.+)") re := regexp.MustCompile("(?P<dockerUA>.+) UpstreamClient(?P<upstreamUA>.+)")
substrArr := re.FindStringSubmatch(ua) substrArr := re.FindStringSubmatch(ua)
@ -71,7 +71,7 @@ func registerUserAgentHandler(reg *registry.Mock, result *string) {
// TestUserAgentPassThrough verifies that when an image is pulled from // TestUserAgentPassThrough verifies that when an image is pulled from
// a registry, the registry should see a User-Agent string of the form // a registry, the registry should see a User-Agent string of the form
// [docker engine UA] UpstreamClientSTREAM-CLIENT([client UA]) // [docker engine UA] UpstreamClientSTREAM-CLIENT([client UA])
func (s *DockerRegistrySuite) TestUserAgentPassThrough(c *check.C) { func (s *DockerRegistrySuite) TestUserAgentPassThrough(c *testing.T) {
var ua string var ua string
reg, err := registry.NewMock(c) reg, err := registry.NewMock(c)

View file

@ -12,7 +12,7 @@ import (
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
) )
func (s *DockerSuite) TestRestartStoppedContainer(c *check.C) { func (s *DockerSuite) TestRestartStoppedContainer(c *testing.T) {
dockerCmd(c, "run", "--name=test", "busybox", "echo", "foobar") dockerCmd(c, "run", "--name=test", "busybox", "echo", "foobar")
cleanedContainerID := getIDByName(c, "test") cleanedContainerID := getIDByName(c, "test")
@ -29,14 +29,14 @@ func (s *DockerSuite) TestRestartStoppedContainer(c *check.C) {
assert.Equal(c, out, "foobar\nfoobar\n") assert.Equal(c, out, "foobar\nfoobar\n")
} }
func (s *DockerSuite) TestRestartRunningContainer(c *check.C) { func (s *DockerSuite) TestRestartRunningContainer(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", "echo foobar && sleep 30 && echo 'should not print this'") out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", "echo foobar && sleep 30 && echo 'should not print this'")
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
assert.NilError(c, waitRun(cleanedContainerID)) assert.NilError(c, waitRun(cleanedContainerID))
getLogs := func(c *check.C) (interface{}, check.CommentInterface) { getLogs := func(c *testing.T) (interface{}, check.CommentInterface) {
out, _ := dockerCmd(c, "logs", cleanedContainerID) out, _ := dockerCmd(c, "logs", cleanedContainerID)
return out, nil return out, nil
} }
@ -52,7 +52,7 @@ func (s *DockerSuite) TestRestartRunningContainer(c *check.C) {
} }
// Test that restarting a container with a volume does not create a new volume on restart. Regression test for #819. // Test that restarting a container with a volume does not create a new volume on restart. Regression test for #819.
func (s *DockerSuite) TestRestartWithVolumes(c *check.C) { func (s *DockerSuite) TestRestartWithVolumes(c *testing.T) {
prefix, slash := getPrefixAndSlashFromDaemonPlatform() prefix, slash := getPrefixAndSlashFromDaemonPlatform()
out := runSleepingContainer(c, "-d", "-v", prefix+slash+"test") out := runSleepingContainer(c, "-d", "-v", prefix+slash+"test")
@ -77,7 +77,7 @@ func (s *DockerSuite) TestRestartWithVolumes(c *check.C) {
assert.Equal(c, source, sourceAfterRestart) assert.Equal(c, source, sourceAfterRestart)
} }
func (s *DockerSuite) TestRestartDisconnectedContainer(c *check.C) { func (s *DockerSuite) TestRestartDisconnectedContainer(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon, NotUserNamespace, NotArm) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon, NotUserNamespace, NotArm)
// Run a container on the default bridge network // Run a container on the default bridge network
@ -94,7 +94,7 @@ func (s *DockerSuite) TestRestartDisconnectedContainer(c *check.C) {
assert.Assert(c, exitCode == 0, out) assert.Assert(c, exitCode == 0, out)
} }
func (s *DockerSuite) TestRestartPolicyNO(c *check.C) { func (s *DockerSuite) TestRestartPolicyNO(c *testing.T) {
out, _ := dockerCmd(c, "create", "--restart=no", "busybox") out, _ := dockerCmd(c, "create", "--restart=no", "busybox")
id := strings.TrimSpace(string(out)) id := strings.TrimSpace(string(out))
@ -102,7 +102,7 @@ func (s *DockerSuite) TestRestartPolicyNO(c *check.C) {
assert.Equal(c, name, "no") assert.Equal(c, name, "no")
} }
func (s *DockerSuite) TestRestartPolicyAlways(c *check.C) { func (s *DockerSuite) TestRestartPolicyAlways(c *testing.T) {
out, _ := dockerCmd(c, "create", "--restart=always", "busybox") out, _ := dockerCmd(c, "create", "--restart=always", "busybox")
id := strings.TrimSpace(string(out)) id := strings.TrimSpace(string(out))
@ -115,7 +115,7 @@ func (s *DockerSuite) TestRestartPolicyAlways(c *check.C) {
assert.Equal(c, MaximumRetryCount, "0") assert.Equal(c, MaximumRetryCount, "0")
} }
func (s *DockerSuite) TestRestartPolicyOnFailure(c *check.C) { func (s *DockerSuite) TestRestartPolicyOnFailure(c *testing.T) {
out, _, err := dockerCmdWithError("create", "--restart=on-failure:-1", "busybox") out, _, err := dockerCmdWithError("create", "--restart=on-failure:-1", "busybox")
assert.ErrorContains(c, err, "", out) assert.ErrorContains(c, err, "", out)
assert.Assert(c, strings.Contains(out, "maximum retry count cannot be negative")) assert.Assert(c, strings.Contains(out, "maximum retry count cannot be negative"))
@ -150,7 +150,7 @@ func (s *DockerSuite) TestRestartPolicyOnFailure(c *check.C) {
// a good container with --restart=on-failure:3 // a good container with --restart=on-failure:3
// MaximumRetryCount!=0; RestartCount=0 // MaximumRetryCount!=0; RestartCount=0
func (s *DockerSuite) TestRestartContainerwithGoodContainer(c *check.C) { func (s *DockerSuite) TestRestartContainerwithGoodContainer(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "true") out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "true")
id := strings.TrimSpace(string(out)) id := strings.TrimSpace(string(out))
@ -164,7 +164,7 @@ func (s *DockerSuite) TestRestartContainerwithGoodContainer(c *check.C) {
assert.Equal(c, MaximumRetryCount, "3") assert.Equal(c, MaximumRetryCount, "3")
} }
func (s *DockerSuite) TestRestartContainerSuccess(c *check.C) { func (s *DockerSuite) TestRestartContainerSuccess(c *testing.T) {
// Skipped for Hyper-V isolated containers. Test is currently written // Skipped for Hyper-V isolated containers. Test is currently written
// such that it assumes there is a host process to kill. In Hyper-V // such that it assumes there is a host process to kill. In Hyper-V
// containers, the process is inside the utility VM, not on the host. // containers, the process is inside the utility VM, not on the host.
@ -193,7 +193,7 @@ func (s *DockerSuite) TestRestartContainerSuccess(c *check.C) {
assert.NilError(c, err) assert.NilError(c, err)
} }
func (s *DockerSuite) TestRestartWithPolicyUserDefinedNetwork(c *check.C) { func (s *DockerSuite) TestRestartWithPolicyUserDefinedNetwork(c *testing.T) {
// TODO Windows. This may be portable following HNS integration post TP5. // TODO Windows. This may be portable following HNS integration post TP5.
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon, NotUserNamespace, NotArm) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon, NotUserNamespace, NotArm)
dockerCmd(c, "network", "create", "-d", "bridge", "udNet") dockerCmd(c, "network", "create", "-d", "bridge", "udNet")
@ -237,7 +237,7 @@ func (s *DockerSuite) TestRestartWithPolicyUserDefinedNetwork(c *check.C) {
assert.NilError(c, err) assert.NilError(c, err)
} }
func (s *DockerSuite) TestRestartPolicyAfterRestart(c *check.C) { func (s *DockerSuite) TestRestartPolicyAfterRestart(c *testing.T) {
// Skipped for Hyper-V isolated containers. Test is currently written // Skipped for Hyper-V isolated containers. Test is currently written
// such that it assumes there is a host process to kill. In Hyper-V // such that it assumes there is a host process to kill. In Hyper-V
// containers, the process is inside the utility VM, not on the host. // containers, the process is inside the utility VM, not on the host.
@ -270,7 +270,7 @@ func (s *DockerSuite) TestRestartPolicyAfterRestart(c *check.C) {
assert.NilError(c, err) assert.NilError(c, err)
} }
func (s *DockerSuite) TestRestartContainerwithRestartPolicy(c *check.C) { func (s *DockerSuite) TestRestartContainerwithRestartPolicy(c *testing.T) {
out1, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "false") out1, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "false")
out2, _ := dockerCmd(c, "run", "-d", "--restart=always", "busybox", "false") out2, _ := dockerCmd(c, "run", "-d", "--restart=always", "busybox", "false")
@ -301,7 +301,7 @@ func (s *DockerSuite) TestRestartContainerwithRestartPolicy(c *check.C) {
assert.NilError(c, err) assert.NilError(c, err)
} }
func (s *DockerSuite) TestRestartAutoRemoveContainer(c *check.C) { func (s *DockerSuite) TestRestartAutoRemoveContainer(c *testing.T) {
out := runSleepingContainer(c, "--rm") out := runSleepingContainer(c, "--rm")
id := strings.TrimSpace(string(out)) id := strings.TrimSpace(string(out))

View file

@ -14,7 +14,7 @@ import (
"gotest.tools/icmd" "gotest.tools/icmd"
) )
func (s *DockerSuite) TestRmiWithContainerFails(c *check.C) { func (s *DockerSuite) TestRmiWithContainerFails(c *testing.T) {
errSubstr := "is using it" errSubstr := "is using it"
// create a container // create a container
@ -35,7 +35,7 @@ func (s *DockerSuite) TestRmiWithContainerFails(c *check.C) {
assert.Assert(c, images, checker.Contains, "busybox") assert.Assert(c, images, checker.Contains, "busybox")
} }
func (s *DockerSuite) TestRmiTag(c *check.C) { func (s *DockerSuite) TestRmiTag(c *testing.T) {
imagesBefore, _ := dockerCmd(c, "images", "-a") imagesBefore, _ := dockerCmd(c, "images", "-a")
dockerCmd(c, "tag", "busybox", "utest:tag1") dockerCmd(c, "tag", "busybox", "utest:tag1")
dockerCmd(c, "tag", "busybox", "utest/docker:tag2") dockerCmd(c, "tag", "busybox", "utest/docker:tag2")
@ -63,7 +63,7 @@ func (s *DockerSuite) TestRmiTag(c *check.C) {
} }
} }
func (s *DockerSuite) TestRmiImgIDMultipleTag(c *check.C) { func (s *DockerSuite) TestRmiImgIDMultipleTag(c *testing.T) {
out := cli.DockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir '/busybox-one'").Combined() out := cli.DockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir '/busybox-one'").Combined()
containerID := strings.TrimSpace(out) containerID := strings.TrimSpace(out)
@ -104,7 +104,7 @@ func (s *DockerSuite) TestRmiImgIDMultipleTag(c *check.C) {
assert.Assert(c, imagesAfter, checker.Not(checker.Contains), imgID[:12], check.Commentf("ImageID:%q; ImagesAfter: %q", imgID, imagesAfter)) assert.Assert(c, imagesAfter, checker.Not(checker.Contains), imgID[:12], check.Commentf("ImageID:%q; ImagesAfter: %q", imgID, imagesAfter))
} }
func (s *DockerSuite) TestRmiImgIDForce(c *check.C) { func (s *DockerSuite) TestRmiImgIDForce(c *testing.T) {
out := cli.DockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir '/busybox-test'").Combined() out := cli.DockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir '/busybox-test'").Combined()
containerID := strings.TrimSpace(out) containerID := strings.TrimSpace(out)
@ -142,7 +142,7 @@ func (s *DockerSuite) TestRmiImgIDForce(c *check.C) {
} }
// See https://github.com/docker/docker/issues/14116 // See https://github.com/docker/docker/issues/14116
func (s *DockerSuite) TestRmiImageIDForceWithRunningContainersAndMultipleTags(c *check.C) { func (s *DockerSuite) TestRmiImageIDForceWithRunningContainersAndMultipleTags(c *testing.T) {
dockerfile := "FROM busybox\nRUN echo test 14116\n" dockerfile := "FROM busybox\nRUN echo test 14116\n"
buildImageSuccessfully(c, "test-14116", build.WithDockerfile(dockerfile)) buildImageSuccessfully(c, "test-14116", build.WithDockerfile(dockerfile))
imgID := getIDByName(c, "test-14116") imgID := getIDByName(c, "test-14116")
@ -157,7 +157,7 @@ func (s *DockerSuite) TestRmiImageIDForceWithRunningContainersAndMultipleTags(c
assert.Assert(c, out, checker.Contains, "(cannot be forced) - image is being used by running container") assert.Assert(c, out, checker.Contains, "(cannot be forced) - image is being used by running container")
} }
func (s *DockerSuite) TestRmiTagWithExistingContainers(c *check.C) { func (s *DockerSuite) TestRmiTagWithExistingContainers(c *testing.T) {
container := "test-delete-tag" container := "test-delete-tag"
newtag := "busybox:newtag" newtag := "busybox:newtag"
bb := "busybox:latest" bb := "busybox:latest"
@ -169,7 +169,7 @@ func (s *DockerSuite) TestRmiTagWithExistingContainers(c *check.C) {
assert.Assert(c, strings.Count(out, "Untagged: "), checker.Equals, 1) assert.Assert(c, strings.Count(out, "Untagged: "), checker.Equals, 1)
} }
func (s *DockerSuite) TestRmiForceWithExistingContainers(c *check.C) { func (s *DockerSuite) TestRmiForceWithExistingContainers(c *testing.T) {
image := "busybox-clone" image := "busybox-clone"
icmd.RunCmd(icmd.Cmd{ icmd.RunCmd(icmd.Cmd{
@ -183,7 +183,7 @@ MAINTAINER foo`),
dockerCmd(c, "rmi", "-f", image) dockerCmd(c, "rmi", "-f", image)
} }
func (s *DockerSuite) TestRmiWithMultipleRepositories(c *check.C) { func (s *DockerSuite) TestRmiWithMultipleRepositories(c *testing.T) {
newRepo := "127.0.0.1:5000/busybox" newRepo := "127.0.0.1:5000/busybox"
oldRepo := "busybox" oldRepo := "busybox"
newTag := "busybox:test" newTag := "busybox:test"
@ -197,7 +197,7 @@ func (s *DockerSuite) TestRmiWithMultipleRepositories(c *check.C) {
assert.Assert(c, out, checker.Contains, "Untagged: "+newTag) assert.Assert(c, out, checker.Contains, "Untagged: "+newTag)
} }
func (s *DockerSuite) TestRmiForceWithMultipleRepositories(c *check.C) { func (s *DockerSuite) TestRmiForceWithMultipleRepositories(c *testing.T) {
imageName := "rmiimage" imageName := "rmiimage"
tag1 := imageName + ":tag1" tag1 := imageName + ":tag1"
tag2 := imageName + ":tag2" tag2 := imageName + ":tag2"
@ -215,7 +215,7 @@ func (s *DockerSuite) TestRmiForceWithMultipleRepositories(c *check.C) {
assert.Assert(c, images, checker.Contains, imageName, check.Commentf("Built image missing %q; Images: %q", imageName, images)) assert.Assert(c, images, checker.Contains, imageName, check.Commentf("Built image missing %q; Images: %q", imageName, images))
} }
func (s *DockerSuite) TestRmiBlank(c *check.C) { func (s *DockerSuite) TestRmiBlank(c *testing.T) {
out, _, err := dockerCmdWithError("rmi", " ") out, _, err := dockerCmdWithError("rmi", " ")
// Should have failed to delete ' ' image // Should have failed to delete ' ' image
assert.ErrorContains(c, err, "") assert.ErrorContains(c, err, "")
@ -225,7 +225,7 @@ func (s *DockerSuite) TestRmiBlank(c *check.C) {
assert.Assert(c, out, checker.Contains, "image name cannot be blank", check.Commentf("out: %s", out)) assert.Assert(c, out, checker.Contains, "image name cannot be blank", check.Commentf("out: %s", out))
} }
func (s *DockerSuite) TestRmiContainerImageNotFound(c *check.C) { func (s *DockerSuite) TestRmiContainerImageNotFound(c *testing.T) {
// Build 2 images for testing. // Build 2 images for testing.
imageNames := []string{"test1", "test2"} imageNames := []string{"test1", "test2"}
imageIds := make([]string, 2) imageIds := make([]string, 2)
@ -251,7 +251,7 @@ func (s *DockerSuite) TestRmiContainerImageNotFound(c *check.C) {
} }
// #13422 // #13422
func (s *DockerSuite) TestRmiUntagHistoryLayer(c *check.C) { func (s *DockerSuite) TestRmiUntagHistoryLayer(c *testing.T) {
image := "tmp1" image := "tmp1"
// Build an image for testing. // Build an image for testing.
dockerfile := `FROM busybox dockerfile := `FROM busybox
@ -295,7 +295,7 @@ RUN echo 2 #layer2
assert.Assert(c, out, checker.Contains, fmt.Sprintf("Untagged: %s:latest", newTag)) assert.Assert(c, out, checker.Contains, fmt.Sprintf("Untagged: %s:latest", newTag))
} }
func (*DockerSuite) TestRmiParentImageFail(c *check.C) { func (*DockerSuite) TestRmiParentImageFail(c *testing.T) {
buildImageSuccessfully(c, "test", build.WithDockerfile(` buildImageSuccessfully(c, "test", build.WithDockerfile(`
FROM busybox FROM busybox
RUN echo hello`)) RUN echo hello`))
@ -308,7 +308,7 @@ func (*DockerSuite) TestRmiParentImageFail(c *check.C) {
} }
} }
func (s *DockerSuite) TestRmiWithParentInUse(c *check.C) { func (s *DockerSuite) TestRmiWithParentInUse(c *testing.T) {
out, _ := dockerCmd(c, "create", "busybox") out, _ := dockerCmd(c, "create", "busybox")
cID := strings.TrimSpace(out) cID := strings.TrimSpace(out)
@ -325,7 +325,7 @@ func (s *DockerSuite) TestRmiWithParentInUse(c *check.C) {
} }
// #18873 // #18873
func (s *DockerSuite) TestRmiByIDHardConflict(c *check.C) { func (s *DockerSuite) TestRmiByIDHardConflict(c *testing.T) {
dockerCmd(c, "create", "busybox") dockerCmd(c, "create", "busybox")
imgID := inspectField(c, "busybox:latest", "Id") imgID := inspectField(c, "busybox:latest", "Id")

File diff suppressed because it is too large Load diff

View file

@ -32,7 +32,7 @@ import (
) )
// #6509 // #6509
func (s *DockerSuite) TestRunRedirectStdout(c *check.C) { func (s *DockerSuite) TestRunRedirectStdout(c *testing.T) {
checkRedirect := func(command string) { checkRedirect := func(command string) {
_, tty, err := pty.Open() _, tty, err := pty.Open()
assert.Assert(c, err, checker.IsNil, check.Commentf("Could not open pty")) assert.Assert(c, err, checker.IsNil, check.Commentf("Could not open pty"))
@ -60,7 +60,7 @@ func (s *DockerSuite) TestRunRedirectStdout(c *check.C) {
} }
// Test recursive bind mount works by default // Test recursive bind mount works by default
func (s *DockerSuite) TestRunWithVolumesIsRecursive(c *check.C) { func (s *DockerSuite) TestRunWithVolumesIsRecursive(c *testing.T) {
// /tmp gets permission denied // /tmp gets permission denied
testRequires(c, NotUserNamespace, testEnv.IsLocalDaemon) testRequires(c, NotUserNamespace, testEnv.IsLocalDaemon)
tmpDir, err := ioutil.TempDir("", "docker_recursive_mount_test") tmpDir, err := ioutil.TempDir("", "docker_recursive_mount_test")
@ -81,7 +81,7 @@ func (s *DockerSuite) TestRunWithVolumesIsRecursive(c *check.C) {
assert.Assert(c, out, checker.Contains, filepath.Base(f.Name()), check.Commentf("Recursive bind mount test failed. Expected file not found")) assert.Assert(c, out, checker.Contains, filepath.Base(f.Name()), check.Commentf("Recursive bind mount test failed. Expected file not found"))
} }
func (s *DockerSuite) TestRunDeviceDirectory(c *check.C) { func (s *DockerSuite) TestRunDeviceDirectory(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
if _, err := os.Stat("/dev/snd"); err != nil { if _, err := os.Stat("/dev/snd"); err != nil {
c.Skip("Host does not have /dev/snd") c.Skip("Host does not have /dev/snd")
@ -95,7 +95,7 @@ func (s *DockerSuite) TestRunDeviceDirectory(c *check.C) {
} }
// TestRunAttachDetach checks attaching and detaching with the default escape sequence. // TestRunAttachDetach checks attaching and detaching with the default escape sequence.
func (s *DockerSuite) TestRunAttachDetach(c *check.C) { func (s *DockerSuite) TestRunAttachDetach(c *testing.T) {
name := "attach-detach" name := "attach-detach"
dockerCmd(c, "run", "--name", name, "-itd", "busybox", "cat") dockerCmd(c, "run", "--name", name, "-itd", "busybox", "cat")
@ -146,7 +146,7 @@ func (s *DockerSuite) TestRunAttachDetach(c *check.C) {
} }
// TestRunAttachDetachFromFlag checks attaching and detaching with the escape sequence specified via flags. // TestRunAttachDetachFromFlag checks attaching and detaching with the escape sequence specified via flags.
func (s *DockerSuite) TestRunAttachDetachFromFlag(c *check.C) { func (s *DockerSuite) TestRunAttachDetachFromFlag(c *testing.T) {
name := "attach-detach" name := "attach-detach"
keyCtrlA := []byte{1} keyCtrlA := []byte{1}
keyA := []byte{97} keyA := []byte{97}
@ -207,7 +207,7 @@ func (s *DockerSuite) TestRunAttachDetachFromFlag(c *check.C) {
} }
// TestRunAttachDetachFromInvalidFlag checks attaching and detaching with the escape sequence specified via flags. // TestRunAttachDetachFromInvalidFlag checks attaching and detaching with the escape sequence specified via flags.
func (s *DockerSuite) TestRunAttachDetachFromInvalidFlag(c *check.C) { func (s *DockerSuite) TestRunAttachDetachFromInvalidFlag(c *testing.T) {
name := "attach-detach" name := "attach-detach"
dockerCmd(c, "run", "--name", name, "-itd", "busybox", "top") dockerCmd(c, "run", "--name", name, "-itd", "busybox", "top")
assert.Assert(c, waitRun(name), check.IsNil) assert.Assert(c, waitRun(name), check.IsNil)
@ -240,7 +240,7 @@ func (s *DockerSuite) TestRunAttachDetachFromInvalidFlag(c *check.C) {
} }
// TestRunAttachDetachFromConfig checks attaching and detaching with the escape sequence specified via config file. // TestRunAttachDetachFromConfig checks attaching and detaching with the escape sequence specified via config file.
func (s *DockerSuite) TestRunAttachDetachFromConfig(c *check.C) { func (s *DockerSuite) TestRunAttachDetachFromConfig(c *testing.T) {
keyCtrlA := []byte{1} keyCtrlA := []byte{1}
keyA := []byte{97} keyA := []byte{97}
@ -323,7 +323,7 @@ func (s *DockerSuite) TestRunAttachDetachFromConfig(c *check.C) {
} }
// TestRunAttachDetachKeysOverrideConfig checks attaching and detaching with the detach flags, making sure it overrides config file // TestRunAttachDetachKeysOverrideConfig checks attaching and detaching with the detach flags, making sure it overrides config file
func (s *DockerSuite) TestRunAttachDetachKeysOverrideConfig(c *check.C) { func (s *DockerSuite) TestRunAttachDetachKeysOverrideConfig(c *testing.T) {
keyCtrlA := []byte{1} keyCtrlA := []byte{1}
keyA := []byte{97} keyA := []byte{97}
@ -405,7 +405,7 @@ func (s *DockerSuite) TestRunAttachDetachKeysOverrideConfig(c *check.C) {
assert.Assert(c, running, checker.Equals, "true", check.Commentf("expected container to still be running")) assert.Assert(c, running, checker.Equals, "true", check.Commentf("expected container to still be running"))
} }
func (s *DockerSuite) TestRunAttachInvalidDetachKeySequencePreserved(c *check.C) { func (s *DockerSuite) TestRunAttachInvalidDetachKeySequencePreserved(c *testing.T) {
name := "attach-detach" name := "attach-detach"
keyA := []byte{97} keyA := []byte{97}
keyB := []byte{98} keyB := []byte{98}
@ -456,7 +456,7 @@ func (s *DockerSuite) TestRunAttachInvalidDetachKeySequencePreserved(c *check.C)
} }
// "test" should be printed // "test" should be printed
func (s *DockerSuite) TestRunWithCPUQuota(c *check.C) { func (s *DockerSuite) TestRunWithCPUQuota(c *testing.T) {
testRequires(c, cpuCfsQuota) testRequires(c, cpuCfsQuota)
file := "/sys/fs/cgroup/cpu/cpu.cfs_quota_us" file := "/sys/fs/cgroup/cpu/cpu.cfs_quota_us"
@ -467,7 +467,7 @@ func (s *DockerSuite) TestRunWithCPUQuota(c *check.C) {
assert.Equal(c, out, "8000", "setting the CPU CFS quota failed") assert.Equal(c, out, "8000", "setting the CPU CFS quota failed")
} }
func (s *DockerSuite) TestRunWithCpuPeriod(c *check.C) { func (s *DockerSuite) TestRunWithCpuPeriod(c *testing.T) {
testRequires(c, cpuCfsPeriod) testRequires(c, cpuCfsPeriod)
file := "/sys/fs/cgroup/cpu/cpu.cfs_period_us" file := "/sys/fs/cgroup/cpu/cpu.cfs_period_us"
@ -481,7 +481,7 @@ func (s *DockerSuite) TestRunWithCpuPeriod(c *check.C) {
assert.Equal(c, out, "50000", "setting the CPU CFS period failed") assert.Equal(c, out, "50000", "setting the CPU CFS period failed")
} }
func (s *DockerSuite) TestRunWithInvalidCpuPeriod(c *check.C) { func (s *DockerSuite) TestRunWithInvalidCpuPeriod(c *testing.T) {
testRequires(c, cpuCfsPeriod) testRequires(c, cpuCfsPeriod)
out, _, err := dockerCmdWithError("run", "--cpu-period", "900", "busybox", "true") out, _, err := dockerCmdWithError("run", "--cpu-period", "900", "busybox", "true")
assert.ErrorContains(c, err, "") assert.ErrorContains(c, err, "")
@ -497,7 +497,7 @@ func (s *DockerSuite) TestRunWithInvalidCpuPeriod(c *check.C) {
assert.Assert(c, strings.Contains(out, expected)) assert.Assert(c, strings.Contains(out, expected))
} }
func (s *DockerSuite) TestRunWithKernelMemory(c *check.C) { func (s *DockerSuite) TestRunWithKernelMemory(c *testing.T) {
testRequires(c, DaemonIsLinux, kernelMemorySupport) testRequires(c, DaemonIsLinux, kernelMemorySupport)
file := "/sys/fs/cgroup/memory/memory.kmem.limit_in_bytes" file := "/sys/fs/cgroup/memory/memory.kmem.limit_in_bytes"
@ -510,7 +510,7 @@ func (s *DockerSuite) TestRunWithKernelMemory(c *check.C) {
}) })
} }
func (s *DockerSuite) TestRunWithInvalidKernelMemory(c *check.C) { func (s *DockerSuite) TestRunWithInvalidKernelMemory(c *testing.T) {
testRequires(c, DaemonIsLinux, kernelMemorySupport) testRequires(c, DaemonIsLinux, kernelMemorySupport)
out, _, err := dockerCmdWithError("run", "--kernel-memory", "2M", "busybox", "true") out, _, err := dockerCmdWithError("run", "--kernel-memory", "2M", "busybox", "true")
@ -524,7 +524,7 @@ func (s *DockerSuite) TestRunWithInvalidKernelMemory(c *check.C) {
assert.Assert(c, strings.Contains(out, expected)) assert.Assert(c, strings.Contains(out, expected))
} }
func (s *DockerSuite) TestRunWithCPUShares(c *check.C) { func (s *DockerSuite) TestRunWithCPUShares(c *testing.T) {
testRequires(c, cpuShare) testRequires(c, cpuShare)
file := "/sys/fs/cgroup/cpu/cpu.shares" file := "/sys/fs/cgroup/cpu/cpu.shares"
@ -536,7 +536,7 @@ func (s *DockerSuite) TestRunWithCPUShares(c *check.C) {
} }
// "test" should be printed // "test" should be printed
func (s *DockerSuite) TestRunEchoStdoutWithCPUSharesAndMemoryLimit(c *check.C) { func (s *DockerSuite) TestRunEchoStdoutWithCPUSharesAndMemoryLimit(c *testing.T) {
testRequires(c, cpuShare) testRequires(c, cpuShare)
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
cli.DockerCmd(c, "run", "--cpu-shares", "1000", "-m", "32m", "busybox", "echo", "test").Assert(c, icmd.Expected{ cli.DockerCmd(c, "run", "--cpu-shares", "1000", "-m", "32m", "busybox", "echo", "test").Assert(c, icmd.Expected{
@ -544,7 +544,7 @@ func (s *DockerSuite) TestRunEchoStdoutWithCPUSharesAndMemoryLimit(c *check.C) {
}) })
} }
func (s *DockerSuite) TestRunWithCpusetCpus(c *check.C) { func (s *DockerSuite) TestRunWithCpusetCpus(c *testing.T) {
testRequires(c, cgroupCpuset) testRequires(c, cgroupCpuset)
file := "/sys/fs/cgroup/cpuset/cpuset.cpus" file := "/sys/fs/cgroup/cpuset/cpuset.cpus"
@ -555,7 +555,7 @@ func (s *DockerSuite) TestRunWithCpusetCpus(c *check.C) {
assert.Equal(c, out, "0") assert.Equal(c, out, "0")
} }
func (s *DockerSuite) TestRunWithCpusetMems(c *check.C) { func (s *DockerSuite) TestRunWithCpusetMems(c *testing.T) {
testRequires(c, cgroupCpuset) testRequires(c, cgroupCpuset)
file := "/sys/fs/cgroup/cpuset/cpuset.mems" file := "/sys/fs/cgroup/cpuset/cpuset.mems"
@ -566,7 +566,7 @@ func (s *DockerSuite) TestRunWithCpusetMems(c *check.C) {
assert.Equal(c, out, "0") assert.Equal(c, out, "0")
} }
func (s *DockerSuite) TestRunWithBlkioWeight(c *check.C) { func (s *DockerSuite) TestRunWithBlkioWeight(c *testing.T) {
testRequires(c, blkioWeight) testRequires(c, blkioWeight)
file := "/sys/fs/cgroup/blkio/blkio.weight" file := "/sys/fs/cgroup/blkio/blkio.weight"
@ -577,7 +577,7 @@ func (s *DockerSuite) TestRunWithBlkioWeight(c *check.C) {
assert.Equal(c, out, "300") assert.Equal(c, out, "300")
} }
func (s *DockerSuite) TestRunWithInvalidBlkioWeight(c *check.C) { func (s *DockerSuite) TestRunWithInvalidBlkioWeight(c *testing.T) {
testRequires(c, blkioWeight) testRequires(c, blkioWeight)
out, _, err := dockerCmdWithError("run", "--blkio-weight", "5", "busybox", "true") out, _, err := dockerCmdWithError("run", "--blkio-weight", "5", "busybox", "true")
assert.ErrorContains(c, err, "", out) assert.ErrorContains(c, err, "", out)
@ -585,37 +585,37 @@ func (s *DockerSuite) TestRunWithInvalidBlkioWeight(c *check.C) {
assert.Assert(c, strings.Contains(out, expected)) assert.Assert(c, strings.Contains(out, expected))
} }
func (s *DockerSuite) TestRunWithInvalidPathforBlkioWeightDevice(c *check.C) { func (s *DockerSuite) TestRunWithInvalidPathforBlkioWeightDevice(c *testing.T) {
testRequires(c, blkioWeight) testRequires(c, blkioWeight)
out, _, err := dockerCmdWithError("run", "--blkio-weight-device", "/dev/sdX:100", "busybox", "true") out, _, err := dockerCmdWithError("run", "--blkio-weight-device", "/dev/sdX:100", "busybox", "true")
assert.ErrorContains(c, err, "", out) assert.ErrorContains(c, err, "", out)
} }
func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceReadBps(c *check.C) { func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceReadBps(c *testing.T) {
testRequires(c, blkioWeight) testRequires(c, blkioWeight)
out, _, err := dockerCmdWithError("run", "--device-read-bps", "/dev/sdX:500", "busybox", "true") out, _, err := dockerCmdWithError("run", "--device-read-bps", "/dev/sdX:500", "busybox", "true")
assert.ErrorContains(c, err, "", out) assert.ErrorContains(c, err, "", out)
} }
func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceWriteBps(c *check.C) { func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceWriteBps(c *testing.T) {
testRequires(c, blkioWeight) testRequires(c, blkioWeight)
out, _, err := dockerCmdWithError("run", "--device-write-bps", "/dev/sdX:500", "busybox", "true") out, _, err := dockerCmdWithError("run", "--device-write-bps", "/dev/sdX:500", "busybox", "true")
assert.ErrorContains(c, err, "", out) assert.ErrorContains(c, err, "", out)
} }
func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceReadIOps(c *check.C) { func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceReadIOps(c *testing.T) {
testRequires(c, blkioWeight) testRequires(c, blkioWeight)
out, _, err := dockerCmdWithError("run", "--device-read-iops", "/dev/sdX:500", "busybox", "true") out, _, err := dockerCmdWithError("run", "--device-read-iops", "/dev/sdX:500", "busybox", "true")
assert.ErrorContains(c, err, "", out) assert.ErrorContains(c, err, "", out)
} }
func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceWriteIOps(c *check.C) { func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceWriteIOps(c *testing.T) {
testRequires(c, blkioWeight) testRequires(c, blkioWeight)
out, _, err := dockerCmdWithError("run", "--device-write-iops", "/dev/sdX:500", "busybox", "true") out, _, err := dockerCmdWithError("run", "--device-write-iops", "/dev/sdX:500", "busybox", "true")
assert.ErrorContains(c, err, "", out) assert.ErrorContains(c, err, "", out)
} }
func (s *DockerSuite) TestRunOOMExitCode(c *check.C) { func (s *DockerSuite) TestRunOOMExitCode(c *testing.T) {
testRequires(c, memoryLimitSupport, swapMemorySupport, NotPpc64le) testRequires(c, memoryLimitSupport, swapMemorySupport, NotPpc64le)
errChan := make(chan error) errChan := make(chan error)
go func() { go func() {
@ -635,7 +635,7 @@ func (s *DockerSuite) TestRunOOMExitCode(c *check.C) {
} }
} }
func (s *DockerSuite) TestRunWithMemoryLimit(c *check.C) { func (s *DockerSuite) TestRunWithMemoryLimit(c *testing.T) {
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
file := "/sys/fs/cgroup/memory/memory.limit_in_bytes" file := "/sys/fs/cgroup/memory/memory.limit_in_bytes"
@ -651,14 +651,14 @@ func (s *DockerSuite) TestRunWithMemoryLimit(c *check.C) {
// memory limit, this means the processes in the container can use // memory limit, this means the processes in the container can use
// 16M memory and as much swap memory as they need (if the host // 16M memory and as much swap memory as they need (if the host
// supports swap memory). // supports swap memory).
func (s *DockerSuite) TestRunWithoutMemoryswapLimit(c *check.C) { func (s *DockerSuite) TestRunWithoutMemoryswapLimit(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
testRequires(c, swapMemorySupport) testRequires(c, swapMemorySupport)
dockerCmd(c, "run", "-m", "32m", "--memory-swap", "-1", "busybox", "true") dockerCmd(c, "run", "-m", "32m", "--memory-swap", "-1", "busybox", "true")
} }
func (s *DockerSuite) TestRunWithSwappiness(c *check.C) { func (s *DockerSuite) TestRunWithSwappiness(c *testing.T) {
testRequires(c, memorySwappinessSupport) testRequires(c, memorySwappinessSupport)
file := "/sys/fs/cgroup/memory/memory.swappiness" file := "/sys/fs/cgroup/memory/memory.swappiness"
out, _ := dockerCmd(c, "run", "--memory-swappiness", "0", "--name", "test", "busybox", "cat", file) out, _ := dockerCmd(c, "run", "--memory-swappiness", "0", "--name", "test", "busybox", "cat", file)
@ -668,7 +668,7 @@ func (s *DockerSuite) TestRunWithSwappiness(c *check.C) {
assert.Equal(c, out, "0") assert.Equal(c, out, "0")
} }
func (s *DockerSuite) TestRunWithSwappinessInvalid(c *check.C) { func (s *DockerSuite) TestRunWithSwappinessInvalid(c *testing.T) {
testRequires(c, memorySwappinessSupport) testRequires(c, memorySwappinessSupport)
out, _, err := dockerCmdWithError("run", "--memory-swappiness", "101", "busybox", "true") out, _, err := dockerCmdWithError("run", "--memory-swappiness", "101", "busybox", "true")
assert.ErrorContains(c, err, "") assert.ErrorContains(c, err, "")
@ -680,7 +680,7 @@ func (s *DockerSuite) TestRunWithSwappinessInvalid(c *check.C) {
assert.Assert(c, out, checker.Contains, expected, check.Commentf("Expected output to contain %q, not %q", out, expected)) assert.Assert(c, out, checker.Contains, expected, check.Commentf("Expected output to contain %q, not %q", out, expected))
} }
func (s *DockerSuite) TestRunWithMemoryReservation(c *check.C) { func (s *DockerSuite) TestRunWithMemoryReservation(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, memoryReservationSupport) testRequires(c, testEnv.IsLocalDaemon, memoryReservationSupport)
file := "/sys/fs/cgroup/memory/memory.soft_limit_in_bytes" file := "/sys/fs/cgroup/memory/memory.soft_limit_in_bytes"
@ -691,7 +691,7 @@ func (s *DockerSuite) TestRunWithMemoryReservation(c *check.C) {
assert.Equal(c, out, "209715200") assert.Equal(c, out, "209715200")
} }
func (s *DockerSuite) TestRunWithMemoryReservationInvalid(c *check.C) { func (s *DockerSuite) TestRunWithMemoryReservationInvalid(c *testing.T) {
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
testRequires(c, testEnv.IsLocalDaemon, memoryReservationSupport) testRequires(c, testEnv.IsLocalDaemon, memoryReservationSupport)
out, _, err := dockerCmdWithError("run", "-m", "500M", "--memory-reservation", "800M", "busybox", "true") out, _, err := dockerCmdWithError("run", "-m", "500M", "--memory-reservation", "800M", "busybox", "true")
@ -705,7 +705,7 @@ func (s *DockerSuite) TestRunWithMemoryReservationInvalid(c *check.C) {
assert.Assert(c, strings.TrimSpace(out), checker.Contains, expected, check.Commentf("run container should fail with invalid memory reservation")) assert.Assert(c, strings.TrimSpace(out), checker.Contains, expected, check.Commentf("run container should fail with invalid memory reservation"))
} }
func (s *DockerSuite) TestStopContainerSignal(c *check.C) { func (s *DockerSuite) TestStopContainerSignal(c *testing.T) {
out, _ := dockerCmd(c, "run", "--stop-signal", "SIGUSR1", "-d", "busybox", "/bin/sh", "-c", `trap 'echo "exit trapped"; exit 0' USR1; while true; do sleep 1; done`) out, _ := dockerCmd(c, "run", "--stop-signal", "SIGUSR1", "-d", "busybox", "/bin/sh", "-c", `trap 'echo "exit trapped"; exit 0' USR1; while true; do sleep 1; done`)
containerID := strings.TrimSpace(out) containerID := strings.TrimSpace(out)
@ -717,7 +717,7 @@ func (s *DockerSuite) TestStopContainerSignal(c *check.C) {
assert.Assert(c, out, checker.Contains, "exit trapped", check.Commentf("Expected `exit trapped` in the log")) assert.Assert(c, out, checker.Contains, "exit trapped", check.Commentf("Expected `exit trapped` in the log"))
} }
func (s *DockerSuite) TestRunSwapLessThanMemoryLimit(c *check.C) { func (s *DockerSuite) TestRunSwapLessThanMemoryLimit(c *testing.T) {
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
testRequires(c, swapMemorySupport) testRequires(c, swapMemorySupport)
out, _, err := dockerCmdWithError("run", "-m", "16m", "--memory-swap", "15m", "busybox", "echo", "test") out, _, err := dockerCmdWithError("run", "-m", "16m", "--memory-swap", "15m", "busybox", "echo", "test")
@ -727,7 +727,7 @@ func (s *DockerSuite) TestRunSwapLessThanMemoryLimit(c *check.C) {
assert.Assert(c, strings.Contains(out, expected)) assert.Assert(c, strings.Contains(out, expected))
} }
func (s *DockerSuite) TestRunInvalidCpusetCpusFlagValue(c *check.C) { func (s *DockerSuite) TestRunInvalidCpusetCpusFlagValue(c *testing.T) {
testRequires(c, cgroupCpuset, testEnv.IsLocalDaemon) testRequires(c, cgroupCpuset, testEnv.IsLocalDaemon)
sysInfo := sysinfo.New(true) sysInfo := sysinfo.New(true)
@ -746,7 +746,7 @@ func (s *DockerSuite) TestRunInvalidCpusetCpusFlagValue(c *check.C) {
assert.Assert(c, strings.Contains(out, expected)) assert.Assert(c, strings.Contains(out, expected))
} }
func (s *DockerSuite) TestRunInvalidCpusetMemsFlagValue(c *check.C) { func (s *DockerSuite) TestRunInvalidCpusetMemsFlagValue(c *testing.T) {
testRequires(c, cgroupCpuset) testRequires(c, cgroupCpuset)
sysInfo := sysinfo.New(true) sysInfo := sysinfo.New(true)
@ -765,7 +765,7 @@ func (s *DockerSuite) TestRunInvalidCpusetMemsFlagValue(c *check.C) {
assert.Assert(c, strings.Contains(out, expected)) assert.Assert(c, strings.Contains(out, expected))
} }
func (s *DockerSuite) TestRunInvalidCPUShares(c *check.C) { func (s *DockerSuite) TestRunInvalidCPUShares(c *testing.T) {
testRequires(c, cpuShare, DaemonIsLinux) testRequires(c, cpuShare, DaemonIsLinux)
out, _, err := dockerCmdWithError("run", "--cpu-shares", "1", "busybox", "echo", "test") out, _, err := dockerCmdWithError("run", "--cpu-shares", "1", "busybox", "echo", "test")
assert.ErrorContains(c, err, "", out) assert.ErrorContains(c, err, "", out)
@ -783,7 +783,7 @@ func (s *DockerSuite) TestRunInvalidCPUShares(c *check.C) {
assert.Assert(c, strings.Contains(out, expected)) assert.Assert(c, strings.Contains(out, expected))
} }
func (s *DockerSuite) TestRunWithDefaultShmSize(c *check.C) { func (s *DockerSuite) TestRunWithDefaultShmSize(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "shm-default" name := "shm-default"
@ -796,7 +796,7 @@ func (s *DockerSuite) TestRunWithDefaultShmSize(c *check.C) {
assert.Assert(c, shmSize, check.Equals, "67108864") assert.Assert(c, shmSize, check.Equals, "67108864")
} }
func (s *DockerSuite) TestRunWithShmSize(c *check.C) { func (s *DockerSuite) TestRunWithShmSize(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "shm" name := "shm"
@ -809,7 +809,7 @@ func (s *DockerSuite) TestRunWithShmSize(c *check.C) {
assert.Assert(c, shmSize, check.Equals, "1073741824") assert.Assert(c, shmSize, check.Equals, "1073741824")
} }
func (s *DockerSuite) TestRunTmpfsMountsEnsureOrdered(c *check.C) { func (s *DockerSuite) TestRunTmpfsMountsEnsureOrdered(c *testing.T) {
tmpFile, err := ioutil.TempFile("", "test") tmpFile, err := ioutil.TempFile("", "test")
assert.NilError(c, err) assert.NilError(c, err)
defer tmpFile.Close() defer tmpFile.Close()
@ -817,7 +817,7 @@ func (s *DockerSuite) TestRunTmpfsMountsEnsureOrdered(c *check.C) {
assert.Assert(c, out, checker.Contains, "test") assert.Assert(c, out, checker.Contains, "test")
} }
func (s *DockerSuite) TestRunTmpfsMounts(c *check.C) { func (s *DockerSuite) TestRunTmpfsMounts(c *testing.T) {
// TODO Windows (Post TP5): This test cannot run on a Windows daemon as // TODO Windows (Post TP5): This test cannot run on a Windows daemon as
// Windows does not support tmpfs mounts. // Windows does not support tmpfs mounts.
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -838,7 +838,7 @@ func (s *DockerSuite) TestRunTmpfsMounts(c *check.C) {
} }
} }
func (s *DockerSuite) TestRunTmpfsMountsOverrideImageVolumes(c *check.C) { func (s *DockerSuite) TestRunTmpfsMountsOverrideImageVolumes(c *testing.T) {
name := "img-with-volumes" name := "img-with-volumes"
buildImageSuccessfully(c, name, build.WithDockerfile(` buildImageSuccessfully(c, name, build.WithDockerfile(`
FROM busybox FROM busybox
@ -850,7 +850,7 @@ func (s *DockerSuite) TestRunTmpfsMountsOverrideImageVolumes(c *check.C) {
} }
// Test case for #22420 // Test case for #22420
func (s *DockerSuite) TestRunTmpfsMountsWithOptions(c *check.C) { func (s *DockerSuite) TestRunTmpfsMountsWithOptions(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
expectedOptions := []string{"rw", "nosuid", "nodev", "noexec", "relatime"} expectedOptions := []string{"rw", "nosuid", "nodev", "noexec", "relatime"}
@ -890,7 +890,7 @@ func (s *DockerSuite) TestRunTmpfsMountsWithOptions(c *check.C) {
} }
} }
func (s *DockerSuite) TestRunSysctls(c *check.C) { func (s *DockerSuite) TestRunSysctls(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
var err error var err error
@ -921,7 +921,7 @@ func (s *DockerSuite) TestRunSysctls(c *check.C) {
} }
// TestRunSeccompProfileDenyUnshare checks that 'docker run --security-opt seccomp=/tmp/profile.json debian:jessie unshare' exits with operation not permitted. // TestRunSeccompProfileDenyUnshare checks that 'docker run --security-opt seccomp=/tmp/profile.json debian:jessie unshare' exits with operation not permitted.
func (s *DockerSuite) TestRunSeccompProfileDenyUnshare(c *check.C) { func (s *DockerSuite) TestRunSeccompProfileDenyUnshare(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, NotArm, Apparmor) testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, NotArm, Apparmor)
jsonData := `{ jsonData := `{
"defaultAction": "SCMP_ACT_ALLOW", "defaultAction": "SCMP_ACT_ALLOW",
@ -950,7 +950,7 @@ func (s *DockerSuite) TestRunSeccompProfileDenyUnshare(c *check.C) {
} }
// TestRunSeccompProfileDenyChmod checks that 'docker run --security-opt seccomp=/tmp/profile.json busybox chmod 400 /etc/hostname' exits with operation not permitted. // TestRunSeccompProfileDenyChmod checks that 'docker run --security-opt seccomp=/tmp/profile.json busybox chmod 400 /etc/hostname' exits with operation not permitted.
func (s *DockerSuite) TestRunSeccompProfileDenyChmod(c *check.C) { func (s *DockerSuite) TestRunSeccompProfileDenyChmod(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled) testRequires(c, testEnv.IsLocalDaemon, seccompEnabled)
jsonData := `{ jsonData := `{
"defaultAction": "SCMP_ACT_ALLOW", "defaultAction": "SCMP_ACT_ALLOW",
@ -985,7 +985,7 @@ func (s *DockerSuite) TestRunSeccompProfileDenyChmod(c *check.C) {
// TestRunSeccompProfileDenyUnshareUserns checks that 'docker run debian:jessie unshare --map-root-user --user sh -c whoami' with a specific profile to // TestRunSeccompProfileDenyUnshareUserns checks that 'docker run debian:jessie unshare --map-root-user --user sh -c whoami' with a specific profile to
// deny unshare of a userns exits with operation not permitted. // deny unshare of a userns exits with operation not permitted.
func (s *DockerSuite) TestRunSeccompProfileDenyUnshareUserns(c *check.C) { func (s *DockerSuite) TestRunSeccompProfileDenyUnshareUserns(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, NotArm, Apparmor) testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, NotArm, Apparmor)
// from sched.h // from sched.h
jsonData := fmt.Sprintf(`{ jsonData := fmt.Sprintf(`{
@ -1023,7 +1023,7 @@ func (s *DockerSuite) TestRunSeccompProfileDenyUnshareUserns(c *check.C) {
// TestRunSeccompProfileDenyCloneUserns checks that 'docker run syscall-test' // TestRunSeccompProfileDenyCloneUserns checks that 'docker run syscall-test'
// with a the default seccomp profile exits with operation not permitted. // with a the default seccomp profile exits with operation not permitted.
func (s *DockerSuite) TestRunSeccompProfileDenyCloneUserns(c *check.C) { func (s *DockerSuite) TestRunSeccompProfileDenyCloneUserns(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled) testRequires(c, testEnv.IsLocalDaemon, seccompEnabled)
ensureSyscallTest(c) ensureSyscallTest(c)
@ -1035,7 +1035,7 @@ func (s *DockerSuite) TestRunSeccompProfileDenyCloneUserns(c *check.C) {
// TestRunSeccompUnconfinedCloneUserns checks that // TestRunSeccompUnconfinedCloneUserns checks that
// 'docker run --security-opt seccomp=unconfined syscall-test' allows creating a userns. // 'docker run --security-opt seccomp=unconfined syscall-test' allows creating a userns.
func (s *DockerSuite) TestRunSeccompUnconfinedCloneUserns(c *check.C) { func (s *DockerSuite) TestRunSeccompUnconfinedCloneUserns(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, UserNamespaceInKernel, NotUserNamespace, unprivilegedUsernsClone) testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, UserNamespaceInKernel, NotUserNamespace, unprivilegedUsernsClone)
ensureSyscallTest(c) ensureSyscallTest(c)
@ -1048,7 +1048,7 @@ func (s *DockerSuite) TestRunSeccompUnconfinedCloneUserns(c *check.C) {
// TestRunSeccompAllowPrivCloneUserns checks that 'docker run --privileged syscall-test' // TestRunSeccompAllowPrivCloneUserns checks that 'docker run --privileged syscall-test'
// allows creating a userns. // allows creating a userns.
func (s *DockerSuite) TestRunSeccompAllowPrivCloneUserns(c *check.C) { func (s *DockerSuite) TestRunSeccompAllowPrivCloneUserns(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, UserNamespaceInKernel, NotUserNamespace) testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, UserNamespaceInKernel, NotUserNamespace)
ensureSyscallTest(c) ensureSyscallTest(c)
@ -1060,7 +1060,7 @@ func (s *DockerSuite) TestRunSeccompAllowPrivCloneUserns(c *check.C) {
// TestRunSeccompProfileAllow32Bit checks that 32 bit code can run on x86_64 // TestRunSeccompProfileAllow32Bit checks that 32 bit code can run on x86_64
// with the default seccomp profile. // with the default seccomp profile.
func (s *DockerSuite) TestRunSeccompProfileAllow32Bit(c *check.C) { func (s *DockerSuite) TestRunSeccompProfileAllow32Bit(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, IsAmd64) testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, IsAmd64)
ensureSyscallTest(c) ensureSyscallTest(c)
@ -1068,14 +1068,14 @@ func (s *DockerSuite) TestRunSeccompProfileAllow32Bit(c *check.C) {
} }
// TestRunSeccompAllowSetrlimit checks that 'docker run debian:jessie ulimit -v 1048510' succeeds. // TestRunSeccompAllowSetrlimit checks that 'docker run debian:jessie ulimit -v 1048510' succeeds.
func (s *DockerSuite) TestRunSeccompAllowSetrlimit(c *check.C) { func (s *DockerSuite) TestRunSeccompAllowSetrlimit(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled) testRequires(c, testEnv.IsLocalDaemon, seccompEnabled)
// ulimit uses setrlimit, so we want to make sure we don't break it // ulimit uses setrlimit, so we want to make sure we don't break it
icmd.RunCommand(dockerBinary, "run", "debian:jessie", "bash", "-c", "ulimit -v 1048510").Assert(c, icmd.Success) icmd.RunCommand(dockerBinary, "run", "debian:jessie", "bash", "-c", "ulimit -v 1048510").Assert(c, icmd.Success)
} }
func (s *DockerSuite) TestRunSeccompDefaultProfileAcct(c *check.C) { func (s *DockerSuite) TestRunSeccompDefaultProfileAcct(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, NotUserNamespace) testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, NotUserNamespace)
ensureSyscallTest(c) ensureSyscallTest(c)
@ -1105,7 +1105,7 @@ func (s *DockerSuite) TestRunSeccompDefaultProfileAcct(c *check.C) {
} }
} }
func (s *DockerSuite) TestRunSeccompDefaultProfileNS(c *check.C) { func (s *DockerSuite) TestRunSeccompDefaultProfileNS(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, NotUserNamespace) testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, NotUserNamespace)
ensureSyscallTest(c) ensureSyscallTest(c)
@ -1142,7 +1142,7 @@ func (s *DockerSuite) TestRunSeccompDefaultProfileNS(c *check.C) {
// TestRunNoNewPrivSetuid checks that --security-opt='no-new-privileges=true' prevents // TestRunNoNewPrivSetuid checks that --security-opt='no-new-privileges=true' prevents
// effective uid transitions on executing setuid binaries. // effective uid transitions on executing setuid binaries.
func (s *DockerSuite) TestRunNoNewPrivSetuid(c *check.C) { func (s *DockerSuite) TestRunNoNewPrivSetuid(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, NotUserNamespace, testEnv.IsLocalDaemon)
ensureNNPTest(c) ensureNNPTest(c)
@ -1155,7 +1155,7 @@ func (s *DockerSuite) TestRunNoNewPrivSetuid(c *check.C) {
// TestLegacyRunNoNewPrivSetuid checks that --security-opt=no-new-privileges prevents // TestLegacyRunNoNewPrivSetuid checks that --security-opt=no-new-privileges prevents
// effective uid transitions on executing setuid binaries. // effective uid transitions on executing setuid binaries.
func (s *DockerSuite) TestLegacyRunNoNewPrivSetuid(c *check.C) { func (s *DockerSuite) TestLegacyRunNoNewPrivSetuid(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, NotUserNamespace, testEnv.IsLocalDaemon)
ensureNNPTest(c) ensureNNPTest(c)
@ -1166,7 +1166,7 @@ func (s *DockerSuite) TestLegacyRunNoNewPrivSetuid(c *check.C) {
}) })
} }
func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChown(c *check.C) { func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChown(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
ensureSyscallTest(c) ensureSyscallTest(c)
@ -1184,7 +1184,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChown(c *check.C) {
}) })
} }
func (s *DockerSuite) TestUserNoEffectiveCapabilitiesDacOverride(c *check.C) { func (s *DockerSuite) TestUserNoEffectiveCapabilitiesDacOverride(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
ensureSyscallTest(c) ensureSyscallTest(c)
@ -1197,7 +1197,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesDacOverride(c *check.C) {
}) })
} }
func (s *DockerSuite) TestUserNoEffectiveCapabilitiesFowner(c *check.C) { func (s *DockerSuite) TestUserNoEffectiveCapabilitiesFowner(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
ensureSyscallTest(c) ensureSyscallTest(c)
@ -1213,7 +1213,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesFowner(c *check.C) {
// TODO CAP_KILL // TODO CAP_KILL
func (s *DockerSuite) TestUserNoEffectiveCapabilitiesSetuid(c *check.C) { func (s *DockerSuite) TestUserNoEffectiveCapabilitiesSetuid(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
ensureSyscallTest(c) ensureSyscallTest(c)
@ -1231,7 +1231,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesSetuid(c *check.C) {
}) })
} }
func (s *DockerSuite) TestUserNoEffectiveCapabilitiesSetgid(c *check.C) { func (s *DockerSuite) TestUserNoEffectiveCapabilitiesSetgid(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
ensureSyscallTest(c) ensureSyscallTest(c)
@ -1251,7 +1251,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesSetgid(c *check.C) {
// TODO CAP_SETPCAP // TODO CAP_SETPCAP
func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetBindService(c *check.C) { func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetBindService(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
ensureSyscallTest(c) ensureSyscallTest(c)
@ -1269,7 +1269,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetBindService(c *check.C)
}) })
} }
func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetRaw(c *check.C) { func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetRaw(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
ensureSyscallTest(c) ensureSyscallTest(c)
@ -1287,7 +1287,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetRaw(c *check.C) {
}) })
} }
func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChroot(c *check.C) { func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChroot(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
ensureSyscallTest(c) ensureSyscallTest(c)
@ -1305,7 +1305,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChroot(c *check.C) {
}) })
} }
func (s *DockerSuite) TestUserNoEffectiveCapabilitiesMknod(c *check.C) { func (s *DockerSuite) TestUserNoEffectiveCapabilitiesMknod(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, NotUserNamespace, testEnv.IsLocalDaemon)
ensureSyscallTest(c) ensureSyscallTest(c)
@ -1327,7 +1327,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesMknod(c *check.C) {
// TODO CAP_AUDIT_WRITE // TODO CAP_AUDIT_WRITE
// TODO CAP_SETFCAP // TODO CAP_SETFCAP
func (s *DockerSuite) TestRunApparmorProcDirectory(c *check.C) { func (s *DockerSuite) TestRunApparmorProcDirectory(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, Apparmor) testRequires(c, testEnv.IsLocalDaemon, Apparmor)
// running w seccomp unconfined tests the apparmor profile // running w seccomp unconfined tests the apparmor profile
@ -1346,7 +1346,7 @@ func (s *DockerSuite) TestRunApparmorProcDirectory(c *check.C) {
// make sure the default profile can be successfully parsed (using unshare as it is // make sure the default profile can be successfully parsed (using unshare as it is
// something which we know is blocked in the default profile) // something which we know is blocked in the default profile)
func (s *DockerSuite) TestRunSeccompWithDefaultProfile(c *check.C) { func (s *DockerSuite) TestRunSeccompWithDefaultProfile(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled) testRequires(c, testEnv.IsLocalDaemon, seccompEnabled)
out, _, err := dockerCmdWithError("run", "--security-opt", "seccomp=../profiles/seccomp/default.json", "debian:jessie", "unshare", "--map-root-user", "--user", "sh", "-c", "whoami") out, _, err := dockerCmdWithError("run", "--security-opt", "seccomp=../profiles/seccomp/default.json", "debian:jessie", "unshare", "--map-root-user", "--user", "sh", "-c", "whoami")
@ -1355,7 +1355,7 @@ func (s *DockerSuite) TestRunSeccompWithDefaultProfile(c *check.C) {
} }
// TestRunDeviceSymlink checks run with device that follows symlink (#13840 and #22271) // TestRunDeviceSymlink checks run with device that follows symlink (#13840 and #22271)
func (s *DockerSuite) TestRunDeviceSymlink(c *check.C) { func (s *DockerSuite) TestRunDeviceSymlink(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm, testEnv.IsLocalDaemon)
if _, err := os.Stat("/dev/zero"); err != nil { if _, err := os.Stat("/dev/zero"); err != nil {
c.Skip("Host does not have /dev/zero") c.Skip("Host does not have /dev/zero")
@ -1404,7 +1404,7 @@ func (s *DockerSuite) TestRunDeviceSymlink(c *check.C) {
} }
// TestRunPIDsLimit makes sure the pids cgroup is set with --pids-limit // TestRunPIDsLimit makes sure the pids cgroup is set with --pids-limit
func (s *DockerSuite) TestRunPIDsLimit(c *check.C) { func (s *DockerSuite) TestRunPIDsLimit(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, pidsLimit) testRequires(c, testEnv.IsLocalDaemon, pidsLimit)
file := "/sys/fs/cgroup/pids/pids.max" file := "/sys/fs/cgroup/pids/pids.max"
@ -1415,7 +1415,7 @@ func (s *DockerSuite) TestRunPIDsLimit(c *check.C) {
assert.Equal(c, out, "4", "setting the pids limit failed") assert.Equal(c, out, "4", "setting the pids limit failed")
} }
func (s *DockerSuite) TestRunPrivilegedAllowedDevices(c *check.C) { func (s *DockerSuite) TestRunPrivilegedAllowedDevices(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace) testRequires(c, DaemonIsLinux, NotUserNamespace)
file := "/sys/fs/cgroup/devices/devices.list" file := "/sys/fs/cgroup/devices/devices.list"
@ -1424,7 +1424,7 @@ func (s *DockerSuite) TestRunPrivilegedAllowedDevices(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "a *:* rwm") assert.Equal(c, strings.TrimSpace(out), "a *:* rwm")
} }
func (s *DockerSuite) TestRunUserDeviceAllowed(c *check.C) { func (s *DockerSuite) TestRunUserDeviceAllowed(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
fi, err := os.Stat("/dev/snd/timer") fi, err := os.Stat("/dev/snd/timer")
@ -1441,7 +1441,7 @@ func (s *DockerSuite) TestRunUserDeviceAllowed(c *check.C) {
assert.Assert(c, out, checker.Contains, fmt.Sprintf("c %d:%d w", stat.Rdev/256, stat.Rdev%256)) assert.Assert(c, out, checker.Contains, fmt.Sprintf("c %d:%d w", stat.Rdev/256, stat.Rdev%256))
} }
func (s *DockerDaemonSuite) TestRunSeccompJSONNewFormat(c *check.C) { func (s *DockerDaemonSuite) TestRunSeccompJSONNewFormat(c *testing.T) {
testRequires(c, seccompEnabled) testRequires(c, seccompEnabled)
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
@ -1466,7 +1466,7 @@ func (s *DockerDaemonSuite) TestRunSeccompJSONNewFormat(c *check.C) {
assert.Assert(c, out, checker.Contains, "Operation not permitted") assert.Assert(c, out, checker.Contains, "Operation not permitted")
} }
func (s *DockerDaemonSuite) TestRunSeccompJSONNoNameAndNames(c *check.C) { func (s *DockerDaemonSuite) TestRunSeccompJSONNoNameAndNames(c *testing.T) {
testRequires(c, seccompEnabled) testRequires(c, seccompEnabled)
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
@ -1492,7 +1492,7 @@ func (s *DockerDaemonSuite) TestRunSeccompJSONNoNameAndNames(c *check.C) {
assert.Assert(c, out, checker.Contains, "'name' and 'names' were specified in the seccomp profile, use either 'name' or 'names'") assert.Assert(c, out, checker.Contains, "'name' and 'names' were specified in the seccomp profile, use either 'name' or 'names'")
} }
func (s *DockerDaemonSuite) TestRunSeccompJSONNoArchAndArchMap(c *check.C) { func (s *DockerDaemonSuite) TestRunSeccompJSONNoArchAndArchMap(c *testing.T) {
testRequires(c, seccompEnabled) testRequires(c, seccompEnabled)
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
@ -1529,7 +1529,7 @@ func (s *DockerDaemonSuite) TestRunSeccompJSONNoArchAndArchMap(c *check.C) {
assert.Assert(c, out, checker.Contains, "'architectures' and 'archMap' were specified in the seccomp profile, use either 'architectures' or 'archMap'") assert.Assert(c, out, checker.Contains, "'architectures' and 'archMap' were specified in the seccomp profile, use either 'architectures' or 'archMap'")
} }
func (s *DockerDaemonSuite) TestRunWithDaemonDefaultSeccompProfile(c *check.C) { func (s *DockerDaemonSuite) TestRunWithDaemonDefaultSeccompProfile(c *testing.T) {
testRequires(c, seccompEnabled) testRequires(c, seccompEnabled)
s.d.StartWithBusybox(c) s.d.StartWithBusybox(c)
@ -1565,7 +1565,7 @@ func (s *DockerDaemonSuite) TestRunWithDaemonDefaultSeccompProfile(c *check.C) {
assert.Assert(c, out, checker.Contains, "Operation not permitted") assert.Assert(c, out, checker.Contains, "Operation not permitted")
} }
func (s *DockerSuite) TestRunWithNanoCPUs(c *check.C) { func (s *DockerSuite) TestRunWithNanoCPUs(c *testing.T) {
testRequires(c, cpuCfsQuota, cpuCfsPeriod) testRequires(c, cpuCfsQuota, cpuCfsPeriod)
file1 := "/sys/fs/cgroup/cpu/cpu.cfs_quota_us" file1 := "/sys/fs/cgroup/cpu/cpu.cfs_quota_us"

View file

@ -25,7 +25,7 @@ import (
) )
// save a repo using gz compression and try to load it using stdout // save a repo using gz compression and try to load it using stdout
func (s *DockerSuite) TestSaveXzAndLoadRepoStdout(c *check.C) { func (s *DockerSuite) TestSaveXzAndLoadRepoStdout(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "test-save-xz-and-load-repo-stdout" name := "test-save-xz-and-load-repo-stdout"
dockerCmd(c, "run", "--name", name, "busybox", "true") dockerCmd(c, "run", "--name", name, "busybox", "true")
@ -54,7 +54,7 @@ func (s *DockerSuite) TestSaveXzAndLoadRepoStdout(c *check.C) {
} }
// save a repo using xz+gz compression and try to load it using stdout // save a repo using xz+gz compression and try to load it using stdout
func (s *DockerSuite) TestSaveXzGzAndLoadRepoStdout(c *check.C) { func (s *DockerSuite) TestSaveXzGzAndLoadRepoStdout(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "test-save-xz-gz-and-load-repo-stdout" name := "test-save-xz-gz-and-load-repo-stdout"
dockerCmd(c, "run", "--name", name, "busybox", "true") dockerCmd(c, "run", "--name", name, "busybox", "true")
@ -83,7 +83,7 @@ func (s *DockerSuite) TestSaveXzGzAndLoadRepoStdout(c *check.C) {
assert.ErrorContains(c, err, "", "the repo should not exist: %v", after) assert.ErrorContains(c, err, "", "the repo should not exist: %v", after)
} }
func (s *DockerSuite) TestSaveSingleTag(c *check.C) { func (s *DockerSuite) TestSaveSingleTag(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
repoName := "foobar-save-single-tag-test" repoName := "foobar-save-single-tag-test"
dockerCmd(c, "tag", "busybox:latest", fmt.Sprintf("%v:latest", repoName)) dockerCmd(c, "tag", "busybox:latest", fmt.Sprintf("%v:latest", repoName))
@ -98,7 +98,7 @@ func (s *DockerSuite) TestSaveSingleTag(c *check.C) {
assert.NilError(c, err, "failed to save repo with image ID and 'repositories' file: %s, %v", out, err) assert.NilError(c, err, "failed to save repo with image ID and 'repositories' file: %s, %v", out, err)
} }
func (s *DockerSuite) TestSaveCheckTimes(c *check.C) { func (s *DockerSuite) TestSaveCheckTimes(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
repoName := "busybox:latest" repoName := "busybox:latest"
out, _ := dockerCmd(c, "inspect", repoName) out, _ := dockerCmd(c, "inspect", repoName)
@ -117,7 +117,7 @@ func (s *DockerSuite) TestSaveCheckTimes(c *check.C) {
assert.NilError(c, err, "failed to save repo with image ID and 'repositories' file: %s, %v", out, err) assert.NilError(c, err, "failed to save repo with image ID and 'repositories' file: %s, %v", out, err)
} }
func (s *DockerSuite) TestSaveImageId(c *check.C) { func (s *DockerSuite) TestSaveImageId(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
repoName := "foobar-save-image-id-test" repoName := "foobar-save-image-id-test"
dockerCmd(c, "tag", "emptyfs:latest", fmt.Sprintf("%v:latest", repoName)) dockerCmd(c, "tag", "emptyfs:latest", fmt.Sprintf("%v:latest", repoName))
@ -156,7 +156,7 @@ func (s *DockerSuite) TestSaveImageId(c *check.C) {
} }
// save a repo and try to load it using flags // save a repo and try to load it using flags
func (s *DockerSuite) TestSaveAndLoadRepoFlags(c *check.C) { func (s *DockerSuite) TestSaveAndLoadRepoFlags(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "test-save-and-load-repo-flags" name := "test-save-and-load-repo-flags"
dockerCmd(c, "run", "--name", name, "busybox", "true") dockerCmd(c, "run", "--name", name, "busybox", "true")
@ -177,7 +177,7 @@ func (s *DockerSuite) TestSaveAndLoadRepoFlags(c *check.C) {
assert.Equal(c, before, after, "inspect is not the same after a save / load") assert.Equal(c, before, after, "inspect is not the same after a save / load")
} }
func (s *DockerSuite) TestSaveWithNoExistImage(c *check.C) { func (s *DockerSuite) TestSaveWithNoExistImage(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
imgName := "foobar-non-existing-image" imgName := "foobar-non-existing-image"
@ -187,7 +187,7 @@ func (s *DockerSuite) TestSaveWithNoExistImage(c *check.C) {
assert.Assert(c, strings.Contains(out, fmt.Sprintf("No such image: %s", imgName))) assert.Assert(c, strings.Contains(out, fmt.Sprintf("No such image: %s", imgName)))
} }
func (s *DockerSuite) TestSaveMultipleNames(c *check.C) { func (s *DockerSuite) TestSaveMultipleNames(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
repoName := "foobar-save-multi-name-test" repoName := "foobar-save-multi-name-test"
@ -205,7 +205,7 @@ func (s *DockerSuite) TestSaveMultipleNames(c *check.C) {
assert.NilError(c, err, "failed to save multiple repos: %s, %v", out, err) assert.NilError(c, err, "failed to save multiple repos: %s, %v", out, err)
} }
func (s *DockerSuite) TestSaveRepoWithMultipleImages(c *check.C) { func (s *DockerSuite) TestSaveRepoWithMultipleImages(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
makeImage := func(from string, tag string) string { makeImage := func(from string, tag string) string {
var ( var (
@ -257,7 +257,7 @@ func (s *DockerSuite) TestSaveRepoWithMultipleImages(c *check.C) {
} }
// Issue #6722 #5892 ensure directories are included in changes // Issue #6722 #5892 ensure directories are included in changes
func (s *DockerSuite) TestSaveDirectoryPermissions(c *check.C) { func (s *DockerSuite) TestSaveDirectoryPermissions(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
layerEntries := []string{"opt/", "opt/a/", "opt/a/b/", "opt/a/b/c"} layerEntries := []string{"opt/", "opt/a/", "opt/a/b/", "opt/a/b/c"}
layerEntriesAUFS := []string{"./", ".wh..wh.aufs", ".wh..wh.orph/", ".wh..wh.plnk/", "opt/", "opt/a/", "opt/a/b/", "opt/a/b/c"} layerEntriesAUFS := []string{"./", ".wh..wh.aufs", ".wh..wh.orph/", ".wh..wh.plnk/", "opt/", "opt/a/", "opt/a/b/", "opt/a/b/c"}
@ -331,7 +331,7 @@ func listTar(f io.Reader) ([]string, error) {
// Test loading a weird image where one of the layers is of zero size. // Test loading a weird image where one of the layers is of zero size.
// The layer.tar file is actually zero bytes, no padding or anything else. // The layer.tar file is actually zero bytes, no padding or anything else.
// See issue: 18170 // See issue: 18170
func (s *DockerSuite) TestLoadZeroSizeLayer(c *check.C) { func (s *DockerSuite) TestLoadZeroSizeLayer(c *testing.T) {
// this will definitely not work if using remote daemon // this will definitely not work if using remote daemon
// very weird test // very weird test
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
@ -339,7 +339,7 @@ func (s *DockerSuite) TestLoadZeroSizeLayer(c *check.C) {
dockerCmd(c, "load", "-i", "testdata/emptyLayer.tar") dockerCmd(c, "load", "-i", "testdata/emptyLayer.tar")
} }
func (s *DockerSuite) TestSaveLoadParents(c *check.C) { func (s *DockerSuite) TestSaveLoadParents(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
makeImage := func(from string, addfile string) string { makeImage := func(from string, addfile string) string {
@ -378,7 +378,7 @@ func (s *DockerSuite) TestSaveLoadParents(c *check.C) {
assert.Equal(c, inspectOut, "") assert.Equal(c, inspectOut, "")
} }
func (s *DockerSuite) TestSaveLoadNoTag(c *check.C) { func (s *DockerSuite) TestSaveLoadNoTag(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "saveloadnotag" name := "saveloadnotag"

View file

@ -19,7 +19,7 @@ import (
) )
// save a repo and try to load it using stdout // save a repo and try to load it using stdout
func (s *DockerSuite) TestSaveAndLoadRepoStdout(c *check.C) { func (s *DockerSuite) TestSaveAndLoadRepoStdout(c *testing.T) {
name := "test-save-and-load-repo-stdout" name := "test-save-and-load-repo-stdout"
dockerCmd(c, "run", "--name", name, "busybox", "true") dockerCmd(c, "run", "--name", name, "busybox", "true")
@ -70,7 +70,7 @@ func (s *DockerSuite) TestSaveAndLoadRepoStdout(c *check.C) {
assert.Assert(c, strings.Contains(string(buf[:n]), "cowardly refusing"), "help output is not being yielded") assert.Assert(c, strings.Contains(string(buf[:n]), "cowardly refusing"), "help output is not being yielded")
} }
func (s *DockerSuite) TestSaveAndLoadWithProgressBar(c *check.C) { func (s *DockerSuite) TestSaveAndLoadWithProgressBar(c *testing.T) {
name := "test-load" name := "test-load"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox
RUN touch aa RUN touch aa
@ -88,7 +88,7 @@ func (s *DockerSuite) TestSaveAndLoadWithProgressBar(c *check.C) {
} }
// fail because load didn't receive data from stdin // fail because load didn't receive data from stdin
func (s *DockerSuite) TestLoadNoStdinFail(c *check.C) { func (s *DockerSuite) TestLoadNoStdinFail(c *testing.T) {
pty, tty, err := pty.Open() pty, tty, err := pty.Open()
assert.NilError(c, err) assert.NilError(c, err)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)

View file

@ -9,12 +9,12 @@ import (
) )
// search for repos named "registry" on the central registry // search for repos named "registry" on the central registry
func (s *DockerSuite) TestSearchOnCentralRegistry(c *check.C) { func (s *DockerSuite) TestSearchOnCentralRegistry(c *testing.T) {
out, _ := dockerCmd(c, "search", "busybox") out, _ := dockerCmd(c, "search", "busybox")
assert.Assert(c, strings.Contains(out, "Busybox base image."), "couldn't find any repository named (or containing) 'Busybox base image.'") assert.Assert(c, strings.Contains(out, "Busybox base image."), "couldn't find any repository named (or containing) 'Busybox base image.'")
} }
func (s *DockerSuite) TestSearchStarsOptionWithWrongParameter(c *check.C) { func (s *DockerSuite) TestSearchStarsOptionWithWrongParameter(c *testing.T) {
out, _, err := dockerCmdWithError("search", "--filter", "stars=a", "busybox") out, _, err := dockerCmdWithError("search", "--filter", "stars=a", "busybox")
assert.ErrorContains(c, err, "", out) assert.ErrorContains(c, err, "", out)
assert.Assert(c, strings.Contains(out, "Invalid filter"), "couldn't find the invalid filter warning") assert.Assert(c, strings.Contains(out, "Invalid filter"), "couldn't find the invalid filter warning")
@ -32,7 +32,7 @@ func (s *DockerSuite) TestSearchStarsOptionWithWrongParameter(c *check.C) {
assert.Assert(c, strings.Contains(out, "Invalid filter"), "couldn't find the invalid filter warning") assert.Assert(c, strings.Contains(out, "Invalid filter"), "couldn't find the invalid filter warning")
} }
func (s *DockerSuite) TestSearchCmdOptions(c *check.C) { func (s *DockerSuite) TestSearchCmdOptions(c *testing.T) {
outSearchCmd, _ := dockerCmd(c, "search", "busybox") outSearchCmd, _ := dockerCmd(c, "search", "busybox")
assert.Assert(c, strings.Count(outSearchCmd, "\n") > 3, outSearchCmd) assert.Assert(c, strings.Count(outSearchCmd, "\n") > 3, outSearchCmd)
@ -60,12 +60,12 @@ func (s *DockerSuite) TestSearchCmdOptions(c *check.C) {
} }
// search for repos which start with "ubuntu-" on the central registry // search for repos which start with "ubuntu-" on the central registry
func (s *DockerSuite) TestSearchOnCentralRegistryWithDash(c *check.C) { func (s *DockerSuite) TestSearchOnCentralRegistryWithDash(c *testing.T) {
dockerCmd(c, "search", "ubuntu-") dockerCmd(c, "search", "ubuntu-")
} }
// test case for #23055 // test case for #23055
func (s *DockerSuite) TestSearchWithLimit(c *check.C) { func (s *DockerSuite) TestSearchWithLimit(c *testing.T) {
for _, limit := range []int{10, 50, 100} { for _, limit := range []int{10, 50, 100} {
out, _, err := dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker") out, _, err := dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
assert.NilError(c, err) assert.NilError(c, err)

View file

@ -16,20 +16,20 @@ import (
"gotest.tools/assert" "gotest.tools/assert"
) )
func (s *DockerSwarmSuite) TestServiceCreateMountVolume(c *check.C) { func (s *DockerSwarmSuite) TestServiceCreateMountVolume(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
out, err := d.Cmd("service", "create", "--no-resolve-image", "--detach=true", "--mount", "type=volume,source=foo,target=/foo,volume-nocopy", "busybox", "top") out, err := d.Cmd("service", "create", "--no-resolve-image", "--detach=true", "--mount", "type=volume,source=foo,target=/foo,volume-nocopy", "busybox", "top")
assert.NilError(c, err, out) assert.NilError(c, err, out)
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
var tasks []swarm.Task var tasks []swarm.Task
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
tasks = d.GetServiceTasks(c, id) tasks = d.GetServiceTasks(c, id)
return len(tasks) > 0, nil return len(tasks) > 0, nil
}, checker.Equals, true) }, checker.Equals, true)
task := tasks[0] task := tasks[0]
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
if task.NodeID == "" || task.Status.ContainerStatus == nil { if task.NodeID == "" || task.Status.ContainerStatus == nil {
task = d.GetTask(c, task.ID) task = d.GetTask(c, task.ID)
} }
@ -64,7 +64,7 @@ func (s *DockerSwarmSuite) TestServiceCreateMountVolume(c *check.C) {
assert.Assert(c, mounts[0].RW, checker.Equals, true) assert.Assert(c, mounts[0].RW, checker.Equals, true)
} }
func (s *DockerSwarmSuite) TestServiceCreateWithSecretSimple(c *check.C) { func (s *DockerSwarmSuite) TestServiceCreateWithSecretSimple(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
serviceName := "test-service-secret" serviceName := "test-service-secret"
@ -98,7 +98,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretSimple(c *check.C) {
d.DeleteSecret(c, testName) d.DeleteSecret(c, testName)
} }
func (s *DockerSwarmSuite) TestServiceCreateWithSecretSourceTargetPaths(c *check.C) { func (s *DockerSwarmSuite) TestServiceCreateWithSecretSourceTargetPaths(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
testPaths := map[string]string{ testPaths := map[string]string{
@ -137,13 +137,13 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretSourceTargetPaths(c *check
assert.Equal(c, len(refs), len(testPaths)) assert.Equal(c, len(refs), len(testPaths))
var tasks []swarm.Task var tasks []swarm.Task
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
tasks = d.GetServiceTasks(c, serviceName) tasks = d.GetServiceTasks(c, serviceName)
return len(tasks) > 0, nil return len(tasks) > 0, nil
}, checker.Equals, true) }, checker.Equals, true)
task := tasks[0] task := tasks[0]
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
if task.NodeID == "" || task.Status.ContainerStatus == nil { if task.NodeID == "" || task.Status.ContainerStatus == nil {
task = d.GetTask(c, task.ID) task = d.GetTask(c, task.ID)
} }
@ -164,7 +164,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretSourceTargetPaths(c *check
assert.NilError(c, err, out) assert.NilError(c, err, out)
} }
func (s *DockerSwarmSuite) TestServiceCreateWithSecretReferencedTwice(c *check.C) { func (s *DockerSwarmSuite) TestServiceCreateWithSecretReferencedTwice(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
id := d.CreateSecret(c, swarm.SecretSpec{ id := d.CreateSecret(c, swarm.SecretSpec{
@ -187,13 +187,13 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretReferencedTwice(c *check.C
assert.Equal(c, len(refs), 2) assert.Equal(c, len(refs), 2)
var tasks []swarm.Task var tasks []swarm.Task
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
tasks = d.GetServiceTasks(c, serviceName) tasks = d.GetServiceTasks(c, serviceName)
return len(tasks) > 0, nil return len(tasks) > 0, nil
}, checker.Equals, true) }, checker.Equals, true)
task := tasks[0] task := tasks[0]
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
if task.NodeID == "" || task.Status.ContainerStatus == nil { if task.NodeID == "" || task.Status.ContainerStatus == nil {
task = d.GetTask(c, task.ID) task = d.GetTask(c, task.ID)
} }
@ -212,7 +212,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretReferencedTwice(c *check.C
assert.NilError(c, err, out) assert.NilError(c, err, out)
} }
func (s *DockerSwarmSuite) TestServiceCreateWithConfigSimple(c *check.C) { func (s *DockerSwarmSuite) TestServiceCreateWithConfigSimple(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
serviceName := "test-service-config" serviceName := "test-service-config"
@ -246,7 +246,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigSimple(c *check.C) {
d.DeleteConfig(c, testName) d.DeleteConfig(c, testName)
} }
func (s *DockerSwarmSuite) TestServiceCreateWithConfigSourceTargetPaths(c *check.C) { func (s *DockerSwarmSuite) TestServiceCreateWithConfigSourceTargetPaths(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
testPaths := map[string]string{ testPaths := map[string]string{
@ -284,13 +284,13 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigSourceTargetPaths(c *check
assert.Equal(c, len(refs), len(testPaths)) assert.Equal(c, len(refs), len(testPaths))
var tasks []swarm.Task var tasks []swarm.Task
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
tasks = d.GetServiceTasks(c, serviceName) tasks = d.GetServiceTasks(c, serviceName)
return len(tasks) > 0, nil return len(tasks) > 0, nil
}, checker.Equals, true) }, checker.Equals, true)
task := tasks[0] task := tasks[0]
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
if task.NodeID == "" || task.Status.ContainerStatus == nil { if task.NodeID == "" || task.Status.ContainerStatus == nil {
task = d.GetTask(c, task.ID) task = d.GetTask(c, task.ID)
} }
@ -311,7 +311,7 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigSourceTargetPaths(c *check
assert.NilError(c, err, out) assert.NilError(c, err, out)
} }
func (s *DockerSwarmSuite) TestServiceCreateWithConfigReferencedTwice(c *check.C) { func (s *DockerSwarmSuite) TestServiceCreateWithConfigReferencedTwice(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
id := d.CreateConfig(c, swarm.ConfigSpec{ id := d.CreateConfig(c, swarm.ConfigSpec{
@ -334,13 +334,13 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigReferencedTwice(c *check.C
assert.Equal(c, len(refs), 2) assert.Equal(c, len(refs), 2)
var tasks []swarm.Task var tasks []swarm.Task
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
tasks = d.GetServiceTasks(c, serviceName) tasks = d.GetServiceTasks(c, serviceName)
return len(tasks) > 0, nil return len(tasks) > 0, nil
}, checker.Equals, true) }, checker.Equals, true)
task := tasks[0] task := tasks[0]
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
if task.NodeID == "" || task.Status.ContainerStatus == nil { if task.NodeID == "" || task.Status.ContainerStatus == nil {
task = d.GetTask(c, task.ID) task = d.GetTask(c, task.ID)
} }
@ -359,20 +359,20 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigReferencedTwice(c *check.C
assert.NilError(c, err, out) assert.NilError(c, err, out)
} }
func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *check.C) { func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
out, err := d.Cmd("service", "create", "--no-resolve-image", "--detach=true", "--mount", "type=tmpfs,target=/foo,tmpfs-size=1MB", "busybox", "sh", "-c", "mount | grep foo; tail -f /dev/null") out, err := d.Cmd("service", "create", "--no-resolve-image", "--detach=true", "--mount", "type=tmpfs,target=/foo,tmpfs-size=1MB", "busybox", "sh", "-c", "mount | grep foo; tail -f /dev/null")
assert.NilError(c, err, out) assert.NilError(c, err, out)
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
var tasks []swarm.Task var tasks []swarm.Task
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
tasks = d.GetServiceTasks(c, id) tasks = d.GetServiceTasks(c, id)
return len(tasks) > 0, nil return len(tasks) > 0, nil
}, checker.Equals, true) }, checker.Equals, true)
task := tasks[0] task := tasks[0]
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
if task.NodeID == "" || task.Status.ContainerStatus == nil { if task.NodeID == "" || task.Status.ContainerStatus == nil {
task = d.GetTask(c, task.ID) task = d.GetTask(c, task.ID)
} }
@ -412,7 +412,7 @@ func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *check.C) {
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "size=1024k")) assert.Assert(c, strings.Contains(strings.TrimSpace(out), "size=1024k"))
} }
func (s *DockerSwarmSuite) TestServiceCreateWithNetworkAlias(c *check.C) { func (s *DockerSwarmSuite) TestServiceCreateWithNetworkAlias(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
out, err := d.Cmd("network", "create", "--scope=swarm", "test_swarm_br") out, err := d.Cmd("network", "create", "--scope=swarm", "test_swarm_br")
assert.NilError(c, err, out) assert.NilError(c, err, out)
@ -422,13 +422,13 @@ func (s *DockerSwarmSuite) TestServiceCreateWithNetworkAlias(c *check.C) {
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
var tasks []swarm.Task var tasks []swarm.Task
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
tasks = d.GetServiceTasks(c, id) tasks = d.GetServiceTasks(c, id)
return len(tasks) > 0, nil return len(tasks) > 0, nil
}, checker.Equals, true) }, checker.Equals, true)
task := tasks[0] task := tasks[0]
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
if task.NodeID == "" || task.Status.ContainerStatus == nil { if task.NodeID == "" || task.Status.ContainerStatus == nil {
task = d.GetTask(c, task.ID) task = d.GetTask(c, task.ID)
} }

View file

@ -18,7 +18,7 @@ import (
// start a service, and then make its task unhealthy during running // start a service, and then make its task unhealthy during running
// finally, unhealthy task should be detected and killed // finally, unhealthy task should be detected and killed
func (s *DockerSwarmSuite) TestServiceHealthRun(c *check.C) { func (s *DockerSwarmSuite) TestServiceHealthRun(c *testing.T) {
testRequires(c, DaemonIsLinux) // busybox doesn't work on Windows testRequires(c, DaemonIsLinux) // busybox doesn't work on Windows
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
@ -39,7 +39,7 @@ func (s *DockerSwarmSuite) TestServiceHealthRun(c *check.C) {
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
var tasks []swarm.Task var tasks []swarm.Task
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
tasks = d.GetServiceTasks(c, id) tasks = d.GetServiceTasks(c, id)
return tasks, nil return tasks, nil
}, checker.HasLen, 1) }, checker.HasLen, 1)
@ -47,14 +47,14 @@ func (s *DockerSwarmSuite) TestServiceHealthRun(c *check.C) {
task := tasks[0] task := tasks[0]
// wait for task to start // wait for task to start
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
task = d.GetTask(c, task.ID) task = d.GetTask(c, task.ID)
return task.Status.State, nil return task.Status.State, nil
}, checker.Equals, swarm.TaskStateRunning) }, checker.Equals, swarm.TaskStateRunning)
containerID := task.Status.ContainerStatus.ContainerID containerID := task.Status.ContainerStatus.ContainerID
// wait for container to be healthy // wait for container to be healthy
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
out, _ := d.Cmd("inspect", "--format={{.State.Health.Status}}", containerID) out, _ := d.Cmd("inspect", "--format={{.State.Health.Status}}", containerID)
return strings.TrimSpace(out), nil return strings.TrimSpace(out), nil
}, checker.Equals, "healthy") }, checker.Equals, "healthy")
@ -62,13 +62,13 @@ func (s *DockerSwarmSuite) TestServiceHealthRun(c *check.C) {
// make it fail // make it fail
d.Cmd("exec", containerID, "rm", "/status") d.Cmd("exec", containerID, "rm", "/status")
// wait for container to be unhealthy // wait for container to be unhealthy
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
out, _ := d.Cmd("inspect", "--format={{.State.Health.Status}}", containerID) out, _ := d.Cmd("inspect", "--format={{.State.Health.Status}}", containerID)
return strings.TrimSpace(out), nil return strings.TrimSpace(out), nil
}, checker.Equals, "unhealthy") }, checker.Equals, "unhealthy")
// Task should be terminated // Task should be terminated
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
task = d.GetTask(c, task.ID) task = d.GetTask(c, task.ID)
return task.Status.State, nil return task.Status.State, nil
}, checker.Equals, swarm.TaskStateFailed) }, checker.Equals, swarm.TaskStateFailed)
@ -80,7 +80,7 @@ func (s *DockerSwarmSuite) TestServiceHealthRun(c *check.C) {
// start a service whose task is unhealthy at beginning // start a service whose task is unhealthy at beginning
// its tasks should be blocked in starting stage, until health check is passed // its tasks should be blocked in starting stage, until health check is passed
func (s *DockerSwarmSuite) TestServiceHealthStart(c *check.C) { func (s *DockerSwarmSuite) TestServiceHealthStart(c *testing.T) {
testRequires(c, DaemonIsLinux) // busybox doesn't work on Windows testRequires(c, DaemonIsLinux) // busybox doesn't work on Windows
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
@ -100,7 +100,7 @@ func (s *DockerSwarmSuite) TestServiceHealthStart(c *check.C) {
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
var tasks []swarm.Task var tasks []swarm.Task
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
tasks = d.GetServiceTasks(c, id) tasks = d.GetServiceTasks(c, id)
return tasks, nil return tasks, nil
}, checker.HasLen, 1) }, checker.HasLen, 1)
@ -108,7 +108,7 @@ func (s *DockerSwarmSuite) TestServiceHealthStart(c *check.C) {
task := tasks[0] task := tasks[0]
// wait for task to start // wait for task to start
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
task = d.GetTask(c, task.ID) task = d.GetTask(c, task.ID)
return task.Status.State, nil return task.Status.State, nil
}, checker.Equals, swarm.TaskStateStarting) }, checker.Equals, swarm.TaskStateStarting)
@ -116,7 +116,7 @@ func (s *DockerSwarmSuite) TestServiceHealthStart(c *check.C) {
containerID := task.Status.ContainerStatus.ContainerID containerID := task.Status.ContainerStatus.ContainerID
// wait for health check to work // wait for health check to work
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
out, _ := d.Cmd("inspect", "--format={{.State.Health.FailingStreak}}", containerID) out, _ := d.Cmd("inspect", "--format={{.State.Health.FailingStreak}}", containerID)
failingStreak, _ := strconv.Atoi(strings.TrimSpace(out)) failingStreak, _ := strconv.Atoi(strings.TrimSpace(out))
return failingStreak, nil return failingStreak, nil
@ -130,7 +130,7 @@ func (s *DockerSwarmSuite) TestServiceHealthStart(c *check.C) {
d.Cmd("exec", containerID, "touch", "/status") d.Cmd("exec", containerID, "touch", "/status")
// Task should be at running status // Task should be at running status
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
task = d.GetTask(c, task.ID) task = d.GetTask(c, task.ID)
return task.Status.State, nil return task.Status.State, nil
}, checker.Equals, swarm.TaskStateRunning) }, checker.Equals, swarm.TaskStateRunning)

View file

@ -22,7 +22,7 @@ type logMessage struct {
data []byte data []byte
} }
func (s *DockerSwarmSuite) TestServiceLogs(c *check.C) { func (s *DockerSwarmSuite) TestServiceLogs(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
// we have multiple services here for detecting the goroutine issue #28915 // we have multiple services here for detecting the goroutine issue #28915
@ -54,8 +54,8 @@ func (s *DockerSwarmSuite) TestServiceLogs(c *check.C) {
// countLogLines returns a closure that can be used with waitAndAssert to // countLogLines returns a closure that can be used with waitAndAssert to
// verify that a minimum number of expected container log messages have been // verify that a minimum number of expected container log messages have been
// output. // output.
func countLogLines(d *daemon.Daemon, name string) func(*check.C) (interface{}, check.CommentInterface) { func countLogLines(d *daemon.Daemon, name string) func(*testing.T) (interface{}, check.CommentInterface) {
return func(c *check.C) (interface{}, check.CommentInterface) { return func(c *testing.T) (interface{}, check.CommentInterface) {
result := icmd.RunCmd(d.Command("service", "logs", "-t", "--raw", name)) result := icmd.RunCmd(d.Command("service", "logs", "-t", "--raw", name))
result.Assert(c, icmd.Expected{}) result.Assert(c, icmd.Expected{})
// if this returns an emptystring, trying to split it later will return // if this returns an emptystring, trying to split it later will return
@ -69,7 +69,7 @@ func countLogLines(d *daemon.Daemon, name string) func(*check.C) (interface{}, c
} }
} }
func (s *DockerSwarmSuite) TestServiceLogsCompleteness(c *check.C) { func (s *DockerSwarmSuite) TestServiceLogsCompleteness(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
name := "TestServiceLogsCompleteness" name := "TestServiceLogsCompleteness"
@ -96,7 +96,7 @@ func (s *DockerSwarmSuite) TestServiceLogsCompleteness(c *check.C) {
} }
} }
func (s *DockerSwarmSuite) TestServiceLogsTail(c *check.C) { func (s *DockerSwarmSuite) TestServiceLogsTail(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
name := "TestServiceLogsTail" name := "TestServiceLogsTail"
@ -120,7 +120,7 @@ func (s *DockerSwarmSuite) TestServiceLogsTail(c *check.C) {
} }
} }
func (s *DockerSwarmSuite) TestServiceLogsSince(c *check.C) { func (s *DockerSwarmSuite) TestServiceLogsSince(c *testing.T) {
// See DockerSuite.TestLogsSince, which is where this comes from // See DockerSuite.TestLogsSince, which is where this comes from
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
@ -155,7 +155,7 @@ func (s *DockerSwarmSuite) TestServiceLogsSince(c *check.C) {
} }
} }
func (s *DockerSwarmSuite) TestServiceLogsFollow(c *check.C) { func (s *DockerSwarmSuite) TestServiceLogsFollow(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
name := "TestServiceLogsFollow" name := "TestServiceLogsFollow"
@ -201,7 +201,7 @@ func (s *DockerSwarmSuite) TestServiceLogsFollow(c *check.C) {
assert.NilError(c, cmd.Process.Kill()) assert.NilError(c, cmd.Process.Kill())
} }
func (s *DockerSwarmSuite) TestServiceLogsTaskLogs(c *check.C) { func (s *DockerSwarmSuite) TestServiceLogsTaskLogs(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
name := "TestServicelogsTaskLogs" name := "TestServicelogsTaskLogs"
@ -254,7 +254,7 @@ func (s *DockerSwarmSuite) TestServiceLogsTaskLogs(c *check.C) {
} }
} }
func (s *DockerSwarmSuite) TestServiceLogsTTY(c *check.C) { func (s *DockerSwarmSuite) TestServiceLogsTTY(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
name := "TestServiceLogsTTY" name := "TestServiceLogsTTY"
@ -292,7 +292,7 @@ func (s *DockerSwarmSuite) TestServiceLogsTTY(c *check.C) {
result.Assert(c, icmd.Expected{Out: "out\r\nerr\r\n"}) result.Assert(c, icmd.Expected{Out: "out\r\nerr\r\n"})
} }
func (s *DockerSwarmSuite) TestServiceLogsNoHangDeletedContainer(c *check.C) { func (s *DockerSwarmSuite) TestServiceLogsNoHangDeletedContainer(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
name := "TestServiceLogsNoHangDeletedContainer" name := "TestServiceLogsNoHangDeletedContainer"
@ -341,7 +341,7 @@ func (s *DockerSwarmSuite) TestServiceLogsNoHangDeletedContainer(c *check.C) {
result.Assert(c, icmd.Expected{}) result.Assert(c, icmd.Expected{})
} }
func (s *DockerSwarmSuite) TestServiceLogsDetails(c *check.C) { func (s *DockerSwarmSuite) TestServiceLogsDetails(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
name := "TestServiceLogsDetails" name := "TestServiceLogsDetails"

View file

@ -10,7 +10,7 @@ import (
"gotest.tools/assert" "gotest.tools/assert"
) )
func (s *DockerSwarmSuite) TestServiceScale(c *check.C) { func (s *DockerSwarmSuite) TestServiceScale(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
service1Name := "TestService1" service1Name := "TestService1"

View file

@ -14,7 +14,7 @@ import (
"gotest.tools/assert" "gotest.tools/assert"
) )
func (s *DockerSuite) TestClientSetsTLSServerName(c *check.C) { func (s *DockerSuite) TestClientSetsTLSServerName(c *testing.T) {
c.Skip("Flakey test") c.Skip("Flakey test")
// there may be more than one hit to the server for each registry request // there may be more than one hit to the server for each registry request
var serverNameReceived []string var serverNameReceived []string

View file

@ -13,7 +13,7 @@ import (
) )
// Regression test for https://github.com/docker/docker/issues/7843 // Regression test for https://github.com/docker/docker/issues/7843
func (s *DockerSuite) TestStartAttachReturnsOnError(c *check.C) { func (s *DockerSuite) TestStartAttachReturnsOnError(c *testing.T) {
// Windows does not support link // Windows does not support link
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "--name", "test", "busybox") dockerCmd(c, "run", "--name", "test", "busybox")
@ -42,7 +42,7 @@ func (s *DockerSuite) TestStartAttachReturnsOnError(c *check.C) {
} }
// gh#8555: Exit code should be passed through when using start -a // gh#8555: Exit code should be passed through when using start -a
func (s *DockerSuite) TestStartAttachCorrectExitCode(c *check.C) { func (s *DockerSuite) TestStartAttachCorrectExitCode(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out := cli.DockerCmd(c, "run", "-d", "busybox", "sh", "-c", "sleep 2; exit 1").Stdout() out := cli.DockerCmd(c, "run", "-d", "busybox", "sh", "-c", "sleep 2; exit 1").Stdout()
out = strings.TrimSpace(out) out = strings.TrimSpace(out)
@ -55,7 +55,7 @@ func (s *DockerSuite) TestStartAttachCorrectExitCode(c *check.C) {
}) })
} }
func (s *DockerSuite) TestStartAttachSilent(c *check.C) { func (s *DockerSuite) TestStartAttachSilent(c *testing.T) {
name := "teststartattachcorrectexitcode" name := "teststartattachcorrectexitcode"
dockerCmd(c, "run", "--name", name, "busybox", "echo", "test") dockerCmd(c, "run", "--name", name, "busybox", "echo", "test")
@ -67,7 +67,7 @@ func (s *DockerSuite) TestStartAttachSilent(c *check.C) {
assert.Assert(c, startOut, checker.Equals, "test\n") assert.Assert(c, startOut, checker.Equals, "test\n")
} }
func (s *DockerSuite) TestStartRecordError(c *check.C) { func (s *DockerSuite) TestStartRecordError(c *testing.T) {
// TODO Windows CI: Requires further porting work. Should be possible. // TODO Windows CI: Requires further porting work. Should be possible.
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
// when container runs successfully, we should not have state.Error // when container runs successfully, we should not have state.Error
@ -92,7 +92,7 @@ func (s *DockerSuite) TestStartRecordError(c *check.C) {
assert.Assert(c, stateErr, checker.Equals, "") assert.Assert(c, stateErr, checker.Equals, "")
} }
func (s *DockerSuite) TestStartPausedContainer(c *check.C) { func (s *DockerSuite) TestStartPausedContainer(c *testing.T) {
// Windows does not support pausing containers // Windows does not support pausing containers
testRequires(c, IsPausable) testRequires(c, IsPausable)
@ -107,7 +107,7 @@ func (s *DockerSuite) TestStartPausedContainer(c *check.C) {
assert.Assert(c, strings.ToLower(out), checker.Contains, "cannot start a paused container, try unpause instead") assert.Assert(c, strings.ToLower(out), checker.Contains, "cannot start a paused container, try unpause instead")
} }
func (s *DockerSuite) TestStartMultipleContainers(c *check.C) { func (s *DockerSuite) TestStartMultipleContainers(c *testing.T) {
// Windows does not support --link // Windows does not support --link
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
// run a container named 'parent' and create two container link to `parent` // run a container named 'parent' and create two container link to `parent`
@ -143,7 +143,7 @@ func (s *DockerSuite) TestStartMultipleContainers(c *check.C) {
} }
} }
func (s *DockerSuite) TestStartAttachMultipleContainers(c *check.C) { func (s *DockerSuite) TestStartAttachMultipleContainers(c *testing.T) {
// run multiple containers to test // run multiple containers to test
for _, container := range []string{"test1", "test2", "test3"} { for _, container := range []string{"test1", "test2", "test3"} {
runSleepingContainer(c, "--name", container) runSleepingContainer(c, "--name", container)
@ -172,7 +172,7 @@ func (s *DockerSuite) TestStartAttachMultipleContainers(c *check.C) {
} }
// Test case for #23716 // Test case for #23716
func (s *DockerSuite) TestStartAttachWithRename(c *check.C) { func (s *DockerSuite) TestStartAttachWithRename(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
cli.DockerCmd(c, "create", "-t", "--name", "before", "busybox") cli.DockerCmd(c, "create", "-t", "--name", "before", "busybox")
go func() { go func() {
@ -187,7 +187,7 @@ func (s *DockerSuite) TestStartAttachWithRename(c *check.C) {
assert.Assert(c, result.Stderr(), checker.Not(checker.Contains), "No such container") assert.Assert(c, result.Stderr(), checker.Not(checker.Contains), "No such container")
} }
func (s *DockerSuite) TestStartReturnCorrectExitCode(c *check.C) { func (s *DockerSuite) TestStartReturnCorrectExitCode(c *testing.T) {
dockerCmd(c, "create", "--restart=on-failure:2", "--name", "withRestart", "busybox", "sh", "-c", "exit 11") dockerCmd(c, "create", "--restart=on-failure:2", "--name", "withRestart", "busybox", "sh", "-c", "exit 11")
dockerCmd(c, "create", "--rm", "--name", "withRm", "busybox", "sh", "-c", "exit 12") dockerCmd(c, "create", "--rm", "--name", "withRm", "busybox", "sh", "-c", "exit 12")

View file

@ -13,7 +13,7 @@ import (
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
) )
func (s *DockerSuite) TestStatsNoStream(c *check.C) { func (s *DockerSuite) TestStatsNoStream(c *testing.T) {
// Windows does not support stats // Windows does not support stats
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "top") out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
@ -42,7 +42,7 @@ func (s *DockerSuite) TestStatsNoStream(c *check.C) {
} }
} }
func (s *DockerSuite) TestStatsContainerNotFound(c *check.C) { func (s *DockerSuite) TestStatsContainerNotFound(c *testing.T) {
// Windows does not support stats // Windows does not support stats
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -55,7 +55,7 @@ func (s *DockerSuite) TestStatsContainerNotFound(c *check.C) {
assert.Assert(c, is.Contains(out, "No such container: notfound"), "Expected to fail on not found container stats with --no-stream, got %q instead", out) assert.Assert(c, is.Contains(out, "No such container: notfound"), "Expected to fail on not found container stats with --no-stream, got %q instead", out)
} }
func (s *DockerSuite) TestStatsAllRunningNoStream(c *check.C) { func (s *DockerSuite) TestStatsAllRunningNoStream(c *testing.T) {
// Windows does not support stats // Windows does not support stats
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -91,7 +91,7 @@ func (s *DockerSuite) TestStatsAllRunningNoStream(c *check.C) {
assert.Assert(c, realData != nil, "stat result are empty: %s", out) assert.Assert(c, realData != nil, "stat result are empty: %s", out)
} }
func (s *DockerSuite) TestStatsAllNoStream(c *check.C) { func (s *DockerSuite) TestStatsAllNoStream(c *testing.T) {
// Windows does not support stats // Windows does not support stats
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -121,7 +121,7 @@ func (s *DockerSuite) TestStatsAllNoStream(c *check.C) {
assert.Assert(c, realData == nil, "stat result of %s should be empty : %s", id1, out) assert.Assert(c, realData == nil, "stat result of %s should be empty : %s", id1, out)
} }
func (s *DockerSuite) TestStatsAllNewContainersAdded(c *check.C) { func (s *DockerSuite) TestStatsAllNewContainersAdded(c *testing.T) {
// Windows does not support stats // Windows does not support stats
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -162,7 +162,7 @@ func (s *DockerSuite) TestStatsAllNewContainersAdded(c *check.C) {
} }
} }
func (s *DockerSuite) TestStatsFormatAll(c *check.C) { func (s *DockerSuite) TestStatsFormatAll(c *testing.T) {
// Windows does not support stats // Windows does not support stats
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)

View file

@ -34,7 +34,7 @@ import (
"gotest.tools/icmd" "gotest.tools/icmd"
) )
func (s *DockerSwarmSuite) TestSwarmUpdate(c *check.C) { func (s *DockerSwarmSuite) TestSwarmUpdate(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
getSpec := func() swarm.Spec { getSpec := func() swarm.Spec {
@ -82,7 +82,7 @@ func (s *DockerSwarmSuite) TestSwarmUpdate(c *check.C) {
}) })
} }
func (s *DockerSwarmSuite) TestSwarmInit(c *check.C) { func (s *DockerSwarmSuite) TestSwarmInit(c *testing.T) {
d := s.AddDaemon(c, false, false) d := s.AddDaemon(c, false, false)
getSpec := func() swarm.Spec { getSpec := func() swarm.Spec {
@ -125,7 +125,7 @@ func (s *DockerSwarmSuite) TestSwarmInit(c *check.C) {
assert.Assert(c, spec.Dispatcher.HeartbeatPeriod, checker.Equals, 5*time.Second) assert.Assert(c, spec.Dispatcher.HeartbeatPeriod, checker.Equals, 5*time.Second)
} }
func (s *DockerSwarmSuite) TestSwarmInitIPv6(c *check.C) { func (s *DockerSwarmSuite) TestSwarmInitIPv6(c *testing.T) {
testRequires(c, IPv6) testRequires(c, IPv6)
d1 := s.AddDaemon(c, false, false) d1 := s.AddDaemon(c, false, false)
cli.Docker(cli.Args("swarm", "init", "--listen-add", "::1"), cli.Daemon(d1)).Assert(c, icmd.Success) cli.Docker(cli.Args("swarm", "init", "--listen-add", "::1"), cli.Daemon(d1)).Assert(c, icmd.Success)
@ -137,14 +137,14 @@ func (s *DockerSwarmSuite) TestSwarmInitIPv6(c *check.C) {
assert.Assert(c, out, checker.Contains, "Swarm: active") assert.Assert(c, out, checker.Contains, "Swarm: active")
} }
func (s *DockerSwarmSuite) TestSwarmInitUnspecifiedAdvertiseAddr(c *check.C) { func (s *DockerSwarmSuite) TestSwarmInitUnspecifiedAdvertiseAddr(c *testing.T) {
d := s.AddDaemon(c, false, false) d := s.AddDaemon(c, false, false)
out, err := d.Cmd("swarm", "init", "--advertise-addr", "0.0.0.0") out, err := d.Cmd("swarm", "init", "--advertise-addr", "0.0.0.0")
assert.ErrorContains(c, err, "") assert.ErrorContains(c, err, "")
assert.Assert(c, out, checker.Contains, "advertise address must be a non-zero IP address") assert.Assert(c, out, checker.Contains, "advertise address must be a non-zero IP address")
} }
func (s *DockerSwarmSuite) TestSwarmIncompatibleDaemon(c *check.C) { func (s *DockerSwarmSuite) TestSwarmIncompatibleDaemon(c *testing.T) {
// init swarm mode and stop a daemon // init swarm mode and stop a daemon
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
info := d.SwarmInfo(c) info := d.SwarmInfo(c)
@ -168,7 +168,7 @@ func (s *DockerSwarmSuite) TestSwarmIncompatibleDaemon(c *check.C) {
d.StartNode(c) d.StartNode(c)
} }
func (s *DockerSwarmSuite) TestSwarmServiceTemplatingHostname(c *check.C) { func (s *DockerSwarmSuite) TestSwarmServiceTemplatingHostname(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
hostname, err := d.Cmd("node", "inspect", "--format", "{{.Description.Hostname}}", "self") hostname, err := d.Cmd("node", "inspect", "--format", "{{.Description.Hostname}}", "self")
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", hostname)) assert.Assert(c, err, checker.IsNil, check.Commentf("%s", hostname))
@ -186,7 +186,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceTemplatingHostname(c *check.C) {
} }
// Test case for #24270 // Test case for #24270
func (s *DockerSwarmSuite) TestSwarmServiceListFilter(c *check.C) { func (s *DockerSwarmSuite) TestSwarmServiceListFilter(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
name1 := "redis-cluster-md5" name1 := "redis-cluster-md5"
@ -227,7 +227,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceListFilter(c *check.C) {
assert.Assert(c, out, checker.Contains, name3+" ") assert.Assert(c, out, checker.Contains, name3+" ")
} }
func (s *DockerSwarmSuite) TestSwarmNodeListFilter(c *check.C) { func (s *DockerSwarmSuite) TestSwarmNodeListFilter(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
out, err := d.Cmd("node", "inspect", "--format", "{{ .Description.Hostname }}", "self") out, err := d.Cmd("node", "inspect", "--format", "{{ .Description.Hostname }}", "self")
@ -246,7 +246,7 @@ func (s *DockerSwarmSuite) TestSwarmNodeListFilter(c *check.C) {
assert.Assert(c, out, checker.Not(checker.Contains), name) assert.Assert(c, out, checker.Not(checker.Contains), name)
} }
func (s *DockerSwarmSuite) TestSwarmNodeTaskListFilter(c *check.C) { func (s *DockerSwarmSuite) TestSwarmNodeTaskListFilter(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
name := "redis-cluster-md5" name := "redis-cluster-md5"
@ -273,7 +273,7 @@ func (s *DockerSwarmSuite) TestSwarmNodeTaskListFilter(c *check.C) {
} }
// Test case for #25375 // Test case for #25375
func (s *DockerSwarmSuite) TestSwarmPublishAdd(c *check.C) { func (s *DockerSwarmSuite) TestSwarmPublishAdd(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
name := "top" name := "top"
@ -299,7 +299,7 @@ func (s *DockerSwarmSuite) TestSwarmPublishAdd(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "[{ tcp 80 80 ingress}]") assert.Equal(c, strings.TrimSpace(out), "[{ tcp 80 80 ingress}]")
} }
func (s *DockerSwarmSuite) TestSwarmServiceWithGroup(c *check.C) { func (s *DockerSwarmSuite) TestSwarmServiceWithGroup(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
name := "top" name := "top"
@ -321,7 +321,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceWithGroup(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "uid=0(root) gid=0(root) groups=10(wheel),29(audio),50(staff),777") assert.Equal(c, strings.TrimSpace(out), "uid=0(root) gid=0(root) groups=10(wheel),29(audio),50(staff),777")
} }
func (s *DockerSwarmSuite) TestSwarmContainerAutoStart(c *check.C) { func (s *DockerSwarmSuite) TestSwarmContainerAutoStart(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
out, err := d.Cmd("network", "create", "--attachable", "-d", "overlay", "foo") out, err := d.Cmd("network", "create", "--attachable", "-d", "overlay", "foo")
@ -343,7 +343,7 @@ func (s *DockerSwarmSuite) TestSwarmContainerAutoStart(c *check.C) {
assert.Assert(c, strings.TrimSpace(out) != "") assert.Assert(c, strings.TrimSpace(out) != "")
} }
func (s *DockerSwarmSuite) TestSwarmContainerEndpointOptions(c *check.C) { func (s *DockerSwarmSuite) TestSwarmContainerEndpointOptions(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
out, err := d.Cmd("network", "create", "--attachable", "-d", "overlay", "foo") out, err := d.Cmd("network", "create", "--attachable", "-d", "overlay", "foo")
@ -368,7 +368,7 @@ func (s *DockerSwarmSuite) TestSwarmContainerEndpointOptions(c *check.C) {
assert.NilError(c, err, out) assert.NilError(c, err, out)
} }
func (s *DockerSwarmSuite) TestSwarmContainerAttachByNetworkId(c *check.C) { func (s *DockerSwarmSuite) TestSwarmContainerAttachByNetworkId(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
out, err := d.Cmd("network", "create", "--attachable", "-d", "overlay", "testnet") out, err := d.Cmd("network", "create", "--attachable", "-d", "overlay", "testnet")
@ -387,7 +387,7 @@ func (s *DockerSwarmSuite) TestSwarmContainerAttachByNetworkId(c *check.C) {
out, err = d.Cmd("network", "rm", "testnet") out, err = d.Cmd("network", "rm", "testnet")
assert.NilError(c, err, out) assert.NilError(c, err, out)
checkNetwork := func(*check.C) (interface{}, check.CommentInterface) { checkNetwork := func(*testing.T) (interface{}, check.CommentInterface) {
out, err := d.Cmd("network", "ls") out, err := d.Cmd("network", "ls")
assert.NilError(c, err) assert.NilError(c, err)
return out, nil return out, nil
@ -396,7 +396,7 @@ func (s *DockerSwarmSuite) TestSwarmContainerAttachByNetworkId(c *check.C) {
waitAndAssert(c, 3*time.Second, checkNetwork, checker.Not(checker.Contains), "testnet") waitAndAssert(c, 3*time.Second, checkNetwork, checker.Not(checker.Contains), "testnet")
} }
func (s *DockerSwarmSuite) TestOverlayAttachable(c *check.C) { func (s *DockerSwarmSuite) TestOverlayAttachable(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
out, err := d.Cmd("network", "create", "-d", "overlay", "--attachable", "ovnet") out, err := d.Cmd("network", "create", "-d", "overlay", "--attachable", "ovnet")
@ -418,7 +418,7 @@ func (s *DockerSwarmSuite) TestOverlayAttachable(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "true") assert.Equal(c, strings.TrimSpace(out), "true")
} }
func (s *DockerSwarmSuite) TestOverlayAttachableOnSwarmLeave(c *check.C) { func (s *DockerSwarmSuite) TestOverlayAttachableOnSwarmLeave(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
// Create an attachable swarm network // Create an attachable swarm network
@ -444,7 +444,7 @@ func (s *DockerSwarmSuite) TestOverlayAttachableOnSwarmLeave(c *check.C) {
assert.Assert(c, out, checker.Not(checker.Contains), nwName) assert.Assert(c, out, checker.Not(checker.Contains), nwName)
} }
func (s *DockerSwarmSuite) TestOverlayAttachableReleaseResourcesOnFailure(c *check.C) { func (s *DockerSwarmSuite) TestOverlayAttachableReleaseResourcesOnFailure(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
// Create attachable network // Create attachable network
@ -468,7 +468,7 @@ func (s *DockerSwarmSuite) TestOverlayAttachableReleaseResourcesOnFailure(c *che
assert.NilError(c, err, out) assert.NilError(c, err, out)
} }
func (s *DockerSwarmSuite) TestSwarmIngressNetwork(c *check.C) { func (s *DockerSwarmSuite) TestSwarmIngressNetwork(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
// Ingress network can be removed // Ingress network can be removed
@ -522,7 +522,7 @@ func (s *DockerSwarmSuite) TestSwarmIngressNetwork(c *check.C) {
assert.NilError(c, err, out) assert.NilError(c, err, out)
} }
func (s *DockerSwarmSuite) TestSwarmCreateServiceWithNoIngressNetwork(c *check.C) { func (s *DockerSwarmSuite) TestSwarmCreateServiceWithNoIngressNetwork(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
// Remove ingress network // Remove ingress network
@ -541,7 +541,7 @@ func (s *DockerSwarmSuite) TestSwarmCreateServiceWithNoIngressNetwork(c *check.C
// Test case for #24108, also the case from: // Test case for #24108, also the case from:
// https://github.com/docker/docker/pull/24620#issuecomment-233715656 // https://github.com/docker/docker/pull/24620#issuecomment-233715656
func (s *DockerSwarmSuite) TestSwarmTaskListFilter(c *check.C) { func (s *DockerSwarmSuite) TestSwarmTaskListFilter(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
name := "redis-cluster-md5" name := "redis-cluster-md5"
@ -551,7 +551,7 @@ func (s *DockerSwarmSuite) TestSwarmTaskListFilter(c *check.C) {
filter := "name=redis-cluster" filter := "name=redis-cluster"
checkNumTasks := func(*check.C) (interface{}, check.CommentInterface) { checkNumTasks := func(*testing.T) (interface{}, check.CommentInterface) {
out, err := d.Cmd("service", "ps", "--filter", filter, name) out, err := d.Cmd("service", "ps", "--filter", filter, name)
assert.NilError(c, err, out) assert.NilError(c, err, out)
return len(strings.Split(out, "\n")) - 2, nil // includes header and nl in last line return len(strings.Split(out, "\n")) - 2, nil // includes header and nl in last line
@ -599,7 +599,7 @@ func (s *DockerSwarmSuite) TestSwarmTaskListFilter(c *check.C) {
assert.Assert(c, out, checker.Not(checker.Contains), name) assert.Assert(c, out, checker.Not(checker.Contains), name)
} }
func (s *DockerSwarmSuite) TestPsListContainersFilterIsTask(c *check.C) { func (s *DockerSwarmSuite) TestPsListContainersFilterIsTask(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
// Create a bare container // Create a bare container
@ -632,7 +632,7 @@ func (s *DockerSwarmSuite) TestPsListContainersFilterIsTask(c *check.C) {
const globalNetworkPlugin = "global-network-plugin" const globalNetworkPlugin = "global-network-plugin"
const globalIPAMPlugin = "global-ipam-plugin" const globalIPAMPlugin = "global-ipam-plugin"
func setupRemoteGlobalNetworkPlugin(c *check.C, mux *http.ServeMux, url, netDrv, ipamDrv string) { func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDrv, ipamDrv string) {
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json") w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
@ -800,7 +800,7 @@ func setupRemoteGlobalNetworkPlugin(c *check.C, mux *http.ServeMux, url, netDrv,
assert.NilError(c, err) assert.NilError(c, err)
} }
func (s *DockerSwarmSuite) TestSwarmNetworkPlugin(c *check.C) { func (s *DockerSwarmSuite) TestSwarmNetworkPlugin(c *testing.T) {
mux := http.NewServeMux() mux := http.NewServeMux()
s.server = httptest.NewServer(mux) s.server = httptest.NewServer(mux)
assert.Assert(c, s.server, check.NotNil) // check that HTTP server has started assert.Assert(c, s.server, check.NotNil) // check that HTTP server has started
@ -819,7 +819,7 @@ func (s *DockerSwarmSuite) TestSwarmNetworkPlugin(c *check.C) {
} }
// Test case for #24712 // Test case for #24712
func (s *DockerSwarmSuite) TestSwarmServiceEnvFile(c *check.C) { func (s *DockerSwarmSuite) TestSwarmServiceEnvFile(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
path := filepath.Join(d.Folder, "env.txt") path := filepath.Join(d.Folder, "env.txt")
@ -837,7 +837,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceEnvFile(c *check.C) {
assert.Assert(c, out, checker.Contains, "[VAR1=C VAR2]") assert.Assert(c, out, checker.Contains, "[VAR1=C VAR2]")
} }
func (s *DockerSwarmSuite) TestSwarmServiceTTY(c *check.C) { func (s *DockerSwarmSuite) TestSwarmServiceTTY(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
name := "top" name := "top"
@ -885,7 +885,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceTTY(c *check.C) {
assert.Assert(c, out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out)) assert.Assert(c, out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
} }
func (s *DockerSwarmSuite) TestSwarmServiceTTYUpdate(c *check.C) { func (s *DockerSwarmSuite) TestSwarmServiceTTYUpdate(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
// Create a service // Create a service
@ -908,7 +908,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceTTYUpdate(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "true") assert.Equal(c, strings.TrimSpace(out), "true")
} }
func (s *DockerSwarmSuite) TestSwarmServiceNetworkUpdate(c *check.C) { func (s *DockerSwarmSuite) TestSwarmServiceNetworkUpdate(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
result := icmd.RunCmd(d.Command("network", "create", "-d", "overlay", "foo")) result := icmd.RunCmd(d.Command("network", "create", "-d", "overlay", "foo"))
@ -947,7 +947,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceNetworkUpdate(c *check.C) {
map[string]int{barNetwork: 1, bazNetwork: 1}) map[string]int{barNetwork: 1, bazNetwork: 1})
} }
func (s *DockerSwarmSuite) TestDNSConfig(c *check.C) { func (s *DockerSwarmSuite) TestDNSConfig(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
// Create a service // Create a service
@ -974,7 +974,7 @@ func (s *DockerSwarmSuite) TestDNSConfig(c *check.C) {
assert.Assert(c, out, checker.Contains, expectedOutput3, check.Commentf("Expected '%s', but got %q", expectedOutput3, out)) assert.Assert(c, out, checker.Contains, expectedOutput3, check.Commentf("Expected '%s', but got %q", expectedOutput3, out))
} }
func (s *DockerSwarmSuite) TestDNSConfigUpdate(c *check.C) { func (s *DockerSwarmSuite) TestDNSConfigUpdate(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
// Create a service // Create a service
@ -993,13 +993,13 @@ func (s *DockerSwarmSuite) TestDNSConfigUpdate(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "{[1.2.3.4] [example.com] [timeout:3]}") assert.Equal(c, strings.TrimSpace(out), "{[1.2.3.4] [example.com] [timeout:3]}")
} }
func getNodeStatus(c *check.C, d *daemon.Daemon) swarm.LocalNodeState { func getNodeStatus(c *testing.T, d *daemon.Daemon) swarm.LocalNodeState {
info := d.SwarmInfo(c) info := d.SwarmInfo(c)
return info.LocalNodeState return info.LocalNodeState
} }
func checkKeyIsEncrypted(d *daemon.Daemon) func(*check.C) (interface{}, check.CommentInterface) { func checkKeyIsEncrypted(d *daemon.Daemon) func(*testing.T) (interface{}, check.CommentInterface) {
return func(c *check.C) (interface{}, check.CommentInterface) { return func(c *testing.T) (interface{}, check.CommentInterface) {
keyBytes, err := ioutil.ReadFile(filepath.Join(d.Folder, "root", "swarm", "certificates", "swarm-node.key")) keyBytes, err := ioutil.ReadFile(filepath.Join(d.Folder, "root", "swarm", "certificates", "swarm-node.key"))
if err != nil { if err != nil {
return fmt.Errorf("error reading key: %v", err), nil return fmt.Errorf("error reading key: %v", err), nil
@ -1014,7 +1014,7 @@ func checkKeyIsEncrypted(d *daemon.Daemon) func(*check.C) (interface{}, check.Co
} }
} }
func checkSwarmLockedToUnlocked(c *check.C, d *daemon.Daemon) { func checkSwarmLockedToUnlocked(c *testing.T, d *daemon.Daemon) {
// Wait for the PEM file to become unencrypted // Wait for the PEM file to become unencrypted
waitAndAssert(c, defaultReconciliationTimeout, checkKeyIsEncrypted(d), checker.Equals, false) waitAndAssert(c, defaultReconciliationTimeout, checkKeyIsEncrypted(d), checker.Equals, false)
@ -1022,7 +1022,7 @@ func checkSwarmLockedToUnlocked(c *check.C, d *daemon.Daemon) {
waitAndAssert(c, time.Second, d.CheckLocalNodeState, checker.Equals, swarm.LocalNodeStateActive) waitAndAssert(c, time.Second, d.CheckLocalNodeState, checker.Equals, swarm.LocalNodeStateActive)
} }
func checkSwarmUnlockedToLocked(c *check.C, d *daemon.Daemon) { func checkSwarmUnlockedToLocked(c *testing.T, d *daemon.Daemon) {
// Wait for the PEM file to become encrypted // Wait for the PEM file to become encrypted
waitAndAssert(c, defaultReconciliationTimeout, checkKeyIsEncrypted(d), checker.Equals, true) waitAndAssert(c, defaultReconciliationTimeout, checkKeyIsEncrypted(d), checker.Equals, true)
@ -1030,7 +1030,7 @@ func checkSwarmUnlockedToLocked(c *check.C, d *daemon.Daemon) {
waitAndAssert(c, time.Second, d.CheckLocalNodeState, checker.Equals, swarm.LocalNodeStateLocked) waitAndAssert(c, time.Second, d.CheckLocalNodeState, checker.Equals, swarm.LocalNodeStateLocked)
} }
func (s *DockerSwarmSuite) TestUnlockEngineAndUnlockedSwarm(c *check.C) { func (s *DockerSwarmSuite) TestUnlockEngineAndUnlockedSwarm(c *testing.T) {
d := s.AddDaemon(c, false, false) d := s.AddDaemon(c, false, false)
// unlocking a normal engine should return an error - it does not even ask for the key // unlocking a normal engine should return an error - it does not even ask for the key
@ -1055,7 +1055,7 @@ func (s *DockerSwarmSuite) TestUnlockEngineAndUnlockedSwarm(c *check.C) {
assert.Assert(c, result.Combined(), checker.Not(checker.Contains), "Please enter unlock key") assert.Assert(c, result.Combined(), checker.Not(checker.Contains), "Please enter unlock key")
} }
func (s *DockerSwarmSuite) TestSwarmInitLocked(c *check.C) { func (s *DockerSwarmSuite) TestSwarmInitLocked(c *testing.T) {
d := s.AddDaemon(c, false, false) d := s.AddDaemon(c, false, false)
outs, err := d.Cmd("swarm", "init", "--autolock") outs, err := d.Cmd("swarm", "init", "--autolock")
@ -1097,7 +1097,7 @@ func (s *DockerSwarmSuite) TestSwarmInitLocked(c *check.C) {
assert.Assert(c, outs, checker.Not(checker.Contains), "Swarm is encrypted and needs to be unlocked") assert.Assert(c, outs, checker.Not(checker.Contains), "Swarm is encrypted and needs to be unlocked")
} }
func (s *DockerSwarmSuite) TestSwarmLeaveLocked(c *check.C) { func (s *DockerSwarmSuite) TestSwarmLeaveLocked(c *testing.T) {
d := s.AddDaemon(c, false, false) d := s.AddDaemon(c, false, false)
outs, err := d.Cmd("swarm", "init", "--autolock") outs, err := d.Cmd("swarm", "init", "--autolock")
@ -1130,7 +1130,7 @@ func (s *DockerSwarmSuite) TestSwarmLeaveLocked(c *check.C) {
assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateActive) assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateActive)
} }
func (s *DockerSwarmSuite) TestSwarmLockUnlockCluster(c *check.C) { func (s *DockerSwarmSuite) TestSwarmLockUnlockCluster(c *testing.T) {
d1 := s.AddDaemon(c, true, true) d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, true) d2 := s.AddDaemon(c, true, true)
d3 := s.AddDaemon(c, true, true) d3 := s.AddDaemon(c, true, true)
@ -1191,7 +1191,7 @@ func (s *DockerSwarmSuite) TestSwarmLockUnlockCluster(c *check.C) {
assert.Assert(c, getNodeStatus(c, d4), checker.Equals, swarm.LocalNodeStateActive) assert.Assert(c, getNodeStatus(c, d4), checker.Equals, swarm.LocalNodeStateActive)
} }
func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *check.C) { func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *testing.T) {
d1 := s.AddDaemon(c, true, true) d1 := s.AddDaemon(c, true, true)
// enable autolock // enable autolock
@ -1233,7 +1233,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *check.C) {
// (because we never want a manager TLS key to be on disk unencrypted if the cluster // (because we never want a manager TLS key to be on disk unencrypted if the cluster
// is set to autolock) // is set to autolock)
waitAndAssert(c, defaultReconciliationTimeout, d3.CheckControlAvailable, checker.False) waitAndAssert(c, defaultReconciliationTimeout, d3.CheckControlAvailable, checker.False)
waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) { waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
certBytes, err := ioutil.ReadFile(filepath.Join(d3.Folder, "root", "swarm", "certificates", "swarm-node.crt")) certBytes, err := ioutil.ReadFile(filepath.Join(d3.Folder, "root", "swarm", "certificates", "swarm-node.crt"))
if err != nil { if err != nil {
return "", check.Commentf("error: %v", err) return "", check.Commentf("error: %v", err)
@ -1250,7 +1250,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *check.C) {
waitAndAssert(c, time.Second, d3.CheckLocalNodeState, checker.Equals, swarm.LocalNodeStateActive) waitAndAssert(c, time.Second, d3.CheckLocalNodeState, checker.Equals, swarm.LocalNodeStateActive)
} }
func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *check.C) { func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
outs, err := d.Cmd("swarm", "update", "--autolock") outs, err := d.Cmd("swarm", "update", "--autolock")
@ -1330,7 +1330,7 @@ func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *check.C) {
// This differs from `TestSwarmRotateUnlockKey` because that one rotates a single node, which is the leader. // This differs from `TestSwarmRotateUnlockKey` because that one rotates a single node, which is the leader.
// This one keeps the leader up, and asserts that other manager nodes in the cluster also have their unlock // This one keeps the leader up, and asserts that other manager nodes in the cluster also have their unlock
// key rotated. // key rotated.
func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *check.C) { func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *testing.T) {
if runtime.GOARCH == "s390x" { if runtime.GOARCH == "s390x" {
c.Skip("Disabled on s390x") c.Skip("Disabled on s390x")
} }
@ -1420,7 +1420,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *check.C) {
} }
} }
func (s *DockerSwarmSuite) TestSwarmAlternateLockUnlock(c *check.C) { func (s *DockerSwarmSuite) TestSwarmAlternateLockUnlock(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
for i := 0; i < 2; i++ { for i := 0; i < 2; i++ {
@ -1445,7 +1445,7 @@ func (s *DockerSwarmSuite) TestSwarmAlternateLockUnlock(c *check.C) {
} }
} }
func (s *DockerSwarmSuite) TestExtraHosts(c *check.C) { func (s *DockerSwarmSuite) TestExtraHosts(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
// Create a service // Create a service
@ -1468,7 +1468,7 @@ func (s *DockerSwarmSuite) TestExtraHosts(c *check.C) {
assert.Assert(c, out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out)) assert.Assert(c, out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
} }
func (s *DockerSwarmSuite) TestSwarmManagerAddress(c *check.C) { func (s *DockerSwarmSuite) TestSwarmManagerAddress(c *testing.T) {
d1 := s.AddDaemon(c, true, true) d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, false) d2 := s.AddDaemon(c, true, false)
d3 := s.AddDaemon(c, true, false) d3 := s.AddDaemon(c, true, false)
@ -1489,7 +1489,7 @@ func (s *DockerSwarmSuite) TestSwarmManagerAddress(c *check.C) {
assert.Assert(c, strings.Contains(out, expectedOutput)) assert.Assert(c, strings.Contains(out, expectedOutput))
} }
func (s *DockerSwarmSuite) TestSwarmNetworkIPAMOptions(c *check.C) { func (s *DockerSwarmSuite) TestSwarmNetworkIPAMOptions(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
out, err := d.Cmd("network", "create", "-d", "overlay", "--ipam-opt", "foo=bar", "foo") out, err := d.Cmd("network", "create", "-d", "overlay", "--ipam-opt", "foo=bar", "foo")
@ -1515,7 +1515,7 @@ func (s *DockerSwarmSuite) TestSwarmNetworkIPAMOptions(c *check.C) {
// Test case for issue #27866, which did not allow NW name that is the prefix of a swarm NW ID. // Test case for issue #27866, which did not allow NW name that is the prefix of a swarm NW ID.
// e.g. if the ingress ID starts with "n1", it was impossible to create a NW named "n1". // e.g. if the ingress ID starts with "n1", it was impossible to create a NW named "n1".
func (s *DockerSwarmSuite) TestSwarmNetworkCreateIssue27866(c *check.C) { func (s *DockerSwarmSuite) TestSwarmNetworkCreateIssue27866(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
out, err := d.Cmd("network", "inspect", "-f", "{{.Id}}", "ingress") out, err := d.Cmd("network", "inspect", "-f", "{{.Id}}", "ingress")
assert.NilError(c, err, "out: %v", out) assert.NilError(c, err, "out: %v", out)
@ -1538,7 +1538,7 @@ func (s *DockerSwarmSuite) TestSwarmNetworkCreateIssue27866(c *check.C) {
// "network with name FOO already exists". // "network with name FOO already exists".
// Note that it is to ok have multiple networks with the same name if the operations are done // Note that it is to ok have multiple networks with the same name if the operations are done
// in parallel. (#18864) // in parallel. (#18864)
func (s *DockerSwarmSuite) TestSwarmNetworkCreateDup(c *check.C) { func (s *DockerSwarmSuite) TestSwarmNetworkCreateDup(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
drivers := []string{"bridge", "overlay"} drivers := []string{"bridge", "overlay"}
for i, driver1 := range drivers { for i, driver1 := range drivers {
@ -1559,7 +1559,7 @@ func (s *DockerSwarmSuite) TestSwarmNetworkCreateDup(c *check.C) {
} }
} }
func (s *DockerSwarmSuite) TestSwarmPublishDuplicatePorts(c *check.C) { func (s *DockerSwarmSuite) TestSwarmPublishDuplicatePorts(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
out, err := d.Cmd("service", "create", "--no-resolve-image", "--detach=true", "--publish", "5005:80", "--publish", "5006:80", "--publish", "80", "--publish", "80", "busybox", "top") out, err := d.Cmd("service", "create", "--no-resolve-image", "--detach=true", "--publish", "5005:80", "--publish", "5006:80", "--publish", "80", "--publish", "80", "busybox", "top")
@ -1578,7 +1578,7 @@ func (s *DockerSwarmSuite) TestSwarmPublishDuplicatePorts(c *check.C) {
assert.Assert(c, out, checker.Contains, "{ tcp 80 5006 ingress}") assert.Assert(c, out, checker.Contains, "{ tcp 80 5006 ingress}")
} }
func (s *DockerSwarmSuite) TestSwarmJoinWithDrain(c *check.C) { func (s *DockerSwarmSuite) TestSwarmJoinWithDrain(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
out, err := d.Cmd("node", "ls") out, err := d.Cmd("node", "ls")
@ -1606,7 +1606,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinWithDrain(c *check.C) {
assert.Assert(c, out, checker.Contains, "Drain") assert.Assert(c, out, checker.Contains, "Drain")
} }
func (s *DockerSwarmSuite) TestSwarmInitWithDrain(c *check.C) { func (s *DockerSwarmSuite) TestSwarmInitWithDrain(c *testing.T) {
d := s.AddDaemon(c, false, false) d := s.AddDaemon(c, false, false)
out, err := d.Cmd("swarm", "init", "--availability", "drain") out, err := d.Cmd("swarm", "init", "--availability", "drain")
@ -1617,7 +1617,7 @@ func (s *DockerSwarmSuite) TestSwarmInitWithDrain(c *check.C) {
assert.Assert(c, out, checker.Contains, "Drain") assert.Assert(c, out, checker.Contains, "Drain")
} }
func (s *DockerSwarmSuite) TestSwarmReadonlyRootfs(c *check.C) { func (s *DockerSwarmSuite) TestSwarmReadonlyRootfs(c *testing.T) {
testRequires(c, DaemonIsLinux, UserNamespaceROMount) testRequires(c, DaemonIsLinux, UserNamespaceROMount)
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
@ -1638,7 +1638,7 @@ func (s *DockerSwarmSuite) TestSwarmReadonlyRootfs(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "true") assert.Equal(c, strings.TrimSpace(out), "true")
} }
func (s *DockerSwarmSuite) TestNetworkInspectWithDuplicateNames(c *check.C) { func (s *DockerSwarmSuite) TestNetworkInspectWithDuplicateNames(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
name := "foo" name := "foo"
@ -1703,7 +1703,7 @@ func (s *DockerSwarmSuite) TestNetworkInspectWithDuplicateNames(c *check.C) {
assert.Assert(c, out, checker.Contains, "2 matches found based on name") assert.Assert(c, out, checker.Contains, "2 matches found based on name")
} }
func (s *DockerSwarmSuite) TestSwarmStopSignal(c *check.C) { func (s *DockerSwarmSuite) TestSwarmStopSignal(c *testing.T) {
testRequires(c, DaemonIsLinux, UserNamespaceROMount) testRequires(c, DaemonIsLinux, UserNamespaceROMount)
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
@ -1731,7 +1731,7 @@ func (s *DockerSwarmSuite) TestSwarmStopSignal(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "SIGUSR1") assert.Equal(c, strings.TrimSpace(out), "SIGUSR1")
} }
func (s *DockerSwarmSuite) TestSwarmServiceLsFilterMode(c *check.C) { func (s *DockerSwarmSuite) TestSwarmServiceLsFilterMode(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", "top1", "busybox", "top") out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", "top1", "busybox", "top")
@ -1762,7 +1762,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceLsFilterMode(c *check.C) {
assert.Assert(c, out, checker.Not(checker.Contains), "top2") assert.Assert(c, out, checker.Not(checker.Contains), "top2")
} }
func (s *DockerSwarmSuite) TestSwarmInitUnspecifiedDataPathAddr(c *check.C) { func (s *DockerSwarmSuite) TestSwarmInitUnspecifiedDataPathAddr(c *testing.T) {
d := s.AddDaemon(c, false, false) d := s.AddDaemon(c, false, false)
out, err := d.Cmd("swarm", "init", "--data-path-addr", "0.0.0.0") out, err := d.Cmd("swarm", "init", "--data-path-addr", "0.0.0.0")
@ -1774,7 +1774,7 @@ func (s *DockerSwarmSuite) TestSwarmInitUnspecifiedDataPathAddr(c *check.C) {
assert.Assert(c, out, checker.Contains, "data path address must be a non-zero IP") assert.Assert(c, out, checker.Contains, "data path address must be a non-zero IP")
} }
func (s *DockerSwarmSuite) TestSwarmJoinLeave(c *check.C) { func (s *DockerSwarmSuite) TestSwarmJoinLeave(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
out, err := d.Cmd("swarm", "join-token", "-q", "worker") out, err := d.Cmd("swarm", "join-token", "-q", "worker")
@ -1797,7 +1797,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinLeave(c *check.C) {
const defaultRetryCount = 10 const defaultRetryCount = 10
func waitForEvent(c *check.C, d *daemon.Daemon, since string, filter string, event string, retry int) string { func waitForEvent(c *testing.T, d *daemon.Daemon, since string, filter string, event string, retry int) string {
if retry < 1 { if retry < 1 {
c.Fatalf("retry count %d is invalid. It should be no less than 1", retry) c.Fatalf("retry count %d is invalid. It should be no less than 1", retry)
return "" return ""
@ -1824,7 +1824,7 @@ func waitForEvent(c *check.C, d *daemon.Daemon, since string, filter string, eve
return "" return ""
} }
func (s *DockerSwarmSuite) TestSwarmClusterEventsSource(c *check.C) { func (s *DockerSwarmSuite) TestSwarmClusterEventsSource(c *testing.T) {
d1 := s.AddDaemon(c, true, true) d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, true) d2 := s.AddDaemon(c, true, true)
d3 := s.AddDaemon(c, true, false) d3 := s.AddDaemon(c, true, false)
@ -1844,7 +1844,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsSource(c *check.C) {
assert.Assert(c, out, checker.Not(checker.Contains), "network create ") assert.Assert(c, out, checker.Not(checker.Contains), "network create ")
} }
func (s *DockerSwarmSuite) TestSwarmClusterEventsScope(c *check.C) { func (s *DockerSwarmSuite) TestSwarmClusterEventsScope(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
// create a service // create a service
@ -1865,7 +1865,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsScope(c *check.C) {
assert.Assert(c, out, checker.Not(checker.Contains), "service create ") assert.Assert(c, out, checker.Not(checker.Contains), "service create ")
} }
func (s *DockerSwarmSuite) TestSwarmClusterEventsType(c *check.C) { func (s *DockerSwarmSuite) TestSwarmClusterEventsType(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
// create a service // create a service
@ -1888,7 +1888,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsType(c *check.C) {
assert.Assert(c, out, checker.Not(checker.Contains), "service create") assert.Assert(c, out, checker.Not(checker.Contains), "service create")
} }
func (s *DockerSwarmSuite) TestSwarmClusterEventsService(c *check.C) { func (s *DockerSwarmSuite) TestSwarmClusterEventsService(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
// create a service // create a service
@ -1928,7 +1928,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsService(c *check.C) {
waitForEvent(c, d, t3, "-f scope=swarm", "service remove "+serviceID, defaultRetryCount) waitForEvent(c, d, t3, "-f scope=swarm", "service remove "+serviceID, defaultRetryCount)
} }
func (s *DockerSwarmSuite) TestSwarmClusterEventsNode(c *check.C) { func (s *DockerSwarmSuite) TestSwarmClusterEventsNode(c *testing.T) {
d1 := s.AddDaemon(c, true, true) d1 := s.AddDaemon(c, true, true)
s.AddDaemon(c, true, true) s.AddDaemon(c, true, true)
d3 := s.AddDaemon(c, true, true) d3 := s.AddDaemon(c, true, true)
@ -1958,7 +1958,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsNode(c *check.C) {
waitForEvent(c, d1, t3, "-f scope=swarm", "node remove "+d3ID, defaultRetryCount) waitForEvent(c, d1, t3, "-f scope=swarm", "node remove "+d3ID, defaultRetryCount)
} }
func (s *DockerSwarmSuite) TestSwarmClusterEventsNetwork(c *check.C) { func (s *DockerSwarmSuite) TestSwarmClusterEventsNetwork(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
// create a network // create a network
@ -1977,7 +1977,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsNetwork(c *check.C) {
waitForEvent(c, d, t1, "-f type=network", "network remove "+networkID, defaultRetryCount) waitForEvent(c, d, t1, "-f type=network", "network remove "+networkID, defaultRetryCount)
} }
func (s *DockerSwarmSuite) TestSwarmClusterEventsSecret(c *check.C) { func (s *DockerSwarmSuite) TestSwarmClusterEventsSecret(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
testName := "test_secret" testName := "test_secret"
@ -1997,7 +1997,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsSecret(c *check.C) {
waitForEvent(c, d, t1, "-f type=secret", "secret remove "+id, defaultRetryCount) waitForEvent(c, d, t1, "-f type=secret", "secret remove "+id, defaultRetryCount)
} }
func (s *DockerSwarmSuite) TestSwarmClusterEventsConfig(c *check.C) { func (s *DockerSwarmSuite) TestSwarmClusterEventsConfig(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
testName := "test_config" testName := "test_config"
@ -2017,7 +2017,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsConfig(c *check.C) {
waitForEvent(c, d, t1, "-f type=config", "config remove "+id, defaultRetryCount) waitForEvent(c, d, t1, "-f type=config", "config remove "+id, defaultRetryCount)
} }
func getUnlockKey(d *daemon.Daemon, c *check.C, autolockOutput string) string { func getUnlockKey(d *daemon.Daemon, c *testing.T, autolockOutput string) string {
unlockKey, err := d.Cmd("swarm", "unlock-key", "-q") unlockKey, err := d.Cmd("swarm", "unlock-key", "-q")
assert.Assert(c, err, checker.IsNil, check.Commentf("%s", unlockKey)) assert.Assert(c, err, checker.IsNil, check.Commentf("%s", unlockKey))
unlockKey = strings.TrimSuffix(unlockKey, "\n") unlockKey = strings.TrimSuffix(unlockKey, "\n")

View file

@ -13,7 +13,7 @@ import (
"gotest.tools/assert" "gotest.tools/assert"
) )
func (s *DockerSwarmSuite) TestSwarmVolumePlugin(c *check.C) { func (s *DockerSwarmSuite) TestSwarmVolumePlugin(c *testing.T) {
d := s.AddDaemon(c, true, true) d := s.AddDaemon(c, true, true)
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--mount", "type=volume,source=my-volume,destination=/foo,volume-driver=customvolumedriver", "--name", "top", "busybox", "top") out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--mount", "type=volume,source=my-volume,destination=/foo,volume-driver=customvolumedriver", "--name", "top", "busybox", "top")
@ -55,7 +55,7 @@ func (s *DockerSwarmSuite) TestSwarmVolumePlugin(c *check.C) {
} }
// Test network plugin filter in swarm // Test network plugin filter in swarm
func (s *DockerSwarmSuite) TestSwarmNetworkPluginV2(c *check.C) { func (s *DockerSwarmSuite) TestSwarmNetworkPluginV2(c *testing.T) {
testRequires(c, IsAmd64) testRequires(c, IsAmd64)
d1 := s.AddDaemon(c, true, true) d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, false) d2 := s.AddDaemon(c, true, false)

View file

@ -8,7 +8,7 @@ import (
"gotest.tools/icmd" "gotest.tools/icmd"
) )
func (s *DockerSuite) TestTopMultipleArgs(c *check.C) { func (s *DockerSuite) TestTopMultipleArgs(c *testing.T) {
out := runSleepingContainer(c, "-d") out := runSleepingContainer(c, "-d")
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
@ -23,7 +23,7 @@ func (s *DockerSuite) TestTopMultipleArgs(c *check.C) {
result.Assert(c, expected) result.Assert(c, expected)
} }
func (s *DockerSuite) TestTopNonPrivileged(c *check.C) { func (s *DockerSuite) TestTopNonPrivileged(c *testing.T) {
out := runSleepingContainer(c, "-d") out := runSleepingContainer(c, "-d")
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
@ -47,7 +47,7 @@ func (s *DockerSuite) TestTopNonPrivileged(c *check.C) {
// TestTopWindowsCoreProcesses validates that there are lines for the critical // TestTopWindowsCoreProcesses validates that there are lines for the critical
// processes which are found in a Windows container. Note Windows is architecturally // processes which are found in a Windows container. Note Windows is architecturally
// very different to Linux in this regard. // very different to Linux in this regard.
func (s *DockerSuite) TestTopWindowsCoreProcesses(c *check.C) { func (s *DockerSuite) TestTopWindowsCoreProcesses(c *testing.T) {
testRequires(c, DaemonIsWindows) testRequires(c, DaemonIsWindows)
out := runSleepingContainer(c, "-d") out := runSleepingContainer(c, "-d")
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
@ -58,7 +58,7 @@ func (s *DockerSuite) TestTopWindowsCoreProcesses(c *check.C) {
} }
} }
func (s *DockerSuite) TestTopPrivileged(c *check.C) { func (s *DockerSuite) TestTopPrivileged(c *testing.T) {
// Windows does not support --privileged // Windows does not support --privileged
testRequires(c, DaemonIsLinux, NotUserNamespace) testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmd(c, "run", "--privileged", "-i", "-d", "busybox", "top") out, _ := dockerCmd(c, "run", "--privileged", "-i", "-d", "busybox", "top")

View file

@ -19,7 +19,7 @@ import (
"gotest.tools/assert" "gotest.tools/assert"
) )
func (s *DockerSuite) TestUpdateRunningContainer(c *check.C) { func (s *DockerSuite) TestUpdateRunningContainer(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
@ -34,7 +34,7 @@ func (s *DockerSuite) TestUpdateRunningContainer(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "524288000") assert.Equal(c, strings.TrimSpace(out), "524288000")
} }
func (s *DockerSuite) TestUpdateRunningContainerWithRestart(c *check.C) { func (s *DockerSuite) TestUpdateRunningContainerWithRestart(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
@ -50,7 +50,7 @@ func (s *DockerSuite) TestUpdateRunningContainerWithRestart(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "524288000") assert.Equal(c, strings.TrimSpace(out), "524288000")
} }
func (s *DockerSuite) TestUpdateStoppedContainer(c *check.C) { func (s *DockerSuite) TestUpdateStoppedContainer(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
@ -65,7 +65,7 @@ func (s *DockerSuite) TestUpdateStoppedContainer(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "524288000") assert.Equal(c, strings.TrimSpace(out), "524288000")
} }
func (s *DockerSuite) TestUpdatePausedContainer(c *check.C) { func (s *DockerSuite) TestUpdatePausedContainer(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, cpuShare) testRequires(c, cpuShare)
@ -82,7 +82,7 @@ func (s *DockerSuite) TestUpdatePausedContainer(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "500") assert.Equal(c, strings.TrimSpace(out), "500")
} }
func (s *DockerSuite) TestUpdateWithUntouchedFields(c *check.C) { func (s *DockerSuite) TestUpdateWithUntouchedFields(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
testRequires(c, cpuShare) testRequires(c, cpuShare)
@ -100,7 +100,7 @@ func (s *DockerSuite) TestUpdateWithUntouchedFields(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "800") assert.Equal(c, strings.TrimSpace(out), "800")
} }
func (s *DockerSuite) TestUpdateContainerInvalidValue(c *check.C) { func (s *DockerSuite) TestUpdateContainerInvalidValue(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
@ -112,7 +112,7 @@ func (s *DockerSuite) TestUpdateContainerInvalidValue(c *check.C) {
assert.Assert(c, strings.Contains(out, expected)) assert.Assert(c, strings.Contains(out, expected))
} }
func (s *DockerSuite) TestUpdateContainerWithoutFlags(c *check.C) { func (s *DockerSuite) TestUpdateContainerWithoutFlags(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
@ -122,7 +122,7 @@ func (s *DockerSuite) TestUpdateContainerWithoutFlags(c *check.C) {
assert.ErrorContains(c, err, "") assert.ErrorContains(c, err, "")
} }
func (s *DockerSuite) TestUpdateKernelMemory(c *check.C) { func (s *DockerSuite) TestUpdateKernelMemory(c *testing.T) {
testRequires(c, DaemonIsLinux, kernelMemorySupport) testRequires(c, DaemonIsLinux, kernelMemorySupport)
name := "test-update-container" name := "test-update-container"
@ -136,7 +136,7 @@ func (s *DockerSuite) TestUpdateKernelMemory(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "104857600") assert.Equal(c, strings.TrimSpace(out), "104857600")
} }
func (s *DockerSuite) TestUpdateKernelMemoryUninitialized(c *check.C) { func (s *DockerSuite) TestUpdateKernelMemoryUninitialized(c *testing.T) {
testRequires(c, DaemonIsLinux, kernelMemorySupport) testRequires(c, DaemonIsLinux, kernelMemorySupport)
isNewKernel := CheckKernelVersion(4, 6, 0) isNewKernel := CheckKernelVersion(4, 6, 0)
@ -183,7 +183,7 @@ func CheckKernelVersion(k, major, minor int) bool {
return kernel.CompareKernelVersion(*GetKernelVersion(), kernel.VersionInfo{Kernel: k, Major: major, Minor: minor}) >= 0 return kernel.CompareKernelVersion(*GetKernelVersion(), kernel.VersionInfo{Kernel: k, Major: major, Minor: minor}) >= 0
} }
func (s *DockerSuite) TestUpdateSwapMemoryOnly(c *check.C) { func (s *DockerSuite) TestUpdateSwapMemoryOnly(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
testRequires(c, swapMemorySupport) testRequires(c, swapMemorySupport)
@ -199,7 +199,7 @@ func (s *DockerSuite) TestUpdateSwapMemoryOnly(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "629145600") assert.Equal(c, strings.TrimSpace(out), "629145600")
} }
func (s *DockerSuite) TestUpdateInvalidSwapMemory(c *check.C) { func (s *DockerSuite) TestUpdateInvalidSwapMemory(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
testRequires(c, swapMemorySupport) testRequires(c, swapMemorySupport)
@ -224,7 +224,7 @@ func (s *DockerSuite) TestUpdateInvalidSwapMemory(c *check.C) {
assert.Equal(c, strings.TrimSpace(out), "629145600") assert.Equal(c, strings.TrimSpace(out), "629145600")
} }
func (s *DockerSuite) TestUpdateStats(c *check.C) { func (s *DockerSuite) TestUpdateStats(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
testRequires(c, cpuCfsQuota) testRequires(c, cpuCfsQuota)
@ -253,7 +253,7 @@ func (s *DockerSuite) TestUpdateStats(c *check.C) {
assert.Equal(c, preMemLimit, curMemLimit) assert.Equal(c, preMemLimit, curMemLimit)
} }
func (s *DockerSuite) TestUpdateMemoryWithSwapMemory(c *check.C) { func (s *DockerSuite) TestUpdateMemoryWithSwapMemory(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
testRequires(c, swapMemorySupport) testRequires(c, swapMemorySupport)
@ -267,7 +267,7 @@ func (s *DockerSuite) TestUpdateMemoryWithSwapMemory(c *check.C) {
dockerCmd(c, "update", "--memory", "800M", "--memory-swap", "1000M", name) dockerCmd(c, "update", "--memory", "800M", "--memory-swap", "1000M", name)
} }
func (s *DockerSuite) TestUpdateNotAffectMonitorRestartPolicy(c *check.C) { func (s *DockerSuite) TestUpdateNotAffectMonitorRestartPolicy(c *testing.T) {
testRequires(c, DaemonIsLinux, cpuShare) testRequires(c, DaemonIsLinux, cpuShare)
out, _ := dockerCmd(c, "run", "-tid", "--restart=always", "busybox", "sh") out, _ := dockerCmd(c, "run", "-tid", "--restart=always", "busybox", "sh")
@ -295,7 +295,7 @@ func (s *DockerSuite) TestUpdateNotAffectMonitorRestartPolicy(c *check.C) {
assert.NilError(c, waitRun(id)) assert.NilError(c, waitRun(id))
} }
func (s *DockerSuite) TestUpdateWithNanoCPUs(c *check.C) { func (s *DockerSuite) TestUpdateWithNanoCPUs(c *testing.T) {
testRequires(c, cpuCfsQuota, cpuCfsPeriod) testRequires(c, cpuCfsQuota, cpuCfsPeriod)
file1 := "/sys/fs/cgroup/cpu/cpu.cfs_quota_us" file1 := "/sys/fs/cgroup/cpu/cpu.cfs_quota_us"

View file

@ -22,7 +22,7 @@ import (
// user namespaces test: run daemon with remapped root setting // user namespaces test: run daemon with remapped root setting
// 1. validate uid/gid maps are set properly // 1. validate uid/gid maps are set properly
// 2. verify that files created are owned by remapped root // 2. verify that files created are owned by remapped root
func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *check.C) { func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) {
testRequires(c, UserNamespaceInKernel) testRequires(c, UserNamespaceInKernel)
s.d.StartWithBusybox(c, "--userns-remap", "default") s.d.StartWithBusybox(c, "--userns-remap", "default")
@ -88,7 +88,7 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *check.C) {
} }
// findUser finds the uid or name of the user of the first process that runs in a container // findUser finds the uid or name of the user of the first process that runs in a container
func (s *DockerDaemonSuite) findUser(c *check.C, container string) string { func (s *DockerDaemonSuite) findUser(c *testing.T, container string) string {
out, err := s.d.Cmd("top", container) out, err := s.d.Cmd("top", container)
assert.Assert(c, err, checker.IsNil, check.Commentf("Output: %s", out)) assert.Assert(c, err, checker.IsNil, check.Commentf("Output: %s", out))
rows := strings.Split(out, "\n") rows := strings.Split(out, "\n")

View file

@ -25,7 +25,7 @@ func makefile(path string, contents string) (string, error) {
// TestV2Only ensures that a daemon does not // TestV2Only ensures that a daemon does not
// attempt to contact any v1 registry endpoints. // attempt to contact any v1 registry endpoints.
func (s *DockerRegistrySuite) TestV2Only(c *check.C) { func (s *DockerRegistrySuite) TestV2Only(c *testing.T) {
reg, err := registry.NewMock(c) reg, err := registry.NewMock(c)
defer reg.Close() defer reg.Close()
assert.NilError(c, err) assert.NilError(c, err)

View file

@ -20,7 +20,7 @@ import (
"gotest.tools/icmd" "gotest.tools/icmd"
) )
func (s *DockerSuite) TestVolumeCLICreate(c *check.C) { func (s *DockerSuite) TestVolumeCLICreate(c *testing.T) {
dockerCmd(c, "volume", "create") dockerCmd(c, "volume", "create")
_, _, err := dockerCmdWithError("volume", "create", "-d", "nosuchdriver") _, _, err := dockerCmdWithError("volume", "create", "-d", "nosuchdriver")
@ -36,7 +36,7 @@ func (s *DockerSuite) TestVolumeCLICreate(c *check.C) {
assert.Assert(c, name, check.Equals, "test2") assert.Assert(c, name, check.Equals, "test2")
} }
func (s *DockerSuite) TestVolumeCLIInspect(c *check.C) { func (s *DockerSuite) TestVolumeCLIInspect(c *testing.T) {
assert.Assert(c, exec.Command(dockerBinary, "volume", "inspect", "doesnotexist").Run(), check.Not(check.IsNil), check.Commentf("volume inspect should error on non-existent volume")) assert.Assert(c, exec.Command(dockerBinary, "volume", "inspect", "doesnotexist").Run(), check.Not(check.IsNil), check.Commentf("volume inspect should error on non-existent volume"))
out, _ := dockerCmd(c, "volume", "create") out, _ := dockerCmd(c, "volume", "create")
name := strings.TrimSpace(out) name := strings.TrimSpace(out)
@ -48,7 +48,7 @@ func (s *DockerSuite) TestVolumeCLIInspect(c *check.C) {
assert.Assert(c, strings.TrimSpace(out), check.Equals, "test") assert.Assert(c, strings.TrimSpace(out), check.Equals, "test")
} }
func (s *DockerSuite) TestVolumeCLIInspectMulti(c *check.C) { func (s *DockerSuite) TestVolumeCLIInspectMulti(c *testing.T) {
dockerCmd(c, "volume", "create", "test1") dockerCmd(c, "volume", "create", "test1")
dockerCmd(c, "volume", "create", "test2") dockerCmd(c, "volume", "create", "test2")
dockerCmd(c, "volume", "create", "test3") dockerCmd(c, "volume", "create", "test3")
@ -65,7 +65,7 @@ func (s *DockerSuite) TestVolumeCLIInspectMulti(c *check.C) {
assert.Assert(c, out, checker.Contains, "test3") assert.Assert(c, out, checker.Contains, "test3")
} }
func (s *DockerSuite) TestVolumeCLILs(c *check.C) { func (s *DockerSuite) TestVolumeCLILs(c *testing.T) {
prefix, _ := getPrefixAndSlashFromDaemonPlatform() prefix, _ := getPrefixAndSlashFromDaemonPlatform()
dockerCmd(c, "volume", "create", "aaa") dockerCmd(c, "volume", "create", "aaa")
@ -78,7 +78,7 @@ func (s *DockerSuite) TestVolumeCLILs(c *check.C) {
assertVolumesInList(c, out, []string{"aaa", "soo", "test"}) assertVolumesInList(c, out, []string{"aaa", "soo", "test"})
} }
func (s *DockerSuite) TestVolumeLsFormat(c *check.C) { func (s *DockerSuite) TestVolumeLsFormat(c *testing.T) {
dockerCmd(c, "volume", "create", "aaa") dockerCmd(c, "volume", "create", "aaa")
dockerCmd(c, "volume", "create", "test") dockerCmd(c, "volume", "create", "test")
dockerCmd(c, "volume", "create", "soo") dockerCmd(c, "volume", "create", "soo")
@ -87,7 +87,7 @@ func (s *DockerSuite) TestVolumeLsFormat(c *check.C) {
assertVolumesInList(c, out, []string{"aaa", "soo", "test"}) assertVolumesInList(c, out, []string{"aaa", "soo", "test"})
} }
func (s *DockerSuite) TestVolumeLsFormatDefaultFormat(c *check.C) { func (s *DockerSuite) TestVolumeLsFormatDefaultFormat(c *testing.T) {
dockerCmd(c, "volume", "create", "aaa") dockerCmd(c, "volume", "create", "aaa")
dockerCmd(c, "volume", "create", "test") dockerCmd(c, "volume", "create", "test")
dockerCmd(c, "volume", "create", "soo") dockerCmd(c, "volume", "create", "soo")
@ -106,7 +106,7 @@ func (s *DockerSuite) TestVolumeLsFormatDefaultFormat(c *check.C) {
assertVolumesInList(c, out, []string{"aaa default", "soo default", "test default"}) assertVolumesInList(c, out, []string{"aaa default", "soo default", "test default"})
} }
func assertVolumesInList(c *check.C, out string, expected []string) { func assertVolumesInList(c *testing.T, out string, expected []string) {
lines := strings.Split(strings.TrimSpace(string(out)), "\n") lines := strings.Split(strings.TrimSpace(string(out)), "\n")
for _, expect := range expected { for _, expect := range expected {
found := false found := false
@ -120,7 +120,7 @@ func assertVolumesInList(c *check.C, out string, expected []string) {
} }
} }
func (s *DockerSuite) TestVolumeCLILsFilterDangling(c *check.C) { func (s *DockerSuite) TestVolumeCLILsFilterDangling(c *testing.T) {
prefix, _ := getPrefixAndSlashFromDaemonPlatform() prefix, _ := getPrefixAndSlashFromDaemonPlatform()
dockerCmd(c, "volume", "create", "testnotinuse1") dockerCmd(c, "volume", "create", "testnotinuse1")
dockerCmd(c, "volume", "create", "testisinuse1") dockerCmd(c, "volume", "create", "testisinuse1")
@ -170,19 +170,19 @@ func (s *DockerSuite) TestVolumeCLILsFilterDangling(c *check.C) {
assert.Assert(c, out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output")) assert.Assert(c, out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output"))
} }
func (s *DockerSuite) TestVolumeCLILsErrorWithInvalidFilterName(c *check.C) { func (s *DockerSuite) TestVolumeCLILsErrorWithInvalidFilterName(c *testing.T) {
out, _, err := dockerCmdWithError("volume", "ls", "-f", "FOO=123") out, _, err := dockerCmdWithError("volume", "ls", "-f", "FOO=123")
assert.ErrorContains(c, err, "") assert.ErrorContains(c, err, "")
assert.Assert(c, out, checker.Contains, "Invalid filter") assert.Assert(c, out, checker.Contains, "Invalid filter")
} }
func (s *DockerSuite) TestVolumeCLILsWithIncorrectFilterValue(c *check.C) { func (s *DockerSuite) TestVolumeCLILsWithIncorrectFilterValue(c *testing.T) {
out, _, err := dockerCmdWithError("volume", "ls", "-f", "dangling=invalid") out, _, err := dockerCmdWithError("volume", "ls", "-f", "dangling=invalid")
assert.ErrorContains(c, err, "") assert.ErrorContains(c, err, "")
assert.Assert(c, out, checker.Contains, "Invalid filter") assert.Assert(c, out, checker.Contains, "Invalid filter")
} }
func (s *DockerSuite) TestVolumeCLIRm(c *check.C) { func (s *DockerSuite) TestVolumeCLIRm(c *testing.T) {
prefix, _ := getPrefixAndSlashFromDaemonPlatform() prefix, _ := getPrefixAndSlashFromDaemonPlatform()
out, _ := dockerCmd(c, "volume", "create") out, _ := dockerCmd(c, "volume", "create")
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
@ -214,7 +214,7 @@ func (s *DockerSuite) TestVolumeCLIRm(c *check.C) {
} }
// FIXME(vdemeester) should be a unit test in cli/command/volume package // FIXME(vdemeester) should be a unit test in cli/command/volume package
func (s *DockerSuite) TestVolumeCLINoArgs(c *check.C) { func (s *DockerSuite) TestVolumeCLINoArgs(c *testing.T) {
out, _ := dockerCmd(c, "volume") out, _ := dockerCmd(c, "volume")
// no args should produce the cmd usage output // no args should produce the cmd usage output
usage := "Usage: docker volume COMMAND" usage := "Usage: docker volume COMMAND"
@ -237,7 +237,7 @@ func (s *DockerSuite) TestVolumeCLINoArgs(c *check.C) {
assert.Assert(c, result.Stderr(), checker.Contains, "unknown flag: --no-such-flag") assert.Assert(c, result.Stderr(), checker.Contains, "unknown flag: --no-such-flag")
} }
func (s *DockerSuite) TestVolumeCLIInspectTmplError(c *check.C) { func (s *DockerSuite) TestVolumeCLIInspectTmplError(c *testing.T) {
out, _ := dockerCmd(c, "volume", "create") out, _ := dockerCmd(c, "volume", "create")
name := strings.TrimSpace(out) name := strings.TrimSpace(out)
@ -247,7 +247,7 @@ func (s *DockerSuite) TestVolumeCLIInspectTmplError(c *check.C) {
assert.Assert(c, out, checker.Contains, "Template parsing error") assert.Assert(c, out, checker.Contains, "Template parsing error")
} }
func (s *DockerSuite) TestVolumeCLICreateWithOpts(c *check.C) { func (s *DockerSuite) TestVolumeCLICreateWithOpts(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "volume", "create", "-d", "local", "test", "--opt=type=tmpfs", "--opt=device=tmpfs", "--opt=o=size=1m,uid=1000") dockerCmd(c, "volume", "create", "-d", "local", "test", "--opt=type=tmpfs", "--opt=device=tmpfs", "--opt=o=size=1m,uid=1000")
@ -271,7 +271,7 @@ func (s *DockerSuite) TestVolumeCLICreateWithOpts(c *check.C) {
assert.Assert(c, found, checker.Equals, true) assert.Assert(c, found, checker.Equals, true)
} }
func (s *DockerSuite) TestVolumeCLICreateLabel(c *check.C) { func (s *DockerSuite) TestVolumeCLICreateLabel(c *testing.T) {
testVol := "testvolcreatelabel" testVol := "testvolcreatelabel"
testLabel := "foo" testLabel := "foo"
testValue := "bar" testValue := "bar"
@ -283,7 +283,7 @@ func (s *DockerSuite) TestVolumeCLICreateLabel(c *check.C) {
assert.Assert(c, strings.TrimSpace(out), check.Equals, testValue) assert.Assert(c, strings.TrimSpace(out), check.Equals, testValue)
} }
func (s *DockerSuite) TestVolumeCLICreateLabelMultiple(c *check.C) { func (s *DockerSuite) TestVolumeCLICreateLabelMultiple(c *testing.T) {
testVol := "testvolcreatelabel" testVol := "testvolcreatelabel"
testLabels := map[string]string{ testLabels := map[string]string{
@ -310,7 +310,7 @@ func (s *DockerSuite) TestVolumeCLICreateLabelMultiple(c *check.C) {
} }
} }
func (s *DockerSuite) TestVolumeCLILsFilterLabels(c *check.C) { func (s *DockerSuite) TestVolumeCLILsFilterLabels(c *testing.T) {
testVol1 := "testvolcreatelabel-1" testVol1 := "testvolcreatelabel-1"
_, _, err := dockerCmdWithError("volume", "create", "--label", "foo=bar1", testVol1) _, _, err := dockerCmdWithError("volume", "create", "--label", "foo=bar1", testVol1)
assert.NilError(c, err) assert.NilError(c, err)
@ -340,7 +340,7 @@ func (s *DockerSuite) TestVolumeCLILsFilterLabels(c *check.C) {
assert.Assert(c, len(outArr), check.Equals, 1, check.Commentf("\n%s", out)) assert.Assert(c, len(outArr), check.Equals, 1, check.Commentf("\n%s", out))
} }
func (s *DockerSuite) TestVolumeCLILsFilterDrivers(c *check.C) { func (s *DockerSuite) TestVolumeCLILsFilterDrivers(c *testing.T) {
// using default volume driver local to create volumes // using default volume driver local to create volumes
testVol1 := "testvol-1" testVol1 := "testvol-1"
_, _, err := dockerCmdWithError("volume", "create", testVol1) _, _, err := dockerCmdWithError("volume", "create", testVol1)
@ -371,7 +371,7 @@ func (s *DockerSuite) TestVolumeCLILsFilterDrivers(c *check.C) {
assert.Assert(c, len(outArr), check.Equals, 1, check.Commentf("\n%s", out)) assert.Assert(c, len(outArr), check.Equals, 1, check.Commentf("\n%s", out))
} }
func (s *DockerSuite) TestVolumeCLIRmForceUsage(c *check.C) { func (s *DockerSuite) TestVolumeCLIRmForceUsage(c *testing.T) {
out, _ := dockerCmd(c, "volume", "create") out, _ := dockerCmd(c, "volume", "create")
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
@ -379,7 +379,7 @@ func (s *DockerSuite) TestVolumeCLIRmForceUsage(c *check.C) {
dockerCmd(c, "volume", "rm", "--force", "nonexist") dockerCmd(c, "volume", "rm", "--force", "nonexist")
} }
func (s *DockerSuite) TestVolumeCLIRmForce(c *check.C) { func (s *DockerSuite) TestVolumeCLIRmForce(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
name := "test" name := "test"
@ -403,7 +403,7 @@ func (s *DockerSuite) TestVolumeCLIRmForce(c *check.C) {
// TestVolumeCLIRmForceInUse verifies that repeated `docker volume rm -f` calls does not remove a volume // TestVolumeCLIRmForceInUse verifies that repeated `docker volume rm -f` calls does not remove a volume
// if it is in use. Test case for https://github.com/docker/docker/issues/31446 // if it is in use. Test case for https://github.com/docker/docker/issues/31446
func (s *DockerSuite) TestVolumeCLIRmForceInUse(c *check.C) { func (s *DockerSuite) TestVolumeCLIRmForceInUse(c *testing.T) {
name := "testvolume" name := "testvolume"
out, _ := dockerCmd(c, "volume", "create", name) out, _ := dockerCmd(c, "volume", "create", name)
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
@ -441,7 +441,7 @@ func (s *DockerSuite) TestVolumeCLIRmForceInUse(c *check.C) {
assert.Assert(c, out, checker.Not(checker.Contains), name) assert.Assert(c, out, checker.Not(checker.Contains), name)
} }
func (s *DockerSuite) TestVolumeCliInspectWithVolumeOpts(c *check.C) { func (s *DockerSuite) TestVolumeCliInspectWithVolumeOpts(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
// Without options // Without options
@ -463,7 +463,7 @@ func (s *DockerSuite) TestVolumeCliInspectWithVolumeOpts(c *check.C) {
} }
// Test case (1) for 21845: duplicate targets for --volumes-from // Test case (1) for 21845: duplicate targets for --volumes-from
func (s *DockerSuite) TestDuplicateMountpointsForVolumesFrom(c *check.C) { func (s *DockerSuite) TestDuplicateMountpointsForVolumesFrom(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
image := "vimage" image := "vimage"
@ -505,7 +505,7 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFrom(c *check.C) {
} }
// Test case (2) for 21845: duplicate targets for --volumes-from and -v (bind) // Test case (2) for 21845: duplicate targets for --volumes-from and -v (bind)
func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndBind(c *check.C) { func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndBind(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
image := "vimage" image := "vimage"
@ -549,7 +549,7 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndBind(c *check.C)
} }
// Test case (3) for 21845: duplicate targets for --volumes-from and `Mounts` (API only) // Test case (3) for 21845: duplicate targets for --volumes-from and `Mounts` (API only)
func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndMounts(c *check.C) { func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndMounts(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux) testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
image := "vimage" image := "vimage"

View file

@ -18,7 +18,7 @@ func formatV123StartAPIURL(url string) string {
return "/v1.23" + url return "/v1.23" + url
} }
func (s *DockerSuite) TestDeprecatedContainerAPIStartHostConfig(c *check.C) { func (s *DockerSuite) TestDeprecatedContainerAPIStartHostConfig(c *testing.T) {
name := "test-deprecated-api-124" name := "test-deprecated-api-124"
dockerCmd(c, "create", "--name", name, "busybox") dockerCmd(c, "create", "--name", name, "busybox")
config := map[string]interface{}{ config := map[string]interface{}{
@ -37,7 +37,7 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartHostConfig(c *check.C) {
} }
} }
func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumeBinds(c *check.C) { func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumeBinds(c *testing.T) {
// TODO Windows CI: Investigate further why this fails on Windows to Windows CI. // TODO Windows CI: Investigate further why this fails on Windows to Windows CI.
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
path := "/foo" path := "/foo"
@ -68,7 +68,7 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumeBinds(c *check.C) {
} }
// Test for GH#10618 // Test for GH#10618
func (s *DockerSuite) TestDeprecatedContainerAPIStartDupVolumeBinds(c *check.C) { func (s *DockerSuite) TestDeprecatedContainerAPIStartDupVolumeBinds(c *testing.T) {
// TODO Windows to Windows CI - Port this // TODO Windows to Windows CI - Port this
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "testdups" name := "testdups"
@ -101,7 +101,7 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartDupVolumeBinds(c *check.C)
assert.Assert(c, strings.Contains(string(buf), "Duplicate mount point"), "Expected failure due to duplicate bind mounts to same path, instead got: %q with error: %v", string(buf), err) assert.Assert(c, strings.Contains(string(buf), "Duplicate mount point"), "Expected failure due to duplicate bind mounts to same path, instead got: %q with error: %v", string(buf), err)
} }
func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumesFrom(c *check.C) { func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumesFrom(c *testing.T) {
// TODO Windows to Windows CI - Port this // TODO Windows to Windows CI - Port this
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
volName := "voltst" volName := "voltst"
@ -134,7 +134,7 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumesFrom(c *check.C) {
} }
// #9981 - Allow a docker created volume (ie, one in /var/lib/docker/volumes) to be used to overwrite (via passing in Binds on api start) an existing volume // #9981 - Allow a docker created volume (ie, one in /var/lib/docker/volumes) to be used to overwrite (via passing in Binds on api start) an existing volume
func (s *DockerSuite) TestDeprecatedPostContainerBindNormalVolume(c *check.C) { func (s *DockerSuite) TestDeprecatedPostContainerBindNormalVolume(c *testing.T) {
// TODO Windows to Windows CI - Port this // TODO Windows to Windows CI - Port this
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "create", "-v", "/foo", "--name=one", "busybox") dockerCmd(c, "create", "-v", "/foo", "--name=one", "busybox")
@ -154,7 +154,7 @@ func (s *DockerSuite) TestDeprecatedPostContainerBindNormalVolume(c *check.C) {
assert.Equal(c, fooDir2, fooDir, "expected volume path to be %s, got: %s", fooDir, fooDir2) assert.Equal(c, fooDir2, fooDir, "expected volume path to be %s, got: %s", fooDir, fooDir2)
} }
func (s *DockerSuite) TestDeprecatedStartWithTooLowMemoryLimit(c *check.C) { func (s *DockerSuite) TestDeprecatedStartWithTooLowMemoryLimit(c *testing.T) {
// TODO Windows: Port once memory is supported // TODO Windows: Port once memory is supported
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "create", "busybox") out, _ := dockerCmd(c, "create", "busybox")
@ -179,7 +179,7 @@ func (s *DockerSuite) TestDeprecatedStartWithTooLowMemoryLimit(c *check.C) {
} }
// #14640 // #14640
func (s *DockerSuite) TestDeprecatedPostContainersStartWithoutLinksInHostConfig(c *check.C) { func (s *DockerSuite) TestDeprecatedPostContainersStartWithoutLinksInHostConfig(c *testing.T) {
// TODO Windows: Windows doesn't support supplying a hostconfig on start. // TODO Windows: Windows doesn't support supplying a hostconfig on start.
// An alternate test could be written to validate the negative testing aspect of this // An alternate test could be written to validate the negative testing aspect of this
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -196,7 +196,7 @@ func (s *DockerSuite) TestDeprecatedPostContainersStartWithoutLinksInHostConfig(
} }
// #14640 // #14640
func (s *DockerSuite) TestDeprecatedPostContainersStartWithLinksInHostConfig(c *check.C) { func (s *DockerSuite) TestDeprecatedPostContainersStartWithLinksInHostConfig(c *testing.T) {
// TODO Windows: Windows doesn't support supplying a hostconfig on start. // TODO Windows: Windows doesn't support supplying a hostconfig on start.
// An alternate test could be written to validate the negative testing aspect of this // An alternate test could be written to validate the negative testing aspect of this
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
@ -214,7 +214,7 @@ func (s *DockerSuite) TestDeprecatedPostContainersStartWithLinksInHostConfig(c *
} }
// #14640 // #14640
func (s *DockerSuite) TestDeprecatedPostContainersStartWithLinksInHostConfigIdLinked(c *check.C) { func (s *DockerSuite) TestDeprecatedPostContainersStartWithLinksInHostConfigIdLinked(c *testing.T) {
// Windows does not support links // Windows does not support links
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "test-host-config-links" name := "test-host-config-links"
@ -233,7 +233,7 @@ func (s *DockerSuite) TestDeprecatedPostContainersStartWithLinksInHostConfigIdLi
b.Close() b.Close()
} }
func (s *DockerSuite) TestDeprecatedStartWithNilDNS(c *check.C) { func (s *DockerSuite) TestDeprecatedStartWithNilDNS(c *testing.T) {
// TODO Windows: Add once DNS is supported // TODO Windows: Add once DNS is supported
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "create", "busybox") out, _ := dockerCmd(c, "create", "busybox")

View file

@ -11,7 +11,7 @@ import (
) )
// #19100 This is a deprecated feature test, it should be removed in Docker 1.12 // #19100 This is a deprecated feature test, it should be removed in Docker 1.12
func (s *DockerNetworkSuite) TestDeprecatedDockerNetworkStartAPIWithHostconfig(c *check.C) { func (s *DockerNetworkSuite) TestDeprecatedDockerNetworkStartAPIWithHostconfig(c *testing.T) {
netName := "test" netName := "test"
conName := "foo" conName := "foo"
dockerCmd(c, "network", "create", netName) dockerCmd(c, "network", "create", netName)

View file

@ -39,26 +39,26 @@ func newDockerHubPullSuite() *DockerHubPullSuite {
} }
// SetUpSuite starts the suite daemon. // SetUpSuite starts the suite daemon.
func (s *DockerHubPullSuite) SetUpSuite(c *check.C) { func (s *DockerHubPullSuite) SetUpSuite(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
s.d.Start(c) s.d.Start(c)
} }
// TearDownSuite stops the suite daemon. // TearDownSuite stops the suite daemon.
func (s *DockerHubPullSuite) TearDownSuite(c *check.C) { func (s *DockerHubPullSuite) TearDownSuite(c *testing.T) {
if s.d != nil { if s.d != nil {
s.d.Stop(c) s.d.Stop(c)
} }
} }
// SetUpTest declares that all tests of this suite require network. // SetUpTest declares that all tests of this suite require network.
func (s *DockerHubPullSuite) SetUpTest(c *check.C) { func (s *DockerHubPullSuite) SetUpTest(c *testing.T) {
testRequires(c, Network) testRequires(c, Network)
} }
// TearDownTest removes all images from the suite daemon. // TearDownTest removes all images from the suite daemon.
func (s *DockerHubPullSuite) TearDownTest(c *check.C) { func (s *DockerHubPullSuite) TearDownTest(c *testing.T) {
out := s.Cmd(c, "images", "-aq") out := s.Cmd(c, "images", "-aq")
images := strings.Split(out, "\n") images := strings.Split(out, "\n")
images = append([]string{"rmi", "-f"}, images...) images = append([]string{"rmi", "-f"}, images...)
@ -68,7 +68,7 @@ func (s *DockerHubPullSuite) TearDownTest(c *check.C) {
// Cmd executes a command against the suite daemon and returns the combined // Cmd executes a command against the suite daemon and returns the combined
// output. The function fails the test when the command returns an error. // output. The function fails the test when the command returns an error.
func (s *DockerHubPullSuite) Cmd(c *check.C, name string, arg ...string) string { func (s *DockerHubPullSuite) Cmd(c *testing.T, name string, arg ...string) string {
out, err := s.CmdWithError(name, arg...) out, err := s.CmdWithError(name, arg...)
assert.Assert(c, err, checker.IsNil, check.Commentf("%q failed with errors: %s, %v", strings.Join(arg, " "), out, err)) assert.Assert(c, err, checker.IsNil, check.Commentf("%q failed with errors: %s, %v", strings.Join(arg, " "), out, err))
return out return out

View file

@ -48,12 +48,12 @@ func dockerCmdWithResult(args ...string) *icmd.Result {
return cli.Docker(cli.Args(args...)) return cli.Docker(cli.Args(args...))
} }
func findContainerIP(c *check.C, id string, network string) string { func findContainerIP(c *testing.T, id string, network string) string {
out, _ := dockerCmd(c, "inspect", fmt.Sprintf("--format='{{ .NetworkSettings.Networks.%s.IPAddress }}'", network), id) out, _ := dockerCmd(c, "inspect", fmt.Sprintf("--format='{{ .NetworkSettings.Networks.%s.IPAddress }}'", network), id)
return strings.Trim(out, " \r\n'") return strings.Trim(out, " \r\n'")
} }
func getContainerCount(c *check.C) int { func getContainerCount(c *testing.T) int {
const containers = "Containers:" const containers = "Containers:"
result := icmd.RunCommand(dockerBinary, "info") result := icmd.RunCommand(dockerBinary, "info")
@ -73,7 +73,7 @@ func getContainerCount(c *check.C) int {
return 0 return 0
} }
func inspectFieldAndUnmarshall(c *check.C, name, field string, output interface{}) { func inspectFieldAndUnmarshall(c *testing.T, name, field string, output interface{}) {
str := inspectFieldJSON(c, name, field) str := inspectFieldJSON(c, name, field)
err := json.Unmarshal([]byte(str), output) err := json.Unmarshal([]byte(str), output)
if c != nil { if c != nil {
@ -97,7 +97,7 @@ func inspectFieldWithError(name, field string) (string, error) {
} }
// Deprecated: use cli.Inspect // Deprecated: use cli.Inspect
func inspectField(c *check.C, name, field string) string { func inspectField(c *testing.T, name, field string) string {
out, err := inspectFilter(name, fmt.Sprintf(".%s", field)) out, err := inspectFilter(name, fmt.Sprintf(".%s", field))
if c != nil { if c != nil {
assert.NilError(c, err) assert.NilError(c, err)
@ -106,7 +106,7 @@ func inspectField(c *check.C, name, field string) string {
} }
// Deprecated: use cli.Inspect // Deprecated: use cli.Inspect
func inspectFieldJSON(c *check.C, name, field string) string { func inspectFieldJSON(c *testing.T, name, field string) string {
out, err := inspectFilter(name, fmt.Sprintf("json .%s", field)) out, err := inspectFilter(name, fmt.Sprintf("json .%s", field))
if c != nil { if c != nil {
assert.NilError(c, err) assert.NilError(c, err)
@ -115,7 +115,7 @@ func inspectFieldJSON(c *check.C, name, field string) string {
} }
// Deprecated: use cli.Inspect // Deprecated: use cli.Inspect
func inspectFieldMap(c *check.C, name, path, field string) string { func inspectFieldMap(c *testing.T, name, path, field string) string {
out, err := inspectFilter(name, fmt.Sprintf("index .%s %q", path, field)) out, err := inspectFilter(name, fmt.Sprintf("index .%s %q", path, field))
if c != nil { if c != nil {
assert.NilError(c, err) assert.NilError(c, err)
@ -167,7 +167,7 @@ func inspectMountPointJSON(j, destination string) (types.MountPoint, error) {
} }
// Deprecated: use cli.Inspect // Deprecated: use cli.Inspect
func inspectImage(c *check.C, name, filter string) string { func inspectImage(c *testing.T, name, filter string) string {
args := []string{"inspect", "--type", "image"} args := []string{"inspect", "--type", "image"}
if filter != "" { if filter != "" {
format := fmt.Sprintf("{{%s}}", filter) format := fmt.Sprintf("{{%s}}", filter)
@ -179,14 +179,14 @@ func inspectImage(c *check.C, name, filter string) string {
return strings.TrimSpace(result.Combined()) return strings.TrimSpace(result.Combined())
} }
func getIDByName(c *check.C, name string) string { func getIDByName(c *testing.T, name string) string {
id, err := inspectFieldWithError(name, "Id") id, err := inspectFieldWithError(name, "Id")
assert.NilError(c, err) assert.NilError(c, err)
return id return id
} }
// Deprecated: use cli.Build // Deprecated: use cli.Build
func buildImageSuccessfully(c *check.C, name string, cmdOperators ...cli.CmdOperator) { func buildImageSuccessfully(c *testing.T, name string, cmdOperators ...cli.CmdOperator) {
buildImage(name, cmdOperators...).Assert(c, icmd.Success) buildImage(name, cmdOperators...).Assert(c, icmd.Success)
} }
@ -199,7 +199,7 @@ func buildImage(name string, cmdOperators ...cli.CmdOperator) *icmd.Result {
// as well as any missing directories. // as well as any missing directories.
// The file is truncated if it already exists. // The file is truncated if it already exists.
// Fail the test when error occurs. // Fail the test when error occurs.
func writeFile(dst, content string, c *check.C) { func writeFile(dst, content string, c *testing.T) {
// Create subdirectories if necessary // Create subdirectories if necessary
assert.Assert(c, os.MkdirAll(path.Dir(dst), 0700), check.IsNil) assert.Assert(c, os.MkdirAll(path.Dir(dst), 0700), check.IsNil)
f, err := os.OpenFile(dst, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0700) f, err := os.OpenFile(dst, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0700)
@ -212,7 +212,7 @@ func writeFile(dst, content string, c *check.C) {
// Return the contents of file at path `src`. // Return the contents of file at path `src`.
// Fail the test when error occurs. // Fail the test when error occurs.
func readFile(src string, c *check.C) (content string) { func readFile(src string, c *testing.T) (content string) {
data, err := ioutil.ReadFile(src) data, err := ioutil.ReadFile(src)
assert.NilError(c, err) assert.NilError(c, err)
@ -224,7 +224,7 @@ func containerStorageFile(containerID, basename string) string {
} }
// docker commands that use this function must be run with the '-d' switch. // docker commands that use this function must be run with the '-d' switch.
func runCommandAndReadContainerFile(c *check.C, filename string, command string, args ...string) []byte { func runCommandAndReadContainerFile(c *testing.T, filename string, command string, args ...string) []byte {
result := icmd.RunCommand(command, args...) result := icmd.RunCommand(command, args...)
result.Assert(c, icmd.Success) result.Assert(c, icmd.Success)
contID := strings.TrimSpace(result.Combined()) contID := strings.TrimSpace(result.Combined())
@ -234,7 +234,7 @@ func runCommandAndReadContainerFile(c *check.C, filename string, command string,
return readContainerFile(c, contID, filename) return readContainerFile(c, contID, filename)
} }
func readContainerFile(c *check.C, containerID, filename string) []byte { func readContainerFile(c *testing.T, containerID, filename string) []byte {
f, err := os.Open(containerStorageFile(containerID, filename)) f, err := os.Open(containerStorageFile(containerID, filename))
assert.NilError(c, err) assert.NilError(c, err)
defer f.Close() defer f.Close()
@ -244,14 +244,14 @@ func readContainerFile(c *check.C, containerID, filename string) []byte {
return content return content
} }
func readContainerFileWithExec(c *check.C, containerID, filename string) []byte { func readContainerFileWithExec(c *testing.T, containerID, filename string) []byte {
result := icmd.RunCommand(dockerBinary, "exec", containerID, "cat", filename) result := icmd.RunCommand(dockerBinary, "exec", containerID, "cat", filename)
result.Assert(c, icmd.Success) result.Assert(c, icmd.Success)
return []byte(result.Combined()) return []byte(result.Combined())
} }
// daemonTime provides the current time on the daemon host // daemonTime provides the current time on the daemon host
func daemonTime(c *check.C) time.Time { func daemonTime(c *testing.T) time.Time {
if testEnv.IsLocalDaemon() { if testEnv.IsLocalDaemon() {
return time.Now() return time.Now()
} }
@ -269,7 +269,7 @@ func daemonTime(c *check.C) time.Time {
// daemonUnixTime returns the current time on the daemon host with nanoseconds precision. // daemonUnixTime returns the current time on the daemon host with nanoseconds precision.
// It return the time formatted how the client sends timestamps to the server. // It return the time formatted how the client sends timestamps to the server.
func daemonUnixTime(c *check.C) string { func daemonUnixTime(c *testing.T) string {
return parseEventTime(daemonTime(c)) return parseEventTime(daemonTime(c))
} }
@ -304,7 +304,7 @@ func appendBaseEnv(isTLS bool, env ...string) []string {
return env return env
} }
func createTmpFile(c *check.C, content string) string { func createTmpFile(c *testing.T, content string) string {
f, err := ioutil.TempFile("", "testfile") f, err := ioutil.TempFile("", "testfile")
assert.NilError(c, err) assert.NilError(c, err)
@ -335,7 +335,7 @@ func waitInspectWithArgs(name, expr, expected string, timeout time.Duration, arg
return daemon.WaitInspectWithArgs(dockerBinary, name, expr, expected, timeout, arg...) return daemon.WaitInspectWithArgs(dockerBinary, name, expr, expected, timeout, arg...)
} }
func getInspectBody(c *check.C, version, id string) []byte { func getInspectBody(c *testing.T, version, id string) []byte {
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion(version)) cli, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion(version))
assert.NilError(c, err) assert.NilError(c, err)
defer cli.Close() defer cli.Close()
@ -346,13 +346,13 @@ func getInspectBody(c *check.C, version, id string) []byte {
// Run a long running idle task in a background container using the // Run a long running idle task in a background container using the
// system-specific default image and command. // system-specific default image and command.
func runSleepingContainer(c *check.C, extraArgs ...string) string { func runSleepingContainer(c *testing.T, extraArgs ...string) string {
return runSleepingContainerInImage(c, "busybox", extraArgs...) return runSleepingContainerInImage(c, "busybox", extraArgs...)
} }
// Run a long running idle task in a background container using the specified // Run a long running idle task in a background container using the specified
// image and the system-specific command. // image and the system-specific command.
func runSleepingContainerInImage(c *check.C, image string, extraArgs ...string) string { func runSleepingContainerInImage(c *testing.T, image string, extraArgs ...string) string {
args := []string{"run", "-d"} args := []string{"run", "-d"}
args = append(args, extraArgs...) args = append(args, extraArgs...)
args = append(args, image) args = append(args, image)
@ -406,7 +406,7 @@ func waitForGoroutines(expected int) error {
} }
// getErrorMessage returns the error message from an error API response // getErrorMessage returns the error message from an error API response
func getErrorMessage(c *check.C, body []byte) string { func getErrorMessage(c *testing.T, body []byte) string {
var resp types.ErrorResponse var resp types.ErrorResponse
assert.Assert(c, json.Unmarshal(body, &resp), check.IsNil) assert.Assert(c, json.Unmarshal(body, &resp), check.IsNil)
return strings.TrimSpace(resp.Message) return strings.TrimSpace(resp.Message)
@ -421,7 +421,7 @@ func waitAndAssert(t assert.TestingT, timeout time.Duration, f checkF, compariso
after := time.After(timeout) after := time.After(timeout)
for { for {
v, comment := f(t.(*check.C)) v, comment := f(t.(*testing.T))
args = append([]interface{}{v}, args...) args = append([]interface{}{v}, args...)
shouldAssert := assert.Check(t, comparison, args...) shouldAssert := assert.Check(t, comparison, args...)
select { select {
@ -440,11 +440,11 @@ func waitAndAssert(t assert.TestingT, timeout time.Duration, f checkF, compariso
} }
} }
type checkF func(*check.C) (interface{}, check.CommentInterface) type checkF func(*testing.T) (interface{}, check.CommentInterface)
type reducer func(...interface{}) interface{} type reducer func(...interface{}) interface{}
func reducedCheck(r reducer, funcs ...checkF) checkF { func reducedCheck(r reducer, funcs ...checkF) checkF {
return func(c *check.C) (interface{}, check.CommentInterface) { return func(c *testing.T) (interface{}, check.CommentInterface) {
var values []interface{} var values []interface{}
var comments []string var comments []string
for _, f := range funcs { for _, f := range funcs {

View file

@ -35,13 +35,13 @@ type eventObserver struct {
// newEventObserver creates the observer and initializes the command // newEventObserver creates the observer and initializes the command
// without running it. Users must call `eventObserver.Start` to start the command. // without running it. Users must call `eventObserver.Start` to start the command.
func newEventObserver(c *check.C, args ...string) (*eventObserver, error) { func newEventObserver(c *testing.T, args ...string) (*eventObserver, error) {
since := daemonTime(c).Unix() since := daemonTime(c).Unix()
return newEventObserverWithBacklog(c, since, args...) return newEventObserverWithBacklog(c, since, args...)
} }
// newEventObserverWithBacklog creates a new observer changing the start time of the backlog to return. // newEventObserverWithBacklog creates a new observer changing the start time of the backlog to return.
func newEventObserverWithBacklog(c *check.C, since int64, args ...string) (*eventObserver, error) { func newEventObserverWithBacklog(c *testing.T, since int64, args ...string) (*eventObserver, error) {
startTime := strconv.FormatInt(since, 10) startTime := strconv.FormatInt(since, 10)
cmdArgs := []string{"events", "--since", startTime} cmdArgs := []string{"events", "--since", startTime}
if len(args) > 0 { if len(args) > 0 {
@ -93,7 +93,7 @@ func (e *eventObserver) Match(match eventMatcher, process eventMatchProcessor) {
e.disconnectionError = err e.disconnectionError = err
} }
func (e *eventObserver) CheckEventError(c *check.C, id, event string, match eventMatcher) { func (e *eventObserver) CheckEventError(c *testing.T, id, event string, match eventMatcher) {
var foundEvent bool var foundEvent bool
scannerOut := e.buffer.String() scannerOut := e.buffer.String()
@ -144,14 +144,14 @@ func processEventMatch(actions map[string]chan bool) eventMatchProcessor {
// parseEventAction parses an event text and returns the action. // parseEventAction parses an event text and returns the action.
// It fails if the text is not in the event format. // It fails if the text is not in the event format.
func parseEventAction(c *check.C, text string) string { func parseEventAction(c *testing.T, text string) string {
matches := eventstestutils.ScanMap(text) matches := eventstestutils.ScanMap(text)
return matches["action"] return matches["action"]
} }
// eventActionsByIDAndType returns the actions for a given id and type. // eventActionsByIDAndType returns the actions for a given id and type.
// It fails if the text is not in the event format. // It fails if the text is not in the event format.
func eventActionsByIDAndType(c *check.C, events []string, id, eventType string) []string { func eventActionsByIDAndType(c *testing.T, events []string, id, eventType string) []string {
var filtered []string var filtered []string
for _, event := range events { for _, event := range events {
matches := eventstestutils.ScanMap(event) matches := eventstestutils.ScanMap(event)
@ -183,7 +183,7 @@ func matchEventID(matches map[string]string, id string) bool {
return matchID return matchID
} }
func parseEvents(c *check.C, out, match string) { func parseEvents(c *testing.T, out, match string) {
events := strings.Split(strings.TrimSpace(out), "\n") events := strings.Split(strings.TrimSpace(out), "\n")
for _, event := range events { for _, event := range events {
matches := eventstestutils.ScanMap(event) matches := eventstestutils.ScanMap(event)
@ -193,7 +193,7 @@ func parseEvents(c *check.C, out, match string) {
} }
} }
func parseEventsWithID(c *check.C, out, match, id string) { func parseEventsWithID(c *testing.T, out, match, id string) {
events := strings.Split(strings.TrimSpace(out), "\n") events := strings.Split(strings.TrimSpace(out), "\n")
for _, event := range events { for _, event := range events {
matches := eventstestutils.ScanMap(event) matches := eventstestutils.ScanMap(event)

View file

@ -23,7 +23,7 @@ type logT interface {
Logf(string, ...interface{}) Logf(string, ...interface{})
} }
func ensureSyscallTest(c *check.C) { func ensureSyscallTest(c *testing.T) {
defer testEnv.ProtectImage(c, "syscall-test:latest") defer testEnv.ProtectImage(c, "syscall-test:latest")
// If the image already exists, there's nothing left to do. // If the image already exists, there's nothing left to do.
@ -73,7 +73,7 @@ func ensureSyscallTest(c *check.C) {
dockerCmd(c, buildArgs...) dockerCmd(c, buildArgs...)
} }
func ensureSyscallTestBuild(c *check.C) { func ensureSyscallTestBuild(c *testing.T) {
err := load.FrozenImagesLinux(testEnv.APIClient(), "buildpack-deps:jessie") err := load.FrozenImagesLinux(testEnv.APIClient(), "buildpack-deps:jessie")
assert.NilError(c, err) assert.NilError(c, err)
@ -86,7 +86,7 @@ func ensureSyscallTestBuild(c *check.C) {
dockerCmd(c, buildArgs...) dockerCmd(c, buildArgs...)
} }
func ensureNNPTest(c *check.C) { func ensureNNPTest(c *testing.T) {
defer testEnv.ProtectImage(c, "nnp-test:latest") defer testEnv.ProtectImage(c, "nnp-test:latest")
// If the image already exists, there's nothing left to do. // If the image already exists, there's nothing left to do.
@ -128,7 +128,7 @@ func ensureNNPTest(c *check.C) {
dockerCmd(c, buildArgs...) dockerCmd(c, buildArgs...)
} }
func ensureNNPTestBuild(c *check.C) { func ensureNNPTestBuild(c *testing.T) {
err := load.FrozenImagesLinux(testEnv.APIClient(), "buildpack-deps:jessie") err := load.FrozenImagesLinux(testEnv.APIClient(), "buildpack-deps:jessie")
assert.NilError(c, err) assert.NilError(c, err)

View file

@ -118,7 +118,7 @@ type elementListOptions struct {
element, format string element, format string
} }
func existingElements(c *check.C, opts elementListOptions) []string { func existingElements(c *testing.T, opts elementListOptions) []string {
var args []string var args []string
switch opts.element { switch opts.element {
case "container": case "container":
@ -146,12 +146,12 @@ func existingElements(c *check.C, opts elementListOptions) []string {
} }
// ExistingContainerIDs returns a list of currently existing container IDs. // ExistingContainerIDs returns a list of currently existing container IDs.
func ExistingContainerIDs(c *check.C) []string { func ExistingContainerIDs(c *testing.T) []string {
return existingElements(c, elementListOptions{element: "container", format: "{{.ID}}"}) return existingElements(c, elementListOptions{element: "container", format: "{{.ID}}"})
} }
// ExistingContainerNames returns a list of existing container names. // ExistingContainerNames returns a list of existing container names.
func ExistingContainerNames(c *check.C) []string { func ExistingContainerNames(c *testing.T) []string {
return existingElements(c, elementListOptions{element: "container", format: "{{.Names}}"}) return existingElements(c, elementListOptions{element: "container", format: "{{.Names}}"})
} }

View file

@ -13,7 +13,7 @@ type DiscoverySuite struct{}
var _ = check.Suite(&DiscoverySuite{}) var _ = check.Suite(&DiscoverySuite{})
func (s *DiscoverySuite) TestNewEntry(c *check.C) { func (s *DiscoverySuite) TestNewEntry(c *testing.T) {
entry, err := NewEntry("127.0.0.1:2375") entry, err := NewEntry("127.0.0.1:2375")
assert.Assert(c, err, check.IsNil) assert.Assert(c, err, check.IsNil)
assert.Assert(c, entry.Equals(&Entry{Host: "127.0.0.1", Port: "2375"}), check.Equals, true) assert.Assert(c, entry.Equals(&Entry{Host: "127.0.0.1", Port: "2375"}), check.Equals, true)
@ -28,7 +28,7 @@ func (s *DiscoverySuite) TestNewEntry(c *check.C) {
assert.Assert(c, err, check.NotNil) assert.Assert(c, err, check.NotNil)
} }
func (s *DiscoverySuite) TestParse(c *check.C) { func (s *DiscoverySuite) TestParse(c *testing.T) {
scheme, uri := parse("127.0.0.1:2375") scheme, uri := parse("127.0.0.1:2375")
assert.Assert(c, scheme, check.Equals, "nodes") assert.Assert(c, scheme, check.Equals, "nodes")
assert.Assert(c, uri, check.Equals, "127.0.0.1:2375") assert.Assert(c, uri, check.Equals, "127.0.0.1:2375")
@ -50,7 +50,7 @@ func (s *DiscoverySuite) TestParse(c *check.C) {
assert.Assert(c, uri, check.Equals, "") assert.Assert(c, uri, check.Equals, "")
} }
func (s *DiscoverySuite) TestCreateEntries(c *check.C) { func (s *DiscoverySuite) TestCreateEntries(c *testing.T) {
entries, err := CreateEntries(nil) entries, err := CreateEntries(nil)
assert.Assert(c, entries, check.DeepEquals, Entries{}) assert.Assert(c, entries, check.DeepEquals, Entries{})
assert.Assert(c, err, check.IsNil) assert.Assert(c, err, check.IsNil)
@ -68,14 +68,14 @@ func (s *DiscoverySuite) TestCreateEntries(c *check.C) {
assert.Assert(c, err, check.NotNil) assert.Assert(c, err, check.NotNil)
} }
func (s *DiscoverySuite) TestContainsEntry(c *check.C) { func (s *DiscoverySuite) TestContainsEntry(c *testing.T) {
entries, err := CreateEntries([]string{"127.0.0.1:2375", "127.0.0.2:2375", ""}) entries, err := CreateEntries([]string{"127.0.0.1:2375", "127.0.0.2:2375", ""})
assert.Assert(c, err, check.IsNil) assert.Assert(c, err, check.IsNil)
assert.Assert(c, entries.Contains(&Entry{Host: "127.0.0.1", Port: "2375"}), check.Equals, true) assert.Assert(c, entries.Contains(&Entry{Host: "127.0.0.1", Port: "2375"}), check.Equals, true)
assert.Assert(c, entries.Contains(&Entry{Host: "127.0.0.3", Port: "2375"}), check.Equals, false) assert.Assert(c, entries.Contains(&Entry{Host: "127.0.0.3", Port: "2375"}), check.Equals, false)
} }
func (s *DiscoverySuite) TestEntriesEquality(c *check.C) { func (s *DiscoverySuite) TestEntriesEquality(c *testing.T) {
entries := Entries{ entries := Entries{
&Entry{Host: "127.0.0.1", Port: "2375"}, &Entry{Host: "127.0.0.1", Port: "2375"},
&Entry{Host: "127.0.0.2", Port: "2375"}, &Entry{Host: "127.0.0.2", Port: "2375"},
@ -102,7 +102,7 @@ func (s *DiscoverySuite) TestEntriesEquality(c *check.C) {
} }
func (s *DiscoverySuite) TestEntriesDiff(c *check.C) { func (s *DiscoverySuite) TestEntriesDiff(c *testing.T) {
entry1 := &Entry{Host: "1.1.1.1", Port: "1111"} entry1 := &Entry{Host: "1.1.1.1", Port: "1111"}
entry2 := &Entry{Host: "2.2.2.2", Port: "2222"} entry2 := &Entry{Host: "2.2.2.2", Port: "2222"}
entry3 := &Entry{Host: "3.3.3.3", Port: "3333"} entry3 := &Entry{Host: "3.3.3.3", Port: "3333"}

View file

@ -17,19 +17,19 @@ type DiscoverySuite struct{}
var _ = check.Suite(&DiscoverySuite{}) var _ = check.Suite(&DiscoverySuite{})
func (s *DiscoverySuite) TestInitialize(c *check.C) { func (s *DiscoverySuite) TestInitialize(c *testing.T) {
d := &Discovery{} d := &Discovery{}
d.Initialize("/path/to/file", 1000, 0, nil) d.Initialize("/path/to/file", 1000, 0, nil)
assert.Assert(c, d.path, check.Equals, "/path/to/file") assert.Assert(c, d.path, check.Equals, "/path/to/file")
} }
func (s *DiscoverySuite) TestNew(c *check.C) { func (s *DiscoverySuite) TestNew(c *testing.T) {
d, err := discovery.New("file:///path/to/file", 0, 0, nil) d, err := discovery.New("file:///path/to/file", 0, 0, nil)
assert.Assert(c, err, check.IsNil) assert.Assert(c, err, check.IsNil)
assert.Assert(c, d.(*Discovery).path, check.Equals, "/path/to/file") assert.Assert(c, d.(*Discovery).path, check.Equals, "/path/to/file")
} }
func (s *DiscoverySuite) TestContent(c *check.C) { func (s *DiscoverySuite) TestContent(c *testing.T) {
data := ` data := `
1.1.1.[1:2]:1111 1.1.1.[1:2]:1111
2.2.2.[2:4]:2222 2.2.2.[2:4]:2222
@ -43,12 +43,12 @@ func (s *DiscoverySuite) TestContent(c *check.C) {
assert.Assert(c, ips[4], check.Equals, "2.2.2.4:2222") assert.Assert(c, ips[4], check.Equals, "2.2.2.4:2222")
} }
func (s *DiscoverySuite) TestRegister(c *check.C) { func (s *DiscoverySuite) TestRegister(c *testing.T) {
discovery := &Discovery{path: "/path/to/file"} discovery := &Discovery{path: "/path/to/file"}
assert.Assert(c, discovery.Register("0.0.0.0"), check.NotNil) assert.Assert(c, discovery.Register("0.0.0.0"), check.NotNil)
} }
func (s *DiscoverySuite) TestParsingContentsWithComments(c *check.C) { func (s *DiscoverySuite) TestParsingContentsWithComments(c *testing.T) {
data := ` data := `
### test ### ### test ###
1.1.1.1:1111 # inline comment 1.1.1.1:1111 # inline comment
@ -63,7 +63,7 @@ func (s *DiscoverySuite) TestParsingContentsWithComments(c *check.C) {
assert.Assert(c, "3.3.3.3:3333", check.Equals, ips[1]) assert.Assert(c, "3.3.3.3:3333", check.Equals, ips[1])
} }
func (s *DiscoverySuite) TestWatch(c *check.C) { func (s *DiscoverySuite) TestWatch(c *testing.T) {
data := ` data := `
1.1.1.1:1111 1.1.1.1:1111
2.2.2.2:2222 2.2.2.2:2222

View file

@ -4,25 +4,25 @@ import (
"github.com/go-check/check" "github.com/go-check/check"
) )
func (s *DiscoverySuite) TestGeneratorNotGenerate(c *check.C) { func (s *DiscoverySuite) TestGeneratorNotGenerate(c *testing.T) {
ips := Generate("127.0.0.1") ips := Generate("127.0.0.1")
assert.Assert(c, len(ips), check.Equals, 1) assert.Assert(c, len(ips), check.Equals, 1)
assert.Assert(c, ips[0], check.Equals, "127.0.0.1") assert.Assert(c, ips[0], check.Equals, "127.0.0.1")
} }
func (s *DiscoverySuite) TestGeneratorWithPortNotGenerate(c *check.C) { func (s *DiscoverySuite) TestGeneratorWithPortNotGenerate(c *testing.T) {
ips := Generate("127.0.0.1:8080") ips := Generate("127.0.0.1:8080")
assert.Assert(c, len(ips), check.Equals, 1) assert.Assert(c, len(ips), check.Equals, 1)
assert.Assert(c, ips[0], check.Equals, "127.0.0.1:8080") assert.Assert(c, ips[0], check.Equals, "127.0.0.1:8080")
} }
func (s *DiscoverySuite) TestGeneratorMatchFailedNotGenerate(c *check.C) { func (s *DiscoverySuite) TestGeneratorMatchFailedNotGenerate(c *testing.T) {
ips := Generate("127.0.0.[1]") ips := Generate("127.0.0.[1]")
assert.Assert(c, len(ips), check.Equals, 1) assert.Assert(c, len(ips), check.Equals, 1)
assert.Assert(c, ips[0], check.Equals, "127.0.0.[1]") assert.Assert(c, ips[0], check.Equals, "127.0.0.[1]")
} }
func (s *DiscoverySuite) TestGeneratorWithPort(c *check.C) { func (s *DiscoverySuite) TestGeneratorWithPort(c *testing.T) {
ips := Generate("127.0.0.[1:11]:2375") ips := Generate("127.0.0.[1:11]:2375")
assert.Assert(c, len(ips), check.Equals, 11) assert.Assert(c, len(ips), check.Equals, 11)
assert.Assert(c, ips[0], check.Equals, "127.0.0.1:2375") assert.Assert(c, ips[0], check.Equals, "127.0.0.1:2375")
@ -38,14 +38,14 @@ func (s *DiscoverySuite) TestGeneratorWithPort(c *check.C) {
assert.Assert(c, ips[10], check.Equals, "127.0.0.11:2375") assert.Assert(c, ips[10], check.Equals, "127.0.0.11:2375")
} }
func (s *DiscoverySuite) TestGenerateWithMalformedInputAtRangeStart(c *check.C) { func (s *DiscoverySuite) TestGenerateWithMalformedInputAtRangeStart(c *testing.T) {
malformedInput := "127.0.0.[x:11]:2375" malformedInput := "127.0.0.[x:11]:2375"
ips := Generate(malformedInput) ips := Generate(malformedInput)
assert.Assert(c, len(ips), check.Equals, 1) assert.Assert(c, len(ips), check.Equals, 1)
assert.Assert(c, ips[0], check.Equals, malformedInput) assert.Assert(c, ips[0], check.Equals, malformedInput)
} }
func (s *DiscoverySuite) TestGenerateWithMalformedInputAtRangeEnd(c *check.C) { func (s *DiscoverySuite) TestGenerateWithMalformedInputAtRangeEnd(c *testing.T) {
malformedInput := "127.0.0.[1:x]:2375" malformedInput := "127.0.0.[1:x]:2375"
ips := Generate(malformedInput) ips := Generate(malformedInput)
assert.Assert(c, len(ips), check.Equals, 1) assert.Assert(c, len(ips), check.Equals, 1)

View file

@ -21,7 +21,7 @@ type DiscoverySuite struct{}
var _ = check.Suite(&DiscoverySuite{}) var _ = check.Suite(&DiscoverySuite{})
func (ds *DiscoverySuite) TestInitialize(c *check.C) { func (ds *DiscoverySuite) TestInitialize(c *testing.T) {
storeMock := &FakeStore{ storeMock := &FakeStore{
Endpoints: []string{"127.0.0.1"}, Endpoints: []string{"127.0.0.1"},
} }
@ -131,7 +131,7 @@ func (s *Mock) AtomicDelete(key string, previous *store.KVPair) (bool, error) {
func (s *Mock) Close() { func (s *Mock) Close() {
} }
func (ds *DiscoverySuite) TestInitializeWithCerts(c *check.C) { func (ds *DiscoverySuite) TestInitializeWithCerts(c *testing.T) {
cert := `-----BEGIN CERTIFICATE----- cert := `-----BEGIN CERTIFICATE-----
MIIDCDCCAfKgAwIBAgIICifG7YeiQOEwCwYJKoZIhvcNAQELMBIxEDAOBgNVBAMT MIIDCDCCAfKgAwIBAgIICifG7YeiQOEwCwYJKoZIhvcNAQELMBIxEDAOBgNVBAMT
B1Rlc3QgQ0EwHhcNMTUxMDAxMjMwMDAwWhcNMjAwOTI5MjMwMDAwWjASMRAwDgYD B1Rlc3QgQ0EwHhcNMTUxMDAxMjMwMDAwWhcNMjAwOTI5MjMwMDAwWjASMRAwDgYD
@ -205,7 +205,7 @@ BFrwkQE4HQtQBV60hYQUzzlSk44VFDz+jxIEtacRHaomDRh2FtOTz+I=
assert.Assert(c, s.Options.TLS.Certificates, check.HasLen, 1) assert.Assert(c, s.Options.TLS.Certificates, check.HasLen, 1)
} }
func (ds *DiscoverySuite) TestWatch(c *check.C) { func (ds *DiscoverySuite) TestWatch(c *testing.T) {
mockCh := make(chan []*store.KVPair) mockCh := make(chan []*store.KVPair)
storeMock := &FakeStore{ storeMock := &FakeStore{

View file

@ -14,7 +14,7 @@ type discoverySuite struct{}
var _ = check.Suite(&discoverySuite{}) var _ = check.Suite(&discoverySuite{})
func (s *discoverySuite) TestWatch(c *check.C) { func (s *discoverySuite) TestWatch(c *testing.T) {
d := &Discovery{} d := &Discovery{}
d.Initialize("foo", 1000, 0, nil) d.Initialize("foo", 1000, 0, nil)
stopCh := make(chan struct{}) stopCh := make(chan struct{})

View file

@ -15,7 +15,7 @@ type DiscoverySuite struct{}
var _ = check.Suite(&DiscoverySuite{}) var _ = check.Suite(&DiscoverySuite{})
func (s *DiscoverySuite) TestInitialize(c *check.C) { func (s *DiscoverySuite) TestInitialize(c *testing.T) {
d := &Discovery{} d := &Discovery{}
d.Initialize("1.1.1.1:1111,2.2.2.2:2222", 0, 0, nil) d.Initialize("1.1.1.1:1111,2.2.2.2:2222", 0, 0, nil)
assert.Assert(c, len(d.entries), check.Equals, 2) assert.Assert(c, len(d.entries), check.Equals, 2)
@ -23,7 +23,7 @@ func (s *DiscoverySuite) TestInitialize(c *check.C) {
assert.Assert(c, d.entries[1].String(), check.Equals, "2.2.2.2:2222") assert.Assert(c, d.entries[1].String(), check.Equals, "2.2.2.2:2222")
} }
func (s *DiscoverySuite) TestInitializeWithPattern(c *check.C) { func (s *DiscoverySuite) TestInitializeWithPattern(c *testing.T) {
d := &Discovery{} d := &Discovery{}
d.Initialize("1.1.1.[1:2]:1111,2.2.2.[2:4]:2222", 0, 0, nil) d.Initialize("1.1.1.[1:2]:1111,2.2.2.[2:4]:2222", 0, 0, nil)
assert.Assert(c, len(d.entries), check.Equals, 5) assert.Assert(c, len(d.entries), check.Equals, 5)
@ -34,7 +34,7 @@ func (s *DiscoverySuite) TestInitializeWithPattern(c *check.C) {
assert.Assert(c, d.entries[4].String(), check.Equals, "2.2.2.4:2222") assert.Assert(c, d.entries[4].String(), check.Equals, "2.2.2.4:2222")
} }
func (s *DiscoverySuite) TestWatch(c *check.C) { func (s *DiscoverySuite) TestWatch(c *testing.T) {
d := &Discovery{} d := &Discovery{}
d.Initialize("1.1.1.1:1111,2.2.2.2:2222", 0, 0, nil) d.Initialize("1.1.1.1:1111,2.2.2.2:2222", 0, 0, nil)
expected := discovery.Entries{ expected := discovery.Entries{
@ -45,7 +45,7 @@ func (s *DiscoverySuite) TestWatch(c *check.C) {
assert.Assert(c, expected.Equals(<-ch), check.Equals, true) assert.Assert(c, expected.Equals(<-ch), check.Equals, true)
} }
func (s *DiscoverySuite) TestRegister(c *check.C) { func (s *DiscoverySuite) TestRegister(c *testing.T) {
d := &Discovery{} d := &Discovery{}
assert.Assert(c, d.Register("0.0.0.0"), check.NotNil) assert.Assert(c, d.Register("0.0.0.0"), check.NotNil)
} }