1f69c62540
sed -E -i 's#\bc\.Assert\(#assert.Assert(c, #g' \ -- "integration-cli/docker_api_containers_test.go" "integration-cli/docker_api_swarm_node_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_to_container_test.go" "integration-cli/docker_cli_create_test.go" "integration-cli/docker_cli_daemon_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_netmode_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_plugins_test.go" "integration-cli/docker_cli_port_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_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_service_create_test.go" "integration-cli/docker_cli_service_health_test.go" "integration-cli/docker_cli_start_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_userns_test.go" "integration-cli/docker_cli_volume_test.go" "integration-cli/docker_hub_pull_suite_test.go" "integration-cli/docker_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>
90 lines
2.8 KiB
Go
90 lines
2.8 KiB
Go
package main
|
|
|
|
import (
|
|
"os/exec"
|
|
"runtime"
|
|
"strings"
|
|
|
|
"github.com/docker/docker/integration-cli/checker"
|
|
"github.com/docker/docker/integration-cli/daemon"
|
|
testdaemon "github.com/docker/docker/internal/test/daemon"
|
|
"github.com/go-check/check"
|
|
)
|
|
|
|
func init() {
|
|
// FIXME. Temporarily turning this off for Windows as GH16039 was breaking
|
|
// Windows to Linux CI @icecrime
|
|
if runtime.GOOS != "windows" {
|
|
check.Suite(newDockerHubPullSuite())
|
|
}
|
|
}
|
|
|
|
// DockerHubPullSuite provides an isolated daemon that doesn't have all the
|
|
// images that are baked into our 'global' test environment daemon (e.g.,
|
|
// busybox, httpserver, ...).
|
|
//
|
|
// We use it for push/pull tests where we want to start fresh, and measure the
|
|
// relative impact of each individual operation. As part of this suite, all
|
|
// images are removed after each test.
|
|
type DockerHubPullSuite struct {
|
|
d *daemon.Daemon
|
|
ds *DockerSuite
|
|
}
|
|
|
|
// newDockerHubPullSuite returns a new instance of a DockerHubPullSuite.
|
|
func newDockerHubPullSuite() *DockerHubPullSuite {
|
|
return &DockerHubPullSuite{
|
|
ds: &DockerSuite{},
|
|
}
|
|
}
|
|
|
|
// SetUpSuite starts the suite daemon.
|
|
func (s *DockerHubPullSuite) SetUpSuite(c *check.C) {
|
|
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
|
|
s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
|
|
s.d.Start(c)
|
|
}
|
|
|
|
// TearDownSuite stops the suite daemon.
|
|
func (s *DockerHubPullSuite) TearDownSuite(c *check.C) {
|
|
if s.d != nil {
|
|
s.d.Stop(c)
|
|
}
|
|
}
|
|
|
|
// SetUpTest declares that all tests of this suite require network.
|
|
func (s *DockerHubPullSuite) SetUpTest(c *check.C) {
|
|
testRequires(c, Network)
|
|
}
|
|
|
|
// TearDownTest removes all images from the suite daemon.
|
|
func (s *DockerHubPullSuite) TearDownTest(c *check.C) {
|
|
out := s.Cmd(c, "images", "-aq")
|
|
images := strings.Split(out, "\n")
|
|
images = append([]string{"rmi", "-f"}, images...)
|
|
s.d.Cmd(images...)
|
|
s.ds.TearDownTest(c)
|
|
}
|
|
|
|
// Cmd executes a command against the suite daemon and returns the combined
|
|
// output. The function fails the test when the command returns an error.
|
|
func (s *DockerHubPullSuite) Cmd(c *check.C, name string, arg ...string) string {
|
|
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))
|
|
return out
|
|
}
|
|
|
|
// CmdWithError executes a command against the suite daemon and returns the
|
|
// combined output as well as any error.
|
|
func (s *DockerHubPullSuite) CmdWithError(name string, arg ...string) (string, error) {
|
|
c := s.MakeCmd(name, arg...)
|
|
b, err := c.CombinedOutput()
|
|
return string(b), err
|
|
}
|
|
|
|
// MakeCmd returns an exec.Cmd command to run against the suite daemon.
|
|
func (s *DockerHubPullSuite) MakeCmd(name string, arg ...string) *exec.Cmd {
|
|
args := []string{"--host", s.d.Sock(), name}
|
|
args = append(args, arg...)
|
|
return exec.Command(dockerBinary, args...)
|
|
}
|