Merge pull request #383 from thaJeztah/19.03_backport_test_fixes_2
[19.03 backport] Testing and Jenkinsfile changes [step 2]
diff --git a/Jenkinsfile b/Jenkinsfile
index efc859f..4c5439c 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -307,10 +307,10 @@
TEST_INTEGRATION_DEST=1 CONTAINER_NAME=${CONTAINER_NAME}-1 TEST_SKIP_INTEGRATION_CLI=1 run_tests test-integration-flaky &
# integration-cli first set
- TEST_INTEGRATION_DEST=2 CONTAINER_NAME=${CONTAINER_NAME}-2 TEST_SKIP_INTEGRATION=1 TESTFLAGS="-check.f ^(DockerSuite|DockerNetworkSuite|DockerHubPullSuite|DockerRegistrySuite|DockerSchema1RegistrySuite|DockerRegistryAuthTokenSuite|DockerRegistryAuthHtpasswdSuite)" run_tests &
+ TEST_INTEGRATION_DEST=2 CONTAINER_NAME=${CONTAINER_NAME}-2 TEST_SKIP_INTEGRATION=1 TESTFLAGS="-test.run Test(DockerSuite|DockerNetworkSuite|DockerHubPullSuite|DockerRegistrySuite|DockerSchema1RegistrySuite|DockerRegistryAuthTokenSuite|DockerRegistryAuthHtpasswdSuite)/" run_tests &
# integration-cli second set
- TEST_INTEGRATION_DEST=3 CONTAINER_NAME=${CONTAINER_NAME}-3 TEST_SKIP_INTEGRATION=1 TESTFLAGS="-check.f ^(DockerSwarmSuite|DockerDaemonSuite|DockerExternalVolumeSuite)" run_tests &
+ TEST_INTEGRATION_DEST=3 CONTAINER_NAME=${CONTAINER_NAME}-3 TEST_SKIP_INTEGRATION=1 TESTFLAGS="-test.run Test(DockerSwarmSuite|DockerDaemonSuite|DockerExternalVolumeSuite)/" run_tests &
set +x
c=0
diff --git a/daemon/bindmount_unix.go b/daemon/bindmount_unix.go
deleted file mode 100644
index 028e300..0000000
--- a/daemon/bindmount_unix.go
+++ /dev/null
@@ -1,5 +0,0 @@
-// +build linux freebsd
-
-package daemon // import "github.com/docker/docker/daemon"
-
-const bindMountType = "bind"
diff --git a/daemon/volumes_unix.go b/daemon/volumes_unix.go
index 5b47c46..3f4c5ff 100644
--- a/daemon/volumes_unix.go
+++ b/daemon/volumes_unix.go
@@ -141,10 +141,6 @@
if m.Writable {
writeMode = "rw"
}
- opts := strings.Join([]string{bindMode, writeMode}, ",")
- if err := mount.Mount(m.Source, dest, bindMountType, opts); err != nil {
- return err
- }
// mountVolumes() seems to be called for temporary mounts
// outside the container. Soon these will be unmounted with
@@ -154,8 +150,9 @@
// then these unmounts will propagate and unmount original
// mount as well. So make all these mounts rprivate.
// Do not use propagation property of volume as that should
- // apply only when mounting happen inside the container.
- if err := mount.MakeRPrivate(dest); err != nil {
+ // apply only when mounting happens inside the container.
+ opts := strings.Join([]string{bindMode, writeMode, "rprivate"}, ",")
+ if err := mount.Mount(m.Source, dest, "", opts); err != nil {
return err
}
}
diff --git a/docs/contributing/test.md b/docs/contributing/test.md
index ada9aa6..47f03f0 100644
--- a/docs/contributing/test.md
+++ b/docs/contributing/test.md
@@ -174,13 +174,13 @@
your local host you can run the `TestBuild` test with this command:
```bash
-$ TESTFLAGS='-check.f DockerSuite.TestBuild*' make test-integration
+$ TESTFLAGS='-test.run TestDockerSuite/TestBuild*' make test-integration
```
To run the same test inside your Docker development container, you do this:
```bash
-# TESTFLAGS='-check.f TestBuild*' hack/make.sh binary test-integration
+# TESTFLAGS='-test.run TestDockerSuite/TestBuild*' hack/make.sh binary test-integration
```
## Test the Windows binary against a Linux daemon
@@ -228,11 +228,11 @@
```
Should you wish to run a single test such as one with the name
- 'TestExample', you can pass in `TESTFLAGS='-check.f TestExample'`. For
+ 'TestExample', you can pass in `TESTFLAGS='-test.run /TestExample'`. For
example
```bash
- $ TESTFLAGS='-check.f TestExample' hack/make.sh binary test-integration
+ $ TESTFLAGS='-test.run /TestExample' hack/make.sh binary test-integration
```
You can now choose to make changes to the Moby source or the tests. If you
diff --git a/hack/ci/windows.ps1 b/hack/ci/windows.ps1
index 19929f3..04291c5 100644
--- a/hack/ci/windows.ps1
+++ b/hack/ci/windows.ps1
@@ -831,14 +831,13 @@
#https://blogs.technet.microsoft.com/heyscriptingguy/2011/09/20/solve-problems-with-external-command-lines-in-powershell/ is useful to see tokenising
$c = "go test "
- $c += "`"-check.v`" "
+ $c += "`"-test.v`" "
if ($null -ne $env:INTEGRATION_TEST_NAME) { # Makes is quicker for debugging to be able to run only a subset of the integration tests
- $c += "`"-check.f`" "
+ $c += "`"-test.run`" "
$c += "`"$env:INTEGRATION_TEST_NAME`" "
Write-Host -ForegroundColor Magenta "WARN: Only running integration tests matching $env:INTEGRATION_TEST_NAME"
}
$c += "`"-tags`" " + "`"autogen`" "
- $c += "`"-check.timeout`" " + "`"10m`" "
$c += "`"-test.timeout`" " + "`"200m`" "
if ($null -ne $env:INTEGRATION_IN_CONTAINER) {
@@ -926,14 +925,13 @@
} else {
#https://blogs.technet.microsoft.com/heyscriptingguy/2011/09/20/solve-problems-with-external-command-lines-in-powershell/ is useful to see tokenising
$c = "go test "
- $c += "`"-check.v`" "
+ $c += "`"-test.v`" "
if ($null -ne $env:INTEGRATION_TEST_NAME) { # Makes is quicker for debugging to be able to run only a subset of the integration tests
- $c += "`"-check.f`" "
+ $c += "`"-test.run`" "
$c += "`"$env:INTEGRATION_TEST_NAME`" "
Write-Host -ForegroundColor Magenta "WARN: Only running LCOW integration tests matching $env:INTEGRATION_TEST_NAME"
}
$c += "`"-tags`" " + "`"autogen`" "
- $c += "`"-check.timeout`" " + "`"10m`" "
$c += "`"-test.timeout`" " + "`"200m`" "
Write-Host -ForegroundColor Green "INFO: LCOW Integration tests being run from the host:"
diff --git a/hack/make/.integration-test-helpers b/hack/make/.integration-test-helpers
index 91179c9..b266013 100644
--- a/hack/make/.integration-test-helpers
+++ b/hack/make/.integration-test-helpers
@@ -3,20 +3,9 @@
# For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want
# to run certain tests on your local host, you should run with command:
#
-# TESTFLAGS='-check.f DockerSuite.TestBuild*' ./hack/make.sh binary test-integration
+# TESTFLAGS='-test.run TestDockerSuite/TestBuild*' ./hack/make.sh binary test-integration
#
-if [[ "${TESTFLAGS}" = *-check.f* ]]; then
- echo Skipping integration tests since TESTFLAGS includes integration-cli only flags
- TEST_SKIP_INTEGRATION=1
-fi
-
-if [[ "${TESTFLAGS}" = *-test.run* ]]; then
- echo Skipping integration-cli tests since TESTFLAGS includes integration only flags
- TEST_SKIP_INTEGRATION_CLI=1
-fi
-
-
if [ -z "${MAKEDIR}" ]; then
MAKEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export MAKEDIR
@@ -32,24 +21,22 @@
if [ -z "${TEST_FILTER}" ]; then
return
fi
+ TESTFLAGS+="-test.run ${TEST_FILTER}"
+ local dirs
+ dirs=$(grep -rIlE --include '*_test.go' "func .*${TEST_FILTER}.*\(. \*testing\.T\)" ./integration*/ | xargs -I file dirname file | uniq)
if [ -z "${TEST_SKIP_INTEGRATION}" ]; then
- : "${TEST_INTEGRATION_DIR:=$(grep -rl "func\ .*${TEST_FILTER}.*\(t\ \*testing\.T\)" ./integration | grep '_test\.go' | xargs -I file dirname file | uniq)}"
+ : "${TEST_INTEGRATION_DIR:=$(echo "$dirs" | grep -v '^\./integration-cli$')}"
if [ -z "${TEST_INTEGRATION_DIR}" ]; then
echo "Skipping integration tests since the supplied filter \"${TEST_FILTER}\" omits all integration tests"
TEST_SKIP_INTEGRATION=1
- else
- TESTFLAGS_INTEGRATION+="-test.run ${TEST_FILTER}"
fi
fi
if [ -z "${TEST_SKIP_INTEGRATION_CLI}" ]; then
- # ease up on the filtering here since CLI suites are namespaced by an object
- if grep -r "${TEST_FILTER}.*\(c\ \*check\.C\)" ./integration-cli | grep -q '_test\.go$'; then
+ if echo "$dirs" | grep -vq '^./integration-cli$'; then
TEST_SKIP_INTEGRATION_CLI=1
echo "Skipping integration-cli tests since the supplied filter \"${TEST_FILTER}\" omits all integration-cli tests"
- else
- TESTFLAGS_INTEGRATION_CLI+="-check.f ${TEST_FILTER}"
fi
fi
}
@@ -60,16 +47,17 @@
run_test_integration() {
set_platform_timeout
if [ -z "${TEST_SKIP_INTEGRATION}" ]; then
- run_test_integration_suites
+ run_test_integration_suites "${integration_api_dirs}"
fi
if [ -z "${TEST_SKIP_INTEGRATION_CLI}" ]; then
- run_test_integration_legacy_suites
+ TIMEOUT=360m run_test_integration_suites integration-cli
fi
}
run_test_integration_suites() {
- local flags="-test.v -test.timeout=${TIMEOUT} $TESTFLAGS ${TESTFLAGS_INTEGRATION}"
- for dir in ${integration_api_dirs}; do
+ local flags="-test.v -test.timeout=${TIMEOUT} $TESTFLAGS"
+ local dirs="$1"
+ for dir in ${dirs}; do
if ! (
cd "$dir"
# Create a useful package name based on the tests's $dir. We need to take
@@ -97,16 +85,6 @@
done
}
-run_test_integration_legacy_suites() {
- (
- flags="-check.v -check.timeout=${TIMEOUT} -test.timeout=360m $TESTFLAGS ${TESTFLAGS_INTEGRATION_CLI}"
- cd integration-cli
- echo "Running $PWD flags=${flags}"
- # shellcheck disable=SC2086
- test_env ./test.main $flags
- )
-}
-
build_test_suite_binaries() {
if [ -n "${DOCKER_INTEGRATION_TESTS_VERIFIED}" ]; then
echo "Skipping building test binaries; as DOCKER_INTEGRATION_TESTS_VERIFIED is set"
diff --git a/hack/test/e2e-run.sh b/hack/test/e2e-run.sh
index 6463f2f..4ca1d35 100755
--- a/hack/test/e2e-run.sh
+++ b/hack/test/e2e-run.sh
@@ -18,12 +18,8 @@
run_test_integration() {
set_platform_timeout
- if [[ "$TESTFLAGS" != *-check.f* ]]; then
- run_test_integration_suites
- fi
- if [[ "$TESTFLAGS" != *-test.run* ]]; then
- run_test_integration_legacy_suites
- fi
+ run_test_integration_suites
+ run_test_integration_legacy_suites
}
run_test_integration_suites() {
@@ -39,7 +35,7 @@
run_test_integration_legacy_suites() {
(
- flags="-check.v -check.timeout=${TIMEOUT:-200m} -test.timeout=360m $TESTFLAGS"
+ flags="-test.v -test.timeout=360m $TESTFLAGS"
cd /tests/integration-cli
echo "Running $PWD"
test_env ./test.main $flags
diff --git a/hack/test/unit b/hack/test/unit
index 1aea06c..a47a939 100755
--- a/hack/test/unit
+++ b/hack/test/unit
@@ -13,7 +13,7 @@
set -eu -o pipefail
BUILDFLAGS=( -tags 'netgo seccomp libdm_no_deferred_remove' )
-TESTFLAGS+="-test.timeout=${TIMEOUT:-5m}"
+TESTFLAGS+=" -test.timeout=${TIMEOUT:-5m}"
TESTDIRS="${TESTDIRS:-./...}"
exclude_paths='/vendor/|/integration'
pkg_list=$(go list $TESTDIRS | grep -vE "($exclude_paths)")
diff --git a/hack/validate/default b/hack/validate/default
index 15ed836..765a413 100755
--- a/hack/validate/default
+++ b/hack/validate/default
@@ -10,7 +10,6 @@
. ${SCRIPTDIR}/pkg-imports
. ${SCRIPTDIR}/swagger
. ${SCRIPTDIR}/swagger-gen
-. ${SCRIPTDIR}/test-imports
. ${SCRIPTDIR}/toml
. ${SCRIPTDIR}/changelog-well-formed
. ${SCRIPTDIR}/changelog-date-descending
diff --git a/hack/validate/test-imports b/hack/validate/test-imports
deleted file mode 100755
index 0e836a3..0000000
--- a/hack/validate/test-imports
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/usr/bin/env bash
-# Make sure we're not using gos' Testing package any more in integration-cli
-
-export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-source "${SCRIPTDIR}/.validate"
-
-IFS=$'\n'
-files=( $(validate_diff --diff-filter=ACMR --name-only -- 'integration-cli/*.go' || true) )
-unset IFS
-
-badFiles=()
-for f in "${files[@]}"; do
- # skip check_test.go since it *does* use the testing package
- if [ "$f" = "integration-cli/check_test.go" ]; then
- continue
- fi
-
- # we use "git show" here to validate that what's committed doesn't contain golang built-in testing
- if git show "$VALIDATE_HEAD:$f" | grep -q testing.T; then
- if [ "$(echo $f | grep '_test')" ]; then
- # allow testing.T for non- _test files
- badFiles+=( "$f" )
- fi
- fi
-done
-
-if [ ${#badFiles[@]} -eq 0 ]; then
- echo 'Congratulations! No testing.T found.'
-else
- {
- echo "These files use the wrong testing infrastructure:"
- for f in "${badFiles[@]}"; do
- echo " - $f"
- done
- echo
- } >&2
- false
-fi
diff --git a/integration-cli/benchmark_test.go b/integration-cli/benchmark_test.go
index 47f164f..8fb9a7b 100644
--- a/integration-cli/benchmark_test.go
+++ b/integration-cli/benchmark_test.go
@@ -7,12 +7,12 @@
"runtime"
"strings"
"sync"
+ "testing"
- "github.com/go-check/check"
"gotest.tools/assert"
)
-func (s *DockerSuite) BenchmarkConcurrentContainerActions(c *check.C) {
+func (s *DockerSuite) BenchmarkConcurrentContainerActions(c *testing.B) {
maxConcurrency := runtime.GOMAXPROCS(0)
numIterations := c.N
outerGroup := &sync.WaitGroup{}
diff --git a/integration-cli/check_test.go b/integration-cli/check_test.go
index 4fd9a10..5527006 100644
--- a/integration-cli/check_test.go
+++ b/integration-cli/check_test.go
@@ -2,6 +2,7 @@
import (
"context"
+ "flag"
"fmt"
"io/ioutil"
"net/http/httptest"
@@ -22,8 +23,8 @@
"github.com/docker/docker/internal/test/fakestorage"
"github.com/docker/docker/internal/test/fixtures/plugin"
"github.com/docker/docker/internal/test/registry"
+ "github.com/docker/docker/internal/test/suite"
"github.com/docker/docker/pkg/reexec"
- "github.com/go-check/check"
"gotest.tools/assert"
)
@@ -43,6 +44,8 @@
// the docker client binary to use
dockerBinary = ""
+
+ testEnvOnce sync.Once
)
func init() {
@@ -58,6 +61,9 @@
}
func TestMain(m *testing.M) {
+ flag.Parse()
+
+ // Global set up
dockerBinary = testEnv.DockerBinary()
err := ienv.EnsureFrozenImagesLinux(&testEnv.Execution)
if err != nil {
@@ -69,21 +75,78 @@
os.Exit(m.Run())
}
-func Test(t *testing.T) {
- cli.SetTestEnvironment(testEnv)
- fakestorage.SetTestEnvironment(&testEnv.Execution)
- ienv.ProtectAll(t, &testEnv.Execution)
- check.TestingT(t)
+func ensureTestEnvSetup(t *testing.T) {
+ testEnvOnce.Do(func() {
+ cli.SetTestEnvironment(testEnv)
+ fakestorage.SetTestEnvironment(&testEnv.Execution)
+ ienv.ProtectAll(t, &testEnv.Execution)
+ })
}
-func init() {
- check.Suite(&DockerSuite{})
+func TestDockerSuite(t *testing.T) {
+ ensureTestEnvSetup(t)
+ suite.Run(t, &DockerSuite{})
+}
+
+func TestDockerRegistrySuite(t *testing.T) {
+ ensureTestEnvSetup(t)
+ suite.Run(t, &DockerRegistrySuite{ds: &DockerSuite{}})
+}
+
+func TestDockerSchema1RegistrySuite(t *testing.T) {
+ ensureTestEnvSetup(t)
+ suite.Run(t, &DockerSchema1RegistrySuite{ds: &DockerSuite{}})
+}
+
+func TestDockerRegistryAuthHtpasswdSuite(t *testing.T) {
+ ensureTestEnvSetup(t)
+ suite.Run(t, &DockerRegistryAuthHtpasswdSuite{ds: &DockerSuite{}})
+}
+
+func TestDockerRegistryAuthTokenSuite(t *testing.T) {
+ ensureTestEnvSetup(t)
+ suite.Run(t, &DockerRegistryAuthTokenSuite{ds: &DockerSuite{}})
+}
+
+func TestDockerDaemonSuite(t *testing.T) {
+ ensureTestEnvSetup(t)
+ suite.Run(t, &DockerDaemonSuite{ds: &DockerSuite{}})
+}
+
+func TestDockerSwarmSuite(t *testing.T) {
+ ensureTestEnvSetup(t)
+ suite.Run(t, &DockerSwarmSuite{ds: &DockerSuite{}})
+}
+
+func TestDockerPluginSuite(t *testing.T) {
+ ensureTestEnvSetup(t)
+ suite.Run(t, &DockerPluginSuite{ds: &DockerSuite{}})
+}
+
+func TestDockerExternalVolumeSuite(t *testing.T) {
+ ensureTestEnvSetup(t)
+ testRequires(t, DaemonIsLinux)
+ suite.Run(t, &DockerExternalVolumeSuite{ds: &DockerSuite{}})
+}
+
+func TestDockerNetworkSuite(t *testing.T) {
+ ensureTestEnvSetup(t)
+ testRequires(t, DaemonIsLinux)
+ suite.Run(t, &DockerExternalVolumeSuite{ds: &DockerSuite{}})
+}
+
+func TestDockerHubPullSuite(t *testing.T) {
+ ensureTestEnvSetup(t)
+ // FIXME. Temporarily turning this off for Windows as GH16039 was breaking
+ // Windows to Linux CI @icecrime
+ testRequires(t, DaemonIsLinux)
+ suite.Run(t, newDockerHubPullSuite())
}
type DockerSuite struct {
}
-func (s *DockerSuite) OnTimeout(c *check.C) {
+func (s *DockerSuite) OnTimeout(c *testing.T) {
if testEnv.IsRemoteDaemon() {
return
}
@@ -104,34 +167,28 @@
}
}
-func (s *DockerSuite) TearDownTest(c *check.C) {
+func (s *DockerSuite) TearDownTest(c *testing.T) {
testEnv.Clean(c)
}
-func init() {
- check.Suite(&DockerRegistrySuite{
- ds: &DockerSuite{},
- })
-}
-
type DockerRegistrySuite struct {
ds *DockerSuite
reg *registry.V2
d *daemon.Daemon
}
-func (s *DockerRegistrySuite) OnTimeout(c *check.C) {
+func (s *DockerRegistrySuite) OnTimeout(c *testing.T) {
s.d.DumpStackAndQuit()
}
-func (s *DockerRegistrySuite) SetUpTest(c *check.C) {
+func (s *DockerRegistrySuite) SetUpTest(c *testing.T) {
testRequires(c, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon)
s.reg = registry.NewV2(c)
s.reg.WaitReady(c)
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 {
s.reg.Close()
}
@@ -141,30 +198,24 @@
s.ds.TearDownTest(c)
}
-func init() {
- check.Suite(&DockerSchema1RegistrySuite{
- ds: &DockerSuite{},
- })
-}
-
type DockerSchema1RegistrySuite struct {
ds *DockerSuite
reg *registry.V2
d *daemon.Daemon
}
-func (s *DockerSchema1RegistrySuite) OnTimeout(c *check.C) {
+func (s *DockerSchema1RegistrySuite) OnTimeout(c *testing.T) {
s.d.DumpStackAndQuit()
}
-func (s *DockerSchema1RegistrySuite) SetUpTest(c *check.C) {
+func (s *DockerSchema1RegistrySuite) SetUpTest(c *testing.T) {
testRequires(c, DaemonIsLinux, RegistryHosting, NotArm64, testEnv.IsLocalDaemon)
s.reg = registry.NewV2(c, registry.Schema1)
s.reg.WaitReady(c)
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 {
s.reg.Close()
}
@@ -174,30 +225,24 @@
s.ds.TearDownTest(c)
}
-func init() {
- check.Suite(&DockerRegistryAuthHtpasswdSuite{
- ds: &DockerSuite{},
- })
-}
-
type DockerRegistryAuthHtpasswdSuite struct {
ds *DockerSuite
reg *registry.V2
d *daemon.Daemon
}
-func (s *DockerRegistryAuthHtpasswdSuite) OnTimeout(c *check.C) {
+func (s *DockerRegistryAuthHtpasswdSuite) OnTimeout(c *testing.T) {
s.d.DumpStackAndQuit()
}
-func (s *DockerRegistryAuthHtpasswdSuite) SetUpTest(c *check.C) {
+func (s *DockerRegistryAuthHtpasswdSuite) SetUpTest(c *testing.T) {
testRequires(c, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon)
s.reg = registry.NewV2(c, registry.Htpasswd)
s.reg.WaitReady(c)
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 {
out, err := s.d.Cmd("logout", privateRegistryURL)
assert.NilError(c, err, out)
@@ -209,28 +254,22 @@
s.ds.TearDownTest(c)
}
-func init() {
- check.Suite(&DockerRegistryAuthTokenSuite{
- ds: &DockerSuite{},
- })
-}
-
type DockerRegistryAuthTokenSuite struct {
ds *DockerSuite
reg *registry.V2
d *daemon.Daemon
}
-func (s *DockerRegistryAuthTokenSuite) OnTimeout(c *check.C) {
+func (s *DockerRegistryAuthTokenSuite) OnTimeout(c *testing.T) {
s.d.DumpStackAndQuit()
}
-func (s *DockerRegistryAuthTokenSuite) SetUpTest(c *check.C) {
+func (s *DockerRegistryAuthTokenSuite) SetUpTest(c *testing.T) {
testRequires(c, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon)
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 {
out, err := s.d.Cmd("logout", privateRegistryURL)
assert.NilError(c, err, out)
@@ -242,7 +281,7 @@
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 {
c.Fatal("registry suite isn't initialized")
}
@@ -250,27 +289,21 @@
s.reg.WaitReady(c)
}
-func init() {
- check.Suite(&DockerDaemonSuite{
- ds: &DockerSuite{},
- })
-}
-
type DockerDaemonSuite struct {
ds *DockerSuite
d *daemon.Daemon
}
-func (s *DockerDaemonSuite) OnTimeout(c *check.C) {
+func (s *DockerDaemonSuite) OnTimeout(c *testing.T) {
s.d.DumpStackAndQuit()
}
-func (s *DockerDaemonSuite) SetUpTest(c *check.C) {
+func (s *DockerDaemonSuite) SetUpTest(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
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)
if s.d != nil {
s.d.Stop(c)
@@ -278,7 +311,7 @@
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 {
if err != nil {
// ignore errors here
@@ -295,12 +328,6 @@
const defaultSwarmPort = 2477
-func init() {
- check.Suite(&DockerSwarmSuite{
- ds: &DockerSuite{},
- })
-}
-
type DockerSwarmSuite struct {
server *httptest.Server
ds *DockerSuite
@@ -309,7 +336,7 @@
portIndex int
}
-func (s *DockerSwarmSuite) OnTimeout(c *check.C) {
+func (s *DockerSwarmSuite) OnTimeout(c *testing.T) {
s.daemonsLock.Lock()
defer s.daemonsLock.Unlock()
for _, d := range s.daemons {
@@ -317,11 +344,11 @@
}
}
-func (s *DockerSwarmSuite) SetUpTest(c *check.C) {
+func (s *DockerSwarmSuite) SetUpTest(c *testing.T) {
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,
testdaemon.WithEnvironment(testEnv.Execution),
testdaemon.WithSwarmPort(defaultSwarmPort+s.portIndex),
@@ -344,7 +371,7 @@
return d
}
-func (s *DockerSwarmSuite) TearDownTest(c *check.C) {
+func (s *DockerSwarmSuite) TearDownTest(c *testing.T) {
testRequires(c, DaemonIsLinux)
s.daemonsLock.Lock()
for _, d := range s.daemons {
@@ -359,12 +386,6 @@
s.ds.TearDownTest(c)
}
-func init() {
- check.Suite(&DockerPluginSuite{
- ds: &DockerSuite{},
- })
-}
-
type DockerPluginSuite struct {
ds *DockerSuite
registry *registry.V2
@@ -381,7 +402,7 @@
return ps.getPluginRepo() + ":" + "latest"
}
-func (ps *DockerPluginSuite) SetUpSuite(c *check.C) {
+func (ps *DockerPluginSuite) SetUpSuite(c *testing.T) {
testRequires(c, DaemonIsLinux, RegistryHosting)
ps.registry = registry.NewV2(c)
ps.registry.WaitReady(c)
@@ -393,16 +414,16 @@
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 {
ps.registry.Close()
}
}
-func (ps *DockerPluginSuite) TearDownTest(c *check.C) {
+func (ps *DockerPluginSuite) TearDownTest(c *testing.T) {
ps.ds.TearDownTest(c)
}
-func (ps *DockerPluginSuite) OnTimeout(c *check.C) {
+func (ps *DockerPluginSuite) OnTimeout(c *testing.T) {
ps.ds.OnTimeout(c)
}
diff --git a/integration-cli/checker/checker.go b/integration-cli/checker/checker.go
index 7a13fa2..a12f8e4 100644
--- a/integration-cli/checker/checker.go
+++ b/integration-cli/checker/checker.go
@@ -1,24 +1,84 @@
-// Package checker provides Docker specific implementations of the go-check.Checker interface.
+// Package checker provides helpers for gotest.tools/assert.
+// Please remove this package whenever possible.
package checker // import "github.com/docker/docker/integration-cli/checker"
import (
- "github.com/go-check/check"
- "github.com/vdemeester/shakers"
+ "fmt"
+
+ "gotest.tools/assert"
+ "gotest.tools/assert/cmp"
)
-// As a commodity, we bring all check.Checker variables into the current namespace to avoid having
-// to think about check.X versus checker.X.
-var (
- DeepEquals = check.DeepEquals
- HasLen = check.HasLen
- IsNil = check.IsNil
- Matches = check.Matches
- Not = check.Not
- NotNil = check.NotNil
+// Compare defines the interface to compare values
+type Compare func(x interface{}) assert.BoolOrComparison
- Contains = shakers.Contains
- Equals = shakers.Equals
- False = shakers.False
- GreaterThan = shakers.GreaterThan
- True = shakers.True
-)
+// False checks if the value is false
+func False() Compare {
+ return func(x interface{}) assert.BoolOrComparison {
+ return !x.(bool)
+ }
+}
+
+// True checks if the value is true
+func True() Compare {
+ return func(x interface{}) assert.BoolOrComparison {
+ return x
+ }
+}
+
+// Equals checks if the value is equal to the given value
+func Equals(y interface{}) Compare {
+ return func(x interface{}) assert.BoolOrComparison {
+ return cmp.Equal(x, y)
+ }
+}
+
+// Contains checks if the value contains the given value
+func Contains(y interface{}) Compare {
+ return func(x interface{}) assert.BoolOrComparison {
+ return cmp.Contains(x, y)
+ }
+}
+
+// Not checks if two values are not
+func Not(c Compare) Compare {
+ return func(x interface{}) assert.BoolOrComparison {
+ r := c(x)
+ switch r := r.(type) {
+ case bool:
+ return !r
+ case cmp.Comparison:
+ return !r().Success()
+ default:
+ panic(fmt.Sprintf("unexpected type %T", r))
+ }
+ }
+}
+
+// DeepEquals checks if two values are equal
+func DeepEquals(y interface{}) Compare {
+ return func(x interface{}) assert.BoolOrComparison {
+ return cmp.DeepEqual(x, y)
+ }
+}
+
+// DeepEquals compares if two values are deepequal
+func HasLen(y int) Compare {
+ return func(x interface{}) assert.BoolOrComparison {
+ return cmp.Len(x, y)
+ }
+}
+
+// DeepEquals checks if the given value is nil
+func IsNil() Compare {
+ return func(x interface{}) assert.BoolOrComparison {
+ return cmp.Nil(x)
+ }
+}
+
+// GreaterThan checks if the value is greater than the given value
+func GreaterThan(y int) Compare {
+ return func(x interface{}) assert.BoolOrComparison {
+ return x.(int) > y
+ }
+}
diff --git a/integration-cli/daemon/daemon.go b/integration-cli/daemon/daemon.go
index 4bf773b..f8ba48c 100644
--- a/integration-cli/daemon/daemon.go
+++ b/integration-cli/daemon/daemon.go
@@ -3,10 +3,10 @@
import (
"fmt"
"strings"
+ "testing"
"time"
"github.com/docker/docker/internal/test/daemon"
- "github.com/go-check/check"
"github.com/pkg/errors"
"gotest.tools/assert"
"gotest.tools/icmd"
@@ -88,13 +88,13 @@
// CheckActiveContainerCount returns the number of active containers
// 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{}, string) {
out, err := d.Cmd("ps", "-q")
assert.NilError(c, err)
if len(strings.TrimSpace(out)) == 0 {
- return 0, nil
+ return 0, ""
}
- return len(strings.Split(strings.TrimSpace(out), "\n")), check.Commentf("output: %q", string(out))
+ return len(strings.Split(strings.TrimSpace(out), "\n")), fmt.Sprintf("output: %q", string(out))
}
// WaitRun waits for a container to be running for 10s
diff --git a/integration-cli/daemon/daemon_swarm.go b/integration-cli/daemon/daemon_swarm.go
index bbb124d..8acc30d 100644
--- a/integration-cli/daemon/daemon_swarm.go
+++ b/integration-cli/daemon/daemon_swarm.go
@@ -4,19 +4,19 @@
"context"
"fmt"
"strings"
+ "testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/client"
- "github.com/go-check/check"
"gotest.tools/assert"
)
// CheckServiceTasksInState returns the number of tasks with a matching state,
// and optional message substring.
-func (d *Daemon) CheckServiceTasksInState(service string, state swarm.TaskState, message string) func(*check.C) (interface{}, check.CommentInterface) {
- return func(c *check.C) (interface{}, check.CommentInterface) {
+func (d *Daemon) CheckServiceTasksInState(service string, state swarm.TaskState, message string) func(*testing.T) (interface{}, string) {
+ return func(c *testing.T) (interface{}, string) {
tasks := d.GetServiceTasks(c, service)
var count int
for _, task := range tasks {
@@ -26,14 +26,14 @@
}
}
}
- return count, nil
+ return count, ""
}
}
// CheckServiceTasksInStateWithError returns the number of tasks with a matching state,
// and optional message substring.
-func (d *Daemon) CheckServiceTasksInStateWithError(service string, state swarm.TaskState, errorMessage string) func(*check.C) (interface{}, check.CommentInterface) {
- return func(c *check.C) (interface{}, check.CommentInterface) {
+func (d *Daemon) CheckServiceTasksInStateWithError(service string, state swarm.TaskState, errorMessage string) func(*testing.T) (interface{}, string) {
+ return func(c *testing.T) (interface{}, string) {
tasks := d.GetServiceTasks(c, service)
var count int
for _, task := range tasks {
@@ -43,62 +43,62 @@
}
}
}
- return count, nil
+ return count, ""
}
}
// 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{}, string) {
return d.CheckServiceTasksInState(service, swarm.TaskStateRunning, "")
}
// CheckServiceUpdateState returns the current update state for the specified service
-func (d *Daemon) CheckServiceUpdateState(service string) func(*check.C) (interface{}, check.CommentInterface) {
- return func(c *check.C) (interface{}, check.CommentInterface) {
+func (d *Daemon) CheckServiceUpdateState(service string) func(*testing.T) (interface{}, string) {
+ return func(c *testing.T) (interface{}, string) {
service := d.GetService(c, service)
if service.UpdateStatus == nil {
- return "", nil
+ return "", ""
}
- return service.UpdateStatus.State, nil
+ return service.UpdateStatus.State, ""
}
}
// CheckPluginRunning returns the runtime state of the plugin
-func (d *Daemon) CheckPluginRunning(plugin string) func(c *check.C) (interface{}, check.CommentInterface) {
- return func(c *check.C) (interface{}, check.CommentInterface) {
+func (d *Daemon) CheckPluginRunning(plugin string) func(c *testing.T) (interface{}, string) {
+ return func(c *testing.T) (interface{}, string) {
apiclient := d.NewClientT(c)
resp, _, err := apiclient.PluginInspectWithRaw(context.Background(), plugin)
if client.IsErrNotFound(err) {
- return false, check.Commentf("%v", err)
+ return false, fmt.Sprintf("%v", err)
}
assert.NilError(c, err)
- return resp.Enabled, check.Commentf("%+v", resp)
+ return resp.Enabled, fmt.Sprintf("%+v", resp)
}
}
// CheckPluginImage returns the runtime state of the plugin
-func (d *Daemon) CheckPluginImage(plugin string) func(c *check.C) (interface{}, check.CommentInterface) {
- return func(c *check.C) (interface{}, check.CommentInterface) {
+func (d *Daemon) CheckPluginImage(plugin string) func(c *testing.T) (interface{}, string) {
+ return func(c *testing.T) (interface{}, string) {
apiclient := d.NewClientT(c)
resp, _, err := apiclient.PluginInspectWithRaw(context.Background(), plugin)
if client.IsErrNotFound(err) {
- return false, check.Commentf("%v", err)
+ return false, fmt.Sprintf("%v", err)
}
assert.NilError(c, err)
- return resp.PluginReference, check.Commentf("%+v", resp)
+ return resp.PluginReference, fmt.Sprintf("%+v", resp)
}
}
// CheckServiceTasks returns the number of tasks for the specified service
-func (d *Daemon) CheckServiceTasks(service string) func(*check.C) (interface{}, check.CommentInterface) {
- return func(c *check.C) (interface{}, check.CommentInterface) {
+func (d *Daemon) CheckServiceTasks(service string) func(*testing.T) (interface{}, string) {
+ return func(c *testing.T) (interface{}, string) {
tasks := d.GetServiceTasks(c, service)
- return len(tasks), nil
+ return len(tasks), ""
}
}
// 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{}, string) {
cli := d.NewClientT(c)
defer cli.Close()
@@ -118,11 +118,11 @@
result[network.Target]++
}
}
- return result, nil
+ return result, ""
}
// 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{}, string) {
cli := d.NewClientT(c)
defer cli.Close()
@@ -142,11 +142,11 @@
result[task.Spec.ContainerSpec.Image]++
}
}
- return result, nil
+ return result, ""
}
// 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{}, string) {
nodes := d.ListNodes(c)
var readyCount int
for _, node := range nodes {
@@ -154,28 +154,28 @@
readyCount++
}
}
- return readyCount, nil
+ return readyCount, ""
}
// 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{}, string) {
info := d.SwarmInfo(c)
- return info.LocalNodeState, nil
+ return info.LocalNodeState, ""
}
// 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{}, string) {
info := d.SwarmInfo(c)
assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateActive)
- return info.ControlAvailable, nil
+ return info.ControlAvailable, ""
}
// 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{}, string) {
cli := d.NewClientT(c)
defer cli.Close()
- errList := check.Commentf("could not get node list")
+ errList := "could not get node list"
ls, err := cli.NodeList(context.Background(), types.NodeListOptions{})
if err != nil {
@@ -184,10 +184,10 @@
for _, node := range ls {
if node.ManagerStatus != nil && node.ManagerStatus.Leader {
- return nil, nil
+ return nil, ""
}
}
- return fmt.Errorf("no leader"), check.Commentf("could not find leader")
+ return fmt.Errorf("no leader"), "could not find leader"
}
// CmdRetryOutOfSequence tries the specified command against the current daemon
diff --git a/integration-cli/daemon_swarm_hack_test.go b/integration-cli/daemon_swarm_hack_test.go
index 7a23e84..4152f73 100644
--- a/integration-cli/daemon_swarm_hack_test.go
+++ b/integration-cli/daemon_swarm_hack_test.go
@@ -1,11 +1,12 @@
package main
import (
+ "testing"
+
"github.com/docker/docker/integration-cli/daemon"
- "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()
defer s.daemonsLock.Unlock()
for _, d := range s.daemons {
@@ -18,6 +19,6 @@
}
// 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...)
}
diff --git a/integration-cli/docker_api_attach_test.go b/integration-cli/docker_api_attach_test.go
index 00f8bc9..530823e 100644
--- a/integration-cli/docker_api_attach_test.go
+++ b/integration-cli/docker_api_attach_test.go
@@ -10,20 +10,20 @@
"net/http"
"net/http/httputil"
"strings"
+ "testing"
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/pkg/stdcopy"
- "github.com/go-check/check"
"github.com/pkg/errors"
"golang.org/x/net/websocket"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
)
-func (s *DockerSuite) TestGetContainersAttachWebsocket(c *check.C) {
+func (s *DockerSuite) TestGetContainersAttachWebsocket(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-dit", "busybox", "cat")
@@ -76,7 +76,7 @@
}
// regression gh14320
-func (s *DockerSuite) TestPostContainersAttachContainerNotFound(c *check.C) {
+func (s *DockerSuite) TestPostContainersAttachContainerNotFound(c *testing.T) {
resp, _, err := request.Post("/containers/doesnotexist/attach")
assert.NilError(c, err)
// connection will shutdown, err should be "persistent connection closed"
@@ -87,7 +87,7 @@
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")
assert.Equal(c, res.StatusCode, http.StatusNotFound)
assert.NilError(c, err)
@@ -97,7 +97,7 @@
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)
expectSuccess := func(conn net.Conn, br *bufio.Reader, stream string, tty bool) {
diff --git a/integration-cli/docker_api_build_test.go b/integration-cli/docker_api_build_test.go
index e82d54c..be96cb9 100644
--- a/integration-cli/docker_api_build_test.go
+++ b/integration-cli/docker_api_build_test.go
@@ -11,18 +11,18 @@
"net/http"
"regexp"
"strings"
+ "testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/internal/test/fakecontext"
"github.com/docker/docker/internal/test/fakegit"
"github.com/docker/docker/internal/test/fakestorage"
"github.com/docker/docker/internal/test/request"
- "github.com/go-check/check"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
)
-func (s *DockerSuite) TestBuildAPIDockerFileRemote(c *check.C) {
+func (s *DockerSuite) TestBuildAPIDockerFileRemote(c *testing.T) {
testRequires(c, NotUserNamespace)
var testD string
@@ -53,7 +53,7 @@
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)
tw := tar.NewWriter(buffer)
defer tw.Close()
@@ -80,7 +80,7 @@
b.Close()
}
-func (s *DockerSuite) TestBuildAPIRemoteTarballContextWithCustomDockerfile(c *check.C) {
+func (s *DockerSuite) TestBuildAPIRemoteTarballContextWithCustomDockerfile(c *testing.T) {
buffer := new(bytes.Buffer)
tw := tar.NewWriter(buffer)
defer tw.Close()
@@ -134,7 +134,7 @@
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{
"dockerfile": `FROM busybox
RUN echo from dockerfile`,
@@ -152,7 +152,7 @@
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{
"baz": `FROM busybox
RUN echo from baz`,
@@ -173,7 +173,7 @@
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
git := fakegit.New(c, "repo", map[string]string{
"Dockerfile": `FROM busybox
@@ -195,7 +195,7 @@
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
// x/./y don't cause caching false positives.
@@ -254,7 +254,7 @@
assert.Assert(c, imageA != imageB)
}
-func (s *DockerSuite) TestBuildOnBuildWithCopy(c *check.C) {
+func (s *DockerSuite) TestBuildOnBuildWithCopy(c *testing.T) {
dockerfile := `
FROM ` + minimalBaseImage() + ` as onbuildbase
ONBUILD COPY file /file
@@ -279,7 +279,7 @@
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 {
ctx := fakecontext.New(c, "",
fakecontext.WithDockerfile(dockerfile),
@@ -321,7 +321,7 @@
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()
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
@@ -358,7 +358,7 @@
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)
tw := tar.NewWriter(buffer)
dt := []byte("contents")
@@ -402,7 +402,7 @@
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
testRequires(c, DaemonIsLinux, MinimumAPIVersion("1.31"))
dockerfile := `FROM busybox
@@ -432,7 +432,7 @@
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
COPY file /file`
@@ -473,7 +473,7 @@
}
}
-func (s *DockerSuite) TestBuildAddCacheOnFileChange(c *check.C) {
+func (s *DockerSuite) TestBuildAddCacheOnFileChange(c *testing.T) {
dockerfile := `FROM busybox
ADD file /file`
@@ -514,7 +514,7 @@
}
}
-func (s *DockerSuite) TestBuildScratchCopy(c *check.C) {
+func (s *DockerSuite) TestBuildScratchCopy(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerfile := `FROM scratch
ADD Dockerfile /
@@ -543,7 +543,7 @@
}
}
-func getImageIDsFromBuild(c *check.C, output []byte) []string {
+func getImageIDsFromBuild(c *testing.T, output []byte) []string {
var ids []string
for _, line := range bytes.Split(output, []byte("\n")) {
if len(line) == 0 {
diff --git a/integration-cli/docker_api_build_windows_test.go b/integration-cli/docker_api_build_windows_test.go
index d100c8e..f19cc7a 100644
--- a/integration-cli/docker_api_build_windows_test.go
+++ b/integration-cli/docker_api_build_windows_test.go
@@ -4,15 +4,15 @@
import (
"net/http"
+ "testing"
"github.com/docker/docker/internal/test/fakecontext"
"github.com/docker/docker/internal/test/request"
- "github.com/go-check/check"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
)
-func (s *DockerSuite) TestBuildWithRecycleBin(c *check.C) {
+func (s *DockerSuite) TestBuildWithRecycleBin(c *testing.T) {
testRequires(c, DaemonIsWindows)
dockerfile := "" +
diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go
index c55a358..d3e8b23 100644
--- a/integration-cli/docker_api_containers_test.go
+++ b/integration-cli/docker_api_containers_test.go
@@ -13,8 +13,8 @@
"path/filepath"
"regexp"
"runtime"
- "strconv"
"strings"
+ "testing"
"time"
"github.com/docker/docker/api/types"
@@ -23,7 +23,6 @@
networktypes "github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/client"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/internal/test/request"
@@ -32,13 +31,12 @@
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/volume"
"github.com/docker/go-connections/nat"
- "github.com/go-check/check"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
"gotest.tools/poll"
)
-func (s *DockerSuite) TestContainerAPIGetAll(c *check.C) {
+func (s *DockerSuite) TestContainerAPIGetAll(c *testing.T) {
startCount := getContainerCount(c)
name := "getall"
dockerCmd(c, "run", "--name", name, "busybox", "true")
@@ -54,11 +52,11 @@
assert.NilError(c, err)
assert.Equal(c, len(containers), startCount+1)
actual := containers[0].Names[0]
- c.Assert(actual, checker.Equals, "/"+name)
+ assert.Equal(c, actual, "/"+name)
}
// 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)
dockerCmd(c, "run", "busybox", "true")
@@ -98,46 +96,7 @@
}
}
-type containerPs struct {
- Names []string
- Ports []types.Port
-}
-
-// regression test for non-empty fields from #13901
-func (s *DockerSuite) TestContainerAPIPsOmitFields(c *check.C) {
- // Problematic for Windows porting due to networking not yet being passed back
- testRequires(c, DaemonIsLinux)
- name := "pstest"
- port := 80
- runSleepingContainer(c, "--name", name, "--expose", strconv.Itoa(port))
-
- cli, err := client.NewClientWithOpts(client.FromEnv)
- assert.NilError(c, err)
- defer cli.Close()
-
- options := types.ContainerListOptions{
- All: true,
- }
- containers, err := cli.ContainerList(context.Background(), options)
- assert.NilError(c, err)
- var foundContainer containerPs
- for _, c := range containers {
- for _, testName := range c.Names {
- if "/"+name == testName {
- foundContainer.Names = c.Names
- foundContainer.Ports = c.Ports
- break
- }
- }
- }
-
- c.Assert(foundContainer.Ports, checker.HasLen, 1)
- c.Assert(foundContainer.Ports[0].PrivatePort, checker.Equals, uint16(port))
- c.Assert(foundContainer.Ports[0].PublicPort, checker.NotNil)
- c.Assert(foundContainer.Ports[0].IP, checker.NotNil)
-}
-
-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
testRequires(c, DaemonIsLinux)
name := "exportcontainer"
@@ -161,10 +120,10 @@
break
}
}
- c.Assert(found, checker.True, check.Commentf("The created test file has not been found in the exported image"))
+ assert.Assert(c, found, "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)
testRequires(c, DaemonIsLinux)
name := "changescontainer"
@@ -184,10 +143,10 @@
success = true
}
}
- c.Assert(success, checker.True, check.Commentf("/etc/passwd has been removed but is not present in the diff"))
+ assert.Assert(c, success, "/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 (
name = "statscontainer"
)
@@ -227,7 +186,7 @@
}
}
-func (s *DockerSuite) TestGetContainerStatsRmRunning(c *check.C) {
+func (s *DockerSuite) TestGetContainerStatsRmRunning(c *testing.T) {
out := runSleepingContainer(c)
id := strings.TrimSpace(out)
@@ -255,12 +214,12 @@
// Now remove without `-f` and make sure we are still pulling stats
_, _, err = dockerCmdWithError("rm", id)
- c.Assert(err, checker.Not(checker.IsNil), check.Commentf("rm should have failed but didn't"))
+ assert.Assert(c, err != nil, "rm should have failed but didn't")
_, err = buf.ReadTimeout(b, 2*time.Second)
assert.NilError(c, err)
dockerCmd(c, "rm", "-f", id)
- c.Assert(<-chErr, checker.IsNil)
+ assert.Assert(c, <-chErr == nil)
}
// ChannelBuffer holds a chan of byte array that can be populate in a goroutine.
@@ -294,7 +253,7 @@
// regression test for gh13421
// previous test was just checking one stat entry so it didn't fail (stats with
// stream false always return one stat)
-func (s *DockerSuite) TestGetContainerStatsStream(c *check.C) {
+func (s *DockerSuite) TestGetContainerStatsStream(c *testing.T) {
name := "statscontainer"
runSleepingContainer(c, "--name", name)
@@ -335,7 +294,7 @@
}
}
-func (s *DockerSuite) TestGetContainerStatsNoStream(c *check.C) {
+func (s *DockerSuite) TestGetContainerStatsNoStream(c *testing.T) {
name := "statscontainer"
runSleepingContainer(c, "--name", name)
@@ -375,7 +334,7 @@
}
}
-func (s *DockerSuite) TestGetStoppedContainerStats(c *check.C) {
+func (s *DockerSuite) TestGetStoppedContainerStats(c *testing.T) {
name := "statscontainer"
dockerCmd(c, "create", "--name", name, "busybox", "ps")
@@ -401,11 +360,11 @@
}
}
-func (s *DockerSuite) TestContainerAPIPause(c *check.C) {
+func (s *DockerSuite) TestContainerAPIPause(c *testing.T) {
// Problematic on Windows as Windows does not support pause
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())
}
@@ -429,10 +388,10 @@
assert.NilError(c, err)
pausedContainers = getPaused(c)
- c.Assert(pausedContainers, checker.HasLen, 0, check.Commentf("There should be no paused container."))
+ assert.Equal(c, len(pausedContainers), 0, "There should be no paused container.")
}
-func (s *DockerSuite) TestContainerAPITop(c *check.C) {
+func (s *DockerSuite) TestContainerAPITop(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "top")
id := strings.TrimSpace(string(out))
@@ -445,17 +404,17 @@
// sort by comm[andline] to make sure order stays the same in case of PID rollover
top, err := cli.ContainerTop(context.Background(), id, []string{"aux", "--sort=comm"})
assert.NilError(c, err)
- c.Assert(top.Titles, checker.HasLen, 11, check.Commentf("expected 11 titles, found %d: %v", len(top.Titles), top.Titles))
+ assert.Equal(c, len(top.Titles), 11, fmt.Sprintf("expected 11 titles, found %d: %v", len(top.Titles), top.Titles))
if top.Titles[0] != "USER" || top.Titles[10] != "COMMAND" {
c.Fatalf("expected `USER` at `Titles[0]` and `COMMAND` at Titles[10]: %v", top.Titles)
}
- c.Assert(top.Processes, checker.HasLen, 2, check.Commentf("expected 2 processes, found %d: %v", len(top.Processes), top.Processes))
- c.Assert(top.Processes[0][10], checker.Equals, "/bin/sh -c top")
- c.Assert(top.Processes[1][10], checker.Equals, "top")
+ assert.Equal(c, len(top.Processes), 2, fmt.Sprintf("expected 2 processes, found %d: %v", len(top.Processes), top.Processes))
+ assert.Equal(c, top.Processes[0][10], "/bin/sh -c top")
+ assert.Equal(c, top.Processes[1][10], "top")
}
-func (s *DockerSuite) TestContainerAPITopWindows(c *check.C) {
+func (s *DockerSuite) TestContainerAPITopWindows(c *testing.T) {
testRequires(c, DaemonIsWindows)
out := runSleepingContainer(c, "-d")
id := strings.TrimSpace(string(out))
@@ -486,7 +445,7 @@
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"
dockerCmd(c, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test")
@@ -502,13 +461,13 @@
assert.NilError(c, err)
cmd := inspectField(c, img.ID, "Config.Cmd")
- c.Assert(cmd, checker.Equals, "[/bin/sh -c touch /test]", check.Commentf("got wrong Cmd from commit: %q", cmd))
+ assert.Equal(c, cmd, "[/bin/sh -c touch /test]", fmt.Sprintf("got wrong Cmd from commit: %q", cmd))
// sanity check, make sure the image is what we think it is
dockerCmd(c, "run", img.ID, "ls", "/test")
}
-func (s *DockerSuite) TestContainerAPICommitWithLabelInConfig(c *check.C) {
+func (s *DockerSuite) TestContainerAPICommitWithLabelInConfig(c *testing.T) {
cName := "testapicommitwithconfig"
dockerCmd(c, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test")
@@ -528,19 +487,19 @@
assert.NilError(c, err)
label1 := inspectFieldMap(c, img.ID, "Config.Labels", "key1")
- c.Assert(label1, checker.Equals, "value1")
+ assert.Equal(c, label1, "value1")
label2 := inspectFieldMap(c, img.ID, "Config.Labels", "key2")
- c.Assert(label2, checker.Equals, "value2")
+ assert.Equal(c, label2, "value2")
cmd := inspectField(c, img.ID, "Config.Cmd")
- c.Assert(cmd, checker.Equals, "[/bin/sh -c touch /test]", check.Commentf("got wrong Cmd from commit: %q", cmd))
+ assert.Equal(c, cmd, "[/bin/sh -c touch /test]", fmt.Sprintf("got wrong Cmd from commit: %q", cmd))
// sanity check, make sure the image is what we think it is
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
testRequires(c, DaemonIsLinux)
@@ -567,7 +526,7 @@
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{
Image: "busybox",
Cmd: []string{"/bin/sh", "-c", "touch /test && ls /test"},
@@ -584,7 +543,7 @@
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)
assert.NilError(c, err)
@@ -596,7 +555,7 @@
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
config := containertypes.Config{
Image: "busybox",
@@ -617,26 +576,26 @@
_, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networkingConfig, "")
msg := err.Error()
// network name order in error message is not deterministic
- c.Assert(msg, checker.Contains, "Container cannot be connected to network endpoints")
- c.Assert(msg, checker.Contains, "net1")
- c.Assert(msg, checker.Contains, "net2")
- c.Assert(msg, checker.Contains, "net3")
+ assert.Assert(c, strings.Contains(msg, "Container cannot be connected to network endpoints"))
+ assert.Assert(c, strings.Contains(msg, "net1"))
+ assert.Assert(c, strings.Contains(msg, "net2"))
+ assert.Assert(c, strings.Contains(msg, "net3"))
}
-func (s *DockerSuite) TestContainerAPICreateBridgeNetworkMode(c *check.C) {
+func (s *DockerSuite) TestContainerAPICreateBridgeNetworkMode(c *testing.T) {
// Windows does not support bridge
testRequires(c, DaemonIsLinux)
UtilCreateNetworkMode(c, "bridge")
}
-func (s *DockerSuite) TestContainerAPICreateOtherNetworkModes(c *check.C) {
+func (s *DockerSuite) TestContainerAPICreateOtherNetworkModes(c *testing.T) {
// Windows does not support these network modes
testRequires(c, DaemonIsLinux, NotUserNamespace)
UtilCreateNetworkMode(c, "host")
UtilCreateNetworkMode(c, "container:web1")
}
-func UtilCreateNetworkMode(c *check.C, networkMode containertypes.NetworkMode) {
+func UtilCreateNetworkMode(c *testing.T, networkMode containertypes.NetworkMode) {
config := containertypes.Config{
Image: "busybox",
}
@@ -655,10 +614,10 @@
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
assert.NilError(c, err)
- c.Assert(containerJSON.HostConfig.NetworkMode, checker.Equals, containertypes.NetworkMode(networkMode), check.Commentf("Mismatched NetworkMode"))
+ assert.Equal(c, containerJSON.HostConfig.NetworkMode, containertypes.NetworkMode(networkMode), "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.
testRequires(c, DaemonIsLinux)
config := containertypes.Config{
@@ -686,17 +645,17 @@
assert.Equal(c, out, "512")
outCpuset := inspectField(c, containerJSON.ID, "HostConfig.CpusetCpus")
- c.Assert(outCpuset, checker.Equals, "0")
+ assert.Equal(c, outCpuset, "0")
}
-func (s *DockerSuite) TestContainerAPIVerifyHeader(c *check.C) {
+func (s *DockerSuite) TestContainerAPIVerifyHeader(c *testing.T) {
config := map[string]interface{}{
"Image": "busybox",
}
create := func(ct string) (*http.Response, io.ReadCloser, error) {
jsonData := bytes.NewBuffer(nil)
- c.Assert(json.NewEncoder(jsonData).Encode(config), checker.IsNil)
+ assert.Assert(c, json.NewEncoder(jsonData).Encode(config) == nil)
return request.Post("/containers/create", request.RawContent(ioutil.NopCloser(jsonData)), request.ContentType(ct))
}
@@ -708,7 +667,7 @@
if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") {
assert.Equal(c, res.StatusCode, http.StatusBadRequest)
} else {
- c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK)
+ assert.Assert(c, res.StatusCode != http.StatusOK)
}
body.Close()
@@ -718,7 +677,7 @@
if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") {
assert.Equal(c, res.StatusCode, http.StatusBadRequest)
} else {
- c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK)
+ assert.Assert(c, res.StatusCode != http.StatusOK)
}
body.Close()
@@ -730,7 +689,7 @@
}
//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 := `{
"Image": "busybox",
"HostConfig": {
@@ -748,15 +707,15 @@
if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") {
assert.Equal(c, res.StatusCode, http.StatusBadRequest)
} else {
- c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK)
+ assert.Assert(c, res.StatusCode != http.StatusOK)
}
b, err := request.ReadBody(body)
assert.NilError(c, err)
- c.Assert(string(b[:]), checker.Contains, "invalid port")
+ assert.Assert(c, strings.Contains(string(b[:]), "invalid port"))
}
-func (s *DockerSuite) TestContainerAPIRestartPolicyInvalidPolicyName(c *check.C) {
+func (s *DockerSuite) TestContainerAPIRestartPolicyInvalidPolicyName(c *testing.T) {
config := `{
"Image": "busybox",
"HostConfig": {
@@ -772,15 +731,15 @@
if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") {
assert.Equal(c, res.StatusCode, http.StatusBadRequest)
} else {
- c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK)
+ assert.Assert(c, res.StatusCode != http.StatusOK)
}
b, err := request.ReadBody(body)
assert.NilError(c, err)
- c.Assert(string(b[:]), checker.Contains, "invalid restart policy")
+ assert.Assert(c, strings.Contains(string(b[:]), "invalid restart policy"))
}
-func (s *DockerSuite) TestContainerAPIRestartPolicyRetryMismatch(c *check.C) {
+func (s *DockerSuite) TestContainerAPIRestartPolicyRetryMismatch(c *testing.T) {
config := `{
"Image": "busybox",
"HostConfig": {
@@ -796,15 +755,15 @@
if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") {
assert.Equal(c, res.StatusCode, http.StatusBadRequest)
} else {
- c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK)
+ assert.Assert(c, res.StatusCode != http.StatusOK)
}
b, err := request.ReadBody(body)
assert.NilError(c, err)
- c.Assert(string(b[:]), checker.Contains, "maximum retry count cannot be used with restart policy")
+ assert.Assert(c, strings.Contains(string(b[:]), "maximum retry count cannot be used with restart policy"))
}
-func (s *DockerSuite) TestContainerAPIRestartPolicyNegativeRetryCount(c *check.C) {
+func (s *DockerSuite) TestContainerAPIRestartPolicyNegativeRetryCount(c *testing.T) {
config := `{
"Image": "busybox",
"HostConfig": {
@@ -820,15 +779,15 @@
if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") {
assert.Equal(c, res.StatusCode, http.StatusBadRequest)
} else {
- c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK)
+ assert.Assert(c, res.StatusCode != http.StatusOK)
}
b, err := request.ReadBody(body)
assert.NilError(c, err)
- c.Assert(string(b[:]), checker.Contains, "maximum retry count cannot be negative")
+ assert.Assert(c, strings.Contains(string(b[:]), "maximum retry count cannot be negative"))
}
-func (s *DockerSuite) TestContainerAPIRestartPolicyDefaultRetryCount(c *check.C) {
+func (s *DockerSuite) TestContainerAPIRestartPolicyDefaultRetryCount(c *testing.T) {
config := `{
"Image": "busybox",
"HostConfig": {
@@ -846,7 +805,7 @@
// 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"
-func (s *DockerSuite) TestContainerAPIPostCreateNull(c *check.C) {
+func (s *DockerSuite) TestContainerAPIPostCreateNull(c *testing.T) {
config := `{
"Hostname":"",
"Domainname":"",
@@ -880,17 +839,17 @@
ID string
}
var container createResp
- c.Assert(json.Unmarshal(b, &container), checker.IsNil)
+ assert.Assert(c, json.Unmarshal(b, &container) == nil)
out := inspectField(c, container.ID, "HostConfig.CpusetCpus")
assert.Equal(c, out, "")
outMemory := inspectField(c, container.ID, "HostConfig.Memory")
- c.Assert(outMemory, checker.Equals, "0")
+ assert.Equal(c, outMemory, "0")
outMemorySwap := inspectField(c, container.ID, "HostConfig.MemorySwap")
- c.Assert(outMemorySwap, checker.Equals, "0")
+ assert.Equal(c, outMemorySwap, "0")
}
-func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *check.C) {
+func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *testing.T) {
// TODO Windows: Port once memory is supported
testRequires(c, DaemonIsLinux)
config := `{
@@ -904,17 +863,17 @@
res, body, err := request.Post("/containers/create", request.RawString(config), request.JSON)
assert.NilError(c, err)
b, err2 := request.ReadBody(body)
- c.Assert(err2, checker.IsNil)
+ assert.Assert(c, err2 == nil)
if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") {
assert.Equal(c, res.StatusCode, http.StatusBadRequest)
} else {
- c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK)
+ assert.Assert(c, res.StatusCode != http.StatusOK)
}
- c.Assert(string(b), checker.Contains, "Minimum memory limit allowed is 4MB")
+ assert.Assert(c, strings.Contains(string(b), "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")
containerID := strings.TrimSpace(out)
@@ -928,10 +887,10 @@
assert.NilError(c, err)
name := inspectField(c, containerID, "Name")
- c.Assert(name, checker.Equals, "/"+newName, check.Commentf("Failed to rename container"))
+ assert.Equal(c, name, "/"+newName, "Failed to rename container")
}
-func (s *DockerSuite) TestContainerAPIKill(c *check.C) {
+func (s *DockerSuite) TestContainerAPIKill(c *testing.T) {
name := "test-api-kill"
runSleepingContainer(c, "-i", "--name", name)
@@ -943,10 +902,10 @@
assert.NilError(c, err)
state := inspectField(c, name, "State.Running")
- c.Assert(state, checker.Equals, "false", check.Commentf("got wrong State from container %s: %q", name, state))
+ assert.Equal(c, state, "false", fmt.Sprintf("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"
runSleepingContainer(c, "-di", "--name", name)
cli, err := client.NewClientWithOpts(client.FromEnv)
@@ -957,10 +916,10 @@
err = cli.ContainerRestart(context.Background(), name, &timeout)
assert.NilError(c, err)
- c.Assert(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) == nil)
}
-func (s *DockerSuite) TestContainerAPIRestartNotimeoutParam(c *check.C) {
+func (s *DockerSuite) TestContainerAPIRestartNotimeoutParam(c *testing.T) {
name := "test-api-restart-no-timeout-param"
out := runSleepingContainer(c, "-di", "--name", name)
id := strings.TrimSpace(out)
@@ -973,10 +932,10 @@
err = cli.ContainerRestart(context.Background(), name, nil)
assert.NilError(c, err)
- c.Assert(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) == nil)
}
-func (s *DockerSuite) TestContainerAPIStart(c *check.C) {
+func (s *DockerSuite) TestContainerAPIStart(c *testing.T) {
name := "testing-start"
config := containertypes.Config{
Image: "busybox",
@@ -1002,7 +961,7 @@
// 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"
runSleepingContainer(c, "-i", "--name", name)
timeout := 30 * time.Second
@@ -1013,7 +972,7 @@
err = cli.ContainerStop(context.Background(), name, &timeout)
assert.NilError(c, err)
- c.Assert(waitInspect(name, "{{ .State.Running }}", "false", 60*time.Second), checker.IsNil)
+ assert.Assert(c, waitInspect(name, "{{ .State.Running }}", "false", 60*time.Second) == nil)
// second call to start should give 304
// maybe add ContainerStartWithRaw to test it
@@ -1021,7 +980,7 @@
assert.NilError(c, err)
}
-func (s *DockerSuite) TestContainerAPIWait(c *check.C) {
+func (s *DockerSuite) TestContainerAPIWait(c *testing.T) {
name := "test-api-wait"
sleepCmd := "/bin/sleep"
@@ -1040,11 +999,11 @@
case err = <-errC:
assert.NilError(c, err)
case waitres := <-waitresC:
- c.Assert(waitres.StatusCode, checker.Equals, int64(0))
+ assert.Equal(c, waitres.StatusCode, int64(0))
}
}
-func (s *DockerSuite) TestContainerAPICopyNotExistsAnyMore(c *check.C) {
+func (s *DockerSuite) TestContainerAPICopyNotExistsAnyMore(c *testing.T) {
name := "test-container-api-copy"
dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test.txt")
@@ -1057,7 +1016,7 @@
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
name := "test-container-api-copy"
dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test.txt")
@@ -1084,10 +1043,10 @@
break
}
}
- c.Assert(found, checker.True)
+ assert.Assert(c, found)
}
-func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPre124(c *check.C) {
+func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPre124(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
name := "test-container-api-copy-resource-empty"
dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test.txt")
@@ -1101,14 +1060,15 @@
if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") {
assert.Equal(c, res.StatusCode, http.StatusBadRequest)
} else {
- c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK)
+ assert.Assert(c, res.StatusCode != http.StatusOK)
}
b, err := request.ReadBody(body)
assert.NilError(c, err)
- c.Assert(string(b), checker.Matches, "Path cannot be empty\n")
+ assert.Assert(c, is.Regexp("^Path cannot be empty\n$", string(b)))
+
}
-func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *check.C) {
+func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
name := "test-container-api-copy-resource-not-found"
dockerCmd(c, "run", "--name", name, "busybox")
@@ -1126,10 +1086,11 @@
}
b, err := request.ReadBody(body)
assert.NilError(c, err)
- c.Assert(string(b), checker.Matches, "Could not find the file /notexist in container "+name+"\n")
+ assert.Assert(c, is.Regexp("^Could not find the file /notexist in container "+name+"\n$", string(b)))
+
}
-func (s *DockerSuite) TestContainerAPICopyContainerNotFoundPr124(c *check.C) {
+func (s *DockerSuite) TestContainerAPICopyContainerNotFoundPr124(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
postData := types.CopyConfig{
Resource: "/something",
@@ -1140,7 +1101,7 @@
assert.Equal(c, res.StatusCode, http.StatusNotFound)
}
-func (s *DockerSuite) TestContainerAPIDelete(c *check.C) {
+func (s *DockerSuite) TestContainerAPIDelete(c *testing.T) {
out := runSleepingContainer(c)
id := strings.TrimSpace(out)
@@ -1156,7 +1117,7 @@
assert.NilError(c, err)
}
-func (s *DockerSuite) TestContainerAPIDeleteNotExist(c *check.C) {
+func (s *DockerSuite) TestContainerAPIDeleteNotExist(c *testing.T) {
cli, err := client.NewClientWithOpts(client.FromEnv)
assert.NilError(c, err)
defer cli.Close()
@@ -1165,7 +1126,7 @@
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)
id := strings.TrimSpace(out)
assert.NilError(c, waitRun(id))
@@ -1182,7 +1143,7 @@
assert.NilError(c, err)
}
-func (s *DockerSuite) TestContainerAPIDeleteRemoveLinks(c *check.C) {
+func (s *DockerSuite) TestContainerAPIDeleteRemoveLinks(c *testing.T) {
// Windows does not support links
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "--name", "tlink1", "busybox", "top")
@@ -1193,10 +1154,10 @@
out, _ = dockerCmd(c, "run", "--link", "tlink1:tlink1", "--name", "tlink2", "-d", "busybox", "top")
id2 := strings.TrimSpace(out)
- c.Assert(waitRun(id2), checker.IsNil)
+ assert.Assert(c, waitRun(id2) == nil)
links := inspectFieldJSON(c, id2, "HostConfig.Links")
- c.Assert(links, checker.Equals, "[\"/tlink1:/tlink2/tlink1\"]", check.Commentf("expected to have links between containers"))
+ assert.Equal(c, links, "[\"/tlink1:/tlink2/tlink1\"]", "expected to have links between containers")
removeOptions := types.ContainerRemoveOptions{
RemoveLinks: true,
@@ -1210,10 +1171,10 @@
assert.NilError(c, err)
linksPostRm := inspectFieldJSON(c, id2, "HostConfig.Links")
- c.Assert(linksPostRm, checker.Equals, "null", check.Commentf("call to api deleteContainer links should have removed the specified links"))
+ assert.Equal(c, linksPostRm, "null", "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)
id := strings.TrimSpace(out)
@@ -1228,7 +1189,7 @@
assert.ErrorContains(c, err, expected)
}
-func (s *DockerSuite) TestContainerAPIDeleteRemoveVolume(c *check.C) {
+func (s *DockerSuite) TestContainerAPIDeleteRemoveVolume(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
vol := "/testvolume"
@@ -1259,11 +1220,11 @@
assert.NilError(c, err)
_, err = os.Stat(source)
- c.Assert(os.IsNotExist(err), checker.True, check.Commentf("expected to get ErrNotExist error, got %v", err))
+ assert.Assert(c, os.IsNotExist(err), "expected to get ErrNotExist error, got %v", err)
}
// 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{}{
"Image": "busybox",
@@ -1278,16 +1239,16 @@
req.ContentLength = -1
return nil
}))
- c.Assert(err, checker.IsNil, check.Commentf("error creating container with chunked encoding"))
+ assert.Assert(c, err == nil, "error creating container with chunked encoding")
defer resp.Body.Close()
assert.Equal(c, resp.StatusCode, http.StatusCreated)
}
-func (s *DockerSuite) TestContainerAPIPostContainerStop(c *check.C) {
+func (s *DockerSuite) TestContainerAPIPostContainerStop(c *testing.T) {
out := runSleepingContainer(c)
containerID := strings.TrimSpace(out)
- c.Assert(waitRun(containerID), checker.IsNil)
+ assert.Assert(c, waitRun(containerID) == nil)
cli, err := client.NewClientWithOpts(client.FromEnv)
assert.NilError(c, err)
@@ -1295,11 +1256,11 @@
err = cli.ContainerStop(context.Background(), containerID, nil)
assert.NilError(c, err)
- c.Assert(waitInspect(containerID, "{{ .State.Running }}", "false", 60*time.Second), checker.IsNil)
+ assert.Assert(c, waitInspect(containerID, "{{ .State.Running }}", "false", 60*time.Second) == nil)
}
// #14170
-func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *check.C) {
+func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *testing.T) {
config := containertypes.Config{
Image: "busybox",
Entrypoint: []string{"echo"},
@@ -1327,7 +1288,7 @@
}
// #14170
-func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *check.C) {
+func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *testing.T) {
config := containertypes.Config{
Image: "busybox",
Cmd: []string{"echo", "hello", "world"},
@@ -1356,7 +1317,7 @@
// regression #14318
// for backward compatibility testing with and without CAP_ prefix
// 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
testRequires(c, DaemonIsLinux)
config := struct {
@@ -1385,7 +1346,7 @@
}
// #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
config := containertypes.Config{
Image: "busybox",
@@ -1401,7 +1362,7 @@
// 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
// 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
// Requires local volume mount bind.
// --read-only + userns has remount issues
@@ -1427,7 +1388,7 @@
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
testRequires(c, DaemonIsLinux)
@@ -1460,7 +1421,7 @@
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
testRequires(c, DaemonIsLinux)
config := containertypes.Config{
@@ -1478,7 +1439,7 @@
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
testRequires(c, DaemonIsLinux)
var defaultSHMSize int64 = 67108864
@@ -1497,7 +1458,7 @@
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
assert.NilError(c, err)
- c.Assert(containerJSON.HostConfig.ShmSize, check.Equals, defaultSHMSize)
+ assert.Equal(c, containerJSON.HostConfig.ShmSize, defaultSHMSize)
out, _ := dockerCmd(c, "start", "-i", containerJSON.ID)
shmRegexp := regexp.MustCompile(`shm on /dev/shm type tmpfs(.*)size=65536k`)
@@ -1506,7 +1467,7 @@
}
}
-func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *check.C) {
+func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *testing.T) {
// ShmSize is not supported on Windows
testRequires(c, DaemonIsLinux)
config := containertypes.Config{
@@ -1524,7 +1485,7 @@
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
assert.NilError(c, err)
- c.Assert(containerJSON.HostConfig.ShmSize, check.Equals, int64(67108864))
+ assert.Equal(c, containerJSON.HostConfig.ShmSize, int64(67108864))
out, _ := dockerCmd(c, "start", "-i", containerJSON.ID)
shmRegexp := regexp.MustCompile(`shm on /dev/shm type tmpfs(.*)size=65536k`)
@@ -1533,7 +1494,7 @@
}
}
-func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *check.C) {
+func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *testing.T) {
// ShmSize is not supported on Windows
testRequires(c, DaemonIsLinux)
config := containertypes.Config{
@@ -1555,7 +1516,7 @@
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
assert.NilError(c, err)
- c.Assert(containerJSON.HostConfig.ShmSize, check.Equals, int64(1073741824))
+ assert.Equal(c, containerJSON.HostConfig.ShmSize, int64(1073741824))
out, _ := dockerCmd(c, "start", "-i", containerJSON.ID)
shmRegex := regexp.MustCompile(`shm on /dev/shm type tmpfs(.*)size=1048576k`)
@@ -1564,7 +1525,7 @@
}
}
-func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(c *check.C) {
+func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(c *testing.T) {
// Swappiness is not supported on Windows
testRequires(c, DaemonIsLinux)
config := containertypes.Config{
@@ -1582,14 +1543,14 @@
assert.NilError(c, err)
if versions.LessThan(testEnv.DaemonAPIVersion(), "1.31") {
- c.Assert(*containerJSON.HostConfig.MemorySwappiness, check.Equals, int64(-1))
+ assert.Equal(c, *containerJSON.HostConfig.MemorySwappiness, int64(-1))
} else {
- c.Assert(containerJSON.HostConfig.MemorySwappiness, check.IsNil)
+ assert.Assert(c, containerJSON.HostConfig.MemorySwappiness == nil)
}
}
// 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
testRequires(c, DaemonIsLinux)
@@ -1623,7 +1584,7 @@
}
// 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)
assert.NilError(c, err)
defer cli.Close()
@@ -1632,7 +1593,7 @@
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
testRequires(c, DaemonIsLinux)
@@ -1654,7 +1615,7 @@
err = cli.ContainerStart(context.Background(), name, types.ContainerStartOptions{})
assert.NilError(c, err)
- c.Assert(waitRun(name), check.IsNil)
+ assert.Assert(c, waitRun(name) == nil)
type b struct {
stats types.ContainerStats
@@ -1676,12 +1637,12 @@
case <-time.After(2 * time.Second):
c.Fatal("stream was not closed after container was removed")
case sr := <-bc:
- c.Assert(sr.err, checker.IsNil)
+ assert.Assert(c, sr.err == nil)
sr.stats.Body.Close()
}
}
-func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *check.C) {
+func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *testing.T) {
type testCase struct {
config containertypes.Config
hostConfig containertypes.HostConfig
@@ -1972,7 +1933,7 @@
}
}
-func (s *DockerSuite) TestContainerAPICreateMountsBindRead(c *check.C) {
+func (s *DockerSuite) TestContainerAPICreateMountsBindRead(c *testing.T) {
testRequires(c, NotUserNamespace, testEnv.IsLocalDaemon)
// also with data in the host side
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
@@ -2003,7 +1964,7 @@
}
// 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()
destPath := prefix + slash + "foo"
@@ -2092,8 +2053,7 @@
assert.NilError(c, err)
defer os.RemoveAll(tmpDir3)
- c.Assert(mount.Mount(tmpDir3, tmpDir3, "none", "bind,rw"), checker.IsNil)
- c.Assert(mount.ForceMount("", tmpDir3, "none", "shared"), checker.IsNil)
+ assert.Assert(c, mount.Mount(tmpDir3, tmpDir3, "none", "bind,shared") == nil)
cases = append(cases, []testCase{
{
@@ -2218,7 +2178,7 @@
}
}
-func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *check.C) {
+func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *testing.T) {
testRequires(c, DaemonIsLinux)
type testCase struct {
cfg mounttypes.Mount
@@ -2260,7 +2220,7 @@
assert.NilError(c, err)
out, _ := dockerCmd(c, "start", "-a", cName)
for _, option := range x.expectedOptions {
- c.Assert(out, checker.Contains, option)
+ assert.Assert(c, strings.Contains(out, option))
}
}
}
@@ -2268,7 +2228,7 @@
// Regression test for #33334
// 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.
-func (s *DockerSuite) TestContainerKillCustomStopSignal(c *check.C) {
+func (s *DockerSuite) TestContainerKillCustomStopSignal(c *testing.T) {
id := strings.TrimSpace(runSleepingContainer(c, "--stop-signal=SIGTERM", "--restart=always"))
res, _, err := request.Post("/containers/" + id + "/kill")
assert.NilError(c, err)
diff --git a/integration-cli/docker_api_containers_windows_test.go b/integration-cli/docker_api_containers_windows_test.go
index dc3fbef..8c2e96c 100644
--- a/integration-cli/docker_api_containers_windows_test.go
+++ b/integration-cli/docker_api_containers_windows_test.go
@@ -8,17 +8,17 @@
"io/ioutil"
"math/rand"
"strings"
+ "testing"
winio "github.com/Microsoft/go-winio"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/mount"
- "github.com/go-check/check"
"gotest.tools/assert"
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
// Create a host pipe to map into the container
diff --git a/integration-cli/docker_api_exec_resize_test.go b/integration-cli/docker_api_exec_resize_test.go
index 75be90b..0781fbb 100644
--- a/integration-cli/docker_api_exec_resize_test.go
+++ b/integration-cli/docker_api_exec_resize_test.go
@@ -8,14 +8,14 @@
"net/http"
"strings"
"sync"
+ "testing"
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/internal/test/request"
- "github.com/go-check/check"
"gotest.tools/assert"
)
-func (s *DockerSuite) TestExecResizeAPIHeightWidthNoInt(c *check.C) {
+func (s *DockerSuite) TestExecResizeAPIHeightWidthNoInt(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
cleanedContainerID := strings.TrimSpace(out)
@@ -31,7 +31,7 @@
}
// Part of #14845
-func (s *DockerSuite) TestExecResizeImmediatelyAfterExecStart(c *check.C) {
+func (s *DockerSuite) TestExecResizeImmediatelyAfterExecStart(c *testing.T) {
name := "exec_resize_test"
dockerCmd(c, "run", "-d", "-i", "-t", "--name", name, "--restart", "always", "busybox", "/bin/sh")
diff --git a/integration-cli/docker_api_exec_test.go b/integration-cli/docker_api_exec_test.go
index 78c89f1..b8c257f 100644
--- a/integration-cli/docker_api_exec_test.go
+++ b/integration-cli/docker_api_exec_test.go
@@ -9,6 +9,7 @@
"net/http"
"os"
"strings"
+ "testing"
"time"
"github.com/docker/docker/api/types"
@@ -16,12 +17,12 @@
"github.com/docker/docker/client"
"github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/internal/test/request"
- "github.com/go-check/check"
"gotest.tools/assert"
+ "gotest.tools/poll"
)
// Regression test for #9414
-func (s *DockerSuite) TestExecAPICreateNoCmd(c *check.C) {
+func (s *DockerSuite) TestExecAPICreateNoCmd(c *testing.T) {
name := "exec_test"
dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
@@ -37,7 +38,7 @@
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"
dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
@@ -58,7 +59,7 @@
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
testRequires(c, DaemonIsLinux)
name := "exec_create_test"
@@ -77,7 +78,7 @@
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
dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top")
@@ -104,7 +105,7 @@
startExec(c, id, http.StatusOK)
}
-func (s *DockerSuite) TestExecAPIStartEnsureHeaders(c *check.C) {
+func (s *DockerSuite) TestExecAPIStartEnsureHeaders(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top")
@@ -114,7 +115,7 @@
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
runSleepingContainer(c, "-d", "--name", "test")
id := createExec(c, "test")
@@ -123,13 +124,13 @@
assert.NilError(c, err)
b, err := request.ReadBody(body)
- comment := check.Commentf("response body: %s", b)
+ comment := fmt.Sprintf("response body: %s", b)
assert.NilError(c, err, comment)
assert.Equal(c, resp.StatusCode, http.StatusOK, comment)
}
// #19362
-func (s *DockerSuite) TestExecAPIStartMultipleTimesError(c *check.C) {
+func (s *DockerSuite) TestExecAPIStartMultipleTimesError(c *testing.T) {
runSleepingContainer(c, "-d", "--name", "test")
execID := createExec(c, "test")
startExec(c, execID, http.StatusOK)
@@ -139,7 +140,7 @@
}
// #20638
-func (s *DockerSuite) TestExecAPIStartWithDetach(c *check.C) {
+func (s *DockerSuite) TestExecAPIStartWithDetach(c *testing.T) {
name := "foo"
runSleepingContainer(c, "-d", "-t", "--name", name)
@@ -159,7 +160,7 @@
assert.NilError(c, err)
b, err := request.ReadBody(body)
- comment := check.Commentf("response body: %s", b)
+ comment := fmt.Sprintf("response body: %s", b)
assert.NilError(c, err, comment)
resp, _, err := request.Get("/_ping")
@@ -170,7 +171,7 @@
}
// #30311
-func (s *DockerSuite) TestExecAPIStartValidCommand(c *check.C) {
+func (s *DockerSuite) TestExecAPIStartValidCommand(c *testing.T) {
name := "exec_test"
dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
@@ -186,7 +187,7 @@
}
// #30311
-func (s *DockerSuite) TestExecAPIStartInvalidCommand(c *check.C) {
+func (s *DockerSuite) TestExecAPIStartInvalidCommand(c *testing.T) {
name := "exec_test"
dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
@@ -204,7 +205,7 @@
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)
// This test checks accidental regressions. Not part of stable API.
@@ -215,10 +216,10 @@
stateDir := "/var/run/docker/containerd/" + cid
- checkReadDir := func(c *check.C) (interface{}, check.CommentInterface) {
+ checkReadDir := func(c *testing.T) (interface{}, string) {
fi, err := ioutil.ReadDir(stateDir)
assert.NilError(c, err)
- return len(fi), nil
+ return len(fi), ""
}
fi, err := ioutil.ReadDir(stateDir)
@@ -229,13 +230,13 @@
startExec(c, id, http.StatusOK)
waitForExec(c, id)
- waitAndAssert(c, 5*time.Second, checkReadDir, checker.Equals, len(fi))
+ poll.WaitOn(c, pollCheck(c, checkReadDir, checker.Equals(len(fi))), poll.WithTimeout(5*time.Second))
id = createExecCmd(c, name, "invalid")
startExec(c, id, http.StatusBadRequest)
waitForExec(c, id)
- waitAndAssert(c, 5*time.Second, checkReadDir, checker.Equals, len(fi))
+ poll.WaitOn(c, pollCheck(c, checkReadDir, checker.Equals(len(fi))), poll.WithTimeout(5*time.Second))
dockerCmd(c, "stop", name)
_, err = os.Stat(stateDir)
@@ -243,11 +244,11 @@
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")
}
-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}}))
assert.NilError(c, err)
b, err := ioutil.ReadAll(reader)
@@ -260,7 +261,7 @@
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)
assert.NilError(c, err)
@@ -269,7 +270,7 @@
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))
assert.NilError(c, err)
defer body.Close()
@@ -278,7 +279,7 @@
assert.NilError(c, err)
}
-func waitForExec(c *check.C, id string) {
+func waitForExec(c *testing.T, id string) {
timeout := time.After(60 * time.Second)
var execJSON struct{ Running bool }
for {
@@ -295,7 +296,7 @@
}
}
-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))
assert.NilError(c, err)
defer body.Close()
diff --git a/integration-cli/docker_api_images_test.go b/integration-cli/docker_api_images_test.go
index a281ce2..cf60310 100644
--- a/integration-cli/docker_api_images_test.go
+++ b/integration-cli/docker_api_images_test.go
@@ -7,6 +7,7 @@
"runtime"
"strconv"
"strings"
+ "testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
@@ -15,11 +16,10 @@
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/pkg/parsers/kernel"
- "github.com/go-check/check"
"gotest.tools/assert"
)
-func (s *DockerSuite) TestAPIImagesFilter(c *check.C) {
+func (s *DockerSuite) TestAPIImagesFilter(c *testing.T) {
cli, err := client.NewClientWithOpts(client.FromEnv)
assert.NilError(c, err)
defer cli.Close()
@@ -57,7 +57,7 @@
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" {
v, err := kernel.GetKernelVersion()
assert.NilError(c, err)
@@ -87,7 +87,7 @@
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)
assert.NilError(c, err)
defer cli.Close()
@@ -111,7 +111,7 @@
assert.NilError(c, err)
}
-func (s *DockerSuite) TestAPIImagesHistory(c *check.C) {
+func (s *DockerSuite) TestAPIImagesHistory(c *testing.T) {
cli, err := client.NewClientWithOpts(client.FromEnv)
assert.NilError(c, err)
defer cli.Close()
@@ -137,7 +137,7 @@
assert.Assert(c, found)
}
-func (s *DockerSuite) TestAPIImagesImportBadSrc(c *check.C) {
+func (s *DockerSuite) TestAPIImagesImportBadSrc(c *testing.T) {
if runtime.GOOS == "windows" {
v, err := kernel.GetKernelVersion()
assert.NilError(c, err)
@@ -172,7 +172,7 @@
}
// #14846
-func (s *DockerSuite) TestAPIImagesSearchJSONContentType(c *check.C) {
+func (s *DockerSuite) TestAPIImagesSearchJSONContentType(c *testing.T) {
testRequires(c, Network)
res, b, err := request.Get("/images/search?term=test", request.JSON)
@@ -184,7 +184,7 @@
// 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.
-func (s *DockerSuite) TestAPIImagesSizeCompatibility(c *check.C) {
+func (s *DockerSuite) TestAPIImagesSizeCompatibility(c *testing.T) {
apiclient := testEnv.APIClient()
defer apiclient.Close()
diff --git a/integration-cli/docker_api_inspect_test.go b/integration-cli/docker_api_inspect_test.go
index cc0fbc3..3808e8e 100644
--- a/integration-cli/docker_api_inspect_test.go
+++ b/integration-cli/docker_api_inspect_test.go
@@ -4,16 +4,16 @@
"context"
"encoding/json"
"strings"
+ "testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/versions/v1p20"
"github.com/docker/docker/client"
- "github.com/go-check/check"
"gotest.tools/assert"
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")
cleanedContainerID := strings.TrimSpace(out)
@@ -57,7 +57,7 @@
}
}
-func (s *DockerSuite) TestInspectAPIContainerVolumeDriverLegacy(c *check.C) {
+func (s *DockerSuite) TestInspectAPIContainerVolumeDriverLegacy(c *testing.T) {
// No legacy implications for Windows
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
@@ -80,7 +80,7 @@
}
}
-func (s *DockerSuite) TestInspectAPIContainerVolumeDriver(c *check.C) {
+func (s *DockerSuite) TestInspectAPIContainerVolumeDriver(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "--volume-driver", "local", "busybox", "true")
cleanedContainerID := strings.TrimSpace(out)
@@ -104,7 +104,7 @@
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")
cli, err := client.NewClientWithOpts(client.FromEnv)
assert.NilError(c, err)
@@ -119,7 +119,7 @@
}
// #17131, #17139, #17173
-func (s *DockerSuite) TestInspectAPIEmptyFieldsInConfigPre121(c *check.C) {
+func (s *DockerSuite) TestInspectAPIEmptyFieldsInConfigPre121(c *testing.T) {
// Not relevant on Windows
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
@@ -143,7 +143,7 @@
}
}
-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
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
@@ -160,7 +160,7 @@
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
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
diff --git a/integration-cli/docker_api_logs_test.go b/integration-cli/docker_api_logs_test.go
index 62a48f5..8a0d540 100644
--- a/integration-cli/docker_api_logs_test.go
+++ b/integration-cli/docker_api_logs_test.go
@@ -10,17 +10,17 @@
"net/http"
"strconv"
"strings"
+ "testing"
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/pkg/stdcopy"
- "github.com/go-check/check"
"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")
id := strings.TrimSpace(out)
assert.NilError(c, waitRun(id))
@@ -56,7 +56,7 @@
}
}
-func (s *DockerSuite) TestLogsAPINoStdoutNorStderr(c *check.C) {
+func (s *DockerSuite) TestLogsAPINoStdoutNorStderr(c *testing.T) {
name := "logs_test"
dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
cli, err := client.NewClientWithOpts(client.FromEnv)
@@ -68,7 +68,7 @@
}
// Regression test for #12704
-func (s *DockerSuite) TestLogsAPIFollowEmptyOutput(c *check.C) {
+func (s *DockerSuite) TestLogsAPIFollowEmptyOutput(c *testing.T) {
name := "logs_test"
t0 := time.Now()
dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "sleep", "10")
@@ -83,14 +83,14 @@
}
}
-func (s *DockerSuite) TestLogsAPIContainerNotFound(c *check.C) {
+func (s *DockerSuite) TestLogsAPIContainerNotFound(c *testing.T) {
name := "nonExistentContainer"
resp, _, err := request.Get(fmt.Sprintf("/containers/%s/logs?follow=1&stdout=1&stderr=1&tail=all", name))
assert.NilError(c, err)
assert.Equal(c, resp.StatusCode, http.StatusNotFound)
}
-func (s *DockerSuite) TestLogsAPIUntilFutureFollow(c *check.C) {
+func (s *DockerSuite) TestLogsAPIUntilFutureFollow(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "logsuntilfuturefollow"
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) TestLogsAPIUntil(c *check.C) {
+func (s *DockerSuite) TestLogsAPIUntil(c *testing.T) {
testRequires(c, MinimumAPIVersion("1.34"))
name := "logsuntil"
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 @@
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)
assert.NilError(c, err)
@@ -185,7 +185,7 @@
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"
dockerCmd(c, "run", "--name", name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do echo log$i; done")
@@ -194,7 +194,7 @@
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)
assert.NilError(c, err)
diff --git a/integration-cli/docker_api_network_test.go b/integration-cli/docker_api_network_test.go
index 3e854c7..baa43d0 100644
--- a/integration-cli/docker_api_network_test.go
+++ b/integration-cli/docker_api_network_test.go
@@ -7,17 +7,17 @@
"net/http"
"net/url"
"strings"
+ "testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/internal/test/request"
- "github.com/go-check/check"
"gotest.tools/assert"
)
-func (s *DockerSuite) TestAPINetworkGetDefaults(c *check.C) {
+func (s *DockerSuite) TestAPINetworkGetDefaults(c *testing.T) {
testRequires(c, DaemonIsLinux)
// By default docker daemon creates 3 networks. check if they are present
defaults := []string{"bridge", "host", "none"}
@@ -26,7 +26,7 @@
}
}
-func (s *DockerSuite) TestAPINetworkCreateCheckDuplicate(c *check.C) {
+func (s *DockerSuite) TestAPINetworkCreateCheckDuplicate(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "testcheckduplicate"
configOnCheck := types.NetworkCreateRequest{
@@ -64,13 +64,13 @@
createNetwork(c, configNotCheck, http.StatusCreated)
}
-func (s *DockerSuite) TestAPINetworkFilter(c *check.C) {
+func (s *DockerSuite) TestAPINetworkFilter(c *testing.T) {
testRequires(c, DaemonIsLinux)
nr := getNetworkResource(c, getNetworkIDByName(c, "bridge"))
assert.Equal(c, nr.Name, "bridge")
}
-func (s *DockerSuite) TestAPINetworkInspectBridge(c *check.C) {
+func (s *DockerSuite) TestAPINetworkInspectBridge(c *testing.T) {
testRequires(c, DaemonIsLinux)
// Inspect default bridge network
nr := getNetworkResource(c, "bridge")
@@ -96,7 +96,7 @@
assert.Equal(c, ip.String(), containerIP)
}
-func (s *DockerSuite) TestAPINetworkInspectUserDefinedNetwork(c *check.C) {
+func (s *DockerSuite) TestAPINetworkInspectUserDefinedNetwork(c *testing.T) {
testRequires(c, DaemonIsLinux)
// IPAM configuration inspect
ipam := &network.IPAM{
@@ -127,7 +127,7 @@
assert.Assert(c, !isNetworkAvailable(c, "br0"))
}
-func (s *DockerSuite) TestAPINetworkConnectDisconnect(c *check.C) {
+func (s *DockerSuite) TestAPINetworkConnectDisconnect(c *testing.T) {
testRequires(c, DaemonIsLinux)
// Create test network
name := "testnetwork"
@@ -169,7 +169,7 @@
deleteNetwork(c, nr.ID, true)
}
-func (s *DockerSuite) TestAPINetworkIPAMMultipleBridgeNetworks(c *check.C) {
+func (s *DockerSuite) TestAPINetworkIPAMMultipleBridgeNetworks(c *testing.T) {
testRequires(c, DaemonIsLinux)
// test0 bridge network
ipam0 := &network.IPAM{
@@ -238,14 +238,14 @@
}
}
-func (s *DockerSuite) TestAPICreateDeletePredefinedNetworks(c *check.C) {
+func (s *DockerSuite) TestAPICreateDeletePredefinedNetworks(c *testing.T) {
testRequires(c, DaemonIsLinux, SwarmInactive)
createDeletePredefinedNetwork(c, "bridge")
createDeletePredefinedNetwork(c, "none")
createDeletePredefinedNetwork(c, "host")
}
-func createDeletePredefinedNetwork(c *check.C, name string) {
+func createDeletePredefinedNetwork(c *testing.T, name string) {
// Create pre-defined network
config := types.NetworkCreateRequest{
Name: name,
@@ -267,7 +267,7 @@
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")
assert.NilError(c, err)
defer resp.Body.Close()
@@ -285,7 +285,7 @@
return false
}
-func getNetworkIDByName(c *check.C, name string) string {
+func getNetworkIDByName(c *testing.T, name string) string {
var (
v = url.Values{}
filterArgs = filters.NewArgs()
@@ -314,7 +314,7 @@
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)
assert.NilError(c, err)
@@ -325,7 +325,7 @@
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))
assert.NilError(c, err)
defer resp.Body.Close()
@@ -346,7 +346,7 @@
return ""
}
-func connectNetwork(c *check.C, nid, cid string) {
+func connectNetwork(c *testing.T, nid, cid string) {
config := types.NetworkConnect{
Container: cid,
}
@@ -356,7 +356,7 @@
assert.NilError(c, err)
}
-func disconnectNetwork(c *check.C, nid, cid string) {
+func disconnectNetwork(c *testing.T, nid, cid string) {
config := types.NetworkConnect{
Container: cid,
}
@@ -366,7 +366,7 @@
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)
assert.NilError(c, err)
defer resp.Body.Close()
diff --git a/integration-cli/docker_api_stats_test.go b/integration-cli/docker_api_stats_test.go
index 63ee923..3c04bdb 100644
--- a/integration-cli/docker_api_stats_test.go
+++ b/integration-cli/docker_api_stats_test.go
@@ -10,19 +10,19 @@
"strconv"
"strings"
"sync"
+ "testing"
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/client"
"github.com/docker/docker/internal/test/request"
- "github.com/go-check/check"
"gotest.tools/assert"
)
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")
id := strings.TrimSpace(out)
@@ -62,7 +62,7 @@
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")
id := strings.TrimSpace(out)
@@ -97,7 +97,7 @@
}
}
-func (s *DockerSuite) TestAPIStatsNetworkStats(c *check.C) {
+func (s *DockerSuite) TestAPIStatsNetworkStats(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
out := runSleepingContainer(c)
@@ -162,7 +162,7 @@
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
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
@@ -187,7 +187,7 @@
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
_, body, err := request.Get(fmt.Sprintf("/containers/%s/stats?stream=false", id))
@@ -204,7 +204,7 @@
// container with id using an API call with version apiVersion. Since the
// stats result type differs between API versions, we simply return
// 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{})
_, body, err := request.Get(fmt.Sprintf("/%s/containers/%s/stats?stream=false", apiVersion, id))
@@ -257,7 +257,7 @@
return true
}
-func (s *DockerSuite) TestAPIStatsContainerNotFound(c *check.C) {
+func (s *DockerSuite) TestAPIStatsContainerNotFound(c *testing.T) {
testRequires(c, DaemonIsLinux)
cli, err := client.NewClientWithOpts(client.FromEnv)
assert.NilError(c, err)
@@ -271,7 +271,7 @@
assert.ErrorContains(c, err, expected)
}
-func (s *DockerSuite) TestAPIStatsNoStreamConnectedContainers(c *check.C) {
+func (s *DockerSuite) TestAPIStatsNoStreamConnectedContainers(c *testing.T) {
testRequires(c, DaemonIsLinux)
out1 := runSleepingContainer(c)
diff --git a/integration-cli/docker_api_swarm_node_test.go b/integration-cli/docker_api_swarm_node_test.go
index 8a21591..7e867bc 100644
--- a/integration-cli/docker_api_swarm_node_test.go
+++ b/integration-cli/docker_api_swarm_node_test.go
@@ -3,21 +3,24 @@
package main
import (
+ "fmt"
+ "testing"
"time"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/daemon"
- "github.com/go-check/check"
+ "gotest.tools/assert"
+ "gotest.tools/poll"
)
-func (s *DockerSwarmSuite) TestAPISwarmListNodes(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmListNodes(c *testing.T) {
d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, false)
d3 := s.AddDaemon(c, true, false)
nodes := d1.ListNodes(c)
- c.Assert(len(nodes), checker.Equals, 3, check.Commentf("nodes: %#v", nodes))
+ assert.Equal(c, len(nodes), 3, fmt.Sprintf("nodes: %#v", nodes))
loop0:
for _, n := range nodes {
@@ -30,7 +33,7 @@
}
}
-func (s *DockerSwarmSuite) TestAPISwarmNodeUpdate(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmNodeUpdate(c *testing.T) {
d := s.AddDaemon(c, true, true)
nodes := d.ListNodes(c)
@@ -40,17 +43,17 @@
})
n := d.GetNode(c, nodes[0].ID)
- c.Assert(n.Spec.Availability, checker.Equals, swarm.NodeAvailabilityPause)
+ assert.Equal(c, n.Spec.Availability, swarm.NodeAvailabilityPause)
}
-func (s *DockerSwarmSuite) TestAPISwarmNodeRemove(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmNodeRemove(c *testing.T) {
testRequires(c, Network)
d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, false)
_ = s.AddDaemon(c, true, false)
nodes := d1.ListNodes(c)
- c.Assert(len(nodes), checker.Equals, 3, check.Commentf("nodes: %#v", nodes))
+ assert.Equal(c, len(nodes), 3, fmt.Sprintf("nodes: %#v", nodes))
// Getting the info so we can take the NodeID
d2Info := d2.SwarmInfo(c)
@@ -59,7 +62,7 @@
d1.RemoveNode(c, d2Info.NodeID, true)
nodes = d1.ListNodes(c)
- c.Assert(len(nodes), checker.Equals, 2, check.Commentf("nodes: %#v", nodes))
+ assert.Equal(c, len(nodes), 2, fmt.Sprintf("nodes: %#v", nodes))
// Restart the node that was removed
d2.RestartNode(c)
@@ -69,10 +72,10 @@
// Make sure the node didn't rejoin
nodes = d1.ListNodes(c)
- c.Assert(len(nodes), checker.Equals, 2, check.Commentf("nodes: %#v", nodes))
+ assert.Equal(c, len(nodes), 2, fmt.Sprintf("nodes: %#v", nodes))
}
-func (s *DockerSwarmSuite) TestAPISwarmNodeDrainPause(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmNodeDrainPause(c *testing.T) {
d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, false)
@@ -82,16 +85,16 @@
instances := 2
id := d1.CreateService(c, simpleTestService, setInstances(instances))
- waitAndAssert(c, defaultReconciliationTimeout, d1.CheckActiveContainerCount, checker.GreaterThan, 0)
- waitAndAssert(c, defaultReconciliationTimeout, d2.CheckActiveContainerCount, checker.GreaterThan, 0)
- waitAndAssert(c, defaultReconciliationTimeout, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, d1.CheckActiveContainerCount, checker.GreaterThan(0)), poll.WithTimeout(defaultReconciliationTimeout))
+ poll.WaitOn(c, pollCheck(c, d2.CheckActiveContainerCount, checker.GreaterThan(0)), poll.WithTimeout(defaultReconciliationTimeout))
+ poll.WaitOn(c, pollCheck(c, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
// drain d2, all containers should move to d1
d1.UpdateNode(c, d2.NodeID(), func(n *swarm.Node) {
n.Spec.Availability = swarm.NodeAvailabilityDrain
})
- waitAndAssert(c, defaultReconciliationTimeout, d1.CheckActiveContainerCount, checker.Equals, instances)
- waitAndAssert(c, defaultReconciliationTimeout, d2.CheckActiveContainerCount, checker.Equals, 0)
+ poll.WaitOn(c, pollCheck(c, d1.CheckActiveContainerCount, checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
+ poll.WaitOn(c, pollCheck(c, d2.CheckActiveContainerCount, checker.Equals(0)), poll.WithTimeout(defaultReconciliationTimeout))
// set d2 back to active
d1.UpdateNode(c, d2.NodeID(), func(n *swarm.Node) {
@@ -100,15 +103,15 @@
instances = 1
d1.UpdateService(c, d1.GetService(c, id), setInstances(instances))
- waitAndAssert(c, defaultReconciliationTimeout*2, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout*2))
instances = 2
d1.UpdateService(c, d1.GetService(c, id), setInstances(instances))
// drained node first so we don't get any old containers
- waitAndAssert(c, defaultReconciliationTimeout, d2.CheckActiveContainerCount, checker.GreaterThan, 0)
- waitAndAssert(c, defaultReconciliationTimeout, d1.CheckActiveContainerCount, checker.GreaterThan, 0)
- waitAndAssert(c, defaultReconciliationTimeout*2, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, d2.CheckActiveContainerCount, checker.GreaterThan(0)), poll.WithTimeout(defaultReconciliationTimeout))
+ poll.WaitOn(c, pollCheck(c, d1.CheckActiveContainerCount, checker.GreaterThan(0)), poll.WithTimeout(defaultReconciliationTimeout))
+ poll.WaitOn(c, pollCheck(c, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout*2))
d2ContainerCount := len(d2.ActiveContainers(c))
@@ -119,7 +122,7 @@
instances = 4
d1.UpdateService(c, d1.GetService(c, id), setInstances(instances))
- waitAndAssert(c, defaultReconciliationTimeout, d1.CheckActiveContainerCount, checker.Equals, instances-d2ContainerCount)
- waitAndAssert(c, defaultReconciliationTimeout, d2.CheckActiveContainerCount, checker.Equals, d2ContainerCount)
+ poll.WaitOn(c, pollCheck(c, d1.CheckActiveContainerCount, checker.Equals(instances-d2ContainerCount)), poll.WithTimeout(defaultReconciliationTimeout))
+ poll.WaitOn(c, pollCheck(c, d2.CheckActiveContainerCount, checker.Equals(d2ContainerCount)), poll.WithTimeout(defaultReconciliationTimeout))
}
diff --git a/integration-cli/docker_api_swarm_service_test.go b/integration-cli/docker_api_swarm_service_test.go
index e582558..e0500e6 100644
--- a/integration-cli/docker_api_swarm_service_test.go
+++ b/integration-cli/docker_api_swarm_service_test.go
@@ -7,6 +7,7 @@
"fmt"
"strconv"
"strings"
+ "testing"
"time"
"github.com/docker/docker/api/types"
@@ -16,10 +17,10 @@
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/integration-cli/daemon"
testdaemon "github.com/docker/docker/internal/test/daemon"
- "github.com/go-check/check"
"golang.org/x/sys/unix"
"gotest.tools/assert"
"gotest.tools/icmd"
+ "gotest.tools/poll"
)
func setPortConfig(portConfig []swarm.PortConfig) testdaemon.ServiceConstructor {
@@ -31,13 +32,13 @@
}
}
-func (s *DockerSwarmSuite) TestAPIServiceUpdatePort(c *check.C) {
+func (s *DockerSwarmSuite) TestAPIServiceUpdatePort(c *testing.T) {
d := s.AddDaemon(c, true, true)
// Create a service with a port mapping of 8080:8081.
portConfig := []swarm.PortConfig{{TargetPort: 8081, PublishedPort: 8080}}
serviceID := d.CreateService(c, simpleTestService, setInstances(1), setPortConfig(portConfig))
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
// Update the service: changed the port mapping from 8080:8081 to 8082:8083.
updatedPortConfig := []swarm.PortConfig{{TargetPort: 8083, PublishedPort: 8082}}
@@ -52,7 +53,7 @@
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)
services := d.ListServices(c)
@@ -60,12 +61,12 @@
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)
instances := 2
id := d.CreateService(c, simpleTestService, setInstances(instances))
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
client := d.NewClientT(c)
defer client.Close()
@@ -87,13 +88,13 @@
service := d.GetService(c, id)
instances = 5
d.UpdateService(c, service, setInstances(instances))
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
d.RemoveService(c, service.ID)
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 0)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(0)), poll.WithTimeout(defaultReconciliationTimeout))
}
-func (s *DockerSwarmSuite) TestAPISwarmServicesMultipleAgents(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmServicesMultipleAgents(c *testing.T) {
d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, false)
d3 := s.AddDaemon(c, true, false)
@@ -103,50 +104,50 @@
instances := 9
id := d1.CreateService(c, simpleTestService, setInstances(instances))
- waitAndAssert(c, defaultReconciliationTimeout, d1.CheckActiveContainerCount, checker.GreaterThan, 0)
- waitAndAssert(c, defaultReconciliationTimeout, d2.CheckActiveContainerCount, checker.GreaterThan, 0)
- waitAndAssert(c, defaultReconciliationTimeout, d3.CheckActiveContainerCount, checker.GreaterThan, 0)
+ poll.WaitOn(c, pollCheck(c, d1.CheckActiveContainerCount, checker.GreaterThan(0)), poll.WithTimeout(defaultReconciliationTimeout))
+ poll.WaitOn(c, pollCheck(c, d2.CheckActiveContainerCount, checker.GreaterThan(0)), poll.WithTimeout(defaultReconciliationTimeout))
+ poll.WaitOn(c, pollCheck(c, d3.CheckActiveContainerCount, checker.GreaterThan(0)), poll.WithTimeout(defaultReconciliationTimeout))
- waitAndAssert(c, defaultReconciliationTimeout, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount, d3.CheckActiveContainerCount), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount, d3.CheckActiveContainerCount), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
// reconciliation on d2 node down
d2.Stop(c)
- waitAndAssert(c, defaultReconciliationTimeout, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d3.CheckActiveContainerCount), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d3.CheckActiveContainerCount), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
// test downscaling
instances = 5
d1.UpdateService(c, d1.GetService(c, id), setInstances(instances))
- waitAndAssert(c, defaultReconciliationTimeout, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d3.CheckActiveContainerCount), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d3.CheckActiveContainerCount), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
}
-func (s *DockerSwarmSuite) TestAPISwarmServicesCreateGlobal(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmServicesCreateGlobal(c *testing.T) {
d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, false)
d3 := s.AddDaemon(c, true, false)
d1.CreateService(c, simpleTestService, setGlobalMode)
- waitAndAssert(c, defaultReconciliationTimeout, d1.CheckActiveContainerCount, checker.Equals, 1)
- waitAndAssert(c, defaultReconciliationTimeout, d2.CheckActiveContainerCount, checker.Equals, 1)
- waitAndAssert(c, defaultReconciliationTimeout, d3.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d1.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
+ poll.WaitOn(c, pollCheck(c, d2.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
+ poll.WaitOn(c, pollCheck(c, d3.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
d4 := s.AddDaemon(c, true, false)
d5 := s.AddDaemon(c, true, false)
- waitAndAssert(c, defaultReconciliationTimeout, d4.CheckActiveContainerCount, checker.Equals, 1)
- waitAndAssert(c, defaultReconciliationTimeout, d5.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d4.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
+ poll.WaitOn(c, pollCheck(c, d5.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
}
-func (s *DockerSwarmSuite) TestAPISwarmServicesUpdate(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmServicesUpdate(c *testing.T) {
const nodeCount = 3
var daemons [nodeCount]*daemon.Daemon
for i := 0; i < nodeCount; i++ {
daemons[i] = s.AddDaemon(c, true, i == 0)
}
// wait for nodes ready
- waitAndAssert(c, 5*time.Second, daemons[0].CheckNodeReadyCount, checker.Equals, nodeCount)
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckNodeReadyCount, checker.Equals(nodeCount)), poll.WithTimeout(5*time.Second))
// service image at start
image1 := "busybox:latest"
@@ -166,24 +167,20 @@
id := daemons[0].CreateService(c, serviceForUpdate, setInstances(instances))
// wait for tasks ready
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image1: instances})
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckRunningTaskImages, checker.DeepEquals(map[string]int{image1: instances})), poll.WithTimeout(defaultReconciliationTimeout))
// issue service update
service := daemons[0].GetService(c, id)
daemons[0].UpdateService(c, service, setImage(image2))
// first batch
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image1: instances - parallelism, image2: parallelism})
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckRunningTaskImages, checker.DeepEquals(map[string]int{image1: instances - parallelism, image2: parallelism})), poll.WithTimeout(defaultReconciliationTimeout))
// 2nd batch
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image1: instances - 2*parallelism, image2: 2 * parallelism})
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckRunningTaskImages, checker.DeepEquals(map[string]int{image1: instances - 2*parallelism, image2: 2 * parallelism})), poll.WithTimeout(defaultReconciliationTimeout))
// 3nd batch
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image2: instances})
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckRunningTaskImages, checker.DeepEquals(map[string]int{image2: instances})), poll.WithTimeout(defaultReconciliationTimeout))
// Roll back to the previous version. This uses the CLI because
// rollback used to be a client-side operation.
@@ -191,15 +188,14 @@
assert.NilError(c, err, out)
// first batch
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image2: instances - rollbackParallelism, image1: rollbackParallelism})
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckRunningTaskImages, checker.DeepEquals(map[string]int{image2: instances - rollbackParallelism, image1: rollbackParallelism})), poll.WithTimeout(defaultReconciliationTimeout))
// 2nd batch
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image1: instances})
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckRunningTaskImages, checker.DeepEquals(map[string]int{image1: instances})), poll.WithTimeout(defaultReconciliationTimeout))
+
}
-func (s *DockerSwarmSuite) TestAPISwarmServicesUpdateStartFirst(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmServicesUpdateStartFirst(c *testing.T) {
d := s.AddDaemon(c, true, true)
// service image at start
@@ -223,7 +219,7 @@
checkStartingTasks := func(expected int) []swarm.Task {
var startingTasks []swarm.Task
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
tasks := d.GetServiceTasks(c, id)
startingTasks = nil
for _, t := range tasks {
@@ -231,8 +227,8 @@
startingTasks = append(startingTasks, t)
}
}
- return startingTasks, nil
- }, checker.HasLen, expected)
+ return startingTasks, ""
+ }, checker.HasLen(expected)), poll.WithTimeout(defaultReconciliationTimeout))
return startingTasks
}
@@ -245,8 +241,7 @@
}
// wait for tasks ready
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image1: instances})
+ poll.WaitOn(c, pollCheck(c, d.CheckRunningTaskImages, checker.DeepEquals(map[string]int{image1: instances})), poll.WithTimeout(defaultReconciliationTimeout))
// issue service update
service := d.GetService(c, id)
@@ -257,42 +252,36 @@
// The old tasks should be running, and the new ones should be starting.
startingTasks := checkStartingTasks(parallelism)
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image1: instances})
+ poll.WaitOn(c, pollCheck(c, d.CheckRunningTaskImages, checker.DeepEquals(map[string]int{image1: instances})), poll.WithTimeout(defaultReconciliationTimeout))
// make it healthy
makeTasksHealthy(startingTasks)
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image1: instances - parallelism, image2: parallelism})
+ poll.WaitOn(c, pollCheck(c, d.CheckRunningTaskImages, checker.DeepEquals(map[string]int{image1: instances - parallelism, image2: parallelism})), poll.WithTimeout(defaultReconciliationTimeout))
// 2nd batch
// The old tasks should be running, and the new ones should be starting.
startingTasks = checkStartingTasks(parallelism)
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image1: instances - parallelism, image2: parallelism})
+ poll.WaitOn(c, pollCheck(c, d.CheckRunningTaskImages, checker.DeepEquals(map[string]int{image1: instances - parallelism, image2: parallelism})), poll.WithTimeout(defaultReconciliationTimeout))
// make it healthy
makeTasksHealthy(startingTasks)
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image1: instances - 2*parallelism, image2: 2 * parallelism})
+ poll.WaitOn(c, pollCheck(c, d.CheckRunningTaskImages, checker.DeepEquals(map[string]int{image1: instances - 2*parallelism, image2: 2 * parallelism})), poll.WithTimeout(defaultReconciliationTimeout))
// 3nd batch
// The old tasks should be running, and the new ones should be starting.
startingTasks = checkStartingTasks(1)
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image1: instances - 2*parallelism, image2: 2 * parallelism})
+ poll.WaitOn(c, pollCheck(c, d.CheckRunningTaskImages, checker.DeepEquals(map[string]int{image1: instances - 2*parallelism, image2: 2 * parallelism})), poll.WithTimeout(defaultReconciliationTimeout))
// make it healthy
makeTasksHealthy(startingTasks)
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image2: instances})
+ poll.WaitOn(c, pollCheck(c, d.CheckRunningTaskImages, checker.DeepEquals(map[string]int{image2: instances})), poll.WithTimeout(defaultReconciliationTimeout))
// Roll back to the previous version. This uses the CLI because
// rollback is a client-side operation.
@@ -300,22 +289,21 @@
assert.NilError(c, err, out)
// first batch
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image2: instances - rollbackParallelism, image1: rollbackParallelism})
+ poll.WaitOn(c, pollCheck(c, d.CheckRunningTaskImages, checker.DeepEquals(map[string]int{image2: instances - rollbackParallelism, image1: rollbackParallelism})), poll.WithTimeout(defaultReconciliationTimeout))
// 2nd batch
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image1: instances})
+ poll.WaitOn(c, pollCheck(c, d.CheckRunningTaskImages, checker.DeepEquals(map[string]int{image1: instances})), poll.WithTimeout(defaultReconciliationTimeout))
+
}
-func (s *DockerSwarmSuite) TestAPISwarmServicesFailedUpdate(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmServicesFailedUpdate(c *testing.T) {
const nodeCount = 3
var daemons [nodeCount]*daemon.Daemon
for i := 0; i < nodeCount; i++ {
daemons[i] = s.AddDaemon(c, true, i == 0)
}
// wait for nodes ready
- waitAndAssert(c, 5*time.Second, daemons[0].CheckNodeReadyCount, checker.Equals, nodeCount)
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckNodeReadyCount, checker.Equals(nodeCount)), poll.WithTimeout(5*time.Second))
// service image at start
image1 := "busybox:latest"
@@ -327,15 +315,14 @@
id := daemons[0].CreateService(c, serviceForUpdate, setInstances(instances))
// wait for tasks ready
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image1: instances})
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckRunningTaskImages, checker.DeepEquals(map[string]int{image1: instances})), poll.WithTimeout(defaultReconciliationTimeout))
// issue service update
service := daemons[0].GetService(c, id)
daemons[0].UpdateService(c, service, setImage(image2), setFailureAction(swarm.UpdateFailureActionPause), setMaxFailureRatio(0.25), setParallelism(1))
// should update 2 tasks and then pause
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckServiceUpdateState(id), checker.Equals, swarm.UpdateStatePaused)
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckServiceUpdateState(id), checker.Equals(swarm.UpdateStatePaused)), poll.WithTimeout(defaultReconciliationTimeout))
v, _ := daemons[0].CheckServiceRunningTasks(id)(c)
assert.Assert(c, v == instances-2)
@@ -344,25 +331,25 @@
out, err := daemons[0].Cmd("service", "update", "--detach", "--rollback", id)
assert.NilError(c, err, out)
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image1: instances})
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckRunningTaskImages, checker.DeepEquals(map[string]int{image1: instances})), poll.WithTimeout(defaultReconciliationTimeout))
+
}
-func (s *DockerSwarmSuite) TestAPISwarmServiceConstraintRole(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmServiceConstraintRole(c *testing.T) {
const nodeCount = 3
var daemons [nodeCount]*daemon.Daemon
for i := 0; i < nodeCount; i++ {
daemons[i] = s.AddDaemon(c, true, i == 0)
}
// wait for nodes ready
- waitAndAssert(c, 5*time.Second, daemons[0].CheckNodeReadyCount, checker.Equals, nodeCount)
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckNodeReadyCount, checker.Equals(nodeCount)), poll.WithTimeout(5*time.Second))
// create service
constraints := []string{"node.role==worker"}
instances := 3
id := daemons[0].CreateService(c, simpleTestService, setConstraints(constraints), setInstances(instances))
// wait for tasks ready
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckServiceRunningTasks(id), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckServiceRunningTasks(id), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
// validate tasks are running on worker nodes
tasks := daemons[0].GetServiceTasks(c, id)
for _, task := range tasks {
@@ -376,7 +363,7 @@
constraints = []string{"node.role!=worker"}
id = daemons[0].CreateService(c, simpleTestService, setConstraints(constraints), setInstances(instances))
// wait for tasks ready
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckServiceRunningTasks(id), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckServiceRunningTasks(id), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
tasks = daemons[0].GetServiceTasks(c, id)
// validate tasks are running on manager nodes
for _, task := range tasks {
@@ -390,7 +377,7 @@
constraints = []string{"node.role==nosuchrole"}
id = daemons[0].CreateService(c, simpleTestService, setConstraints(constraints), setInstances(instances))
// wait for tasks created
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckServiceTasks(id), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckServiceTasks(id), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
// let scheduler try
time.Sleep(250 * time.Millisecond)
// validate tasks are not assigned to any node
@@ -400,14 +387,14 @@
}
}
-func (s *DockerSwarmSuite) TestAPISwarmServiceConstraintLabel(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmServiceConstraintLabel(c *testing.T) {
const nodeCount = 3
var daemons [nodeCount]*daemon.Daemon
for i := 0; i < nodeCount; i++ {
daemons[i] = s.AddDaemon(c, true, i == 0)
}
// wait for nodes ready
- waitAndAssert(c, 5*time.Second, daemons[0].CheckNodeReadyCount, checker.Equals, nodeCount)
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckNodeReadyCount, checker.Equals(nodeCount)), poll.WithTimeout(5*time.Second))
nodes := daemons[0].ListNodes(c)
assert.Equal(c, len(nodes), nodeCount)
@@ -430,7 +417,7 @@
constraints := []string{"node.labels.security==high"}
id := daemons[0].CreateService(c, simpleTestService, setConstraints(constraints), setInstances(instances))
// wait for tasks ready
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckServiceRunningTasks(id), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckServiceRunningTasks(id), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
tasks := daemons[0].GetServiceTasks(c, id)
// validate all tasks are running on nodes[0]
for _, task := range tasks {
@@ -443,7 +430,7 @@
constraints = []string{"node.labels.security!=high"}
id = daemons[0].CreateService(c, simpleTestService, setConstraints(constraints), setInstances(instances))
// wait for tasks ready
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckServiceRunningTasks(id), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckServiceRunningTasks(id), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
tasks = daemons[0].GetServiceTasks(c, id)
// validate all tasks are NOT running on nodes[0]
for _, task := range tasks {
@@ -455,7 +442,7 @@
constraints = []string{"node.labels.security==medium"}
id = daemons[0].CreateService(c, simpleTestService, setConstraints(constraints), setInstances(instances))
// wait for tasks created
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckServiceTasks(id), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckServiceTasks(id), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
// let scheduler try
time.Sleep(250 * time.Millisecond)
tasks = daemons[0].GetServiceTasks(c, id)
@@ -473,7 +460,7 @@
}
id = daemons[0].CreateService(c, simpleTestService, setConstraints(constraints), setInstances(instances))
// wait for tasks created
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckServiceTasks(id), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckServiceTasks(id), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
// let scheduler try
time.Sleep(250 * time.Millisecond)
tasks = daemons[0].GetServiceTasks(c, id)
@@ -488,21 +475,21 @@
}
})
// wait for tasks ready
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckServiceRunningTasks(id), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckServiceRunningTasks(id), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
tasks = daemons[0].GetServiceTasks(c, id)
for _, task := range tasks {
assert.Assert(c, task.NodeID == nodes[1].ID)
}
}
-func (s *DockerSwarmSuite) TestAPISwarmServicePlacementPrefs(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmServicePlacementPrefs(c *testing.T) {
const nodeCount = 3
var daemons [nodeCount]*daemon.Daemon
for i := 0; i < nodeCount; i++ {
daemons[i] = s.AddDaemon(c, true, i == 0)
}
// wait for nodes ready
- waitAndAssert(c, 5*time.Second, daemons[0].CheckNodeReadyCount, checker.Equals, nodeCount)
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckNodeReadyCount, checker.Equals(nodeCount)), poll.WithTimeout(5*time.Second))
nodes := daemons[0].ListNodes(c)
assert.Equal(c, len(nodes), nodeCount)
@@ -525,7 +512,7 @@
prefs := []swarm.PlacementPreference{{Spread: &swarm.SpreadOver{SpreadDescriptor: "node.labels.rack"}}}
id := daemons[0].CreateService(c, simpleTestService, setPlacementPrefs(prefs), setInstances(instances))
// wait for tasks ready
- waitAndAssert(c, defaultReconciliationTimeout, daemons[0].CheckServiceRunningTasks(id), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, daemons[0].CheckServiceRunningTasks(id), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
tasks := daemons[0].GetServiceTasks(c, id)
// validate all tasks are running on nodes[0]
tasksOnNode := make(map[string]int)
@@ -537,7 +524,7 @@
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, DaemonIsLinux)
@@ -550,7 +537,7 @@
instances := 9
d1.CreateService(c, simpleTestService, setInstances(instances))
- waitAndAssert(c, defaultReconciliationTimeout, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount, d3.CheckActiveContainerCount), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount, d3.CheckActiveContainerCount), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
getContainers := func() map[string]*daemon.Daemon {
m := make(map[string]*daemon.Daemon)
@@ -572,7 +559,7 @@
_, err := containers[toRemove].Cmd("stop", toRemove)
assert.NilError(c, err)
- waitAndAssert(c, defaultReconciliationTimeout, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount, d3.CheckActiveContainerCount), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount, d3.CheckActiveContainerCount), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
containers2 := getContainers()
assert.Assert(c, len(containers2) == instances)
@@ -598,7 +585,7 @@
time.Sleep(time.Second) // give some time to handle the signal
- waitAndAssert(c, defaultReconciliationTimeout, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount, d3.CheckActiveContainerCount), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount, d3.CheckActiveContainerCount), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
containers2 = getContainers()
assert.Assert(c, len(containers2) == instances)
diff --git a/integration-cli/docker_api_swarm_test.go b/integration-cli/docker_api_swarm_test.go
index 7b498d5..8e230fa 100644
--- a/integration-cli/docker_api_swarm_test.go
+++ b/integration-cli/docker_api_swarm_test.go
@@ -12,6 +12,7 @@
"runtime"
"strings"
"sync"
+ "testing"
"time"
"github.com/cloudflare/cfssl/csr"
@@ -26,15 +27,15 @@
testdaemon "github.com/docker/docker/internal/test/daemon"
"github.com/docker/docker/internal/test/request"
"github.com/docker/swarmkit/ca"
- "github.com/go-check/check"
"github.com/pkg/errors"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
+ "gotest.tools/poll"
)
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
d1 := s.AddDaemon(c, true, true)
info := d1.SwarmInfo(c)
@@ -80,7 +81,7 @@
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.SwarmInit(c, swarm.InitRequest{})
@@ -158,7 +159,7 @@
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.SwarmInit(c, swarm.InitRequest{})
d1.UpdateSwarm(c, func(s *swarm.Spec) {
@@ -180,7 +181,7 @@
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)
d2 := s.AddDaemon(c, false, false)
splitToken := strings.Split(d1.JoinTokens(c).Worker, "-")
@@ -195,7 +196,7 @@
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.SwarmInit(c, swarm.InitRequest{})
d2 := s.AddDaemon(c, true, false)
@@ -208,13 +209,13 @@
n.Spec.Role = swarm.NodeRoleManager
})
- waitAndAssert(c, defaultReconciliationTimeout, d2.CheckControlAvailable, checker.True)
+ poll.WaitOn(c, pollCheck(c, d2.CheckControlAvailable, checker.True()), poll.WithTimeout(defaultReconciliationTimeout))
d1.UpdateNode(c, d2.NodeID(), func(n *swarm.Node) {
n.Spec.Role = swarm.NodeRoleWorker
})
- waitAndAssert(c, defaultReconciliationTimeout, d2.CheckControlAvailable, checker.False)
+ poll.WaitOn(c, pollCheck(c, d2.CheckControlAvailable, checker.False()), poll.WithTimeout(defaultReconciliationTimeout))
// Wait for the role to change to worker in the cert. This is partially
// done because it's something worth testing in its own right, and
@@ -222,17 +223,17 @@
// 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
// time out during this interval.
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
certBytes, err := ioutil.ReadFile(filepath.Join(d2.Folder, "root", "swarm", "certificates", "swarm-node.crt"))
if err != nil {
- return "", check.Commentf("error: %v", err)
+ return "", fmt.Sprintf("error: %v", err)
}
certs, err := helpers.ParseCertificatesPEM(certBytes)
if err == nil && len(certs) > 0 && len(certs[0].Subject.OrganizationalUnit) > 0 {
- return certs[0].Subject.OrganizationalUnit[0], nil
+ return certs[0].Subject.OrganizationalUnit[0], ""
}
- return "", check.Commentf("could not get organizational unit from certificate")
- }, checker.Equals, "swarm-worker")
+ return "", "could not get organizational unit from certificate"
+ }, checker.Equals("swarm-worker")), poll.WithTimeout(defaultReconciliationTimeout))
// Demoting last node should fail
node := d1.GetNode(c, d1.NodeID())
@@ -262,10 +263,10 @@
n.Spec.Role = swarm.NodeRoleManager
})
- waitAndAssert(c, defaultReconciliationTimeout, d2.CheckControlAvailable, checker.True)
+ poll.WaitOn(c, pollCheck(c, d2.CheckControlAvailable, checker.True()), poll.WithTimeout(defaultReconciliationTimeout))
}
-func (s *DockerSwarmSuite) TestAPISwarmLeaderProxy(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmLeaderProxy(c *testing.T) {
// add three managers, one of these is leader
d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, true)
@@ -290,7 +291,7 @@
}
}
-func (s *DockerSwarmSuite) TestAPISwarmLeaderElection(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmLeaderElection(c *testing.T) {
if runtime.GOARCH == "s390x" {
c.Skip("Disabled on s390x")
}
@@ -316,7 +317,7 @@
)
var lastErr error
checkLeader := func(nodes ...*daemon.Daemon) checkF {
- return func(c *check.C) (interface{}, check.CommentInterface) {
+ return func(c *testing.T) (interface{}, string) {
// clear these out before each run
leader = nil
followers = nil
@@ -329,7 +330,7 @@
return false
})
if n == nil {
- return false, check.Commentf("failed to get node: %v", lastErr)
+ return false, fmt.Sprintf("failed to get node: %v", lastErr)
}
if n.ManagerStatus.Leader {
leader = d
@@ -339,16 +340,16 @@
}
if leader == nil {
- return false, check.Commentf("no leader elected")
+ return false, "no leader elected"
}
- return true, check.Commentf("elected %v", leader.ID())
+ return true, fmt.Sprintf("elected %v", leader.ID())
}
}
// wait for an election to occur
c.Logf("Waiting for election to occur...")
- waitAndAssert(c, defaultReconciliationTimeout, checkLeader(d2, d3), checker.True)
+ poll.WaitOn(c, pollCheck(c, checkLeader(d2, d3), checker.True()), poll.WithTimeout(defaultReconciliationTimeout))
// assert that we have a new leader
assert.Assert(c, leader != nil)
@@ -361,7 +362,7 @@
// wait for possible election
c.Logf("Waiting for possible election...")
- waitAndAssert(c, defaultReconciliationTimeout, checkLeader(d1, d2, d3), checker.True)
+ poll.WaitOn(c, pollCheck(c, checkLeader(d1, d2, d3), checker.True()), poll.WithTimeout(defaultReconciliationTimeout))
// pick out the leader and the followers again
// verify that we still only have 1 leader and 2 followers
@@ -371,7 +372,7 @@
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" {
c.Skip("Disabled on s390x")
}
@@ -388,7 +389,7 @@
d2.Stop(c)
// make sure there is a leader
- waitAndAssert(c, defaultReconciliationTimeout, d1.CheckLeader, checker.IsNil)
+ poll.WaitOn(c, pollCheck(c, d1.CheckLeader, checker.IsNil()), poll.WithTimeout(defaultReconciliationTimeout))
d1.CreateService(c, simpleTestService, func(s *swarm.Service) {
s.Spec.Name = "top1"
@@ -403,22 +404,22 @@
defer cli.Close()
// d1 will eventually step down from leader because there is no longer an active quorum, wait for that to happen
- waitAndAssert(c, defaultReconciliationTimeout*2, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
_, err := cli.ServiceCreate(context.Background(), service.Spec, types.ServiceCreateOptions{})
- return err.Error(), nil
- }, checker.Contains, "Make sure more than half of the managers are online.")
+ return err.Error(), ""
+ }, checker.Contains("Make sure more than half of the managers are online.")), poll.WithTimeout(defaultReconciliationTimeout*2))
d2.StartNode(c)
// make sure there is a leader
- waitAndAssert(c, defaultReconciliationTimeout, d1.CheckLeader, checker.IsNil)
+ poll.WaitOn(c, pollCheck(c, d1.CheckLeader, checker.IsNil()), poll.WithTimeout(defaultReconciliationTimeout))
d1.CreateService(c, simpleTestService, func(s *swarm.Service) {
s.Spec.Name = "top3"
})
}
-func (s *DockerSwarmSuite) TestAPISwarmLeaveRemovesContainer(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmLeaveRemovesContainer(c *testing.T) {
d := s.AddDaemon(c, true, true)
instances := 2
@@ -428,12 +429,12 @@
assert.NilError(c, err, id)
id = strings.TrimSpace(id)
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, instances+1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(instances+1)), poll.WithTimeout(defaultReconciliationTimeout))
assert.ErrorContains(c, d.SwarmLeave(c, false), "")
assert.NilError(c, d.SwarmLeave(c, true))
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
id2, err := d.Cmd("ps", "-q")
assert.NilError(c, err, id2)
@@ -441,7 +442,7 @@
}
// #23629
-func (s *DockerSwarmSuite) TestAPISwarmLeaveOnPendingJoin(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmLeaveOnPendingJoin(c *testing.T) {
testRequires(c, Network)
s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, false, false)
@@ -462,7 +463,7 @@
assert.NilError(c, d2.SwarmLeave(c, true))
- waitAndAssert(c, defaultReconciliationTimeout, d2.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d2.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
id2, err := d2.Cmd("ps", "-q")
assert.NilError(c, err, id2)
@@ -470,7 +471,7 @@
}
// #23705
-func (s *DockerSwarmSuite) TestAPISwarmRestoreOnPendingJoin(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmRestoreOnPendingJoin(c *testing.T) {
testRequires(c, Network)
d := s.AddDaemon(c, false, false)
client := d.NewClientT(c)
@@ -480,7 +481,7 @@
})
assert.ErrorContains(c, err, "Timeout was reached")
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckLocalNodeState, checker.Equals, swarm.LocalNodeStatePending)
+ poll.WaitOn(c, pollCheck(c, d.CheckLocalNodeState, checker.Equals(swarm.LocalNodeStatePending)), poll.WithTimeout(defaultReconciliationTimeout))
d.RestartNode(c)
@@ -488,7 +489,7 @@
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)
instances := 2
@@ -515,17 +516,17 @@
d3.GetService(c, id)
}
-func (s *DockerSwarmSuite) TestAPISwarmScaleNoRollingUpdate(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmScaleNoRollingUpdate(c *testing.T) {
d := s.AddDaemon(c, true, true)
instances := 2
id := d.CreateService(c, simpleTestService, setInstances(instances))
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
containers := d.ActiveContainers(c)
instances = 4
d.UpdateService(c, d.GetService(c, id), setInstances(instances))
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
containers2 := d.ActiveContainers(c)
loop0:
@@ -539,7 +540,7 @@
}
}
-func (s *DockerSwarmSuite) TestAPISwarmInvalidAddress(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmInvalidAddress(c *testing.T) {
d := s.AddDaemon(c, false, false)
req := swarm.InitRequest{
ListenAddr: "",
@@ -557,20 +558,20 @@
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)
d2 := s.AddDaemon(c, true, true)
instances := 2
id := d1.CreateService(c, simpleTestService, setInstances(instances))
- waitAndAssert(c, defaultReconciliationTimeout, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
// drain d2, all containers should move to d1
d1.UpdateNode(c, d2.NodeID(), func(n *swarm.Node) {
n.Spec.Availability = swarm.NodeAvailabilityDrain
})
- waitAndAssert(c, defaultReconciliationTimeout, d1.CheckActiveContainerCount, checker.Equals, instances)
- waitAndAssert(c, defaultReconciliationTimeout, d2.CheckActiveContainerCount, checker.Equals, 0)
+ poll.WaitOn(c, pollCheck(c, d1.CheckActiveContainerCount, checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
+ poll.WaitOn(c, pollCheck(c, d2.CheckActiveContainerCount, checker.Equals(0)), poll.WithTimeout(defaultReconciliationTimeout))
d2.Stop(c)
@@ -579,7 +580,7 @@
Spec: swarm.Spec{},
})
- waitAndAssert(c, defaultReconciliationTimeout, d1.CheckActiveContainerCount, checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, d1.CheckActiveContainerCount, checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
d3 := s.AddDaemon(c, true, true)
info := d3.SwarmInfo(c)
@@ -589,7 +590,7 @@
instances = 4
d3.UpdateService(c, d3.GetService(c, id), setInstances(instances))
- waitAndAssert(c, defaultReconciliationTimeout, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d3.CheckActiveContainerCount), checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d3.CheckActiveContainerCount), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
}
func simpleTestService(s *swarm.Service) {
@@ -728,7 +729,7 @@
}
}
-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
for _, d := range cl {
@@ -737,13 +738,13 @@
)
// 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{}, string) {
client := d.NewClientT(c)
daemonInfo, err := client.Info(context.Background())
info = daemonInfo.Swarm
- return err, check.Commentf("cluster not ready in time")
+ return err, "cluster not ready in time"
}
- waitAndAssert(c, defaultReconciliationTimeout, checkInfo, checker.IsNil)
+ poll.WaitOn(c, pollCheck(c, checkInfo, checker.IsNil()), poll.WithTimeout(defaultReconciliationTimeout))
if !info.ControlAvailable {
totalWCount++
continue
@@ -754,25 +755,25 @@
var mCount, wCount int
for _, n := range d.ListNodes(c) {
- waitReady := func(c *check.C) (interface{}, check.CommentInterface) {
+ waitReady := func(c *testing.T) (interface{}, string) {
if n.Status.State == swarm.NodeStateReady {
- return true, nil
+ return true, ""
}
nn := d.GetNode(c, n.ID)
n = *nn
- return n.Status.State == swarm.NodeStateReady, check.Commentf("state of node %s, reported by %s", n.ID, d.NodeID())
+ return n.Status.State == swarm.NodeStateReady, fmt.Sprintf("state of node %s, reported by %s", n.ID, d.NodeID())
}
- waitAndAssert(c, defaultReconciliationTimeout, waitReady, checker.True)
+ poll.WaitOn(c, pollCheck(c, waitReady, checker.True()), poll.WithTimeout(defaultReconciliationTimeout))
- waitActive := func(c *check.C) (interface{}, check.CommentInterface) {
+ waitActive := func(c *testing.T) (interface{}, string) {
if n.Spec.Availability == swarm.NodeAvailabilityActive {
- return true, nil
+ return true, ""
}
nn := d.GetNode(c, n.ID)
n = *nn
- return n.Spec.Availability == swarm.NodeAvailabilityActive, check.Commentf("availability of node %s, reported by %s", n.ID, d.NodeID())
+ return n.Spec.Availability == swarm.NodeAvailabilityActive, fmt.Sprintf("availability of node %s, reported by %s", n.ID, d.NodeID())
}
- waitAndAssert(c, defaultReconciliationTimeout, waitActive, checker.True)
+ poll.WaitOn(c, pollCheck(c, waitActive, checker.True()), poll.WithTimeout(defaultReconciliationTimeout))
if n.Spec.Role == swarm.NodeRoleManager {
assert.Assert(c, n.ManagerStatus != nil, "manager status of node %s (manager), reported by %s", n.ID, d.NodeID())
@@ -793,7 +794,7 @@
assert.Equal(c, totalWCount, workerCount)
}
-func (s *DockerSwarmSuite) TestAPISwarmRestartCluster(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmRestartCluster(c *testing.T) {
mCount, wCount := 5, 1
var nodes []*daemon.Daemon
@@ -858,12 +859,12 @@
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)
instances := 2
id := d.CreateService(c, simpleTestService, setInstances(instances))
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
service := d.GetService(c, id)
instances = 5
@@ -873,18 +874,18 @@
defer cli.Close()
_, err := cli.ServiceUpdate(context.Background(), service.Spec.Name, service.Version, service.Spec, types.ServiceUpdateOptions{})
assert.NilError(c, err)
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
}
// 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)
err := d.SwarmUnlock(c, swarm.UnlockRequest{UnlockKey: "wrong-key"})
assert.ErrorContains(c, err, "swarm is not locked")
}
// #29885
-func (s *DockerSwarmSuite) TestAPISwarmErrorHandling(c *check.C) {
+func (s *DockerSwarmSuite) TestAPISwarmErrorHandling(c *testing.T) {
ln, err := net.Listen("tcp", fmt.Sprintf(":%d", defaultSwarmPort))
assert.NilError(c, err)
defer ln.Close()
@@ -899,7 +900,7 @@
// 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`.
// 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)
cli := d.NewClientT(c)
defer cli.Close()
@@ -929,7 +930,7 @@
}
// 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.
c.Skip("Root cause of Issue #36386 is needed")
d := s.AddDaemon(c, true, true)
@@ -948,7 +949,7 @@
}
})
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, instances)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
containers := d.ActiveContainers(c)
@@ -956,7 +957,7 @@
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)
w := s.AddDaemon(c, true, false)
@@ -1025,7 +1026,7 @@
}
}
-func (s *DockerSwarmSuite) TestAPINetworkInspectWithScope(c *check.C) {
+func (s *DockerSwarmSuite) TestAPINetworkInspectWithScope(c *testing.T) {
d := s.AddDaemon(c, true, true)
name := "test-scoped-network"
diff --git a/integration-cli/docker_api_test.go b/integration-cli/docker_api_test.go
index ecf69bb..9ada07e 100644
--- a/integration-cli/docker_api_test.go
+++ b/integration-cli/docker_api_test.go
@@ -7,21 +7,21 @@
"runtime"
"strconv"
"strings"
+ "testing"
"github.com/docker/docker/api"
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/internal/test/request"
- "github.com/go-check/check"
"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))
assert.NilError(c, err)
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")
assert.NilError(c, err)
assert.Equal(c, res.StatusCode, http.StatusOK)
@@ -33,7 +33,7 @@
//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 {
c.Skip("Daemon platform doesn't match test platform")
}
@@ -57,7 +57,7 @@
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{}{}))
assert.NilError(c, err)
if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") {
@@ -71,7 +71,7 @@
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
// in v1.23, but changed in 1.24, hence not applicable on Windows. See apiVersionSupportsJSONErrors
testRequires(c, DaemonIsLinux)
@@ -88,7 +88,7 @@
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
httpResp, body, err := request.Get("/notfound", request.JSON)
assert.NilError(c, err)
@@ -99,7 +99,7 @@
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)
assert.NilError(c, err)
assert.Equal(c, httpResp.StatusCode, http.StatusNotFound)
diff --git a/integration-cli/docker_cli_attach_test.go b/integration-cli/docker_cli_attach_test.go
index d8ad4cc..b1ae40a 100644
--- a/integration-cli/docker_cli_attach_test.go
+++ b/integration-cli/docker_cli_attach_test.go
@@ -8,17 +8,17 @@
"runtime"
"strings"
"sync"
+ "testing"
"time"
"github.com/docker/docker/integration-cli/cli"
- "github.com/go-check/check"
"gotest.tools/assert"
"gotest.tools/icmd"
)
const attachWait = 5 * time.Second
-func (s *DockerSuite) TestAttachMultipleAndRestart(c *check.C) {
+func (s *DockerSuite) TestAttachMultipleAndRestart(c *testing.T) {
endGroup := &sync.WaitGroup{}
startGroup := &sync.WaitGroup{}
endGroup.Add(3)
@@ -88,7 +88,7 @@
}
}
-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.
// 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.
@@ -133,7 +133,7 @@
}
}
-func (s *DockerSuite) TestAttachDisconnect(c *check.C) {
+func (s *DockerSuite) TestAttachDisconnect(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-di", "busybox", "/bin/cat")
id := strings.TrimSpace(out)
@@ -147,7 +147,7 @@
stdout, err := cmd.StdoutPipe()
assert.NilError(c, err)
defer stdout.Close()
- c.Assert(cmd.Start(), check.IsNil)
+ assert.Assert(c, cmd.Start() == nil)
defer func() {
cmd.Process.Kill()
cmd.Wait()
@@ -157,16 +157,16 @@
assert.NilError(c, err)
out, err = bufio.NewReader(stdout).ReadString('\n')
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), check.Equals, "hello")
+ assert.Equal(c, strings.TrimSpace(out), "hello")
- c.Assert(stdin.Close(), check.IsNil)
+ assert.Assert(c, stdin.Close() == nil)
// Expect container to still be running after stdin is closed
running := inspectField(c, id, "State.Running")
- c.Assert(running, check.Equals, "true")
+ assert.Equal(c, running, "true")
}
-func (s *DockerSuite) TestAttachPausedContainer(c *check.C) {
+func (s *DockerSuite) TestAttachPausedContainer(c *testing.T) {
testRequires(c, IsPausable)
runSleepingContainer(c, "-d", "--name=test")
dockerCmd(c, "pause", "test")
diff --git a/integration-cli/docker_cli_attach_unix_test.go b/integration-cli/docker_cli_attach_unix_test.go
index 1872648..ebe185d 100644
--- a/integration-cli/docker_cli_attach_unix_test.go
+++ b/integration-cli/docker_cli_attach_unix_test.go
@@ -7,15 +7,15 @@
"io/ioutil"
"os/exec"
"strings"
+ "testing"
"time"
"github.com/creack/pty"
- "github.com/go-check/check"
"gotest.tools/assert"
)
// #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)
out, _ := dockerCmd(c, "run", "-dti", "busybox", "/bin/sh", "-c", `trap 'exit 0' SIGTERM; while true; do sleep 1; done`)
@@ -51,14 +51,14 @@
case err := <-errChan:
tty.Close()
out, _ := ioutil.ReadAll(pty)
- c.Assert(err, check.IsNil, check.Commentf("out: %v", string(out)))
+ assert.Assert(c, err == nil, "out: %v", string(out))
case <-time.After(attachWait):
c.Fatal("timed out without attach returning")
}
}
-func (s *DockerSuite) TestAttachAfterDetach(c *check.C) {
+func (s *DockerSuite) TestAttachAfterDetach(c *testing.T) {
name := "detachtest"
cpty, tty, err := pty.Open()
@@ -74,7 +74,7 @@
close(cmdExit)
}()
- c.Assert(waitRun(name), check.IsNil)
+ assert.Assert(c, waitRun(name) == nil)
cpty.Write([]byte{16})
time.Sleep(100 * time.Millisecond)
@@ -123,7 +123,7 @@
}
// 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")
id := strings.TrimSpace(out)
assert.NilError(c, waitRun(id))
diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go
index 5f192af..8c4c625 100644
--- a/integration-cli/docker_cli_build_test.go
+++ b/integration-cli/docker_cli_build_test.go
@@ -13,10 +13,10 @@
"runtime"
"strconv"
"strings"
+ "testing"
"text/template"
"time"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/internal/test/fakecontext"
@@ -25,21 +25,21 @@
"github.com/docker/docker/internal/testutil"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/system"
- "github.com/go-check/check"
"github.com/moby/buildkit/frontend/dockerfile/command"
"github.com/opencontainers/go-digest"
"gotest.tools/assert"
+ "gotest.tools/assert/cmp"
"gotest.tools/icmd"
)
-func (s *DockerSuite) TestBuildJSONEmptyRun(c *check.C) {
+func (s *DockerSuite) TestBuildJSONEmptyRun(c *testing.T) {
cli.BuildCmd(c, "testbuildjsonemptyrun", build.WithDockerfile(`
FROM busybox
RUN []
`))
}
-func (s *DockerSuite) TestBuildShCmdJSONEntrypoint(c *check.C) {
+func (s *DockerSuite) TestBuildShCmdJSONEntrypoint(c *testing.T) {
name := "testbuildshcmdjsonentrypoint"
expected := "/bin/sh -c echo test"
if testEnv.OSType == "windows" {
@@ -58,7 +58,7 @@
}
}
-func (s *DockerSuite) TestBuildEnvironmentReplacementUser(c *check.C) {
+func (s *DockerSuite) TestBuildEnvironmentReplacementUser(c *testing.T) {
// Windows does not support FROM scratch or the USER command
testRequires(c, DaemonIsLinux)
name := "testbuildenvironmentreplacement"
@@ -75,7 +75,7 @@
}
}
-func (s *DockerSuite) TestBuildEnvironmentReplacementVolume(c *check.C) {
+func (s *DockerSuite) TestBuildEnvironmentReplacementVolume(c *testing.T) {
name := "testbuildenvironmentreplacement"
var volumePath string
@@ -100,7 +100,7 @@
}
-func (s *DockerSuite) TestBuildEnvironmentReplacementExpose(c *check.C) {
+func (s *DockerSuite) TestBuildEnvironmentReplacementExpose(c *testing.T) {
// Windows does not support FROM scratch or the EXPOSE command
testRequires(c, DaemonIsLinux)
name := "testbuildenvironmentreplacement"
@@ -125,7 +125,7 @@
}
-func (s *DockerSuite) TestBuildEnvironmentReplacementWorkdir(c *check.C) {
+func (s *DockerSuite) TestBuildEnvironmentReplacementWorkdir(c *testing.T) {
name := "testbuildenvironmentreplacement"
buildImageSuccessfully(c, name, build.WithDockerfile(`
@@ -145,7 +145,7 @@
}
}
-func (s *DockerSuite) TestBuildEnvironmentReplacementAddCopy(c *check.C) {
+func (s *DockerSuite) TestBuildEnvironmentReplacementAddCopy(c *testing.T) {
name := "testbuildenvironmentreplacement"
buildImageSuccessfully(c, name, build.WithBuildContext(c,
@@ -169,7 +169,7 @@
))
}
-func (s *DockerSuite) TestBuildEnvironmentReplacementEnv(c *check.C) {
+func (s *DockerSuite) TestBuildEnvironmentReplacementEnv(c *testing.T) {
// ENV expansions work differently in Windows
testRequires(c, DaemonIsLinux)
name := "testbuildenvironmentreplacement"
@@ -232,7 +232,7 @@
}
-func (s *DockerSuite) TestBuildHandleEscapesInVolume(c *check.C) {
+func (s *DockerSuite) TestBuildHandleEscapesInVolume(c *testing.T) {
// The volume paths used in this test are invalid on Windows
testRequires(c, DaemonIsLinux)
name := "testbuildhandleescapes"
@@ -276,7 +276,7 @@
}
}
-func (s *DockerSuite) TestBuildOnBuildLowercase(c *check.C) {
+func (s *DockerSuite) TestBuildOnBuildLowercase(c *testing.T) {
name := "testbuildonbuildlowercase"
name2 := "testbuildonbuildlowercase2"
@@ -300,7 +300,7 @@
}
-func (s *DockerSuite) TestBuildEnvEscapes(c *check.C) {
+func (s *DockerSuite) TestBuildEnvEscapes(c *testing.T) {
// ENV expansions work differently in Windows
testRequires(c, DaemonIsLinux)
name := "testbuildenvescapes"
@@ -317,7 +317,7 @@
}
-func (s *DockerSuite) TestBuildEnvOverwrite(c *check.C) {
+func (s *DockerSuite) TestBuildEnvOverwrite(c *testing.T) {
// ENV expansions work differently in Windows
testRequires(c, DaemonIsLinux)
name := "testbuildenvoverwrite"
@@ -335,7 +335,7 @@
}
// FIXME(vdemeester) why we disabled cache here ?
-func (s *DockerSuite) TestBuildOnBuildCmdEntrypointJSON(c *check.C) {
+func (s *DockerSuite) TestBuildOnBuildCmdEntrypointJSON(c *testing.T) {
name1 := "onbuildcmd"
name2 := "onbuildgenerated"
@@ -352,7 +352,7 @@
}
// FIXME(vdemeester) why we disabled cache here ?
-func (s *DockerSuite) TestBuildOnBuildEntrypointJSON(c *check.C) {
+func (s *DockerSuite) TestBuildOnBuildEntrypointJSON(c *testing.T) {
name1 := "onbuildcmd"
name2 := "onbuildgenerated"
@@ -369,7 +369,7 @@
}
-func (s *DockerSuite) TestBuildCacheAdd(c *check.C) {
+func (s *DockerSuite) TestBuildCacheAdd(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows doesn't have httpserver image yet
name := "testbuildtwoimageswithadd"
server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{
@@ -389,7 +389,7 @@
}
}
-func (s *DockerSuite) TestBuildLastModified(c *check.C) {
+func (s *DockerSuite) TestBuildLastModified(c *testing.T) {
// Temporary fix for #30890. TODO @jhowardmsft figure out what
// has changed in the master busybox image.
testRequires(c, DaemonIsLinux)
@@ -442,7 +442,7 @@
// Regression for https://github.com/docker/docker/pull/27805
// Makes sure that we don't use the cache if the contents of
// a file in a subfolder of the context is modified and we re-build.
-func (s *DockerSuite) TestBuildModifyFileInFolder(c *check.C) {
+func (s *DockerSuite) TestBuildModifyFileInFolder(c *testing.T) {
name := "testbuildmodifyfileinfolder"
ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(`FROM busybox
@@ -464,7 +464,7 @@
}
}
-func (s *DockerSuite) TestBuildAddSingleFileToRoot(c *check.C) {
+func (s *DockerSuite) TestBuildAddSingleFileToRoot(c *testing.T) {
testRequires(c, DaemonIsLinux) // Linux specific test
buildImageSuccessfully(c, "testaddimg", build.WithBuildContext(c,
build.WithFile("Dockerfile", fmt.Sprintf(`FROM busybox
@@ -480,7 +480,7 @@
}
// Issue #3960: "ADD src ." hangs
-func (s *DockerSuite) TestBuildAddSingleFileToWorkdir(c *check.C) {
+func (s *DockerSuite) TestBuildAddSingleFileToWorkdir(c *testing.T) {
name := "testaddsinglefiletoworkdir"
ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(
`FROM busybox
@@ -503,7 +503,7 @@
}
}
-func (s *DockerSuite) TestBuildAddSingleFileToExistDir(c *check.C) {
+func (s *DockerSuite) TestBuildAddSingleFileToExistDir(c *testing.T) {
testRequires(c, DaemonIsLinux) // Linux specific test
cli.BuildCmd(c, "testaddsinglefiletoexistdir", build.WithBuildContext(c,
build.WithFile("Dockerfile", `FROM busybox
@@ -519,7 +519,7 @@
build.WithFile("test_file", "test1")))
}
-func (s *DockerSuite) TestBuildCopyAddMultipleFiles(c *check.C) {
+func (s *DockerSuite) TestBuildCopyAddMultipleFiles(c *testing.T) {
testRequires(c, DaemonIsLinux) // Linux specific test
server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{
"robots.txt": "hello",
@@ -552,7 +552,7 @@
// These tests are mainly for user namespaces to verify that new directories
// are created as the remapped root uid/gid pair
-func (s *DockerSuite) TestBuildUsernamespaceValidateRemappedRoot(c *check.C) {
+func (s *DockerSuite) TestBuildUsernamespaceValidateRemappedRoot(c *testing.T) {
testRequires(c, DaemonIsLinux)
testCases := []string{
"ADD . /new_dir",
@@ -571,7 +571,7 @@
}
}
-func (s *DockerSuite) TestBuildAddAndCopyFileWithWhitespace(c *check.C) {
+func (s *DockerSuite) TestBuildAddAndCopyFileWithWhitespace(c *testing.T) {
testRequires(c, DaemonIsLinux) // Not currently passing on Windows
name := "testaddfilewithwhitespace"
@@ -604,7 +604,7 @@
}
}
-func (s *DockerSuite) TestBuildCopyFileWithWhitespaceOnWindows(c *check.C) {
+func (s *DockerSuite) TestBuildCopyFileWithWhitespaceOnWindows(c *testing.T) {
testRequires(c, DaemonIsWindows)
dockerfile := `FROM ` + testEnv.PlatformDefaults.BaseImage + `
RUN mkdir "C:/test dir"
@@ -634,7 +634,7 @@
))
}
-func (s *DockerSuite) TestBuildCopyWildcard(c *check.C) {
+func (s *DockerSuite) TestBuildCopyWildcard(c *testing.T) {
name := "testcopywildcard"
server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{
"robots.txt": "hello",
@@ -674,7 +674,7 @@
}
-func (s *DockerSuite) TestBuildCopyWildcardInName(c *check.C) {
+func (s *DockerSuite) TestBuildCopyWildcardInName(c *testing.T) {
// Run this only on Linux
// Below is the original comment (that I don't agree with — vdemeester)
// Normally we would do c.Fatal(err) here but given that
@@ -694,7 +694,7 @@
))
}
-func (s *DockerSuite) TestBuildCopyWildcardCache(c *check.C) {
+func (s *DockerSuite) TestBuildCopyWildcardCache(c *testing.T) {
name := "testcopywildcardcache"
ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(`FROM busybox
COPY file1.txt /tmp/`),
@@ -720,7 +720,7 @@
}
-func (s *DockerSuite) TestBuildAddSingleFileToNonExistingDir(c *check.C) {
+func (s *DockerSuite) TestBuildAddSingleFileToNonExistingDir(c *testing.T) {
testRequires(c, DaemonIsLinux) // Linux specific test
buildImageSuccessfully(c, "testaddsinglefiletononexistingdir", build.WithBuildContext(c,
build.WithFile("Dockerfile", `FROM busybox
@@ -735,7 +735,7 @@
build.WithFile("test_file", "test1")))
}
-func (s *DockerSuite) TestBuildAddDirContentToRoot(c *check.C) {
+func (s *DockerSuite) TestBuildAddDirContentToRoot(c *testing.T) {
testRequires(c, DaemonIsLinux) // Linux specific test
buildImageSuccessfully(c, "testadddircontenttoroot", build.WithBuildContext(c,
build.WithFile("Dockerfile", `FROM busybox
@@ -749,7 +749,7 @@
build.WithFile("test_dir/test_file", "test1")))
}
-func (s *DockerSuite) TestBuildAddDirContentToExistingDir(c *check.C) {
+func (s *DockerSuite) TestBuildAddDirContentToExistingDir(c *testing.T) {
testRequires(c, DaemonIsLinux) // Linux specific test
buildImageSuccessfully(c, "testadddircontenttoexistingdir", build.WithBuildContext(c,
build.WithFile("Dockerfile", `FROM busybox
@@ -765,7 +765,7 @@
build.WithFile("test_dir/test_file", "test1")))
}
-func (s *DockerSuite) TestBuildAddWholeDirToRoot(c *check.C) {
+func (s *DockerSuite) TestBuildAddWholeDirToRoot(c *testing.T) {
testRequires(c, DaemonIsLinux) // Linux specific test
buildImageSuccessfully(c, "testaddwholedirtoroot", build.WithBuildContext(c,
build.WithFile("Dockerfile", fmt.Sprintf(`FROM busybox
@@ -783,7 +783,7 @@
}
// Testing #5941 : Having an etc directory in context conflicts with the /etc/mtab
-func (s *DockerSuite) TestBuildAddOrCopyEtcToRootShouldNotConflict(c *check.C) {
+func (s *DockerSuite) TestBuildAddOrCopyEtcToRootShouldNotConflict(c *testing.T) {
buildImageSuccessfully(c, "testaddetctoroot", build.WithBuildContext(c,
build.WithFile("Dockerfile", `FROM `+minimalBaseImage()+`
ADD . /`),
@@ -795,7 +795,7 @@
}
// Testing #9401 : Losing setuid flag after a ADD
-func (s *DockerSuite) TestBuildAddPreservesFilesSpecialBits(c *check.C) {
+func (s *DockerSuite) TestBuildAddPreservesFilesSpecialBits(c *testing.T) {
testRequires(c, DaemonIsLinux) // Linux specific test
buildImageSuccessfully(c, "testaddetctoroot", build.WithBuildContext(c,
build.WithFile("Dockerfile", `FROM busybox
@@ -808,7 +808,7 @@
build.WithFile("/data/usr/test_file", "test1")))
}
-func (s *DockerSuite) TestBuildCopySingleFileToRoot(c *check.C) {
+func (s *DockerSuite) TestBuildCopySingleFileToRoot(c *testing.T) {
testRequires(c, DaemonIsLinux) // Linux specific test
buildImageSuccessfully(c, "testcopysinglefiletoroot", build.WithBuildContext(c,
build.WithFile("Dockerfile", fmt.Sprintf(`FROM busybox
@@ -824,7 +824,7 @@
}
// Issue #3960: "ADD src ." hangs - adapted for COPY
-func (s *DockerSuite) TestBuildCopySingleFileToWorkdir(c *check.C) {
+func (s *DockerSuite) TestBuildCopySingleFileToWorkdir(c *testing.T) {
name := "testcopysinglefiletoworkdir"
ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(`FROM busybox
COPY test_file .`),
@@ -846,7 +846,7 @@
}
}
-func (s *DockerSuite) TestBuildCopySingleFileToExistDir(c *check.C) {
+func (s *DockerSuite) TestBuildCopySingleFileToExistDir(c *testing.T) {
testRequires(c, DaemonIsLinux) // Linux specific test
buildImageSuccessfully(c, "testcopysinglefiletoexistdir", build.WithBuildContext(c,
build.WithFile("Dockerfile", `FROM busybox
@@ -862,7 +862,7 @@
build.WithFile("test_file", "test1")))
}
-func (s *DockerSuite) TestBuildCopySingleFileToNonExistDir(c *check.C) {
+func (s *DockerSuite) TestBuildCopySingleFileToNonExistDir(c *testing.T) {
testRequires(c, DaemonIsLinux) // Linux specific
buildImageSuccessfully(c, "testcopysinglefiletononexistdir", build.WithBuildContext(c,
build.WithFile("Dockerfile", `FROM busybox
@@ -877,7 +877,7 @@
build.WithFile("test_file", "test1")))
}
-func (s *DockerSuite) TestBuildCopyDirContentToRoot(c *check.C) {
+func (s *DockerSuite) TestBuildCopyDirContentToRoot(c *testing.T) {
testRequires(c, DaemonIsLinux) // Linux specific test
buildImageSuccessfully(c, "testcopydircontenttoroot", build.WithBuildContext(c,
build.WithFile("Dockerfile", `FROM busybox
@@ -891,7 +891,7 @@
build.WithFile("test_dir/test_file", "test1")))
}
-func (s *DockerSuite) TestBuildCopyDirContentToExistDir(c *check.C) {
+func (s *DockerSuite) TestBuildCopyDirContentToExistDir(c *testing.T) {
testRequires(c, DaemonIsLinux) // Linux specific test
buildImageSuccessfully(c, "testcopydircontenttoexistdir", build.WithBuildContext(c,
build.WithFile("Dockerfile", `FROM busybox
@@ -907,7 +907,7 @@
build.WithFile("test_dir/test_file", "test1")))
}
-func (s *DockerSuite) TestBuildCopyWholeDirToRoot(c *check.C) {
+func (s *DockerSuite) TestBuildCopyWholeDirToRoot(c *testing.T) {
testRequires(c, DaemonIsLinux) // Linux specific test
buildImageSuccessfully(c, "testcopywholedirtoroot", build.WithBuildContext(c,
build.WithFile("Dockerfile", fmt.Sprintf(`FROM busybox
@@ -924,7 +924,7 @@
build.WithFile("test_dir/test_file", "test1")))
}
-func (s *DockerSuite) TestBuildAddBadLinks(c *check.C) {
+func (s *DockerSuite) TestBuildAddBadLinks(c *testing.T) {
testRequires(c, DaemonIsLinux) // Not currently working on Windows
dockerfile := `
@@ -1004,7 +1004,7 @@
}
-func (s *DockerSuite) TestBuildAddBadLinksVolume(c *check.C) {
+func (s *DockerSuite) TestBuildAddBadLinksVolume(c *testing.T) {
testRequires(c, DaemonIsLinux) // ln not implemented on Windows busybox
const (
dockerfileTemplate = `
@@ -1047,7 +1047,7 @@
// Issue #5270 - ensure we throw a better error than "unexpected EOF"
// when we can't access files in the context.
-func (s *DockerSuite) TestBuildWithInaccessibleFilesInContext(c *check.C) {
+func (s *DockerSuite) TestBuildWithInaccessibleFilesInContext(c *testing.T) {
testRequires(c, DaemonIsLinux, UnixCli, testEnv.IsLocalDaemon) // test uses chown/chmod: not available on windows
{
@@ -1168,7 +1168,7 @@
}
}
-func (s *DockerSuite) TestBuildForceRm(c *check.C) {
+func (s *DockerSuite) TestBuildForceRm(c *testing.T) {
containerCountBefore := getContainerCount(c)
name := "testbuildforcerm"
@@ -1187,7 +1187,7 @@
}
-func (s *DockerSuite) TestBuildRm(c *check.C) {
+func (s *DockerSuite) TestBuildRm(c *testing.T) {
name := "testbuildrm"
testCases := []struct {
@@ -1230,7 +1230,7 @@
}
}
-func (s *DockerSuite) TestBuildWithVolumes(c *check.C) {
+func (s *DockerSuite) TestBuildWithVolumes(c *testing.T) {
testRequires(c, DaemonIsLinux) // Invalid volume paths on Windows
var (
result map[string]map[string]struct{}
@@ -1265,7 +1265,7 @@
}
-func (s *DockerSuite) TestBuildMaintainer(c *check.C) {
+func (s *DockerSuite) TestBuildMaintainer(c *testing.T) {
name := "testbuildmaintainer"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+`
@@ -1278,7 +1278,7 @@
}
}
-func (s *DockerSuite) TestBuildUser(c *check.C) {
+func (s *DockerSuite) TestBuildUser(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "testbuilduser"
expected := "dockerio"
@@ -1292,7 +1292,7 @@
}
}
-func (s *DockerSuite) TestBuildRelativeWorkdir(c *check.C) {
+func (s *DockerSuite) TestBuildRelativeWorkdir(c *testing.T) {
name := "testbuildrelativeworkdir"
var (
@@ -1334,7 +1334,7 @@
// #22181 Regression test. Single end-to-end test of using
// Windows semantics. Most path handling verifications are in unit tests
-func (s *DockerSuite) TestBuildWindowsWorkdirProcessing(c *check.C) {
+func (s *DockerSuite) TestBuildWindowsWorkdirProcessing(c *testing.T) {
testRequires(c, DaemonIsWindows)
buildImageSuccessfully(c, "testbuildwindowsworkdirprocessing", build.WithDockerfile(`FROM busybox
WORKDIR C:\\foo
@@ -1345,7 +1345,7 @@
// #22181 Regression test. Most paths handling verifications are in unit test.
// One functional test for end-to-end
-func (s *DockerSuite) TestBuildWindowsAddCopyPathProcessing(c *check.C) {
+func (s *DockerSuite) TestBuildWindowsAddCopyPathProcessing(c *testing.T) {
testRequires(c, DaemonIsWindows)
// TODO Windows (@jhowardmsft). Needs a follow-up PR to 22181 to
// support backslash such as .\\ being equivalent to ./ and c:\\ being
@@ -1378,7 +1378,7 @@
))
}
-func (s *DockerSuite) TestBuildWorkdirWithEnvVariables(c *check.C) {
+func (s *DockerSuite) TestBuildWorkdirWithEnvVariables(c *testing.T) {
name := "testbuildworkdirwithenvvariables"
var expected string
@@ -1399,7 +1399,7 @@
}
}
-func (s *DockerSuite) TestBuildRelativeCopy(c *check.C) {
+func (s *DockerSuite) TestBuildRelativeCopy(c *testing.T) {
// cat /test1/test2/foo gets permission denied for the user
testRequires(c, NotUserNamespace)
@@ -1438,7 +1438,7 @@
}
// FIXME(vdemeester) should be unit test
-func (s *DockerSuite) TestBuildBlankName(c *check.C) {
+func (s *DockerSuite) TestBuildBlankName(c *testing.T) {
name := "testbuildblankname"
testCases := []struct {
expression string
@@ -1467,7 +1467,7 @@
}
}
-func (s *DockerSuite) TestBuildEnv(c *check.C) {
+func (s *DockerSuite) TestBuildEnv(c *testing.T) {
testRequires(c, DaemonIsLinux) // ENV expansion is different in Windows
name := "testbuildenv"
expected := "[PATH=/test:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PORT=2375]"
@@ -1481,7 +1481,7 @@
}
}
-func (s *DockerSuite) TestBuildPATH(c *check.C) {
+func (s *DockerSuite) TestBuildPATH(c *testing.T) {
testRequires(c, DaemonIsLinux) // ENV expansion is different in Windows
defPath := "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
@@ -1510,7 +1510,7 @@
}
}
-func (s *DockerSuite) TestBuildContextCleanup(c *check.C) {
+func (s *DockerSuite) TestBuildContextCleanup(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
name := "testbuildcontextcleanup"
@@ -1532,7 +1532,7 @@
}
-func (s *DockerSuite) TestBuildContextCleanupFailedBuild(c *check.C) {
+func (s *DockerSuite) TestBuildContextCleanupFailedBuild(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
name := "testbuildcontextcleanup"
@@ -1575,7 +1575,7 @@
return nil
}
-func (s *DockerSuite) TestBuildCmd(c *check.C) {
+func (s *DockerSuite) TestBuildCmd(c *testing.T) {
name := "testbuildcmd"
expected := "[/bin/echo Hello World]"
@@ -1588,7 +1588,7 @@
}
}
-func (s *DockerSuite) TestBuildExpose(c *check.C) {
+func (s *DockerSuite) TestBuildExpose(c *testing.T) {
testRequires(c, DaemonIsLinux) // Expose not implemented on Windows
name := "testbuildexpose"
expected := "map[2375/tcp:{}]"
@@ -1602,7 +1602,7 @@
}
}
-func (s *DockerSuite) TestBuildExposeMorePorts(c *check.C) {
+func (s *DockerSuite) TestBuildExposeMorePorts(c *testing.T) {
testRequires(c, DaemonIsLinux) // Expose not implemented on Windows
// start building docker file with a large number of ports
portList := make([]string, 50)
@@ -1651,7 +1651,7 @@
}
}
-func (s *DockerSuite) TestBuildExposeOrder(c *check.C) {
+func (s *DockerSuite) TestBuildExposeOrder(c *testing.T) {
testRequires(c, DaemonIsLinux) // Expose not implemented on Windows
buildID := func(name, exposed string) string {
buildImageSuccessfully(c, name, build.WithDockerfile(fmt.Sprintf(`FROM scratch
@@ -1667,7 +1667,7 @@
}
}
-func (s *DockerSuite) TestBuildExposeUpperCaseProto(c *check.C) {
+func (s *DockerSuite) TestBuildExposeUpperCaseProto(c *testing.T) {
testRequires(c, DaemonIsLinux) // Expose not implemented on Windows
name := "testbuildexposeuppercaseproto"
expected := "map[5678/udp:{}]"
@@ -1679,7 +1679,7 @@
}
}
-func (s *DockerSuite) TestBuildEmptyEntrypointInheritance(c *check.C) {
+func (s *DockerSuite) TestBuildEmptyEntrypointInheritance(c *testing.T) {
name := "testbuildentrypointinheritance"
name2 := "testbuildentrypointinheritance2"
@@ -1702,7 +1702,7 @@
}
}
-func (s *DockerSuite) TestBuildEmptyEntrypoint(c *check.C) {
+func (s *DockerSuite) TestBuildEmptyEntrypoint(c *testing.T) {
name := "testbuildentrypoint"
expected := "[]"
@@ -1716,7 +1716,7 @@
}
-func (s *DockerSuite) TestBuildEntrypoint(c *check.C) {
+func (s *DockerSuite) TestBuildEntrypoint(c *testing.T) {
name := "testbuildentrypoint"
expected := "[/bin/echo]"
@@ -1731,7 +1731,7 @@
}
// #6445 ensure ONBUILD triggers aren't committed to grandchildren
-func (s *DockerSuite) TestBuildOnBuildLimitedInheritance(c *check.C) {
+func (s *DockerSuite) TestBuildOnBuildLimitedInheritance(c *testing.T) {
buildImageSuccessfully(c, "testonbuildtrigger1", build.WithDockerfile(`
FROM busybox
RUN echo "GRANDPARENT"
@@ -1749,7 +1749,7 @@
}
}
-func (s *DockerSuite) TestBuildSameDockerfileWithAndWithoutCache(c *check.C) {
+func (s *DockerSuite) TestBuildSameDockerfileWithAndWithoutCache(c *testing.T) {
testRequires(c, DaemonIsLinux) // Expose not implemented on Windows
name := "testbuildwithcache"
dockerfile := `FROM scratch
@@ -1771,7 +1771,7 @@
}
// Make sure that ADD/COPY still populate the cache even if they don't use it
-func (s *DockerSuite) TestBuildConditionalCache(c *check.C) {
+func (s *DockerSuite) TestBuildConditionalCache(c *testing.T) {
name := "testbuildconditionalcache"
dockerfile := `
@@ -1805,7 +1805,7 @@
}
}
-func (s *DockerSuite) TestBuildAddMultipleLocalFileWithAndWithoutCache(c *check.C) {
+func (s *DockerSuite) TestBuildAddMultipleLocalFileWithAndWithoutCache(c *testing.T) {
name := "testbuildaddmultiplelocalfilewithcache"
baseName := name + "-base"
@@ -1837,7 +1837,7 @@
}
}
-func (s *DockerSuite) TestBuildCopyDirButNotFile(c *check.C) {
+func (s *DockerSuite) TestBuildCopyDirButNotFile(c *testing.T) {
name := "testbuildcopydirbutnotfile"
name2 := "testbuildcopydirbutnotfile2"
@@ -1861,7 +1861,7 @@
}
}
-func (s *DockerSuite) TestBuildAddCurrentDirWithCache(c *check.C) {
+func (s *DockerSuite) TestBuildAddCurrentDirWithCache(c *testing.T) {
name := "testbuildaddcurrentdirwithcache"
name2 := name + "2"
name3 := name + "3"
@@ -1908,7 +1908,7 @@
}
// FIXME(vdemeester) this really seems to test the same thing as before (TestBuildAddMultipleLocalFileWithAndWithoutCache)
-func (s *DockerSuite) TestBuildAddCurrentDirWithoutCache(c *check.C) {
+func (s *DockerSuite) TestBuildAddCurrentDirWithoutCache(c *testing.T) {
name := "testbuildaddcurrentdirwithoutcache"
dockerfile := `
FROM ` + minimalBaseImage() + `
@@ -1927,7 +1927,7 @@
}
}
-func (s *DockerSuite) TestBuildAddRemoteFileWithAndWithoutCache(c *check.C) {
+func (s *DockerSuite) TestBuildAddRemoteFileWithAndWithoutCache(c *testing.T) {
name := "testbuildaddremotefilewithcache"
server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{
"baz": "hello",
@@ -1952,7 +1952,7 @@
}
}
-func (s *DockerSuite) TestBuildAddRemoteFileMTime(c *check.C) {
+func (s *DockerSuite) TestBuildAddRemoteFileMTime(c *testing.T) {
name := "testbuildaddremotefilemtime"
name2 := name + "2"
name3 := name + "3"
@@ -1995,7 +1995,7 @@
}
// FIXME(vdemeester) this really seems to test the same thing as before (combined)
-func (s *DockerSuite) TestBuildAddLocalAndRemoteFilesWithAndWithoutCache(c *check.C) {
+func (s *DockerSuite) TestBuildAddLocalAndRemoteFilesWithAndWithoutCache(c *testing.T) {
name := "testbuildaddlocalandremotefilewithcache"
server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{
"baz": "hello",
@@ -2024,7 +2024,7 @@
}
}
-func testContextTar(c *check.C, compression archive.Compression) {
+func testContextTar(c *testing.T, compression archive.Compression) {
ctx := fakecontext.New(c, "",
fakecontext.WithDockerfile(`FROM busybox
ADD foo /foo
@@ -2043,15 +2043,15 @@
cli.BuildCmd(c, name, build.WithStdinContext(context))
}
-func (s *DockerSuite) TestBuildContextTarGzip(c *check.C) {
+func (s *DockerSuite) TestBuildContextTarGzip(c *testing.T) {
testContextTar(c, archive.Gzip)
}
-func (s *DockerSuite) TestBuildContextTarNoCompression(c *check.C) {
+func (s *DockerSuite) TestBuildContextTarNoCompression(c *testing.T) {
testContextTar(c, archive.Uncompressed)
}
-func (s *DockerSuite) TestBuildNoContext(c *check.C) {
+func (s *DockerSuite) TestBuildNoContext(c *testing.T) {
name := "nocontext"
icmd.RunCmd(icmd.Cmd{
Command: []string{dockerBinary, "build", "-t", name, "-"},
@@ -2066,7 +2066,7 @@
}
// FIXME(vdemeester) migrate to docker/cli e2e
-func (s *DockerSuite) TestBuildDockerfileStdin(c *check.C) {
+func (s *DockerSuite) TestBuildDockerfileStdin(c *testing.T) {
name := "stdindockerfile"
tmpDir, err := ioutil.TempDir("", "fake-context")
assert.NilError(c, err)
@@ -2082,11 +2082,11 @@
}).Assert(c, icmd.Success)
res := inspectField(c, name, "Config.Cmd")
- c.Assert(strings.TrimSpace(string(res)), checker.Equals, `[cat /foo]`)
+ assert.Equal(c, strings.TrimSpace(string(res)), `[cat /foo]`)
}
// FIXME(vdemeester) migrate to docker/cli tests (unit or e2e)
-func (s *DockerSuite) TestBuildDockerfileStdinConflict(c *check.C) {
+func (s *DockerSuite) TestBuildDockerfileStdinConflict(c *testing.T) {
name := "stdindockerfiletarcontext"
icmd.RunCmd(icmd.Cmd{
Command: []string{dockerBinary, "build", "-t", name, "-f", "-", "-"},
@@ -2096,19 +2096,19 @@
})
}
-func (s *DockerSuite) TestBuildDockerfileStdinNoExtraFiles(c *check.C) {
+func (s *DockerSuite) TestBuildDockerfileStdinNoExtraFiles(c *testing.T) {
s.testBuildDockerfileStdinNoExtraFiles(c, false, false)
}
-func (s *DockerSuite) TestBuildDockerfileStdinDockerignore(c *check.C) {
+func (s *DockerSuite) TestBuildDockerfileStdinDockerignore(c *testing.T) {
s.testBuildDockerfileStdinNoExtraFiles(c, true, false)
}
-func (s *DockerSuite) TestBuildDockerfileStdinDockerignoreIgnored(c *check.C) {
+func (s *DockerSuite) TestBuildDockerfileStdinDockerignoreIgnored(c *testing.T) {
s.testBuildDockerfileStdinNoExtraFiles(c, true, true)
}
-func (s *DockerSuite) testBuildDockerfileStdinNoExtraFiles(c *check.C, hasDockerignore, ignoreDockerignore bool) {
+func (s *DockerSuite) testBuildDockerfileStdinNoExtraFiles(c *testing.T, hasDockerignore, ignoreDockerignore bool) {
name := "stdindockerfilenoextra"
tmpDir, err := ioutil.TempDir("", "fake-context")
assert.NilError(c, err)
@@ -2142,13 +2142,13 @@
result = cli.DockerCmd(c, "run", "--rm", name, "ls", "-A", "/baz")
if hasDockerignore && !ignoreDockerignore {
- c.Assert(result.Stdout(), checker.Equals, ".dockerignore\nfoo\n")
+ assert.Equal(c, result.Stdout(), ".dockerignore\nfoo\n")
} else {
- c.Assert(result.Stdout(), checker.Equals, "foo\n")
+ assert.Equal(c, result.Stdout(), "foo\n")
}
}
-func (s *DockerSuite) TestBuildWithVolumeOwnership(c *check.C) {
+func (s *DockerSuite) TestBuildWithVolumeOwnership(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "testbuildimg"
@@ -2168,7 +2168,7 @@
// testing #1405 - config.Cmd does not get cleaned up if
// utilizing cache
-func (s *DockerSuite) TestBuildEntrypointRunCleanup(c *check.C) {
+func (s *DockerSuite) TestBuildEntrypointRunCleanup(c *testing.T) {
name := "testbuildcmdcleanup"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox
RUN echo "hello"`))
@@ -2187,7 +2187,7 @@
}
}
-func (s *DockerSuite) TestBuildAddFileNotFound(c *check.C) {
+func (s *DockerSuite) TestBuildAddFileNotFound(c *testing.T) {
name := "testbuildaddnotfound"
expected := "foo: no such file or directory"
@@ -2204,7 +2204,7 @@
})
}
-func (s *DockerSuite) TestBuildInheritance(c *check.C) {
+func (s *DockerSuite) TestBuildInheritance(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "testbuildinheritance"
@@ -2225,7 +2225,7 @@
}
}
-func (s *DockerSuite) TestBuildFails(c *check.C) {
+func (s *DockerSuite) TestBuildFails(c *testing.T) {
name := "testbuildfails"
buildImage(name, build.WithDockerfile(`FROM busybox
RUN sh -c "exit 23"`)).Assert(c, icmd.Expected{
@@ -2234,7 +2234,7 @@
})
}
-func (s *DockerSuite) TestBuildOnBuild(c *check.C) {
+func (s *DockerSuite) TestBuildOnBuild(c *testing.T) {
name := "testbuildonbuild"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox
ONBUILD RUN touch foobar`))
@@ -2243,7 +2243,7 @@
}
// gh #2446
-func (s *DockerSuite) TestBuildAddToSymlinkDest(c *check.C) {
+func (s *DockerSuite) TestBuildAddToSymlinkDest(c *testing.T) {
makeLink := `ln -s /foo /bar`
if testEnv.OSType == "windows" {
makeLink = `mklink /D C:\bar C:\foo`
@@ -2261,7 +2261,7 @@
))
}
-func (s *DockerSuite) TestBuildEscapeWhitespace(c *check.C) {
+func (s *DockerSuite) TestBuildEscapeWhitespace(c *testing.T) {
name := "testbuildescapewhitespace"
buildImageSuccessfully(c, name, build.WithDockerfile(`
@@ -2279,7 +2279,7 @@
}
-func (s *DockerSuite) TestBuildVerifyIntString(c *check.C) {
+func (s *DockerSuite) TestBuildVerifyIntString(c *testing.T) {
// Verify that strings that look like ints are still passed as strings
name := "testbuildstringing"
@@ -2294,7 +2294,7 @@
}
-func (s *DockerSuite) TestBuildDockerignore(c *check.C) {
+func (s *DockerSuite) TestBuildDockerignore(c *testing.T) {
name := "testbuilddockerignore"
buildImageSuccessfully(c, name, build.WithBuildContext(c,
build.WithFile("Dockerfile", `
@@ -2332,7 +2332,7 @@
))
}
-func (s *DockerSuite) TestBuildDockerignoreCleanPaths(c *check.C) {
+func (s *DockerSuite) TestBuildDockerignoreCleanPaths(c *testing.T) {
name := "testbuilddockerignorecleanpaths"
buildImageSuccessfully(c, name, build.WithBuildContext(c,
build.WithFile("Dockerfile", `
@@ -2346,7 +2346,7 @@
))
}
-func (s *DockerSuite) TestBuildDockerignoreExceptions(c *check.C) {
+func (s *DockerSuite) TestBuildDockerignoreExceptions(c *testing.T) {
name := "testbuilddockerignoreexceptions"
buildImageSuccessfully(c, name, build.WithBuildContext(c,
build.WithFile("Dockerfile", `
@@ -2391,7 +2391,7 @@
))
}
-func (s *DockerSuite) TestBuildDockerignoringDockerfile(c *check.C) {
+func (s *DockerSuite) TestBuildDockerignoringDockerfile(c *testing.T) {
name := "testbuilddockerignoredockerfile"
dockerfile := `
FROM busybox
@@ -2409,7 +2409,7 @@
))
}
-func (s *DockerSuite) TestBuildDockerignoringRenamedDockerfile(c *check.C) {
+func (s *DockerSuite) TestBuildDockerignoringRenamedDockerfile(c *testing.T) {
name := "testbuilddockerignoredockerfile"
dockerfile := `
FROM busybox
@@ -2430,7 +2430,7 @@
))
}
-func (s *DockerSuite) TestBuildDockerignoringDockerignore(c *check.C) {
+func (s *DockerSuite) TestBuildDockerignoringDockerignore(c *testing.T) {
name := "testbuilddockerignoredockerignore"
dockerfile := `
FROM busybox
@@ -2443,7 +2443,7 @@
))
}
-func (s *DockerSuite) TestBuildDockerignoreTouchDockerfile(c *check.C) {
+func (s *DockerSuite) TestBuildDockerignoreTouchDockerfile(c *testing.T) {
name := "testbuilddockerignoretouchdockerfile"
dockerfile := `
FROM busybox
@@ -2485,7 +2485,7 @@
}
}
-func (s *DockerSuite) TestBuildDockerignoringWholeDir(c *check.C) {
+func (s *DockerSuite) TestBuildDockerignoringWholeDir(c *testing.T) {
name := "testbuilddockerignorewholedir"
dockerfile := `
@@ -2502,7 +2502,7 @@
))
}
-func (s *DockerSuite) TestBuildDockerignoringOnlyDotfiles(c *check.C) {
+func (s *DockerSuite) TestBuildDockerignoringOnlyDotfiles(c *testing.T) {
name := "testbuilddockerignorewholedir"
dockerfile := `
@@ -2519,7 +2519,7 @@
))
}
-func (s *DockerSuite) TestBuildDockerignoringBadExclusion(c *check.C) {
+func (s *DockerSuite) TestBuildDockerignoringBadExclusion(c *testing.T) {
name := "testbuilddockerignorebadexclusion"
buildImage(name, build.WithBuildContext(c,
build.WithFile("Dockerfile", `
@@ -2536,7 +2536,7 @@
})
}
-func (s *DockerSuite) TestBuildDockerignoringWildTopDir(c *check.C) {
+func (s *DockerSuite) TestBuildDockerignoringWildTopDir(c *testing.T) {
dockerfile := `
FROM busybox
COPY . /
@@ -2558,7 +2558,7 @@
}
}
-func (s *DockerSuite) TestBuildDockerignoringWildDirs(c *check.C) {
+func (s *DockerSuite) TestBuildDockerignoringWildDirs(c *testing.T) {
dockerfile := `
FROM busybox
COPY . /
@@ -2621,7 +2621,7 @@
))
}
-func (s *DockerSuite) TestBuildLineBreak(c *check.C) {
+func (s *DockerSuite) TestBuildLineBreak(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "testbuildlinebreak"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox
@@ -2632,7 +2632,7 @@
RUN sh -c "[ "$(ls -d /var/run/sshd)" = "/var/run/sshd" ]"`))
}
-func (s *DockerSuite) TestBuildEOLInLine(c *check.C) {
+func (s *DockerSuite) TestBuildEOLInLine(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "testbuildeolinline"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox
@@ -2643,7 +2643,7 @@
RUN sh -c "[ "$(ls -d /var/run/sshd)" = "/var/run/sshd" ]"`))
}
-func (s *DockerSuite) TestBuildCommentsShebangs(c *check.C) {
+func (s *DockerSuite) TestBuildCommentsShebangs(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "testbuildcomments"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox
@@ -2657,7 +2657,7 @@
RUN [ "$(/hello.sh)" = "hello world" ]`))
}
-func (s *DockerSuite) TestBuildUsersAndGroups(c *check.C) {
+func (s *DockerSuite) TestBuildUsersAndGroups(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "testbuildusers"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox
@@ -2713,7 +2713,7 @@
}
// FIXME(vdemeester) rename this test (and probably "merge" it with the one below TestBuildEnvUsage2)
-func (s *DockerSuite) TestBuildEnvUsage(c *check.C) {
+func (s *DockerSuite) TestBuildEnvUsage(c *testing.T) {
// /docker/world/hello is not owned by the correct user
testRequires(c, NotUserNamespace)
testRequires(c, DaemonIsLinux)
@@ -2744,7 +2744,7 @@
}
// FIXME(vdemeester) rename this test (and probably "merge" it with the one above TestBuildEnvUsage)
-func (s *DockerSuite) TestBuildEnvUsage2(c *check.C) {
+func (s *DockerSuite) TestBuildEnvUsage2(c *testing.T) {
// /docker/world/hello is not owned by the correct user
testRequires(c, NotUserNamespace)
testRequires(c, DaemonIsLinux)
@@ -2813,7 +2813,7 @@
))
}
-func (s *DockerSuite) TestBuildAddScript(c *check.C) {
+func (s *DockerSuite) TestBuildAddScript(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "testbuildaddscript"
dockerfile := `
@@ -2829,7 +2829,7 @@
))
}
-func (s *DockerSuite) TestBuildAddTar(c *check.C) {
+func (s *DockerSuite) TestBuildAddTar(c *testing.T) {
// /test/foo is not owned by the correct user
testRequires(c, NotUserNamespace)
name := "testbuildaddtar"
@@ -2883,7 +2883,7 @@
buildImageSuccessfully(c, name, build.WithExternalBuildContext(ctx))
}
-func (s *DockerSuite) TestBuildAddBrokenTar(c *check.C) {
+func (s *DockerSuite) TestBuildAddBrokenTar(c *testing.T) {
name := "testbuildaddbrokentar"
ctx := func() *fakecontext.Fake {
@@ -2934,7 +2934,7 @@
})
}
-func (s *DockerSuite) TestBuildAddNonTar(c *check.C) {
+func (s *DockerSuite) TestBuildAddNonTar(c *testing.T) {
name := "testbuildaddnontar"
// Should not try to extract test.tar
@@ -2947,7 +2947,7 @@
))
}
-func (s *DockerSuite) TestBuildAddTarXz(c *check.C) {
+func (s *DockerSuite) TestBuildAddTarXz(c *testing.T) {
// /test/foo is not owned by the correct user
testRequires(c, NotUserNamespace)
testRequires(c, DaemonIsLinux)
@@ -2996,7 +2996,7 @@
buildImageSuccessfully(c, name, build.WithExternalBuildContext(ctx))
}
-func (s *DockerSuite) TestBuildAddTarXzGz(c *check.C) {
+func (s *DockerSuite) TestBuildAddTarXzGz(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "testbuildaddtarxzgz"
@@ -3049,7 +3049,7 @@
}
// FIXME(vdemeester) most of the from git tests could be moved to `docker/cli` e2e tests
-func (s *DockerSuite) TestBuildFromGit(c *check.C) {
+func (s *DockerSuite) TestBuildFromGit(c *testing.T) {
name := "testbuildfromgit"
git := fakegit.New(c, "repo", map[string]string{
"Dockerfile": `FROM busybox
@@ -3068,7 +3068,7 @@
}
}
-func (s *DockerSuite) TestBuildFromGitWithContext(c *check.C) {
+func (s *DockerSuite) TestBuildFromGitWithContext(c *testing.T) {
name := "testbuildfromgit"
git := fakegit.New(c, "repo", map[string]string{
"docker/Dockerfile": `FROM busybox
@@ -3087,7 +3087,7 @@
}
}
-func (s *DockerSuite) TestBuildFromGitWithF(c *check.C) {
+func (s *DockerSuite) TestBuildFromGitWithF(c *testing.T) {
name := "testbuildfromgitwithf"
git := fakegit.New(c, "repo", map[string]string{
"myApp/myDockerfile": `FROM busybox
@@ -3100,7 +3100,7 @@
})
}
-func (s *DockerSuite) TestBuildFromRemoteTarball(c *check.C) {
+func (s *DockerSuite) TestBuildFromRemoteTarball(c *testing.T) {
name := "testbuildfromremotetarball"
buffer := new(bytes.Buffer)
@@ -3135,7 +3135,7 @@
}
}
-func (s *DockerSuite) TestBuildCleanupCmdOnEntrypoint(c *check.C) {
+func (s *DockerSuite) TestBuildCleanupCmdOnEntrypoint(c *testing.T) {
name := "testbuildcmdcleanuponentrypoint"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+`
@@ -3154,7 +3154,7 @@
}
}
-func (s *DockerSuite) TestBuildClearCmd(c *check.C) {
+func (s *DockerSuite) TestBuildClearCmd(c *testing.T) {
name := "testbuildclearcmd"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+`
ENTRYPOINT ["/bin/bash"]
@@ -3166,7 +3166,7 @@
}
}
-func (s *DockerSuite) TestBuildEmptyCmd(c *check.C) {
+func (s *DockerSuite) TestBuildEmptyCmd(c *testing.T) {
// Skip on Windows. Base image on Windows has a CMD set in the image.
testRequires(c, DaemonIsLinux)
@@ -3179,7 +3179,7 @@
}
}
-func (s *DockerSuite) TestBuildOnBuildOutput(c *check.C) {
+func (s *DockerSuite) TestBuildOnBuildOutput(c *testing.T) {
name := "testbuildonbuildparent"
buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nONBUILD RUN echo foo\n"))
@@ -3189,7 +3189,7 @@
}
// FIXME(vdemeester) should be a unit test
-func (s *DockerSuite) TestBuildInvalidTag(c *check.C) {
+func (s *DockerSuite) TestBuildInvalidTag(c *testing.T) {
name := "abcd:" + testutil.GenerateRandomAlphaOnlyString(200)
buildImage(name, build.WithDockerfile("FROM "+minimalBaseImage()+"\nMAINTAINER quux\n")).Assert(c, icmd.Expected{
ExitCode: 125,
@@ -3197,7 +3197,7 @@
})
}
-func (s *DockerSuite) TestBuildCmdShDashC(c *check.C) {
+func (s *DockerSuite) TestBuildCmdShDashC(c *testing.T) {
name := "testbuildcmdshc"
buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nCMD echo cmd\n"))
@@ -3212,7 +3212,7 @@
}
-func (s *DockerSuite) TestBuildCmdSpaces(c *check.C) {
+func (s *DockerSuite) TestBuildCmdSpaces(c *testing.T) {
// Test to make sure that when we strcat arrays we take into account
// the arg separator to make sure ["echo","hi"] and ["echo hi"] don't
// look the same
@@ -3238,7 +3238,7 @@
}
}
-func (s *DockerSuite) TestBuildCmdJSONNoShDashC(c *check.C) {
+func (s *DockerSuite) TestBuildCmdJSONNoShDashC(c *testing.T) {
name := "testbuildcmdjson"
buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nCMD [\"echo\", \"cmd\"]"))
@@ -3249,7 +3249,7 @@
}
}
-func (s *DockerSuite) TestBuildEntrypointCanBeOverriddenByChild(c *check.C) {
+func (s *DockerSuite) TestBuildEntrypointCanBeOverriddenByChild(c *testing.T) {
buildImageSuccessfully(c, "parent", build.WithDockerfile(`
FROM busybox
ENTRYPOINT exit 130
@@ -3269,7 +3269,7 @@
})
}
-func (s *DockerSuite) TestBuildEntrypointCanBeOverriddenByChildInspect(c *check.C) {
+func (s *DockerSuite) TestBuildEntrypointCanBeOverriddenByChildInspect(c *testing.T) {
var (
name = "testbuildepinherit"
name2 = "testbuildepinherit2"
@@ -3293,14 +3293,14 @@
})
}
-func (s *DockerSuite) TestBuildRunShEntrypoint(c *check.C) {
+func (s *DockerSuite) TestBuildRunShEntrypoint(c *testing.T) {
name := "testbuildentrypoint"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox
ENTRYPOINT echo`))
dockerCmd(c, "run", "--rm", name)
}
-func (s *DockerSuite) TestBuildExoticShellInterpolation(c *check.C) {
+func (s *DockerSuite) TestBuildExoticShellInterpolation(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "testbuildexoticshellinterpolation"
@@ -3325,7 +3325,7 @@
`))
}
-func (s *DockerSuite) TestBuildVerifySingleQuoteFails(c *check.C) {
+func (s *DockerSuite) TestBuildVerifySingleQuoteFails(c *testing.T) {
// This testcase is supposed to generate an error because the
// JSON array we're passing in on the CMD uses single quotes instead
// of double quotes (per the JSON spec). This means we interpret it
@@ -3342,7 +3342,7 @@
})
}
-func (s *DockerSuite) TestBuildVerboseOut(c *check.C) {
+func (s *DockerSuite) TestBuildVerboseOut(c *testing.T) {
name := "testbuildverboseout"
expected := "\n123\n"
@@ -3356,7 +3356,7 @@
})
}
-func (s *DockerSuite) TestBuildWithTabs(c *check.C) {
+func (s *DockerSuite) TestBuildWithTabs(c *testing.T) {
name := "testbuildwithtabs"
buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nRUN echo\tone\t\ttwo"))
res := inspectFieldJSON(c, name, "ContainerConfig.Cmd")
@@ -3371,7 +3371,7 @@
}
}
-func (s *DockerSuite) TestBuildLabels(c *check.C) {
+func (s *DockerSuite) TestBuildLabels(c *testing.T) {
name := "testbuildlabel"
expected := `{"License":"GPL","Vendor":"Acme"}`
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox
@@ -3383,7 +3383,7 @@
}
}
-func (s *DockerSuite) TestBuildLabelsCache(c *check.C) {
+func (s *DockerSuite) TestBuildLabelsCache(c *testing.T) {
name := "testbuildlabelcache"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox
@@ -3424,7 +3424,7 @@
}
// FIXME(vdemeester) port to docker/cli e2e tests (api tests should test suppressOutput option though)
-func (s *DockerSuite) TestBuildNotVerboseSuccess(c *check.C) {
+func (s *DockerSuite) TestBuildNotVerboseSuccess(c *testing.T) {
// This test makes sure that -q works correctly when build is successful:
// stdout has only the image ID (long image ID) and stderr is empty.
outRegexp := regexp.MustCompile("^(sha256:|)[a-z0-9]{64}\\n$")
@@ -3475,7 +3475,7 @@
}
// FIXME(vdemeester) migrate to docker/cli tests
-func (s *DockerSuite) TestBuildNotVerboseFailureWithNonExistImage(c *check.C) {
+func (s *DockerSuite) TestBuildNotVerboseFailureWithNonExistImage(c *testing.T) {
// This test makes sure that -q works correctly when build fails by
// comparing between the stderr output in quiet mode and in stdout
// and stderr output in verbose mode
@@ -3496,7 +3496,7 @@
}
// FIXME(vdemeester) migrate to docker/cli tests
-func (s *DockerSuite) TestBuildNotVerboseFailure(c *check.C) {
+func (s *DockerSuite) TestBuildNotVerboseFailure(c *testing.T) {
// This test makes sure that -q works correctly when build fails by
// comparing between the stderr output in quiet mode and in stdout
// and stderr output in verbose mode
@@ -3524,7 +3524,7 @@
}
// FIXME(vdemeester) migrate to docker/cli tests
-func (s *DockerSuite) TestBuildNotVerboseFailureRemote(c *check.C) {
+func (s *DockerSuite) TestBuildNotVerboseFailureRemote(c *testing.T) {
// This test ensures that when given a wrong URL, stderr in quiet mode and
// stderr in verbose mode are identical.
// TODO(vdemeester) with cobra, stdout has a carriage return too much so this test should not check stdout
@@ -3554,7 +3554,7 @@
}
// FIXME(vdemeester) migrate to docker/cli tests
-func (s *DockerSuite) TestBuildStderr(c *check.C) {
+func (s *DockerSuite) TestBuildStderr(c *testing.T) {
// This test just makes sure that no non-error output goes
// to stderr
name := "testbuildstderr"
@@ -3572,7 +3572,7 @@
}
}
-func (s *DockerSuite) TestBuildChownSingleFile(c *check.C) {
+func (s *DockerSuite) TestBuildChownSingleFile(c *testing.T) {
testRequires(c, UnixCli, DaemonIsLinux) // test uses chown: not available on windows
name := "testbuildchownsinglefile"
@@ -3596,7 +3596,7 @@
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
}
-func (s *DockerSuite) TestBuildSymlinkBreakout(c *check.C) {
+func (s *DockerSuite) TestBuildSymlinkBreakout(c *testing.T) {
name := "testbuildsymlinkbreakout"
tmpdir, err := ioutil.TempDir("", name)
assert.NilError(c, err)
@@ -3651,7 +3651,7 @@
}
}
-func (s *DockerSuite) TestBuildXZHost(c *check.C) {
+func (s *DockerSuite) TestBuildXZHost(c *testing.T) {
// /usr/local/sbin/xz gets permission denied for the user
testRequires(c, NotUserNamespace)
testRequires(c, DaemonIsLinux)
@@ -3669,7 +3669,7 @@
))
}
-func (s *DockerSuite) TestBuildVolumesRetainContents(c *check.C) {
+func (s *DockerSuite) TestBuildVolumesRetainContents(c *testing.T) {
// /foo/file gets permission denied for the user
testRequires(c, NotUserNamespace)
testRequires(c, DaemonIsLinux) // TODO Windows: Issue #20127
@@ -3699,7 +3699,7 @@
}
-func (s *DockerSuite) TestBuildFromMixedcaseDockerfile(c *check.C) {
+func (s *DockerSuite) TestBuildFromMixedcaseDockerfile(c *testing.T) {
testRequires(c, UnixCli) // Dockerfile overwrites dockerfile on windows
testRequires(c, DaemonIsLinux)
@@ -3723,7 +3723,7 @@
}
// FIXME(vdemeester) should migrate to docker/cli tests
-func (s *DockerSuite) TestBuildFromURLWithF(c *check.C) {
+func (s *DockerSuite) TestBuildFromURLWithF(c *testing.T) {
server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{"baz": `FROM busybox
RUN echo from baz
COPY * /tmp/
@@ -3750,7 +3750,7 @@
}
// FIXME(vdemeester) should migrate to docker/cli tests
-func (s *DockerSuite) TestBuildFromStdinWithF(c *check.C) {
+func (s *DockerSuite) TestBuildFromStdinWithF(c *testing.T) {
testRequires(c, DaemonIsLinux) // TODO Windows: This test is flaky; no idea why
ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(`FROM busybox
RUN echo "from Dockerfile"`))
@@ -3775,7 +3775,7 @@
}
-func (s *DockerSuite) TestBuildFromOfficialNames(c *check.C) {
+func (s *DockerSuite) TestBuildFromOfficialNames(c *testing.T) {
name := "testbuildfromofficial"
fromNames := []string{
"busybox",
@@ -3793,7 +3793,7 @@
}
// FIXME(vdemeester) should be a unit test
-func (s *DockerSuite) TestBuildSpaces(c *check.C) {
+func (s *DockerSuite) TestBuildSpaces(c *testing.T) {
// Test to make sure that leading/trailing spaces on a command
// doesn't change the error msg we get
name := "testspaces"
@@ -3856,7 +3856,7 @@
}
-func (s *DockerSuite) TestBuildSpacesWithQuotes(c *check.C) {
+func (s *DockerSuite) TestBuildSpacesWithQuotes(c *testing.T) {
// Test to make sure that spaces in quotes aren't lost
name := "testspacesquotes"
@@ -3876,7 +3876,7 @@
}
// #4393
-func (s *DockerSuite) TestBuildVolumeFileExistsinContainer(c *check.C) {
+func (s *DockerSuite) TestBuildVolumeFileExistsinContainer(c *testing.T) {
testRequires(c, DaemonIsLinux) // TODO Windows: This should error out
buildImage("docker-test-errcreatevolumewithfile", build.WithDockerfile(`
FROM busybox
@@ -3889,7 +3889,7 @@
}
// FIXME(vdemeester) should be a unit test
-func (s *DockerSuite) TestBuildMissingArgs(c *check.C) {
+func (s *DockerSuite) TestBuildMissingArgs(c *testing.T) {
// Test to make sure that all Dockerfile commands (except the ones listed
// in skipCmds) will generate an error if no args are provided.
// Note: INSERT is deprecated so we exclude it because of that.
@@ -3934,7 +3934,7 @@
}
-func (s *DockerSuite) TestBuildEmptyScratch(c *check.C) {
+func (s *DockerSuite) TestBuildEmptyScratch(c *testing.T) {
testRequires(c, DaemonIsLinux)
buildImage("sc", build.WithDockerfile("FROM scratch")).Assert(c, icmd.Expected{
ExitCode: 1,
@@ -3942,14 +3942,14 @@
})
}
-func (s *DockerSuite) TestBuildDotDotFile(c *check.C) {
+func (s *DockerSuite) TestBuildDotDotFile(c *testing.T) {
buildImageSuccessfully(c, "sc", build.WithBuildContext(c,
build.WithFile("Dockerfile", "FROM busybox\n"),
build.WithFile("..gitme", ""),
))
}
-func (s *DockerSuite) TestBuildRUNoneJSON(c *check.C) {
+func (s *DockerSuite) TestBuildRUNoneJSON(c *testing.T) {
testRequires(c, DaemonIsLinux) // No hello-world Windows image
name := "testbuildrunonejson"
@@ -3959,7 +3959,7 @@
})
}
-func (s *DockerSuite) TestBuildEmptyStringVolume(c *check.C) {
+func (s *DockerSuite) TestBuildEmptyStringVolume(c *testing.T) {
name := "testbuildemptystringvolume"
buildImage(name, build.WithDockerfile(`
@@ -3971,7 +3971,7 @@
})
}
-func (s *DockerSuite) TestBuildContainerWithCgroupParent(c *check.C) {
+func (s *DockerSuite) TestBuildContainerWithCgroupParent(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
cgroupParent := "test"
@@ -3999,7 +3999,7 @@
}
// FIXME(vdemeester) could be a unit test
-func (s *DockerSuite) TestBuildNoDupOutput(c *check.C) {
+func (s *DockerSuite) TestBuildNoDupOutput(c *testing.T) {
// Check to make sure our build output prints the Dockerfile cmd
// property - there was a bug that caused it to be duplicated on the
// Step X line
@@ -4016,7 +4016,7 @@
// GH15826
// FIXME(vdemeester) could be a unit test
-func (s *DockerSuite) TestBuildStartsFromOne(c *check.C) {
+func (s *DockerSuite) TestBuildStartsFromOne(c *testing.T) {
// Explicit check to ensure that build starts from step 1 rather than 0
name := "testbuildstartsfromone"
result := buildImage(name, build.WithDockerfile(`FROM busybox`))
@@ -4027,7 +4027,7 @@
}
}
-func (s *DockerSuite) TestBuildRUNErrMsg(c *check.C) {
+func (s *DockerSuite) TestBuildRUNErrMsg(c *testing.T) {
// Test to make sure the bad command is quoted with just "s and
// not as a Go []string
name := "testbuildbadrunerrmsg"
@@ -4049,7 +4049,7 @@
}
// Issue #15634: COPY fails when path starts with "null"
-func (s *DockerSuite) TestBuildNullStringInAddCopyVolume(c *check.C) {
+func (s *DockerSuite) TestBuildNullStringInAddCopyVolume(c *testing.T) {
name := "testbuildnullstringinaddcopyvolume"
volName := "nullvolume"
if testEnv.OSType == "windows" {
@@ -4069,7 +4069,7 @@
))
}
-func (s *DockerSuite) TestBuildStopSignal(c *check.C) {
+func (s *DockerSuite) TestBuildStopSignal(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows does not support STOPSIGNAL yet
imgName := "test_build_stop_signal"
buildImageSuccessfully(c, imgName, build.WithDockerfile(`FROM busybox
@@ -4087,7 +4087,7 @@
}
}
-func (s *DockerSuite) TestBuildBuildTimeArg(c *check.C) {
+func (s *DockerSuite) TestBuildBuildTimeArg(c *testing.T) {
imgName := "bldargtest"
envKey := "foo"
envVal := "bar"
@@ -4120,7 +4120,7 @@
}
}
-func (s *DockerSuite) TestBuildBuildTimeArgHistory(c *check.C) {
+func (s *DockerSuite) TestBuildBuildTimeArgHistory(c *testing.T) {
imgName := "bldargtest"
envKey := "foo"
envVal := "bar"
@@ -4141,7 +4141,7 @@
}
}
-func (s *DockerSuite) TestBuildTimeArgHistoryExclusions(c *check.C) {
+func (s *DockerSuite) TestBuildTimeArgHistoryExclusions(c *testing.T) {
imgName := "bldargtest"
envKey := "foo"
envVal := "bar"
@@ -4178,10 +4178,10 @@
result.Assert(c, icmd.Expected{Out: fmt.Sprintf("%s=%s", explicitProxyKey, explicitProxyVal)})
cacheID := buildImage(imgName + "-two")
- c.Assert(origID, checker.Equals, cacheID)
+ assert.Equal(c, origID, cacheID)
}
-func (s *DockerSuite) TestBuildBuildTimeArgCacheHit(c *check.C) {
+func (s *DockerSuite) TestBuildBuildTimeArgCacheHit(c *testing.T) {
imgName := "bldargtest"
envKey := "foo"
envVal := "bar"
@@ -4205,7 +4205,7 @@
}
}
-func (s *DockerSuite) TestBuildBuildTimeArgCacheMissExtraArg(c *check.C) {
+func (s *DockerSuite) TestBuildBuildTimeArgCacheMissExtraArg(c *testing.T) {
imgName := "bldargtest"
envKey := "foo"
envVal := "bar"
@@ -4236,7 +4236,7 @@
}
}
-func (s *DockerSuite) TestBuildBuildTimeArgCacheMissSameArgDiffVal(c *check.C) {
+func (s *DockerSuite) TestBuildBuildTimeArgCacheMissSameArgDiffVal(c *testing.T) {
imgName := "bldargtest"
envKey := "foo"
envVal := "bar"
@@ -4261,7 +4261,7 @@
}
}
-func (s *DockerSuite) TestBuildBuildTimeArgOverrideArgDefinedBeforeEnv(c *check.C) {
+func (s *DockerSuite) TestBuildBuildTimeArgOverrideArgDefinedBeforeEnv(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows does not support ARG
imgName := "bldargtest"
envKey := "foo"
@@ -4290,7 +4290,7 @@
}
// FIXME(vdemeester) might be useful to merge with the one above ?
-func (s *DockerSuite) TestBuildBuildTimeArgOverrideEnvDefinedBeforeArg(c *check.C) {
+func (s *DockerSuite) TestBuildBuildTimeArgOverrideEnvDefinedBeforeArg(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows does not support ARG
imgName := "bldargtest"
envKey := "foo"
@@ -4317,7 +4317,7 @@
}
}
-func (s *DockerSuite) TestBuildBuildTimeArgExpansion(c *check.C) {
+func (s *DockerSuite) TestBuildBuildTimeArgExpansion(c *testing.T) {
imgName := "bldvarstest"
wdVar := "WDIR"
@@ -4373,7 +4373,7 @@
)
res := inspectField(c, imgName, "Config.WorkingDir")
- c.Check(filepath.ToSlash(res), check.Equals, filepath.ToSlash(wdVal))
+ assert.Equal(c, filepath.ToSlash(res), filepath.ToSlash(wdVal))
var resArr []string
inspectFieldAndUnmarshall(c, imgName, "Config.Env", &resArr)
@@ -4407,7 +4407,7 @@
}
}
-func (s *DockerSuite) TestBuildBuildTimeArgExpansionOverride(c *check.C) {
+func (s *DockerSuite) TestBuildBuildTimeArgExpansionOverride(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows does not support ARG
imgName := "bldvarstest"
envKey := "foo"
@@ -4435,7 +4435,7 @@
}
}
-func (s *DockerSuite) TestBuildBuildTimeArgUntrustedDefinedAfterUse(c *check.C) {
+func (s *DockerSuite) TestBuildBuildTimeArgUntrustedDefinedAfterUse(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows does not support ARG
imgName := "bldargtest"
envKey := "foo"
@@ -4459,7 +4459,7 @@
}
}
-func (s *DockerSuite) TestBuildBuildTimeArgBuiltinArg(c *check.C) {
+func (s *DockerSuite) TestBuildBuildTimeArgBuiltinArg(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows does not support --build-arg
imgName := "bldargtest"
envKey := "HTTP_PROXY"
@@ -4482,7 +4482,7 @@
}
}
-func (s *DockerSuite) TestBuildBuildTimeArgDefaultOverride(c *check.C) {
+func (s *DockerSuite) TestBuildBuildTimeArgDefaultOverride(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows does not support ARG
imgName := "bldargtest"
envKey := "foo"
@@ -4508,7 +4508,7 @@
}
}
-func (s *DockerSuite) TestBuildBuildTimeArgUnconsumedArg(c *check.C) {
+func (s *DockerSuite) TestBuildBuildTimeArgUnconsumedArg(c *testing.T) {
imgName := "bldargtest"
envKey := "foo"
envVal := "bar"
@@ -4524,7 +4524,7 @@
})
}
-func (s *DockerSuite) TestBuildBuildTimeArgEnv(c *check.C) {
+func (s *DockerSuite) TestBuildBuildTimeArgEnv(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows does not support ARG
dockerfile := `FROM busybox
ARG FOO1=fromfile
@@ -4579,12 +4579,12 @@
out := result.Combined()[i:] // "out" should contain just the warning message now
// These were specified on a --build-arg but no ARG was in the Dockerfile
- c.Assert(out, checker.Contains, "FOO7")
- c.Assert(out, checker.Contains, "FOO8")
- c.Assert(out, checker.Contains, "FOO9")
+ assert.Assert(c, strings.Contains(out, "FOO7"))
+ assert.Assert(c, strings.Contains(out, "FOO8"))
+ assert.Assert(c, strings.Contains(out, "FOO9"))
}
-func (s *DockerSuite) TestBuildBuildTimeArgQuotedValVariants(c *check.C) {
+func (s *DockerSuite) TestBuildBuildTimeArgQuotedValVariants(c *testing.T) {
imgName := "bldargtest"
envKey := "foo"
envKey1 := "foo1"
@@ -4605,7 +4605,7 @@
buildImageSuccessfully(c, imgName, build.WithDockerfile(dockerfile))
}
-func (s *DockerSuite) TestBuildBuildTimeArgEmptyValVariants(c *check.C) {
+func (s *DockerSuite) TestBuildBuildTimeArgEmptyValVariants(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows does not support ARG
imgName := "bldargtest"
envKey := "foo"
@@ -4621,7 +4621,7 @@
buildImageSuccessfully(c, imgName, build.WithDockerfile(dockerfile))
}
-func (s *DockerSuite) TestBuildBuildTimeArgDefinitionWithNoEnvInjection(c *check.C) {
+func (s *DockerSuite) TestBuildBuildTimeArgDefinitionWithNoEnvInjection(c *testing.T) {
imgName := "bldargtest"
envKey := "foo"
dockerfile := fmt.Sprintf(`FROM busybox
@@ -4635,7 +4635,7 @@
}
}
-func (s *DockerSuite) TestBuildMultiStageArg(c *check.C) {
+func (s *DockerSuite) TestBuildMultiStageArg(c *testing.T) {
imgName := "multifrombldargtest"
dockerfile := `FROM busybox
ARG foo=abc
@@ -4652,14 +4652,13 @@
parentID := strings.TrimSpace(result.Stdout())
result = cli.DockerCmd(c, "run", "--rm", parentID, "cat", "/out")
- c.Assert(result.Stdout(), checker.Contains, "foo=abc")
-
+ assert.Assert(c, strings.Contains(result.Stdout(), "foo=abc"))
result = cli.DockerCmd(c, "run", "--rm", imgName, "cat", "/out")
- c.Assert(result.Stdout(), checker.Not(checker.Contains), "foo")
- c.Assert(result.Stdout(), checker.Contains, "bar=def")
+ assert.Assert(c, !strings.Contains(result.Stdout(), "foo"))
+ assert.Assert(c, strings.Contains(result.Stdout(), "bar=def"))
}
-func (s *DockerSuite) TestBuildMultiStageGlobalArg(c *check.C) {
+func (s *DockerSuite) TestBuildMultiStageGlobalArg(c *testing.T) {
imgName := "multifrombldargtest"
dockerfile := `ARG tag=nosuchtag
FROM busybox:${tag}
@@ -4678,13 +4677,12 @@
parentID := strings.TrimSpace(result.Stdout())
result = cli.DockerCmd(c, "run", "--rm", parentID, "cat", "/out")
- c.Assert(result.Stdout(), checker.Not(checker.Contains), "tag")
-
+ assert.Assert(c, !strings.Contains(result.Stdout(), "tag"))
result = cli.DockerCmd(c, "run", "--rm", imgName, "cat", "/out")
- c.Assert(result.Stdout(), checker.Contains, "tag=latest")
+ assert.Assert(c, strings.Contains(result.Stdout(), "tag=latest"))
}
-func (s *DockerSuite) TestBuildMultiStageUnusedArg(c *check.C) {
+func (s *DockerSuite) TestBuildMultiStageUnusedArg(c *testing.T) {
imgName := "multifromunusedarg"
dockerfile := `FROM busybox
ARG foo
@@ -4696,15 +4694,14 @@
build.WithDockerfile(dockerfile),
cli.WithFlags("--build-arg", fmt.Sprintf("baz=abc")))
result.Assert(c, icmd.Success)
- c.Assert(result.Combined(), checker.Contains, "[Warning]")
- c.Assert(result.Combined(), checker.Contains, "[baz] were not consumed")
-
+ assert.Assert(c, strings.Contains(result.Combined(), "[Warning]"))
+ assert.Assert(c, strings.Contains(result.Combined(), "[baz] were not consumed"))
result = cli.DockerCmd(c, "run", "--rm", imgName, "cat", "/out")
- c.Assert(result.Stdout(), checker.Not(checker.Contains), "bar")
- c.Assert(result.Stdout(), checker.Not(checker.Contains), "baz")
+ assert.Assert(c, !strings.Contains(result.Stdout(), "bar"))
+ assert.Assert(c, !strings.Contains(result.Stdout(), "baz"))
}
-func (s *DockerSuite) TestBuildNoNamedVolume(c *check.C) {
+func (s *DockerSuite) TestBuildNoNamedVolume(c *testing.T) {
volName := "testname:/foo"
if testEnv.OSType == "windows" {
@@ -4721,7 +4718,7 @@
})
}
-func (s *DockerSuite) TestBuildTagEvent(c *check.C) {
+func (s *DockerSuite) TestBuildTagEvent(c *testing.T) {
since := daemonUnixTime(c)
dockerFile := `FROM busybox
@@ -4741,11 +4738,11 @@
}
}
- c.Assert(foundTag, checker.True, check.Commentf("No tag event found:\n%s", out))
+ assert.Assert(c, foundTag, "No tag event found:\n%s", out)
}
// #15780
-func (s *DockerSuite) TestBuildMultipleTags(c *check.C) {
+func (s *DockerSuite) TestBuildMultipleTags(c *testing.T) {
dockerfile := `
FROM busybox
MAINTAINER test-15780
@@ -4754,11 +4751,11 @@
id1 := getIDByName(c, "tag1")
id2 := getIDByName(c, "tag2:v2")
- c.Assert(id1, check.Equals, id2)
+ assert.Equal(c, id1, id2)
}
// #17290
-func (s *DockerSuite) TestBuildCacheBrokenSymlink(c *check.C) {
+func (s *DockerSuite) TestBuildCacheBrokenSymlink(c *testing.T) {
name := "testbuildbrokensymlink"
ctx := fakecontext.New(c, "",
fakecontext.WithDockerfile(`
@@ -4785,7 +4782,7 @@
}
}
-func (s *DockerSuite) TestBuildFollowSymlinkToFile(c *check.C) {
+func (s *DockerSuite) TestBuildFollowSymlinkToFile(c *testing.T) {
name := "testbuildbrokensymlink"
ctx := fakecontext.New(c, "",
fakecontext.WithDockerfile(`
@@ -4802,20 +4799,20 @@
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
out := cli.DockerCmd(c, "run", "--rm", name, "cat", "target").Combined()
- c.Assert(out, checker.Matches, "bar")
+ assert.Assert(c, cmp.Regexp("^bar$", out))
// change target file should invalidate cache
err = ioutil.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("baz"), 0644)
assert.NilError(c, err)
result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
- c.Assert(result.Combined(), checker.Not(checker.Contains), "Using cache")
-
+ assert.Assert(c, !strings.Contains(result.Combined(), "Using cache"))
out = cli.DockerCmd(c, "run", "--rm", name, "cat", "target").Combined()
- c.Assert(out, checker.Matches, "baz")
+ assert.Assert(c, cmp.Regexp("^baz$", out))
+
}
-func (s *DockerSuite) TestBuildFollowSymlinkToDir(c *check.C) {
+func (s *DockerSuite) TestBuildFollowSymlinkToDir(c *testing.T) {
name := "testbuildbrokensymlink"
ctx := fakecontext.New(c, "",
fakecontext.WithDockerfile(`
@@ -4833,23 +4830,22 @@
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
out := cli.DockerCmd(c, "run", "--rm", name, "cat", "abc", "def").Combined()
- c.Assert(out, checker.Matches, "barbaz")
+ assert.Assert(c, cmp.Regexp("^barbaz$", out))
// change target file should invalidate cache
err = ioutil.WriteFile(filepath.Join(ctx.Dir, "foo/def"), []byte("bax"), 0644)
assert.NilError(c, err)
result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
- c.Assert(result.Combined(), checker.Not(checker.Contains), "Using cache")
-
+ assert.Assert(c, !strings.Contains(result.Combined(), "Using cache"))
out = cli.DockerCmd(c, "run", "--rm", name, "cat", "abc", "def").Combined()
- c.Assert(out, checker.Matches, "barbax")
+ assert.Assert(c, cmp.Regexp("^barbax$", out))
}
// TestBuildSymlinkBasename tests that target file gets basename from symlink,
// not from the target file.
-func (s *DockerSuite) TestBuildSymlinkBasename(c *check.C) {
+func (s *DockerSuite) TestBuildSymlinkBasename(c *testing.T) {
name := "testbuildbrokensymlink"
ctx := fakecontext.New(c, "",
fakecontext.WithDockerfile(`
@@ -4866,11 +4862,12 @@
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
out := cli.DockerCmd(c, "run", "--rm", name, "cat", "asymlink").Combined()
- c.Assert(out, checker.Matches, "bar")
+ assert.Assert(c, cmp.Regexp("^bar$", out))
+
}
// #17827
-func (s *DockerSuite) TestBuildCacheRootSource(c *check.C) {
+func (s *DockerSuite) TestBuildCacheRootSource(c *testing.T) {
name := "testbuildrootsource"
ctx := fakecontext.New(c, "",
fakecontext.WithDockerfile(`
@@ -4890,12 +4887,12 @@
result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
- c.Assert(result.Combined(), checker.Not(checker.Contains), "Using cache")
+ assert.Assert(c, !strings.Contains(result.Combined(), "Using cache"))
}
// #19375
// FIXME(vdemeester) should migrate to docker/cli tests
-func (s *DockerSuite) TestBuildFailsGitNotCallable(c *check.C) {
+func (s *DockerSuite) TestBuildFailsGitNotCallable(c *testing.T) {
buildImage("gitnotcallable", cli.WithEnvironmentVariables("PATH="),
build.WithContextPath("github.com/docker/v1.10-migrator.git")).Assert(c, icmd.Expected{
ExitCode: 1,
@@ -4910,7 +4907,7 @@
}
// TestBuildWorkdirWindowsPath tests that a Windows style path works as a workdir
-func (s *DockerSuite) TestBuildWorkdirWindowsPath(c *check.C) {
+func (s *DockerSuite) TestBuildWorkdirWindowsPath(c *testing.T) {
testRequires(c, DaemonIsWindows)
name := "testbuildworkdirwindowspath"
buildImageSuccessfully(c, name, build.WithDockerfile(`
@@ -4921,7 +4918,7 @@
`))
}
-func (s *DockerSuite) TestBuildLabel(c *check.C) {
+func (s *DockerSuite) TestBuildLabel(c *testing.T) {
name := "testbuildlabel"
testLabel := "foo"
@@ -4938,7 +4935,7 @@
}
}
-func (s *DockerSuite) TestBuildLabelOneNode(c *check.C) {
+func (s *DockerSuite) TestBuildLabelOneNode(c *testing.T) {
name := "testbuildlabel"
buildImageSuccessfully(c, name, cli.WithFlags("--label", "foo=bar"),
build.WithDockerfile("FROM busybox"))
@@ -4949,10 +4946,10 @@
if !ok {
c.Fatal("label `foo` not found in image")
}
- c.Assert(v, checker.Equals, "bar")
+ assert.Equal(c, v, "bar")
}
-func (s *DockerSuite) TestBuildLabelCacheCommit(c *check.C) {
+func (s *DockerSuite) TestBuildLabelCacheCommit(c *testing.T) {
name := "testbuildlabelcachecommit"
testLabel := "foo"
@@ -4973,7 +4970,7 @@
}
}
-func (s *DockerSuite) TestBuildLabelMultiple(c *check.C) {
+func (s *DockerSuite) TestBuildLabelMultiple(c *testing.T) {
name := "testbuildlabelmultiple"
testLabels := map[string]string{
"foo": "bar",
@@ -4999,7 +4996,7 @@
}
}
-func (s *DockerRegistryAuthHtpasswdSuite) TestBuildFromAuthenticatedRegistry(c *check.C) {
+func (s *DockerRegistryAuthHtpasswdSuite) TestBuildFromAuthenticatedRegistry(c *testing.T) {
dockerCmd(c, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
baseImage := privateRegistryURL + "/baseimage"
@@ -5017,7 +5014,7 @@
`, baseImage)))
}
-func (s *DockerRegistryAuthHtpasswdSuite) TestBuildWithExternalAuth(c *check.C) {
+func (s *DockerRegistryAuthHtpasswdSuite) TestBuildWithExternalAuth(c *testing.T) {
osPath := os.Getenv("PATH")
defer os.Setenv("PATH", osPath)
@@ -5044,8 +5041,7 @@
b, err := ioutil.ReadFile(configPath)
assert.NilError(c, err)
- c.Assert(string(b), checker.Not(checker.Contains), "\"auth\":")
-
+ assert.Assert(c, !strings.Contains(string(b), "\"auth\":"))
dockerCmd(c, "--config", tmp, "tag", "busybox", repoName)
dockerCmd(c, "--config", tmp, "push", repoName)
@@ -5059,7 +5055,7 @@
}
// Test cases in #22036
-func (s *DockerSuite) TestBuildLabelsOverride(c *check.C) {
+func (s *DockerSuite) TestBuildLabelsOverride(c *testing.T) {
// Command line option labels will always override
name := "scratchy"
expected := `{"bar":"from-flag","foo":"from-flag"}`
@@ -5138,7 +5134,7 @@
}
// Test case for #22855
-func (s *DockerSuite) TestBuildDeleteCommittedFile(c *check.C) {
+func (s *DockerSuite) TestBuildDeleteCommittedFile(c *testing.T) {
name := "test-delete-committed-file"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox
RUN echo test > file
@@ -5148,7 +5144,7 @@
}
// #20083
-func (s *DockerSuite) TestBuildDockerignoreComment(c *check.C) {
+func (s *DockerSuite) TestBuildDockerignoreComment(c *testing.T) {
// TODO Windows: Figure out why this test is flakey on TP5. If you add
// something like RUN sleep 5, or even RUN ls /tmp after the ADD line,
// it is more reliable, but that's not a good fix.
@@ -5182,7 +5178,7 @@
}
// Test case for #23221
-func (s *DockerSuite) TestBuildWithUTF8BOM(c *check.C) {
+func (s *DockerSuite) TestBuildWithUTF8BOM(c *testing.T) {
name := "test-with-utf8-bom"
dockerfile := []byte(`FROM busybox`)
bomDockerfile := append([]byte{0xEF, 0xBB, 0xBF}, dockerfile...)
@@ -5192,7 +5188,7 @@
}
// Test case for UTF-8 BOM in .dockerignore, related to #23221
-func (s *DockerSuite) TestBuildWithUTF8BOMDockerignore(c *check.C) {
+func (s *DockerSuite) TestBuildWithUTF8BOMDockerignore(c *testing.T) {
name := "test-with-utf8-bom-dockerignore"
dockerfile := `
FROM busybox
@@ -5209,7 +5205,7 @@
}
// #22489 Shell test to confirm config gets updated correctly
-func (s *DockerSuite) TestBuildShellUpdatesConfig(c *check.C) {
+func (s *DockerSuite) TestBuildShellUpdatesConfig(c *testing.T) {
name := "testbuildshellupdatesconfig"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+`
@@ -5226,7 +5222,7 @@
}
// #22489 Changing the shell multiple times and CMD after.
-func (s *DockerSuite) TestBuildShellMultiple(c *check.C) {
+func (s *DockerSuite) TestBuildShellMultiple(c *testing.T) {
name := "testbuildshellmultiple"
result := buildImage(name, build.WithDockerfile(`FROM busybox
@@ -5262,7 +5258,7 @@
}
// #22489. Changed SHELL with ENTRYPOINT
-func (s *DockerSuite) TestBuildShellEntrypoint(c *check.C) {
+func (s *DockerSuite) TestBuildShellEntrypoint(c *testing.T) {
name := "testbuildshellentrypoint"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox
@@ -5277,7 +5273,7 @@
}
// #22489 Shell test to confirm shell is inherited in a subsequent build
-func (s *DockerSuite) TestBuildShellInherited(c *check.C) {
+func (s *DockerSuite) TestBuildShellInherited(c *testing.T) {
name1 := "testbuildshellinherited1"
buildImageSuccessfully(c, name1, build.WithDockerfile(`FROM busybox
SHELL ["ls"]`))
@@ -5290,7 +5286,7 @@
}
// #22489 Shell test to confirm non-JSON doesn't work
-func (s *DockerSuite) TestBuildShellNotJSON(c *check.C) {
+func (s *DockerSuite) TestBuildShellNotJSON(c *testing.T) {
name := "testbuildshellnotjson"
buildImage(name, build.WithDockerfile(`FROM `+minimalBaseImage()+`
@@ -5303,7 +5299,7 @@
// #22489 Windows shell test to confirm native is powershell if executing a PS command
// This would error if the default shell were still cmd.
-func (s *DockerSuite) TestBuildShellWindowsPowershell(c *check.C) {
+func (s *DockerSuite) TestBuildShellWindowsPowershell(c *testing.T) {
testRequires(c, DaemonIsWindows)
name := "testbuildshellpowershell"
buildImage(name, build.WithDockerfile(`FROM `+minimalBaseImage()+`
@@ -5315,7 +5311,7 @@
// Verify that escape is being correctly applied to words when escape directive is not \.
// Tests WORKDIR, ADD
-func (s *DockerSuite) TestBuildEscapeNotBackslashWordTest(c *check.C) {
+func (s *DockerSuite) TestBuildEscapeNotBackslashWordTest(c *testing.T) {
testRequires(c, DaemonIsWindows)
name := "testbuildescapenotbackslashwordtesta"
buildImage(name, build.WithDockerfile(`# escape= `+"`"+`
@@ -5338,7 +5334,7 @@
// #22868. Make sure shell-form CMD is not marked as escaped in the config of the image,
// but an exec-form CMD is marked.
-func (s *DockerSuite) TestBuildCmdShellArgsEscaped(c *check.C) {
+func (s *DockerSuite) TestBuildCmdShellArgsEscaped(c *testing.T) {
testRequires(c, DaemonIsWindows)
name1 := "testbuildcmdshellescapedshellform"
buildImageSuccessfully(c, name1, build.WithDockerfile(`
@@ -5378,36 +5374,35 @@
}
// Test case for #24912.
-func (s *DockerSuite) TestBuildStepsWithProgress(c *check.C) {
+func (s *DockerSuite) TestBuildStepsWithProgress(c *testing.T) {
name := "testbuildstepswithprogress"
totalRun := 5
result := buildImage(name, build.WithDockerfile("FROM busybox\n"+strings.Repeat("RUN echo foo\n", totalRun)))
result.Assert(c, icmd.Success)
- c.Assert(result.Combined(), checker.Contains, fmt.Sprintf("Step 1/%d : FROM busybox", 1+totalRun))
+ assert.Assert(c, strings.Contains(result.Combined(), fmt.Sprintf("Step 1/%d : FROM busybox", 1+totalRun)))
for i := 2; i <= 1+totalRun; i++ {
- c.Assert(result.Combined(), checker.Contains, fmt.Sprintf("Step %d/%d : RUN echo foo", i, 1+totalRun))
+ assert.Assert(c, strings.Contains(result.Combined(), fmt.Sprintf("Step %d/%d : RUN echo foo", i, 1+totalRun)))
}
}
-func (s *DockerSuite) TestBuildWithFailure(c *check.C) {
+func (s *DockerSuite) TestBuildWithFailure(c *testing.T) {
name := "testbuildwithfailure"
// First test case can only detect `nobody` in runtime so all steps will show up
dockerfile := "FROM busybox\nRUN nobody"
result := buildImage(name, build.WithDockerfile(dockerfile))
- c.Assert(result.Error, checker.NotNil)
- c.Assert(result.Stdout(), checker.Contains, "Step 1/2 : FROM busybox")
- c.Assert(result.Stdout(), checker.Contains, "Step 2/2 : RUN nobody")
-
+ assert.Assert(c, result.Error != nil)
+ assert.Assert(c, strings.Contains(result.Stdout(), "Step 1/2 : FROM busybox"))
+ assert.Assert(c, strings.Contains(result.Stdout(), "Step 2/2 : RUN nobody"))
// Second test case `FFOM` should have been detected before build runs so no steps
dockerfile = "FFOM nobody\nRUN nobody"
result = buildImage(name, build.WithDockerfile(dockerfile))
- c.Assert(result.Error, checker.NotNil)
- c.Assert(result.Stdout(), checker.Not(checker.Contains), "Step 1/2 : FROM busybox")
- c.Assert(result.Stdout(), checker.Not(checker.Contains), "Step 2/2 : RUN nobody")
+ assert.Assert(c, result.Error != nil)
+ assert.Assert(c, !strings.Contains(result.Stdout(), "Step 1/2 : FROM busybox"))
+ assert.Assert(c, !strings.Contains(result.Stdout(), "Step 2/2 : RUN nobody"))
}
-func (s *DockerSuite) TestBuildCacheFromEqualDiffIDsLength(c *check.C) {
+func (s *DockerSuite) TestBuildCacheFromEqualDiffIDsLength(c *testing.T) {
dockerfile := `
FROM busybox
RUN echo "test"
@@ -5425,11 +5420,11 @@
// rebuild with cache-from
result := cli.BuildCmd(c, "build2", cli.WithFlags("--cache-from=build1"), build.WithExternalBuildContext(ctx))
id2 := getIDByName(c, "build2")
- c.Assert(id1, checker.Equals, id2)
- c.Assert(strings.Count(result.Combined(), "Using cache"), checker.Equals, 2)
+ assert.Equal(c, id1, id2)
+ assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 2)
}
-func (s *DockerSuite) TestBuildCacheFrom(c *check.C) {
+func (s *DockerSuite) TestBuildCacheFrom(c *testing.T) {
testRequires(c, DaemonIsLinux) // All tests that do save are skipped in windows
dockerfile := `
FROM busybox
@@ -5450,15 +5445,15 @@
// rebuild with cache-from
result := cli.BuildCmd(c, "build2", cli.WithFlags("--cache-from=build1"), build.WithExternalBuildContext(ctx))
id2 := getIDByName(c, "build2")
- c.Assert(id1, checker.Equals, id2)
- c.Assert(strings.Count(result.Combined(), "Using cache"), checker.Equals, 3)
+ assert.Equal(c, id1, id2)
+ assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 3)
cli.DockerCmd(c, "rmi", "build2")
// no cache match with unknown source
result = cli.BuildCmd(c, "build2", cli.WithFlags("--cache-from=nosuchtag"), build.WithExternalBuildContext(ctx))
id2 = getIDByName(c, "build2")
- c.Assert(id1, checker.Not(checker.Equals), id2)
- c.Assert(strings.Count(result.Combined(), "Using cache"), checker.Equals, 0)
+ assert.Assert(c, id1 != id2)
+ assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 0)
cli.DockerCmd(c, "rmi", "build2")
// clear parent images
@@ -5472,23 +5467,23 @@
cli.DockerCmd(c, "rmi", "build1")
cli.DockerCmd(c, "load", "-i", tempFile)
parentID := cli.DockerCmd(c, "inspect", "-f", "{{.Parent}}", "build1").Combined()
- c.Assert(strings.TrimSpace(parentID), checker.Equals, "")
+ assert.Equal(c, strings.TrimSpace(parentID), "")
// cache still applies without parents
result = cli.BuildCmd(c, "build2", cli.WithFlags("--cache-from=build1"), build.WithExternalBuildContext(ctx))
id2 = getIDByName(c, "build2")
- c.Assert(id1, checker.Equals, id2)
- c.Assert(strings.Count(result.Combined(), "Using cache"), checker.Equals, 3)
+ assert.Equal(c, id1, id2)
+ assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 3)
history1 := cli.DockerCmd(c, "history", "-q", "build2").Combined()
// Retry, no new intermediate images
result = cli.BuildCmd(c, "build3", cli.WithFlags("--cache-from=build1"), build.WithExternalBuildContext(ctx))
id3 := getIDByName(c, "build3")
- c.Assert(id1, checker.Equals, id3)
- c.Assert(strings.Count(result.Combined(), "Using cache"), checker.Equals, 3)
+ assert.Equal(c, id1, id3)
+ assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 3)
history2 := cli.DockerCmd(c, "history", "-q", "build3").Combined()
- c.Assert(history1, checker.Equals, history2)
+ assert.Equal(c, history1, history2)
cli.DockerCmd(c, "rmi", "build2")
cli.DockerCmd(c, "rmi", "build3")
cli.DockerCmd(c, "rmi", "build1")
@@ -5505,25 +5500,25 @@
result = cli.BuildCmd(c, "build2", cli.WithFlags("--cache-from=build1"), build.WithExternalBuildContext(ctx))
id2 = getIDByName(c, "build2")
- c.Assert(id1, checker.Not(checker.Equals), id2)
- c.Assert(strings.Count(result.Combined(), "Using cache"), checker.Equals, 2)
+ assert.Assert(c, id1 != id2)
+ assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 2)
layers1Str := cli.DockerCmd(c, "inspect", "-f", "{{json .RootFS.Layers}}", "build1").Combined()
layers2Str := cli.DockerCmd(c, "inspect", "-f", "{{json .RootFS.Layers}}", "build2").Combined()
var layers1 []string
var layers2 []string
- c.Assert(json.Unmarshal([]byte(layers1Str), &layers1), checker.IsNil)
- c.Assert(json.Unmarshal([]byte(layers2Str), &layers2), checker.IsNil)
+ assert.Assert(c, json.Unmarshal([]byte(layers1Str), &layers1) == nil)
+ assert.Assert(c, json.Unmarshal([]byte(layers2Str), &layers2) == nil)
- c.Assert(len(layers1), checker.Equals, len(layers2))
+ assert.Equal(c, len(layers1), len(layers2))
for i := 0; i < len(layers1)-1; i++ {
- c.Assert(layers1[i], checker.Equals, layers2[i])
+ assert.Equal(c, layers1[i], layers2[i])
}
- c.Assert(layers1[len(layers1)-1], checker.Not(checker.Equals), layers2[len(layers1)-1])
+ assert.Assert(c, layers1[len(layers1)-1] != layers2[len(layers1)-1])
}
-func (s *DockerSuite) TestBuildMultiStageCache(c *check.C) {
+func (s *DockerSuite) TestBuildMultiStageCache(c *testing.T) {
testRequires(c, DaemonIsLinux) // All tests that do save are skipped in windows
dockerfile := `
FROM busybox
@@ -5540,14 +5535,14 @@
result := cli.BuildCmd(c, "build1", build.WithExternalBuildContext(ctx))
// second part of dockerfile was a repeat of first so should be cached
- c.Assert(strings.Count(result.Combined(), "Using cache"), checker.Equals, 1)
+ assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 1)
result = cli.BuildCmd(c, "build2", cli.WithFlags("--cache-from=build1"), build.WithExternalBuildContext(ctx))
// now both parts of dockerfile should be cached
- c.Assert(strings.Count(result.Combined(), "Using cache"), checker.Equals, 2)
+ assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 2)
}
-func (s *DockerSuite) TestBuildNetNone(c *check.C) {
+func (s *DockerSuite) TestBuildNetNone(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "testbuildnetnone"
buildImage(name, cli.WithFlags("--network=none"), build.WithDockerfile(`
@@ -5559,7 +5554,7 @@
})
}
-func (s *DockerSuite) TestBuildNetContainer(c *check.C) {
+func (s *DockerSuite) TestBuildNetContainer(c *testing.T) {
testRequires(c, DaemonIsLinux)
id, _ := dockerCmd(c, "run", "--hostname", "foobar", "-d", "busybox", "nc", "-ll", "-p", "1234", "-e", "hostname")
@@ -5572,10 +5567,10 @@
`))
host, _ := dockerCmd(c, "run", "testbuildnetcontainer", "cat", "/otherhost")
- c.Assert(strings.TrimSpace(host), check.Equals, "foobar")
+ assert.Equal(c, strings.TrimSpace(host), "foobar")
}
-func (s *DockerSuite) TestBuildWithExtraHost(c *check.C) {
+func (s *DockerSuite) TestBuildWithExtraHost(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "testbuildwithextrahost"
@@ -5591,7 +5586,7 @@
`))
}
-func (s *DockerSuite) TestBuildWithExtraHostInvalidFormat(c *check.C) {
+func (s *DockerSuite) TestBuildWithExtraHostInvalidFormat(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerfile := `
FROM busybox
@@ -5618,7 +5613,7 @@
}
-func (s *DockerSuite) TestBuildContChar(c *check.C) {
+func (s *DockerSuite) TestBuildContChar(c *testing.T) {
name := "testbuildcontchar"
buildImage(name, build.WithDockerfile(`FROM busybox\`)).Assert(c, icmd.Expected{
@@ -5628,23 +5623,21 @@
result := buildImage(name, build.WithDockerfile(`FROM busybox
RUN echo hi \`))
result.Assert(c, icmd.Success)
- c.Assert(result.Combined(), checker.Contains, "Step 1/2 : FROM busybox")
- c.Assert(result.Combined(), checker.Contains, "Step 2/2 : RUN echo hi\n")
-
+ assert.Assert(c, strings.Contains(result.Combined(), "Step 1/2 : FROM busybox"))
+ assert.Assert(c, strings.Contains(result.Combined(), "Step 2/2 : RUN echo hi\n"))
result = buildImage(name, build.WithDockerfile(`FROM busybox
RUN echo hi \\`))
result.Assert(c, icmd.Success)
- c.Assert(result.Combined(), checker.Contains, "Step 1/2 : FROM busybox")
- c.Assert(result.Combined(), checker.Contains, "Step 2/2 : RUN echo hi \\\n")
-
+ assert.Assert(c, strings.Contains(result.Combined(), "Step 1/2 : FROM busybox"))
+ assert.Assert(c, strings.Contains(result.Combined(), "Step 2/2 : RUN echo hi \\\n"))
result = buildImage(name, build.WithDockerfile(`FROM busybox
RUN echo hi \\\`))
result.Assert(c, icmd.Success)
- c.Assert(result.Combined(), checker.Contains, "Step 1/2 : FROM busybox")
- c.Assert(result.Combined(), checker.Contains, "Step 2/2 : RUN echo hi \\\\\n")
+ assert.Assert(c, strings.Contains(result.Combined(), "Step 1/2 : FROM busybox"))
+ assert.Assert(c, strings.Contains(result.Combined(), "Step 2/2 : RUN echo hi \\\\\n"))
}
-func (s *DockerSuite) TestBuildMultiStageCopyFromSyntax(c *check.C) {
+func (s *DockerSuite) TestBuildMultiStageCopyFromSyntax(c *testing.T) {
dockerfile := `
FROM busybox AS first
COPY foo bar
@@ -5681,28 +5674,28 @@
result := cli.BuildCmd(c, "build2", build.WithExternalBuildContext(ctx))
// all commands should be cached
- c.Assert(strings.Count(result.Combined(), "Using cache"), checker.Equals, 7)
- c.Assert(getIDByName(c, "build1"), checker.Equals, getIDByName(c, "build2"))
+ assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 7)
+ assert.Equal(c, getIDByName(c, "build1"), getIDByName(c, "build2"))
err := ioutil.WriteFile(filepath.Join(ctx.Dir, "Dockerfile"), []byte(fmt.Sprintf(dockerfile, "COPY baz/aa foo")), 0644)
assert.NilError(c, err)
// changing file in parent block should not affect last block
result = cli.BuildCmd(c, "build3", build.WithExternalBuildContext(ctx))
- c.Assert(strings.Count(result.Combined(), "Using cache"), checker.Equals, 5)
+ assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 5)
err = ioutil.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("pqr"), 0644)
assert.NilError(c, err)
// changing file in parent block should affect both first and last block
result = cli.BuildCmd(c, "build4", build.WithExternalBuildContext(ctx))
- c.Assert(strings.Count(result.Combined(), "Using cache"), checker.Equals, 5)
+ assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 5)
cli.DockerCmd(c, "run", "build4", "cat", "bay").Assert(c, icmd.Expected{Out: "pqr"})
cli.DockerCmd(c, "run", "build4", "cat", "baz").Assert(c, icmd.Expected{Out: "pqr"})
}
-func (s *DockerSuite) TestBuildMultiStageCopyFromErrors(c *check.C) {
+func (s *DockerSuite) TestBuildMultiStageCopyFromErrors(c *testing.T) {
testCases := []struct {
dockerfile string
expectedError string
@@ -5749,7 +5742,7 @@
}
}
-func (s *DockerSuite) TestBuildMultiStageMultipleBuilds(c *check.C) {
+func (s *DockerSuite) TestBuildMultiStageMultipleBuilds(c *testing.T) {
dockerfile := `
FROM busybox
COPY foo bar`
@@ -5777,12 +5770,12 @@
cli.BuildCmd(c, "build2", build.WithExternalBuildContext(ctx))
out := cli.DockerCmd(c, "run", "build2", "cat", "bar").Combined()
- c.Assert(strings.TrimSpace(out), check.Equals, "abc")
+ assert.Equal(c, strings.TrimSpace(out), "abc")
out = cli.DockerCmd(c, "run", "build2", "cat", "foo").Combined()
- c.Assert(strings.TrimSpace(out), check.Equals, "def")
+ assert.Equal(c, strings.TrimSpace(out), "def")
}
-func (s *DockerSuite) TestBuildMultiStageImplicitFrom(c *check.C) {
+func (s *DockerSuite) TestBuildMultiStageImplicitFrom(c *testing.T) {
dockerfile := `
FROM busybox
COPY --from=busybox /etc/passwd /mypasswd
@@ -5809,7 +5802,7 @@
}
}
-func (s *DockerRegistrySuite) TestBuildMultiStageImplicitPull(c *check.C) {
+func (s *DockerRegistrySuite) TestBuildMultiStageImplicitPull(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/testf", privateRegistryURL)
dockerfile := `
@@ -5839,7 +5832,7 @@
cli.Docker(cli.Args("run", "build1", "cat", "baz")).Assert(c, icmd.Expected{Out: "abc"})
}
-func (s *DockerSuite) TestBuildMultiStageNameVariants(c *check.C) {
+func (s *DockerSuite) TestBuildMultiStageNameVariants(c *testing.T) {
dockerfile := `
FROM busybox as foo
COPY foo /
@@ -5864,7 +5857,7 @@
cli.Docker(cli.Args("run", "build1", "cat", "f2")).Assert(c, icmd.Expected{Out: "bar2"})
}
-func (s *DockerSuite) TestBuildMultiStageMultipleBuildsWindows(c *check.C) {
+func (s *DockerSuite) TestBuildMultiStageMultipleBuildsWindows(c *testing.T) {
testRequires(c, DaemonIsWindows)
dockerfile := `
FROM ` + testEnv.PlatformDefaults.BaseImage + `
@@ -5893,12 +5886,12 @@
cli.BuildCmd(c, "build2", build.WithExternalBuildContext(ctx))
out := cli.DockerCmd(c, "run", "build2", "cmd.exe", "/s", "/c", "type", "c:\\bar").Combined()
- c.Assert(strings.TrimSpace(out), check.Equals, "abc")
+ assert.Equal(c, strings.TrimSpace(out), "abc")
out = cli.DockerCmd(c, "run", "build2", "cmd.exe", "/s", "/c", "type", "c:\\foo").Combined()
- c.Assert(strings.TrimSpace(out), check.Equals, "def")
+ assert.Equal(c, strings.TrimSpace(out), "def")
}
-func (s *DockerSuite) TestBuildCopyFromForbidWindowsSystemPaths(c *check.C) {
+func (s *DockerSuite) TestBuildCopyFromForbidWindowsSystemPaths(c *testing.T) {
testRequires(c, DaemonIsWindows)
dockerfile := `
FROM ` + testEnv.PlatformDefaults.BaseImage + `
@@ -5915,7 +5908,7 @@
buildImage("testforbidsystempaths4", build.WithDockerfile(fmt.Sprintf(dockerfile, "c:\\\\wInDows"))).Assert(c, exp)
}
-func (s *DockerSuite) TestBuildCopyFromForbidWindowsRelativePaths(c *check.C) {
+func (s *DockerSuite) TestBuildCopyFromForbidWindowsRelativePaths(c *testing.T) {
testRequires(c, DaemonIsWindows)
dockerfile := `
FROM ` + testEnv.PlatformDefaults.BaseImage + `
@@ -5933,7 +5926,7 @@
buildImage("testforbidsystempaths5", build.WithDockerfile(fmt.Sprintf(dockerfile, "\\\\windows"))).Assert(c, exp)
}
-func (s *DockerSuite) TestBuildCopyFromWindowsIsCaseInsensitive(c *check.C) {
+func (s *DockerSuite) TestBuildCopyFromWindowsIsCaseInsensitive(c *testing.T) {
testRequires(c, DaemonIsWindows)
dockerfile := `
FROM ` + testEnv.PlatformDefaults.BaseImage + `
@@ -5952,7 +5945,7 @@
}
// #33176
-func (s *DockerSuite) TestBuildMultiStageResetScratch(c *check.C) {
+func (s *DockerSuite) TestBuildMultiStageResetScratch(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerfile := `
@@ -5969,10 +5962,10 @@
cli.BuildCmd(c, "build1", build.WithExternalBuildContext(ctx))
res := cli.InspectCmd(c, "build1", cli.Format(".Config.WorkingDir")).Combined()
- c.Assert(strings.TrimSpace(res), checker.Equals, "")
+ assert.Equal(c, strings.TrimSpace(res), "")
}
-func (s *DockerSuite) TestBuildIntermediateTarget(c *check.C) {
+func (s *DockerSuite) TestBuildIntermediateTarget(c *testing.T) {
//todo: need to be removed after 18.06 release
if strings.Contains(testEnv.DaemonInfo.ServerVersion, "18.05.0") {
c.Skip(fmt.Sprintf("Bug fixed in 18.06 or higher.Skipping it for %s", testEnv.DaemonInfo.ServerVersion))
@@ -5990,14 +5983,14 @@
cli.WithFlags("--target", "build-env"))
res := cli.InspectCmd(c, "build1", cli.Format("json .Config.Cmd")).Combined()
- c.Assert(strings.TrimSpace(res), checker.Equals, `["/dev"]`)
+ assert.Equal(c, strings.TrimSpace(res), `["/dev"]`)
// Stage name is case-insensitive by design
cli.BuildCmd(c, "build1", build.WithExternalBuildContext(ctx),
cli.WithFlags("--target", "BUIld-EnV"))
res = cli.InspectCmd(c, "build1", cli.Format("json .Config.Cmd")).Combined()
- c.Assert(strings.TrimSpace(res), checker.Equals, `["/dev"]`)
+ assert.Equal(c, strings.TrimSpace(res), `["/dev"]`)
result := cli.Docker(cli.Build("build1"), build.WithExternalBuildContext(ctx),
cli.WithFlags("--target", "nosuchtarget"))
@@ -6010,7 +6003,7 @@
// TestBuildOpaqueDirectory tests that a build succeeds which
// creates opaque directories.
// See https://github.com/docker/docker/issues/25244
-func (s *DockerSuite) TestBuildOpaqueDirectory(c *check.C) {
+func (s *DockerSuite) TestBuildOpaqueDirectory(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerFile := `
FROM busybox
@@ -6025,7 +6018,7 @@
}
// Windows test for USER in dockerfile
-func (s *DockerSuite) TestBuildWindowsUser(c *check.C) {
+func (s *DockerSuite) TestBuildWindowsUser(c *testing.T) {
testRequires(c, DaemonIsWindows)
name := "testbuildwindowsuser"
buildImage(name, build.WithDockerfile(`FROM `+testEnv.PlatformDefaults.BaseImage+`
@@ -6042,7 +6035,7 @@
// as opposed to the file being copied as a file with the name of the
// directory. Fix for 27545 (found on Windows, but regression good for Linux too).
// Note 27545 was reverted in 28505, but a new fix was added subsequently in 28514.
-func (s *DockerSuite) TestBuildCopyFileDotWithWorkdir(c *check.C) {
+func (s *DockerSuite) TestBuildCopyFileDotWithWorkdir(c *testing.T) {
name := "testbuildcopyfiledotwithworkdir"
buildImageSuccessfully(c, name, build.WithBuildContext(c,
build.WithFile("Dockerfile", `FROM busybox
@@ -6055,7 +6048,7 @@
}
// Case-insensitive environment variables on Windows
-func (s *DockerSuite) TestBuildWindowsEnvCaseInsensitive(c *check.C) {
+func (s *DockerSuite) TestBuildWindowsEnvCaseInsensitive(c *testing.T) {
testRequires(c, DaemonIsWindows)
name := "testbuildwindowsenvcaseinsensitive"
buildImageSuccessfully(c, name, build.WithDockerfile(`
@@ -6069,7 +6062,7 @@
}
// Test case for 29667
-func (s *DockerSuite) TestBuildWorkdirImageCmd(c *check.C) {
+func (s *DockerSuite) TestBuildWorkdirImageCmd(c *testing.T) {
image := "testworkdirimagecmd"
buildImageSuccessfully(c, image, build.WithDockerfile(`
FROM busybox
@@ -6090,7 +6083,7 @@
}
// Test case for 28902/28909
-func (s *DockerSuite) TestBuildWorkdirCmd(c *check.C) {
+func (s *DockerSuite) TestBuildWorkdirCmd(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "testbuildworkdircmd"
dockerFile := `
@@ -6100,11 +6093,11 @@
buildImageSuccessfully(c, name, build.WithDockerfile(dockerFile))
result := buildImage(name, build.WithDockerfile(dockerFile))
result.Assert(c, icmd.Success)
- c.Assert(strings.Count(result.Combined(), "Using cache"), checker.Equals, 1)
+ assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 1)
}
// FIXME(vdemeester) should be a unit test
-func (s *DockerSuite) TestBuildLineErrorOnBuild(c *check.C) {
+func (s *DockerSuite) TestBuildLineErrorOnBuild(c *testing.T) {
name := "test_build_line_error_onbuild"
buildImage(name, build.WithDockerfile(`FROM busybox
ONBUILD
@@ -6115,7 +6108,7 @@
}
// FIXME(vdemeester) should be a unit test
-func (s *DockerSuite) TestBuildLineErrorUnknownInstruction(c *check.C) {
+func (s *DockerSuite) TestBuildLineErrorUnknownInstruction(c *testing.T) {
name := "test_build_line_error_unknown_instruction"
cli.Docker(cli.Build(name), build.WithDockerfile(`FROM busybox
RUN echo hello world
@@ -6129,7 +6122,7 @@
}
// FIXME(vdemeester) should be a unit test
-func (s *DockerSuite) TestBuildLineErrorWithEmptyLines(c *check.C) {
+func (s *DockerSuite) TestBuildLineErrorWithEmptyLines(c *testing.T) {
name := "test_build_line_error_with_empty_lines"
cli.Docker(cli.Build(name), build.WithDockerfile(`
FROM busybox
@@ -6146,7 +6139,7 @@
}
// FIXME(vdemeester) should be a unit test
-func (s *DockerSuite) TestBuildLineErrorWithComments(c *check.C) {
+func (s *DockerSuite) TestBuildLineErrorWithComments(c *testing.T) {
name := "test_build_line_error_with_comments"
cli.Docker(cli.Build(name), build.WithDockerfile(`FROM busybox
# This will print hello world
@@ -6160,7 +6153,7 @@
}
// #31957
-func (s *DockerSuite) TestBuildSetCommandWithDefinedShell(c *check.C) {
+func (s *DockerSuite) TestBuildSetCommandWithDefinedShell(c *testing.T) {
buildImageSuccessfully(c, "build1", build.WithDockerfile(`
FROM busybox
SHELL ["/bin/sh", "-c"]
@@ -6179,7 +6172,7 @@
}
// FIXME(vdemeester) should migrate to docker/cli tests
-func (s *DockerSuite) TestBuildIidFile(c *check.C) {
+func (s *DockerSuite) TestBuildIidFile(c *testing.T) {
tmpDir, err := ioutil.TempDir("", "TestBuildIidFile")
if err != nil {
c.Fatal(err)
@@ -6200,11 +6193,11 @@
assert.NilError(c, err)
d, err := digest.Parse(string(id))
assert.NilError(c, err)
- c.Assert(d.String(), checker.Equals, getIDByName(c, name))
+ assert.Equal(c, d.String(), getIDByName(c, name))
}
// FIXME(vdemeester) should migrate to docker/cli tests
-func (s *DockerSuite) TestBuildIidFileCleanupOnFail(c *check.C) {
+func (s *DockerSuite) TestBuildIidFileCleanupOnFail(c *testing.T) {
tmpDir, err := ioutil.TempDir("", "TestBuildIidFileCleanupOnFail")
if err != nil {
c.Fatal(err)
@@ -6223,5 +6216,5 @@
})
_, err = os.Stat(tmpIidFile)
assert.ErrorContains(c, err, "")
- c.Assert(os.IsNotExist(err), check.Equals, true)
+ assert.Equal(c, os.IsNotExist(err), true)
}
diff --git a/integration-cli/docker_cli_build_unix_test.go b/integration-cli/docker_cli_build_unix_test.go
index af005f5..ef6da0e 100644
--- a/integration-cli/docker_cli_build_unix_test.go
+++ b/integration-cli/docker_cli_build_unix_test.go
@@ -13,19 +13,18 @@
"regexp"
"strings"
"syscall"
+ "testing"
"time"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/internal/test/fakecontext"
"github.com/docker/go-units"
- "github.com/go-check/check"
"gotest.tools/assert"
"gotest.tools/icmd"
)
-func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *check.C) {
+func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *testing.T) {
testRequires(c, cpuCfsQuota)
name := "testbuildresourceconstraints"
buildLabel := "DockerSuite.TestBuildResourceConstraintsAreUsed"
@@ -56,16 +55,16 @@
var c1 hostConfig
err := json.Unmarshal([]byte(cfg), &c1)
- c.Assert(err, checker.IsNil, check.Commentf(cfg))
+ assert.Assert(c, err == nil, cfg)
- c.Assert(c1.Memory, checker.Equals, int64(64*1024*1024), check.Commentf("resource constraints not set properly for Memory"))
- c.Assert(c1.MemorySwap, checker.Equals, int64(-1), check.Commentf("resource constraints not set properly for MemorySwap"))
- c.Assert(c1.CpusetCpus, checker.Equals, "0", check.Commentf("resource constraints not set properly for CpusetCpus"))
- c.Assert(c1.CpusetMems, checker.Equals, "0", check.Commentf("resource constraints not set properly for CpusetMems"))
- c.Assert(c1.CPUShares, checker.Equals, int64(100), check.Commentf("resource constraints not set properly for CPUShares"))
- c.Assert(c1.CPUQuota, checker.Equals, int64(8000), check.Commentf("resource constraints not set properly for CPUQuota"))
- c.Assert(c1.Ulimits[0].Name, checker.Equals, "nofile", check.Commentf("resource constraints not set properly for Ulimits"))
- c.Assert(c1.Ulimits[0].Hard, checker.Equals, int64(42), check.Commentf("resource constraints not set properly for Ulimits"))
+ assert.Equal(c, c1.Memory, int64(64*1024*1024), "resource constraints not set properly for Memory")
+ assert.Equal(c, c1.MemorySwap, int64(-1), "resource constraints not set properly for MemorySwap")
+ assert.Equal(c, c1.CpusetCpus, "0", "resource constraints not set properly for CpusetCpus")
+ assert.Equal(c, c1.CpusetMems, "0", "resource constraints not set properly for CpusetMems")
+ assert.Equal(c, c1.CPUShares, int64(100), "resource constraints not set properly for CPUShares")
+ assert.Equal(c, c1.CPUQuota, int64(8000), "resource constraints not set properly for CPUQuota")
+ assert.Equal(c, c1.Ulimits[0].Name, "nofile", "resource constraints not set properly for Ulimits")
+ assert.Equal(c, c1.Ulimits[0].Hard, int64(42), "resource constraints not set properly for Ulimits")
// Make sure constraints aren't saved to image
cli.DockerCmd(c, "run", "--name=test", name)
@@ -74,18 +73,18 @@
var c2 hostConfig
err = json.Unmarshal([]byte(cfg), &c2)
- c.Assert(err, checker.IsNil, check.Commentf(cfg))
+ assert.Assert(c, err == nil, cfg)
- c.Assert(c2.Memory, check.Not(checker.Equals), int64(64*1024*1024), check.Commentf("resource leaked from build for Memory"))
- c.Assert(c2.MemorySwap, check.Not(checker.Equals), int64(-1), check.Commentf("resource leaked from build for MemorySwap"))
- c.Assert(c2.CpusetCpus, check.Not(checker.Equals), "0", check.Commentf("resource leaked from build for CpusetCpus"))
- c.Assert(c2.CpusetMems, check.Not(checker.Equals), "0", check.Commentf("resource leaked from build for CpusetMems"))
- c.Assert(c2.CPUShares, check.Not(checker.Equals), int64(100), check.Commentf("resource leaked from build for CPUShares"))
- c.Assert(c2.CPUQuota, check.Not(checker.Equals), int64(8000), check.Commentf("resource leaked from build for CPUQuota"))
- c.Assert(c2.Ulimits, checker.IsNil, check.Commentf("resource leaked from build for Ulimits"))
+ assert.Assert(c, c2.Memory != int64(64*1024*1024), "resource leaked from build for Memory")
+ assert.Assert(c, c2.MemorySwap != int64(-1), "resource leaked from build for MemorySwap")
+ assert.Assert(c, c2.CpusetCpus != "0", "resource leaked from build for CpusetCpus")
+ assert.Assert(c, c2.CpusetMems != "0", "resource leaked from build for CpusetMems")
+ assert.Assert(c, c2.CPUShares != int64(100), "resource leaked from build for CPUShares")
+ assert.Assert(c, c2.CPUQuota != int64(8000), "resource leaked from build for CPUQuota")
+ assert.Assert(c, c2.Ulimits == nil, "resource leaked from build for Ulimits")
}
-func (s *DockerSuite) TestBuildAddChangeOwnership(c *check.C) {
+func (s *DockerSuite) TestBuildAddChangeOwnership(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "testbuildaddown"
@@ -131,7 +130,7 @@
// TODO(buildkit): this test needs to be rewritten for buildkit.
// 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.
-func (s *DockerSuite) TestBuildCancellationKillsSleep(c *check.C) {
+func (s *DockerSuite) TestBuildCancellationKillsSleep(c *testing.T) {
testRequires(c, DaemonIsLinux, TODOBuildkit)
name := "testbuildcancellation"
diff --git a/integration-cli/docker_cli_by_digest_test.go b/integration-cli/docker_cli_by_digest_test.go
index c884d31..494ac50 100644
--- a/integration-cli/docker_cli_by_digest_test.go
+++ b/integration-cli/docker_cli_by_digest_test.go
@@ -7,14 +7,13 @@
"path/filepath"
"regexp"
"strings"
+ "testing"
"github.com/docker/distribution/manifest/schema1"
"github.com/docker/distribution/manifest/schema2"
"github.com/docker/docker/api/types"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
- "github.com/go-check/check"
"github.com/opencontainers/go-digest"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
@@ -27,11 +26,11 @@
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")
}
-func setupImageWithTag(c *check.C, tag string) (digest.Digest, error) {
+func setupImageWithTag(c *testing.T, tag string) (digest.Digest, error) {
containerName := "busyboxbydigest"
// new file is committed because this layer is used for detecting malicious
@@ -59,7 +58,7 @@
return digest.Digest(pushDigest), nil
}
-func testPullByTagDisplaysDigest(c *check.C) {
+func testPullByTagDisplaysDigest(c *testing.T) {
testRequires(c, DaemonIsLinux)
pushDigest, err := setupImage(c)
assert.NilError(c, err, "error setting up image")
@@ -73,18 +72,18 @@
pullDigest := matches[1]
// make sure the pushed and pull digests match
- c.Assert(pushDigest.String(), checker.Equals, pullDigest)
+ assert.Equal(c, pushDigest.String(), pullDigest)
}
-func (s *DockerRegistrySuite) TestPullByTagDisplaysDigest(c *check.C) {
+func (s *DockerRegistrySuite) TestPullByTagDisplaysDigest(c *testing.T) {
testPullByTagDisplaysDigest(c)
}
-func (s *DockerSchema1RegistrySuite) TestPullByTagDisplaysDigest(c *check.C) {
+func (s *DockerSchema1RegistrySuite) TestPullByTagDisplaysDigest(c *testing.T) {
testPullByTagDisplaysDigest(c)
}
-func testPullByDigest(c *check.C) {
+func testPullByDigest(c *testing.T) {
testRequires(c, DaemonIsLinux)
pushDigest, err := setupImage(c)
assert.NilError(c, err, "error setting up image")
@@ -99,35 +98,35 @@
pullDigest := matches[1]
// make sure the pushed and pull digests match
- c.Assert(pushDigest.String(), checker.Equals, pullDigest)
+ assert.Equal(c, pushDigest.String(), pullDigest)
}
-func (s *DockerRegistrySuite) TestPullByDigest(c *check.C) {
+func (s *DockerRegistrySuite) TestPullByDigest(c *testing.T) {
testPullByDigest(c)
}
-func (s *DockerSchema1RegistrySuite) TestPullByDigest(c *check.C) {
+func (s *DockerSchema1RegistrySuite) TestPullByDigest(c *testing.T) {
testPullByDigest(c)
}
-func testPullByDigestNoFallback(c *check.C) {
+func testPullByDigestNoFallback(c *testing.T) {
testRequires(c, DaemonIsLinux)
// pull from the registry using the <name>@<digest> reference
imageReference := fmt.Sprintf("%s@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", repoName)
out, _, err := dockerCmdWithError("pull", imageReference)
- c.Assert(err, checker.NotNil, check.Commentf("expected non-zero exit status and correct error message when pulling non-existing image"))
- c.Assert(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, err != nil, "expected non-zero exit status and correct error message when pulling non-existing image")
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf("manifest for %s not found", imageReference)), "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)
}
-func (s *DockerSchema1RegistrySuite) TestPullByDigestNoFallback(c *check.C) {
+func (s *DockerSchema1RegistrySuite) TestPullByDigestNoFallback(c *testing.T) {
testPullByDigestNoFallback(c)
}
-func (s *DockerRegistrySuite) TestCreateByDigest(c *check.C) {
+func (s *DockerRegistrySuite) TestCreateByDigest(c *testing.T) {
pushDigest, err := setupImage(c)
assert.NilError(c, err, "error setting up image")
@@ -140,7 +139,7 @@
assert.Equal(c, res, imageReference)
}
-func (s *DockerRegistrySuite) TestRunByDigest(c *check.C) {
+func (s *DockerRegistrySuite) TestRunByDigest(c *testing.T) {
pushDigest, err := setupImage(c)
assert.NilError(c, err)
@@ -151,14 +150,14 @@
foundRegex := regexp.MustCompile("found=([^\n]+)")
matches := foundRegex.FindStringSubmatch(out)
- c.Assert(matches, checker.HasLen, 2, check.Commentf("unable to parse digest from pull output: %s", out))
- c.Assert(matches[1], checker.Equals, "1", check.Commentf("Expected %q, got %q", "1", matches[1]))
+ assert.Equal(c, len(matches), 2, fmt.Sprintf("unable to parse digest from pull output: %s", out))
+ assert.Equal(c, matches[1], "1", fmt.Sprintf("Expected %q, got %q", "1", matches[1]))
res := inspectField(c, containerName, "Config.Image")
assert.Equal(c, res, imageReference)
}
-func (s *DockerRegistrySuite) TestRemoveImageByDigest(c *check.C) {
+func (s *DockerRegistrySuite) TestRemoveImageByDigest(c *testing.T) {
digest, err := setupImage(c)
assert.NilError(c, err, "error setting up image")
@@ -180,7 +179,7 @@
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)
assert.NilError(c, err, "error setting up image")
@@ -205,7 +204,7 @@
assert.Equal(c, res, imageID)
}
-func (s *DockerRegistrySuite) TestTagByDigest(c *check.C) {
+func (s *DockerRegistrySuite) TestTagByDigest(c *testing.T) {
digest, err := setupImage(c)
assert.NilError(c, err, "error setting up image")
@@ -224,7 +223,7 @@
assert.Equal(c, tagID, expectedID)
}
-func (s *DockerRegistrySuite) TestListImagesWithoutDigests(c *check.C) {
+func (s *DockerRegistrySuite) TestListImagesWithoutDigests(c *testing.T) {
digest, err := setupImage(c)
assert.NilError(c, err, "error setting up image")
@@ -234,10 +233,10 @@
dockerCmd(c, "pull", imageReference)
out, _ := dockerCmd(c, "images")
- c.Assert(out, checker.Not(checker.Contains), "DIGEST", check.Commentf("list output should not have contained DIGEST header"))
+ assert.Assert(c, !strings.Contains(out, "DIGEST"), "list output should not have contained DIGEST header")
}
-func (s *DockerRegistrySuite) TestListImagesWithDigests(c *check.C) {
+func (s *DockerRegistrySuite) TestListImagesWithDigests(c *testing.T) {
// setup image1
digest1, err := setupImageWithTag(c, "tag1")
@@ -253,7 +252,7 @@
// make sure repo shown, tag=<none>, digest = $digest1
re1 := regexp.MustCompile(`\s*` + repoName + `\s*<none>\s*` + digest1.String() + `\s`)
- c.Assert(re1.MatchString(out), checker.True, check.Commentf("expected %q: %s", re1.String(), out))
+ assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out)
// setup image2
digest2, err := setupImageWithTag(c, "tag2")
//error setting up image
@@ -271,11 +270,11 @@
out, _ = dockerCmd(c, "images", "--digests")
// make sure repo shown, tag=<none>, digest = $digest1
- c.Assert(re1.MatchString(out), checker.True, check.Commentf("expected %q: %s", re1.String(), out))
+ assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out)
// make sure repo shown, tag=<none>, digest = $digest2
re2 := regexp.MustCompile(`\s*` + repoName + `\s*<none>\s*` + digest2.String() + `\s`)
- c.Assert(re2.MatchString(out), checker.True, check.Commentf("expected %q: %s", re2.String(), out))
+ assert.Assert(c, re2.MatchString(out), "expected %q: %s", re2.String(), out)
// pull tag1
dockerCmd(c, "pull", repoName+":tag1")
@@ -285,9 +284,9 @@
// make sure image 1 has repo, tag, <none> AND repo, <none>, digest
reWithDigest1 := regexp.MustCompile(`\s*` + repoName + `\s*tag1\s*` + digest1.String() + `\s`)
- c.Assert(reWithDigest1.MatchString(out), checker.True, check.Commentf("expected %q: %s", reWithDigest1.String(), out))
+ assert.Assert(c, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out)
// make sure image 2 has repo, <none>, digest
- c.Assert(re2.MatchString(out), checker.True, check.Commentf("expected %q: %s", re2.String(), out))
+ assert.Assert(c, re2.MatchString(out), "expected %q: %s", re2.String(), out)
// pull tag 2
dockerCmd(c, "pull", repoName+":tag2")
@@ -296,25 +295,25 @@
out, _ = dockerCmd(c, "images", "--digests")
// make sure image 1 has repo, tag, digest
- c.Assert(reWithDigest1.MatchString(out), checker.True, check.Commentf("expected %q: %s", reWithDigest1.String(), out))
+ assert.Assert(c, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out)
// make sure image 2 has repo, tag, digest
reWithDigest2 := regexp.MustCompile(`\s*` + repoName + `\s*tag2\s*` + digest2.String() + `\s`)
- c.Assert(reWithDigest2.MatchString(out), checker.True, check.Commentf("expected %q: %s", reWithDigest2.String(), out))
+ assert.Assert(c, reWithDigest2.MatchString(out), "expected %q: %s", reWithDigest2.String(), out)
// list images
out, _ = dockerCmd(c, "images", "--digests")
// make sure image 1 has repo, tag, digest
- c.Assert(reWithDigest1.MatchString(out), checker.True, check.Commentf("expected %q: %s", reWithDigest1.String(), out))
+ assert.Assert(c, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out)
// make sure image 2 has repo, tag, digest
- c.Assert(reWithDigest2.MatchString(out), checker.True, check.Commentf("expected %q: %s", reWithDigest2.String(), out))
+ assert.Assert(c, reWithDigest2.MatchString(out), "expected %q: %s", reWithDigest2.String(), out)
// make sure busybox has tag, but not digest
busyboxRe := regexp.MustCompile(`\s*busybox\s*latest\s*<none>\s`)
- c.Assert(busyboxRe.MatchString(out), checker.True, check.Commentf("expected %q: %s", busyboxRe.String(), out))
+ assert.Assert(c, busyboxRe.MatchString(out), "expected %q: %s", busyboxRe.String(), out)
}
-func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *check.C) {
+func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *testing.T) {
// setup image1
digest1, err := setupImageWithTag(c, "dangle1")
assert.NilError(c, err, "error setting up image")
@@ -329,7 +328,7 @@
// make sure repo shown, tag=<none>, digest = $digest1
re1 := regexp.MustCompile(`\s*` + repoName + `\s*<none>\s*` + digest1.String() + `\s`)
- c.Assert(re1.MatchString(out), checker.True, check.Commentf("expected %q: %s", re1.String(), out))
+ assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out)
// setup image2
digest2, err := setupImageWithTag(c, "dangle2")
//error setting up image
@@ -347,11 +346,11 @@
out, _ = dockerCmd(c, "images", "--digests", "--filter=dangling=true")
// make sure repo shown, tag=<none>, digest = $digest1
- c.Assert(re1.MatchString(out), checker.True, check.Commentf("expected %q: %s", re1.String(), out))
+ assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out)
// make sure repo shown, tag=<none>, digest = $digest2
re2 := regexp.MustCompile(`\s*` + repoName + `\s*<none>\s*` + digest2.String() + `\s`)
- c.Assert(re2.MatchString(out), checker.True, check.Commentf("expected %q: %s", re2.String(), out))
+ assert.Assert(c, re2.MatchString(out), "expected %q: %s", re2.String(), out)
// pull dangle1 tag
dockerCmd(c, "pull", repoName+":dangle1")
@@ -361,9 +360,9 @@
// make sure image 1 has repo, tag, <none> AND repo, <none>, digest
reWithDigest1 := regexp.MustCompile(`\s*` + repoName + `\s*dangle1\s*` + digest1.String() + `\s`)
- c.Assert(reWithDigest1.MatchString(out), checker.False, check.Commentf("unexpected %q: %s", reWithDigest1.String(), out))
+ assert.Assert(c, !reWithDigest1.MatchString(out), "unexpected %q: %s", reWithDigest1.String(), out)
// make sure image 2 has repo, <none>, digest
- c.Assert(re2.MatchString(out), checker.True, check.Commentf("expected %q: %s", re2.String(), out))
+ assert.Assert(c, re2.MatchString(out), "expected %q: %s", re2.String(), out)
// pull dangle2 tag
dockerCmd(c, "pull", repoName+":dangle2")
@@ -372,24 +371,24 @@
out, _ = dockerCmd(c, "images", "--digests")
// make sure image 1 has repo, tag, digest
- c.Assert(reWithDigest1.MatchString(out), checker.True, check.Commentf("expected %q: %s", reWithDigest1.String(), out))
+ assert.Assert(c, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out)
// make sure image 2 has repo, tag, digest
reWithDigest2 := regexp.MustCompile(`\s*` + repoName + `\s*dangle2\s*` + digest2.String() + `\s`)
- c.Assert(reWithDigest2.MatchString(out), checker.True, check.Commentf("expected %q: %s", reWithDigest2.String(), out))
+ assert.Assert(c, reWithDigest2.MatchString(out), "expected %q: %s", reWithDigest2.String(), out)
// list images, no longer dangling, should not match
out, _ = dockerCmd(c, "images", "--digests", "--filter=dangling=true")
// make sure image 1 has repo, tag, digest
- c.Assert(reWithDigest1.MatchString(out), checker.False, check.Commentf("unexpected %q: %s", reWithDigest1.String(), out))
+ assert.Assert(c, !reWithDigest1.MatchString(out), "unexpected %q: %s", reWithDigest1.String(), out)
// make sure image 2 has repo, tag, digest
- c.Assert(reWithDigest2.MatchString(out), checker.False, check.Commentf("unexpected %q: %s", reWithDigest2.String(), out))
+ assert.Assert(c, !reWithDigest2.MatchString(out), "unexpected %q: %s", reWithDigest2.String(), out)
}
-func (s *DockerRegistrySuite) TestInspectImageWithDigests(c *check.C) {
+func (s *DockerRegistrySuite) TestInspectImageWithDigests(c *testing.T) {
digest, err := setupImage(c)
- c.Assert(err, check.IsNil, check.Commentf("error setting up image"))
+ assert.Assert(c, err == nil, "error setting up image")
imageReference := fmt.Sprintf("%s@%s", repoName, digest)
@@ -401,12 +400,12 @@
var imageJSON []types.ImageInspect
err = json.Unmarshal([]byte(out), &imageJSON)
assert.NilError(c, err)
- c.Assert(imageJSON, checker.HasLen, 1)
- c.Assert(imageJSON[0].RepoDigests, checker.HasLen, 1)
+ assert.Equal(c, len(imageJSON), 1)
+ assert.Equal(c, len(imageJSON[0].RepoDigests), 1)
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)
digest, err := setupImage(c)
@@ -442,7 +441,7 @@
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)
assert.NilError(c, err, "error setting up image")
@@ -461,7 +460,7 @@
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)
assert.NilError(c, err, "error setting up image")
@@ -488,7 +487,7 @@
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)
assert.NilError(c, err, "error setting up image")
@@ -525,7 +524,7 @@
// TestPullFailsWithAlteredManifest tests that a `docker pull` fails when
// we have modified a manifest blob and its digest cannot be verified.
// 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)
manifestDigest, err := setupImage(c)
assert.NilError(c, err, "error setting up image")
@@ -556,7 +555,7 @@
// Pull from the registry using the <name>@<digest> reference.
imageReference := fmt.Sprintf("%s@%s", repoName, manifestDigest)
out, exitStatus, _ := dockerCmdWithError("pull", imageReference)
- c.Assert(exitStatus, checker.Not(check.Equals), 0)
+ assert.Assert(c, exitStatus != 0)
expectedErrorMsg := fmt.Sprintf("manifest verification failed for digest %s", manifestDigest)
assert.Assert(c, is.Contains(out, expectedErrorMsg))
@@ -565,17 +564,17 @@
// TestPullFailsWithAlteredManifest tests that a `docker pull` fails when
// we have modified a manifest blob and its digest cannot be verified.
// 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)
manifestDigest, err := setupImage(c)
- c.Assert(err, checker.IsNil, check.Commentf("error setting up image"))
+ assert.Assert(c, err == nil, "error setting up image")
// Load the target manifest blob.
manifestBlob := s.reg.ReadBlobContents(c, manifestDigest)
var imgManifest schema1.Manifest
err = json.Unmarshal(manifestBlob, &imgManifest)
- c.Assert(err, checker.IsNil, check.Commentf("unable to decode image manifest from blob"))
+ assert.Assert(c, err == nil, "unable to decode image manifest from blob")
// Change a layer in the manifest.
imgManifest.FSLayers[0] = schema1.FSLayer{
@@ -588,7 +587,7 @@
defer undo()
alteredManifestBlob, err := json.MarshalIndent(imgManifest, "", " ")
- c.Assert(err, checker.IsNil, check.Commentf("unable to encode altered image manifest to JSON"))
+ assert.Assert(c, err == nil, "unable to encode altered image manifest to JSON")
s.reg.WriteBlobContents(c, manifestDigest, alteredManifestBlob)
@@ -598,26 +597,26 @@
// Pull from the registry using the <name>@<digest> reference.
imageReference := fmt.Sprintf("%s@%s", repoName, manifestDigest)
out, exitStatus, _ := dockerCmdWithError("pull", imageReference)
- c.Assert(exitStatus, checker.Not(check.Equals), 0)
+ assert.Assert(c, exitStatus != 0)
expectedErrorMsg := fmt.Sprintf("image verification failed for digest %s", manifestDigest)
- c.Assert(out, checker.Contains, expectedErrorMsg)
+ assert.Assert(c, strings.Contains(out, expectedErrorMsg))
}
// TestPullFailsWithAlteredLayer tests that a `docker pull` fails when
// we have modified a layer blob and its digest cannot be verified.
// 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)
manifestDigest, err := setupImage(c)
- c.Assert(err, checker.IsNil)
+ assert.Assert(c, err == nil)
// Load the target manifest blob.
manifestBlob := s.reg.ReadBlobContents(c, manifestDigest)
var imgManifest schema2.Manifest
err = json.Unmarshal(manifestBlob, &imgManifest)
- c.Assert(err, checker.IsNil)
+ assert.Assert(c, err == nil)
// Next, get the digest of one of the layers from the manifest.
targetLayerDigest := imgManifest.Layers[0].Digest
@@ -641,26 +640,26 @@
// Pull from the registry using the <name>@<digest> reference.
imageReference := fmt.Sprintf("%s@%s", repoName, manifestDigest)
out, exitStatus, _ := dockerCmdWithError("pull", imageReference)
- c.Assert(exitStatus, checker.Not(check.Equals), 0, check.Commentf("expected a non-zero exit status"))
+ assert.Assert(c, exitStatus != 0, "expected a non-zero exit status")
expectedErrorMsg := fmt.Sprintf("filesystem layer verification failed for digest %s", targetLayerDigest)
- c.Assert(out, checker.Contains, expectedErrorMsg, check.Commentf("expected error message in output: %s", out))
+ assert.Assert(c, strings.Contains(out, expectedErrorMsg), "expected error message in output: %s", out)
}
// TestPullFailsWithAlteredLayer tests that a `docker pull` fails when
// we have modified a layer blob and its digest cannot be verified.
// 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)
manifestDigest, err := setupImage(c)
- c.Assert(err, checker.IsNil)
+ assert.Assert(c, err == nil)
// Load the target manifest blob.
manifestBlob := s.reg.ReadBlobContents(c, manifestDigest)
var imgManifest schema1.Manifest
err = json.Unmarshal(manifestBlob, &imgManifest)
- c.Assert(err, checker.IsNil)
+ assert.Assert(c, err == nil)
// Next, get the digest of one of the layers from the manifest.
targetLayerDigest := imgManifest.FSLayers[0].BlobSum
@@ -684,8 +683,8 @@
// Pull from the registry using the <name>@<digest> reference.
imageReference := fmt.Sprintf("%s@%s", repoName, manifestDigest)
out, exitStatus, _ := dockerCmdWithError("pull", imageReference)
- c.Assert(exitStatus, checker.Not(check.Equals), 0, check.Commentf("expected a non-zero exit status"))
+ assert.Assert(c, exitStatus != 0, "expected a non-zero exit status")
expectedErrorMsg := fmt.Sprintf("filesystem layer verification failed for digest %s", targetLayerDigest)
- c.Assert(out, checker.Contains, expectedErrorMsg, check.Commentf("expected error message in output: %s", out))
+ assert.Assert(c, strings.Contains(out, expectedErrorMsg), "expected error message in output: %s", out)
}
diff --git a/integration-cli/docker_cli_commit_test.go b/integration-cli/docker_cli_commit_test.go
index d9f6e68..126e30a 100644
--- a/integration-cli/docker_cli_commit_test.go
+++ b/integration-cli/docker_cli_commit_test.go
@@ -2,14 +2,14 @@
import (
"strings"
+ "testing"
"github.com/docker/docker/api/types/versions"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli"
- "github.com/go-check/check"
+ "gotest.tools/assert"
)
-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()
cleanedContainerID := strings.TrimSpace(out)
@@ -23,7 +23,7 @@
cli.DockerCmd(c, "inspect", cleanedImageID)
}
-func (s *DockerSuite) TestCommitWithoutPause(c *check.C) {
+func (s *DockerSuite) TestCommitWithoutPause(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-i", "-a", "stdin", "busybox", "echo", "foo")
@@ -39,7 +39,7 @@
}
//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)
out, _ := dockerCmd(c, "run", "-i", "-d", "busybox")
@@ -50,10 +50,10 @@
out = inspectField(c, cleanedContainerID, "State.Paused")
// commit should not unpause a paused container
- c.Assert(out, checker.Contains, "true")
+ assert.Assert(c, strings.Contains(out, "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")
imageID, _ := dockerCmd(c, "commit", "committer")
@@ -61,18 +61,17 @@
out, _ := dockerCmd(c, "run", imageID, "cat", "/foo")
actual := strings.TrimSpace(out)
- c.Assert(actual, checker.Equals, "koye")
+ assert.Equal(c, actual, "koye")
}
-func (s *DockerSuite) TestCommitHardlink(c *check.C) {
+func (s *DockerSuite) TestCommitHardlink(c *testing.T) {
testRequires(c, DaemonIsLinux)
firstOutput, _ := dockerCmd(c, "run", "-t", "--name", "hardlinks", "busybox", "sh", "-c", "touch file1 && ln file1 file2 && ls -di file1 file2")
chunks := strings.Split(strings.TrimSpace(firstOutput), " ")
inode := chunks[0]
chunks = strings.SplitAfterN(strings.TrimSpace(firstOutput), " ", 2)
- c.Assert(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, strings.Contains(chunks[1], chunks[0]), "Failed to create hardlink in a container. Expected to find %q in %q", inode, chunks[1:])
imageID, _ := dockerCmd(c, "commit", "hardlinks", "hardlinks")
imageID = strings.TrimSpace(imageID)
@@ -81,10 +80,10 @@
chunks = strings.Split(strings.TrimSpace(secondOutput), " ")
inode = chunks[0]
chunks = strings.SplitAfterN(strings.TrimSpace(secondOutput), " ", 2)
- c.Assert(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, strings.Contains(chunks[1], chunks[0]), "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")
imageID, _ := dockerCmd(c, "commit", "tty", "ttytest")
@@ -93,7 +92,7 @@
dockerCmd(c, "run", imageID, "/bin/ls")
}
-func (s *DockerSuite) TestCommitWithHostBindMount(c *check.C) {
+func (s *DockerSuite) TestCommitWithHostBindMount(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "--name", "bind-commit", "-v", "/dev/null:/winning", "busybox", "true")
@@ -103,7 +102,7 @@
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")
imageID, _ := dockerCmd(c, "commit",
@@ -153,7 +152,7 @@
}
}
-func (s *DockerSuite) TestCommitChangeLabels(c *check.C) {
+func (s *DockerSuite) TestCommitChangeLabels(c *testing.T) {
dockerCmd(c, "run", "--name", "test", "--label", "some=label", "busybox", "true")
imageID, _ := dockerCmd(c, "commit",
@@ -161,7 +160,7 @@
"test", "test-commit")
imageID = strings.TrimSpace(imageID)
- c.Assert(inspectField(c, imageID, "Config.Labels"), checker.Equals, "map[some:label2]")
+ assert.Equal(c, inspectField(c, imageID, "Config.Labels"), "map[some:label2]")
// check that container labels didn't change
- c.Assert(inspectField(c, "test", "Config.Labels"), checker.Equals, "map[some:label]")
+ assert.Equal(c, inspectField(c, "test", "Config.Labels"), "map[some:label]")
}
diff --git a/integration-cli/docker_cli_cp_from_container_test.go b/integration-cli/docker_cli_cp_from_container_test.go
index 98c35fc..7cfe1a9 100644
--- a/integration-cli/docker_cli_cp_from_container_test.go
+++ b/integration-cli/docker_cli_cp_from_container_test.go
@@ -3,9 +3,8 @@
import (
"os"
"path/filepath"
+ "testing"
- "github.com/docker/docker/integration-cli/checker"
- "github.com/go-check/check"
"gotest.tools/assert"
)
@@ -22,7 +21,7 @@
// Check that copying from a container to a local symlink copies to the symlink
// target and does not overwrite the local symlink itself.
// 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)
containerID := makeTestContainer(c, testContainerOptions{addContent: true})
@@ -36,38 +35,38 @@
srcPath := containerCpPath(containerID, "/file2")
dstPath := cpPath(tmpDir, "symlinkToFile1")
- c.Assert(runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
- c.Assert(symlinkTargetEquals(c, dstPath, "file1"), checker.IsNil)
+ assert.Assert(c, symlinkTargetEquals(c, dstPath, "file1") == nil)
// The file should have the contents of "file2" now.
- c.Assert(fileContentEquals(c, cpPath(tmpDir, "file1"), "file2\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, cpPath(tmpDir, "file1"), "file2\n") == nil)
// Next, copy a file from the container to a symlink to a directory. This
// should copy the file into the symlink target directory.
dstPath = cpPath(tmpDir, "symlinkToDir1")
- c.Assert(runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
- c.Assert(symlinkTargetEquals(c, dstPath, "dir1"), checker.IsNil)
+ assert.Assert(c, symlinkTargetEquals(c, dstPath, "dir1") == nil)
// The file should have the contents of "file2" now.
- c.Assert(fileContentEquals(c, cpPath(tmpDir, "file2"), "file2\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, cpPath(tmpDir, "file2"), "file2\n") == nil)
// Next, copy a file from the container to a symlink to a file that does
// not exist (a broken symlink). This should create the target file with
// the contents of the source file.
dstPath = cpPath(tmpDir, "brokenSymlinkToFileX")
- c.Assert(runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
- c.Assert(symlinkTargetEquals(c, dstPath, "fileX"), checker.IsNil)
+ assert.Assert(c, symlinkTargetEquals(c, dstPath, "fileX") == nil)
// The file should have the contents of "file2" now.
- c.Assert(fileContentEquals(c, cpPath(tmpDir, "fileX"), "file2\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, cpPath(tmpDir, "fileX"), "file2\n") == nil)
// Next, copy a directory from the container to a symlink to a local
// directory. This should copy the directory into the symlink target
@@ -75,13 +74,13 @@
srcPath = containerCpPath(containerID, "/dir2")
dstPath = cpPath(tmpDir, "symlinkToDir1")
- c.Assert(runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
- c.Assert(symlinkTargetEquals(c, dstPath, "dir1"), checker.IsNil)
+ assert.Assert(c, symlinkTargetEquals(c, dstPath, "dir1") == nil)
// The directory should now contain a copy of "dir2".
- c.Assert(fileContentEquals(c, cpPath(tmpDir, "dir1/dir2/file2-1"), "file2-1\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, cpPath(tmpDir, "dir1/dir2/file2-1"), "file2-1\n") == nil)
// Next, copy a directory from the container to a symlink to a local
// directory that does not exist (a broken symlink). This should create
@@ -89,13 +88,13 @@
// should not modify the symlink.
dstPath = cpPath(tmpDir, "brokenSymlinkToDirX")
- c.Assert(runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
- c.Assert(symlinkTargetEquals(c, dstPath, "dirX"), checker.IsNil)
+ assert.Assert(c, symlinkTargetEquals(c, dstPath, "dirX") == nil)
// The "dirX" directory should now be a copy of "dir2".
- c.Assert(fileContentEquals(c, cpPath(tmpDir, "dirX/file2-1"), "file2-1\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, cpPath(tmpDir, "dirX/file2-1"), "file2-1\n") == nil)
}
// Possibilities are reduced to the remaining 10 cases:
@@ -117,7 +116,7 @@
// 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
// contents of the source file into it.
-func (s *DockerSuite) TestCpFromCaseA(c *check.C) {
+func (s *DockerSuite) TestCpFromCaseA(c *testing.T) {
testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root",
@@ -129,15 +128,15 @@
srcPath := containerCpPath(containerID, "/root/file1")
dstPath := cpPath(tmpDir, "itWorks.txt")
- c.Assert(runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
- c.Assert(fileContentEquals(c, dstPath, "file1\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, dstPath, "file1\n") == nil)
}
// B. SRC specifies a file and DST (with trailing path separator) doesn't
// exist. This should cause an error because the copy operation cannot
// 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)
containerID := makeTestContainer(c, testContainerOptions{addContent: true})
@@ -150,12 +149,12 @@
err := runDockerCp(c, srcPath, dstDir, nil)
assert.ErrorContains(c, err, "")
- c.Assert(isCpDirNotExist(err), checker.True, check.Commentf("expected DirNotExists error, but got %T: %s", err, err))
+ assert.Assert(c, isCpDirNotExist(err), "expected DirNotExists error, but got %T: %s", err, err)
}
// 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.
-func (s *DockerSuite) TestCpFromCaseC(c *check.C) {
+func (s *DockerSuite) TestCpFromCaseC(c *testing.T) {
testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root",
@@ -170,17 +169,17 @@
dstPath := cpPath(tmpDir, "file2")
// Ensure the local file starts with different content.
- c.Assert(fileContentEquals(c, dstPath, "file2\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, dstPath, "file2\n") == nil)
- c.Assert(runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
- c.Assert(fileContentEquals(c, dstPath, "file1\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, dstPath, "file1\n") == nil)
}
// 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
// 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)
containerID := makeTestContainer(c, testContainerOptions{addContent: true})
@@ -195,32 +194,32 @@
// Ensure that dstPath doesn't exist.
_, err := os.Stat(dstPath)
- c.Assert(os.IsNotExist(err), checker.True, check.Commentf("did not expect dstPath %q to exist", dstPath))
+ assert.Assert(c, os.IsNotExist(err), "did not expect dstPath %q to exist", dstPath)
- c.Assert(runDockerCp(c, srcPath, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstDir, nil) == nil)
- c.Assert(fileContentEquals(c, dstPath, "file1\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, dstPath, "file1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
// unable to remove dstDir
- c.Assert(os.RemoveAll(dstDir), checker.IsNil)
+ assert.Assert(c, os.RemoveAll(dstDir) == nil)
// unable to make dstDir
- c.Assert(os.MkdirAll(dstDir, os.FileMode(0755)), checker.IsNil)
+ assert.Assert(c, os.MkdirAll(dstDir, os.FileMode(0755)) == nil)
dstDir = cpPathTrailingSep(tmpDir, "dir1")
- c.Assert(runDockerCp(c, srcPath, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstDir, nil) == nil)
- c.Assert(fileContentEquals(c, dstPath, "file1\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, dstPath, "file1\n") == nil)
}
// E. SRC specifies a directory and DST does not exist. This should create a
// 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
// not.
-func (s *DockerSuite) TestCpFromCaseE(c *check.C) {
+func (s *DockerSuite) TestCpFromCaseE(c *testing.T) {
testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{addContent: true})
@@ -231,25 +230,25 @@
dstDir := cpPath(tmpDir, "testDir")
dstPath := filepath.Join(dstDir, "file1-1")
- c.Assert(runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
- c.Assert(fileContentEquals(c, dstPath, "file1-1\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
// unable to remove dstDir
- c.Assert(os.RemoveAll(dstDir), checker.IsNil)
+ assert.Assert(c, os.RemoveAll(dstDir) == nil)
dstDir = cpPathTrailingSep(tmpDir, "testDir")
- c.Assert(runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
- c.Assert(fileContentEquals(c, dstPath, "file1-1\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n") == nil)
}
// 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.
-func (s *DockerSuite) TestCpFromCaseF(c *check.C) {
+func (s *DockerSuite) TestCpFromCaseF(c *testing.T) {
testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root",
@@ -266,13 +265,13 @@
err := runDockerCp(c, srcDir, dstFile, nil)
assert.ErrorContains(c, err, "")
- c.Assert(isCpCannotCopyDir(err), checker.True, check.Commentf("expected ErrCannotCopyDir error, but got %T: %s", err, err))
+ assert.Assert(c, isCpCannotCopyDir(err), "expected ErrCannotCopyDir error, but got %T: %s", err, err)
}
// 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
// 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)
containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root",
@@ -288,30 +287,30 @@
resultDir := filepath.Join(dstDir, "dir1")
dstPath := filepath.Join(resultDir, "file1-1")
- c.Assert(runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
- c.Assert(fileContentEquals(c, dstPath, "file1-1\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
// unable to remove dstDir
- c.Assert(os.RemoveAll(dstDir), checker.IsNil)
+ assert.Assert(c, os.RemoveAll(dstDir) == nil)
// unable to make dstDir
- c.Assert(os.MkdirAll(dstDir, os.FileMode(0755)), checker.IsNil)
+ assert.Assert(c, os.MkdirAll(dstDir, os.FileMode(0755)) == nil)
dstDir = cpPathTrailingSep(tmpDir, "dir2")
- c.Assert(runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
- c.Assert(fileContentEquals(c, dstPath, "file1-1\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n") == nil)
}
// H. SRC specifies a directory's contents only and DST does not exist. This
// should create a directory at DST and copy the contents of the SRC
// directory (but not the directory itself) into the DST directory. Ensure
// 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)
containerID := makeTestContainer(c, testContainerOptions{addContent: true})
@@ -322,26 +321,26 @@
dstDir := cpPath(tmpDir, "testDir")
dstPath := filepath.Join(dstDir, "file1-1")
- c.Assert(runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
- c.Assert(fileContentEquals(c, dstPath, "file1-1\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
// unable to remove resultDir
- c.Assert(os.RemoveAll(dstDir), checker.IsNil)
+ assert.Assert(c, os.RemoveAll(dstDir) == nil)
dstDir = cpPathTrailingSep(tmpDir, "testDir")
- c.Assert(runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
- c.Assert(fileContentEquals(c, dstPath, "file1-1\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n") == nil)
}
// 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
// directory.
-func (s *DockerSuite) TestCpFromCaseI(c *check.C) {
+func (s *DockerSuite) TestCpFromCaseI(c *testing.T) {
testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root",
@@ -358,14 +357,14 @@
err := runDockerCp(c, srcDir, dstFile, nil)
assert.ErrorContains(c, err, "")
- c.Assert(isCpCannotCopyDir(err), checker.True, check.Commentf("expected ErrCannotCopyDir error, but got %T: %s", err, err))
+ assert.Assert(c, isCpCannotCopyDir(err), "expected ErrCannotCopyDir error, but got %T: %s", err, err)
}
// J. SRC specifies a directory's contents only and DST exists as a 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
// trailing path separator or not.
-func (s *DockerSuite) TestCpFromCaseJ(c *check.C) {
+func (s *DockerSuite) TestCpFromCaseJ(c *testing.T) {
testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root",
@@ -380,21 +379,21 @@
dstDir := cpPath(tmpDir, "dir2")
dstPath := filepath.Join(dstDir, "file1-1")
- c.Assert(runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
- c.Assert(fileContentEquals(c, dstPath, "file1-1\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
// unable to remove dstDir
- c.Assert(os.RemoveAll(dstDir), checker.IsNil)
+ assert.Assert(c, os.RemoveAll(dstDir) == nil)
// unable to make dstDir
- c.Assert(os.MkdirAll(dstDir, os.FileMode(0755)), checker.IsNil)
+ assert.Assert(c, os.MkdirAll(dstDir, os.FileMode(0755)) == nil)
dstDir = cpPathTrailingSep(tmpDir, "dir2")
- c.Assert(runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
- c.Assert(fileContentEquals(c, dstPath, "file1-1\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, dstPath, "file1-1\n") == nil)
}
diff --git a/integration-cli/docker_cli_cp_test.go b/integration-cli/docker_cli_cp_test.go
index 9e84ee2..791138e 100644
--- a/integration-cli/docker_cli_cp_test.go
+++ b/integration-cli/docker_cli_cp_test.go
@@ -9,8 +9,8 @@
"path"
"path/filepath"
"strings"
+ "testing"
- "github.com/go-check/check"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
"gotest.tools/icmd"
@@ -27,14 +27,14 @@
)
// 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)
assert.ErrorContains(c, err, "must specify at least one container source")
}
// Test for #5656
// 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)
containerID := strings.TrimSpace(out)
@@ -70,7 +70,7 @@
}
// 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)
containerID := strings.TrimSpace(out)
@@ -112,7 +112,7 @@
}
// 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)
containerID := strings.TrimSpace(out)
@@ -149,7 +149,7 @@
// Test for #5619
// 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)
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 @@
// Check that symlinks to a directory behave as expected when copying one from
// a container.
-func (s *DockerSuite) TestCpFromSymlinkToDirectory(c *check.C) {
+func (s *DockerSuite) TestCpFromSymlinkToDirectory(c *testing.T) {
testRequires(c, DaemonIsLinux)
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 @@
// Check that symlinks to a directory behave as expected when copying one to a
// container.
-func (s *DockerSuite) TestCpToSymlinkToDirectory(c *check.C) {
+func (s *DockerSuite) TestCpToSymlinkToDirectory(c *testing.T) {
testRequires(c, DaemonIsLinux)
testRequires(c, testEnv.IsLocalDaemon) // Requires local volume mount bind.
@@ -308,7 +308,7 @@
// Test for #5619
// 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)
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 @@
}
// 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, UnixCli) // uses chmod/su: not available on windows
@@ -371,7 +371,7 @@
result.Assert(c, icmd.Expected{})
}
-func (s *DockerSuite) TestCpSpecialFiles(c *check.C) {
+func (s *DockerSuite) TestCpSpecialFiles(c *testing.T) {
testRequires(c, DaemonIsLinux)
testRequires(c, testEnv.IsLocalDaemon)
@@ -411,7 +411,7 @@
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
testRequires(c, NotUserNamespace)
testRequires(c, DaemonIsLinux)
@@ -474,7 +474,7 @@
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")
containerID := strings.TrimSpace(out)
@@ -497,7 +497,7 @@
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")
containerID := strings.TrimSpace(out)
@@ -514,7 +514,7 @@
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)
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /te:s:t")
@@ -533,7 +533,7 @@
assert.Equal(c, string(content), "lololol\n")
}
-func (s *DockerSuite) TestCopyAndRestart(c *check.C) {
+func (s *DockerSuite) TestCopyAndRestart(c *testing.T) {
testRequires(c, DaemonIsLinux)
expectedMsg := "hello"
out, _ := dockerCmd(c, "run", "-d", "busybox", "echo", expectedMsg)
@@ -552,7 +552,7 @@
assert.Equal(c, strings.TrimSpace(out), expectedMsg)
}
-func (s *DockerSuite) TestCopyCreatedContainer(c *check.C) {
+func (s *DockerSuite) TestCopyCreatedContainer(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "create", "--name", "test_cp", "-v", "/test", "busybox")
@@ -565,7 +565,7 @@
// test copy with option `-L`: following symbol link
// Check that symlinks to a file behave as expected when copying one from
// a container to host following symbol link
-func (s *DockerSuite) TestCpSymlinkFromConToHostFollowSymlink(c *check.C) {
+func (s *DockerSuite) TestCpSymlinkFromConToHostFollowSymlink(c *testing.T) {
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")
assert.Equal(c, exitCode, 0, "failed to set up container: %s", out)
diff --git a/integration-cli/docker_cli_cp_to_container_test.go b/integration-cli/docker_cli_cp_to_container_test.go
index cbf2fdc..4a5c747 100644
--- a/integration-cli/docker_cli_cp_to_container_test.go
+++ b/integration-cli/docker_cli_cp_to_container_test.go
@@ -2,9 +2,8 @@
import (
"os"
+ "testing"
- "github.com/docker/docker/integration-cli/checker"
- "github.com/go-check/check"
"gotest.tools/assert"
)
@@ -20,7 +19,7 @@
// 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.
-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
testRequires(c, NotUserNamespace)
testRequires(c, DaemonIsLinux)
@@ -40,38 +39,38 @@
srcPath := cpPath(testVol, "file2")
dstPath := containerCpPath(containerID, "/vol2/symlinkToFile1")
- c.Assert(runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
- c.Assert(symlinkTargetEquals(c, cpPath(testVol, "symlinkToFile1"), "file1"), checker.IsNil)
+ assert.Assert(c, symlinkTargetEquals(c, cpPath(testVol, "symlinkToFile1"), "file1") == nil)
// The file should have the contents of "file2" now.
- c.Assert(fileContentEquals(c, cpPath(testVol, "file1"), "file2\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, cpPath(testVol, "file1"), "file2\n") == nil)
// Next, copy a local file to a symlink to a directory in the container.
// This should copy the file into the symlink target directory.
dstPath = containerCpPath(containerID, "/vol2/symlinkToDir1")
- c.Assert(runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
- c.Assert(symlinkTargetEquals(c, cpPath(testVol, "symlinkToDir1"), "dir1"), checker.IsNil)
+ assert.Assert(c, symlinkTargetEquals(c, cpPath(testVol, "symlinkToDir1"), "dir1") == nil)
// The file should have the contents of "file2" now.
- c.Assert(fileContentEquals(c, cpPath(testVol, "file2"), "file2\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, cpPath(testVol, "file2"), "file2\n") == nil)
// Next, copy a file to a symlink to a file that does not exist (a broken
// symlink) in the container. This should create the target file with the
// contents of the source file.
dstPath = containerCpPath(containerID, "/vol2/brokenSymlinkToFileX")
- c.Assert(runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
- c.Assert(symlinkTargetEquals(c, cpPath(testVol, "brokenSymlinkToFileX"), "fileX"), checker.IsNil)
+ assert.Assert(c, symlinkTargetEquals(c, cpPath(testVol, "brokenSymlinkToFileX"), "fileX") == nil)
// The file should have the contents of "file2" now.
- c.Assert(fileContentEquals(c, cpPath(testVol, "fileX"), "file2\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, cpPath(testVol, "fileX"), "file2\n") == nil)
// Next, copy a local directory to a symlink to a directory in the
// container. This should copy the directory into the symlink target
@@ -79,13 +78,13 @@
srcPath = cpPath(testVol, "/dir2")
dstPath = containerCpPath(containerID, "/vol2/symlinkToDir1")
- c.Assert(runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
- c.Assert(symlinkTargetEquals(c, cpPath(testVol, "symlinkToDir1"), "dir1"), checker.IsNil)
+ assert.Assert(c, symlinkTargetEquals(c, cpPath(testVol, "symlinkToDir1"), "dir1") == nil)
// The directory should now contain a copy of "dir2".
- c.Assert(fileContentEquals(c, cpPath(testVol, "dir1/dir2/file2-1"), "file2-1\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, cpPath(testVol, "dir1/dir2/file2-1"), "file2-1\n") == nil)
// Next, copy a local directory to a symlink to a local directory that does
// not exist (a broken symlink) in the container. This should create the
@@ -93,13 +92,13 @@
// should not modify the symlink.
dstPath = containerCpPath(containerID, "/vol2/brokenSymlinkToDirX")
- c.Assert(runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// The symlink should not have been modified.
- c.Assert(symlinkTargetEquals(c, cpPath(testVol, "brokenSymlinkToDirX"), "dirX"), checker.IsNil)
+ assert.Assert(c, symlinkTargetEquals(c, cpPath(testVol, "brokenSymlinkToDirX"), "dirX") == nil)
// The "dirX" directory should now be a copy of "dir2".
- c.Assert(fileContentEquals(c, cpPath(testVol, "dirX/file2-1"), "file2-1\n"), checker.IsNil)
+ assert.Assert(c, fileContentEquals(c, cpPath(testVol, "dirX/file2-1"), "file2-1\n") == nil)
}
// Possibilities are reduced to the remaining 10 cases:
@@ -121,7 +120,7 @@
// 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
// 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{
workDir: "/root", command: makeCatFileCommand("itWorks.txt"),
})
@@ -134,15 +133,15 @@
srcPath := cpPath(tmpDir, "file1")
dstPath := containerCpPath(containerID, "/root/itWorks.txt")
- c.Assert(runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
- c.Assert(containerStartOutputEquals(c, containerID, "file1\n"), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "file1\n") == nil)
}
// B. SRC specifies a file and DST (with trailing path separator) doesn't
// exist. This should cause an error because the copy operation cannot
// 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{
command: makeCatFileCommand("testDir/file1"),
})
@@ -158,12 +157,12 @@
err := runDockerCp(c, srcPath, dstDir, nil)
assert.ErrorContains(c, err, "")
- c.Assert(isCpDirNotExist(err), checker.True, check.Commentf("expected DirNotExists error, but got %T: %s", err, err))
+ assert.Assert(c, isCpDirNotExist(err), "expected DirNotExists error, but got %T: %s", err, err)
}
// 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.
-func (s *DockerSuite) TestCpToCaseC(c *check.C) {
+func (s *DockerSuite) TestCpToCaseC(c *testing.T) {
testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root",
@@ -179,18 +178,18 @@
dstPath := containerCpPath(containerID, "/root/file2")
// Ensure the container's file starts with the original content.
- c.Assert(containerStartOutputEquals(c, containerID, "file2\n"), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "file2\n") == nil)
- c.Assert(runDockerCp(c, srcPath, dstPath, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstPath, nil) == nil)
// Should now contain file1's contents.
- c.Assert(containerStartOutputEquals(c, containerID, "file1\n"), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "file1\n") == nil)
}
// 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
// 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)
containerID := makeTestContainer(c, testContainerOptions{
addContent: true,
@@ -206,12 +205,12 @@
dstDir := containerCpPath(containerID, "dir1")
// Ensure that dstPath doesn't exist.
- c.Assert(containerStartOutputEquals(c, containerID, ""), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil)
- c.Assert(runDockerCp(c, srcPath, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstDir, nil) == nil)
// Should now contain file1's contents.
- c.Assert(containerStartOutputEquals(c, containerID, "file1\n"), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "file1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
@@ -224,19 +223,19 @@
dstDir = containerCpPathTrailingSep(containerID, "dir1")
// Ensure that dstPath doesn't exist.
- c.Assert(containerStartOutputEquals(c, containerID, ""), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil)
- c.Assert(runDockerCp(c, srcPath, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcPath, dstDir, nil) == nil)
// Should now contain file1's contents.
- c.Assert(containerStartOutputEquals(c, containerID, "file1\n"), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "file1\n") == nil)
}
// E. SRC specifies a directory and DST does not exist. This should create a
// 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
// not.
-func (s *DockerSuite) TestCpToCaseE(c *check.C) {
+func (s *DockerSuite) TestCpToCaseE(c *testing.T) {
containerID := makeTestContainer(c, testContainerOptions{
command: makeCatFileCommand("/testDir/file1-1"),
})
@@ -249,10 +248,10 @@
srcDir := cpPath(tmpDir, "dir1")
dstDir := containerCpPath(containerID, "testDir")
- c.Assert(runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
// Should now contain file1-1's contents.
- c.Assert(containerStartOutputEquals(c, containerID, "file1-1\n"), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
@@ -263,15 +262,15 @@
dstDir = containerCpPathTrailingSep(containerID, "testDir")
- c.Assert(runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
// Should now contain file1-1's contents.
- c.Assert(containerStartOutputEquals(c, containerID, "file1-1\n"), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n") == nil)
}
// 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.
-func (s *DockerSuite) TestCpToCaseF(c *check.C) {
+func (s *DockerSuite) TestCpToCaseF(c *testing.T) {
testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root",
@@ -288,13 +287,13 @@
err := runDockerCp(c, srcDir, dstFile, nil)
assert.ErrorContains(c, err, "")
- c.Assert(isCpCannotCopyDir(err), checker.True, check.Commentf("expected ErrCannotCopyDir error, but got %T: %s", err, err))
+ assert.Assert(c, isCpCannotCopyDir(err), "expected ErrCannotCopyDir error, but got %T: %s", err, err)
}
// 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
// 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)
containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root",
@@ -310,12 +309,12 @@
dstDir := containerCpPath(containerID, "/root/dir2")
// Ensure that dstPath doesn't exist.
- c.Assert(containerStartOutputEquals(c, containerID, ""), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil)
- c.Assert(runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
// Should now contain file1-1's contents.
- c.Assert(containerStartOutputEquals(c, containerID, "file1-1\n"), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
@@ -328,19 +327,19 @@
dstDir = containerCpPathTrailingSep(containerID, "/dir2")
// Ensure that dstPath doesn't exist.
- c.Assert(containerStartOutputEquals(c, containerID, ""), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil)
- c.Assert(runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
// Should now contain file1-1's contents.
- c.Assert(containerStartOutputEquals(c, containerID, "file1-1\n"), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n") == nil)
}
// H. SRC specifies a directory's contents only and DST does not exist. This
// should create a directory at DST and copy the contents of the SRC
// directory (but not the directory itself) into the DST directory. Ensure
// 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{
command: makeCatFileCommand("/testDir/file1-1"),
})
@@ -353,10 +352,10 @@
srcDir := cpPathTrailingSep(tmpDir, "dir1") + "."
dstDir := containerCpPath(containerID, "testDir")
- c.Assert(runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
// Should now contain file1-1's contents.
- c.Assert(containerStartOutputEquals(c, containerID, "file1-1\n"), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
@@ -367,16 +366,16 @@
dstDir = containerCpPathTrailingSep(containerID, "testDir")
- c.Assert(runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
// Should now contain file1-1's contents.
- c.Assert(containerStartOutputEquals(c, containerID, "file1-1\n"), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n") == nil)
}
// 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
// directory.
-func (s *DockerSuite) TestCpToCaseI(c *check.C) {
+func (s *DockerSuite) TestCpToCaseI(c *testing.T) {
testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root",
@@ -393,14 +392,14 @@
err := runDockerCp(c, srcDir, dstFile, nil)
assert.ErrorContains(c, err, "")
- c.Assert(isCpCannotCopyDir(err), checker.True, check.Commentf("expected ErrCannotCopyDir error, but got %T: %s", err, err))
+ assert.Assert(c, isCpCannotCopyDir(err), "expected ErrCannotCopyDir error, but got %T: %s", err, err)
}
// J. SRC specifies a directory's contents only and DST exists as a 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
// trailing path separator or not.
-func (s *DockerSuite) TestCpToCaseJ(c *check.C) {
+func (s *DockerSuite) TestCpToCaseJ(c *testing.T) {
testRequires(c, DaemonIsLinux)
containerID := makeTestContainer(c, testContainerOptions{
addContent: true, workDir: "/root",
@@ -416,12 +415,12 @@
dstDir := containerCpPath(containerID, "/dir2")
// Ensure that dstPath doesn't exist.
- c.Assert(containerStartOutputEquals(c, containerID, ""), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil)
- c.Assert(runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
// Should now contain file1-1's contents.
- c.Assert(containerStartOutputEquals(c, containerID, "file1-1\n"), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n") == nil)
// Now try again but using a trailing path separator for dstDir.
@@ -433,17 +432,17 @@
dstDir = containerCpPathTrailingSep(containerID, "/dir2")
// Ensure that dstPath doesn't exist.
- c.Assert(containerStartOutputEquals(c, containerID, ""), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil)
- c.Assert(runDockerCp(c, srcDir, dstDir, nil), checker.IsNil)
+ assert.Assert(c, runDockerCp(c, srcDir, dstDir, nil) == nil)
// Should now contain file1-1's contents.
- c.Assert(containerStartOutputEquals(c, containerID, "file1-1\n"), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "file1-1\n") == nil)
}
// The `docker cp` command should also ensure that you cannot
// 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
testRequires(c, DaemonIsLinux, NotUserNamespace)
tmpDir := getTestDir(c, "test-cp-to-err-read-only-rootfs")
@@ -462,15 +461,15 @@
err := runDockerCp(c, srcPath, dstPath, nil)
assert.ErrorContains(c, err, "")
- c.Assert(isCpCannotCopyReadOnly(err), checker.True, check.Commentf("expected ErrContainerRootfsReadonly error, but got %T: %s", err, err))
+ assert.Assert(c, isCpCannotCopyReadOnly(err), "expected ErrContainerRootfsReadonly error, but got %T: %s", err, err)
// Ensure that dstPath doesn't exist.
- c.Assert(containerStartOutputEquals(c, containerID, ""), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil)
}
// The `docker cp` command should also ensure that you
// 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
testRequires(c, DaemonIsLinux, NotUserNamespace)
tmpDir := getTestDir(c, "test-cp-to-err-read-only-volume")
@@ -489,8 +488,8 @@
err := runDockerCp(c, srcPath, dstPath, nil)
assert.ErrorContains(c, err, "")
- c.Assert(isCpCannotCopyReadOnly(err), checker.True, check.Commentf("expected ErrVolumeReadonly error, but got %T: %s", err, err))
+ assert.Assert(c, isCpCannotCopyReadOnly(err), "expected ErrVolumeReadonly error, but got %T: %s", err, err)
// Ensure that dstPath doesn't exist.
- c.Assert(containerStartOutputEquals(c, containerID, ""), checker.IsNil)
+ assert.Assert(c, containerStartOutputEquals(c, containerID, "") == nil)
}
diff --git a/integration-cli/docker_cli_cp_to_container_unix_test.go b/integration-cli/docker_cli_cp_to_container_unix_test.go
index bbf0040..9c1b822 100644
--- a/integration-cli/docker_cli_cp_to_container_unix_test.go
+++ b/integration-cli/docker_cli_cp_to_container_unix_test.go
@@ -8,13 +8,13 @@
"path/filepath"
"strconv"
"strings"
+ "testing"
"github.com/docker/docker/pkg/system"
- "github.com/go-check/check"
"gotest.tools/assert"
)
-func (s *DockerSuite) TestCpToContainerWithPermissions(c *check.C) {
+func (s *DockerSuite) TestCpToContainerWithPermissions(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
tmpDir := getTestDir(c, "test-cp-to-host-with-permissions")
@@ -38,7 +38,7 @@
}
// 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)
tmpVolDir := getTestDir(c, "test-cp-tmpvol")
containerID := makeTestContainer(c,
diff --git a/integration-cli/docker_cli_cp_utils_test.go b/integration-cli/docker_cli_cp_utils_test.go
index 3215c8f..a7c317b 100644
--- a/integration-cli/docker_cli_cp_utils_test.go
+++ b/integration-cli/docker_cli_cp_utils_test.go
@@ -9,9 +9,9 @@
"path/filepath"
"runtime"
"strings"
+ "testing"
"github.com/docker/docker/pkg/archive"
- "github.com/go-check/check"
"gotest.tools/assert"
)
@@ -92,7 +92,7 @@
return mkFilesCommand(defaultFileData)
}
-func makeTestContentInDir(c *check.C, dir string) {
+func makeTestContentInDir(c *testing.T, dir string) {
for _, fd := range defaultFileData {
path := filepath.Join(dir, filepath.FromSlash(fd.path))
switch fd.filetype {
@@ -118,7 +118,7 @@
command string
}
-func makeTestContainer(c *check.C, options testContainerOptions) (containerID string) {
+func makeTestContainer(c *testing.T, options testContainerOptions) (containerID string) {
if options.addContent {
mkContentCmd := defaultMkContentCommand()
if options.command == "" {
@@ -188,7 +188,7 @@
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)
args := []string{"cp"}
@@ -205,7 +205,7 @@
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)
args := []string{"start", "-a", containerID}
@@ -218,7 +218,7 @@
return
}
-func getTestDir(c *check.C, label string) (tmpDir string) {
+func getTestDir(c *testing.T, label string) (tmpDir string) {
var err error
tmpDir, err = ioutil.TempDir("", label)
@@ -240,7 +240,7 @@
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)
fileBytes, err := ioutil.ReadFile(filename)
@@ -260,7 +260,7 @@
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)
actualTarget, err := os.Readlink(symlink)
@@ -275,7 +275,7 @@
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)
out, err := startContainerGetOutput(c, containerID)
diff --git a/integration-cli/docker_cli_create_test.go b/integration-cli/docker_cli_create_test.go
index cb8171b..5a3a857 100644
--- a/integration-cli/docker_cli_create_test.go
+++ b/integration-cli/docker_cli_create_test.go
@@ -6,21 +6,20 @@
"os"
"reflect"
"strings"
+ "testing"
"time"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/internal/test/fakecontext"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/go-connections/nat"
- "github.com/go-check/check"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
)
// 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
out, _ := dockerCmd(c, "create", "--entrypoint=", "busybox", "command", "arg1", "arg2", "arg with space", "-c", "flags")
@@ -37,11 +36,11 @@
}
err := json.Unmarshal([]byte(out), &containers)
- c.Assert(err, check.IsNil, check.Commentf("Error inspecting the container: %s", err))
+ assert.Assert(c, err == nil, "Error inspecting the container: %s", err)
assert.Equal(c, len(containers), 1)
cont := containers[0]
- c.Assert(string(cont.Path), checker.Equals, "command", check.Commentf("Unexpected container path. Expected command, received: %s", cont.Path))
+ assert.Equal(c, string(cont.Path), "command", fmt.Sprintf("Unexpected container path. Expected command, received: %s", cont.Path))
b := false
expected := []string{"arg1", "arg2", "arg with space", "-c", "flags"}
@@ -58,7 +57,7 @@
}
// 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
if testEnv.OSType != "windows" {
testRequires(c, Devicemapper)
@@ -68,21 +67,21 @@
cleanedContainerID := strings.TrimSpace(out)
inspectOut := inspectField(c, cleanedContainerID, "HostConfig.StorageOpt")
- c.Assert(inspectOut, checker.Equals, "map[size:120G]")
+ assert.Equal(c, inspectOut, "map[size:120G]")
}
// 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)
// Ensure this fails because of the defaultBaseFsSize is 10G
out, _, err := dockerCmdWithError("create", "--storage-opt", "size=5G", "busybox")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "Container size cannot be smaller than")
+ assert.Assert(c, strings.Contains(out, "Container size cannot be smaller than"))
}
// 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")
cleanedContainerID := strings.TrimSpace(out)
@@ -96,15 +95,15 @@
}
err := json.Unmarshal([]byte(out), &containers)
- c.Assert(err, check.IsNil, check.Commentf("Error inspecting the container: %s", err))
+ assert.Assert(c, err == nil, "Error inspecting the container: %s", err)
assert.Equal(c, len(containers), 1)
cont := containers[0]
- c.Assert(cont.HostConfig, check.NotNil, check.Commentf("Expected HostConfig, got none"))
- c.Assert(cont.HostConfig.PublishAllPorts, check.NotNil, check.Commentf("Expected PublishAllPorts, got false"))
+ assert.Assert(c, cont.HostConfig != nil, "Expected HostConfig, got none")
+ assert.Assert(c, cont.HostConfig.PublishAllPorts, "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")
cleanedContainerID := strings.TrimSpace(out)
@@ -117,23 +116,23 @@
}
}
err := json.Unmarshal([]byte(out), &containers)
- c.Assert(err, check.IsNil, check.Commentf("Error inspecting the container: %s", err))
+ assert.Assert(c, err == nil, "Error inspecting the container: %s", err)
assert.Equal(c, len(containers), 1)
cont := containers[0]
- c.Assert(cont.HostConfig, check.NotNil, check.Commentf("Expected HostConfig, got none"))
- c.Assert(cont.HostConfig.PortBindings, checker.HasLen, 4, check.Commentf("Expected 4 ports bindings, got %d", len(cont.HostConfig.PortBindings)))
+ assert.Assert(c, cont.HostConfig != nil, "Expected HostConfig, got none")
+ assert.Equal(c, len(cont.HostConfig.PortBindings), 4, fmt.Sprintf("Expected 4 ports bindings, got %d", len(cont.HostConfig.PortBindings)))
for k, v := range cont.HostConfig.PortBindings {
- c.Assert(v, checker.HasLen, 1, check.Commentf("Expected 1 ports binding, for the port %s but found %s", k, v))
- c.Assert(k.Port(), checker.Equals, v[0].HostPort, check.Commentf("Expected host port %s to match published port %s", k.Port(), v[0].HostPort))
+ assert.Equal(c, len(v), 1, fmt.Sprintf("Expected 1 ports binding, for the port %s but found %s", k, v))
+ assert.Equal(c, k.Port(), v[0].HostPort, fmt.Sprintf("Expected host port %s to match published port %s", k.Port(), v[0].HostPort))
}
}
-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")
cleanedContainerID := strings.TrimSpace(out)
@@ -147,22 +146,22 @@
}
err := json.Unmarshal([]byte(out), &containers)
- c.Assert(err, check.IsNil, check.Commentf("Error inspecting the container: %s", err))
+ assert.Assert(c, err == nil, "Error inspecting the container: %s", err)
assert.Equal(c, len(containers), 1)
cont := containers[0]
- c.Assert(cont.HostConfig, check.NotNil, check.Commentf("Expected HostConfig, got none"))
- c.Assert(cont.HostConfig.PortBindings, checker.HasLen, 65535)
+ assert.Assert(c, cont.HostConfig != nil, "Expected HostConfig, got none")
+ assert.Equal(c, len(cont.HostConfig.PortBindings), 65535)
for k, v := range cont.HostConfig.PortBindings {
- c.Assert(v, checker.HasLen, 1)
- c.Assert(k.Port(), checker.Equals, v[0].HostPort, check.Commentf("Expected host port %s to match published port %s", k.Port(), v[0].HostPort))
+ assert.Equal(c, len(v), 1)
+ assert.Equal(c, k.Port(), v[0].HostPort, fmt.Sprintf("Expected host port %s to match published port %s", k.Port(), v[0].HostPort))
}
}
// "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")
cleanedContainerID := strings.TrimSpace(out)
@@ -171,7 +170,7 @@
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)
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
@@ -179,7 +178,7 @@
dockerCmd(c, "create", "--name", name, "-v", prefix+slash+"foo", "busybox")
dir, err := inspectMountSourceField(name, prefix+slash+"foo")
- c.Assert(err, check.IsNil, check.Commentf("Error getting volume host path: %q", err))
+ assert.Assert(c, err == nil, "Error getting volume host path: %q", err)
if _, err := os.Stat(dir); err != nil && os.IsNotExist(err) {
c.Fatalf("Volume was not created")
@@ -190,7 +189,7 @@
}
-func (s *DockerSuite) TestCreateLabels(c *check.C) {
+func (s *DockerSuite) TestCreateLabels(c *testing.T) {
name := "test_create_labels"
expected := map[string]string{"k1": "v1", "k2": "v2"}
dockerCmd(c, "create", "--name", name, "-l", "k1=v1", "--label", "k2=v2", "busybox")
@@ -203,7 +202,7 @@
}
}
-func (s *DockerSuite) TestCreateLabelFromImage(c *check.C) {
+func (s *DockerSuite) TestCreateLabelFromImage(c *testing.T) {
imageName := "testcreatebuildlabel"
buildImageSuccessfully(c, imageName, build.WithDockerfile(`FROM busybox
LABEL k1=v1 k2=v2`))
@@ -220,7 +219,7 @@
}
}
-func (s *DockerSuite) TestCreateHostnameWithNumber(c *check.C) {
+func (s *DockerSuite) TestCreateHostnameWithNumber(c *testing.T) {
image := "busybox"
// Busybox on Windows does not implement hostname command
if testEnv.OSType == "windows" {
@@ -230,7 +229,7 @@
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
// "Created" state, and has ever been run. Test "rm -f" too.
@@ -247,7 +246,7 @@
dockerCmd(c, "rm", "-f", cID)
}
-func (s *DockerSuite) TestCreateModeIpcContainer(c *check.C) {
+func (s *DockerSuite) TestCreateModeIpcContainer(c *testing.T) {
// Uses Linux specific functionality (--ipc)
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
@@ -257,7 +256,7 @@
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"
buildImageSuccessfully(c, imageName, build.WithDockerfile(`FROM busybox
MAINTAINER dockerio`))
@@ -290,16 +289,15 @@
}
}
-func (s *DockerSuite) TestCreateStopSignal(c *check.C) {
+func (s *DockerSuite) TestCreateStopSignal(c *testing.T) {
name := "test_create_stop_signal"
dockerCmd(c, "create", "--name", name, "--stop-signal", "9", "busybox")
res := inspectFieldJSON(c, name, "Config.StopSignal")
- c.Assert(res, checker.Contains, "9")
-
+ assert.Assert(c, strings.Contains(res, "9"))
}
-func (s *DockerSuite) TestCreateWithWorkdir(c *check.C) {
+func (s *DockerSuite) TestCreateWithWorkdir(c *testing.T) {
name := "foo"
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
@@ -321,19 +319,19 @@
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"
out, _, err := dockerCmdWithError("create", "--name", name, "--log-opt", "invalid=true", "busybox")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "unknown log opt")
+ assert.Assert(c, strings.Contains(out, "unknown log opt"))
assert.Assert(c, is.Contains(out, "unknown log opt"))
out, _ = dockerCmd(c, "ps", "-a")
- c.Assert(out, checker.Not(checker.Contains), name)
+ assert.Assert(c, !strings.Contains(out, name))
}
// #20972
-func (s *DockerSuite) TestCreate64ByteHexID(c *check.C) {
+func (s *DockerSuite) TestCreate64ByteHexID(c *testing.T) {
out := inspectField(c, "busybox", "Id")
imageID := strings.TrimPrefix(strings.TrimSpace(string(out)), "sha256:")
@@ -341,7 +339,7 @@
}
// Test case for #23498
-func (s *DockerSuite) TestCreateUnsetEntrypoint(c *check.C) {
+func (s *DockerSuite) TestCreateUnsetEntrypoint(c *testing.T) {
name := "test-entrypoint"
dockerfile := `FROM busybox
ADD entrypoint.sh /entrypoint.sh
@@ -362,22 +360,21 @@
out := cli.DockerCmd(c, "create", "--entrypoint=", name, "echo", "foo").Combined()
id := strings.TrimSpace(out)
- c.Assert(id, check.Not(check.Equals), "")
+ assert.Assert(c, id != "")
out = cli.DockerCmd(c, "start", "-a", id).Combined()
- c.Assert(strings.TrimSpace(out), check.Equals, "foo")
+ assert.Equal(c, strings.TrimSpace(out), "foo")
}
// #22471
-func (s *DockerSuite) TestCreateStopTimeout(c *check.C) {
+func (s *DockerSuite) TestCreateStopTimeout(c *testing.T) {
name1 := "test_create_stop_timeout_1"
dockerCmd(c, "create", "--name", name1, "--stop-timeout", "15", "busybox")
res := inspectFieldJSON(c, name1, "Config.StopTimeout")
- c.Assert(res, checker.Contains, "15")
-
+ assert.Assert(c, strings.Contains(res, "15"))
name2 := "test_create_stop_timeout_2"
dockerCmd(c, "create", "--name", name2, "busybox")
res = inspectFieldJSON(c, name2, "Config.StopTimeout")
- c.Assert(res, checker.Contains, "null")
+ assert.Assert(c, strings.Contains(res, "null"))
}
diff --git a/integration-cli/docker_cli_daemon_plugins_test.go b/integration-cli/docker_cli_daemon_plugins_test.go
index 033db85..a581d94 100644
--- a/integration-cli/docker_cli_daemon_plugins_test.go
+++ b/integration-cli/docker_cli_daemon_plugins_test.go
@@ -4,16 +4,16 @@
import (
"strings"
+ "testing"
"github.com/docker/docker/pkg/mount"
- "github.com/go-check/check"
"golang.org/x/sys/unix"
"gotest.tools/assert"
"gotest.tools/icmd"
)
// 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)
s.d.Start(c)
@@ -42,7 +42,7 @@
}
// 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)
s.d.Start(c)
@@ -69,7 +69,7 @@
// TestDaemonKillLiveRestoreWithPlugins SIGKILLs daemon started with --live-restore.
// Plugins should continue to run.
-func (s *DockerDaemonSuite) TestDaemonKillLiveRestoreWithPlugins(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonKillLiveRestoreWithPlugins(c *testing.T) {
testRequires(c, IsAmd64, Network)
s.d.Start(c, "--live-restore")
@@ -95,7 +95,7 @@
// TestDaemonShutdownLiveRestoreWithPlugins SIGTERMs daemon started with --live-restore.
// Plugins should continue to run.
-func (s *DockerDaemonSuite) TestDaemonShutdownLiveRestoreWithPlugins(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonShutdownLiveRestoreWithPlugins(c *testing.T) {
testRequires(c, IsAmd64, Network)
s.d.Start(c, "--live-restore")
@@ -120,7 +120,7 @@
}
// TestDaemonShutdownWithPlugins shuts down running plugins.
-func (s *DockerDaemonSuite) TestDaemonShutdownWithPlugins(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonShutdownWithPlugins(c *testing.T) {
testRequires(c, IsAmd64, Network)
s.d.Start(c)
@@ -158,7 +158,7 @@
}
// TestDaemonKillWithPlugins leaves plugins running.
-func (s *DockerDaemonSuite) TestDaemonKillWithPlugins(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonKillWithPlugins(c *testing.T) {
testRequires(c, IsAmd64, Network)
s.d.Start(c)
@@ -185,7 +185,7 @@
}
// 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)
volName := "plugin-volume"
@@ -231,7 +231,7 @@
assert.NilError(c, err, out)
}
-func (s *DockerDaemonSuite) TestPluginVolumeRemoveOnRestart(c *check.C) {
+func (s *DockerDaemonSuite) TestPluginVolumeRemoveOnRestart(c *testing.T) {
testRequires(c, IsAmd64, Network)
s.d.Start(c, "--live-restore=true")
@@ -272,7 +272,7 @@
return false, nil
}
-func (s *DockerDaemonSuite) TestPluginListFilterEnabled(c *check.C) {
+func (s *DockerDaemonSuite) TestPluginListFilterEnabled(c *testing.T) {
testRequires(c, IsAmd64, Network)
s.d.Start(c)
@@ -300,7 +300,7 @@
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)
s.d.Start(c)
diff --git a/integration-cli/docker_cli_daemon_test.go b/integration-cli/docker_cli_daemon_test.go
index d27e7d7..bf1c2ad 100644
--- a/integration-cli/docker_cli_daemon_test.go
+++ b/integration-cli/docker_cli_daemon_test.go
@@ -21,6 +21,7 @@
"strconv"
"strings"
"sync"
+ "testing"
"time"
"github.com/cloudflare/cfssl/helpers"
@@ -36,17 +37,17 @@
"github.com/docker/go-units"
"github.com/docker/libnetwork/iptables"
"github.com/docker/libtrust"
- "github.com/go-check/check"
"golang.org/x/sys/unix"
"gotest.tools/assert"
"gotest.tools/icmd"
+ "gotest.tools/poll"
)
const containerdSocket = "/var/run/docker/containerd/containerd.sock"
// TestLegacyDaemonCommand test starting docker daemon using "deprecated" docker daemon
// 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")
err := cmd.Start()
go cmd.Wait()
@@ -54,7 +55,7 @@
assert.NilError(c, cmd.Process.Kill())
}
-func (s *DockerDaemonSuite) TestDaemonRestartWithRunningContainersPorts(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonRestartWithRunningContainersPorts(c *testing.T) {
s.d.StartWithBusybox(c)
cli.Docker(
@@ -88,7 +89,7 @@
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)
if out, err := s.d.Cmd("run", "--name", "volrestarttest1", "-v", "/foo", "busybox"); err != nil {
@@ -114,7 +115,7 @@
}
// #11008
-func (s *DockerDaemonSuite) TestDaemonRestartUnlessStopped(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonRestartUnlessStopped(c *testing.T) {
s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "-d", "--name", "top1", "--restart", "always", "busybox:latest", "top")
@@ -130,13 +131,13 @@
var format string
for name, shouldRun := range m {
out, err := s.d.Cmd("ps")
- c.Assert(err, check.IsNil, check.Commentf("run ps: %v", out))
+ assert.Assert(c, err == nil, "run ps: %v", out)
if shouldRun {
format = "%scontainer %q is not running"
} else {
format = "%scontainer %q is running"
}
- c.Assert(strings.Contains(out, name), check.Equals, shouldRun, check.Commentf(format, prefix, name))
+ assert.Equal(c, strings.Contains(out, name), shouldRun, fmt.Sprintf(format, prefix, name))
}
}
@@ -173,7 +174,7 @@
}
-func (s *DockerDaemonSuite) TestDaemonRestartOnFailure(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonRestartOnFailure(c *testing.T) {
s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "-d", "--name", "test1", "--restart", "on-failure:3", "busybox:latest", "false")
@@ -202,12 +203,12 @@
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")
}
// 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)
s.d.Start(c)
@@ -216,7 +217,7 @@
if newBasesizeBytes < oldBasesizeBytes {
err := s.d.RestartWithError("--storage-opt", fmt.Sprintf("dm.basesize=%d", newBasesizeBytes))
- c.Assert(err, check.NotNil, check.Commentf("daemon should not have started as new base device size is less than existing base device size: %v", err))
+ assert.Assert(c, err != nil, "daemon should not have started as new base device size is less than existing base device size: %v", err)
// 'err != nil' is expected behaviour, no new daemon started,
// so no need to stop daemon.
if err != nil {
@@ -227,7 +228,7 @@
}
// 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)
s.d.Start(c)
@@ -240,16 +241,16 @@
}
err := s.d.RestartWithError("--storage-opt", fmt.Sprintf("dm.basesize=%d", newBasesizeBytes))
- c.Assert(err, check.IsNil, check.Commentf("we should have been able to start the daemon with increased base device size: %v", err))
+ assert.Assert(c, err == nil, "we should have been able to start the daemon with increased base device size: %v", err)
basesizeAfterRestart := getBaseDeviceSize(c, s.d)
newBasesize, err := convertBasesize(newBasesizeBytes)
- c.Assert(err, check.IsNil, check.Commentf("Error in converting base device size: %v", err))
- c.Assert(newBasesize, check.Equals, basesizeAfterRestart, check.Commentf("Basesize passed is not equal to Basesize set"))
+ assert.Assert(c, err == nil, "Error in converting base device size: %v", err)
+ assert.Equal(c, newBasesize, basesizeAfterRestart, "Basesize passed is not equal to Basesize set")
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)
for _, statusLine := range info.DriverStatus {
key, value := statusLine[0], statusLine[1]
@@ -261,7 +262,7 @@
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))
assert.NilError(c, err)
return size
@@ -280,7 +281,7 @@
// 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
// 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
// let's start the daemon and stop it, and then make a modification to run the
// actual test
@@ -296,7 +297,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonIptablesClean(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonIptablesClean(c *testing.T) {
s.d.StartWithBusybox(c)
if out, err := s.d.Cmd("run", "-d", "--name", "top", "-p", "80", "busybox:latest", "top"); err != nil {
@@ -314,7 +315,7 @@
verifyIPTablesDoesNotContains(c, ipTablesSearchString)
}
-func (s *DockerDaemonSuite) TestDaemonIptablesCreate(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonIptablesCreate(c *testing.T) {
s.d.StartWithBusybox(c)
if out, err := s.d.Cmd("run", "-d", "--name", "top", "--restart=always", "-p", "80", "busybox:latest", "top"); err != nil {
@@ -340,7 +341,7 @@
verifyIPTablesContains(c, ipTablesSearchString)
}
-func verifyIPTablesContains(c *check.C, ipTablesSearchString string) {
+func verifyIPTablesContains(c *testing.T, ipTablesSearchString string) {
result := icmd.RunCommand("iptables", "-nvL")
result.Assert(c, icmd.Success)
if !strings.Contains(result.Combined(), ipTablesSearchString) {
@@ -348,7 +349,7 @@
}
}
-func verifyIPTablesDoesNotContains(c *check.C, ipTablesSearchString string) {
+func verifyIPTablesDoesNotContains(c *testing.T, ipTablesSearchString string) {
result := icmd.RunCommand("iptables", "-nvL")
result.Assert(c, icmd.Success)
if strings.Contains(result.Combined(), ipTablesSearchString) {
@@ -358,7 +359,7 @@
// 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
-func (s *DockerDaemonSuite) TestDaemonIPv6Enabled(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonIPv6Enabled(c *testing.T) {
testRequires(c, IPv6)
setupV6(c)
@@ -417,7 +418,7 @@
// 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
-func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDR(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDR(c *testing.T) {
// IPv6 setup is messing with local bridge address.
testRequires(c, testEnv.IsLocalDaemon)
// Delete the docker0 bridge if its left around from previous daemon. It has to be recreated with
@@ -434,17 +435,17 @@
out = strings.Trim(out, " \r\n'")
ip := net.ParseIP(out)
- c.Assert(ip, checker.NotNil, check.Commentf("Container should have a global IPv6 address"))
+ assert.Assert(c, ip != nil, "Container should have a global IPv6 address")
out, err = s.d.Cmd("inspect", "--format", "{{.NetworkSettings.Networks.bridge.IPv6Gateway}}", "ipv6test")
assert.NilError(c, err, out)
- c.Assert(strings.Trim(out, " \r\n'"), checker.Equals, "2001:db8:2::100", check.Commentf("Container should have a global IPv6 gateway"))
+ assert.Equal(c, strings.Trim(out, " \r\n'"), "2001:db8:2::100", "Container should have a global IPv6 gateway")
}
// 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
-func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDRAndMac(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDRAndMac(c *testing.T) {
// IPv6 setup is messing with local bridge address.
testRequires(c, testEnv.IsLocalDaemon)
// Delete the docker0 bridge if its left around from previous daemon. It has to be recreated with
@@ -458,12 +459,12 @@
out, err = s.d.Cmd("inspect", "--format", "{{.NetworkSettings.Networks.bridge.GlobalIPv6Address}}", "ipv6test")
assert.NilError(c, err, out)
- c.Assert(strings.Trim(out, " \r\n'"), checker.Equals, "2001:db8:1::aabb:ccdd:eeff")
+ assert.Equal(c, strings.Trim(out, " \r\n'"), "2001:db8:1::aabb:ccdd:eeff")
}
// TestDaemonIPv6HostMode checks that when the running a container with
// 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)
deleteInterface(c, "docker0")
@@ -473,14 +474,14 @@
out, err = s.d.Cmd("exec", "hostcnt", "ip", "-6", "addr", "show", "docker0")
assert.NilError(c, err, out)
- c.Assert(strings.Trim(out, " \r\n'"), checker.Contains, "2001:db8:2::1")
+ assert.Assert(c, strings.Contains(strings.Trim(out, " \r\n'"), "2001:db8:2::1"))
}
-func (s *DockerDaemonSuite) TestDaemonLogLevelWrong(c *check.C) {
- c.Assert(s.d.StartWithError("--log-level=bogus"), check.NotNil, check.Commentf("Daemon shouldn't start with wrong log level"))
+func (s *DockerDaemonSuite) TestDaemonLogLevelWrong(c *testing.T) {
+ assert.Assert(c, s.d.StartWithError("--log-level=bogus") != nil, "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")
content, err := s.d.ReadLogFile()
assert.NilError(c, err)
@@ -489,7 +490,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonLogLevelFatal(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonLogLevelFatal(c *testing.T) {
// we creating new daemons to create new logFile
s.d.Start(c, "--log-level=fatal")
content, err := s.d.ReadLogFile()
@@ -499,7 +500,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonFlagD(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonFlagD(c *testing.T) {
s.d.Start(c, "-D")
content, err := s.d.ReadLogFile()
assert.NilError(c, err)
@@ -508,7 +509,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonFlagDebug(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonFlagDebug(c *testing.T) {
s.d.Start(c, "--debug")
content, err := s.d.ReadLogFile()
assert.NilError(c, err)
@@ -517,7 +518,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonFlagDebugLogLevelFatal(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonFlagDebugLogLevelFatal(c *testing.T) {
s.d.Start(c, "--debug", "--log-level=fatal")
content, err := s.d.ReadLogFile()
assert.NilError(c, err)
@@ -526,7 +527,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonAllocatesListeningPort(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonAllocatesListeningPort(c *testing.T) {
listeningPorts := [][]string{
{"0.0.0.0", "0.0.0.0", "5678"},
{"127.0.0.1", "127.0.0.1", "1234"},
@@ -550,7 +551,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonKeyGeneration(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonKeyGeneration(c *testing.T) {
// TODO: skip or update for Windows daemon
os.Remove("/etc/docker/key.json")
s.d.Start(c)
@@ -570,7 +571,7 @@
// 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
// 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)
if err := s.d.StartWithError("--bridge", "nosuchbridge", "--bip", "1.1.1.1"); err != nil {
//verify we got the right error
@@ -585,7 +586,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonBridgeExternal(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonBridgeExternal(c *testing.T) {
d := s.d
err := d.StartWithError("--bridge", "nosuchbridge")
assert.ErrorContains(c, err, "", `--bridge option with an invalid bridge should cause the daemon to fail`)
@@ -613,7 +614,7 @@
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
d := s.d
d.StartWithBusybox(c, "--bridge", "none")
@@ -632,18 +633,18 @@
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("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("iptables", "-t", "nat", "--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
// 1. Delete the existing docker0 Bridge
// 2. Set --bip daemon configuration and start the new Docker Daemon
@@ -679,13 +680,11 @@
containerIP := d.FindContainerIP(c, "test")
ip = net.ParseIP(containerIP)
- c.Assert(bridgeIPNet.Contains(ip), check.Equals, true,
- check.Commentf("Container IP-Address must be in the same subnet range : %s",
- containerIP))
+ assert.Equal(c, bridgeIPNet.Contains(ip), true, fmt.Sprintf("Container IP-Address must be in the same subnet range : %s", containerIP))
deleteInterface(c, defaultNetworkBridge)
}
-func (s *DockerDaemonSuite) TestDaemonRestartWithBridgeIPChange(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonRestartWithBridgeIPChange(c *testing.T) {
s.d.Start(c)
defer s.d.Restart(c)
s.d.Stop(c)
@@ -705,7 +704,7 @@
})
}
-func (s *DockerDaemonSuite) TestDaemonBridgeFixedCidr(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonBridgeFixedCidr(c *testing.T) {
d := s.d
bridgeName := "external-bridge"
@@ -727,7 +726,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonBridgeFixedCidr2(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonBridgeFixedCidr2(c *testing.T) {
d := s.d
bridgeName := "external-bridge"
@@ -752,7 +751,7 @@
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
bridgeName := "external-bridge"
@@ -770,7 +769,7 @@
defer d.Cmd("stop", cid1)
}
-func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4Implicit(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4Implicit(c *testing.T) {
defaultNetworkBridge := "docker0"
deleteInterface(c, defaultNetworkBridge)
@@ -785,13 +784,11 @@
expectedMessage := fmt.Sprintf("default via %s dev", bridgeIP)
out, err := d.Cmd("run", "busybox", "ip", "-4", "route", "list", "0/0")
assert.NilError(c, err, out)
- c.Assert(strings.Contains(out, expectedMessage), check.Equals, true,
- check.Commentf("Implicit default gateway should be bridge IP %s, but default route was '%s'",
- bridgeIP, strings.TrimSpace(out)))
+ assert.Equal(c, strings.Contains(out, expectedMessage), true, fmt.Sprintf("Implicit default gateway should be bridge IP %s, but default route was '%s'", bridgeIP, strings.TrimSpace(out)))
deleteInterface(c, defaultNetworkBridge)
}
-func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4Explicit(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4Explicit(c *testing.T) {
defaultNetworkBridge := "docker0"
deleteInterface(c, defaultNetworkBridge)
@@ -807,13 +804,11 @@
expectedMessage := fmt.Sprintf("default via %s dev", gatewayIP)
out, err := d.Cmd("run", "busybox", "ip", "-4", "route", "list", "0/0")
assert.NilError(c, err, out)
- c.Assert(strings.Contains(out, expectedMessage), check.Equals, true,
- check.Commentf("Explicit default gateway should be %s, but default route was '%s'",
- gatewayIP, strings.TrimSpace(out)))
+ assert.Equal(c, strings.Contains(out, expectedMessage), true, fmt.Sprintf("Explicit default gateway should be %s, but default route was '%s'", gatewayIP, strings.TrimSpace(out)))
deleteInterface(c, defaultNetworkBridge)
}
-func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4ExplicitOutsideContainerSubnet(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4ExplicitOutsideContainerSubnet(c *testing.T) {
defaultNetworkBridge := "docker0"
deleteInterface(c, defaultNetworkBridge)
@@ -824,7 +819,7 @@
s.d.Restart(c)
}
-func (s *DockerDaemonSuite) TestDaemonDefaultNetworkInvalidClusterConfig(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonDefaultNetworkInvalidClusterConfig(c *testing.T) {
// Start daemon without docker0 bridge
defaultNetworkBridge := "docker0"
@@ -840,7 +835,7 @@
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
ipStr := "192.170.1.1/24"
@@ -850,9 +845,8 @@
defer d.Restart(c)
out, err := d.Cmd("run", "-d", "-p", "8000:8000", "busybox", "top")
- c.Assert(err, check.NotNil,
- check.Commentf("Running a container must fail with an invalid --ip option"))
- c.Assert(strings.Contains(out, "Error starting userland proxy"), check.Equals, true)
+ assert.Assert(c, err != nil, "Running a container must fail with an invalid --ip option")
+ assert.Equal(c, strings.Contains(out, "Error starting userland proxy"), true)
ifName := "dummy"
createInterface(c, "dummy", ifName, ipStr)
@@ -865,11 +859,10 @@
result.Assert(c, icmd.Success)
regex := fmt.Sprintf("DNAT.*%s.*dpt:8000", ip.String())
matched, _ := regexp.MatchString(regex, result.Combined())
- c.Assert(matched, check.Equals, true,
- check.Commentf("iptables output should have contained %q, but was %q", regex, result.Combined()))
+ assert.Equal(c, matched, true, fmt.Sprintf("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)
d := s.d
@@ -886,9 +879,7 @@
result.Assert(c, icmd.Success)
regex := fmt.Sprintf("DROP.*all.*%s.*%s", bridgeName, bridgeName)
matched, _ := regexp.MatchString(regex, result.Combined())
- c.Assert(matched, check.Equals, true,
- check.Commentf("iptables output should have contained %q, but was %q", regex, result.Combined()))
-
+ assert.Equal(c, matched, true, fmt.Sprintf("iptables output should have contained %q, but was %q", regex, result.Combined()))
// Pinging another container must fail with --icc=false
pingContainers(c, d, true)
@@ -905,7 +896,7 @@
assert.NilError(c, err, out)
}
-func (s *DockerDaemonSuite) TestDaemonICCLinkExpose(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonICCLinkExpose(c *testing.T) {
d := s.d
bridgeName := "external-bridge"
@@ -921,9 +912,7 @@
result.Assert(c, icmd.Success)
regex := fmt.Sprintf("DROP.*all.*%s.*%s", bridgeName, bridgeName)
matched, _ := regexp.MatchString(regex, result.Combined())
- c.Assert(matched, check.Equals, true,
- check.Commentf("iptables output should have contained %q, but was %q", regex, result.Combined()))
-
+ assert.Equal(c, matched, true, fmt.Sprintf("iptables output should have contained %q, but was %q", regex, result.Combined()))
out, err := d.Cmd("run", "-d", "--expose", "4567", "--name", "icc1", "busybox", "nc", "-l", "-p", "4567")
assert.NilError(c, err, out)
@@ -931,7 +920,7 @@
assert.NilError(c, err, out)
}
-func (s *DockerDaemonSuite) TestDaemonLinksIpTablesRulesWhenLinkAndUnlink(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonLinksIpTablesRulesWhenLinkAndUnlink(c *testing.T) {
bridgeName := "external-bridge"
bridgeIP := "192.169.1.1/24"
@@ -964,7 +953,7 @@
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")
@@ -1011,7 +1000,7 @@
}
// #11315
-func (s *DockerDaemonSuite) TestDaemonRestartRenameContainer(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonRestartRenameContainer(c *testing.T) {
s.d.StartWithBusybox(c)
if out, err := s.d.Cmd("run", "--name=test", "busybox"); err != nil {
@@ -1029,7 +1018,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonLoggingDriverDefault(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonLoggingDriverDefault(c *testing.T) {
s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "--name=test", "busybox", "echo", "testline")
@@ -1067,7 +1056,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonLoggingDriverDefaultOverride(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonLoggingDriverDefaultOverride(c *testing.T) {
s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "--name=test", "--log-driver=none", "busybox", "echo", "testline")
@@ -1084,7 +1073,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonLoggingDriverNone(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonLoggingDriverNone(c *testing.T) {
s.d.StartWithBusybox(c, "--log-driver=none")
out, err := s.d.Cmd("run", "--name=test", "busybox", "echo", "testline")
@@ -1101,7 +1090,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneOverride(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneOverride(c *testing.T) {
s.d.StartWithBusybox(c, "--log-driver=none")
out, err := s.d.Cmd("run", "--name=test", "--log-driver=json-file", "busybox", "echo", "testline")
@@ -1141,19 +1130,19 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneLogsError(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneLogsError(c *testing.T) {
s.d.StartWithBusybox(c, "--log-driver=none")
out, err := s.d.Cmd("run", "--name=test", "busybox", "echo", "testline")
assert.NilError(c, err, out)
out, err = s.d.Cmd("logs", "test")
- c.Assert(err, check.NotNil, check.Commentf("Logs should fail with 'none' driver"))
+ assert.Assert(c, err != nil, "Logs should fail with 'none' driver")
expected := `configured logging driver does not support reading`
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")
result := cli.BuildCmd(c, "busyboxs", cli.Daemon(s.d),
@@ -1162,13 +1151,13 @@
RUN echo foo`),
build.WithoutCache,
)
- comment := check.Commentf("Failed to build image. output %s, exitCode %d, err %v", result.Combined(), result.ExitCode, result.Error)
- c.Assert(result.Error, check.IsNil, comment)
- c.Assert(result.ExitCode, check.Equals, 0, comment)
- c.Assert(result.Combined(), checker.Contains, "foo", comment)
+ comment := fmt.Sprintf("Failed to build image. output %s, exitCode %d, err %v", result.Combined(), result.ExitCode, result.Error)
+ assert.Assert(c, result.Error == nil, comment)
+ assert.Equal(c, result.ExitCode, 0, comment)
+ assert.Assert(c, strings.Contains(result.Combined(), "foo"), comment)
}
-func (s *DockerDaemonSuite) TestDaemonUnixSockCleanedUp(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonUnixSockCleanedUp(c *testing.T) {
dir, err := ioutil.TempDir("", "socket-cleanup-test")
if err != nil {
c.Fatal(err)
@@ -1189,7 +1178,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonWithWrongkey(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonWithWrongkey(c *testing.T) {
type Config struct {
Crv string `json:"crv"`
D string `json:"d"`
@@ -1235,14 +1224,14 @@
}
content, err := s.d.ReadLogFile()
- c.Assert(err, checker.IsNil)
+ assert.Assert(c, err == nil)
if !strings.Contains(string(content), "Public Key ID does not match") {
c.Fatalf("Missing KeyID message from daemon logs: %s", string(content))
}
}
-func (s *DockerDaemonSuite) TestDaemonRestartKillWait(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonRestartKillWait(c *testing.T) {
s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "-id", "busybox", "/bin/cat")
@@ -1276,7 +1265,7 @@
}
// 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 (
testDaemonHTTPSAddr = "tcp://localhost:4271"
)
@@ -1304,7 +1293,7 @@
// TestHTTPSRun connects via two-way authenticated HTTPS to the create, attach, start, and wait endpoints.
// https://github.com/docker/docker/issues/19280
-func (s *DockerDaemonSuite) TestHTTPSRun(c *check.C) {
+func (s *DockerDaemonSuite) TestHTTPSRun(c *testing.T) {
const (
testDaemonHTTPSAddr = "tcp://localhost:4271"
)
@@ -1330,7 +1319,7 @@
}
// 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()
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))
@@ -1339,7 +1328,7 @@
// 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.
-func (s *DockerDaemonSuite) TestHTTPSInfoRogueCert(c *check.C) {
+func (s *DockerDaemonSuite) TestHTTPSInfoRogueCert(c *testing.T) {
const (
errBadCertificate = "bad certificate"
testDaemonHTTPSAddr = "tcp://localhost:4271"
@@ -1368,7 +1357,7 @@
// 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
-func (s *DockerDaemonSuite) TestHTTPSInfoRogueServerCert(c *check.C) {
+func (s *DockerDaemonSuite) TestHTTPSInfoRogueServerCert(c *testing.T) {
const (
errCaUnknown = "x509: certificate signed by unknown authority"
testDaemonRogueHTTPSAddr = "tcp://localhost:4272"
@@ -1394,7 +1383,7 @@
}
}
-func pingContainers(c *check.C, d *daemon.Daemon, expectFailure bool) {
+func pingContainers(c *testing.T, d *daemon.Daemon, expectFailure bool) {
var dargs []string
if d != nil {
dargs = []string{"--host", d.Sock()}
@@ -1418,7 +1407,7 @@
dockerCmd(c, args...)
}
-func (s *DockerDaemonSuite) TestDaemonRestartWithSocketAsVolume(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonRestartWithSocketAsVolume(c *testing.T) {
s.d.StartWithBusybox(c)
socket := filepath.Join(s.d.Folder, "docker.sock")
@@ -1430,7 +1419,7 @@
// os.Kill should kill daemon ungracefully, leaving behind container 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.StartWithBusybox(c)
@@ -1468,7 +1457,7 @@
}
// 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.StartWithBusybox(c)
@@ -1487,7 +1476,7 @@
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)
if out, err := s.d.Cmd("run", "-d", "--name", "test", "busybox", "top"); err != nil {
t.Fatal(out, err)
@@ -1500,7 +1489,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonRestartCleanupNetns(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonRestartCleanupNetns(c *testing.T) {
s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "--name", "netns", "-d", "busybox", "top")
if err != nil {
@@ -1538,7 +1527,7 @@
}
// 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"
s.d.Start(c, "-H", host)
icmd.RunCmd(icmd.Cmd{
@@ -1550,18 +1539,18 @@
})
}
-func setupV6(c *check.C) {
+func setupV6(c *testing.T) {
// 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.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.Assert(c, icmd.Success)
}
-func (s *DockerDaemonSuite) TestDaemonRestartWithContainerWithRestartPolicyAlways(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonRestartWithContainerWithRestartPolicyAlways(c *testing.T) {
s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "-d", "--restart", "always", "busybox", "top")
@@ -1581,10 +1570,10 @@
out, err = s.d.Cmd("ps", "-q")
assert.NilError(c, err, out)
- c.Assert(strings.TrimSpace(out), check.Equals, id[:12])
+ assert.Equal(c, strings.TrimSpace(out), 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")
name := "logtest"
out, err := s.d.Cmd("run", "-d", "--log-opt=max-file=5", "--name", name, "busybox", "top")
@@ -1600,7 +1589,7 @@
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)
if out, err := s.d.Cmd("run", "-i", "-d", "--name", "test", "busybox", "top"); err != nil {
c.Fatal(err, out)
@@ -1633,7 +1622,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonRestartRmVolumeInUse(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonRestartRmVolumeInUse(c *testing.T) {
s.d.StartWithBusybox(c)
out, err := s.d.Cmd("create", "-v", "test:/foo", "busybox")
@@ -1642,11 +1631,11 @@
s.d.Restart(c)
out, err = s.d.Cmd("volume", "rm", "test")
- c.Assert(err, check.NotNil, check.Commentf("should not be able to remove in use volume after daemon restart"))
- c.Assert(out, checker.Contains, "in use")
+ assert.Assert(c, err != nil, "should not be able to remove in use volume after daemon restart")
+ assert.Assert(c, strings.Contains(out, "in use"))
}
-func (s *DockerDaemonSuite) TestDaemonRestartLocalVolumes(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonRestartLocalVolumes(c *testing.T) {
s.d.Start(c)
out, err := s.d.Cmd("volume", "create", "test")
@@ -1658,23 +1647,23 @@
}
// 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))
- c.Assert(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") != nil)
expected := "syslog-address should be in form proto://address"
icmd.RunCommand("grep", expected, d.LogFileName()).Assert(c, icmd.Success)
}
// 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))
- c.Assert(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") != nil)
expected := "invalid fluentd-address corrupted:c: "
icmd.RunCommand("grep", expected, d.LogFileName()).Assert(c, icmd.Success)
}
// 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
defer func() {
s.d.UseDefaultHost = false
@@ -1683,7 +1672,7 @@
}
// 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
defer func() {
s.d.UseDefaultTLSHost = false
@@ -1737,12 +1726,12 @@
assert.NilError(c, err)
conn.Close()
- c.Assert(certRequestInfo, checker.NotNil)
- c.Assert(certRequestInfo.AcceptableCAs, checker.HasLen, 1)
- c.Assert(certRequestInfo.AcceptableCAs[0], checker.DeepEquals, rootCert.RawSubject)
+ assert.Assert(c, certRequestInfo != nil)
+ assert.Equal(c, len(certRequestInfo.AcceptableCAs), 1)
+ assert.DeepEqual(c, certRequestInfo.AcceptableCAs[0], rootCert.RawSubject)
}
-func (s *DockerDaemonSuite) TestBridgeIPIsExcludedFromAllocatorPool(c *check.C) {
+func (s *DockerDaemonSuite) TestBridgeIPIsExcludedFromAllocatorPool(c *testing.T) {
defaultNetworkBridge := "docker0"
deleteInterface(c, defaultNetworkBridge)
@@ -1761,21 +1750,21 @@
break
}
ip, err := s.d.Cmd("inspect", "--format", "'{{.NetworkSettings.IPAddress}}'", contName)
- c.Assert(err, check.IsNil, check.Commentf("%s", ip))
+ assert.Assert(c, err == nil, "%s", ip)
- c.Assert(ip, check.Not(check.Equals), bridgeIP)
+ assert.Assert(c, ip != bridgeIP)
cont++
}
}
// 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)
testDir, err := ioutil.TempDir("", "no-space-left-on-device-test")
assert.NilError(c, err)
defer os.RemoveAll(testDir)
- c.Assert(mount.MakeRShared(testDir), checker.IsNil)
+ assert.Assert(c, mount.MakeRShared(testDir) == nil)
defer mount.Unmount(testDir)
// create a 3MiB image (with a 2MiB ext4 fs) and mount it as graph root
@@ -1791,12 +1780,12 @@
// pull a repository large enough to overfill the mounted filesystem
pullOut, err := s.d.Cmd("pull", "debian:stretch")
- c.Assert(err, checker.NotNil, check.Commentf("%s", pullOut))
- c.Assert(pullOut, checker.Contains, "no space left on device")
+ assert.Assert(c, err != nil, "%s", pullOut)
+ assert.Assert(c, strings.Contains(pullOut, "no space left on device"))
}
// 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)
var parent1Args []string
@@ -1854,7 +1843,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonCgroupParent(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonCgroupParent(c *testing.T) {
testRequires(c, DaemonIsLinux)
cgroupParent := "test"
@@ -1866,7 +1855,7 @@
out, err := s.d.Cmd("run", "--name", name, "busybox", "cat", "/proc/self/cgroup")
assert.NilError(c, err)
cgroupPaths := ParseCgroupPaths(string(out))
- c.Assert(len(cgroupPaths), checker.Not(checker.Equals), 0, check.Commentf("unexpected output - %q", string(out)))
+ assert.Assert(c, len(cgroupPaths) != 0, "unexpected output - %q", string(out))
out, err = s.d.Cmd("inspect", "-f", "{{.Id}}", name)
assert.NilError(c, err)
id := strings.TrimSpace(string(out))
@@ -1878,10 +1867,10 @@
break
}
}
- c.Assert(found, checker.True, check.Commentf("Cgroup path for container (%s) doesn't found in cgroups file: %s", expectedCgroup, cgroupPaths))
+ assert.Assert(c, found, "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
s.d.StartWithBusybox(c)
@@ -1901,10 +1890,10 @@
assert.NilError(c, err, out)
out, err = s.d.Cmd("start", "-a", "test2")
assert.NilError(c, err, out)
- c.Assert(strings.Contains(out, "1 packets transmitted, 1 packets received"), check.Equals, true, check.Commentf("%s", out))
+ assert.Equal(c, strings.Contains(out, "1 packets transmitted, 1 packets received"), true, fmt.Sprintf("%s", out))
}
-func (s *DockerDaemonSuite) TestDaemonRestartWithNames(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonRestartWithNames(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows does not support links
s.d.StartWithBusybox(c)
@@ -1952,7 +1941,7 @@
}
// TestDaemonRestartWithKilledRunningContainer requires live restore of running containers
-func (s *DockerDaemonSuite) TestDaemonRestartWithKilledRunningContainer(t *check.C) {
+func (s *DockerDaemonSuite) TestDaemonRestartWithKilledRunningContainer(t *testing.T) {
testRequires(t, DaemonIsLinux)
s.d.StartWithBusybox(t)
@@ -2002,7 +1991,7 @@
// os.Kill should kill daemon ungracefully, leaving behind live containers.
// The live containers should be known to the restarted daemon. Stopping
// them now, should remove the mounts.
-func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonCrash(c *check.C) {
+func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonCrash(c *testing.T) {
testRequires(c, DaemonIsLinux)
s.d.StartWithBusybox(c, "--live-restore")
@@ -2011,14 +2000,14 @@
id := strings.TrimSpace(out)
// kill the daemon
- c.Assert(s.d.Kill(), check.IsNil)
+ assert.Assert(c, s.d.Kill() == nil)
// Check if there are mounts with container id visible from the host.
// If not, those mounts exist in container's own mount ns, and so
// the following check for mounts being cleared is pointless.
skipMountCheck := false
mountOut, err := ioutil.ReadFile("/proc/self/mountinfo")
- c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
+ assert.Assert(c, err == nil, "Output: %s", mountOut)
if !strings.Contains(string(mountOut), id) {
skipMountCheck = true
}
@@ -2043,13 +2032,13 @@
}
// Now, container mounts should be gone.
mountOut, err = ioutil.ReadFile("/proc/self/mountinfo")
- c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
- comment := check.Commentf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.Root, mountOut)
- c.Assert(strings.Contains(string(mountOut), id), check.Equals, false, comment)
+ assert.Assert(c, err == nil, "Output: %s", mountOut)
+ comment := fmt.Sprintf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.Root, mountOut)
+ assert.Equal(c, strings.Contains(string(mountOut), id), false, comment)
}
// TestDaemonRestartWithUnpausedRunningContainer requires live restore of running containers.
-func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *check.C) {
+func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *testing.T) {
testRequires(t, DaemonIsLinux)
s.d.StartWithBusybox(t, "--live-restore")
@@ -2083,10 +2072,10 @@
// Give time to containerd to process the command if we don't
// the resume event might be received after we do the inspect
- waitAndAssert(t, defaultReconciliationTimeout, func(*check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(t, pollCheck(t, func(*testing.T) (interface{}, string) {
result := icmd.RunCommand("kill", "-0", strings.TrimSpace(pid))
- return result.ExitCode, nil
- }, checker.Equals, 0)
+ return result.ExitCode, ""
+ }, checker.Equals(0)), poll.WithTimeout(defaultReconciliationTimeout))
// restart the daemon
s.d.Start(t, "--live-restore")
@@ -2106,7 +2095,7 @@
// 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
-func (s *DockerDaemonSuite) TestRunLinksChanged(c *check.C) {
+func (s *DockerDaemonSuite) TestRunLinksChanged(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows does not support links
s.d.StartWithBusybox(c)
@@ -2115,8 +2104,7 @@
out, err = s.d.Cmd("run", "--name=test2", "--link=test:abc", "busybox", "sh", "-c", "ping -c 1 abc")
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, "1 packets transmitted, 1 packets received")
-
+ assert.Assert(c, strings.Contains(out, "1 packets transmitted, 1 packets received"))
out, err = s.d.Cmd("rm", "-f", "test")
assert.NilError(c, err, out)
@@ -2124,15 +2112,14 @@
assert.NilError(c, err, out)
out, err = s.d.Cmd("start", "-a", "test2")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, check.Not(checker.Contains), "1 packets transmitted, 1 packets received")
-
+ assert.Assert(c, !strings.Contains(out, "1 packets transmitted, 1 packets received"))
s.d.Restart(c)
out, err = s.d.Cmd("start", "-a", "test2")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, check.Not(checker.Contains), "1 packets transmitted, 1 packets received")
+ assert.Assert(c, !strings.Contains(out, "1 packets transmitted, 1 packets received"))
}
-func (s *DockerDaemonSuite) TestDaemonStartWithoutColors(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonStartWithoutColors(c *testing.T) {
testRequires(c, DaemonIsLinux)
infoLog := "\x1b[36mINFO\x1b"
@@ -2157,8 +2144,7 @@
s.d.Stop(c)
// Wait for io.Copy() before checking output
<-done
- c.Assert(b.String(), checker.Contains, infoLog)
-
+ assert.Assert(c, strings.Contains(b.String(), infoLog))
b.Reset()
// "tty" is already closed in prev s.d.Stop(),
@@ -2178,11 +2164,11 @@
s.d.Stop(c)
// Wait for io.Copy() before checking output
<-done
- c.Assert(b.String(), check.Not(check.Equals), "")
- c.Assert(b.String(), check.Not(checker.Contains), infoLog)
+ assert.Assert(c, b.String() != "")
+ assert.Assert(c, !strings.Contains(b.String(), infoLog))
}
-func (s *DockerDaemonSuite) TestDaemonDebugLog(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonDebugLog(c *testing.T) {
testRequires(c, DaemonIsLinux)
debugLog := "\x1b[37mDEBU\x1b"
@@ -2199,16 +2185,16 @@
s.d.StartWithLogFile(tty, "--debug")
s.d.Stop(c)
- c.Assert(b.String(), checker.Contains, debugLog)
+ assert.Assert(c, strings.Contains(b.String(), debugLog))
}
-func (s *DockerDaemonSuite) TestDaemonDiscoveryBackendConfigReload(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonDiscoveryBackendConfigReload(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
// daemon config file
daemonConfig := `{ "debug" : false }`
configFile, err := ioutil.TempFile("", "test-daemon-discovery-backend-config-reload-config")
- c.Assert(err, checker.IsNil, check.Commentf("could not create temp file for config reload"))
+ assert.Assert(c, err == nil, "could not create temp file for config reload")
configFilePath := configFile.Name()
defer func() {
configFile.Close()
@@ -2238,17 +2224,17 @@
assert.NilError(c, err)
err = s.d.ReloadConfig()
- c.Assert(err, checker.IsNil, check.Commentf("error reloading daemon config"))
+ assert.Assert(c, err == nil, "error reloading daemon config")
out, err := s.d.Cmd("info")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, fmt.Sprintf("Cluster Store: consul://consuladdr:consulport/some/path"))
- c.Assert(out, checker.Contains, fmt.Sprintf("Cluster Advertise: 192.168.56.100:0"))
+ assert.Assert(c, strings.Contains(out, "Cluster Store: consul://consuladdr:consulport/some/path"))
+ assert.Assert(c, strings.Contains(out, "Cluster Advertise: 192.168.56.100:0"))
}
// 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")
out, err := s.d.Cmd("run", "-d", "--log-driver=json-file", "busybox", "top")
@@ -2257,23 +2243,23 @@
out, err = s.d.Cmd("inspect", "--format='{{.HostConfig.LogConfig}}'", id)
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, "{json-file map[]}")
+ assert.Assert(c, strings.Contains(out, "{json-file map[]}"))
}
// 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")
expectedMaxConcurrentUploads := `level=debug msg="Max Concurrent Uploads: 6"`
expectedMaxConcurrentDownloads := `level=debug msg="Max Concurrent Downloads: 8"`
content, err := s.d.ReadLogFile()
assert.NilError(c, err)
- c.Assert(string(content), checker.Contains, expectedMaxConcurrentUploads)
- c.Assert(string(content), checker.Contains, expectedMaxConcurrentDownloads)
+ assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentUploads))
+ assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentDownloads))
}
// Test case for #20936, #22443
-func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFile(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFile(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
// daemon config file
@@ -2291,16 +2277,15 @@
expectedMaxConcurrentDownloads := `level=debug msg="Max Concurrent Downloads: 8"`
content, err := s.d.ReadLogFile()
assert.NilError(c, err)
- c.Assert(string(content), checker.Contains, expectedMaxConcurrentUploads)
- c.Assert(string(content), checker.Contains, expectedMaxConcurrentDownloads)
-
+ assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentUploads))
+ assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentDownloads))
configFile, err = os.Create(configFilePath)
assert.NilError(c, err)
daemonConfig = `{ "max-concurrent-uploads" : 7, "max-concurrent-downloads" : 9 }`
fmt.Fprintf(configFile, "%s", daemonConfig)
configFile.Close()
- c.Assert(s.d.Signal(unix.SIGHUP), checker.IsNil)
+ assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
// unix.Kill(s.d.cmd.Process.Pid, unix.SIGHUP)
time.Sleep(3 * time.Second)
@@ -2309,12 +2294,12 @@
expectedMaxConcurrentDownloads = `level=debug msg="Reset Max Concurrent Downloads: 9"`
content, err = s.d.ReadLogFile()
assert.NilError(c, err)
- c.Assert(string(content), checker.Contains, expectedMaxConcurrentUploads)
- c.Assert(string(content), checker.Contains, expectedMaxConcurrentDownloads)
+ assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentUploads))
+ assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentDownloads))
}
// Test case for #20936, #22443
-func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
// daemon config file
@@ -2332,16 +2317,15 @@
expectedMaxConcurrentDownloads := `level=debug msg="Max Concurrent Downloads: 3"`
content, err := s.d.ReadLogFile()
assert.NilError(c, err)
- c.Assert(string(content), checker.Contains, expectedMaxConcurrentUploads)
- c.Assert(string(content), checker.Contains, expectedMaxConcurrentDownloads)
-
+ assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentUploads))
+ assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentDownloads))
configFile, err = os.Create(configFilePath)
assert.NilError(c, err)
daemonConfig = `{ "max-concurrent-uploads" : 1, "max-concurrent-downloads" : null }`
fmt.Fprintf(configFile, "%s", daemonConfig)
configFile.Close()
- c.Assert(s.d.Signal(unix.SIGHUP), checker.IsNil)
+ assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
// unix.Kill(s.d.cmd.Process.Pid, unix.SIGHUP)
time.Sleep(3 * time.Second)
@@ -2350,16 +2334,15 @@
expectedMaxConcurrentDownloads = `level=debug msg="Reset Max Concurrent Downloads: 3"`
content, err = s.d.ReadLogFile()
assert.NilError(c, err)
- c.Assert(string(content), checker.Contains, expectedMaxConcurrentUploads)
- c.Assert(string(content), checker.Contains, expectedMaxConcurrentDownloads)
-
+ assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentUploads))
+ assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentDownloads))
configFile, err = os.Create(configFilePath)
assert.NilError(c, err)
daemonConfig = `{ "labels":["foo=bar"] }`
fmt.Fprintf(configFile, "%s", daemonConfig)
configFile.Close()
- c.Assert(s.d.Signal(unix.SIGHUP), checker.IsNil)
+ assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
time.Sleep(3 * time.Second)
@@ -2367,11 +2350,11 @@
expectedMaxConcurrentDownloads = `level=debug msg="Reset Max Concurrent Downloads: 3"`
content, err = s.d.ReadLogFile()
assert.NilError(c, err)
- c.Assert(string(content), checker.Contains, expectedMaxConcurrentUploads)
- c.Assert(string(content), checker.Contains, expectedMaxConcurrentDownloads)
+ assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentUploads))
+ assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentDownloads))
}
-func (s *DockerDaemonSuite) TestBuildOnDisabledBridgeNetworkDaemon(c *check.C) {
+func (s *DockerDaemonSuite) TestBuildOnDisabledBridgeNetworkDaemon(c *testing.T) {
s.d.StartWithBusybox(c, "-b=none", "--iptables=false")
result := cli.BuildCmd(c, "busyboxs", cli.Daemon(s.d),
@@ -2380,27 +2363,27 @@
RUN cat /etc/hosts`),
build.WithoutCache,
)
- comment := check.Commentf("Failed to build image. output %s, exitCode %d, err %v", result.Combined(), result.ExitCode, result.Error)
- c.Assert(result.Error, check.IsNil, comment)
- c.Assert(result.ExitCode, check.Equals, 0, comment)
+ comment := fmt.Sprintf("Failed to build image. output %s, exitCode %d, err %v", result.Combined(), result.ExitCode, result.Error)
+ assert.Assert(c, result.Error == nil, comment)
+ assert.Equal(c, result.ExitCode, 0, comment)
}
// Test case for #21976
-func (s *DockerDaemonSuite) TestDaemonDNSFlagsInHostMode(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonDNSFlagsInHostMode(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
s.d.StartWithBusybox(c, "--dns", "1.2.3.4", "--dns-search", "example.com", "--dns-opt", "timeout:3")
expectedOutput := "nameserver 1.2.3.4"
out, _ := s.d.Cmd("run", "--net=host", "busybox", "cat", "/etc/resolv.conf")
- c.Assert(out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
+ assert.Assert(c, strings.Contains(out, expectedOutput), "Expected '%s', but got %q", expectedOutput, out)
expectedOutput = "search example.com"
- c.Assert(out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
+ assert.Assert(c, strings.Contains(out, expectedOutput), "Expected '%s', but got %q", expectedOutput, out)
expectedOutput = "options timeout:3"
- c.Assert(out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
+ assert.Assert(c, strings.Contains(out, expectedOutput), "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-")
assert.NilError(c, err)
configName := conf.Name()
@@ -2440,8 +2423,7 @@
// Run with "vm"
out, err = s.d.Cmd("run", "--rm", "--runtime=vm", "busybox", "ls")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "/usr/local/bin/vm-manager: no such file or directory")
-
+ assert.Assert(c, strings.Contains(out, "/usr/local/bin/vm-manager: no such file or directory"))
// Reset config to only have the default
config = `
{
@@ -2450,7 +2432,7 @@
}
`
ioutil.WriteFile(configName, []byte(config), 0644)
- c.Assert(s.d.Signal(unix.SIGHUP), checker.IsNil)
+ assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
// Give daemon time to reload config
<-time.After(1 * time.Second)
@@ -2461,13 +2443,11 @@
// Run with "oci"
out, err = s.d.Cmd("run", "--rm", "--runtime=oci", "busybox", "ls")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "Unknown runtime specified oci")
-
+ assert.Assert(c, strings.Contains(out, "Unknown runtime specified oci"))
// Start previously created container with oci
out, err = s.d.Cmd("start", "oci-runtime-ls")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "Unknown runtime specified oci")
-
+ assert.Assert(c, strings.Contains(out, "Unknown runtime specified oci"))
// Check that we can't override the default runtime
config = `
{
@@ -2479,14 +2459,13 @@
}
`
ioutil.WriteFile(configName, []byte(config), 0644)
- c.Assert(s.d.Signal(unix.SIGHUP), checker.IsNil)
+ assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
// Give daemon time to reload config
<-time.After(1 * time.Second)
content, err := s.d.ReadLogFile()
assert.NilError(c, err)
- c.Assert(string(content), checker.Contains, `file configuration validation failed: runtime name 'runc' is reserved`)
-
+ assert.Assert(c, strings.Contains(string(content), `file configuration validation failed: runtime name 'runc' is reserved`))
// Check that we can select a default runtime
config = `
{
@@ -2505,20 +2484,19 @@
}
`
ioutil.WriteFile(configName, []byte(config), 0644)
- c.Assert(s.d.Signal(unix.SIGHUP), checker.IsNil)
+ assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
// Give daemon time to reload config
<-time.After(1 * time.Second)
out, err = s.d.Cmd("run", "--rm", "busybox", "ls")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "/usr/local/bin/vm-manager: no such file or directory")
-
+ assert.Assert(c, strings.Contains(out, "/usr/local/bin/vm-manager: no such file or directory"))
// Run with default runtime explicitly
out, err = s.d.Cmd("run", "--rm", "--runtime=runc", "busybox", "ls")
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")
// Run with default runtime
@@ -2536,8 +2514,7 @@
// Run with "vm"
out, err = s.d.Cmd("run", "--rm", "--runtime=vm", "busybox", "ls")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "/usr/local/bin/vm-manager: no such file or directory")
-
+ assert.Assert(c, strings.Contains(out, "/usr/local/bin/vm-manager: no such file or directory"))
// Start a daemon without any extra runtimes
s.d.Stop(c)
s.d.StartWithBusybox(c)
@@ -2549,59 +2526,54 @@
// Run with "oci"
out, err = s.d.Cmd("run", "--rm", "--runtime=oci", "busybox", "ls")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "Unknown runtime specified oci")
-
+ assert.Assert(c, strings.Contains(out, "Unknown runtime specified oci"))
// Start previously created container with oci
out, err = s.d.Cmd("start", "oci-runtime-ls")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "Unknown runtime specified oci")
-
+ assert.Assert(c, strings.Contains(out, "Unknown runtime specified oci"))
// Check that we can't override the default runtime
s.d.Stop(c)
- c.Assert(s.d.StartWithError("--add-runtime", "runc=my-runc"), checker.NotNil)
+ assert.Assert(c, s.d.StartWithError("--add-runtime", "runc=my-runc") != nil)
content, err := s.d.ReadLogFile()
assert.NilError(c, err)
- c.Assert(string(content), checker.Contains, `runtime name 'runc' is reserved`)
-
+ assert.Assert(c, strings.Contains(string(content), `runtime name 'runc' is reserved`))
// Check that we can select a default runtime
s.d.Stop(c)
s.d.StartWithBusybox(c, "--default-runtime=vm", "--add-runtime", "oci=runc", "--add-runtime", "vm=/usr/local/bin/vm-manager")
out, err = s.d.Cmd("run", "--rm", "busybox", "ls")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "/usr/local/bin/vm-manager: no such file or directory")
-
+ assert.Assert(c, strings.Contains(out, "/usr/local/bin/vm-manager: no such file or directory"))
// Run with default runtime explicitly
out, err = s.d.Cmd("run", "--rm", "--runtime=runc", "busybox", "ls")
assert.NilError(c, err, out)
}
-func (s *DockerDaemonSuite) TestDaemonRestartWithAutoRemoveContainer(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonRestartWithAutoRemoveContainer(c *testing.T) {
s.d.StartWithBusybox(c)
// top1 will exist after daemon restarts
out, err := s.d.Cmd("run", "-d", "--name", "top1", "busybox:latest", "top")
- c.Assert(err, checker.IsNil, check.Commentf("run top1: %v", out))
+ assert.Assert(c, err == nil, "run top1: %v", out)
// top2 will be removed after daemon restarts
out, err = s.d.Cmd("run", "-d", "--rm", "--name", "top2", "busybox:latest", "top")
- c.Assert(err, checker.IsNil, check.Commentf("run top2: %v", out))
+ assert.Assert(c, err == nil, "run top2: %v", out)
out, err = s.d.Cmd("ps")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, "top1", check.Commentf("top1 should be running"))
- c.Assert(out, checker.Contains, "top2", check.Commentf("top2 should be running"))
-
+ assert.Assert(c, strings.Contains(out, "top1"), "top1 should be running")
+ assert.Assert(c, strings.Contains(out, "top2"), "top2 should be running")
// now restart daemon gracefully
s.d.Restart(c)
out, err = s.d.Cmd("ps", "-a")
assert.NilError(c, err, "out: %v", out)
- c.Assert(out, checker.Contains, "top1", check.Commentf("top1 should exist after daemon restarts"))
- c.Assert(out, checker.Not(checker.Contains), "top2", check.Commentf("top2 should be removed after daemon restarts"))
+ assert.Assert(c, strings.Contains(out, "top1"), "top1 should exist after daemon restarts")
+ assert.Assert(c, !strings.Contains(out, "top2"), "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)
containerName := "error-values"
@@ -2625,8 +2597,7 @@
errMsg1, err := s.d.Cmd("inspect", "-f", "{{.State.Error}}", containerName)
errMsg1 = strings.TrimSpace(errMsg1)
assert.NilError(c, err)
- c.Assert(errMsg1, checker.Contains, "executable file not found")
-
+ assert.Assert(c, strings.Contains(errMsg1, "executable file not found"))
// now restart daemon
s.d.Restart(c)
@@ -2642,7 +2613,7 @@
assert.Equal(c, out, errMsg1)
}
-func (s *DockerDaemonSuite) TestDaemonWithUserlandProxyPath(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonWithUserlandProxyPath(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
dockerProxyPath, err := exec.LookPath("docker-proxy")
@@ -2668,19 +2639,19 @@
s.d.Restart(c, "--userland-proxy-path", "/does/not/exist")
out, err = s.d.Cmd("run", "-p", "5000:5000", "busybox:latest", "true")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "driver failed programming external connectivity on endpoint")
- c.Assert(out, checker.Contains, "/does/not/exist: no such file or directory")
+ assert.Assert(c, strings.Contains(out, "driver failed programming external connectivity on endpoint"))
+ assert.Assert(c, strings.Contains(out, "/does/not/exist: no such file or directory"))
}
// Test case for #22471
-func (s *DockerDaemonSuite) TestDaemonShutdownTimeout(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonShutdownTimeout(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
s.d.StartWithBusybox(c, "--shutdown-timeout=3")
_, err := s.d.Cmd("run", "-d", "busybox", "top")
assert.NilError(c, err)
- c.Assert(s.d.Signal(unix.SIGINT), checker.IsNil)
+ assert.Assert(c, s.d.Signal(unix.SIGINT) == nil)
select {
case <-s.d.Wait:
@@ -2690,11 +2661,11 @@
expectedMessage := `level=debug msg="daemon configured with a 3 seconds minimum shutdown timeout"`
content, err := s.d.ReadLogFile()
assert.NilError(c, err)
- c.Assert(string(content), checker.Contains, expectedMessage)
+ assert.Assert(c, strings.Contains(string(content), expectedMessage))
}
// Test case for #22471
-func (s *DockerDaemonSuite) TestDaemonShutdownTimeoutWithConfigFile(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonShutdownTimeoutWithConfigFile(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
// daemon config file
@@ -2714,7 +2685,7 @@
fmt.Fprintf(configFile, "%s", daemonConfig)
configFile.Close()
- c.Assert(s.d.Signal(unix.SIGHUP), checker.IsNil)
+ assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
select {
case <-s.d.Wait:
@@ -2724,11 +2695,11 @@
expectedMessage := `level=debug msg="Reset Shutdown Timeout: 5"`
content, err := s.d.ReadLogFile()
assert.NilError(c, err)
- c.Assert(string(content), checker.Contains, expectedMessage)
+ assert.Assert(c, strings.Contains(string(content), expectedMessage))
}
// Test case for 29342
-func (s *DockerDaemonSuite) TestExecWithUserAfterLiveRestore(c *check.C) {
+func (s *DockerDaemonSuite) TestExecWithUserAfterLiveRestore(c *testing.T) {
testRequires(c, DaemonIsLinux)
s.d.StartWithBusybox(c, "--live-restore")
@@ -2739,24 +2710,24 @@
// Wait for shell command to be completed
_, err = s.d.Cmd("exec", "top", "sh", "-c", `for i in $(seq 1 5); do if [ -e /adduser_end ]; then rm -f /adduser_end && break; else sleep 1 && false; fi; done`)
- c.Assert(err, check.IsNil, check.Commentf("Timeout waiting for shell command to be completed"))
+ assert.Assert(c, err == nil, "Timeout waiting for shell command to be completed")
out1, err := s.d.Cmd("exec", "-u", "test", "top", "id")
// uid=100(test) gid=101(test) groups=101(test)
- c.Assert(err, check.IsNil, check.Commentf("Output: %s", out1))
+ assert.Assert(c, err == nil, "Output: %s", out1)
// restart daemon.
s.d.Restart(c, "--live-restore")
out2, err := s.d.Cmd("exec", "-u", "test", "top", "id")
- c.Assert(err, check.IsNil, check.Commentf("Output: %s", out2))
- c.Assert(out2, check.Equals, out1, check.Commentf("Output: before restart '%s', after restart '%s'", out1, out2))
+ assert.Assert(c, err == nil, "Output: %s", out2)
+ assert.Equal(c, out2, out1, fmt.Sprintf("Output: before restart '%s', after restart '%s'", out1, out2))
out, err = s.d.Cmd("stop", "top")
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)
s.d.StartWithBusybox(c, "--live-restore", "--storage-driver", "overlay")
out, err := s.d.Cmd("run", "-d", "--name=top", "busybox", "top")
@@ -2789,7 +2760,7 @@
}
// #29598
-func (s *DockerDaemonSuite) TestRestartPolicyWithLiveRestore(c *check.C) {
+func (s *DockerDaemonSuite) TestRestartPolicyWithLiveRestore(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
s.d.StartWithBusybox(c, "--live-restore")
@@ -2802,7 +2773,7 @@
StartedAt time.Time
}
out, err = s.d.Cmd("inspect", "-f", "{{json .State}}", id)
- c.Assert(err, checker.IsNil, check.Commentf("output: %s", out))
+ assert.Assert(c, err == nil, "output: %s", out)
var origState state
err = json.Unmarshal([]byte(strings.TrimSpace(out)), &origState)
@@ -2828,7 +2799,7 @@
}
out, err := s.d.Cmd("inspect", "-f", "{{json .State}}", id)
- c.Assert(err, checker.IsNil, check.Commentf("output: %s", out))
+ assert.Assert(c, err == nil, "output: %s", out)
var newState state
err = json.Unmarshal([]byte(strings.TrimSpace(out)), &newState)
@@ -2846,7 +2817,7 @@
assert.NilError(c, err, "Output: %s", out)
}
-func (s *DockerDaemonSuite) TestShmSize(c *check.C) {
+func (s *DockerDaemonSuite) TestShmSize(c *testing.T) {
testRequires(c, DaemonIsLinux)
size := 67108864 * 2
@@ -2857,23 +2828,23 @@
name := "shm1"
out, err := s.d.Cmd("run", "--name", name, "busybox", "mount")
assert.NilError(c, err, "Output: %s", out)
- c.Assert(pattern.MatchString(out), checker.True)
+ assert.Assert(c, pattern.MatchString(out))
out, err = s.d.Cmd("inspect", "--format", "{{.HostConfig.ShmSize}}", name)
assert.NilError(c, err, "Output: %s", out)
- c.Assert(strings.TrimSpace(out), check.Equals, fmt.Sprintf("%v", size))
+ assert.Equal(c, strings.TrimSpace(out), fmt.Sprintf("%v", size))
}
-func (s *DockerDaemonSuite) TestShmSizeReload(c *check.C) {
+func (s *DockerDaemonSuite) TestShmSizeReload(c *testing.T) {
testRequires(c, DaemonIsLinux)
configPath, err := ioutil.TempDir("", "test-daemon-shm-size-reload-config")
- c.Assert(err, checker.IsNil, check.Commentf("could not create temp file for config reload"))
+ assert.Assert(c, err == nil, "could not create temp file for config reload")
defer os.RemoveAll(configPath) // clean up
configFile := filepath.Join(configPath, "config.json")
size := 67108864 * 2
configData := []byte(fmt.Sprintf(`{"default-shm-size": "%dM"}`, size/1024/1024))
- c.Assert(ioutil.WriteFile(configFile, configData, 0666), checker.IsNil, check.Commentf("could not write temp file for config reload"))
+ assert.Assert(c, ioutil.WriteFile(configFile, configData, 0666) == nil, "could not write temp file for config reload")
pattern := regexp.MustCompile(fmt.Sprintf("shm on /dev/shm type tmpfs(.*)size=%dk", size/1024))
s.d.StartWithBusybox(c, "--config-file", configFile)
@@ -2881,29 +2852,29 @@
name := "shm1"
out, err := s.d.Cmd("run", "--name", name, "busybox", "mount")
assert.NilError(c, err, "Output: %s", out)
- c.Assert(pattern.MatchString(out), checker.True)
+ assert.Assert(c, pattern.MatchString(out))
out, err = s.d.Cmd("inspect", "--format", "{{.HostConfig.ShmSize}}", name)
assert.NilError(c, err, "Output: %s", out)
- c.Assert(strings.TrimSpace(out), check.Equals, fmt.Sprintf("%v", size))
+ assert.Equal(c, strings.TrimSpace(out), fmt.Sprintf("%v", size))
size = 67108864 * 3
configData = []byte(fmt.Sprintf(`{"default-shm-size": "%dM"}`, size/1024/1024))
- c.Assert(ioutil.WriteFile(configFile, configData, 0666), checker.IsNil, check.Commentf("could not write temp file for config reload"))
+ assert.Assert(c, ioutil.WriteFile(configFile, configData, 0666) == nil, "could not write temp file for config reload")
pattern = regexp.MustCompile(fmt.Sprintf("shm on /dev/shm type tmpfs(.*)size=%dk", size/1024))
err = s.d.ReloadConfig()
- c.Assert(err, checker.IsNil, check.Commentf("error reloading daemon config"))
+ assert.Assert(c, err == nil, "error reloading daemon config")
name = "shm2"
out, err = s.d.Cmd("run", "--name", name, "busybox", "mount")
assert.NilError(c, err, "Output: %s", out)
- c.Assert(pattern.MatchString(out), checker.True)
+ assert.Assert(c, pattern.MatchString(out))
out, err = s.d.Cmd("inspect", "--format", "{{.HostConfig.ShmSize}}", name)
assert.NilError(c, err, "Output: %s", out)
- c.Assert(strings.TrimSpace(out), check.Equals, fmt.Sprintf("%v", size))
+ assert.Equal(c, strings.TrimSpace(out), 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))
c.Logf("Checking IpcMode %s set from %s\n", mode, from)
var serr error
@@ -2938,7 +2909,7 @@
// TestDaemonStartWithIpcModes checks that daemon starts fine given correct
// arguments for default IPC mode, and bails out with incorrect ones.
// 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)
ipcModes := []struct {
@@ -2962,7 +2933,7 @@
// TestFailedPluginRemove makes sure that a failed plugin remove does not block
// the daemon from starting
-func (s *DockerDaemonSuite) TestFailedPluginRemove(c *check.C) {
+func (s *DockerDaemonSuite) TestFailedPluginRemove(c *testing.T) {
testRequires(c, DaemonIsLinux, IsAmd64, testEnv.IsLocalDaemon)
d := daemon.New(c, dockerBinary, dockerdBinary)
d.Start(c)
diff --git a/integration-cli/docker_cli_events_test.go b/integration-cli/docker_cli_events_test.go
index 611ae3c..9e818af 100644
--- a/integration-cli/docker_cli_events_test.go
+++ b/integration-cli/docker_cli_events_test.go
@@ -11,6 +11,7 @@
"os/exec"
"strconv"
"strings"
+ "testing"
"time"
"github.com/docker/docker/api/types"
@@ -19,13 +20,12 @@
eventstestutils "github.com/docker/docker/daemon/events/testutils"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
- "github.com/go-check/check"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
"gotest.tools/icmd"
)
-func (s *DockerSuite) TestEventsTimestampFormats(c *check.C) {
+func (s *DockerSuite) TestEventsTimestampFormats(c *testing.T) {
name := "events-time-format-test"
// Start stopwatch, generate an event
@@ -54,7 +54,7 @@
}
}
-func (s *DockerSuite) TestEventsUntag(c *check.C) {
+func (s *DockerSuite) TestEventsUntag(c *testing.T) {
image := "busybox"
dockerCmd(c, "tag", image, "utest:tag1")
dockerCmd(c, "tag", image, "utest:tag2")
@@ -77,7 +77,7 @@
}
}
-func (s *DockerSuite) TestEventsContainerEvents(c *check.C) {
+func (s *DockerSuite) TestEventsContainerEvents(c *testing.T) {
dockerCmd(c, "run", "--rm", "--name", "container-events-test", "busybox", "true")
out, _ := dockerCmd(c, "events", "--until", daemonUnixTime(c))
@@ -89,7 +89,7 @@
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)
dockerCmd(c, "run", "--rm", "--name", "container-events-test", "busybox", "true")
@@ -113,7 +113,7 @@
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")
timeBeginning := time.Unix(0, 0).Format(time.RFC3339Nano)
timeBeginning = strings.Replace(timeBeginning, "Z", ".000000000Z", -1)
@@ -127,7 +127,7 @@
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
since := daemonUnixTime(c)
image := "testimageevents:tag"
@@ -145,7 +145,7 @@
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
testRequires(c, DaemonIsLinux)
since := daemonUnixTime(c)
@@ -163,7 +163,7 @@
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
// more reliable (@swernli)
testRequires(c, DaemonIsLinux)
@@ -187,7 +187,7 @@
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)
myImageName := "footest:v1"
dockerCmd(c, "tag", "busybox", myImageName)
@@ -226,7 +226,7 @@
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)
since := daemonUnixTime(c)
@@ -245,7 +245,7 @@
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)
dockerCmd(c, "run", "--rm", "busybox", "true")
dockerCmd(c, "run", "--rm", "busybox", "true")
@@ -260,7 +260,7 @@
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)
out, _ := dockerCmd(c, "run", "--name", "container_1", "-d", "busybox:latest", "true")
@@ -288,7 +288,7 @@
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)
label := "io.docker.testing=foo"
@@ -323,7 +323,7 @@
assert.Assert(c, found)
}
-func (s *DockerSuite) TestEventsFilterImageLabels(c *check.C) {
+func (s *DockerSuite) TestEventsFilterImageLabels(c *testing.T) {
since := daemonUnixTime(c)
name := "labelfiltertest"
label := "io.docker.testing=image"
@@ -353,7 +353,7 @@
}
}
-func (s *DockerSuite) TestEventsFilterContainer(c *check.C) {
+func (s *DockerSuite) TestEventsFilterContainer(c *testing.T) {
since := daemonUnixTime(c)
nameID := make(map[string]string)
@@ -391,7 +391,7 @@
}
}
-func (s *DockerSuite) TestEventsCommit(c *check.C) {
+func (s *DockerSuite) TestEventsCommit(c *testing.T) {
// Problematic on Windows as cannot commit a running container
testRequires(c, DaemonIsLinux)
@@ -408,7 +408,7 @@
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.
buildImageSuccessfully(c, "cpimg", build.WithDockerfile(`
FROM busybox
@@ -437,7 +437,7 @@
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")
cID := strings.TrimSpace(out)
assert.NilError(c, waitRun(cID))
@@ -460,7 +460,7 @@
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).
testRequires(c, DaemonIsLinux)
@@ -498,7 +498,7 @@
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")
cID := strings.TrimSpace(out)
dockerCmd(c, "rename", "oldName", "newName")
@@ -509,7 +509,7 @@
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
testRequires(c, DaemonIsLinux)
@@ -526,7 +526,7 @@
}
// #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
// supporting push
testRequires(c, DaemonIsLinux)
@@ -546,7 +546,7 @@
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
testRequires(c, testEnv.IsLocalDaemon)
since := daemonUnixTime(c)
@@ -600,7 +600,7 @@
}
// #25798
-func (s *DockerSuite) TestEventsSpecialFiltersWithExecCreate(c *check.C) {
+func (s *DockerSuite) TestEventsSpecialFiltersWithExecCreate(c *testing.T) {
since := daemonUnixTime(c)
runSleepingContainer(c, "--name", "test-container", "-d")
waitRun("test-container")
@@ -630,7 +630,7 @@
assert.Equal(c, len(events), 1, out)
}
-func (s *DockerSuite) TestEventsFilterImageInContainerAction(c *check.C) {
+func (s *DockerSuite) TestEventsFilterImageInContainerAction(c *testing.T) {
since := daemonUnixTime(c)
dockerCmd(c, "run", "--name", "test-container", "-d", "busybox", "true")
waitRun("test-container")
@@ -640,7 +640,7 @@
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")
// wait until test2 is auto removed.
@@ -680,7 +680,7 @@
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")
waitRun("test-container")
@@ -692,7 +692,7 @@
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)
dockerCmd(c, "run", "--name", "test-container", "-d", "busybox", "true")
@@ -709,7 +709,7 @@
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)
dockerCmd(c, "run", "--rm", "busybox", "true")
dockerCmd(c, "run", "--rm", "busybox", "true")
@@ -732,7 +732,7 @@
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
result := dockerCmdWithResult("events", "--format", "{{badFuncString .}}")
result.Assert(c, icmd.Expected{
@@ -742,7 +742,7 @@
})
}
-func (s *DockerSuite) TestEventsFormatBadField(c *check.C) {
+func (s *DockerSuite) TestEventsFormatBadField(c *testing.T) {
// make sure it fails immediately, without receiving any event
result := dockerCmdWithResult("events", "--format", "{{.badFieldString}}")
result.Assert(c, icmd.Expected{
diff --git a/integration-cli/docker_cli_events_unix_test.go b/integration-cli/docker_cli_events_unix_test.go
index 44252c9..2662310 100644
--- a/integration-cli/docker_cli_events_unix_test.go
+++ b/integration-cli/docker_cli_events_unix_test.go
@@ -10,18 +10,18 @@
"os"
"os/exec"
"strings"
+ "testing"
"time"
"unicode"
"github.com/creack/pty"
"github.com/docker/docker/integration-cli/cli/build"
- "github.com/go-check/check"
"golang.org/x/sys/unix"
"gotest.tools/assert"
)
// #5979
-func (s *DockerSuite) TestEventsRedirectStdout(c *check.C) {
+func (s *DockerSuite) TestEventsRedirectStdout(c *testing.T) {
since := daemonUnixTime(c)
dockerCmd(c, "run", "busybox", "true")
@@ -47,7 +47,7 @@
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)
errChan := make(chan error)
@@ -77,7 +77,7 @@
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)
errChan := make(chan error)
@@ -125,7 +125,7 @@
}
// #18453
-func (s *DockerSuite) TestEventsContainerFilterByName(c *check.C) {
+func (s *DockerSuite) TestEventsContainerFilterByName(c *testing.T) {
testRequires(c, DaemonIsLinux)
cOut, _ := dockerCmd(c, "run", "--name=foo", "-d", "busybox", "top")
c1 := strings.TrimSpace(cOut)
@@ -139,7 +139,7 @@
}
// #18453
-func (s *DockerSuite) TestEventsContainerFilterBeforeCreate(c *check.C) {
+func (s *DockerSuite) TestEventsContainerFilterBeforeCreate(c *testing.T) {
testRequires(c, DaemonIsLinux)
buf := &bytes.Buffer{}
cmd := exec.Command(dockerBinary, "events", "-f", "container=foo", "--since=0")
@@ -164,7 +164,7 @@
}
}
-func (s *DockerSuite) TestVolumeEvents(c *check.C) {
+func (s *DockerSuite) TestVolumeEvents(c *testing.T) {
testRequires(c, DaemonIsLinux)
since := daemonUnixTime(c)
@@ -192,7 +192,7 @@
assert.Equal(c, volumeEvents[4], "destroy")
}
-func (s *DockerSuite) TestNetworkEvents(c *check.C) {
+func (s *DockerSuite) TestNetworkEvents(c *testing.T) {
testRequires(c, DaemonIsLinux)
since := daemonUnixTime(c)
@@ -219,7 +219,7 @@
assert.Equal(c, netEvents[3], "destroy")
}
-func (s *DockerSuite) TestEventsContainerWithMultiNetwork(c *check.C) {
+func (s *DockerSuite) TestEventsContainerWithMultiNetwork(c *testing.T) {
testRequires(c, DaemonIsLinux)
// Observe create/connect network actions
@@ -247,7 +247,7 @@
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)
observer, err := newEventObserver(c)
@@ -301,7 +301,7 @@
}
}
-func (s *DockerSuite) TestEventsImageUntagDelete(c *check.C) {
+func (s *DockerSuite) TestEventsImageUntagDelete(c *testing.T) {
testRequires(c, DaemonIsLinux)
observer, err := newEventObserver(c)
@@ -340,7 +340,7 @@
}
}
-func (s *DockerSuite) TestEventsFilterVolumeAndNetworkType(c *check.C) {
+func (s *DockerSuite) TestEventsFilterVolumeAndNetworkType(c *testing.T) {
testRequires(c, DaemonIsLinux)
since := daemonUnixTime(c)
@@ -359,7 +359,7 @@
assert.Equal(c, networkActions[0], "create")
}
-func (s *DockerSuite) TestEventsFilterVolumeID(c *check.C) {
+func (s *DockerSuite) TestEventsFilterVolumeID(c *testing.T) {
testRequires(c, DaemonIsLinux)
since := daemonUnixTime(c)
@@ -374,7 +374,7 @@
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)
since := daemonUnixTime(c)
@@ -387,7 +387,7 @@
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
configFilePath := "test.json"
@@ -455,7 +455,7 @@
}
}
-func (s *DockerDaemonSuite) TestDaemonEventsWithFilters(c *check.C) {
+func (s *DockerDaemonSuite) TestDaemonEventsWithFilters(c *testing.T) {
// daemon config file
configFilePath := "test.json"
diff --git a/integration-cli/docker_cli_exec_test.go b/integration-cli/docker_cli_exec_test.go
index 72fa092..6733951 100644
--- a/integration-cli/docker_cli_exec_test.go
+++ b/integration-cli/docker_cli_exec_test.go
@@ -11,18 +11,18 @@
"sort"
"strings"
"sync"
+ "testing"
"time"
"github.com/docker/docker/client"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
- "github.com/go-check/check"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
"gotest.tools/icmd"
)
-func (s *DockerSuite) TestExec(c *check.C) {
+func (s *DockerSuite) TestExec(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "sh", "-c", "echo test > /tmp/file && top")
assert.NilError(c, waitRun(strings.TrimSpace(out)))
@@ -31,7 +31,7 @@
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)
dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "sh", "-c", "echo test > /tmp/file && top")
@@ -67,7 +67,7 @@
}
-func (s *DockerSuite) TestExecAfterContainerRestart(c *check.C) {
+func (s *DockerSuite) TestExecAfterContainerRestart(c *testing.T) {
out := runSleepingContainer(c)
cleanedContainerID := strings.TrimSpace(out)
assert.NilError(c, waitRun(cleanedContainerID))
@@ -78,7 +78,7 @@
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.
s.d.StartWithBusybox(c)
@@ -96,7 +96,7 @@
}
// 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
// difference between Windows and Linux. On Windows, the environment is passed
// into the process that is launched, not into the machine environment. Hence
@@ -111,7 +111,7 @@
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)
runSleepingContainer(c, "-e", "HOME=/root", "-d", "--name", "testing")
assert.NilError(c, waitRun("testing"))
@@ -122,14 +122,14 @@
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")
result := icmd.RunCommand(dockerBinary, "exec", "top", "sh", "-c", "exit 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)
out := runSleepingContainer(c, "-d", "--name", "testing")
@@ -144,7 +144,7 @@
}
// 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.
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "-it", "--name", "exec_tty_stdin", "busybox")
@@ -165,7 +165,7 @@
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")
id := strings.TrimSpace(out)
assert.NilError(c, waitRun(id))
@@ -202,7 +202,7 @@
}
// 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
// runSleepingContainer helper to have an exec version.
testRequires(c, DaemonIsLinux)
@@ -216,7 +216,7 @@
})
}
-func (s *DockerSuite) TestExecStopNotHanging(c *check.C) {
+func (s *DockerSuite) TestExecStopNotHanging(c *testing.T) {
// TODO Windows CI: Requires some extra work. Consider copying the
// runSleepingContainer helper to have an exec version.
testRequires(c, DaemonIsLinux)
@@ -244,7 +244,7 @@
}
}
-func (s *DockerSuite) TestExecCgroup(c *check.C) {
+func (s *DockerSuite) TestExecCgroup(c *testing.T) {
// Not applicable on Windows - using Linux specific functionality
testRequires(c, NotUserNamespace)
testRequires(c, DaemonIsLinux)
@@ -297,7 +297,7 @@
}
}
-func (s *DockerSuite) TestExecInspectID(c *check.C) {
+func (s *DockerSuite) TestExecInspectID(c *testing.T) {
out := runSleepingContainer(c, "-d")
id := strings.TrimSuffix(out, "\n")
@@ -364,7 +364,7 @@
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
testRequires(c, DaemonIsLinux)
var out string
@@ -380,7 +380,7 @@
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.
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
for _, fn := range []string{"resolv.conf", "hosts"} {
@@ -421,7 +421,7 @@
}
}
-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
// supports users
testRequires(c, DaemonIsLinux)
@@ -434,7 +434,7 @@
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
testRequires(c, DaemonIsLinux, NotUserNamespace)
// Start main loop which attempts mknod repeatedly
@@ -464,7 +464,7 @@
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
testRequires(c, DaemonIsLinux)
name := "testbuilduser"
@@ -477,7 +477,7 @@
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
// --read-only + userns has remount issues
testRequires(c, DaemonIsLinux, NotUserNamespace)
@@ -485,7 +485,7 @@
dockerCmd(c, "exec", "parent", "true")
}
-func (s *DockerSuite) TestExecUlimits(c *check.C) {
+func (s *DockerSuite) TestExecUlimits(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "testexeculimits"
runSleepingContainer(c, "-d", "--ulimit", "nofile=511:511", "--name", name)
@@ -497,7 +497,7 @@
}
// #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
// currently.
testRequires(c, DaemonIsLinux)
@@ -511,7 +511,7 @@
}
// 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)
out, _ := dockerCmd(c, "run", "-d", "--name", "testing", minimalBaseImage(), "powershell", "start-sleep", "60")
assert.NilError(c, waitRun(strings.TrimSpace(out)))
@@ -521,7 +521,7 @@
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)
runSleepingContainer(c, "-d", "--name", "foo")
runSleepingContainer(c, "-d", "--link", "foo:db", "--hostname", "myhost", "--name", "bar")
diff --git a/integration-cli/docker_cli_exec_unix_test.go b/integration-cli/docker_cli_exec_unix_test.go
index f2f89f2..8def4ea 100644
--- a/integration-cli/docker_cli_exec_unix_test.go
+++ b/integration-cli/docker_cli_exec_unix_test.go
@@ -7,15 +7,15 @@
"io"
"os/exec"
"strings"
+ "testing"
"time"
"github.com/creack/pty"
- "github.com/go-check/check"
"gotest.tools/assert"
)
// regression test for #12546
-func (s *DockerSuite) TestExecInteractiveStdinClose(c *check.C) {
+func (s *DockerSuite) TestExecInteractiveStdinClose(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-itd", "busybox", "/bin/cat")
contID := strings.TrimSpace(out)
@@ -44,7 +44,7 @@
}
}
-func (s *DockerSuite) TestExecTTY(c *check.C) {
+func (s *DockerSuite) TestExecTTY(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
dockerCmd(c, "run", "-d", "--name=test", "busybox", "sh", "-c", "echo hello > /foo && top")
@@ -74,7 +74,7 @@
}
// 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)
out, _ := dockerCmd(c, "run", "-id", "busybox", "/bin/cat")
contID := strings.TrimSpace(out)
@@ -86,7 +86,7 @@
// Test that the TERM env var is not set on exec when -t is not provided, even if it was set
// on run
-func (s *DockerSuite) TestExecWithNoTERM(c *check.C) {
+func (s *DockerSuite) TestExecWithNoTERM(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
out, _ := dockerCmd(c, "run", "-itd", "busybox", "/bin/cat")
contID := strings.TrimSpace(out)
diff --git a/integration-cli/docker_cli_external_volume_driver_unix_test.go b/integration-cli/docker_cli_external_volume_driver_test.go
similarity index 76%
rename from integration-cli/docker_cli_external_volume_driver_unix_test.go
rename to integration-cli/docker_cli_external_volume_driver_test.go
index e9e92d4..1a219ab 100644
--- a/integration-cli/docker_cli_external_volume_driver_unix_test.go
+++ b/integration-cli/docker_cli_external_volume_driver_test.go
@@ -1,5 +1,3 @@
-// +build !windows
-
package main
import (
@@ -13,26 +11,19 @@
"os/exec"
"path/filepath"
"strings"
+ "testing"
"time"
"github.com/docker/docker/api/types"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/daemon"
testdaemon "github.com/docker/docker/internal/test/daemon"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/volume"
- "github.com/go-check/check"
"gotest.tools/assert"
)
const volumePluginName = "test-external-volume-driver"
-func init() {
- check.Suite(&DockerExternalVolumeSuite{
- ds: &DockerSuite{},
- })
-}
-
type eventCounter struct {
activations int
creations int
@@ -51,20 +42,20 @@
*volumePlugin
}
-func (s *DockerExternalVolumeSuite) SetUpTest(c *check.C) {
+func (s *DockerExternalVolumeSuite) SetUpTest(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
s.ec = &eventCounter{}
}
-func (s *DockerExternalVolumeSuite) TearDownTest(c *check.C) {
+func (s *DockerExternalVolumeSuite) TearDownTest(c *testing.T) {
if s.d != nil {
s.d.Stop(c)
s.ds.TearDownTest(c)
}
}
-func (s *DockerExternalVolumeSuite) SetUpSuite(c *check.C) {
+func (s *DockerExternalVolumeSuite) SetUpSuite(c *testing.T) {
s.volumePlugin = newVolumePlugin(c, volumePluginName)
}
@@ -86,7 +77,7 @@
p.Server.Close()
}
-func newVolumePlugin(c *check.C, name string) *volumePlugin {
+func newVolumePlugin(c *testing.T, name string) *volumePlugin {
mux := http.NewServeMux()
s := &volumePlugin{Server: httptest.NewServer(mux), ec: &eventCounter{}, vols: make(map[string]vol)}
@@ -276,62 +267,59 @@
return s
}
-func (s *DockerExternalVolumeSuite) TearDownSuite(c *check.C) {
+func (s *DockerExternalVolumeSuite) TearDownSuite(c *testing.T) {
s.volumePlugin.Close()
err := os.RemoveAll("/etc/docker/plugins")
assert.NilError(c, err)
}
-func (s *DockerExternalVolumeSuite) TestVolumeCLICreateOptionConflict(c *check.C) {
+func (s *DockerExternalVolumeSuite) TestVolumeCLICreateOptionConflict(c *testing.T) {
dockerCmd(c, "volume", "create", "test")
out, _, err := dockerCmdWithError("volume", "create", "test", "--driver", volumePluginName)
- c.Assert(err, check.NotNil, check.Commentf("volume create exception name already in use with another driver"))
- c.Assert(out, checker.Contains, "must be unique")
-
+ assert.Assert(c, err != nil, "volume create exception name already in use with another driver")
+ assert.Assert(c, strings.Contains(out, "must be unique"))
out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Driver }}", "test")
_, _, err = dockerCmdWithError("volume", "create", "test", "--driver", strings.TrimSpace(out))
assert.NilError(c, err)
}
-func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverNamed(c *check.C) {
+func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverNamed(c *testing.T) {
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")
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, s.Server.URL)
-
+ assert.Assert(c, strings.Contains(out, s.Server.URL))
_, err = s.d.Cmd("volume", "rm", "external-volume-test")
assert.NilError(c, err)
p := hostVolumePath("external-volume-test")
_, err = os.Lstat(p)
assert.ErrorContains(c, err, "")
- c.Assert(os.IsNotExist(err), checker.True, check.Commentf("Expected volume path in host to not exist: %s, %v\n", p, err))
+ assert.Assert(c, os.IsNotExist(err), "Expected volume path in host to not exist: %s, %v\n", p, err)
- c.Assert(s.ec.activations, checker.Equals, 1)
- c.Assert(s.ec.creations, checker.Equals, 1)
- c.Assert(s.ec.removals, checker.Equals, 1)
- c.Assert(s.ec.mounts, checker.Equals, 1)
- c.Assert(s.ec.unmounts, checker.Equals, 1)
+ assert.Equal(c, s.ec.activations, 1)
+ assert.Equal(c, s.ec.creations, 1)
+ assert.Equal(c, s.ec.removals, 1)
+ assert.Equal(c, s.ec.mounts, 1)
+ assert.Equal(c, s.ec.unmounts, 1)
}
-func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnnamed(c *check.C) {
+func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnnamed(c *testing.T) {
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")
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, s.Server.URL)
-
- c.Assert(s.ec.activations, checker.Equals, 1)
- c.Assert(s.ec.creations, checker.Equals, 1)
- c.Assert(s.ec.removals, checker.Equals, 1)
- c.Assert(s.ec.mounts, checker.Equals, 1)
- c.Assert(s.ec.unmounts, checker.Equals, 1)
+ assert.Assert(c, strings.Contains(out, s.Server.URL))
+ assert.Equal(c, s.ec.activations, 1)
+ assert.Equal(c, s.ec.creations, 1)
+ assert.Equal(c, s.ec.removals, 1)
+ assert.Equal(c, s.ec.mounts, 1)
+ assert.Equal(c, s.ec.unmounts, 1)
}
-func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverVolumesFrom(c *check.C) {
+func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverVolumesFrom(c *testing.T) {
s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "--name", "vol-test1", "-v", "/foo", "--volume-driver", volumePluginName, "busybox:latest")
@@ -343,14 +331,14 @@
out, err = s.d.Cmd("rm", "-fv", "vol-test1")
assert.NilError(c, err, out)
- c.Assert(s.ec.activations, checker.Equals, 1)
- c.Assert(s.ec.creations, checker.Equals, 1)
- c.Assert(s.ec.removals, checker.Equals, 1)
- c.Assert(s.ec.mounts, checker.Equals, 2)
- c.Assert(s.ec.unmounts, checker.Equals, 2)
+ assert.Equal(c, s.ec.activations, 1)
+ assert.Equal(c, s.ec.creations, 1)
+ assert.Equal(c, s.ec.removals, 1)
+ assert.Equal(c, s.ec.mounts, 2)
+ assert.Equal(c, s.ec.unmounts, 2)
}
-func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverDeleteContainer(c *check.C) {
+func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverDeleteContainer(c *testing.T) {
s.d.StartWithBusybox(c)
out, err := s.d.Cmd("run", "--name", "vol-test1", "-v", "/foo", "--volume-driver", volumePluginName, "busybox:latest")
@@ -359,11 +347,11 @@
out, err = s.d.Cmd("rm", "-fv", "vol-test1")
assert.NilError(c, err, out)
- c.Assert(s.ec.activations, checker.Equals, 1)
- c.Assert(s.ec.creations, checker.Equals, 1)
- c.Assert(s.ec.removals, checker.Equals, 1)
- c.Assert(s.ec.mounts, checker.Equals, 1)
- c.Assert(s.ec.unmounts, checker.Equals, 1)
+ assert.Equal(c, s.ec.activations, 1)
+ assert.Equal(c, s.ec.creations, 1)
+ assert.Equal(c, s.ec.removals, 1)
+ assert.Equal(c, s.ec.mounts, 1)
+ assert.Equal(c, s.ec.unmounts, 1)
}
func hostVolumePath(name string) string {
@@ -371,7 +359,7 @@
}
// 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"
err := ioutil.WriteFile(specPath, []byte("tcp://127.0.0.7:9999"), 0644)
assert.NilError(c, err)
@@ -382,10 +370,10 @@
cmd1 := exec.Command(dockerBinary, "volume", "create", "-d", "down-driver")
cmd2 := exec.Command(dockerBinary, "volume", "create")
- c.Assert(cmd1.Start(), checker.IsNil)
+ assert.Assert(c, cmd1.Start() == nil)
defer cmd1.Process.Kill()
time.Sleep(100 * time.Millisecond) // ensure API has been called
- c.Assert(cmd2.Start(), checker.IsNil)
+ assert.Assert(c, cmd2.Start() == nil)
go func() {
cmd1.Wait()
@@ -407,7 +395,7 @@
}
}
-func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverRetryNotImmediatelyExists(c *check.C) {
+func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverRetryNotImmediatelyExists(c *testing.T) {
s.d.StartWithBusybox(c)
driverName := "test-external-volume-driver-retry"
@@ -437,14 +425,14 @@
_, err := s.d.Cmd("volume", "rm", "external-volume-test")
assert.NilError(c, err)
- c.Assert(p.ec.activations, checker.Equals, 1)
- c.Assert(p.ec.creations, checker.Equals, 1)
- c.Assert(p.ec.removals, checker.Equals, 1)
- c.Assert(p.ec.mounts, checker.Equals, 1)
- c.Assert(p.ec.unmounts, checker.Equals, 1)
+ assert.Equal(c, p.ec.activations, 1)
+ assert.Equal(c, p.ec.creations, 1)
+ assert.Equal(c, p.ec.removals, 1)
+ assert.Equal(c, p.ec.mounts, 1)
+ assert.Equal(c, p.ec.unmounts, 1)
}
-func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverBindExternalVolume(c *check.C) {
+func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverBindExternalVolume(c *testing.T) {
dockerCmd(c, "volume", "create", "-d", volumePluginName, "foo")
dockerCmd(c, "run", "-d", "--name", "testing", "-v", "foo:/bar", "busybox", "top")
@@ -453,31 +441,31 @@
Driver string
}
out := inspectFieldJSON(c, "testing", "Mounts")
- c.Assert(json.NewDecoder(strings.NewReader(out)).Decode(&mounts), checker.IsNil)
- c.Assert(len(mounts), checker.Equals, 1, check.Commentf("%s", out))
- c.Assert(mounts[0].Name, checker.Equals, "foo")
- c.Assert(mounts[0].Driver, checker.Equals, volumePluginName)
+ assert.Assert(c, json.NewDecoder(strings.NewReader(out)).Decode(&mounts) == nil)
+ assert.Equal(c, len(mounts), 1, fmt.Sprintf("%s", out))
+ assert.Equal(c, mounts[0].Name, "foo")
+ assert.Equal(c, mounts[0].Driver, volumePluginName)
}
-func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverList(c *check.C) {
+func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverList(c *testing.T) {
dockerCmd(c, "volume", "create", "-d", volumePluginName, "abc3")
out, _ := dockerCmd(c, "volume", "ls")
ls := strings.Split(strings.TrimSpace(out), "\n")
- c.Assert(len(ls), check.Equals, 2, check.Commentf("\n%s", out))
+ assert.Equal(c, len(ls), 2, fmt.Sprintf("\n%s", out))
vol := strings.Fields(ls[len(ls)-1])
- c.Assert(len(vol), check.Equals, 2, check.Commentf("%v", vol))
- c.Assert(vol[0], check.Equals, volumePluginName)
- c.Assert(vol[1], check.Equals, "abc3")
+ assert.Equal(c, len(vol), 2, fmt.Sprintf("%v", vol))
+ assert.Equal(c, vol[0], volumePluginName)
+ assert.Equal(c, vol[1], "abc3")
- c.Assert(s.ec.lists, check.Equals, 1)
+ assert.Equal(c, s.ec.lists, 1)
}
-func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGet(c *check.C) {
+func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGet(c *testing.T) {
out, _, err := dockerCmdWithError("volume", "inspect", "dummy")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "No such volume")
- c.Assert(s.ec.gets, check.Equals, 1)
+ assert.Assert(c, strings.Contains(out, "No such volume"))
+ assert.Equal(c, s.ec.gets, 1)
dockerCmd(c, "volume", "create", "test", "-d", volumePluginName)
out, _ = dockerCmd(c, "volume", "inspect", "test")
@@ -487,26 +475,26 @@
}
var st []vol
- c.Assert(json.Unmarshal([]byte(out), &st), checker.IsNil)
- c.Assert(st, checker.HasLen, 1)
- c.Assert(st[0].Status, checker.HasLen, 1, check.Commentf("%v", st[0]))
- c.Assert(st[0].Status["Hello"], checker.Equals, "world", check.Commentf("%v", st[0].Status))
+ assert.Assert(c, json.Unmarshal([]byte(out), &st) == nil)
+ assert.Equal(c, len(st), 1)
+ assert.Equal(c, len(st[0].Status), 1, fmt.Sprintf("%v", st[0]))
+ assert.Equal(c, st[0].Status["Hello"], "world", fmt.Sprintf("%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")
s.d.Restart(c)
dockerCmd(c, "run", "--name=test", "-v", "abc1:/foo", "busybox", "true")
var mounts []types.MountPoint
inspectFieldAndUnmarshall(c, "test", "Mounts", &mounts)
- c.Assert(mounts, checker.HasLen, 1)
- c.Assert(mounts[0].Driver, checker.Equals, volumePluginName)
+ assert.Equal(c, len(mounts), 1)
+ assert.Equal(c, mounts[0].Driver, volumePluginName)
}
// 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.
-func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGetEmptyResponse(c *check.C) {
+func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGetEmptyResponse(c *testing.T) {
s.d.Start(c)
out, err := s.d.Cmd("volume", "create", "-d", volumePluginName, "abc2", "--opt", "ninja=1")
@@ -514,27 +502,27 @@
out, err = s.d.Cmd("volume", "inspect", "abc2")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "No such volume")
+ assert.Assert(c, strings.Contains(out, "No such volume"))
}
// Ensure only cached paths are used in volume list to prevent N+1 calls to `VolumeDriver.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.
-func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverPathCalls(c *check.C) {
+func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverPathCalls(c *testing.T) {
s.d.Start(c)
- c.Assert(s.ec.paths, checker.Equals, 0)
+ assert.Equal(c, s.ec.paths, 0)
out, err := s.d.Cmd("volume", "create", "test", "--driver=test-external-volume-driver")
assert.NilError(c, err, out)
- c.Assert(s.ec.paths, checker.Equals, 0)
+ assert.Equal(c, s.ec.paths, 0)
out, err = s.d.Cmd("volume", "ls")
assert.NilError(c, err, out)
- c.Assert(s.ec.paths, checker.Equals, 0)
+ assert.Equal(c, s.ec.paths, 0)
}
-func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverMountID(c *check.C) {
+func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverMountID(c *testing.T) {
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")
@@ -543,21 +531,21 @@
}
// 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)
- c.Assert(s.ec.caps, checker.Equals, 0)
+ assert.Equal(c, s.ec.caps, 0)
for i := 0; i < 3; i++ {
out, err := s.d.Cmd("volume", "create", "-d", volumePluginName, fmt.Sprintf("test%d", i))
assert.NilError(c, err, out)
- c.Assert(s.ec.caps, checker.Equals, 1)
+ assert.Equal(c, s.ec.caps, 1)
out, err = s.d.Cmd("volume", "inspect", "--format={{.Scope}}", fmt.Sprintf("test%d", i))
assert.NilError(c, err)
assert.Equal(c, strings.TrimSpace(out), volume.GlobalScope)
}
}
-func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverOutOfBandDelete(c *check.C) {
+func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverOutOfBandDelete(c *testing.T) {
driverName := stringid.GenerateRandomID()
p := newVolumePlugin(c, driverName)
defer p.Close()
@@ -569,8 +557,7 @@
out, err = s.d.Cmd("volume", "create", "-d", "local", "--name", "test")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "must be unique")
-
+ assert.Assert(c, strings.Contains(out, "must be unique"))
// simulate out of band volume deletion on plugin level
delete(p.vols, "test")
@@ -583,11 +570,11 @@
var vs []types.Volume
err = json.Unmarshal([]byte(out), &vs)
assert.NilError(c, err)
- c.Assert(vs, checker.HasLen, 1)
- c.Assert(vs[0].Driver, checker.Equals, driverName)
- c.Assert(vs[0].Options, checker.NotNil)
- c.Assert(vs[0].Options["foo"], checker.Equals, "bar")
- c.Assert(vs[0].Driver, checker.Equals, driverName)
+ assert.Equal(c, len(vs), 1)
+ assert.Equal(c, vs[0].Driver, driverName)
+ assert.Assert(c, vs[0].Options != nil)
+ assert.Equal(c, vs[0].Options["foo"], "bar")
+ assert.Equal(c, vs[0].Driver, driverName)
// simulate out of band volume deletion on plugin level
delete(p.vols, "test")
@@ -601,32 +588,32 @@
vs = nil
err = json.Unmarshal([]byte(out), &vs)
assert.NilError(c, err)
- c.Assert(vs, checker.HasLen, 1)
- c.Assert(vs[0].Options, checker.HasLen, 0)
- c.Assert(vs[0].Driver, checker.Equals, "local")
+ assert.Equal(c, len(vs), 1)
+ assert.Equal(c, len(vs[0].Options), 0)
+ assert.Equal(c, vs[0].Driver, "local")
}
-func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnmountOnMountFail(c *check.C) {
+func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnmountOnMountFail(c *testing.T) {
s.d.StartWithBusybox(c)
s.d.Cmd("volume", "create", "-d", "test-external-volume-driver", "--opt=invalidOption=1", "--name=testumount")
out, _ := s.d.Cmd("run", "-v", "testumount:/foo", "busybox", "true")
- c.Assert(s.ec.unmounts, checker.Equals, 0, check.Commentf("%s", out))
+ assert.Equal(c, s.ec.unmounts, 0, fmt.Sprintf("%s", out))
out, _ = s.d.Cmd("run", "-w", "/foo", "-v", "testumount:/foo", "busybox", "true")
- c.Assert(s.ec.unmounts, checker.Equals, 0, check.Commentf("%s", out))
+ assert.Equal(c, s.ec.unmounts, 0, fmt.Sprintf("%s", out))
}
-func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnmountOnCp(c *check.C) {
+func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnmountOnCp(c *testing.T) {
s.d.StartWithBusybox(c)
s.d.Cmd("volume", "create", "-d", "test-external-volume-driver", "--name=test")
out, _ := s.d.Cmd("run", "-d", "--name=test", "-v", "test:/foo", "busybox", "/bin/sh", "-c", "touch /test && top")
- c.Assert(s.ec.mounts, checker.Equals, 1, check.Commentf("%s", out))
+ assert.Equal(c, s.ec.mounts, 1, fmt.Sprintf("%s", out))
out, _ = s.d.Cmd("cp", "test:/test", "/tmp/test")
- c.Assert(s.ec.mounts, checker.Equals, 2, check.Commentf("%s", out))
- c.Assert(s.ec.unmounts, checker.Equals, 1, check.Commentf("%s", out))
+ assert.Equal(c, s.ec.mounts, 2, fmt.Sprintf("%s", out))
+ assert.Equal(c, s.ec.unmounts, 1, fmt.Sprintf("%s", out))
out, _ = s.d.Cmd("kill", "test")
- c.Assert(s.ec.unmounts, checker.Equals, 2, check.Commentf("%s", out))
+ assert.Equal(c, s.ec.unmounts, 2, fmt.Sprintf("%s", out))
}
diff --git a/integration-cli/docker_cli_health_test.go b/integration-cli/docker_cli_health_test.go
index 4fb6399..0300db7 100644
--- a/integration-cli/docker_cli_health_test.go
+++ b/integration-cli/docker_cli_health_test.go
@@ -4,15 +4,15 @@
"encoding/json"
"strconv"
"strings"
+ "testing"
"time"
"github.com/docker/docker/api/types"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli/build"
- "github.com/go-check/check"
+ "gotest.tools/assert"
)
-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"
expected = expected + "\n"
for {
@@ -20,7 +20,7 @@
if out == expected {
return
}
- c.Check(out, checker.Equals, prev)
+ assert.Equal(c, out, prev)
if out != prev {
return
}
@@ -28,15 +28,15 @@
}
}
-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)
var health types.Health
err := json.Unmarshal([]byte(out), &health)
- c.Check(err, checker.Equals, nil)
+ assert.Equal(c, err, nil)
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
existingContainers := ExistingContainerIDs(c)
@@ -54,12 +54,12 @@
cid, _ := dockerCmd(c, "create", "--name", name, imageName)
out, _ := dockerCmd(c, "ps", "-a", "--format={{.ID}} {{.Status}}")
out = RemoveOutputForExistingElements(out, existingContainers)
- c.Check(out, checker.Equals, cid[:12]+" Created\n")
+ assert.Equal(c, out, cid[:12]+" Created\n")
// Inspect the options
out, _ = dockerCmd(c, "inspect",
"--format=timeout={{.Config.Healthcheck.Timeout}} interval={{.Config.Healthcheck.Interval}} retries={{.Config.Healthcheck.Retries}} test={{.Config.Healthcheck.Test}}", name)
- c.Check(out, checker.Equals, "timeout=30s interval=1s retries=0 test=[CMD-SHELL cat /status]\n")
+ assert.Equal(c, out, "timeout=30s interval=1s retries=0 test=[CMD-SHELL cat /status]\n")
// Start
dockerCmd(c, "start", name)
@@ -71,7 +71,7 @@
// Inspect the status
out, _ = dockerCmd(c, "inspect", "--format={{.State.Health.Status}}", name)
- c.Check(out, checker.Equals, "unhealthy\n")
+ assert.Equal(c, out, "unhealthy\n")
// Make it healthy again
dockerCmd(c, "exec", name, "touch", "/status")
@@ -83,7 +83,7 @@
// Disable the check from the CLI
dockerCmd(c, "create", "--name=noh", "--no-healthcheck", imageName)
out, _ = dockerCmd(c, "inspect", "--format={{.Config.Healthcheck.Test}}", "noh")
- c.Check(out, checker.Equals, "[NONE]\n")
+ assert.Equal(c, out, "[NONE]\n")
dockerCmd(c, "rm", "noh")
// Disable the check with a new build
@@ -91,7 +91,7 @@
HEALTHCHECK NONE`))
out, _ = dockerCmd(c, "inspect", "--format={{.Config.Healthcheck.Test}}", "no_healthcheck")
- c.Check(out, checker.Equals, "[NONE]\n")
+ assert.Equal(c, out, "[NONE]\n")
// Enable the checks from the CLI
_, _ = dockerCmd(c, "run", "-d", "--name=fatal_healthcheck",
@@ -101,11 +101,11 @@
"no_healthcheck")
waitForHealthStatus(c, "fatal_healthcheck", "starting", "healthy")
health := getHealth(c, "fatal_healthcheck")
- c.Check(health.Status, checker.Equals, "healthy")
- c.Check(health.FailingStreak, checker.Equals, 0)
+ assert.Equal(c, health.Status, "healthy")
+ assert.Equal(c, health.FailingStreak, 0)
last := health.Log[len(health.Log)-1]
- c.Check(last.ExitCode, checker.Equals, 0)
- c.Check(last.Output, checker.Equals, "OK\n")
+ assert.Equal(c, last.ExitCode, 0)
+ assert.Equal(c, last.Output, "OK\n")
// Fail the check
dockerCmd(c, "exec", "fatal_healthcheck", "rm", "/status")
@@ -113,8 +113,8 @@
failsStr, _ := dockerCmd(c, "inspect", "--format={{.State.Health.FailingStreak}}", "fatal_healthcheck")
fails, err := strconv.Atoi(strings.TrimSpace(failsStr))
- c.Check(err, check.IsNil)
- c.Check(fails >= 3, checker.Equals, true)
+ assert.Assert(c, err == nil)
+ assert.Equal(c, fails >= 3, true)
dockerCmd(c, "rm", "-f", "fatal_healthcheck")
// Check timeout
@@ -125,9 +125,9 @@
waitForHealthStatus(c, "test", "starting", "unhealthy")
health = getHealth(c, "test")
last = health.Log[len(health.Log)-1]
- c.Check(health.Status, checker.Equals, "unhealthy")
- c.Check(last.ExitCode, checker.Equals, -1)
- c.Check(last.Output, checker.Equals, "Health check exceeded timeout (1s)")
+ assert.Equal(c, health.Status, "unhealthy")
+ assert.Equal(c, last.ExitCode, -1)
+ assert.Equal(c, last.Output, "Health check exceeded timeout (1s)")
dockerCmd(c, "rm", "-f", "test")
// Check JSON-format
@@ -139,12 +139,12 @@
CMD ["cat", "/my status"]`))
out, _ = dockerCmd(c, "inspect",
"--format={{.Config.Healthcheck.Test}}", imageName)
- c.Check(out, checker.Equals, "[CMD cat /my status]\n")
+ assert.Equal(c, out, "[CMD cat /my status]\n")
}
// 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
imageName := "testhealth"
diff --git a/integration-cli/docker_cli_history_test.go b/integration-cli/docker_cli_history_test.go
index 43c4b94..a32be33 100644
--- a/integration-cli/docker_cli_history_test.go
+++ b/integration-cli/docker_cli_history_test.go
@@ -5,15 +5,16 @@
"regexp"
"strconv"
"strings"
+ "testing"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli/build"
- "github.com/go-check/check"
+ "gotest.tools/assert"
+ "gotest.tools/assert/cmp"
)
// This is a heisen-test. Because the created timestamp of images and the behavior of
// 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"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+`
LABEL label.A="A"
@@ -50,21 +51,21 @@
for i := 0; i < 26; i++ {
echoValue := fmt.Sprintf("LABEL label.%s=%s", expectedValues[i], expectedValues[i])
actualValue := actualValues[i]
- c.Assert(actualValue, checker.Contains, echoValue)
+ assert.Assert(c, strings.Contains(actualValue, echoValue))
}
}
-func (s *DockerSuite) TestHistoryExistentImage(c *check.C) {
+func (s *DockerSuite) TestHistoryExistentImage(c *testing.T) {
dockerCmd(c, "history", "busybox")
}
-func (s *DockerSuite) TestHistoryNonExistentImage(c *check.C) {
+func (s *DockerSuite) TestHistoryNonExistentImage(c *testing.T) {
_, _, err := dockerCmdWithError("history", "testHistoryNonExistentImage")
- c.Assert(err, checker.NotNil, check.Commentf("history on a non-existent image should fail."))
+ assert.Assert(c, err != nil, "history on a non-existent image should fail.")
}
-func (s *DockerSuite) TestHistoryImageWithComment(c *check.C) {
+func (s *DockerSuite) TestHistoryImageWithComment(c *testing.T) {
name := "testhistoryimagewithcomment"
// make an image through docker commit <container id> [ -m messages ]
@@ -80,10 +81,10 @@
out, _ := dockerCmd(c, "history", name)
outputTabs := strings.Fields(strings.Split(out, "\n")[1])
actualValue := outputTabs[len(outputTabs)-1]
- c.Assert(actualValue, checker.Contains, comment)
+ assert.Assert(c, strings.Contains(actualValue, comment))
}
-func (s *DockerSuite) TestHistoryHumanOptionFalse(c *check.C) {
+func (s *DockerSuite) TestHistoryHumanOptionFalse(c *testing.T) {
out, _ := dockerCmd(c, "history", "--human=false", "busybox")
lines := strings.Split(out, "\n")
sizeColumnRegex, _ := regexp.Compile("SIZE +")
@@ -97,11 +98,11 @@
sizeString := lines[i][startIndex:endIndex]
_, err := strconv.Atoi(strings.TrimSpace(sizeString))
- c.Assert(err, checker.IsNil, check.Commentf("The size '%s' was not an Integer", sizeString))
+ assert.Assert(c, err == nil, "The size '%s' was not an Integer", sizeString)
}
}
-func (s *DockerSuite) TestHistoryHumanOptionTrue(c *check.C) {
+func (s *DockerSuite) TestHistoryHumanOptionTrue(c *testing.T) {
out, _ := dockerCmd(c, "history", "--human=true", "busybox")
lines := strings.Split(out, "\n")
sizeColumnRegex, _ := regexp.Compile("SIZE +")
@@ -114,6 +115,7 @@
endIndex = len(lines[i])
}
sizeString := lines[i][startIndex:endIndex]
- c.Assert(strings.TrimSpace(sizeString), checker.Matches, humanSizeRegexRaw, check.Commentf("The size '%s' was not in human format", sizeString))
+ assert.Assert(c, cmp.Regexp("^"+humanSizeRegexRaw+"$",
+ strings.TrimSpace(sizeString)), fmt.Sprintf("The size '%s' was not in human format", sizeString))
}
}
diff --git a/integration-cli/docker_cli_images_test.go b/integration-cli/docker_cli_images_test.go
index 652acc5..e9e728b 100644
--- a/integration-cli/docker_cli_images_test.go
+++ b/integration-cli/docker_cli_images_test.go
@@ -8,47 +8,45 @@
"reflect"
"sort"
"strings"
+ "testing"
"time"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/pkg/stringid"
- "github.com/go-check/check"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
"gotest.tools/icmd"
)
-func (s *DockerSuite) TestImagesEnsureImageIsListed(c *check.C) {
+func (s *DockerSuite) TestImagesEnsureImageIsListed(c *testing.T) {
imagesOut, _ := dockerCmd(c, "images")
- c.Assert(imagesOut, checker.Contains, "busybox")
+ assert.Assert(c, strings.Contains(imagesOut, "busybox"))
}
-func (s *DockerSuite) TestImagesEnsureImageWithTagIsListed(c *check.C) {
+func (s *DockerSuite) TestImagesEnsureImageWithTagIsListed(c *testing.T) {
name := "imagewithtag"
dockerCmd(c, "tag", "busybox", name+":v1")
dockerCmd(c, "tag", "busybox", name+":v1v1")
dockerCmd(c, "tag", "busybox", name+":v2")
imagesOut, _ := dockerCmd(c, "images", name+":v1")
- c.Assert(imagesOut, checker.Contains, name)
- c.Assert(imagesOut, checker.Contains, "v1")
- c.Assert(imagesOut, checker.Not(checker.Contains), "v2")
- c.Assert(imagesOut, checker.Not(checker.Contains), "v1v1")
-
+ assert.Assert(c, strings.Contains(imagesOut, name))
+ assert.Assert(c, strings.Contains(imagesOut, "v1"))
+ assert.Assert(c, !strings.Contains(imagesOut, "v2"))
+ assert.Assert(c, !strings.Contains(imagesOut, "v1v1"))
imagesOut, _ = dockerCmd(c, "images", name)
- c.Assert(imagesOut, checker.Contains, name)
- c.Assert(imagesOut, checker.Contains, "v1")
- c.Assert(imagesOut, checker.Contains, "v1v1")
- c.Assert(imagesOut, checker.Contains, "v2")
+ assert.Assert(c, strings.Contains(imagesOut, name))
+ assert.Assert(c, strings.Contains(imagesOut, "v1"))
+ assert.Assert(c, strings.Contains(imagesOut, "v1v1"))
+ assert.Assert(c, strings.Contains(imagesOut, "v2"))
}
-func (s *DockerSuite) TestImagesEnsureImageWithBadTagIsNotListed(c *check.C) {
+func (s *DockerSuite) TestImagesEnsureImageWithBadTagIsNotListed(c *testing.T) {
imagesOut, _ := dockerCmd(c, "images", "busybox:nonexistent")
- c.Assert(imagesOut, checker.Not(checker.Contains), "busybox")
+ assert.Assert(c, !strings.Contains(imagesOut, "busybox"))
}
-func (s *DockerSuite) TestImagesOrderedByCreationDate(c *check.C) {
+func (s *DockerSuite) TestImagesOrderedByCreationDate(c *testing.T) {
buildImageSuccessfully(c, "order:test_a", build.WithDockerfile(`FROM busybox
MAINTAINER dockerio1`))
id1 := getIDByName(c, "order:test_a")
@@ -63,18 +61,18 @@
out, _ := dockerCmd(c, "images", "-q", "--no-trunc")
imgs := strings.Split(out, "\n")
- c.Assert(imgs[0], checker.Equals, id3, check.Commentf("First image must be %s, got %s", id3, imgs[0]))
- c.Assert(imgs[1], checker.Equals, id2, check.Commentf("First image must be %s, got %s", id2, imgs[1]))
- c.Assert(imgs[2], checker.Equals, id1, check.Commentf("First image must be %s, got %s", id1, imgs[2]))
+ assert.Equal(c, imgs[0], id3, fmt.Sprintf("First image must be %s, got %s", id3, imgs[0]))
+ assert.Equal(c, imgs[1], id2, fmt.Sprintf("First image must be %s, got %s", id2, imgs[1]))
+ assert.Equal(c, imgs[2], id1, fmt.Sprintf("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")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "Invalid filter")
+ assert.Assert(c, strings.Contains(out, "Invalid filter"))
}
-func (s *DockerSuite) TestImagesFilterLabelMatch(c *check.C) {
+func (s *DockerSuite) TestImagesFilterLabelMatch(c *testing.T) {
imageName1 := "images_filter_test1"
imageName2 := "images_filter_test2"
imageName3 := "images_filter_test3"
@@ -92,9 +90,11 @@
out, _ := dockerCmd(c, "images", "--no-trunc", "-q", "-f", "label=match")
out = strings.TrimSpace(out)
- c.Assert(out, check.Matches, fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image1ID))
- c.Assert(out, check.Matches, fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image2ID))
- c.Assert(out, check.Not(check.Matches), fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image3ID))
+ assert.Assert(c, is.Regexp(fmt.Sprintf("^[\\s\\w:]*%s[\\s\\w:]*$", image1ID), out))
+
+ assert.Assert(c, is.Regexp(fmt.Sprintf("^[\\s\\w:]*%s[\\s\\w:]*$", image2ID), out))
+
+ assert.Assert(c, !is.Regexp(fmt.Sprintf("^[\\s\\w:]*%s[\\s\\w:]*$", image3ID), out)().Success())
out, _ = dockerCmd(c, "images", "--no-trunc", "-q", "-f", "label=match=me too")
out = strings.TrimSpace(out)
@@ -102,7 +102,7 @@
}
// Regression : #15659
-func (s *DockerSuite) TestCommitWithFilterLabel(c *check.C) {
+func (s *DockerSuite) TestCommitWithFilterLabel(c *testing.T) {
// Create a container
dockerCmd(c, "run", "--name", "bar", "busybox", "/bin/sh")
// Commit with labels "using changes"
@@ -114,7 +114,7 @@
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()+`
LABEL number=1`))
imageID1 := getIDByName(c, "image:1")
@@ -128,34 +128,34 @@
expected := []string{imageID3, imageID2}
out, _ := dockerCmd(c, "images", "-f", "since=image:1", "image")
- c.Assert(assertImageList(out, expected), checker.Equals, true, check.Commentf("SINCE filter: Image list is not in the correct order: %v\n%s", expected, out))
+ assert.Equal(c, assertImageList(out, expected), true, fmt.Sprintf("SINCE filter: Image list is not in the correct order: %v\n%s", expected, out))
out, _ = dockerCmd(c, "images", "-f", "since="+imageID1, "image")
- c.Assert(assertImageList(out, expected), checker.Equals, true, check.Commentf("SINCE filter: Image list is not in the correct order: %v\n%s", expected, out))
+ assert.Equal(c, assertImageList(out, expected), true, fmt.Sprintf("SINCE filter: Image list is not in the correct order: %v\n%s", expected, out))
expected = []string{imageID3}
out, _ = dockerCmd(c, "images", "-f", "since=image:2", "image")
- c.Assert(assertImageList(out, expected), checker.Equals, true, check.Commentf("SINCE filter: Image list is not in the correct order: %v\n%s", expected, out))
+ assert.Equal(c, assertImageList(out, expected), true, fmt.Sprintf("SINCE filter: Image list is not in the correct order: %v\n%s", expected, out))
out, _ = dockerCmd(c, "images", "-f", "since="+imageID2, "image")
- c.Assert(assertImageList(out, expected), checker.Equals, true, check.Commentf("SINCE filter: Image list is not in the correct order: %v\n%s", expected, out))
+ assert.Equal(c, assertImageList(out, expected), true, fmt.Sprintf("SINCE filter: Image list is not in the correct order: %v\n%s", expected, out))
expected = []string{imageID2, imageID1}
out, _ = dockerCmd(c, "images", "-f", "before=image:3", "image")
- c.Assert(assertImageList(out, expected), checker.Equals, true, check.Commentf("BEFORE filter: Image list is not in the correct order: %v\n%s", expected, out))
+ assert.Equal(c, assertImageList(out, expected), true, fmt.Sprintf("BEFORE filter: Image list is not in the correct order: %v\n%s", expected, out))
out, _ = dockerCmd(c, "images", "-f", "before="+imageID3, "image")
- c.Assert(assertImageList(out, expected), checker.Equals, true, check.Commentf("BEFORE filter: Image list is not in the correct order: %v\n%s", expected, out))
+ assert.Equal(c, assertImageList(out, expected), true, fmt.Sprintf("BEFORE filter: Image list is not in the correct order: %v\n%s", expected, out))
expected = []string{imageID1}
out, _ = dockerCmd(c, "images", "-f", "before=image:2", "image")
- c.Assert(assertImageList(out, expected), checker.Equals, true, check.Commentf("BEFORE filter: Image list is not in the correct order: %v\n%s", expected, out))
+ assert.Equal(c, assertImageList(out, expected), true, fmt.Sprintf("BEFORE filter: Image list is not in the correct order: %v\n%s", expected, out))
out, _ = dockerCmd(c, "images", "-f", "before="+imageID2, "image")
- c.Assert(assertImageList(out, expected), checker.Equals, true, check.Commentf("BEFORE filter: Image list is not in the correct order: %v\n%s", expected, out))
+ assert.Equal(c, assertImageList(out, expected), true, fmt.Sprintf("BEFORE filter: Image list is not in the correct order: %v\n%s", expected, out))
}
func assertImageList(out string, expected []string) bool {
@@ -184,7 +184,7 @@
}
// 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"
// Build a image and fail to build so that we have dangling images ?
buildImage(imageName, build.WithDockerfile(`FROM busybox
@@ -224,7 +224,7 @@
}
}
-func (s *DockerSuite) TestImagesEnsureDanglingImageOnlyListedOnce(c *check.C) {
+func (s *DockerSuite) TestImagesEnsureDanglingImageOnlyListedOnce(c *testing.T) {
testRequires(c, DaemonIsLinux)
// create container 1
out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
@@ -239,26 +239,24 @@
out, _ = dockerCmd(c, "images", "-q", "-f", "dangling=true")
// Expect one dangling image
- c.Assert(strings.Count(out, imageID), checker.Equals, 1)
+ assert.Equal(c, strings.Count(out, imageID), 1)
out, _ = dockerCmd(c, "images", "-q", "-f", "dangling=false")
//dangling=false would not include dangling images
- c.Assert(out, checker.Not(checker.Contains), imageID)
-
+ assert.Assert(c, !strings.Contains(out, imageID))
out, _ = dockerCmd(c, "images")
//docker images still include dangling images
- c.Assert(out, checker.Contains, imageID)
-
+ assert.Assert(c, strings.Contains(out, imageID))
}
// 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")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "Invalid filter")
+ assert.Assert(c, strings.Contains(out, "Invalid filter"))
}
-func (s *DockerSuite) TestImagesEnsureOnlyHeadsImagesShown(c *check.C) {
+func (s *DockerSuite) TestImagesEnsureOnlyHeadsImagesShown(c *testing.T) {
dockerfile := `
FROM busybox
MAINTAINER docker
@@ -276,12 +274,12 @@
out, _ := dockerCmd(c, "images")
// images shouldn't show non-heads images
- c.Assert(out, checker.Not(checker.Contains), intermediate)
+ assert.Assert(c, !strings.Contains(out, intermediate))
// images should contain final built images
- c.Assert(out, checker.Contains, stringid.TruncateID(id))
+ assert.Assert(c, strings.Contains(out, 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
dockerfile := `
FROM scratch
@@ -293,12 +291,12 @@
out, _ := dockerCmd(c, "images")
// images should contain images built from scratch
- c.Assert(out, checker.Contains, stringid.TruncateID(id))
+ assert.Assert(c, strings.Contains(out, stringid.TruncateID(id)))
}
// For W2W - equivalent to TestImagesEnsureImagesFromScratchShown but Windows
// doesn't support from scratch
-func (s *DockerSuite) TestImagesEnsureImagesFromBusyboxShown(c *check.C) {
+func (s *DockerSuite) TestImagesEnsureImagesFromBusyboxShown(c *testing.T) {
dockerfile := `
FROM busybox
MAINTAINER docker`
@@ -309,24 +307,22 @@
out, _ := dockerCmd(c, "images")
// images should contain images built from busybox
- c.Assert(out, checker.Contains, stringid.TruncateID(id))
+ assert.Assert(c, strings.Contains(out, stringid.TruncateID(id)))
}
// #18181
-func (s *DockerSuite) TestImagesFilterNameWithPort(c *check.C) {
+func (s *DockerSuite) TestImagesFilterNameWithPort(c *testing.T) {
tag := "a.b.c.d:5000/hello"
dockerCmd(c, "tag", "busybox", tag)
out, _ := dockerCmd(c, "images", tag)
- c.Assert(out, checker.Contains, tag)
-
+ assert.Assert(c, strings.Contains(out, tag))
out, _ = dockerCmd(c, "images", tag+":latest")
- c.Assert(out, checker.Contains, tag)
-
+ assert.Assert(c, strings.Contains(out, tag))
out, _ = dockerCmd(c, "images", tag+":no-such-tag")
- c.Assert(out, checker.Not(checker.Contains), tag)
+ assert.Assert(c, !strings.Contains(out, tag))
}
-func (s *DockerSuite) TestImagesFormat(c *check.C) {
+func (s *DockerSuite) TestImagesFormat(c *testing.T) {
// testRequires(c, DaemonIsLinux)
tag := "myimage"
dockerCmd(c, "tag", "busybox", tag+":v1")
@@ -342,7 +338,7 @@
}
// ImagesDefaultFormatAndQuiet
-func (s *DockerSuite) TestImagesFormatDefaultFormat(c *check.C) {
+func (s *DockerSuite) TestImagesFormatDefaultFormat(c *testing.T) {
testRequires(c, DaemonIsLinux)
// create container 1
diff --git a/integration-cli/docker_cli_import_test.go b/integration-cli/docker_cli_import_test.go
index 11cebf1..3506c18 100644
--- a/integration-cli/docker_cli_import_test.go
+++ b/integration-cli/docker_cli_import_test.go
@@ -8,15 +8,14 @@
"os/exec"
"regexp"
"strings"
+ "testing"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli"
- "github.com/go-check/check"
"gotest.tools/assert"
"gotest.tools/icmd"
)
-func (s *DockerSuite) TestImportDisplay(c *check.C) {
+func (s *DockerSuite) TestImportDisplay(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
cleanedContainerID := strings.TrimSpace(out)
@@ -34,9 +33,9 @@
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")
- c.Assert(err, checker.NotNil, check.Commentf("import was supposed to fail but didn't"))
+ assert.Assert(c, err != nil, "import was supposed to fail but didn't")
// Depending on your system you can get either of these errors
if !strings.Contains(out, "dial tcp") &&
!strings.Contains(out, "ApplyLayer exit status 1 stdout: stderr: archive/tar: invalid tar header") &&
@@ -45,12 +44,12 @@
}
}
-func (s *DockerSuite) TestImportFile(c *check.C) {
+func (s *DockerSuite) TestImportFile(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "--name", "test-import", "busybox", "true")
temporaryFile, err := ioutil.TempFile("", "exportImportTest")
- c.Assert(err, checker.IsNil, check.Commentf("failed to create temporary file"))
+ assert.Assert(c, err == nil, "failed to create temporary file")
defer os.Remove(temporaryFile.Name())
icmd.RunCmd(icmd.Cmd{
@@ -66,12 +65,12 @@
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)
dockerCmd(c, "run", "--name", "test-import", "busybox", "true")
temporaryFile, err := ioutil.TempFile("", "exportImportTest")
- c.Assert(err, checker.IsNil, check.Commentf("failed to create temporary file"))
+ assert.Assert(c, err == nil, "failed to create temporary file")
defer os.Remove(temporaryFile.Name())
w := gzip.NewWriter(temporaryFile)
@@ -79,7 +78,7 @@
Command: []string{dockerBinary, "export", "test-import"},
Stdout: w,
}).Assert(c, icmd.Success)
- c.Assert(w.Close(), checker.IsNil, check.Commentf("failed to close gzip writer"))
+ assert.Assert(c, w.Close() == nil, "failed to close gzip writer")
temporaryFile.Close()
out, _ := dockerCmd(c, "import", temporaryFile.Name())
assert.Assert(c, strings.Count(out, "\n") == 1, "display is expected 1 '\\n' but didn't")
@@ -89,12 +88,12 @@
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)
dockerCmd(c, "run", "--name", "test-import", "busybox", "true")
temporaryFile, err := ioutil.TempFile("", "exportImportTest")
- c.Assert(err, checker.IsNil, check.Commentf("failed to create temporary file"))
+ assert.Assert(c, err == nil, "failed to create temporary file")
defer os.Remove(temporaryFile.Name())
icmd.RunCmd(icmd.Cmd{
@@ -110,27 +109,27 @@
out, _ = dockerCmd(c, "history", image)
split := strings.Split(out, "\n")
- c.Assert(split, checker.HasLen, 3, check.Commentf("expected 3 lines from image history"))
+ assert.Equal(c, len(split), 3, "expected 3 lines from image history")
r := regexp.MustCompile("[\\s]{2,}")
split = r.Split(split[1], -1)
- c.Assert(message, checker.Equals, split[3], check.Commentf("didn't get expected value in commit message"))
+ assert.Equal(c, message, split[3], "didn't get expected value in commit message")
out, _ = dockerCmd(c, "run", "--rm", image, "true")
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")
- c.Assert(err, checker.NotNil, check.Commentf("import non-existing file must failed"))
+ assert.Assert(c, err != nil, "import non-existing file must failed")
}
-func (s *DockerSuite) TestImportWithQuotedChanges(c *check.C) {
+func (s *DockerSuite) TestImportWithQuotedChanges(c *testing.T) {
testRequires(c, DaemonIsLinux)
cli.DockerCmd(c, "run", "--name", "test-import", "busybox", "true")
temporaryFile, err := ioutil.TempFile("", "exportImportTest")
- c.Assert(err, checker.IsNil, check.Commentf("failed to create temporary file"))
+ assert.Assert(c, err == nil, "failed to create temporary file")
defer os.Remove(temporaryFile.Name())
cli.Docker(cli.Args("export", "test-import"), cli.WithStdout(bufio.NewWriter(temporaryFile))).Assert(c, icmd.Success)
diff --git a/integration-cli/docker_cli_info_test.go b/integration-cli/docker_cli_info_test.go
index c569a0d..410a00e 100644
--- a/integration-cli/docker_cli_info_test.go
+++ b/integration-cli/docker_cli_info_test.go
@@ -5,16 +5,15 @@
"fmt"
"net"
"strings"
+ "testing"
- "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"
"gotest.tools/assert"
)
// ensure docker info succeeds
-func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) {
+func (s *DockerSuite) TestInfoEnsureSucceeds(c *testing.T) {
out, _ := dockerCmd(c, "info")
// always shown fields
@@ -53,14 +52,14 @@
}
for _, linePrefix := range stringsToCheck {
- c.Assert(out, checker.Contains, linePrefix, check.Commentf("couldn't find string %v in output", linePrefix))
+ assert.Assert(c, strings.Contains(out, linePrefix), "couldn't find string %v in output", linePrefix)
}
}
// 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 .}}")
- c.Assert(status, checker.Equals, 0)
+ assert.Equal(c, status, 0)
var m map[string]interface{}
err := json.Unmarshal([]byte(out), &m)
assert.NilError(c, err)
@@ -70,7 +69,7 @@
// TestInfoDiscoveryBackend verifies that a daemon run with `--cluster-advertise` and
// `--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)
d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
@@ -81,13 +80,13 @@
out, err := d.Cmd("info")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, fmt.Sprintf("Cluster Store: %s\n", discoveryBackend))
- c.Assert(out, checker.Contains, fmt.Sprintf("Cluster Advertise: %s\n", discoveryAdvertise))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf("Cluster Store: %s\n", discoveryBackend)))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf("Cluster Advertise: %s\n", discoveryAdvertise)))
}
// TestInfoDiscoveryInvalidAdvertise verifies that a daemon run with
// an invalid `--cluster-advertise` configuration
-func (s *DockerSuite) TestInfoDiscoveryInvalidAdvertise(c *check.C) {
+func (s *DockerSuite) TestInfoDiscoveryInvalidAdvertise(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
@@ -104,7 +103,7 @@
// TestInfoDiscoveryAdvertiseInterfaceName verifies that a daemon run with `--cluster-advertise`
// 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)
d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
@@ -124,24 +123,24 @@
out, err := d.Cmd("info")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, fmt.Sprintf("Cluster Store: %s\n", discoveryBackend))
- c.Assert(out, checker.Contains, fmt.Sprintf("Cluster Advertise: %s:2375\n", ip.String()))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf("Cluster Store: %s\n", discoveryBackend)))
+ assert.Assert(c, strings.Contains(out, 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)
existing := existingContainerStates(c)
dockerCmd(c, "run", "-d", "busybox", "top")
out, _ := dockerCmd(c, "info")
- c.Assert(out, checker.Contains, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1))
- c.Assert(out, checker.Contains, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"]+1))
- c.Assert(out, checker.Contains, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"]))
- c.Assert(out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"]))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1)))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"]+1)))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"])))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"])))
}
-func (s *DockerSuite) TestInfoDisplaysPausedContainers(c *check.C) {
+func (s *DockerSuite) TestInfoDisplaysPausedContainers(c *testing.T) {
testRequires(c, IsPausable)
existing := existingContainerStates(c)
@@ -152,13 +151,13 @@
dockerCmd(c, "pause", cleanedContainerID)
out, _ = dockerCmd(c, "info")
- c.Assert(out, checker.Contains, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1))
- c.Assert(out, checker.Contains, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"]))
- c.Assert(out, checker.Contains, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"]+1))
- c.Assert(out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"]))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1)))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"])))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"]+1)))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"])))
}
-func (s *DockerSuite) TestInfoDisplaysStoppedContainers(c *check.C) {
+func (s *DockerSuite) TestInfoDisplaysStoppedContainers(c *testing.T) {
testRequires(c, DaemonIsLinux)
existing := existingContainerStates(c)
@@ -169,13 +168,13 @@
dockerCmd(c, "stop", cleanedContainerID)
out, _ = dockerCmd(c, "info")
- c.Assert(out, checker.Contains, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1))
- c.Assert(out, checker.Contains, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"]))
- c.Assert(out, checker.Contains, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"]))
- c.Assert(out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"]+1))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1)))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"])))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"])))
+ assert.Assert(c, strings.Contains(out, 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)
d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
@@ -184,16 +183,16 @@
out, err := d.Cmd("--debug", "info")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, "Debug Mode (client): true\n")
- c.Assert(out, checker.Contains, "Debug Mode (server): true\n")
- c.Assert(out, checker.Contains, "File Descriptors")
- c.Assert(out, checker.Contains, "Goroutines")
- c.Assert(out, checker.Contains, "System Time")
- c.Assert(out, checker.Contains, "EventsListeners")
- c.Assert(out, checker.Contains, "Docker Root Dir")
+ assert.Assert(c, strings.Contains(out, "Debug Mode (client): true\n"))
+ assert.Assert(c, strings.Contains(out, "Debug Mode (server): true\n"))
+ assert.Assert(c, strings.Contains(out, "File Descriptors"))
+ assert.Assert(c, strings.Contains(out, "Goroutines"))
+ assert.Assert(c, strings.Contains(out, "System Time"))
+ assert.Assert(c, strings.Contains(out, "EventsListeners"))
+ assert.Assert(c, strings.Contains(out, "Docker Root Dir"))
}
-func (s *DockerSuite) TestInsecureRegistries(c *check.C) {
+func (s *DockerSuite) TestInsecureRegistries(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
registryCIDR := "192.168.1.0/24"
@@ -205,12 +204,12 @@
out, err := d.Cmd("info")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, "Insecure Registries:\n")
- c.Assert(out, checker.Contains, fmt.Sprintf(" %s\n", registryHost))
- c.Assert(out, checker.Contains, fmt.Sprintf(" %s\n", registryCIDR))
+ assert.Assert(c, strings.Contains(out, "Insecure Registries:\n"))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf(" %s\n", registryHost)))
+ assert.Assert(c, strings.Contains(out, 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"
registryMirror2 := "http://registry.mirror.com:5000"
@@ -219,12 +218,12 @@
out, err := s.d.Cmd("info")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, "Registry Mirrors:\n")
- c.Assert(out, checker.Contains, fmt.Sprintf(" %s", registryMirror1))
- c.Assert(out, checker.Contains, fmt.Sprintf(" %s", registryMirror2))
+ assert.Assert(c, strings.Contains(out, "Registry Mirrors:\n"))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf(" %s", registryMirror1)))
+ assert.Assert(c, strings.Contains(out, 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 .}}")
var m map[string]interface{}
err := json.Unmarshal([]byte(out), &m)
diff --git a/integration-cli/docker_cli_info_unix_test.go b/integration-cli/docker_cli_info_unix_test.go
index 3ac1f95..59e0764 100644
--- a/integration-cli/docker_cli_info_unix_test.go
+++ b/integration-cli/docker_cli_info_unix_test.go
@@ -3,13 +3,15 @@
package main
import (
- "github.com/docker/docker/integration-cli/checker"
- "github.com/go-check/check"
+ "strings"
+ "testing"
+
+ "gotest.tools/assert"
)
-func (s *DockerSuite) TestInfoSecurityOptions(c *check.C) {
+func (s *DockerSuite) TestInfoSecurityOptions(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, Apparmor, DaemonIsLinux)
out, _ := dockerCmd(c, "info")
- c.Assert(out, checker.Contains, "Security Options:\n apparmor\n seccomp\n Profile: default\n")
+ assert.Assert(c, strings.Contains(out, "Security Options:\n apparmor\n seccomp\n Profile: default\n"))
}
diff --git a/integration-cli/docker_cli_inspect_test.go b/integration-cli/docker_cli_inspect_test.go
index 620272f..be80439 100644
--- a/integration-cli/docker_cli_inspect_test.go
+++ b/integration-cli/docker_cli_inspect_test.go
@@ -6,23 +6,22 @@
"os"
"strconv"
"strings"
+ "testing"
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
- "github.com/docker/docker/integration-cli/checker"
- "github.com/go-check/check"
"gotest.tools/assert"
"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" {
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)
imageTest := "emptyfs"
// It is important that this ID remain stable. If a code change causes
@@ -33,16 +32,16 @@
imageTestID := "sha256:11f64303f0f7ffdc71f001788132bca5346831939a956e3e975c93267d89a16d"
id := inspectField(c, imageTest, "Id")
- c.Assert(id, checker.Equals, imageTestID)
+ assert.Equal(c, id, 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")
inspectOut := inspectField(c, "inspectTest", "HostConfig.Memory")
- c.Assert(inspectOut, checker.Equals, "314572800")
+ assert.Equal(c, inspectOut, "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.
//If the container JSON is not available, it will go for the image JSON.
@@ -50,35 +49,35 @@
containerID := strings.TrimSpace(out)
inspectOut := inspectField(c, "busybox", "Id")
- c.Assert(strings.TrimSpace(inspectOut), checker.Equals, containerID)
+ assert.Equal(c, strings.TrimSpace(inspectOut), containerID)
}
-func (s *DockerSuite) TestInspectStatus(c *check.C) {
+func (s *DockerSuite) TestInspectStatus(c *testing.T) {
out := runSleepingContainer(c, "-d")
out = strings.TrimSpace(out)
inspectOut := inspectField(c, out, "State.Status")
- c.Assert(inspectOut, checker.Equals, "running")
+ assert.Equal(c, inspectOut, "running")
// Windows does not support pause/unpause on Windows Server Containers.
// (RS1 does for Hyper-V Containers, but production CI is not setup for that)
if testEnv.OSType != "windows" {
dockerCmd(c, "pause", out)
inspectOut = inspectField(c, out, "State.Status")
- c.Assert(inspectOut, checker.Equals, "paused")
+ assert.Equal(c, inspectOut, "paused")
dockerCmd(c, "unpause", out)
inspectOut = inspectField(c, out, "State.Status")
- c.Assert(inspectOut, checker.Equals, "running")
+ assert.Equal(c, inspectOut, "running")
}
dockerCmd(c, "stop", out)
inspectOut = inspectField(c, out, "State.Status")
- c.Assert(inspectOut, checker.Equals, "exited")
+ assert.Equal(c, inspectOut, "exited")
}
-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
//JSON State.Running field. If the field is true, it's a container.
runSleepingContainer(c, "--name=busybox", "-d")
@@ -88,7 +87,7 @@
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
//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.
@@ -100,7 +99,7 @@
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
//JSON as --type=image. if there is no image with name busybox, docker inspect
//will throw an error.
@@ -108,38 +107,39 @@
dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "true")
out, _ := dockerCmd(c, "inspect", "--type=image", "busybox")
- c.Assert(out, checker.Not(checker.Contains), "State") // not an image JSON
+ // not an image JSON
+ assert.Assert(c, !strings.Contains(out, "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
//as --type=foobar is not a valid value for the flag.
dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "true")
out, exitCode, err := dockerCmdWithError("inspect", "--type=foobar", "busybox")
- c.Assert(err, checker.NotNil, check.Commentf("%s", exitCode))
- c.Assert(exitCode, checker.Equals, 1, check.Commentf("%s", err))
- c.Assert(out, checker.Contains, "not a valid value for --type")
+ assert.Assert(c, err != nil, "%d", exitCode)
+ assert.Equal(c, exitCode, 1, fmt.Sprintf("%s", err))
+ assert.Assert(c, strings.Contains(out, "not a valid value for --type"))
}
-func (s *DockerSuite) TestInspectImageFilterInt(c *check.C) {
+func (s *DockerSuite) TestInspectImageFilterInt(c *testing.T) {
testRequires(c, DaemonIsLinux)
imageTest := "emptyfs"
out := inspectField(c, imageTest, "Size")
size, err := strconv.Atoi(out)
- c.Assert(err, checker.IsNil, check.Commentf("failed to inspect size of the image: %s, %v", out, err))
+ assert.Assert(c, err == nil, "failed to inspect size of the image: %s, %v", out, err)
//now see if the size turns out to be the same
formatStr := fmt.Sprintf("--format={{eq .Size %d}}", size)
out, _ = dockerCmd(c, "inspect", formatStr, imageTest)
result, err := strconv.ParseBool(strings.TrimSuffix(out, "\n"))
assert.NilError(c, err)
- c.Assert(result, checker.Equals, true)
+ assert.Equal(c, result, true)
}
-func (s *DockerSuite) TestInspectContainerFilterInt(c *check.C) {
+func (s *DockerSuite) TestInspectContainerFilterInt(c *testing.T) {
result := icmd.RunCmd(icmd.Cmd{
Command: []string{dockerBinary, "run", "-i", "-a", "stdin", "busybox", "cat"},
Stdin: strings.NewReader("blahblah"),
@@ -151,17 +151,17 @@
out = inspectField(c, id, "State.ExitCode")
exitCode, err := strconv.Atoi(out)
- c.Assert(err, checker.IsNil, check.Commentf("failed to inspect exitcode of the container: %s, %v", out, err))
+ assert.Assert(c, err == nil, "failed to inspect exitcode of the container: %s, %v", out, err)
//now get the exit code to verify
formatStr := fmt.Sprintf("--format={{eq .State.ExitCode %d}}", exitCode)
out, _ = dockerCmd(c, "inspect", formatStr, id)
inspectResult, err := strconv.ParseBool(strings.TrimSuffix(out, "\n"))
assert.NilError(c, err)
- c.Assert(inspectResult, checker.Equals, true)
+ assert.Equal(c, inspectResult, true)
}
-func (s *DockerSuite) TestInspectImageGraphDriver(c *check.C) {
+func (s *DockerSuite) TestInspectImageGraphDriver(c *testing.T) {
testRequires(c, DaemonIsLinux, Devicemapper)
imageTest := "emptyfs"
name := inspectField(c, imageTest, "GraphDriver.Name")
@@ -171,15 +171,15 @@
deviceID := inspectField(c, imageTest, "GraphDriver.Data.DeviceId")
_, err := strconv.Atoi(deviceID)
- c.Assert(err, checker.IsNil, check.Commentf("failed to inspect DeviceId of the image: %s, %v", deviceID, err))
+ assert.Assert(c, err == nil, "failed to inspect DeviceId of the image: %s, %v", deviceID, err)
deviceSize := inspectField(c, imageTest, "GraphDriver.Data.DeviceSize")
_, err = strconv.ParseUint(deviceSize, 10, 64)
- c.Assert(err, checker.IsNil, check.Commentf("failed to inspect DeviceSize of the image: %s, %v", deviceSize, err))
+ assert.Assert(c, err == nil, "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)
out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
@@ -193,18 +193,18 @@
deviceID := inspectField(c, out, "GraphDriver.Data.DeviceId")
- c.Assert(imageDeviceID, checker.Not(checker.Equals), deviceID)
+ assert.Assert(c, imageDeviceID != deviceID)
_, err := strconv.Atoi(deviceID)
- c.Assert(err, checker.IsNil, check.Commentf("failed to inspect DeviceId of the image: %s, %v", deviceID, err))
+ assert.Assert(c, err == nil, "failed to inspect DeviceId of the image: %s, %v", deviceID, err)
deviceSize := inspectField(c, out, "GraphDriver.Data.DeviceSize")
_, err = strconv.ParseUint(deviceSize, 10, 64)
- c.Assert(err, checker.IsNil, check.Commentf("failed to inspect DeviceSize of the image: %s, %v", deviceSize, err))
+ assert.Assert(c, err == nil, "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"
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
if testEnv.OSType == "windows" {
@@ -222,21 +222,21 @@
assert.NilError(c, err)
// check that there is only one mountpoint
- c.Assert(mp, check.HasLen, 1)
+ assert.Equal(c, len(mp), 1)
m := mp[0]
- c.Assert(m.Name, checker.Equals, "")
- c.Assert(m.Driver, checker.Equals, "")
- c.Assert(m.Source, checker.Equals, prefix+slash+"data")
- c.Assert(m.Destination, checker.Equals, prefix+slash+"data")
+ assert.Equal(c, m.Name, "")
+ assert.Equal(c, m.Driver, "")
+ assert.Equal(c, m.Source, prefix+slash+"data")
+ assert.Equal(c, m.Destination, prefix+slash+"data")
if testEnv.OSType != "windows" { // Windows does not set mode
- c.Assert(m.Mode, checker.Equals, "ro"+modifier)
+ assert.Equal(c, m.Mode, "ro"+modifier)
}
- c.Assert(m.RW, checker.Equals, false)
+ assert.Equal(c, m.RW, false)
}
-func (s *DockerSuite) TestInspectNamedMountPoint(c *check.C) {
+func (s *DockerSuite) TestInspectNamedMountPoint(c *testing.T) {
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
dockerCmd(c, "run", "-d", "--name", "test", "-v", "data:"+prefix+slash+"data", "busybox", "cat")
@@ -248,19 +248,19 @@
assert.NilError(c, err)
// check that there is only one mountpoint
- c.Assert(mp, checker.HasLen, 1)
+ assert.Equal(c, len(mp), 1)
m := mp[0]
- c.Assert(m.Name, checker.Equals, "data")
- c.Assert(m.Driver, checker.Equals, "local")
- c.Assert(m.Source, checker.Not(checker.Equals), "")
- c.Assert(m.Destination, checker.Equals, prefix+slash+"data")
- c.Assert(m.RW, checker.Equals, true)
+ assert.Equal(c, m.Name, "data")
+ assert.Equal(c, m.Driver, "local")
+ assert.Assert(c, m.Source != "")
+ assert.Equal(c, m.Destination, prefix+slash+"data")
+ assert.Equal(c, m.RW, true)
}
// #14947
-func (s *DockerSuite) TestInspectTimesAsRFC3339Nano(c *check.C) {
+func (s *DockerSuite) TestInspectTimesAsRFC3339Nano(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
id := strings.TrimSpace(out)
startedAt := inspectField(c, id, "State.StartedAt")
@@ -281,20 +281,20 @@
}
// #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")
var logConfig container.LogConfig
out := inspectFieldJSON(c, "test", "HostConfig.LogConfig")
err := json.NewDecoder(strings.NewReader(out)).Decode(&logConfig)
- c.Assert(err, checker.IsNil, check.Commentf("%v", out))
+ assert.Assert(c, err == nil, "%v", out)
- c.Assert(logConfig.Type, checker.Equals, "json-file")
- c.Assert(logConfig.Config["max-file"], checker.Equals, "42", check.Commentf("%v", logConfig))
+ assert.Equal(c, logConfig.Type, "json-file")
+ assert.Equal(c, logConfig.Config["max-file"], "42", fmt.Sprintf("%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
//JSON SizeRw and SizeRootFs field. If there is no flag --size/-s, there are no size fields.
@@ -303,35 +303,34 @@
formatStr := "--format={{.SizeRw}},{{.SizeRootFs}}"
out, _ := dockerCmd(c, "inspect", "--type=container", formatStr, "busybox")
- c.Assert(strings.TrimSpace(out), check.Equals, "<nil>,<nil>", check.Commentf("Expected not to display size info: %s", out))
+ assert.Equal(c, strings.TrimSpace(out), "<nil>,<nil>", fmt.Sprintf("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")
formatStr := "--format='{{.SizeRw}},{{.SizeRootFs}}'"
out, _ := dockerCmd(c, "inspect", "-s", "--type=container", formatStr, "busybox")
sz := strings.Split(out, ",")
- c.Assert(strings.TrimSpace(sz[0]), check.Not(check.Equals), "<nil>")
- c.Assert(strings.TrimSpace(sz[1]), check.Not(check.Equals), "<nil>")
+ assert.Assert(c, strings.TrimSpace(sz[0]) != "<nil>")
+ assert.Assert(c, strings.TrimSpace(sz[1]) != "<nil>")
}
-func (s *DockerSuite) TestInspectTemplateError(c *check.C) {
+func (s *DockerSuite) TestInspectTemplateError(c *testing.T) {
// Template parsing error for both the container and image.
runSleepingContainer(c, "--name=container1", "-d")
out, _, err := dockerCmdWithError("inspect", "--type=container", "--format='Format container: {{.ThisDoesNotExist}}'", "container1")
- c.Assert(err, check.Not(check.IsNil))
- c.Assert(out, checker.Contains, "Template parsing error")
-
+ assert.Assert(c, err != nil)
+ assert.Assert(c, strings.Contains(out, "Template parsing error"))
out, _, err = dockerCmdWithError("inspect", "--type=image", "--format='Format container: {{.ThisDoesNotExist}}'", "busybox")
- c.Assert(err, check.Not(check.IsNil))
- c.Assert(out, checker.Contains, "Template parsing error")
+ assert.Assert(c, err != nil)
+ assert.Assert(c, strings.Contains(out, "Template parsing error"))
}
-func (s *DockerSuite) TestInspectJSONFields(c *check.C) {
+func (s *DockerSuite) TestInspectJSONFields(c *testing.T) {
runSleepingContainer(c, "--name=busybox", "-d")
out, _, err := dockerCmdWithError("inspect", "--type=container", "--format={{.HostConfig.Dns}}", "busybox")
@@ -339,68 +338,67 @@
assert.Equal(c, out, "[]\n")
}
-func (s *DockerSuite) TestInspectByPrefix(c *check.C) {
+func (s *DockerSuite) TestInspectByPrefix(c *testing.T) {
id := inspectField(c, "busybox", "Id")
assert.Assert(c, strings.HasPrefix(id, "sha256:"))
id2 := inspectField(c, id[:12], "Id")
- c.Assert(id, checker.Equals, id2)
+ assert.Equal(c, id, id2)
id3 := inspectField(c, strings.TrimPrefix(id, "sha256:")[:12], "Id")
- c.Assert(id, checker.Equals, id3)
+ assert.Equal(c, id, id3)
}
-func (s *DockerSuite) TestInspectStopWhenNotFound(c *check.C) {
+func (s *DockerSuite) TestInspectStopWhenNotFound(c *testing.T) {
runSleepingContainer(c, "--name=busybox1", "-d")
runSleepingContainer(c, "--name=busybox2", "-d")
result := dockerCmdWithResult("inspect", "--type=container", "--format='{{.Name}}'", "busybox1", "busybox2", "missing")
- c.Assert(result.Error, checker.Not(check.IsNil))
- c.Assert(result.Stdout(), checker.Contains, "busybox1")
- c.Assert(result.Stdout(), checker.Contains, "busybox2")
- c.Assert(result.Stderr(), checker.Contains, "Error: No such container: missing")
-
+ assert.Assert(c, result.Error != nil)
+ assert.Assert(c, strings.Contains(result.Stdout(), "busybox1"))
+ assert.Assert(c, strings.Contains(result.Stdout(), "busybox2"))
+ assert.Assert(c, strings.Contains(result.Stderr(), "Error: No such container: missing"))
// test inspect would not fast fail
result = dockerCmdWithResult("inspect", "--type=container", "--format='{{.Name}}'", "missing", "busybox1", "busybox2")
- c.Assert(result.Error, checker.Not(check.IsNil))
- c.Assert(result.Stdout(), checker.Contains, "busybox1")
- c.Assert(result.Stdout(), checker.Contains, "busybox2")
- c.Assert(result.Stderr(), checker.Contains, "Error: No such container: missing")
+ assert.Assert(c, result.Error != nil)
+ assert.Assert(c, strings.Contains(result.Stdout(), "busybox1"))
+ assert.Assert(c, strings.Contains(result.Stdout(), "busybox2"))
+ assert.Assert(c, strings.Contains(result.Stderr(), "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, "commit", "-m", "test comment", "testcont", "testimg")
out, _, err := dockerCmdWithError("inspect", "--format='{{.Comment}}'", "testimg")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, "test comment")
+ assert.Assert(c, strings.Contains(out, "test comment"))
}
-func (s *DockerSuite) TestInspectContainerNetworkDefault(c *check.C) {
+func (s *DockerSuite) TestInspectContainerNetworkDefault(c *testing.T) {
testRequires(c, DaemonIsLinux)
contName := "test1"
dockerCmd(c, "run", "--name", contName, "-d", "busybox", "top")
netOut, _ := dockerCmd(c, "network", "inspect", "--format={{.ID}}", "bridge")
out := inspectField(c, contName, "NetworkSettings.Networks")
- c.Assert(out, checker.Contains, "bridge")
+ assert.Assert(c, strings.Contains(out, "bridge"))
out = inspectField(c, contName, "NetworkSettings.Networks.bridge.NetworkID")
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)
netOut, _ := dockerCmd(c, "network", "create", "net1")
dockerCmd(c, "run", "--name=container1", "--net=net1", "-d", "busybox", "top")
out := inspectField(c, "container1", "NetworkSettings.Networks")
- c.Assert(out, checker.Contains, "net1")
+ assert.Assert(c, strings.Contains(out, "net1"))
out = inspectField(c, "container1", "NetworkSettings.Networks.net1.NetworkID")
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")
assert.NilError(c, err)
@@ -410,17 +408,17 @@
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)
name := "test"
out, _ := dockerCmd(c, "run", "--name", name, "--env", `TEST_ENV="soanni&rtr"`, "busybox", "env")
- c.Assert(out, checker.Contains, `soanni&rtr`)
+ assert.Assert(c, strings.Contains(out, `soanni&rtr`))
out, _ = dockerCmd(c, "inspect", name)
- c.Assert(out, checker.Contains, `soanni&rtr`)
+ assert.Assert(c, strings.Contains(out, `soanni&rtr`))
}
-func (s *DockerSuite) TestInspectPlugin(c *check.C) {
+func (s *DockerSuite) TestInspectPlugin(c *testing.T) {
testRequires(c, DaemonIsLinux, IsAmd64, Network)
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
assert.NilError(c, err)
@@ -447,14 +445,14 @@
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
assert.NilError(c, err)
- c.Assert(out, checker.Contains, pNameWithTag)
+ assert.Assert(c, strings.Contains(out, pNameWithTag))
}
// 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
out, _, err := dockerCmdWithError("inspect", "foobar")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "Error: No such object: foobar")
+ assert.Assert(c, strings.Contains(out, "Error: No such object: foobar"))
assert.ErrorContains(c, err, "Error: No such object: foobar")
}
diff --git a/integration-cli/docker_cli_links_test.go b/integration-cli/docker_cli_links_test.go
index 8966cae..575d12c 100644
--- a/integration-cli/docker_cli_links_test.go
+++ b/integration-cli/docker_cli_links_test.go
@@ -6,35 +6,35 @@
"regexp"
"sort"
"strings"
+ "testing"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/runconfig"
- "github.com/go-check/check"
"gotest.tools/assert"
+ "gotest.tools/assert/cmp"
)
-func (s *DockerSuite) TestLinksPingUnlinkedContainers(c *check.C) {
+func (s *DockerSuite) TestLinksPingUnlinkedContainers(c *testing.T) {
testRequires(c, DaemonIsLinux)
_, exitCode, err := dockerCmdWithError("run", "--rm", "busybox", "sh", "-c", "ping -c 1 alias1 -W 1 && ping -c 1 alias2 -W 1")
// run ping failed with error
- c.Assert(exitCode, checker.Equals, 1, check.Commentf("error: %v", err))
+ assert.Equal(c, exitCode, 1, fmt.Sprintf("error: %v", err))
}
// 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)
out, _, err := dockerCmdWithError("run", "--link", "bogus:alias", "busybox", "true")
// an invalid container target should produce an error
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
+ assert.Assert(c, err != nil, "out: %s", out)
// an invalid container target should produce an error
// note: convert the output to lowercase first as the error string
// capitalization was changed after API version 1.32
- c.Assert(strings.ToLower(out), checker.Contains, "could not get container")
+ assert.Assert(c, strings.Contains(strings.ToLower(out), "could not get container"))
}
-func (s *DockerSuite) TestLinksPingLinkedContainers(c *check.C) {
+func (s *DockerSuite) TestLinksPingLinkedContainers(c *testing.T) {
testRequires(c, DaemonIsLinux)
// Test with the three different ways of specifying the default network on Linux
testLinkPingOnNetwork(c, "")
@@ -42,7 +42,7 @@
testLinkPingOnNetwork(c, "bridge")
}
-func testLinkPingOnNetwork(c *check.C, network string) {
+func testLinkPingOnNetwork(c *testing.T, network string) {
var postArgs []string
if network != "" {
postArgs = append(postArgs, []string{"--net", network}...)
@@ -78,7 +78,7 @@
dockerCmd(c, "rm", "-f", "container2")
}
-func (s *DockerSuite) TestLinksPingLinkedContainersAfterRename(c *check.C) {
+func (s *DockerSuite) TestLinksPingLinkedContainersAfterRename(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
idA := strings.TrimSpace(out)
@@ -91,7 +91,7 @@
}
-func (s *DockerSuite) TestLinksInspectLinksStarted(c *check.C) {
+func (s *DockerSuite) TestLinksInspectLinksStarted(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
dockerCmd(c, "run", "-d", "--name", "container2", "busybox", "top")
@@ -110,7 +110,7 @@
assert.DeepEqual(c, result, expected)
}
-func (s *DockerSuite) TestLinksInspectLinksStopped(c *check.C) {
+func (s *DockerSuite) TestLinksInspectLinksStopped(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
@@ -130,7 +130,7 @@
assert.DeepEqual(c, result, expected)
}
-func (s *DockerSuite) TestLinksNotStartedParentNotFail(c *check.C) {
+func (s *DockerSuite) TestLinksNotStartedParentNotFail(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "create", "--name=first", "busybox", "top")
dockerCmd(c, "create", "--name=second", "--link=first:first", "busybox", "top")
@@ -138,7 +138,7 @@
}
-func (s *DockerSuite) TestLinksHostsFilesInject(c *check.C) {
+func (s *DockerSuite) TestLinksHostsFilesInject(c *testing.T) {
testRequires(c, DaemonIsLinux)
testRequires(c, testEnv.IsLocalDaemon)
@@ -148,15 +148,15 @@
out, _ = dockerCmd(c, "run", "-itd", "--name", "two", "--link", "one:onetwo", "busybox", "top")
idTwo := strings.TrimSpace(out)
- c.Assert(waitRun(idTwo), checker.IsNil)
+ assert.Assert(c, waitRun(idTwo) == nil)
readContainerFileWithExec(c, idOne, "/etc/hosts")
contentTwo := readContainerFileWithExec(c, idTwo, "/etc/hosts")
// Host is not present in updated hosts file
- c.Assert(string(contentTwo), checker.Contains, "onetwo")
+ assert.Assert(c, strings.Contains(string(contentTwo), "onetwo"))
}
-func (s *DockerSuite) TestLinksUpdateOnRestart(c *check.C) {
+func (s *DockerSuite) TestLinksUpdateOnRestart(c *testing.T) {
testRequires(c, DaemonIsLinux)
testRequires(c, testEnv.IsLocalDaemon)
dockerCmd(c, "run", "-d", "--name", "one", "busybox", "top")
@@ -169,70 +169,70 @@
getIP := func(hosts []byte, hostname string) string {
re := regexp.MustCompile(fmt.Sprintf(`(\S*)\t%s`, regexp.QuoteMeta(hostname)))
matches := re.FindSubmatch(hosts)
- c.Assert(matches, checker.NotNil, check.Commentf("Hostname %s have no matches in hosts", hostname))
+ assert.Assert(c, matches != nil, "Hostname %s have no matches in hosts", hostname)
return string(matches[1])
}
ip := getIP(content, "one")
- c.Assert(ip, checker.Equals, realIP)
+ assert.Equal(c, ip, realIP)
ip = getIP(content, "onetwo")
- c.Assert(ip, checker.Equals, realIP)
+ assert.Equal(c, ip, realIP)
dockerCmd(c, "restart", "one")
realIP = inspectField(c, "one", "NetworkSettings.Networks.bridge.IPAddress")
content = readContainerFileWithExec(c, id, "/etc/hosts")
ip = getIP(content, "one")
- c.Assert(ip, checker.Equals, realIP)
+ assert.Equal(c, ip, realIP)
ip = getIP(content, "onetwo")
- c.Assert(ip, checker.Equals, realIP)
+ assert.Equal(c, ip, realIP)
}
-func (s *DockerSuite) TestLinksEnvs(c *check.C) {
+func (s *DockerSuite) TestLinksEnvs(c *testing.T) {
testRequires(c, DaemonIsLinux)
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")
- c.Assert(out, checker.Contains, "FIRST_ENV_e1=\n")
- c.Assert(out, checker.Contains, "FIRST_ENV_e2=v2")
- c.Assert(out, checker.Contains, "FIRST_ENV_e3=v3=v3")
+ assert.Assert(c, strings.Contains(out, "FIRST_ENV_e1=\n"))
+ assert.Assert(c, strings.Contains(out, "FIRST_ENV_e2=v2"))
+ assert.Assert(c, strings.Contains(out, "FIRST_ENV_e3=v3=v3"))
}
-func (s *DockerSuite) TestLinkShortDefinition(c *check.C) {
+func (s *DockerSuite) TestLinkShortDefinition(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "--name", "shortlinkdef", "busybox", "top")
cid := strings.TrimSpace(out)
- c.Assert(waitRun(cid), checker.IsNil)
+ assert.Assert(c, waitRun(cid) == nil)
out, _ = dockerCmd(c, "run", "-d", "--name", "link2", "--link", "shortlinkdef", "busybox", "top")
cid2 := strings.TrimSpace(out)
- c.Assert(waitRun(cid2), checker.IsNil)
+ assert.Assert(c, waitRun(cid2) == nil)
links := inspectFieldJSON(c, cid2, "HostConfig.Links")
- c.Assert(links, checker.Equals, "[\"/shortlinkdef:/link2/shortlinkdef\"]")
+ assert.Equal(c, links, "[\"/shortlinkdef:/link2/shortlinkdef\"]")
}
-func (s *DockerSuite) TestLinksNetworkHostContainer(c *check.C) {
+func (s *DockerSuite) TestLinksNetworkHostContainer(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
dockerCmd(c, "run", "-d", "--net", "host", "--name", "host_container", "busybox", "top")
out, _, err := dockerCmdWithError("run", "--name", "should_fail", "--link", "host_container:tester", "busybox", "true")
// Running container linking to a container with --net host should have failed
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
+ assert.Assert(c, err != nil, "out: %s", out)
// Running container linking to a container with --net host should have failed
- c.Assert(out, checker.Contains, runconfig.ErrConflictHostNetworkAndLinks.Error())
+ assert.Assert(c, strings.Contains(out, runconfig.ErrConflictHostNetworkAndLinks.Error()))
}
-func (s *DockerSuite) TestLinksEtcHostsRegularFile(c *check.C) {
+func (s *DockerSuite) TestLinksEtcHostsRegularFile(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmd(c, "run", "--net=host", "busybox", "ls", "-la", "/etc/hosts")
// /etc/hosts should be a regular file
- c.Assert(out, checker.Matches, "^-.+\n")
+ assert.Assert(c, cmp.Regexp("^-.+\n$", out))
}
-func (s *DockerSuite) TestLinksMultipleWithSameName(c *check.C) {
+func (s *DockerSuite) TestLinksMultipleWithSameName(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--name=upstream-a", "busybox", "top")
dockerCmd(c, "run", "-d", "--name=upstream-b", "busybox", "top")
diff --git a/integration-cli/docker_cli_login_test.go b/integration-cli/docker_cli_login_test.go
index b147f48..c189d11 100644
--- a/integration-cli/docker_cli_login_test.go
+++ b/integration-cli/docker_cli_login_test.go
@@ -4,12 +4,12 @@
"bytes"
"os/exec"
"strings"
+ "testing"
- "github.com/go-check/check"
"gotest.tools/assert"
)
-func (s *DockerSuite) TestLoginWithoutTTY(c *check.C) {
+func (s *DockerSuite) TestLoginWithoutTTY(c *testing.T) {
cmd := exec.Command(dockerBinary, "login")
// Send to stdin so the process does not get the TTY
@@ -20,7 +20,7 @@
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
out, _, err := dockerCmdWithError("login", "-u", s.reg.Username(), "-p", "WRONGPASSWORD", privateRegistryURL)
assert.ErrorContains(c, err, "", out)
diff --git a/integration-cli/docker_cli_logout_test.go b/integration-cli/docker_cli_logout_test.go
index 5fce1cb..f6b6568 100644
--- a/integration-cli/docker_cli_logout_test.go
+++ b/integration-cli/docker_cli_logout_test.go
@@ -8,12 +8,12 @@
"os/exec"
"path/filepath"
"strings"
+ "testing"
- "github.com/go-check/check"
"gotest.tools/assert"
)
-func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithExternalAuth(c *check.C) {
+func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithExternalAuth(c *testing.T) {
s.d.StartWithBusybox(c)
osPath := os.Getenv("PATH")
@@ -65,7 +65,7 @@
}
// #23100
-func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithWrongHostnamesStored(c *check.C) {
+func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithWrongHostnamesStored(c *testing.T) {
osPath := os.Getenv("PATH")
defer os.Setenv("PATH", osPath)
diff --git a/integration-cli/docker_cli_logs_bench_test.go b/integration-cli/docker_cli_logs_bench_test.go
index eeb008d..4702b2a 100644
--- a/integration-cli/docker_cli_logs_bench_test.go
+++ b/integration-cli/docker_cli_logs_bench_test.go
@@ -3,12 +3,11 @@
import (
"fmt"
"strings"
+ "testing"
"time"
-
- "github.com/go-check/check"
)
-func (s *DockerSuite) BenchmarkLogsCLIRotateFollow(c *check.C) {
+func (s *DockerSuite) BenchmarkLogsCLIRotateFollow(c *testing.B) {
out, _ := dockerCmd(c, "run", "-d", "--log-opt", "max-size=1b", "--log-opt", "max-file=10", "busybox", "sh", "-c", "while true; do usleep 50000; echo hello; done")
id := strings.TrimSpace(out)
ch := make(chan error, 1)
diff --git a/integration-cli/docker_cli_logs_test.go b/integration-cli/docker_cli_logs_test.go
index dadb827..fcb7ac9 100644
--- a/integration-cli/docker_cli_logs_test.go
+++ b/integration-cli/docker_cli_logs_test.go
@@ -6,31 +6,31 @@
"os/exec"
"regexp"
"strings"
+ "testing"
"time"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/pkg/jsonmessage"
- "github.com/go-check/check"
"gotest.tools/assert"
"gotest.tools/icmd"
)
// 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)
}
// 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)
}
// 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)
}
-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))
id := strings.TrimSpace(out)
dockerCmd(c, "wait", id)
@@ -38,7 +38,7 @@
assert.Equal(c, len(out), testLen+1)
}
-func (s *DockerSuite) TestLogsTimestamps(c *check.C) {
+func (s *DockerSuite) TestLogsTimestamps(c *testing.T) {
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))
@@ -63,7 +63,7 @@
}
}
-func (s *DockerSuite) TestLogsSeparateStderr(c *check.C) {
+func (s *DockerSuite) TestLogsSeparateStderr(c *testing.T) {
msg := "stderr_log"
out := cli.DockerCmd(c, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("echo %s 1>&2", msg)).Combined()
id := strings.TrimSpace(out)
@@ -74,7 +74,7 @@
})
}
-func (s *DockerSuite) TestLogsStderrInStdout(c *check.C) {
+func (s *DockerSuite) TestLogsStderrInStdout(c *testing.T) {
// TODO Windows: Needs investigation why this fails. Obtained string includes
// a bunch of ANSI escape sequences before the "stderr_log" message.
testRequires(c, DaemonIsLinux)
@@ -89,7 +89,7 @@
})
}
-func (s *DockerSuite) TestLogsTail(c *check.C) {
+func (s *DockerSuite) TestLogsTail(c *testing.T) {
testLen := 100
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 @@
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")
id := getIDByName(c, "test")
@@ -142,7 +142,7 @@
}
}
-func (s *DockerSuite) TestLogsSince(c *check.C) {
+func (s *DockerSuite) TestLogsSince(c *testing.T) {
name := "testlogssince"
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)
@@ -177,7 +177,7 @@
}
}
-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.
testRequires(c, DaemonIsLinux)
name := "testlogssincefuturefollow"
@@ -211,7 +211,7 @@
}
// 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.
testRequires(c, DaemonIsLinux)
expected := 150000
@@ -269,7 +269,7 @@
}
}
-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")
id := strings.TrimSpace(out)
assert.NilError(c, waitRun(id))
@@ -297,7 +297,7 @@
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")
id := strings.TrimSpace(out)
assert.NilError(c, waitRun(id))
@@ -315,14 +315,14 @@
assert.NilError(c, waitForGoroutines(nroutines))
}
-func (s *DockerSuite) TestLogsCLIContainerNotFound(c *check.C) {
+func (s *DockerSuite) TestLogsCLIContainerNotFound(c *testing.T) {
name := "testlogsnocontainer"
out, _, _ := dockerCmdWithError("logs", name)
message := fmt.Sprintf("No such container: %s\n", name)
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")
out, _ := dockerCmd(c, "logs", "--details", "--timestamps", "test")
diff --git a/integration-cli/docker_cli_netmode_test.go b/integration-cli/docker_cli_netmode_test.go
index 76f9898..48f8f93 100644
--- a/integration-cli/docker_cli_netmode_test.go
+++ b/integration-cli/docker_cli_netmode_test.go
@@ -2,10 +2,10 @@
import (
"strings"
+ "testing"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/runconfig"
- "github.com/go-check/check"
+ "gotest.tools/assert"
)
// GH14530. Validates combinations of --net= with other options
@@ -17,80 +17,70 @@
// 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
// 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...)
- c.Assert(err, check.NotNil, check.Commentf("%v", out))
+ assert.Assert(c, err != nil, "%v", out)
return out, status
}
-func (s *DockerSuite) TestNetHostnameWithNetHost(c *check.C) {
+func (s *DockerSuite) TestNetHostnameWithNetHost(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmd(c, "run", "--net=host", "busybox", "ps")
- c.Assert(out, checker.Contains, stringCheckPS)
+ assert.Assert(c, strings.Contains(out, stringCheckPS))
}
-func (s *DockerSuite) TestNetHostname(c *check.C) {
+func (s *DockerSuite) TestNetHostname(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-h=name", "busybox", "ps")
- c.Assert(out, checker.Contains, stringCheckPS)
-
+ assert.Assert(c, strings.Contains(out, stringCheckPS))
out, _ = dockerCmd(c, "run", "-h=name", "--net=bridge", "busybox", "ps")
- c.Assert(out, checker.Contains, stringCheckPS)
-
+ assert.Assert(c, strings.Contains(out, stringCheckPS))
out, _ = dockerCmd(c, "run", "-h=name", "--net=none", "busybox", "ps")
- c.Assert(out, checker.Contains, stringCheckPS)
-
+ assert.Assert(c, strings.Contains(out, stringCheckPS))
out, _ = dockerCmdWithFail(c, "run", "-h=name", "--net=container:other", "busybox", "ps")
- c.Assert(out, checker.Contains, runconfig.ErrConflictNetworkHostname.Error())
-
+ assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkHostname.Error()))
out, _ = dockerCmdWithFail(c, "run", "--net=container", "busybox", "ps")
- c.Assert(out, checker.Contains, "invalid container format container:<name|id>")
-
+ assert.Assert(c, strings.Contains(out, "invalid container format container:<name|id>"))
out, _ = dockerCmdWithFail(c, "run", "--net=weird", "busybox", "ps")
- c.Assert(strings.ToLower(out), checker.Contains, "not found")
+ assert.Assert(c, strings.Contains(strings.ToLower(out), "not found"))
}
-func (s *DockerSuite) TestConflictContainerNetworkAndLinks(c *check.C) {
+func (s *DockerSuite) TestConflictContainerNetworkAndLinks(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmdWithFail(c, "run", "--net=container:other", "--link=zip:zap", "busybox", "ps")
- c.Assert(out, checker.Contains, runconfig.ErrConflictContainerNetworkAndLinks.Error())
+ assert.Assert(c, strings.Contains(out, runconfig.ErrConflictContainerNetworkAndLinks.Error()))
}
-func (s *DockerSuite) TestConflictContainerNetworkHostAndLinks(c *check.C) {
+func (s *DockerSuite) TestConflictContainerNetworkHostAndLinks(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmdWithFail(c, "run", "--net=host", "--link=zip:zap", "busybox", "ps")
- c.Assert(out, checker.Contains, runconfig.ErrConflictHostNetworkAndLinks.Error())
+ assert.Assert(c, strings.Contains(out, runconfig.ErrConflictHostNetworkAndLinks.Error()))
}
-func (s *DockerSuite) TestConflictNetworkModeNetHostAndOptions(c *check.C) {
+func (s *DockerSuite) TestConflictNetworkModeNetHostAndOptions(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmdWithFail(c, "run", "--net=host", "--mac-address=92:d0:c6:0a:29:33", "busybox", "ps")
- c.Assert(out, checker.Contains, runconfig.ErrConflictContainerNetworkAndMac.Error())
+ assert.Assert(c, strings.Contains(out, runconfig.ErrConflictContainerNetworkAndMac.Error()))
}
-func (s *DockerSuite) TestConflictNetworkModeAndOptions(c *check.C) {
+func (s *DockerSuite) TestConflictNetworkModeAndOptions(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmdWithFail(c, "run", "--net=container:other", "--dns=8.8.8.8", "busybox", "ps")
- c.Assert(out, checker.Contains, runconfig.ErrConflictNetworkAndDNS.Error())
-
+ assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkAndDNS.Error()))
out, _ = dockerCmdWithFail(c, "run", "--net=container:other", "--add-host=name:8.8.8.8", "busybox", "ps")
- c.Assert(out, checker.Contains, runconfig.ErrConflictNetworkHosts.Error())
-
+ assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkHosts.Error()))
out, _ = dockerCmdWithFail(c, "run", "--net=container:other", "--mac-address=92:d0:c6:0a:29:33", "busybox", "ps")
- c.Assert(out, checker.Contains, runconfig.ErrConflictContainerNetworkAndMac.Error())
-
+ assert.Assert(c, strings.Contains(out, runconfig.ErrConflictContainerNetworkAndMac.Error()))
out, _ = dockerCmdWithFail(c, "run", "--net=container:other", "-P", "busybox", "ps")
- c.Assert(out, checker.Contains, runconfig.ErrConflictNetworkPublishPorts.Error())
-
+ assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkPublishPorts.Error()))
out, _ = dockerCmdWithFail(c, "run", "--net=container:other", "-p", "8080", "busybox", "ps")
- c.Assert(out, checker.Contains, runconfig.ErrConflictNetworkPublishPorts.Error())
-
+ assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkPublishPorts.Error()))
out, _ = dockerCmdWithFail(c, "run", "--net=container:other", "--expose", "8000-9000", "busybox", "ps")
- c.Assert(out, checker.Contains, runconfig.ErrConflictNetworkExposePorts.Error())
+ assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkExposePorts.Error()))
}
diff --git a/integration-cli/docker_cli_network_test.go b/integration-cli/docker_cli_network_test.go
new file mode 100644
index 0000000..ad1c958
--- /dev/null
+++ b/integration-cli/docker_cli_network_test.go
@@ -0,0 +1,13 @@
+package main
+
+import (
+ "net/http/httptest"
+
+ "github.com/docker/docker/integration-cli/daemon"
+)
+
+type DockerNetworkSuite struct {
+ server *httptest.Server
+ ds *DockerSuite
+ d *daemon.Daemon
+}
diff --git a/integration-cli/docker_cli_network_unix_test.go b/integration-cli/docker_cli_network_unix_test.go
index cbc953e..09c0343 100644
--- a/integration-cli/docker_cli_network_unix_test.go
+++ b/integration-cli/docker_cli_network_unix_test.go
@@ -11,11 +11,11 @@
"net/http/httptest"
"os"
"strings"
+ "testing"
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/versions/v1p20"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/daemon"
testdaemon "github.com/docker/docker/internal/test/daemon"
@@ -26,7 +26,6 @@
"github.com/docker/libnetwork/ipamapi"
remoteipam "github.com/docker/libnetwork/ipams/remote/api"
"github.com/docker/libnetwork/netlabel"
- "github.com/go-check/check"
"github.com/vishvananda/netlink"
"golang.org/x/sys/unix"
"gotest.tools/assert"
@@ -38,37 +37,25 @@
var remoteDriverNetworkRequest remoteapi.CreateNetworkRequest
-func init() {
- check.Suite(&DockerNetworkSuite{
- ds: &DockerSuite{},
- })
-}
-
-type DockerNetworkSuite struct {
- server *httptest.Server
- ds *DockerSuite
- 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))
}
-func (s *DockerNetworkSuite) TearDownTest(c *check.C) {
+func (s *DockerNetworkSuite) TearDownTest(c *testing.T) {
if s.d != nil {
s.d.Stop(c)
s.ds.TearDownTest(c)
}
}
-func (s *DockerNetworkSuite) SetUpSuite(c *check.C) {
+func (s *DockerNetworkSuite) SetUpSuite(c *testing.T) {
mux := http.NewServeMux()
s.server = httptest.NewServer(mux)
- c.Assert(s.server, check.NotNil, check.Commentf("Failed to start an HTTP Server"))
+ assert.Assert(c, s.server != nil, "Failed to start an HTTP Server")
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) {
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
@@ -221,7 +208,7 @@
assert.NilError(c, err)
}
-func (s *DockerNetworkSuite) TearDownSuite(c *check.C) {
+func (s *DockerNetworkSuite) TearDownSuite(c *testing.T) {
if s.server == nil {
return
}
@@ -232,19 +219,19 @@
assert.NilError(c, err)
}
-func assertNwIsAvailable(c *check.C, name string) {
+func assertNwIsAvailable(c *testing.T, name string) {
if !isNwPresent(c, 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) {
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")
lines := strings.Split(out, "\n")
for i := 1; i < len(lines)-1; i++ {
@@ -259,7 +246,7 @@
// assertNwList checks network list retrieved with ls command
// equals to expected network list
// 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")
var nwList []string
for _, line := range lines[1 : len(lines)-1] {
@@ -272,7 +259,7 @@
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)
var nr []types.NetworkResource
err := json.Unmarshal([]byte(out), &nr)
@@ -280,14 +267,14 @@
return &nr[0]
}
-func (s *DockerNetworkSuite) TestDockerNetworkLsDefault(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkLsDefault(c *testing.T) {
defaults := []string{"bridge", "host", "none"}
for _, nn := range defaults {
assertNwIsAvailable(c, nn)
}
}
-func (s *DockerNetworkSuite) TestDockerNetworkCreatePredefined(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkCreatePredefined(c *testing.T) {
predefined := []string{"bridge", "host", "none", "default"}
for _, net := range predefined {
// predefined networks can't be created again
@@ -296,7 +283,7 @@
}
}
-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")
assertNwIsAvailable(c, "testbind")
@@ -304,10 +291,10 @@
id := strings.TrimSpace(out)
assert.NilError(c, waitRun(id))
out, _ = dockerCmd(c, "ps")
- c.Assert(out, checker.Contains, "192.168.10.1:5000->5000/tcp")
+ assert.Assert(c, strings.Contains(out, "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"}
for _, net := range predefined {
// predefined networks can't be removed
@@ -316,7 +303,7 @@
}
}
-func (s *DockerNetworkSuite) TestDockerNetworkLsFilter(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkLsFilter(c *testing.T) {
testRequires(c, OnlyDefaultNetworks)
testNet := "testnet1"
testLabel := "foo"
@@ -360,7 +347,7 @@
out, _ = dockerCmd(c, "network", "ls", "-f", "label=nonexistent")
outArr := strings.Split(strings.TrimSpace(out), "\n")
- c.Assert(len(outArr), check.Equals, 1, check.Commentf("%s\n", out))
+ assert.Equal(c, len(outArr), 1, fmt.Sprintf("%s\n", out))
out, _ = dockerCmd(c, "network", "ls", "-f", "driver=null")
assertNwList(c, out, []string{"none"})
@@ -372,7 +359,7 @@
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")
assertNwIsAvailable(c, "test")
@@ -380,7 +367,7 @@
assertNwNotAvailable(c, "test")
}
-func (s *DockerNetworkSuite) TestDockerNetworkCreateLabel(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkCreateLabel(c *testing.T) {
testNet := "testnetcreatelabel"
testLabel := "foo"
testValue := "bar"
@@ -390,18 +377,18 @@
out, _, err := dockerCmdWithError("network", "inspect", "--format={{ .Labels."+testLabel+" }}", testNet)
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), check.Equals, testValue)
+ assert.Equal(c, strings.TrimSpace(out), testValue)
dockerCmd(c, "network", "rm", testNet)
assertNwNotAvailable(c, testNet)
}
-func (s *DockerSuite) TestDockerNetworkDeleteNotExists(c *check.C) {
+func (s *DockerSuite) TestDockerNetworkDeleteNotExists(c *testing.T) {
out, _, err := dockerCmdWithError("network", "rm", "test")
assert.ErrorContains(c, err, "", out)
}
-func (s *DockerSuite) TestDockerNetworkDeleteMultiple(c *check.C) {
+func (s *DockerSuite) TestDockerNetworkDeleteMultiple(c *testing.T) {
dockerCmd(c, "network", "create", "testDelMulti0")
assertNwIsAvailable(c, "testDelMulti0")
dockerCmd(c, "network", "create", "testDelMulti1")
@@ -416,16 +403,16 @@
// contains active container, its deletion should fail.
out, _, err := dockerCmdWithError("network", "rm", "testDelMulti0", "testDelMulti1", "testDelMulti2")
// err should not be nil due to deleting testDelMulti2 failed.
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
+ assert.Assert(c, err != nil, "out: %s", out)
// testDelMulti2 should fail due to network has active endpoints
- c.Assert(out, checker.Contains, "has active endpoints")
+ assert.Assert(c, strings.Contains(out, "has active endpoints"))
assertNwNotAvailable(c, "testDelMulti0")
assertNwNotAvailable(c, "testDelMulti1")
// testDelMulti2 can't be deleted, so it should exist
assertNwIsAvailable(c, "testDelMulti2")
}
-func (s *DockerSuite) TestDockerNetworkInspect(c *check.C) {
+func (s *DockerSuite) TestDockerNetworkInspect(c *testing.T) {
out, _ := dockerCmd(c, "network", "inspect", "host")
var networkResources []types.NetworkResource
err := json.Unmarshal([]byte(out), &networkResources)
@@ -433,21 +420,21 @@
assert.Equal(c, len(networkResources), 1)
out, _ = dockerCmd(c, "network", "inspect", "--format={{ .Name }}", "host")
- c.Assert(strings.TrimSpace(out), check.Equals, "host")
+ assert.Equal(c, strings.TrimSpace(out), "host")
}
-func (s *DockerSuite) TestDockerNetworkInspectWithID(c *check.C) {
+func (s *DockerSuite) TestDockerNetworkInspectWithID(c *testing.T) {
out, _ := dockerCmd(c, "network", "create", "test2")
networkID := strings.TrimSpace(out)
assertNwIsAvailable(c, "test2")
out, _ = dockerCmd(c, "network", "inspect", "--format={{ .Id }}", "test2")
- c.Assert(strings.TrimSpace(out), check.Equals, networkID)
+ assert.Equal(c, strings.TrimSpace(out), networkID)
out, _ = dockerCmd(c, "network", "inspect", "--format={{ .ID }}", "test2")
- c.Assert(strings.TrimSpace(out), check.Equals, networkID)
+ assert.Equal(c, strings.TrimSpace(out), networkID)
}
-func (s *DockerSuite) TestDockerInspectMultipleNetwork(c *check.C) {
+func (s *DockerSuite) TestDockerInspectMultipleNetwork(c *testing.T) {
result := dockerCmdWithResult("network", "inspect", "host", "none")
result.Assert(c, icmd.Success)
@@ -457,7 +444,7 @@
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
// This should print an error, return an exitCode 1 and print the host network
result := dockerCmdWithResult("network", "inspect", "host", "nonexistent")
@@ -496,7 +483,7 @@
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")
assertNwIsAvailable(c, "brNetForInspect")
defer func() {
@@ -505,7 +492,7 @@
}()
out, _ := dockerCmd(c, "run", "-d", "--name", "testNetInspect1", "--net", "brNetForInspect", "busybox", "top")
- c.Assert(waitRun("testNetInspect1"), check.IsNil)
+ assert.Assert(c, waitRun("testNetInspect1") == nil)
containerID := strings.TrimSpace(out)
defer func() {
// we don't stop container by name, because we'll rename it later
@@ -530,23 +517,23 @@
var newNetRes []types.NetworkResource
err = json.Unmarshal([]byte(out), &newNetRes)
assert.NilError(c, err)
- c.Assert(newNetRes, checker.HasLen, 1)
+ assert.Equal(c, len(newNetRes), 1)
container1, ok := newNetRes[0].Containers[containerID]
assert.Assert(c, ok)
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")
assertNwIsAvailable(c, "test")
nr := getNwResource(c, "test")
- c.Assert(nr.Name, checker.Equals, "test")
- c.Assert(len(nr.Containers), checker.Equals, 0)
+ assert.Equal(c, nr.Name, "test")
+ assert.Equal(c, len(nr.Containers), 0)
// run a container
out, _ := dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top")
- c.Assert(waitRun("test"), check.IsNil)
+ assert.Assert(c, waitRun("test") == nil)
containerID := strings.TrimSpace(out)
// connect the container to the test network
@@ -554,42 +541,41 @@
// inspect the network to make sure container is connected
nr = getNetworkResource(c, nr.ID)
- c.Assert(len(nr.Containers), checker.Equals, 1)
- c.Assert(nr.Containers[containerID], check.NotNil)
+ assert.Equal(c, len(nr.Containers), 1)
// check if container IP matches network inspect
ip, _, err := net.ParseCIDR(nr.Containers[containerID].IPv4Address)
assert.NilError(c, err)
containerIP := findContainerIP(c, "test", "test")
- c.Assert(ip.String(), checker.Equals, containerIP)
+ assert.Equal(c, ip.String(), containerIP)
// disconnect container from the network
dockerCmd(c, "network", "disconnect", "test", containerID)
nr = getNwResource(c, "test")
- c.Assert(nr.Name, checker.Equals, "test")
- c.Assert(len(nr.Containers), checker.Equals, 0)
+ assert.Equal(c, nr.Name, "test")
+ assert.Equal(c, len(nr.Containers), 0)
// run another container
out, _ = dockerCmd(c, "run", "-d", "--net", "test", "--name", "test2", "busybox", "top")
- c.Assert(waitRun("test2"), check.IsNil)
+ assert.Assert(c, waitRun("test2") == nil)
containerID = strings.TrimSpace(out)
nr = getNwResource(c, "test")
- c.Assert(nr.Name, checker.Equals, "test")
- c.Assert(len(nr.Containers), checker.Equals, 1)
+ assert.Equal(c, nr.Name, "test")
+ assert.Equal(c, len(nr.Containers), 1)
// force disconnect the container to the test network
dockerCmd(c, "network", "disconnect", "-f", "test", containerID)
nr = getNwResource(c, "test")
- c.Assert(nr.Name, checker.Equals, "test")
- c.Assert(len(nr.Containers), checker.Equals, 0)
+ assert.Equal(c, nr.Name, "test")
+ assert.Equal(c, len(nr.Containers), 0)
dockerCmd(c, "network", "rm", "test")
assertNwNotAvailable(c, "test")
}
-func (s *DockerNetworkSuite) TestDockerNetworkIPAMMultipleNetworks(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkIPAMMultipleNetworks(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
// test0 bridge network
dockerCmd(c, "network", "create", "--subnet=192.168.0.0/16", "test1")
@@ -630,7 +616,7 @@
}
}
-func (s *DockerNetworkSuite) TestDockerNetworkCustomIPAM(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkCustomIPAM(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
// Create a bridge network using custom ipam driver
dockerCmd(c, "network", "create", "--ipam-driver", dummyIPAMDriver, "br0")
@@ -638,15 +624,15 @@
// Verify expected network ipam fields are there
nr := getNetworkResource(c, "br0")
- c.Assert(nr.Driver, checker.Equals, "bridge")
- c.Assert(nr.IPAM.Driver, checker.Equals, dummyIPAMDriver)
+ assert.Equal(c, nr.Driver, "bridge")
+ assert.Equal(c, nr.IPAM.Driver, dummyIPAMDriver)
// remove network and exercise remote ipam driver
dockerCmd(c, "network", "rm", "br0")
assertNwNotAvailable(c, "br0")
}
-func (s *DockerNetworkSuite) TestDockerNetworkIPAMOptions(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkIPAMOptions(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
// 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")
@@ -655,11 +641,11 @@
// Verify expected network ipam options
nr := getNetworkResource(c, "br0")
opts := nr.IPAM.Options
- c.Assert(opts["opt1"], checker.Equals, "drv1")
- c.Assert(opts["opt2"], checker.Equals, "drv2")
+ assert.Equal(c, opts["opt1"], "drv1")
+ assert.Equal(c, opts["opt2"], "drv2")
}
-func (s *DockerNetworkSuite) TestDockerNetworkNullIPAMDriver(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkNullIPAMDriver(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
// Create a network with null ipam driver
_, _, err := dockerCmdWithError("network", "create", "-d", dummyNetworkDriver, "--ipam-driver", "null", "test000")
@@ -669,79 +655,75 @@
// Verify the inspect data contains the default subnet provided by the null
// ipam driver and no gateway, as the null ipam driver does not provide one
nr := getNetworkResource(c, "test000")
- c.Assert(nr.IPAM.Driver, checker.Equals, "null")
- c.Assert(len(nr.IPAM.Config), checker.Equals, 1)
- c.Assert(nr.IPAM.Config[0].Subnet, checker.Equals, "0.0.0.0/0")
- c.Assert(nr.IPAM.Config[0].Gateway, checker.Equals, "")
+ assert.Equal(c, nr.IPAM.Driver, "null")
+ assert.Equal(c, len(nr.IPAM.Config), 1)
+ assert.Equal(c, nr.IPAM.Config[0].Subnet, "0.0.0.0/0")
+ assert.Equal(c, nr.IPAM.Config[0].Gateway, "")
}
-func (s *DockerNetworkSuite) TestDockerNetworkInspectDefault(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkInspectDefault(c *testing.T) {
nr := getNetworkResource(c, "none")
- c.Assert(nr.Driver, checker.Equals, "null")
- c.Assert(nr.Scope, checker.Equals, "local")
- c.Assert(nr.Internal, checker.Equals, false)
- c.Assert(nr.EnableIPv6, checker.Equals, false)
- c.Assert(nr.IPAM.Driver, checker.Equals, "default")
- c.Assert(len(nr.IPAM.Config), checker.Equals, 0)
+ assert.Equal(c, nr.Driver, "null")
+ assert.Equal(c, nr.Scope, "local")
+ assert.Equal(c, nr.Internal, false)
+ assert.Equal(c, nr.EnableIPv6, false)
+ assert.Equal(c, nr.IPAM.Driver, "default")
+ assert.Equal(c, len(nr.IPAM.Config), 0)
nr = getNetworkResource(c, "host")
- c.Assert(nr.Driver, checker.Equals, "host")
- c.Assert(nr.Scope, checker.Equals, "local")
- c.Assert(nr.Internal, checker.Equals, false)
- c.Assert(nr.EnableIPv6, checker.Equals, false)
- c.Assert(nr.IPAM.Driver, checker.Equals, "default")
- c.Assert(len(nr.IPAM.Config), checker.Equals, 0)
+ assert.Equal(c, nr.Driver, "host")
+ assert.Equal(c, nr.Scope, "local")
+ assert.Equal(c, nr.Internal, false)
+ assert.Equal(c, nr.EnableIPv6, false)
+ assert.Equal(c, nr.IPAM.Driver, "default")
+ assert.Equal(c, len(nr.IPAM.Config), 0)
nr = getNetworkResource(c, "bridge")
- c.Assert(nr.Driver, checker.Equals, "bridge")
- c.Assert(nr.Scope, checker.Equals, "local")
- c.Assert(nr.Internal, checker.Equals, false)
- c.Assert(nr.EnableIPv6, checker.Equals, false)
- c.Assert(nr.IPAM.Driver, checker.Equals, "default")
- c.Assert(len(nr.IPAM.Config), checker.Equals, 1)
- c.Assert(nr.IPAM.Config[0].Subnet, checker.NotNil)
- c.Assert(nr.IPAM.Config[0].Gateway, checker.NotNil)
+ assert.Equal(c, nr.Driver, "bridge")
+ assert.Equal(c, nr.Scope, "local")
+ assert.Equal(c, nr.Internal, false)
+ assert.Equal(c, nr.EnableIPv6, false)
+ assert.Equal(c, nr.IPAM.Driver, "default")
+ assert.Equal(c, len(nr.IPAM.Config), 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
dockerCmd(c, "network", "create", "test01")
assertNwIsAvailable(c, "test01")
nr := getNetworkResource(c, "test01")
- c.Assert(nr.Driver, checker.Equals, "bridge")
- c.Assert(nr.Scope, checker.Equals, "local")
- c.Assert(nr.Internal, checker.Equals, false)
- c.Assert(nr.EnableIPv6, checker.Equals, false)
- c.Assert(nr.IPAM.Driver, checker.Equals, "default")
- c.Assert(len(nr.IPAM.Config), checker.Equals, 1)
- c.Assert(nr.IPAM.Config[0].Subnet, checker.NotNil)
- c.Assert(nr.IPAM.Config[0].Gateway, checker.NotNil)
+ assert.Equal(c, nr.Driver, "bridge")
+ assert.Equal(c, nr.Scope, "local")
+ assert.Equal(c, nr.Internal, false)
+ assert.Equal(c, nr.EnableIPv6, false)
+ assert.Equal(c, nr.IPAM.Driver, "default")
+ assert.Equal(c, len(nr.IPAM.Config), 1)
dockerCmd(c, "network", "rm", "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")
assertNwIsAvailable(c, "br0")
nr := getNetworkResource(c, "br0")
- c.Assert(nr.Driver, checker.Equals, "bridge")
- c.Assert(nr.Scope, checker.Equals, "local")
- c.Assert(nr.Internal, checker.Equals, false)
- c.Assert(nr.EnableIPv6, checker.Equals, true)
- c.Assert(nr.IPAM.Driver, checker.Equals, "default")
- c.Assert(len(nr.IPAM.Config), checker.Equals, 2)
- c.Assert(nr.IPAM.Config[0].Subnet, checker.Equals, "172.28.0.0/16")
- c.Assert(nr.IPAM.Config[0].IPRange, checker.Equals, "172.28.5.0/24")
- c.Assert(nr.IPAM.Config[0].Gateway, checker.Equals, "172.28.5.254")
+ assert.Equal(c, nr.Driver, "bridge")
+ assert.Equal(c, nr.Scope, "local")
+ assert.Equal(c, nr.Internal, false)
+ assert.Equal(c, nr.EnableIPv6, true)
+ assert.Equal(c, nr.IPAM.Driver, "default")
+ assert.Equal(c, len(nr.IPAM.Config), 2)
+ assert.Equal(c, nr.IPAM.Config[0].Subnet, "172.28.0.0/16")
+ assert.Equal(c, nr.IPAM.Config[0].IPRange, "172.28.5.0/24")
+ assert.Equal(c, nr.IPAM.Config[0].Gateway, "172.28.5.254")
assert.Equal(c, nr.Internal, false)
dockerCmd(c, "network", "rm", "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
_, _, err := dockerCmdWithError("network", "create", "--subnet=192.168.0.0/16", "--ip-range=192.170.0.0/16", "test")
assert.ErrorContains(c, err, "")
@@ -765,22 +747,22 @@
assertNwNotAvailable(c, "test0")
}
-func (s *DockerNetworkSuite) TestDockerNetworkDriverOptions(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkDriverOptions(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
dockerCmd(c, "network", "create", "-d", dummyNetworkDriver, "-o", "opt1=drv1", "-o", "opt2=drv2", "testopt")
assertNwIsAvailable(c, "testopt")
gopts := remoteDriverNetworkRequest.Options[netlabel.GenericData]
- c.Assert(gopts, checker.NotNil)
+ assert.Assert(c, gopts != nil)
opts, ok := gopts.(map[string]interface{})
- c.Assert(ok, checker.Equals, true)
- c.Assert(opts["opt1"], checker.Equals, "drv1")
- c.Assert(opts["opt2"], checker.Equals, "drv2")
+ assert.Equal(c, ok, true)
+ assert.Equal(c, opts["opt1"], "drv1")
+ assert.Equal(c, opts["opt2"], "drv2")
dockerCmd(c, "network", "rm", "testopt")
assertNwNotAvailable(c, "testopt")
}
-func (s *DockerNetworkSuite) TestDockerPluginV2NetworkDriver(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerPluginV2NetworkDriver(c *testing.T) {
testRequires(c, DaemonIsLinux, IsAmd64, Network)
var (
@@ -793,10 +775,9 @@
out, _, err := dockerCmdWithError("plugin", "ls")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, npName)
- c.Assert(out, checker.Contains, npTag)
- c.Assert(out, checker.Contains, "true")
-
+ assert.Assert(c, strings.Contains(out, npName))
+ assert.Assert(c, strings.Contains(out, npTag))
+ assert.Assert(c, strings.Contains(out, "true"))
dockerCmd(c, "network", "create", "-d", npNameWithTag, "v2net")
assertNwIsAvailable(c, "v2net")
dockerCmd(c, "network", "rm", "v2net")
@@ -804,7 +785,7 @@
}
-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
hostsFile := "/etc/hosts"
bridgeName := "external-bridge"
@@ -831,18 +812,14 @@
// verify first container's etc/hosts file has not changed after spawning the second named container
hostsPost, err := s.d.Cmd("exec", cid1, "cat", hostsFile)
assert.NilError(c, err)
- c.Assert(string(hosts), checker.Equals, string(hostsPost),
- check.Commentf("Unexpected %s change on second container creation", hostsFile))
-
+ assert.Equal(c, string(hosts), string(hostsPost), fmt.Sprintf("Unexpected %s change on second container creation", hostsFile))
// stop container 2 and verify first container's etc/hosts has not changed
_, err = s.d.Cmd("stop", cid2)
assert.NilError(c, err)
hostsPost, err = s.d.Cmd("exec", cid1, "cat", hostsFile)
assert.NilError(c, err)
- c.Assert(string(hosts), checker.Equals, string(hostsPost),
- check.Commentf("Unexpected %s change on second container creation", hostsFile))
-
+ assert.Equal(c, string(hosts), string(hostsPost), fmt.Sprintf("Unexpected %s change on second container creation", hostsFile))
// but discovery is on when connecting to non default bridge network
network := "anotherbridge"
out, err = s.d.Cmd("network", "create", network)
@@ -857,11 +834,10 @@
hostsPost, err = s.d.Cmd("exec", cid1, "cat", hostsFile)
assert.NilError(c, err)
- c.Assert(string(hosts), checker.Equals, string(hostsPost),
- check.Commentf("Unexpected %s change on second network connection", hostsFile))
+ assert.Equal(c, string(hosts), string(hostsPost), fmt.Sprintf("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)
hostsFile := "/etc/hosts"
cstmBridgeNw := "custom-bridge-nw"
@@ -881,9 +857,7 @@
// verify first container etc/hosts file has not changed
hosts1post := readContainerFileWithExec(c, cid1, hostsFile)
- c.Assert(string(hosts1), checker.Equals, string(hosts1post),
- check.Commentf("Unexpected %s change on anonymous container creation", hostsFile))
-
+ assert.Equal(c, string(hosts1), string(hosts1post), fmt.Sprintf("Unexpected %s change on anonymous container creation", hostsFile))
// Connect the 2nd container to a new network and verify the
// first container /etc/hosts file still hasn't changed.
dockerCmd(c, "network", "create", "-d", "bridge", cstmBridgeNw1)
@@ -893,9 +867,7 @@
hosts2 := readContainerFileWithExec(c, cid2, hostsFile)
hosts1post = readContainerFileWithExec(c, cid1, hostsFile)
- c.Assert(string(hosts1), checker.Equals, string(hosts1post),
- check.Commentf("Unexpected %s change on container connect", hostsFile))
-
+ assert.Equal(c, string(hosts1), string(hosts1post), fmt.Sprintf("Unexpected %s change on container connect", hostsFile))
// start a named container
cName := "AnyName"
out, _ = dockerCmd(c, "run", "-d", "--net", cstmBridgeNw, "--name", cName, "busybox", "top")
@@ -908,13 +880,9 @@
// Stop named container and verify first two containers' etc/hosts file hasn't changed
dockerCmd(c, "stop", cid3)
hosts1post = readContainerFileWithExec(c, cid1, hostsFile)
- c.Assert(string(hosts1), checker.Equals, string(hosts1post),
- check.Commentf("Unexpected %s change on name container creation", hostsFile))
-
+ assert.Equal(c, string(hosts1), string(hosts1post), fmt.Sprintf("Unexpected %s change on name container creation", hostsFile))
hosts2post := readContainerFileWithExec(c, cid2, hostsFile)
- c.Assert(string(hosts2), checker.Equals, string(hosts2post),
- check.Commentf("Unexpected %s change on name container creation", hostsFile))
-
+ assert.Equal(c, string(hosts2), string(hosts2post), fmt.Sprintf("Unexpected %s change on name container creation", hostsFile))
// verify that container 1 and 2 can't ping the named container now
_, _, err := dockerCmdWithError("exec", cid1, "ping", "-c", "1", cName)
assert.ErrorContains(c, err, "")
@@ -922,7 +890,7 @@
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
cnt1 := "container1"
cnt2 := "container2"
@@ -948,7 +916,7 @@
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)
// 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
@@ -970,12 +938,12 @@
unpPort2 := fmt.Sprintf("%d/tcp", port2)
out, _ := dockerCmd(c, "ps", "-n=1")
// Missing unpublished ports in docker ps output
- c.Assert(out, checker.Contains, unpPort1)
+ assert.Assert(c, strings.Contains(out, unpPort1))
// Missing unpublished ports in docker ps output
- c.Assert(out, checker.Contains, unpPort2)
+ assert.Assert(c, strings.Contains(out, unpPort2))
}
-func (s *DockerNetworkSuite) TestDockerNetworkDriverUngracefulRestart(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkDriverUngracefulRestart(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, testEnv.IsLocalDaemon)
dnd := "dnd"
did := "did"
@@ -992,7 +960,7 @@
assert.NilError(c, err)
// Kill daemon and restart
- c.Assert(s.d.Kill(), checker.IsNil)
+ assert.Assert(c, s.d.Kill() == nil)
server.Close()
@@ -1016,7 +984,7 @@
assert.NilError(c, err)
}
-func (s *DockerNetworkSuite) TestDockerNetworkMacInspect(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkMacInspect(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
// Verify endpoint MAC address is correctly populated in container's network settings
nwn := "ov"
@@ -1028,10 +996,10 @@
dockerCmd(c, "run", "-d", "--net", nwn, "--name", ctn, "busybox", "top")
mac := inspectField(c, ctn, "NetworkSettings.Networks."+nwn+".MacAddress")
- c.Assert(mac, checker.Equals, "a0:b1:c2:d3:e4:f5")
+ assert.Equal(c, mac, "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", "mybridge2")
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
@@ -1052,14 +1020,14 @@
var inspect121 types.ContainerJSON
err = json.Unmarshal(body, &inspect121)
assert.NilError(c, err)
- c.Assert(inspect121.NetworkSettings.Networks, checker.HasLen, 3)
+ assert.Equal(c, len(inspect121.NetworkSettings.Networks), 3)
bridge := inspect121.NetworkSettings.Networks["bridge"]
- c.Assert(bridge.IPAddress, checker.Equals, versionedIP)
- c.Assert(bridge.IPAddress, checker.Equals, inspect121.NetworkSettings.IPAddress)
+ assert.Equal(c, bridge.IPAddress, versionedIP)
+ assert.Equal(c, bridge.IPAddress, 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
out, err := d.Cmd("run", "-d", "--name", cName, "busybox", "top")
assert.NilError(c, err, out)
@@ -1073,16 +1041,16 @@
}
}
-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
for _, nw := range nws {
out, err := d.Cmd("inspect", "-f", fmt.Sprintf("{{.NetworkSettings.Networks.%s}}", nw), cName)
assert.NilError(c, err, out)
- c.Assert(out, checker.Not(checker.Equals), "<no value>\n")
+ assert.Assert(c, out != "<no value>\n")
}
}
-func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksGracefulDaemonRestart(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksGracefulDaemonRestart(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
cName := "bb"
nwList := []string{"nw1", "nw2", "nw3"}
@@ -1101,7 +1069,7 @@
verifyContainerIsConnectedToNetworks(c, s.d, cName, nwList)
}
-func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksUngracefulDaemonRestart(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksUngracefulDaemonRestart(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
cName := "cc"
nwList := []string{"nw1", "nw2", "nw3"}
@@ -1112,7 +1080,7 @@
verifyContainerIsConnectedToNetworks(c, s.d, cName, nwList)
// Kill daemon and restart
- c.Assert(s.d.Kill(), checker.IsNil)
+ assert.Assert(c, s.d.Kill() == nil)
s.d.Restart(c)
// Restart container
@@ -1122,13 +1090,13 @@
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")
containerOut, _, err := dockerCmdWithError("run", "-d", "--net", strings.TrimSpace(out), "busybox", "top")
- c.Assert(err, checker.IsNil, check.Commentf(containerOut))
+ assert.Assert(c, err == nil, containerOut)
}
-func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, testEnv.IsLocalDaemon)
s.d.StartWithBusybox(c)
@@ -1144,7 +1112,7 @@
}
// Kill daemon ungracefully and restart
- c.Assert(s.d.Kill(), checker.IsNil)
+ assert.Assert(c, s.d.Kill() == nil)
s.d.Restart(c)
// make sure all the containers are up and running
@@ -1154,41 +1122,41 @@
}
}
-func (s *DockerNetworkSuite) TestDockerNetworkConnectToHostFromOtherNetwork(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkConnectToHostFromOtherNetwork(c *testing.T) {
dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
- c.Assert(waitRun("container1"), check.IsNil)
+ assert.Assert(c, waitRun("container1") == nil)
dockerCmd(c, "network", "disconnect", "bridge", "container1")
out, _, err := dockerCmdWithError("network", "connect", "host", "container1")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, runconfig.ErrConflictHostNetwork.Error())
+ assert.Assert(c, strings.Contains(out, 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")
- c.Assert(waitRun("container1"), check.IsNil)
+ assert.Assert(c, waitRun("container1") == nil)
out, _, err := dockerCmdWithError("network", "disconnect", "host", "container1")
- c.Assert(err, checker.NotNil, check.Commentf("Should err out disconnect from host"))
- c.Assert(out, checker.Contains, runconfig.ErrConflictHostNetwork.Error())
+ assert.Assert(c, err != nil, "Should err out disconnect from host")
+ assert.Assert(c, strings.Contains(out, runconfig.ErrConflictHostNetwork.Error()))
}
-func (s *DockerNetworkSuite) TestDockerNetworkConnectWithPortMapping(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkConnectWithPortMapping(c *testing.T) {
testRequires(c, NotArm)
dockerCmd(c, "network", "create", "test1")
dockerCmd(c, "run", "-d", "--name", "c1", "-p", "5000:5000", "busybox", "top")
- c.Assert(waitRun("c1"), check.IsNil)
+ assert.Assert(c, waitRun("c1") == nil)
dockerCmd(c, "network", "connect", "test1", "c1")
}
-func verifyPortMap(c *check.C, container, port, originalMapping string, mustBeEqual bool) {
- chk := checker.Equals
- if !mustBeEqual {
- chk = checker.Not(checker.Equals)
- }
+func verifyPortMap(c *testing.T, container, port, originalMapping string, mustBeEqual bool) {
currentMapping, _ := dockerCmd(c, "port", container, port)
- c.Assert(currentMapping, chk, originalMapping)
+ if mustBeEqual {
+ assert.Equal(c, currentMapping, originalMapping)
+ } else {
+ assert.Assert(c, currentMapping != originalMapping)
+ }
}
-func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectWithPortMapping(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectWithPortMapping(c *testing.T) {
// Connect and disconnect a container with explicit and non-explicit
// host port mapping to/from networks which do cause and do not cause
// the container default gateway to change, and verify docker port cmd
@@ -1199,7 +1167,7 @@
dockerCmd(c, "network", "create", "ccc")
dockerCmd(c, "run", "-d", "--name", cnt, "-p", "9000:90", "-p", "70", "busybox", "top")
- c.Assert(waitRun(cnt), check.IsNil)
+ assert.Assert(c, waitRun(cnt) == nil)
curPortMap, _ := dockerCmd(c, "port", cnt, "70")
curExplPortMap, _ := dockerCmd(c, "port", cnt, "90")
@@ -1225,51 +1193,49 @@
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"
dockerCmd(c, "network", "create", "mynetwork")
dockerCmd(c, "run", "--name=test", "-d", "--mac-address", macAddress, "busybox", "top")
- c.Assert(waitRun("test"), check.IsNil)
+ assert.Assert(c, waitRun("test") == nil)
mac1 := inspectField(c, "test", "NetworkSettings.Networks.bridge.MacAddress")
- c.Assert(strings.TrimSpace(mac1), checker.Equals, macAddress)
+ assert.Equal(c, strings.TrimSpace(mac1), macAddress)
dockerCmd(c, "network", "connect", "mynetwork", "test")
mac2 := inspectField(c, "test", "NetworkSettings.Networks.mynetwork.MacAddress")
- c.Assert(strings.TrimSpace(mac2), checker.Not(checker.Equals), strings.TrimSpace(mac1))
+ assert.Assert(c, strings.TrimSpace(mac2) != strings.TrimSpace(mac1))
}
-func (s *DockerNetworkSuite) TestDockerNetworkInspectCreatedContainer(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkInspectCreatedContainer(c *testing.T) {
dockerCmd(c, "create", "--name", "test", "busybox")
networks := inspectField(c, "test", "NetworkSettings.Networks")
- c.Assert(networks, checker.Contains, "bridge", check.Commentf("Should return 'bridge' network"))
+ assert.Assert(c, strings.Contains(networks, "bridge"), "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, "run", "--name=foo", "-d", "busybox", "top")
- c.Assert(waitRun("foo"), checker.IsNil)
+ assert.Assert(c, waitRun("foo") == nil)
dockerCmd(c, "network", "connect", "test", "foo")
dockerCmd(c, "restart", "foo")
networks := inspectField(c, "foo", "NetworkSettings.Networks")
- c.Assert(networks, checker.Contains, "bridge", check.Commentf("Should contain 'bridge' network"))
- c.Assert(networks, checker.Contains, "test", check.Commentf("Should contain 'test' network"))
+ assert.Assert(c, strings.Contains(networks, "bridge"), "Should contain 'bridge' network")
+ assert.Assert(c, strings.Contains(networks, "test"), "Should contain 'test' network")
}
-func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectToStoppedContainer(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectToStoppedContainer(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
dockerCmd(c, "network", "create", "test")
dockerCmd(c, "create", "--name=foo", "busybox", "top")
dockerCmd(c, "network", "connect", "test", "foo")
networks := inspectField(c, "foo", "NetworkSettings.Networks")
- c.Assert(networks, checker.Contains, "test", check.Commentf("Should contain 'test' network"))
-
+ assert.Assert(c, strings.Contains(networks, "test"), "Should contain 'test' network")
// Restart docker daemon to test the config has persisted to disk
s.d.Restart(c)
networks = inspectField(c, "foo", "NetworkSettings.Networks")
- c.Assert(networks, checker.Contains, "test", check.Commentf("Should contain 'test' network"))
-
+ assert.Assert(c, strings.Contains(networks, "test"), "Should contain 'test' network")
// start the container and test if we can ping it from another container in the same network
dockerCmd(c, "start", "foo")
- c.Assert(waitRun("foo"), checker.IsNil)
+ assert.Assert(c, waitRun("foo") == nil)
ip := inspectField(c, "foo", "NetworkSettings.Networks.test.IPAddress")
ip = strings.TrimSpace(ip)
dockerCmd(c, "run", "--net=test", "busybox", "sh", "-c", fmt.Sprintf("ping -c 1 %s", ip))
@@ -1279,21 +1245,18 @@
// Test disconnect
dockerCmd(c, "network", "disconnect", "test", "foo")
networks = inspectField(c, "foo", "NetworkSettings.Networks")
- c.Assert(networks, checker.Not(checker.Contains), "test", check.Commentf("Should not contain 'test' network"))
-
+ assert.Assert(c, !strings.Contains(networks, "test"), "Should not contain 'test' network")
// Restart docker daemon to test the config has persisted to disk
s.d.Restart(c)
networks = inspectField(c, "foo", "NetworkSettings.Networks")
- c.Assert(networks, checker.Not(checker.Contains), "test", check.Commentf("Should not contain 'test' network"))
-
+ assert.Assert(c, !strings.Contains(networks, "test"), "Should not contain 'test' network")
}
-func (s *DockerNetworkSuite) TestDockerNetworkDisconnectContainerNonexistingNetwork(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkDisconnectContainerNonexistingNetwork(c *testing.T) {
dockerCmd(c, "network", "create", "test")
dockerCmd(c, "run", "--net=test", "-d", "--name=foo", "busybox", "top")
networks := inspectField(c, "foo", "NetworkSettings.Networks")
- c.Assert(networks, checker.Contains, "test", check.Commentf("Should contain 'test' network"))
-
+ assert.Assert(c, strings.Contains(networks, "test"), "Should contain 'test' network")
// Stop container and remove network
dockerCmd(c, "stop", "foo")
dockerCmd(c, "network", "rm", "test")
@@ -1301,10 +1264,10 @@
// Test disconnecting stopped container from nonexisting network
dockerCmd(c, "network", "disconnect", "-f", "test", "foo")
networks = inspectField(c, "foo", "NetworkSettings.Networks")
- c.Assert(networks, checker.Not(checker.Contains), "test", check.Commentf("Should not contain 'test' network"))
+ assert.Assert(c, !strings.Contains(networks, "test"), "Should not contain 'test' network")
}
-func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIP(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIP(c *testing.T) {
// create two networks
dockerCmd(c, "network", "create", "--ipv6", "--subnet=172.28.0.0/16", "--subnet=2001:db8:1234::/64", "n0")
assertNwIsAvailable(c, "n0")
@@ -1314,7 +1277,7 @@
// run a container on first network specifying the ip addresses
dockerCmd(c, "run", "-d", "--name", "c0", "--net=n0", "--ip", "172.28.99.88", "--ip6", "2001:db8:1234::9988", "busybox", "top")
- c.Assert(waitRun("c0"), check.IsNil)
+ assert.Assert(c, waitRun("c0") == nil)
verifyIPAddressConfig(c, "c0", "n0", "172.28.99.88", "2001:db8:1234::9988")
verifyIPAddresses(c, "c0", "n0", "172.28.99.88", "2001:db8:1234::9988")
@@ -1335,12 +1298,11 @@
// Still it should fail to connect to the default network with a specified IP (whatever ip)
out, _, err := dockerCmdWithError("network", "connect", "--ip", "172.21.55.44", "bridge", "c0")
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
- c.Assert(out, checker.Contains, runconfig.ErrUnsupportedNetworkAndIP.Error())
-
+ assert.Assert(c, err != nil, "out: %s", out)
+ assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkAndIP.Error()))
}
-func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIPStoppedContainer(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIPStoppedContainer(c *testing.T) {
// create a container
dockerCmd(c, "create", "--name", "c0", "busybox", "top")
@@ -1354,7 +1316,7 @@
// start the container, verify config has not changed and ip addresses are assigned
dockerCmd(c, "start", "c0")
- c.Assert(waitRun("c0"), check.IsNil)
+ assert.Assert(c, waitRun("c0") == nil)
verifyIPAddressConfig(c, "c0", "n0", "172.30.55.44", "2001:db8:abcd::5544")
verifyIPAddresses(c, "c0", "n0", "172.30.55.44", "2001:db8:abcd::5544")
@@ -1363,7 +1325,7 @@
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
for _, mode := range []string{"none", "host", "bridge", "default"} {
checkUnsupportedNetworkAndIP(c, mode)
@@ -1374,44 +1336,42 @@
assertNwIsAvailable(c, "n0")
out, _, err := dockerCmdWithError("run", "-d", "--ip", "172.28.99.88", "--net", "n0", "busybox", "top")
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
- c.Assert(out, checker.Contains, runconfig.ErrUnsupportedNetworkNoSubnetAndIP.Error())
-
+ assert.Assert(c, err != nil, "out: %s", out)
+ assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkNoSubnetAndIP.Error()))
out, _, err = dockerCmdWithError("run", "-d", "--ip6", "2001:db8:1234::9988", "--net", "n0", "busybox", "top")
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
- c.Assert(out, checker.Contains, runconfig.ErrUnsupportedNetworkNoSubnetAndIP.Error())
-
+ assert.Assert(c, err != nil, "out: %s", out)
+ assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkNoSubnetAndIP.Error()))
dockerCmd(c, "network", "rm", "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")
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
- c.Assert(out, checker.Contains, runconfig.ErrUnsupportedNetworkAndIP.Error())
+ assert.Assert(c, err != nil, "out: %s", out)
+ assert.Assert(c, strings.Contains(out, 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 != "" {
out := inspectField(c, cName, fmt.Sprintf("NetworkSettings.Networks.%s.IPAMConfig.IPv4Address", nwname))
- c.Assert(strings.TrimSpace(out), check.Equals, ipv4)
+ assert.Equal(c, strings.TrimSpace(out), ipv4)
}
if ipv6 != "" {
out := inspectField(c, cName, fmt.Sprintf("NetworkSettings.Networks.%s.IPAMConfig.IPv6Address", nwname))
- c.Assert(strings.TrimSpace(out), check.Equals, ipv6)
+ assert.Equal(c, strings.TrimSpace(out), ipv6)
}
}
-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))
- c.Assert(strings.TrimSpace(out), check.Equals, ipv4)
+ assert.Equal(c, strings.TrimSpace(out), ipv4)
out = inspectField(c, cName, fmt.Sprintf("NetworkSettings.Networks.%s.GlobalIPv6Address", nwname))
- c.Assert(strings.TrimSpace(out), check.Equals, ipv6)
+ assert.Equal(c, strings.TrimSpace(out), ipv6)
}
-func (s *DockerNetworkSuite) TestDockerNetworkConnectLinkLocalIP(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkConnectLinkLocalIP(c *testing.T) {
// create one test network
dockerCmd(c, "network", "create", "--ipv6", "--subnet=2001:db8:1234::/64", "n0")
assertNwIsAvailable(c, "n0")
@@ -1424,13 +1384,13 @@
// run two containers with link-local ip on the test network
dockerCmd(c, "run", "-d", "--name", "c0", "--net=n0", "--link-local-ip", "169.254.7.7", "--link-local-ip", "fe80::254:77", "busybox", "top")
- c.Assert(waitRun("c0"), check.IsNil)
+ assert.Assert(c, waitRun("c0") == nil)
dockerCmd(c, "run", "-d", "--name", "c1", "--net=n0", "--link-local-ip", "169.254.8.8", "--link-local-ip", "fe80::254:88", "busybox", "top")
- c.Assert(waitRun("c1"), check.IsNil)
+ assert.Assert(c, waitRun("c1") == nil)
// run a container on the default network and connect it to the test network specifying a link-local address
dockerCmd(c, "run", "-d", "--name", "c2", "busybox", "top")
- c.Assert(waitRun("c2"), check.IsNil)
+ assert.Assert(c, waitRun("c2") == nil)
dockerCmd(c, "network", "connect", "--link-local-ip", "169.254.9.9", "n0", "c2")
// verify the three containers can ping each other via the link-local addresses
@@ -1458,19 +1418,19 @@
assert.NilError(c, err)
}
-func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectLink(c *check.C) {
+func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectLink(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
dockerCmd(c, "network", "create", "-d", "bridge", "foo1")
dockerCmd(c, "network", "create", "-d", "bridge", "foo2")
dockerCmd(c, "run", "-d", "--net=foo1", "--name=first", "busybox", "top")
- c.Assert(waitRun("first"), check.IsNil)
+ assert.Assert(c, waitRun("first") == nil)
// run a container in a user-defined network with a link for an existing container
// and a link for a container that doesn't exist
dockerCmd(c, "run", "-d", "--net=foo1", "--name=second", "--link=first:FirstInFoo1",
"--link=third:bar", "busybox", "top")
- c.Assert(waitRun("second"), check.IsNil)
+ assert.Assert(c, waitRun("second") == nil)
// ping to first and its alias FirstInFoo1 must succeed
_, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
@@ -1499,7 +1459,7 @@
assert.NilError(c, err)
}
-func (s *DockerNetworkSuite) TestDockerNetworkDisconnectDefault(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkDisconnectDefault(c *testing.T) {
netWorkName1 := "test1"
netWorkName2 := "test2"
containerName := "foo"
@@ -1512,14 +1472,14 @@
dockerCmd(c, "network", "disconnect", "bridge", containerName)
dockerCmd(c, "start", containerName)
- c.Assert(waitRun(containerName), checker.IsNil)
+ assert.Assert(c, waitRun(containerName) == nil)
networks := inspectField(c, containerName, "NetworkSettings.Networks")
- c.Assert(networks, checker.Contains, netWorkName1, check.Commentf(fmt.Sprintf("Should contain '%s' network", netWorkName1)))
- c.Assert(networks, checker.Contains, netWorkName2, check.Commentf(fmt.Sprintf("Should contain '%s' network", netWorkName2)))
- c.Assert(networks, checker.Not(checker.Contains), "bridge", check.Commentf("Should not contain 'bridge' network"))
+ assert.Assert(c, strings.Contains(networks, netWorkName1), fmt.Sprintf("Should contain '%s' network", netWorkName1))
+ assert.Assert(c, strings.Contains(networks, netWorkName2), fmt.Sprintf("Should contain '%s' network", netWorkName2))
+ assert.Assert(c, !strings.Contains(networks, "bridge"), "Should not contain 'bridge' network")
}
-func (s *DockerNetworkSuite) TestDockerNetworkConnectWithAliasOnDefaultNetworks(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkConnectWithAliasOnDefaultNetworks(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
defaults := []string{"bridge", "host", "none"}
@@ -1528,20 +1488,20 @@
for _, net := range defaults {
res, _, err := dockerCmdWithError("network", "connect", "--alias", "alias"+net, net, containerID)
assert.ErrorContains(c, err, "")
- c.Assert(res, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error())
+ assert.Assert(c, strings.Contains(res, runconfig.ErrUnsupportedNetworkAndAlias.Error()))
}
}
-func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *check.C) {
+func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
dockerCmd(c, "network", "create", "-d", "bridge", "net1")
dockerCmd(c, "network", "create", "-d", "bridge", "net2")
cid, _ := dockerCmd(c, "run", "-d", "--net=net1", "--name=first", "--net-alias=foo", "busybox:glibc", "top")
- c.Assert(waitRun("first"), check.IsNil)
+ assert.Assert(c, waitRun("first") == nil)
dockerCmd(c, "run", "-d", "--net=net1", "--name=second", "busybox:glibc", "top")
- c.Assert(waitRun("second"), check.IsNil)
+ assert.Assert(c, waitRun("second") == nil)
// ping first container and its alias
_, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
@@ -1578,24 +1538,23 @@
// verify the alias option is rejected when running on predefined network
out, _, err := dockerCmdWithError("run", "--rm", "--name=any", "--net-alias=any", "busybox:glibc", "top")
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
- c.Assert(out, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error())
-
+ assert.Assert(c, err != nil, "out: %s", out)
+ assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkAndAlias.Error()))
// verify the alias option is rejected when connecting to predefined network
out, _, err = dockerCmdWithError("network", "connect", "--alias=any", "bridge", "first")
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
- c.Assert(out, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error())
+ assert.Assert(c, err != nil, "out: %s", out)
+ assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkAndAlias.Error()))
}
-func (s *DockerSuite) TestUserDefinedNetworkConnectivity(c *check.C) {
+func (s *DockerSuite) TestUserDefinedNetworkConnectivity(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
dockerCmd(c, "network", "create", "-d", "bridge", "br.net1")
dockerCmd(c, "run", "-d", "--net=br.net1", "--name=c1.net1", "busybox:glibc", "top")
- c.Assert(waitRun("c1.net1"), check.IsNil)
+ assert.Assert(c, waitRun("c1.net1") == nil)
dockerCmd(c, "run", "-d", "--net=br.net1", "--name=c2.net1", "busybox:glibc", "top")
- c.Assert(waitRun("c2.net1"), check.IsNil)
+ assert.Assert(c, waitRun("c2.net1") == nil)
// ping first container by its unqualified name
_, _, err := dockerCmdWithError("exec", "c2.net1", "ping", "-c", "1", "c1.net1")
@@ -1610,7 +1569,7 @@
assert.ErrorContains(c, err, "")
}
-func (s *DockerSuite) TestEmbeddedDNSInvalidInput(c *check.C) {
+func (s *DockerSuite) TestEmbeddedDNSInvalidInput(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
dockerCmd(c, "network", "create", "-d", "bridge", "nw1")
@@ -1618,9 +1577,9 @@
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")
- c.Assert(waitRun("bb"), check.IsNil)
+ assert.Assert(c, waitRun("bb") == nil)
defer dockerCmd(c, "stop", "bb")
ns0 := inspectField(c, "bb", "NetworkSettings.Networks.bridge")
@@ -1630,28 +1589,28 @@
assert.ErrorContains(c, err, "")
ns1 := inspectField(c, "bb", "NetworkSettings.Networks.bridge")
- c.Assert(ns1, check.Equals, ns0)
+ assert.Equal(c, ns1, ns0)
}
-func (s *DockerSuite) TestDockerNetworkInternalMode(c *check.C) {
+func (s *DockerSuite) TestDockerNetworkInternalMode(c *testing.T) {
dockerCmd(c, "network", "create", "--driver=bridge", "--internal", "internal")
assertNwIsAvailable(c, "internal")
nr := getNetworkResource(c, "internal")
- c.Assert(nr.Internal, checker.True)
+ assert.Assert(c, nr.Internal)
dockerCmd(c, "run", "-d", "--net=internal", "--name=first", "busybox:glibc", "top")
- c.Assert(waitRun("first"), check.IsNil)
+ assert.Assert(c, waitRun("first") == nil)
dockerCmd(c, "run", "-d", "--net=internal", "--name=second", "busybox:glibc", "top")
- c.Assert(waitRun("second"), check.IsNil)
+ assert.Assert(c, waitRun("second") == nil)
out, _, err := dockerCmdWithError("exec", "first", "ping", "-W", "4", "-c", "1", "8.8.8.8")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "100% packet loss")
+ assert.Assert(c, strings.Contains(out, "100% packet loss"))
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
assert.NilError(c, err)
}
// Test for #21401
-func (s *DockerNetworkSuite) TestDockerNetworkCreateDeleteSpecialCharacters(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkCreateDeleteSpecialCharacters(c *testing.T) {
dockerCmd(c, "network", "create", "test@#$")
assertNwIsAvailable(c, "test@#$")
dockerCmd(c, "network", "rm", "test@#$")
@@ -1663,7 +1622,7 @@
assertNwNotAvailable(c, "kiwl$%^")
}
-func (s *DockerDaemonSuite) TestDaemonRestartRestoreBridgeNetwork(t *check.C) {
+func (s *DockerDaemonSuite) TestDaemonRestartRestoreBridgeNetwork(t *testing.T) {
s.d.StartWithBusybox(t, "--live-restore")
defer s.d.Stop(t)
oldCon := "old"
@@ -1732,26 +1691,26 @@
}
}
-func (s *DockerNetworkSuite) TestDockerNetworkFlagAlias(c *check.C) {
+func (s *DockerNetworkSuite) TestDockerNetworkFlagAlias(c *testing.T) {
dockerCmd(c, "network", "create", "user")
output, status := dockerCmd(c, "run", "--rm", "--network=user", "--network-alias=foo", "busybox", "true")
- c.Assert(status, checker.Equals, 0, check.Commentf("unexpected status code %d (%s)", status, output))
+ assert.Equal(c, status, 0, fmt.Sprintf("unexpected status code %d (%s)", status, output))
output, status, _ = dockerCmdWithError("run", "--rm", "--net=user", "--network=user", "busybox", "true")
- c.Assert(status, checker.Equals, 0, check.Commentf("unexpected status code %d (%s)", status, output))
+ assert.Equal(c, status, 0, fmt.Sprintf("unexpected status code %d (%s)", status, output))
output, status, _ = dockerCmdWithError("run", "--rm", "--network=user", "--net-alias=foo", "--network-alias=bar", "busybox", "true")
- c.Assert(status, checker.Equals, 0, check.Commentf("unexpected status code %d (%s)", status, output))
+ assert.Equal(c, status, 0, fmt.Sprintf("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")
assert.NilError(c, err)
assertNwIsAvailable(c, "mynet")
_, _, err = dockerCmdWithError("run", "-d", "--name", "mynet0", "--net=mynet", "--ip", "172.28.99.88", "--ip6", "2001:db8:1234::9988", "busybox", "top")
assert.NilError(c, err)
- c.Assert(waitRun("mynet0"), check.IsNil)
+ assert.Assert(c, waitRun("mynet0") == nil)
verifyIPAddressConfig(c, "mynet0", "mynet", "172.28.99.88", "2001:db8:1234::9988")
verifyIPAddresses(c, "mynet0", "mynet", "172.28.99.88", "2001:db8:1234::9988")
@@ -1769,7 +1728,7 @@
}
// 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")
network := strings.TrimSpace(out)
@@ -1783,7 +1742,7 @@
// 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
-func (s *DockerNetworkSuite) TestConntrackFlowsLeak(c *check.C) {
+func (s *DockerNetworkSuite) TestConntrackFlowsLeak(c *testing.T) {
testRequires(c, IsAmd64, DaemonIsLinux, Network, testEnv.IsLocalDaemon)
// Create a new network
diff --git a/integration-cli/docker_cli_plugins_logdriver_test.go b/integration-cli/docker_cli_plugins_logdriver_test.go
index df013e4..5c45202 100644
--- a/integration-cli/docker_cli_plugins_logdriver_test.go
+++ b/integration-cli/docker_cli_plugins_logdriver_test.go
@@ -3,13 +3,13 @@
import (
"context"
"strings"
+ "testing"
"github.com/docker/docker/client"
- "github.com/go-check/check"
"gotest.tools/assert"
)
-func (s *DockerSuite) TestPluginLogDriver(c *check.C) {
+func (s *DockerSuite) TestPluginLogDriver(c *testing.T) {
testRequires(c, IsAmd64, DaemonIsLinux)
pluginName := "cpuguy83/docker-logdriver-test:latest"
@@ -29,7 +29,7 @@
}
// 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)
pluginName := "cpuguy83/docker-logdriver-test"
diff --git a/integration-cli/docker_cli_plugins_test.go b/integration-cli/docker_cli_plugins_test.go
index bd9cfab..2be4b32 100644
--- a/integration-cli/docker_cli_plugins_test.go
+++ b/integration-cli/docker_cli_plugins_test.go
@@ -9,14 +9,13 @@
"path"
"path/filepath"
"strings"
+ "testing"
"time"
"github.com/docker/docker/api/types"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/daemon"
"github.com/docker/docker/internal/test/fixtures/plugin"
- "github.com/go-check/check"
"gotest.tools/assert"
)
@@ -29,52 +28,48 @@
npNameWithTag = npName + ":" + pTag
)
-func (ps *DockerPluginSuite) TestPluginBasicOps(c *check.C) {
+func (ps *DockerPluginSuite) TestPluginBasicOps(c *testing.T) {
plugin := ps.getPluginRepoWithTag()
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", plugin)
assert.NilError(c, err)
out, _, err := dockerCmdWithError("plugin", "ls")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, plugin)
- c.Assert(out, checker.Contains, "true")
-
+ assert.Assert(c, strings.Contains(out, plugin))
+ assert.Assert(c, strings.Contains(out, "true"))
id, _, err := dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", plugin)
id = strings.TrimSpace(id)
assert.NilError(c, err)
out, _, err = dockerCmdWithError("plugin", "remove", plugin)
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "is enabled")
-
+ assert.Assert(c, strings.Contains(out, "is enabled"))
_, _, err = dockerCmdWithError("plugin", "disable", plugin)
assert.NilError(c, err)
out, _, err = dockerCmdWithError("plugin", "remove", plugin)
assert.NilError(c, err)
- c.Assert(out, checker.Contains, plugin)
-
+ assert.Assert(c, strings.Contains(out, plugin))
_, err = os.Stat(filepath.Join(testEnv.DaemonInfo.DockerRootDir, "plugins", id))
if !os.IsNotExist(err) {
c.Fatal(err)
}
}
-func (ps *DockerPluginSuite) TestPluginForceRemove(c *check.C) {
+func (ps *DockerPluginSuite) TestPluginForceRemove(c *testing.T) {
pNameWithTag := ps.getPluginRepoWithTag()
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
assert.NilError(c, err)
out, _, _ := dockerCmdWithError("plugin", "remove", pNameWithTag)
- c.Assert(out, checker.Contains, "is enabled")
-
+ assert.Assert(c, strings.Contains(out, "is enabled"))
out, _, err = dockerCmdWithError("plugin", "remove", "--force", pNameWithTag)
assert.NilError(c, err)
- c.Assert(out, checker.Contains, pNameWithTag)
+ assert.Assert(c, strings.Contains(out, pNameWithTag))
}
-func (s *DockerSuite) TestPluginActive(c *check.C) {
+func (s *DockerSuite) TestPluginActive(c *testing.T) {
testRequires(c, DaemonIsLinux, IsAmd64, Network)
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
@@ -84,8 +79,7 @@
assert.NilError(c, err)
out, _, _ := dockerCmdWithError("plugin", "disable", pNameWithTag)
- c.Assert(out, checker.Contains, "in use")
-
+ assert.Assert(c, strings.Contains(out, "in use"))
_, _, err = dockerCmdWithError("volume", "rm", "testvol1")
assert.NilError(c, err)
@@ -94,10 +88,10 @@
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
assert.NilError(c, err)
- c.Assert(out, checker.Contains, pNameWithTag)
+ assert.Assert(c, strings.Contains(out, pNameWithTag))
}
-func (s *DockerSuite) TestPluginActiveNetwork(c *check.C) {
+func (s *DockerSuite) TestPluginActiveNetwork(c *testing.T) {
testRequires(c, DaemonIsLinux, IsAmd64, Network)
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", npNameWithTag)
assert.NilError(c, err)
@@ -108,56 +102,49 @@
nID := strings.TrimSpace(out)
out, _, _ = dockerCmdWithError("plugin", "remove", npNameWithTag)
- c.Assert(out, checker.Contains, "is in use")
-
+ assert.Assert(c, strings.Contains(out, "is in use"))
_, _, err = dockerCmdWithError("network", "rm", nID)
assert.NilError(c, err)
out, _, _ = dockerCmdWithError("plugin", "remove", npNameWithTag)
- c.Assert(out, checker.Contains, "is enabled")
-
+ assert.Assert(c, strings.Contains(out, "is enabled"))
_, _, err = dockerCmdWithError("plugin", "disable", npNameWithTag)
assert.NilError(c, err)
out, _, err = dockerCmdWithError("plugin", "remove", npNameWithTag)
assert.NilError(c, err)
- c.Assert(out, checker.Contains, npNameWithTag)
+ assert.Assert(c, strings.Contains(out, npNameWithTag))
}
-func (ps *DockerPluginSuite) TestPluginInstallDisable(c *check.C) {
+func (ps *DockerPluginSuite) TestPluginInstallDisable(c *testing.T) {
pName := ps.getPluginRepoWithTag()
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName)
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), checker.Contains, pName)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), pName))
out, _, err = dockerCmdWithError("plugin", "ls")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, "false")
-
+ assert.Assert(c, strings.Contains(out, "false"))
out, _, err = dockerCmdWithError("plugin", "enable", pName)
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), checker.Contains, pName)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), pName))
out, _, err = dockerCmdWithError("plugin", "disable", pName)
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), checker.Contains, pName)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), pName))
out, _, err = dockerCmdWithError("plugin", "remove", pName)
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), checker.Contains, pName)
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), pName))
}
-func (s *DockerSuite) TestPluginInstallDisableVolumeLs(c *check.C) {
+func (s *DockerSuite) TestPluginInstallDisableVolumeLs(c *testing.T) {
testRequires(c, DaemonIsLinux, IsAmd64, Network)
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName)
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), checker.Contains, pName)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), pName))
dockerCmd(c, "volume", "ls")
}
-func (ps *DockerPluginSuite) TestPluginSet(c *check.C) {
+func (ps *DockerPluginSuite) TestPluginSet(c *testing.T) {
client := testEnv.APIClient()
name := "test"
@@ -180,35 +167,31 @@
{Name: "pdev2", Settable: []string{"path"}}, // Device without Path is invalid.
}
})
- c.Assert(err, checker.IsNil, check.Commentf("failed to create test plugin"))
+ assert.Assert(c, err == nil, "failed to create test plugin")
env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", name)
- c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=0]")
+ assert.Equal(c, strings.TrimSpace(env), "[DEBUG=0]")
dockerCmd(c, "plugin", "set", name, "DEBUG=1")
env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", name)
- c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
+ assert.Equal(c, strings.TrimSpace(env), "[DEBUG=1]")
env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{with $mount := index .Settings.Mounts 0}}{{$mount.Source}}{{end}}", name)
- c.Assert(strings.TrimSpace(env), checker.Contains, mntSrc)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(env), mntSrc))
dockerCmd(c, "plugin", "set", name, "pmount1.source=bar")
env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{with $mount := index .Settings.Mounts 0}}{{$mount.Source}}{{end}}", name)
- c.Assert(strings.TrimSpace(env), checker.Contains, "bar")
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(env), "bar"))
out, _, err := dockerCmdWithError("plugin", "set", name, "pmount2.source=bar2")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "Plugin config has no mount source")
-
+ assert.Assert(c, strings.Contains(out, "Plugin config has no mount source"))
out, _, err = dockerCmdWithError("plugin", "set", name, "pdev2.path=/dev/bar2")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "Plugin config has no device path")
-
+ assert.Assert(c, strings.Contains(out, "Plugin config has no device path"))
}
-func (ps *DockerPluginSuite) TestPluginInstallArgs(c *check.C) {
+func (ps *DockerPluginSuite) TestPluginInstallArgs(c *testing.T) {
pName := path.Join(ps.registryHost(), "plugin", "testplugininstallwithargs")
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
@@ -218,13 +201,12 @@
})
out, _ := dockerCmd(c, "plugin", "install", "--grant-all-permissions", "--disable", pName, "DEBUG=1")
- c.Assert(strings.TrimSpace(out), checker.Contains, pName)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), pName))
env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", pName)
- c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
+ assert.Equal(c, strings.TrimSpace(env), "[DEBUG=1]")
}
-func (ps *DockerPluginSuite) TestPluginInstallImage(c *check.C) {
+func (ps *DockerPluginSuite) TestPluginInstallImage(c *testing.T) {
testRequires(c, IsAmd64)
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
@@ -235,32 +217,29 @@
out, _, err := dockerCmdWithError("plugin", "install", repoName)
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, `Encountered remote "application/vnd.docker.container.image.v1+json"(image) when fetching`)
+ assert.Assert(c, strings.Contains(out, `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()
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pName)
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), checker.Contains, pName)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), pName))
out, _, err = dockerCmdWithError("plugin", "enable", pName)
assert.ErrorContains(c, err, "")
- c.Assert(strings.TrimSpace(out), checker.Contains, "already enabled")
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), "already enabled"))
_, _, err = dockerCmdWithError("plugin", "disable", pName)
assert.NilError(c, err)
out, _, err = dockerCmdWithError("plugin", "disable", pName)
assert.ErrorContains(c, err, "")
- c.Assert(strings.TrimSpace(out), checker.Contains, "already disabled")
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), "already disabled"))
_, _, err = dockerCmdWithError("plugin", "remove", pName)
assert.NilError(c, err)
}
-func (ps *DockerPluginSuite) TestPluginCreate(c *check.C) {
+func (ps *DockerPluginSuite) TestPluginCreate(c *testing.T) {
name := "foo/bar-driver"
temp, err := ioutil.TempDir("", "foo")
assert.NilError(c, err)
@@ -275,24 +254,21 @@
out, _, err := dockerCmdWithError("plugin", "create", name, temp)
assert.NilError(c, err)
- c.Assert(out, checker.Contains, name)
-
+ assert.Assert(c, strings.Contains(out, name))
out, _, err = dockerCmdWithError("plugin", "ls")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, name)
-
+ assert.Assert(c, strings.Contains(out, name))
out, _, err = dockerCmdWithError("plugin", "create", name, temp)
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "already exist")
-
+ assert.Assert(c, strings.Contains(out, "already exist"))
out, _, err = dockerCmdWithError("plugin", "ls")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, name)
+ assert.Assert(c, strings.Contains(out, name))
// The output will consists of one HEADER line and one line of foo/bar-driver
- c.Assert(len(strings.Split(strings.TrimSpace(out), "\n")), checker.Equals, 2)
+ assert.Equal(c, len(strings.Split(strings.TrimSpace(out), "\n")), 2)
}
-func (ps *DockerPluginSuite) TestPluginInspect(c *check.C) {
+func (ps *DockerPluginSuite) TestPluginInspect(c *testing.T) {
pNameWithTag := ps.getPluginRepoWithTag()
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
@@ -300,9 +276,8 @@
out, _, err := dockerCmdWithError("plugin", "ls")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, pNameWithTag)
- c.Assert(out, checker.Contains, "true")
-
+ assert.Assert(c, strings.Contains(out, pNameWithTag))
+ assert.Assert(c, strings.Contains(out, "true"))
// Find the ID first
out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pNameWithTag)
assert.NilError(c, err)
@@ -334,25 +309,24 @@
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
assert.NilError(c, err)
- c.Assert(out, checker.Contains, pNameWithTag)
-
+ assert.Assert(c, strings.Contains(out, pNameWithTag))
// After remove nothing should be found
_, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", id[:5])
assert.ErrorContains(c, err, "")
}
// 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
testRequires(c, DaemonIsWindows)
out, _, err := dockerCmdWithError("plugin", "inspect", "foobar")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "plugins are not supported on this platform")
+ assert.Assert(c, strings.Contains(out, "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"
client := testEnv.APIClient()
@@ -363,7 +337,7 @@
})
cancel()
- c.Assert(err, checker.IsNil, check.Commentf("failed to create test plugin"))
+ assert.Assert(c, err == nil, "failed to create test plugin")
// Find ID first
id, _, err := dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", name)
@@ -373,43 +347,40 @@
// List current state
out, _, err := dockerCmdWithError("plugin", "ls")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, name)
- c.Assert(out, checker.Contains, "false")
-
+ assert.Assert(c, strings.Contains(out, name))
+ assert.Assert(c, strings.Contains(out, "false"))
env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", id[:5])
- c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=0]")
+ assert.Equal(c, strings.TrimSpace(env), "[DEBUG=0]")
dockerCmd(c, "plugin", "set", id[:5], "DEBUG=1")
env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", id[:5])
- c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
+ assert.Equal(c, strings.TrimSpace(env), "[DEBUG=1]")
// Enable
_, _, err = dockerCmdWithError("plugin", "enable", id[:5])
assert.NilError(c, err)
out, _, err = dockerCmdWithError("plugin", "ls")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, name)
- c.Assert(out, checker.Contains, "true")
-
+ assert.Assert(c, strings.Contains(out, name))
+ assert.Assert(c, strings.Contains(out, "true"))
// Disable
_, _, err = dockerCmdWithError("plugin", "disable", id[:5])
assert.NilError(c, err)
out, _, err = dockerCmdWithError("plugin", "ls")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, name)
- c.Assert(out, checker.Contains, "false")
-
+ assert.Assert(c, strings.Contains(out, name))
+ assert.Assert(c, strings.Contains(out, "false"))
// Remove
_, _, err = dockerCmdWithError("plugin", "remove", id[:5])
assert.NilError(c, err)
// List returns none
out, _, err = dockerCmdWithError("plugin", "ls")
assert.NilError(c, err)
- c.Assert(out, checker.Not(checker.Contains), name)
+ assert.Assert(c, !strings.Contains(out, name))
}
-func (ps *DockerPluginSuite) TestPluginListDefaultFormat(c *check.C) {
+func (ps *DockerPluginSuite) TestPluginListDefaultFormat(c *testing.T) {
config, err := ioutil.TempDir("", "config-file-")
assert.NilError(c, err)
defer os.RemoveAll(config)
@@ -425,7 +396,7 @@
err = plugin.Create(ctx, client, name, func(cfg *plugin.Config) {
cfg.Description = "test plugin"
})
- c.Assert(err, checker.IsNil, check.Commentf("failed to create test plugin"))
+ assert.Assert(c, err == nil, "failed to create test plugin")
out, _ := dockerCmd(c, "plugin", "inspect", "--format", "{{.ID}}", name)
id := strings.TrimSpace(out)
@@ -437,10 +408,10 @@
enabled: false`, id, name)
out, _ = dockerCmd(c, "--config", config, "plugin", "ls", "--no-trunc")
- c.Assert(strings.TrimSpace(out), checker.Contains, expectedOutput)
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), expectedOutput))
}
-func (s *DockerSuite) TestPluginUpgrade(c *check.C) {
+func (s *DockerSuite) TestPluginUpgrade(c *testing.T) {
testRequires(c, DaemonIsLinux, Network, testEnv.IsLocalDaemon, IsAmd64, NotUserNamespace)
plugin := "cpuguy83/docker-volume-driver-plugin-local:latest"
pluginV2 := "cpuguy83/docker-volume-driver-plugin-local:v2"
@@ -451,14 +422,13 @@
out, _, err := dockerCmdWithError("plugin", "upgrade", "--grant-all-permissions", plugin, pluginV2)
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "disabled before upgrading")
-
+ assert.Assert(c, strings.Contains(out, "disabled before upgrading"))
out, _ = dockerCmd(c, "plugin", "inspect", "--format={{.ID}}", plugin)
id := strings.TrimSpace(out)
// make sure "v2" does not exists
_, err = os.Stat(filepath.Join(testEnv.DaemonInfo.DockerRootDir, "plugins", id, "rootfs", "v2"))
- c.Assert(os.IsNotExist(err), checker.True, check.Commentf("%s", out))
+ assert.Assert(c, os.IsNotExist(err), "%s", out)
dockerCmd(c, "plugin", "disable", "-f", plugin)
dockerCmd(c, "plugin", "upgrade", "--grant-all-permissions", "--skip-remote-check", plugin, pluginV2)
@@ -472,7 +442,7 @@
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)
d := daemon.New(c, dockerBinary, dockerdBinary)
d.Start(c)
@@ -480,7 +450,7 @@
name := "cpuguy83/docker-metrics-plugin-test:latest"
r := cli.Docker(cli.Args("plugin", "install", "--grant-all-permissions", name), cli.Daemon(d))
- c.Assert(r.Error, checker.IsNil, check.Commentf(r.Combined()))
+ assert.Assert(c, r.Error == nil, r.Combined())
// plugin lisens on localhost:19393 and proxies the metrics
resp, err := http.Get("http://localhost:19393/metrics")
@@ -490,5 +460,5 @@
b, err := ioutil.ReadAll(resp.Body)
assert.NilError(c, err)
// check that a known metric is there... don't expect this metric to change over time.. probably safe
- c.Assert(string(b), checker.Contains, "container_actions")
+ assert.Assert(c, strings.Contains(string(b), "container_actions"))
}
diff --git a/integration-cli/docker_cli_port_test.go b/integration-cli/docker_cli_port_test.go
index 32f59eb..dd751e3 100644
--- a/integration-cli/docker_cli_port_test.go
+++ b/integration-cli/docker_cli_port_test.go
@@ -7,13 +7,12 @@
"sort"
"strconv"
"strings"
+ "testing"
- "github.com/docker/docker/integration-cli/checker"
- "github.com/go-check/check"
"gotest.tools/assert"
)
-func (s *DockerSuite) TestPortList(c *check.C) {
+func (s *DockerSuite) TestPortList(c *testing.T) {
testRequires(c, DaemonIsLinux)
// one port
out, _ := dockerCmd(c, "run", "-d", "-p", "9876:80", "busybox", "top")
@@ -105,7 +104,7 @@
"-p", "9090-9092:80",
"busybox", "top")
// Exhausted port range did not return an error
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
+ assert.Assert(c, err != nil, "out: %s", out)
for i := 0; i < 3; i++ {
dockerCmd(c, "rm", "-f", IDs[i])
@@ -121,7 +120,7 @@
"-p", invalidRange,
"busybox", "top")
// Port range should have returned an error
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
+ assert.Assert(c, err != nil, "out: %s", out)
}
// test host range:container range spec.
@@ -157,7 +156,7 @@
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")
if len(lines) != len(expected) {
return fmt.Errorf("different size lists %s, %d, %d", out, len(lines), len(expected))
@@ -174,7 +173,7 @@
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")
var validTcp, validUdp bool
@@ -206,11 +205,11 @@
return nil
}
-func stopRemoveContainer(id string, c *check.C) {
+func stopRemoveContainer(id string, c *testing.T) {
dockerCmd(c, "rm", "-f", id)
}
-func (s *DockerSuite) TestUnpublishedPortsInPsOutput(c *check.C) {
+func (s *DockerSuite) TestUnpublishedPortsInPsOutput(c *testing.T) {
testRequires(c, DaemonIsLinux)
// Run busybox with command line expose (equivalent to EXPOSE in image's Dockerfile) for the following ports
port1 := 80
@@ -224,10 +223,9 @@
unpPort2 := fmt.Sprintf("%d/tcp", port2)
out, _ := dockerCmd(c, "ps", "-n=1")
// Missing unpublished ports in docker ps output
- c.Assert(out, checker.Contains, unpPort1)
+ assert.Assert(c, strings.Contains(out, unpPort1))
// Missing unpublished ports in docker ps output
- c.Assert(out, checker.Contains, unpPort2)
-
+ assert.Assert(c, strings.Contains(out, unpPort2))
// Run the container forcing to publish the exposed ports
dockerCmd(c, "run", "-d", "-P", expose1, expose2, "busybox", "sleep", "5")
@@ -236,9 +234,9 @@
expBndRegx2 := regexp.MustCompile(`0.0.0.0:\d\d\d\d\d->` + unpPort2)
out, _ = dockerCmd(c, "ps", "-n=1")
// Cannot find expected port binding port (0.0.0.0:xxxxx->unpPort1) in docker ps output
- c.Assert(expBndRegx1.MatchString(out), checker.Equals, true, check.Commentf("out: %s; unpPort1: %s", out, unpPort1))
+ assert.Equal(c, expBndRegx1.MatchString(out), true, fmt.Sprintf("out: %s; unpPort1: %s", out, unpPort1))
// Cannot find expected port binding port (0.0.0.0:xxxxx->unpPort2) in docker ps output
- c.Assert(expBndRegx2.MatchString(out), checker.Equals, true, check.Commentf("out: %s; unpPort2: %s", out, unpPort2))
+ assert.Equal(c, expBndRegx2.MatchString(out), true, fmt.Sprintf("out: %s; unpPort2: %s", out, unpPort2))
// Run the container specifying explicit port bindings for the exposed ports
offset := 10000
@@ -252,10 +250,9 @@
expBnd2 := fmt.Sprintf("0.0.0.0:%d->%s", offset+port2, unpPort2)
out, _ = dockerCmd(c, "ps", "-n=1")
// Cannot find expected port binding (expBnd1) in docker ps output
- c.Assert(out, checker.Contains, expBnd1)
+ assert.Assert(c, strings.Contains(out, expBnd1))
// Cannot find expected port binding (expBnd2) in docker ps output
- c.Assert(out, checker.Contains, expBnd2)
-
+ assert.Assert(c, strings.Contains(out, expBnd2))
// Remove container now otherwise it will interfere with next test
stopRemoveContainer(id, c)
@@ -266,9 +263,9 @@
// Check docker ps o/p for last created container reports the specified port mappings
out, _ = dockerCmd(c, "ps", "-n=1")
// Cannot find expected port binding (expBnd1) in docker ps output
- c.Assert(out, checker.Contains, expBnd1)
+ assert.Assert(c, strings.Contains(out, expBnd1))
// Cannot find expected port binding (expBnd2) in docker ps output
- c.Assert(out, checker.Contains, expBnd2)
+ assert.Assert(c, strings.Contains(out, expBnd2))
// Remove container now otherwise it will interfere with next test
stopRemoveContainer(id, c)
@@ -278,12 +275,12 @@
// Check docker ps o/p for last created container reports the specified unpublished port and port mapping
out, _ = dockerCmd(c, "ps", "-n=1")
// Missing unpublished exposed ports (unpPort1) in docker ps output
- c.Assert(out, checker.Contains, unpPort1)
+ assert.Assert(c, strings.Contains(out, unpPort1))
// Missing port binding (expBnd2) in docker ps output
- c.Assert(out, checker.Contains, expBnd2)
+ assert.Assert(c, strings.Contains(out, expBnd2))
}
-func (s *DockerSuite) TestPortHostBinding(c *check.C) {
+func (s *DockerSuite) TestPortHostBinding(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmd(c, "run", "-d", "-p", "9876:80", "busybox",
"nc", "-l", "-p", "80")
@@ -302,10 +299,10 @@
out, _, err = dockerCmdWithError("run", "--net=host", "busybox", "nc", "localhost", "9876")
// Port is still bound after the Container is removed
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
+ assert.Assert(c, err != nil, "out: %s", out)
}
-func (s *DockerSuite) TestPortExposeHostBinding(c *check.C) {
+func (s *DockerSuite) TestPortExposeHostBinding(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmd(c, "run", "-d", "-P", "--expose", "80", "busybox",
"nc", "-l", "-p", "80")
@@ -314,7 +311,7 @@
out, _ = dockerCmd(c, "port", firstID, "80")
_, exposedPort, err := net.SplitHostPort(out)
- c.Assert(err, checker.IsNil, check.Commentf("out: %s", out))
+ assert.Assert(c, err == nil, "out: %s", out)
dockerCmd(c, "run", "--net=host", "busybox",
"nc", "localhost", strings.TrimSpace(exposedPort))
@@ -324,29 +321,25 @@
out, _, err = dockerCmdWithError("run", "--net=host", "busybox",
"nc", "localhost", strings.TrimSpace(exposedPort))
// Port is still bound after the Container is removed
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
+ assert.Assert(c, err != nil, "out: %s", out)
}
-func (s *DockerSuite) TestPortBindingOnSandbox(c *check.C) {
+func (s *DockerSuite) TestPortBindingOnSandbox(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
dockerCmd(c, "network", "create", "--internal", "-d", "bridge", "internal-net")
nr := getNetworkResource(c, "internal-net")
- c.Assert(nr.Internal, checker.Equals, true)
+ assert.Equal(c, nr.Internal, true)
dockerCmd(c, "run", "--net", "internal-net", "-d", "--name", "c1",
"-p", "8080:8080", "busybox", "nc", "-l", "-p", "8080")
- c.Assert(waitRun("c1"), check.IsNil)
+ assert.Assert(c, waitRun("c1") == nil)
_, _, err := dockerCmdWithError("run", "--net=host", "busybox", "nc", "localhost", "8080")
- c.Assert(err, check.NotNil,
- check.Commentf("Port mapping on internal network is expected to fail"))
-
+ assert.Assert(c, err != nil, "Port mapping on internal network is expected to fail")
// Connect container to another normal bridge network
dockerCmd(c, "network", "create", "-d", "bridge", "foo-net")
dockerCmd(c, "network", "connect", "foo-net", "c1")
_, _, err = dockerCmdWithError("run", "--net=host", "busybox", "nc", "localhost", "8080")
- c.Assert(err, check.IsNil,
- check.Commentf("Port mapping on the new network is expected to succeed"))
-
+ assert.Assert(c, err == nil, "Port mapping on the new network is expected to succeed")
}
diff --git a/integration-cli/docker_cli_proxy_test.go b/integration-cli/docker_cli_proxy_test.go
index c444b61..f45acbe 100644
--- a/integration-cli/docker_cli_proxy_test.go
+++ b/integration-cli/docker_cli_proxy_test.go
@@ -3,13 +3,13 @@
import (
"net"
"strings"
+ "testing"
- "github.com/go-check/check"
"gotest.tools/assert"
"gotest.tools/icmd"
)
-func (s *DockerSuite) TestCLIProxyDisableProxyUnixSock(c *check.C) {
+func (s *DockerSuite) TestCLIProxyDisableProxyUnixSock(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
icmd.RunCmd(icmd.Cmd{
@@ -20,7 +20,7 @@
// 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
-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
addrs, err := net.InterfaceAddrs()
assert.NilError(c, err)
diff --git a/integration-cli/docker_cli_prune_unix_test.go b/integration-cli/docker_cli_prune_unix_test.go
index 0264950..818af6a 100644
--- a/integration-cli/docker_cli_prune_unix_test.go
+++ b/integration-cli/docker_cli_prune_unix_test.go
@@ -8,39 +8,41 @@
"path/filepath"
"strconv"
"strings"
+ "testing"
"time"
"github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/integration-cli/daemon"
- "github.com/go-check/check"
"gotest.tools/assert"
"gotest.tools/icmd"
+ "gotest.tools/poll"
)
-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")
assert.NilError(c, err)
for _, s := range kept {
- waitAndAssert(c, defaultReconciliationTimeout, func(*check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(*testing.T) (interface{}, string) {
out, err := d.Cmd("network", "ls", "--format", "{{.Name}}")
assert.NilError(c, err)
- return out, nil
- }, checker.Contains, s)
+ return out, ""
+ }, checker.Contains(s)), poll.WithTimeout(defaultReconciliationTimeout))
+
}
for _, s := range pruned {
- waitAndAssert(c, defaultReconciliationTimeout, func(*check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(*testing.T) (interface{}, string) {
out, err := d.Cmd("network", "ls", "--format", "{{.Name}}")
assert.NilError(c, err)
- return out, nil
- }, checker.Not(checker.Contains), s)
+ return out, ""
+ }, checker.Not(checker.Contains(s))), poll.WithTimeout(defaultReconciliationTimeout))
}
}
-func (s *DockerSwarmSuite) TestPruneNetwork(c *check.C) {
+func (s *DockerSwarmSuite) TestPruneNetwork(c *testing.T) {
d := s.AddDaemon(c, true, true)
_, err := d.Cmd("network", "create", "n1") // used by container (testprune)
assert.NilError(c, err)
@@ -64,7 +66,7 @@
"busybox", "top")
assert.NilError(c, err)
assert.Assert(c, strings.TrimSpace(out) != "")
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, replicas+1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(replicas+1)), poll.WithTimeout(defaultReconciliationTimeout))
// prune and verify
pruneNetworkAndVerify(c, d, []string{"n1", "n3"}, []string{"n2", "n4"})
@@ -74,12 +76,12 @@
assert.NilError(c, err)
_, err = d.Cmd("service", "rm", serviceName)
assert.NilError(c, err)
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 0)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(0)), poll.WithTimeout(defaultReconciliationTimeout))
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)
result := cli.BuildCmd(c, "test", cli.Daemon(s.d),
@@ -92,26 +94,22 @@
out, err := s.d.Cmd("images", "-q", "--no-trunc")
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), checker.Contains, id)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id))
out, err = s.d.Cmd("image", "prune", "--force")
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id)
-
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id))
out, err = s.d.Cmd("images", "-q", "--no-trunc")
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), checker.Contains, id)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id))
out, err = s.d.Cmd("image", "prune", "--force", "--all")
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), checker.Contains, id)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id))
out, err = s.d.Cmd("images", "-q", "--no-trunc")
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id)
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id))
}
-func (s *DockerSuite) TestPruneContainerUntil(c *check.C) {
+func (s *DockerSuite) TestPruneContainerUntil(c *testing.T) {
out := cli.DockerCmd(c, "run", "-d", "busybox").Combined()
id1 := strings.TrimSpace(out)
cli.WaitExited(c, id1, 5*time.Second)
@@ -123,15 +121,14 @@
cli.WaitExited(c, id2, 5*time.Second)
out = cli.DockerCmd(c, "container", "prune", "--force", "--filter", "until="+until).Combined()
- c.Assert(strings.TrimSpace(out), checker.Contains, id1)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id2)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id1))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
out = cli.DockerCmd(c, "ps", "-a", "-q", "--no-trunc").Combined()
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id1)
- c.Assert(strings.TrimSpace(out), checker.Contains, id2)
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), 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()
id1 := strings.TrimSpace(out)
cli.WaitExited(c, id1, 5*time.Second)
@@ -158,53 +155,47 @@
// With config.json only, prune based on label=foobar
out = cli.DockerCmd(c, "--config", d, "container", "prune", "--force").Combined()
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id1)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id2)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id3)
- c.Assert(strings.TrimSpace(out), checker.Contains, id4)
-
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id4))
out = cli.DockerCmd(c, "container", "prune", "--force", "--filter", "label=foo").Combined()
- c.Assert(strings.TrimSpace(out), checker.Contains, id1)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id2)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id3)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id1))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
out = cli.DockerCmd(c, "ps", "-a", "-q", "--no-trunc").Combined()
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id1)
- c.Assert(strings.TrimSpace(out), checker.Contains, id2)
- c.Assert(strings.TrimSpace(out), checker.Contains, id3)
-
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id3))
out = cli.DockerCmd(c, "container", "prune", "--force", "--filter", "label!=bar").Combined()
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id2)
- c.Assert(strings.TrimSpace(out), checker.Contains, id3)
-
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id3))
out = cli.DockerCmd(c, "ps", "-a", "-q", "--no-trunc").Combined()
- c.Assert(strings.TrimSpace(out), checker.Contains, id2)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id3)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
// With config.json label=foobar and CLI label!=foobar, CLI label!=foobar supersede
out = cli.DockerCmd(c, "--config", d, "container", "prune", "--force", "--filter", "label!=foobar").Combined()
- c.Assert(strings.TrimSpace(out), checker.Contains, id2)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
out = cli.DockerCmd(c, "ps", "-a", "-q", "--no-trunc").Combined()
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id2)
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
}
-func (s *DockerSuite) TestPruneVolumeLabel(c *check.C) {
+func (s *DockerSuite) TestPruneVolumeLabel(c *testing.T) {
out, _ := dockerCmd(c, "volume", "create", "--label", "foo")
id1 := strings.TrimSpace(out)
- c.Assert(id1, checker.Not(checker.Equals), "")
+ assert.Assert(c, id1 != "")
out, _ = dockerCmd(c, "volume", "create", "--label", "bar")
id2 := strings.TrimSpace(out)
- c.Assert(id2, checker.Not(checker.Equals), "")
+ assert.Assert(c, id2 != "")
out, _ = dockerCmd(c, "volume", "create")
id3 := strings.TrimSpace(out)
- c.Assert(id3, checker.Not(checker.Equals), "")
+ assert.Assert(c, id3 != "")
out, _ = dockerCmd(c, "volume", "create", "--label", "foobar")
id4 := strings.TrimSpace(out)
- c.Assert(id4, checker.Not(checker.Equals), "")
+ assert.Assert(c, id4 != "")
// Add a config file of label=foobar, that will have no impact if cli is label!=foobar
config := `{"pruneFilters": ["label=foobar"]}`
@@ -216,59 +207,51 @@
// With config.json only, prune based on label=foobar
out, _ = dockerCmd(c, "--config", d, "volume", "prune", "--force")
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id1)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id2)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id3)
- c.Assert(strings.TrimSpace(out), checker.Contains, id4)
-
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id4))
out, _ = dockerCmd(c, "volume", "prune", "--force", "--filter", "label=foo")
- c.Assert(strings.TrimSpace(out), checker.Contains, id1)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id2)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id3)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id1))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
out, _ = dockerCmd(c, "volume", "ls", "--format", "{{.Name}}")
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id1)
- c.Assert(strings.TrimSpace(out), checker.Contains, id2)
- c.Assert(strings.TrimSpace(out), checker.Contains, id3)
-
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id3))
out, _ = dockerCmd(c, "volume", "prune", "--force", "--filter", "label!=bar")
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id2)
- c.Assert(strings.TrimSpace(out), checker.Contains, id3)
-
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id3))
out, _ = dockerCmd(c, "volume", "ls", "--format", "{{.Name}}")
- c.Assert(strings.TrimSpace(out), checker.Contains, id2)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id3)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
// With config.json label=foobar and CLI label!=foobar, CLI label!=foobar supersede
out, _ = dockerCmd(c, "--config", d, "volume", "prune", "--force", "--filter", "label!=foobar")
- c.Assert(strings.TrimSpace(out), checker.Contains, id2)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
out, _ = dockerCmd(c, "volume", "ls", "--format", "{{.Name}}")
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id2)
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), 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", "bar", "n2")
dockerCmd(c, "network", "create", "n3")
out, _ := dockerCmd(c, "network", "prune", "--force", "--filter", "label=foo")
- c.Assert(strings.TrimSpace(out), checker.Contains, "n1")
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), "n2")
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), "n3")
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), "n1"))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n2"))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n3"))
out, _ = dockerCmd(c, "network", "prune", "--force", "--filter", "label!=bar")
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), "n1")
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), "n2")
- c.Assert(strings.TrimSpace(out), checker.Contains, "n3")
-
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n1"))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n2"))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), "n3"))
out, _ = dockerCmd(c, "network", "prune", "--force")
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), "n1")
- c.Assert(strings.TrimSpace(out), checker.Contains, "n2")
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), "n3")
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n1"))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), "n2"))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n3"))
}
-func (s *DockerDaemonSuite) TestPruneImageLabel(c *check.C) {
+func (s *DockerDaemonSuite) TestPruneImageLabel(c *testing.T) {
s.d.StartWithBusybox(c)
result := cli.BuildCmd(c, "test1", cli.Daemon(s.d),
@@ -280,8 +263,7 @@
id1 := strings.TrimSpace(result.Combined())
out, err := s.d.Cmd("images", "-q", "--no-trunc")
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), checker.Contains, id1)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id1))
result = cli.BuildCmd(c, "test2", cli.Daemon(s.d),
build.WithDockerfile(`FROM busybox
LABEL bar=foo`),
@@ -291,20 +273,17 @@
id2 := strings.TrimSpace(result.Combined())
out, err = s.d.Cmd("images", "-q", "--no-trunc")
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), checker.Contains, id2)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
out, err = s.d.Cmd("image", "prune", "--force", "--all", "--filter", "label=foo=bar")
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), checker.Contains, id1)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id2)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id1))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
out, err = s.d.Cmd("image", "prune", "--force", "--all", "--filter", "label!=bar=foo")
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id1)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id2)
-
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
out, err = s.d.Cmd("image", "prune", "--force", "--all", "--filter", "label=bar=foo")
assert.NilError(c, err)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), id1)
- c.Assert(strings.TrimSpace(out), checker.Contains, id2)
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
}
diff --git a/integration-cli/docker_cli_ps_test.go b/integration-cli/docker_cli_ps_test.go
index cab75f4..0989d74 100644
--- a/integration-cli/docker_cli_ps_test.go
+++ b/integration-cli/docker_cli_ps_test.go
@@ -5,20 +5,20 @@
"sort"
"strconv"
"strings"
+ "testing"
"time"
"github.com/docker/docker/api/types/versions"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/pkg/stringid"
- "github.com/go-check/check"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
"gotest.tools/icmd"
+ "gotest.tools/skip"
)
-func (s *DockerSuite) TestPsListContainersBase(c *check.C) {
+func (s *DockerSuite) TestPsListContainersBase(c *testing.T) {
existingContainers := ExistingContainerIDs(c)
out := runSleepingContainer(c, "-d")
@@ -35,89 +35,89 @@
fourthID := strings.TrimSpace(out)
// make sure the second is running
- c.Assert(waitRun(secondID), checker.IsNil)
+ assert.Assert(c, waitRun(secondID) == nil)
// make sure third one is not running
dockerCmd(c, "wait", thirdID)
// make sure the forth is running
- c.Assert(waitRun(fourthID), checker.IsNil)
+ assert.Assert(c, waitRun(fourthID) == nil)
// all
out, _ = dockerCmd(c, "ps", "-a")
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), []string{fourthID, thirdID, secondID, firstID}), checker.Equals, true, check.Commentf("ALL: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), []string{fourthID, thirdID, secondID, firstID}), true, fmt.Sprintf("ALL: Container list is not in the correct order: \n%s", out))
// running
out, _ = dockerCmd(c, "ps")
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), []string{fourthID, secondID, firstID}), checker.Equals, true, check.Commentf("RUNNING: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), []string{fourthID, secondID, firstID}), true, fmt.Sprintf("RUNNING: Container list is not in the correct order: \n%s", out))
// limit
out, _ = dockerCmd(c, "ps", "-n=2", "-a")
expected := []string{fourthID, thirdID}
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("LIMIT & ALL: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, fmt.Sprintf("LIMIT & ALL: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-n=2")
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("LIMIT: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, fmt.Sprintf("LIMIT: Container list is not in the correct order: \n%s", out))
// filter since
out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-a")
expected = []string{fourthID, thirdID, secondID}
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter & ALL: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, fmt.Sprintf("SINCE filter & ALL: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-f", "since="+firstID)
expected = []string{fourthID, secondID}
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, fmt.Sprintf("SINCE filter: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-f", "since="+thirdID)
expected = []string{fourthID}
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, fmt.Sprintf("SINCE filter: Container list is not in the correct order: \n%s", out))
// filter before
out, _ = dockerCmd(c, "ps", "-f", "before="+fourthID, "-a")
expected = []string{thirdID, secondID, firstID}
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("BEFORE filter & ALL: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, fmt.Sprintf("BEFORE filter & ALL: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-f", "before="+fourthID)
expected = []string{secondID, firstID}
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("BEFORE filter: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, fmt.Sprintf("BEFORE filter: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-f", "before="+thirdID)
expected = []string{secondID, firstID}
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, fmt.Sprintf("SINCE filter: Container list is not in the correct order: \n%s", out))
// filter since & before
out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-f", "before="+fourthID, "-a")
expected = []string{thirdID, secondID}
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, BEFORE filter & ALL: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, fmt.Sprintf("SINCE filter, BEFORE filter & ALL: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-f", "before="+fourthID)
expected = []string{secondID}
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, BEFORE filter: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, fmt.Sprintf("SINCE filter, BEFORE filter: Container list is not in the correct order: \n%s", out))
// filter since & limit
out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-n=2", "-a")
expected = []string{fourthID, thirdID}
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, fmt.Sprintf("SINCE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-n=2")
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, LIMIT: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, fmt.Sprintf("SINCE filter, LIMIT: Container list is not in the correct order: \n%s", out))
// filter before & limit
out, _ = dockerCmd(c, "ps", "-f", "before="+fourthID, "-n=1", "-a")
expected = []string{thirdID}
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("BEFORE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, fmt.Sprintf("BEFORE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-f", "before="+fourthID, "-n=1")
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("BEFORE filter, LIMIT: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, fmt.Sprintf("BEFORE filter, LIMIT: Container list is not in the correct order: \n%s", out))
// filter since & filter before & limit
out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-f", "before="+fourthID, "-n=1", "-a")
expected = []string{thirdID}
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, BEFORE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, fmt.Sprintf("SINCE filter, BEFORE filter, LIMIT & ALL: Container list is not in the correct order: \n%s", out))
out, _ = dockerCmd(c, "ps", "-f", "since="+firstID, "-f", "before="+fourthID, "-n=1")
- c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), checker.Equals, true, check.Commentf("SINCE filter, BEFORE filter, LIMIT: Container list is not in the correct order: \n%s", out))
+ assert.Equal(c, assertContainerList(RemoveOutputForExistingElements(out, existingContainers), expected), true, fmt.Sprintf("SINCE filter, BEFORE filter, LIMIT: Container list is not in the correct order: \n%s", out))
}
@@ -139,7 +139,7 @@
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
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "busybox")
@@ -173,13 +173,13 @@
sizeIndex := strings.Index(lines[0], "SIZE")
idIndex := strings.Index(lines[0], "CONTAINER ID")
foundID := lines[1][idIndex : idIndex+12]
- c.Assert(foundID, checker.Equals, id[:12], check.Commentf("Expected id %s, got %s", id[:12], foundID))
+ assert.Equal(c, foundID, id[:12], fmt.Sprintf("Expected id %s, got %s", id[:12], foundID))
expectedSize := fmt.Sprintf("%dB", 2+baseBytes)
foundSize := lines[1][sizeIndex:]
- c.Assert(foundSize, checker.Contains, expectedSize, check.Commentf("Expected size %q, got %q", expectedSize, foundSize))
+ assert.Assert(c, strings.Contains(foundSize, expectedSize), "Expected size %q, got %q", expectedSize, foundSize)
}
-func (s *DockerSuite) TestPsListContainersFilterStatus(c *check.C) {
+func (s *DockerSuite) TestPsListContainersFilterStatus(c *testing.T) {
existingContainers := ExistingContainerIDs(c)
// start exited container
@@ -196,11 +196,11 @@
// filter containers by exited
out = cli.DockerCmd(c, "ps", "--no-trunc", "-q", "--filter=status=exited").Combined()
containerOut := strings.TrimSpace(out)
- c.Assert(RemoveOutputForExistingElements(containerOut, existingContainers), checker.Equals, firstID)
+ assert.Equal(c, RemoveOutputForExistingElements(containerOut, existingContainers), firstID)
out = cli.DockerCmd(c, "ps", "-a", "--no-trunc", "-q", "--filter=status=running").Combined()
containerOut = strings.TrimSpace(out)
- c.Assert(RemoveOutputForExistingElements(containerOut, existingContainers), checker.Equals, secondID)
+ assert.Equal(c, RemoveOutputForExistingElements(containerOut, existingContainers), secondID)
result := cli.Docker(cli.Args("ps", "-a", "-q", "--filter=status=rubbish"), cli.WithTimeout(time.Second*60))
err := "Invalid filter 'status=rubbish'"
@@ -222,11 +222,11 @@
out = cli.DockerCmd(c, "ps", "--no-trunc", "-q", "--filter=status=paused").Combined()
containerOut = strings.TrimSpace(out)
- c.Assert(RemoveOutputForExistingElements(containerOut, existingContainers), checker.Equals, pausedID)
+ assert.Equal(c, RemoveOutputForExistingElements(containerOut, existingContainers), pausedID)
}
}
-func (s *DockerSuite) TestPsListContainersFilterHealth(c *check.C) {
+func (s *DockerSuite) TestPsListContainersFilterHealth(c *testing.T) {
existingContainers := ExistingContainerIDs(c)
// Test legacy no health check
out := runSleepingContainer(c, "--name=none_legacy")
@@ -236,7 +236,7 @@
out = cli.DockerCmd(c, "ps", "-q", "-l", "--no-trunc", "--filter=health=none").Combined()
containerOut := strings.TrimSpace(out)
- c.Assert(containerOut, checker.Equals, containerID, check.Commentf("Expected id %s, got %s for legacy none filter, output: %q", containerID, containerOut, out))
+ assert.Equal(c, containerOut, containerID, fmt.Sprintf("Expected id %s, got %s for legacy none filter, output: %q", containerID, containerOut, out))
// Test no health check specified explicitly
out = runSleepingContainer(c, "--name=none", "--no-healthcheck")
@@ -246,7 +246,7 @@
out = cli.DockerCmd(c, "ps", "-q", "-l", "--no-trunc", "--filter=health=none").Combined()
containerOut = strings.TrimSpace(out)
- c.Assert(containerOut, checker.Equals, containerID, check.Commentf("Expected id %s, got %s for none filter, output: %q", containerID, containerOut, out))
+ assert.Equal(c, containerOut, containerID, fmt.Sprintf("Expected id %s, got %s for none filter, output: %q", containerID, containerOut, out))
// Test failing health check
out = runSleepingContainer(c, "--name=failing_container", "--health-cmd=exit 1", "--health-interval=1s")
@@ -256,7 +256,7 @@
out = cli.DockerCmd(c, "ps", "-q", "--no-trunc", "--filter=health=unhealthy").Combined()
containerOut = strings.TrimSpace(out)
- c.Assert(containerOut, checker.Equals, containerID, check.Commentf("Expected containerID %s, got %s for unhealthy filter, output: %q", containerID, containerOut, out))
+ assert.Equal(c, containerOut, containerID, fmt.Sprintf("Expected containerID %s, got %s for unhealthy filter, output: %q", containerID, containerOut, out))
// Check passing healthcheck
out = runSleepingContainer(c, "--name=passing_container", "--health-cmd=exit 0", "--health-interval=1s")
@@ -266,10 +266,10 @@
out = cli.DockerCmd(c, "ps", "-q", "--no-trunc", "--filter=health=healthy").Combined()
containerOut = strings.TrimSpace(RemoveOutputForExistingElements(out, existingContainers))
- c.Assert(containerOut, checker.Equals, containerID, check.Commentf("Expected containerID %s, got %s for healthy filter, output: %q", containerID, containerOut, out))
+ assert.Equal(c, containerOut, containerID, fmt.Sprintf("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
out, _ := dockerCmd(c, "run", "-d", "busybox")
firstID := strings.TrimSpace(out)
@@ -280,10 +280,10 @@
// filter containers by id
out, _ = dockerCmd(c, "ps", "-a", "-q", "--filter=id="+firstID)
containerOut := strings.TrimSpace(out)
- c.Assert(containerOut, checker.Equals, firstID[:12], check.Commentf("Expected id %s, got %s for exited filter, output: %q", firstID[:12], containerOut, out))
+ assert.Equal(c, containerOut, firstID[:12], fmt.Sprintf("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
dockerCmd(c, "run", "--name=a_name_to_match", "busybox")
id := getIDByName(c, "a_name_to_match")
@@ -294,7 +294,7 @@
// filter containers by name
out, _ := dockerCmd(c, "ps", "-a", "-q", "--filter=name=a_name_to_match")
containerOut := strings.TrimSpace(out)
- c.Assert(containerOut, checker.Equals, id[:12], check.Commentf("Expected id %s, got %s for exited filter, output: %q", id[:12], containerOut, out))
+ assert.Equal(c, containerOut, id[:12], fmt.Sprintf("Expected id %s, got %s for exited filter, output: %q", id[:12], containerOut, out))
}
// Test for the ancestor filter for ps.
@@ -305,7 +305,7 @@
// - 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)
// - Filter them out :P
-func (s *DockerSuite) TestPsListContainersFilterAncestorImage(c *check.C) {
+func (s *DockerSuite) TestPsListContainersFilterAncestorImage(c *testing.T) {
existingContainers := ExistingContainerIDs(c)
// Build images
@@ -378,7 +378,7 @@
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
if out != "" {
actualIDs = strings.Split(out[:len(out)-1], "\n")
@@ -386,7 +386,7 @@
sort.Strings(actualIDs)
sort.Strings(expectedIDs)
- c.Assert(actualIDs, checker.HasLen, len(expectedIDs), check.Commentf("Expected filtered container(s) for %s ancestor filter to be %v:%v, got %v:%v", filterName, len(expectedIDs), expectedIDs, len(actualIDs), actualIDs))
+ assert.Equal(c, len(actualIDs), len(expectedIDs), fmt.Sprintf("Expected filtered container(s) for %s ancestor filter to be %v:%v, got %v:%v", filterName, len(expectedIDs), expectedIDs, len(actualIDs), actualIDs))
if len(expectedIDs) > 0 {
same := true
for i := range expectedIDs {
@@ -396,11 +396,11 @@
break
}
}
- c.Assert(same, checker.Equals, true, check.Commentf("Expected filtered container(s) for %s ancestor filter to be %v, got %v", filterName, expectedIDs, actualIDs))
+ assert.Equal(c, same, true, fmt.Sprintf("Expected filtered container(s) for %s ancestor filter to be %v, got %v", filterName, expectedIDs, actualIDs))
}
}
-func (s *DockerSuite) TestPsListContainersFilterLabel(c *check.C) {
+func (s *DockerSuite) TestPsListContainersFilterLabel(c *testing.T) {
// start container
dockerCmd(c, "run", "--name=first", "-l", "match=me", "-l", "second=tag", "busybox")
firstID := getIDByName(c, "first")
@@ -416,55 +416,58 @@
// filter containers by exact match
out, _ := dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=label=match=me")
containerOut := strings.TrimSpace(out)
- c.Assert(containerOut, checker.Equals, firstID, check.Commentf("Expected id %s, got %s for exited filter, output: %q", firstID, containerOut, out))
+ assert.Equal(c, containerOut, firstID, fmt.Sprintf("Expected id %s, got %s for exited filter, output: %q", firstID, containerOut, out))
// filter containers by two labels
out, _ = dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=label=match=me", "--filter=label=second=tag")
containerOut = strings.TrimSpace(out)
- c.Assert(containerOut, checker.Equals, firstID, check.Commentf("Expected id %s, got %s for exited filter, output: %q", firstID, containerOut, out))
+ assert.Equal(c, containerOut, firstID, fmt.Sprintf("Expected id %s, got %s for exited filter, output: %q", firstID, containerOut, out))
// filter containers by two labels, but expect not found because of AND behavior
out, _ = dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=label=match=me", "--filter=label=second=tag-no")
containerOut = strings.TrimSpace(out)
- c.Assert(containerOut, checker.Equals, "", check.Commentf("Expected nothing, got %s for exited filter, output: %q", containerOut, out))
+ assert.Equal(c, containerOut, "", fmt.Sprintf("Expected nothing, got %s for exited filter, output: %q", containerOut, out))
// filter containers by exact key
out, _ = dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=label=match")
containerOut = strings.TrimSpace(out)
- c.Assert(containerOut, checker.Contains, firstID)
- c.Assert(containerOut, checker.Contains, secondID)
- c.Assert(containerOut, checker.Not(checker.Contains), thirdID)
+ assert.Assert(c, strings.Contains(containerOut, firstID))
+ assert.Assert(c, strings.Contains(containerOut, secondID))
+ assert.Assert(c, !strings.Contains(containerOut, thirdID))
}
-func (s *DockerSuite) TestPsListContainersFilterExited(c *check.C) {
+func (s *DockerSuite) TestPsListContainersFilterExited(c *testing.T) {
+ // TODO Flaky on Windows CI [both RS1 and RS5]
+ // On slower machines the container may not have exited
+ // yet when we filter below by exit status/exit value.
+ skip.If(c, DaemonIsWindows(), "FLAKY on Windows, see #20819")
runSleepingContainer(c, "--name=sleep")
firstZero, _ := dockerCmd(c, "run", "-d", "busybox", "true")
secondZero, _ := dockerCmd(c, "run", "-d", "busybox", "true")
out, _, err := dockerCmdWithError("run", "--name", "nonzero1", "busybox", "false")
- c.Assert(err, checker.NotNil, check.Commentf("Should fail.", out, err))
+ assert.Assert(c, err != nil, "Should fail. out: %s", out)
firstNonZero := getIDByName(c, "nonzero1")
out, _, err = dockerCmdWithError("run", "--name", "nonzero2", "busybox", "false")
- c.Assert(err, checker.NotNil, check.Commentf("Should fail.", out, err))
+ assert.Assert(c, err != nil, "Should fail. out: %s", out)
secondNonZero := getIDByName(c, "nonzero2")
// filter containers by exited=0
out, _ = dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=exited=0")
- c.Assert(out, checker.Contains, strings.TrimSpace(firstZero))
- c.Assert(out, checker.Contains, strings.TrimSpace(secondZero))
- c.Assert(out, checker.Not(checker.Contains), strings.TrimSpace(firstNonZero))
- c.Assert(out, checker.Not(checker.Contains), strings.TrimSpace(secondNonZero))
-
+ assert.Assert(c, strings.Contains(out, strings.TrimSpace(firstZero)))
+ assert.Assert(c, strings.Contains(out, strings.TrimSpace(secondZero)))
+ assert.Assert(c, !strings.Contains(out, strings.TrimSpace(firstNonZero)))
+ assert.Assert(c, !strings.Contains(out, strings.TrimSpace(secondNonZero)))
out, _ = dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=exited=1")
- c.Assert(out, checker.Contains, strings.TrimSpace(firstNonZero))
- c.Assert(out, checker.Contains, strings.TrimSpace(secondNonZero))
- c.Assert(out, checker.Not(checker.Contains), strings.TrimSpace(firstZero))
- c.Assert(out, checker.Not(checker.Contains), strings.TrimSpace(secondZero))
+ assert.Assert(c, strings.Contains(out, strings.TrimSpace(firstNonZero)))
+ assert.Assert(c, strings.Contains(out, strings.TrimSpace(secondNonZero)))
+ assert.Assert(c, !strings.Contains(out, strings.TrimSpace(firstZero)))
+ assert.Assert(c, !strings.Contains(out, 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
testRequires(c, DaemonIsLinux)
@@ -499,18 +502,18 @@
f := strings.Fields(line)
switch f[0] {
case id1:
- c.Assert(f[1], checker.Equals, "busybox", check.Commentf("Expected %s tag for id %s, got %s", "busybox", id1, f[1]))
+ assert.Equal(c, f[1], "busybox", fmt.Sprintf("Expected %s tag for id %s, got %s", "busybox", id1, f[1]))
case id2:
- c.Assert(f[1], checker.Equals, tag, check.Commentf("Expected %s tag for id %s, got %s", tag, id2, f[1]))
+ assert.Equal(c, f[1], tag, fmt.Sprintf("Expected %s tag for id %s, got %s", tag, id2, f[1]))
case id3:
- c.Assert(f[1], checker.Equals, imageID, check.Commentf("Expected %s imageID for id %s, got %s", tag, id3, f[1]))
+ assert.Equal(c, f[1], imageID, fmt.Sprintf("Expected %s imageID for id %s, got %s", tag, id3, f[1]))
default:
c.Fatalf("Unexpected id %s, expected %s and %s and %s", f[0], id1, id2, id3)
}
}
}
-func (s *DockerSuite) TestPsListContainersFilterCreated(c *check.C) {
+func (s *DockerSuite) TestPsListContainersFilterCreated(c *testing.T) {
// create a container
out, _ := dockerCmd(c, "create", "busybox")
cID := strings.TrimSpace(out)
@@ -518,8 +521,7 @@
// Make sure it DOESN'T show up w/o a '-a' for normal 'ps'
out, _ = dockerCmd(c, "ps", "-q")
- c.Assert(out, checker.Not(checker.Contains), shortCID, check.Commentf("Should have not seen '%s' in ps output:\n%s", shortCID, out))
-
+ assert.Assert(c, !strings.Contains(out, shortCID), "Should have not seen '%s' in ps output:\n%s", shortCID, out)
// Make sure it DOES show up as 'Created' for 'ps -a'
out, _ = dockerCmd(c, "ps", "-a")
@@ -529,10 +531,10 @@
continue
}
hits++
- c.Assert(line, checker.Contains, "Created", check.Commentf("Missing 'Created' on '%s'", line))
+ assert.Assert(c, strings.Contains(line, "Created"), "Missing 'Created' on '%s'", line)
}
- c.Assert(hits, checker.Equals, 1, check.Commentf("Should have seen '%s' in ps -a output once:%d\n%s", shortCID, hits, out))
+ assert.Equal(c, hits, 1, fmt.Sprintf("Should have seen '%s' in ps -a output once:%d\n%s", shortCID, hits, out))
// filter containers by 'create' - note, no -a needed
out, _ = dockerCmd(c, "ps", "-q", "-f", "status=created")
@@ -541,7 +543,7 @@
}
// 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.
testRequires(c, DaemonIsLinux)
originalImageName := "busybox:TestPsImageIDAfterUpdate-original"
@@ -564,11 +566,11 @@
lines = RemoveLinesForExistingElements(lines, existingContainers)
// skip header
lines = lines[1:]
- c.Assert(len(lines), checker.Equals, 1)
+ assert.Equal(c, len(lines), 1)
for _, line := range lines {
f := strings.Fields(line)
- c.Assert(f[1], checker.Equals, originalImageName)
+ assert.Equal(c, f[1], originalImageName)
}
icmd.RunCommand(dockerBinary, "commit", containerID, updatedImageName).Assert(c, icmd.Success)
@@ -581,34 +583,34 @@
lines = RemoveLinesForExistingElements(lines, existingContainers)
// skip header
lines = lines[1:]
- c.Assert(len(lines), checker.Equals, 1)
+ assert.Equal(c, len(lines), 1)
for _, line := range lines {
f := strings.Fields(line)
- c.Assert(f[1], checker.Equals, originalImageID)
+ assert.Equal(c, f[1], originalImageID)
}
}
-func (s *DockerSuite) TestPsNotShowPortsOfStoppedContainer(c *check.C) {
+func (s *DockerSuite) TestPsNotShowPortsOfStoppedContainer(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "--name=foo", "-d", "-p", "5000:5000", "busybox", "top")
- c.Assert(waitRun("foo"), checker.IsNil)
+ assert.Assert(c, waitRun("foo") == nil)
out, _ := dockerCmd(c, "ps")
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
expected := "0.0.0.0:5000->5000/tcp"
fields := strings.Fields(lines[1])
- c.Assert(fields[len(fields)-2], checker.Equals, expected, check.Commentf("Expected: %v, got: %v", expected, fields[len(fields)-2]))
+ assert.Equal(c, fields[len(fields)-2], expected, fmt.Sprintf("Expected: %v, got: %v", expected, fields[len(fields)-2]))
dockerCmd(c, "kill", "foo")
dockerCmd(c, "wait", "foo")
out, _ = dockerCmd(c, "ps", "-l")
lines = strings.Split(strings.TrimSpace(string(out)), "\n")
fields = strings.Fields(lines[1])
- c.Assert(fields[len(fields)-2], checker.Not(checker.Equals), expected, check.Commentf("Should not got %v", expected))
+ assert.Assert(c, fields[len(fields)-2] != expected, "Should not got %v", expected)
}
-func (s *DockerSuite) TestPsShowMounts(c *check.C) {
+func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
existingContainers := ExistingContainerNames(c)
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
@@ -618,9 +620,9 @@
dockerCmd(c, "volume", "create", "ps-volume-test")
// volume mount containers
runSleepingContainer(c, "--name=volume-test-1", "--volume", "ps-volume-test:"+mp)
- c.Assert(waitRun("volume-test-1"), checker.IsNil)
+ assert.Assert(c, waitRun("volume-test-1") == nil)
runSleepingContainer(c, "--name=volume-test-2", "--volume", mp)
- c.Assert(waitRun("volume-test-2"), checker.IsNil)
+ assert.Assert(c, waitRun("volume-test-2") == nil)
// bind mount container
var bindMountSource string
var bindMountDestination string
@@ -632,7 +634,7 @@
bindMountDestination = "/t"
}
runSleepingContainer(c, "--name=bind-mount-test", "-v", bindMountSource+":"+bindMountDestination)
- c.Assert(waitRun("bind-mount-test"), checker.IsNil)
+ assert.Assert(c, waitRun("bind-mount-test") == nil)
out, _ := dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}")
@@ -642,8 +644,8 @@
fields := strings.Fields(lines[0])
assert.Equal(c, len(fields), 2)
- c.Assert(fields[0], checker.Equals, "bind-mount-test")
- c.Assert(fields[1], checker.Equals, bindMountSource)
+ assert.Equal(c, fields[0], "bind-mount-test")
+ assert.Equal(c, fields[1], bindMountSource)
fields = strings.Fields(lines[1])
assert.Equal(c, len(fields), 2)
@@ -651,7 +653,7 @@
anonymousVolumeID := fields[1]
fields = strings.Fields(lines[2])
- c.Assert(fields[1], checker.Equals, "ps-volume-test")
+ assert.Equal(c, fields[1], "ps-volume-test")
// filter by volume name
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume=ps-volume-test")
@@ -661,11 +663,11 @@
assert.Equal(c, len(lines), 1)
fields = strings.Fields(lines[0])
- c.Assert(fields[1], checker.Equals, "ps-volume-test")
+ assert.Equal(c, fields[1], "ps-volume-test")
// empty results filtering by unknown volume
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume=this-volume-should-not-exist")
- c.Assert(strings.TrimSpace(string(out)), checker.HasLen, 0)
+ assert.Equal(c, len(strings.TrimSpace(string(out))), 0)
// filter by mount destination
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+mp)
@@ -675,9 +677,9 @@
assert.Equal(c, len(lines), 2)
fields = strings.Fields(lines[0])
- c.Assert(fields[1], checker.Equals, anonymousVolumeID)
+ assert.Equal(c, fields[1], anonymousVolumeID)
fields = strings.Fields(lines[1])
- c.Assert(fields[1], checker.Equals, "ps-volume-test")
+ assert.Equal(c, fields[1], "ps-volume-test")
// filter by bind mount source
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+bindMountSource)
@@ -688,8 +690,8 @@
fields = strings.Fields(lines[0])
assert.Equal(c, len(fields), 2)
- c.Assert(fields[0], checker.Equals, "bind-mount-test")
- c.Assert(fields[1], checker.Equals, bindMountSource)
+ assert.Equal(c, fields[0], "bind-mount-test")
+ assert.Equal(c, fields[1], bindMountSource)
// filter by bind mount destination
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+bindMountDestination)
@@ -700,15 +702,15 @@
fields = strings.Fields(lines[0])
assert.Equal(c, len(fields), 2)
- c.Assert(fields[0], checker.Equals, "bind-mount-test")
- c.Assert(fields[1], checker.Equals, bindMountSource)
+ assert.Equal(c, fields[0], "bind-mount-test")
+ assert.Equal(c, fields[1], bindMountSource)
// empty results filtering by unknown mount point
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+prefix+slash+"this-path-was-never-mounted")
- c.Assert(strings.TrimSpace(string(out)), checker.HasLen, 0)
+ assert.Equal(c, len(strings.TrimSpace(string(out))), 0)
}
-func (s *DockerSuite) TestPsListContainersFilterNetwork(c *check.C) {
+func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
existing := ExistingContainerIDs(c)
// TODO default network on Windows is not called "bridge", and creating a
@@ -743,8 +745,7 @@
assert.Equal(c, len(RemoveLinesForExistingElements(lines, existing)), 1)
// Making sure onbridgenetwork is on the output
- c.Assert(containerOut, checker.Contains, "onbridgenetwork", check.Commentf("Missing the container on network\n"))
-
+ assert.Assert(c, strings.Contains(containerOut, "onbridgenetwork"), "Missing the container on network\n")
// Filter docker ps on networks bridge and none
out, _ = dockerCmd(c, "ps", "--filter", "network=bridge", "--filter", "network=none")
containerOut = strings.TrimSpace(string(out))
@@ -758,9 +759,8 @@
assert.Equal(c, len(RemoveLinesForExistingElements(lines, existing)), 2)
// Making sure onbridgenetwork and onnonenetwork is on the output
- c.Assert(containerOut, checker.Contains, "onnonenetwork", check.Commentf("Missing the container on none network\n"))
- c.Assert(containerOut, checker.Contains, "onbridgenetwork", check.Commentf("Missing the container on bridge network\n"))
-
+ assert.Assert(c, strings.Contains(containerOut, "onnonenetwork"), "Missing the container on none network\n")
+ assert.Assert(c, strings.Contains(containerOut, "onbridgenetwork"), "Missing the container on bridge network\n")
nwID, _ := dockerCmd(c, "network", "inspect", "--format", "{{.ID}}", "bridge")
// Filter by network ID
@@ -784,11 +784,10 @@
assert.Equal(c, len(RemoveLinesForExistingElements(lines, existing)), 1)
// Making sure onbridgenetwork is on the output
- c.Assert(containerOut, checker.Contains, "onbridgenetwork", check.Commentf("Missing the container on network\n"))
-
+ assert.Assert(c, strings.Contains(containerOut, "onbridgenetwork"), "Missing the container on network\n")
}
-func (s *DockerSuite) TestPsByOrder(c *check.C) {
+func (s *DockerSuite) TestPsByOrder(c *testing.T) {
out := runSleepingContainer(c, "--name", "xyz-abc")
container1 := strings.TrimSpace(out)
@@ -807,7 +806,7 @@
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)
existingContainers := ExistingContainerIDs(c)
@@ -818,32 +817,31 @@
id2 := strings.TrimSpace(out)
out, _ = dockerCmd(c, "ps", "--no-trunc", "-q")
- c.Assert(strings.TrimSpace(out), checker.Contains, id1)
- c.Assert(strings.TrimSpace(out), checker.Contains, id2)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id1))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
out, _ = dockerCmd(c, "ps", "--no-trunc", "-q", "--filter", "publish=80-8080/udp")
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), id1)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), id2)
+ assert.Assert(c, strings.TrimSpace(out) != id1)
+ assert.Assert(c, strings.TrimSpace(out) != id2)
out, _ = dockerCmd(c, "ps", "--no-trunc", "-q", "--filter", "expose=8081")
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), id1)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), id2)
+ assert.Assert(c, strings.TrimSpace(out) != id1)
+ assert.Assert(c, strings.TrimSpace(out) != id2)
out, _ = dockerCmd(c, "ps", "--no-trunc", "-q", "--filter", "publish=80-81")
assert.Equal(c, strings.TrimSpace(out), id1)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), id2)
+ assert.Assert(c, strings.TrimSpace(out) != id2)
out, _ = dockerCmd(c, "ps", "--no-trunc", "-q", "--filter", "expose=80/tcp")
assert.Equal(c, strings.TrimSpace(out), id1)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), id2)
+ assert.Assert(c, strings.TrimSpace(out) != id2)
out, _ = dockerCmd(c, "ps", "--no-trunc", "-q", "--filter", "expose=8080/tcp")
out = RemoveOutputForExistingElements(out, existingContainers)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), id1)
+ assert.Assert(c, strings.TrimSpace(out) != id1)
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"))
existingContainers := ExistingContainerNames(c)
diff --git a/integration-cli/docker_cli_pull_local_test.go b/integration-cli/docker_cli_pull_local_test.go
index b6b774e..94df86d 100644
--- a/integration-cli/docker_cli_pull_local_test.go
+++ b/integration-cli/docker_cli_pull_local_test.go
@@ -8,14 +8,13 @@
"path/filepath"
"runtime"
"strings"
+ "testing"
"github.com/docker/distribution"
"github.com/docker/distribution/manifest"
"github.com/docker/distribution/manifest/manifestlist"
"github.com/docker/distribution/manifest/schema2"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli/build"
- "github.com/go-check/check"
"github.com/opencontainers/go-digest"
"gotest.tools/assert"
"gotest.tools/icmd"
@@ -25,7 +24,7 @@
// tags for the same image) are not also pulled down.
//
// Ref: docker/docker#8141
-func testPullImageWithAliases(c *check.C) {
+func testPullImageWithAliases(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
var repos []string
@@ -52,16 +51,16 @@
}
}
-func (s *DockerRegistrySuite) TestPullImageWithAliases(c *check.C) {
+func (s *DockerRegistrySuite) TestPullImageWithAliases(c *testing.T) {
testPullImageWithAliases(c)
}
-func (s *DockerSchema1RegistrySuite) TestPullImageWithAliases(c *check.C) {
+func (s *DockerSchema1RegistrySuite) TestPullImageWithAliases(c *testing.T) {
testPullImageWithAliases(c)
}
// testConcurrentPullWholeRepo pulls the same repo concurrently.
-func testConcurrentPullWholeRepo(c *check.C) {
+func testConcurrentPullWholeRepo(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
var repos []string
@@ -108,16 +107,16 @@
}
}
-func (s *DockerRegistrySuite) testConcurrentPullWholeRepo(c *check.C) {
+func (s *DockerRegistrySuite) testConcurrentPullWholeRepo(c *testing.T) {
testConcurrentPullWholeRepo(c)
}
-func (s *DockerSchema1RegistrySuite) testConcurrentPullWholeRepo(c *check.C) {
+func (s *DockerSchema1RegistrySuite) testConcurrentPullWholeRepo(c *testing.T) {
testConcurrentPullWholeRepo(c)
}
// 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)
// Run multiple pulls concurrently
@@ -139,17 +138,17 @@
}
}
-func (s *DockerRegistrySuite) testConcurrentFailingPull(c *check.C) {
+func (s *DockerRegistrySuite) testConcurrentFailingPull(c *testing.T) {
testConcurrentFailingPull(c)
}
-func (s *DockerSchema1RegistrySuite) testConcurrentFailingPull(c *check.C) {
+func (s *DockerSchema1RegistrySuite) testConcurrentFailingPull(c *testing.T) {
testConcurrentFailingPull(c)
}
// testConcurrentPullMultipleTags pulls multiple tags from the same repo
// concurrently.
-func testConcurrentPullMultipleTags(c *check.C) {
+func testConcurrentPullMultipleTags(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
var repos []string
@@ -195,17 +194,17 @@
}
}
-func (s *DockerRegistrySuite) TestConcurrentPullMultipleTags(c *check.C) {
+func (s *DockerRegistrySuite) TestConcurrentPullMultipleTags(c *testing.T) {
testConcurrentPullMultipleTags(c)
}
-func (s *DockerSchema1RegistrySuite) TestConcurrentPullMultipleTags(c *check.C) {
+func (s *DockerSchema1RegistrySuite) TestConcurrentPullMultipleTags(c *testing.T) {
testConcurrentPullMultipleTags(c)
}
// testPullIDStability verifies that pushing an image and pulling it back
// preserves the image ID.
-func testPullIDStability(c *check.C) {
+func testPullIDStability(c *testing.T) {
derivedImage := privateRegistryURL + "/dockercli/id-stability"
baseImage := "busybox"
@@ -256,16 +255,16 @@
}
}
-func (s *DockerRegistrySuite) TestPullIDStability(c *check.C) {
+func (s *DockerRegistrySuite) TestPullIDStability(c *testing.T) {
testPullIDStability(c)
}
-func (s *DockerSchema1RegistrySuite) TestPullIDStability(c *check.C) {
+func (s *DockerSchema1RegistrySuite) TestPullIDStability(c *testing.T) {
testPullIDStability(c)
}
// #21213
-func testPullNoLayers(c *check.C) {
+func testPullNoLayers(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/scratch", privateRegistryURL)
buildImageSuccessfully(c, repoName, build.WithDockerfile(`
@@ -276,15 +275,15 @@
dockerCmd(c, "pull", repoName)
}
-func (s *DockerRegistrySuite) TestPullNoLayers(c *check.C) {
+func (s *DockerRegistrySuite) TestPullNoLayers(c *testing.T) {
testPullNoLayers(c)
}
-func (s *DockerSchema1RegistrySuite) TestPullNoLayers(c *check.C) {
+func (s *DockerSchema1RegistrySuite) TestPullNoLayers(c *testing.T) {
testPullNoLayers(c)
}
-func (s *DockerRegistrySuite) TestPullManifestList(c *check.C) {
+func (s *DockerRegistrySuite) TestPullManifestList(c *testing.T) {
testRequires(c, NotArm)
pushDigest, err := setupImage(c)
assert.NilError(c, err, "error setting up image")
@@ -340,10 +339,10 @@
// Add to revision store
revisionDir := filepath.Join(registryV2Path, "repositories", remoteRepoName, "_manifests", "revisions", "sha256", hexDigest)
err = os.Mkdir(revisionDir, 0755)
- c.Assert(err, checker.IsNil, check.Commentf("error creating revision dir"))
+ assert.Assert(c, err == nil, "error creating revision dir")
revisionPath := filepath.Join(revisionDir, "link")
err = ioutil.WriteFile(revisionPath, []byte(manifestListDigest.String()), 0644)
- c.Assert(err, checker.IsNil, check.Commentf("error writing revision link"))
+ assert.Assert(c, err == nil, "error writing revision link")
// Update tag
tagPath := filepath.Join(registryV2Path, "repositories", remoteRepoName, "_manifests", "tags", "latest", "current", "link")
@@ -355,7 +354,7 @@
// The pull output includes "Digest: <digest>", so find that
matches := digestRegex.FindStringSubmatch(out)
- c.Assert(matches, checker.HasLen, 2, check.Commentf("unable to parse digest from pull output: %s", out))
+ assert.Equal(c, len(matches), 2, fmt.Sprintf("unable to parse digest from pull output: %s", out))
pullDigest := matches[1]
// Make sure the pushed and pull digests match
@@ -368,7 +367,7 @@
}
// #23100
-func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuthLoginWithScheme(c *check.C) {
+func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuthLoginWithScheme(c *testing.T) {
osPath := os.Getenv("PATH")
defer os.Setenv("PATH", osPath)
@@ -395,8 +394,7 @@
b, err := ioutil.ReadFile(configPath)
assert.NilError(c, err)
- c.Assert(string(b), checker.Not(checker.Contains), "\"auth\":")
-
+ assert.Assert(c, !strings.Contains(string(b), "\"auth\":"))
dockerCmd(c, "--config", tmp, "tag", "busybox", repoName)
dockerCmd(c, "--config", tmp, "push", repoName)
@@ -413,7 +411,7 @@
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")
defer os.Setenv("PATH", osPath)
@@ -440,8 +438,7 @@
b, err := ioutil.ReadFile(configPath)
assert.NilError(c, err)
- c.Assert(string(b), checker.Not(checker.Contains), "\"auth\":")
-
+ assert.Assert(c, !strings.Contains(string(b), "\"auth\":"))
dockerCmd(c, "--config", tmp, "tag", "busybox", repoName)
dockerCmd(c, "--config", tmp, "push", repoName)
@@ -449,7 +446,7 @@
}
// 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)
repo := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
repoTag1 := fmt.Sprintf("%v:latest", repo)
@@ -462,10 +459,9 @@
dockerCmd(c, "rmi", repoTag2)
out, _ := dockerCmd(c, "run", repo)
- c.Assert(out, checker.Contains, fmt.Sprintf("Unable to find image '%s:latest' locally", repo))
-
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf("Unable to find image '%s:latest' locally", repo)))
// There should be only one line for repo, the one with repo:latest
outImageCmd, _ := dockerCmd(c, "images", repo)
splitOutImageCmd := strings.Split(strings.TrimSpace(outImageCmd), "\n")
- c.Assert(splitOutImageCmd, checker.HasLen, 2)
+ assert.Equal(c, len(splitOutImageCmd), 2)
}
diff --git a/integration-cli/docker_cli_pull_test.go b/integration-cli/docker_cli_pull_test.go
index 8526a10..81f5b1f 100644
--- a/integration-cli/docker_cli_pull_test.go
+++ b/integration-cli/docker_cli_pull_test.go
@@ -5,9 +5,9 @@
"regexp"
"strings"
"sync"
+ "testing"
"time"
- "github.com/go-check/check"
"github.com/opencontainers/go-digest"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
@@ -15,7 +15,7 @@
// TestPullFromCentralRegistry pulls an image from the central registry and verifies that the client
// prints all expected output.
-func (s *DockerHubPullSuite) TestPullFromCentralRegistry(c *check.C) {
+func (s *DockerHubPullSuite) TestPullFromCentralRegistry(c *testing.T) {
testRequires(c, DaemonIsLinux)
out := s.Cmd(c, "pull", "hello-world")
defer deleteImages("hello-world")
@@ -40,7 +40,7 @@
// TestPullNonExistingImage pulls non-existing images from the central registry, with different
// combinations of implicit tag and library prefix.
-func (s *DockerHubPullSuite) TestPullNonExistingImage(c *check.C) {
+func (s *DockerHubPullSuite) TestPullNonExistingImage(c *testing.T) {
testRequires(c, DaemonIsLinux)
type entry struct {
@@ -115,7 +115,7 @@
// 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
// multiple images.
-func (s *DockerHubPullSuite) TestPullFromCentralRegistryImplicitRefParts(c *check.C) {
+func (s *DockerHubPullSuite) TestPullFromCentralRegistryImplicitRefParts(c *testing.T) {
testRequires(c, DaemonIsLinux)
// Pull hello-world from v2
@@ -184,7 +184,7 @@
}
// TestPullScratchNotAllowed verifies that pulling 'scratch' is rejected.
-func (s *DockerHubPullSuite) TestPullScratchNotAllowed(c *check.C) {
+func (s *DockerHubPullSuite) TestPullScratchNotAllowed(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, err := s.CmdWithError("pull", "scratch")
assert.ErrorContains(c, err, "", "expected pull of scratch to fail")
@@ -194,7 +194,7 @@
// TestPullAllTagsFromCentralRegistry pulls using `all-tags` for a given image and verifies that it
// 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)
s.Cmd(c, "pull", "dockercore/engine-pull-all-test-fixture")
outImageCmd := s.Cmd(c, "images", "dockercore/engine-pull-all-test-fixture")
@@ -238,7 +238,7 @@
// gets cancelled.
//
// Ref: docker/docker#15589
-func (s *DockerHubPullSuite) TestPullClientDisconnect(c *check.C) {
+func (s *DockerHubPullSuite) TestPullClientDisconnect(c *testing.T) {
testRequires(c, DaemonIsLinux)
repoName := "hello-world:latest"
@@ -263,14 +263,14 @@
}
// 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)
_, _, err := dockerCmdWithError("pull", "ubuntu")
assert.ErrorContains(c, err, "no matching manifest for windows")
}
// 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)
_, _, err := dockerCmdWithError("pull", "mcr.microsoft.com/windows/servercore:ltsc2019")
assert.ErrorContains(c, err, "no matching manifest for linux")
diff --git a/integration-cli/docker_cli_push_test.go b/integration-cli/docker_cli_push_test.go
index 60d5811..53369c2 100644
--- a/integration-cli/docker_cli_push_test.go
+++ b/integration-cli/docker_cli_push_test.go
@@ -9,16 +9,16 @@
"os"
"strings"
"sync"
+ "testing"
"github.com/docker/distribution/reference"
"github.com/docker/docker/integration-cli/cli/build"
- "github.com/go-check/check"
"gotest.tools/assert"
"gotest.tools/icmd"
)
// Pushing an image to a private registry.
-func testPushBusyboxImage(c *check.C) {
+func testPushBusyboxImage(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
// tag the image to upload it to the private registry
dockerCmd(c, "tag", "busybox", repoName)
@@ -26,21 +26,21 @@
dockerCmd(c, "push", repoName)
}
-func (s *DockerRegistrySuite) TestPushBusyboxImage(c *check.C) {
+func (s *DockerRegistrySuite) TestPushBusyboxImage(c *testing.T) {
testPushBusyboxImage(c)
}
-func (s *DockerSchema1RegistrySuite) TestPushBusyboxImage(c *check.C) {
+func (s *DockerSchema1RegistrySuite) TestPushBusyboxImage(c *testing.T) {
testPushBusyboxImage(c)
}
// 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")
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)
expected := "An image does not exist locally with the tag"
@@ -49,15 +49,15 @@
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)
}
-func (s *DockerSchema1RegistrySuite) TestPushUntagged(c *check.C) {
+func (s *DockerSchema1RegistrySuite) TestPushUntagged(c *testing.T) {
testPushUntagged(c)
}
-func testPushBadTag(c *check.C) {
+func testPushBadTag(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/busybox:latest", privateRegistryURL)
expected := "does not exist"
@@ -66,15 +66,15 @@
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)
}
-func (s *DockerSchema1RegistrySuite) TestPushBadTag(c *check.C) {
+func (s *DockerSchema1RegistrySuite) TestPushBadTag(c *testing.T) {
testPushBadTag(c)
}
-func testPushMultipleTags(c *check.C) {
+func testPushMultipleTags(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
repoTag1 := fmt.Sprintf("%v/dockercli/busybox:t1", privateRegistryURL)
repoTag2 := fmt.Sprintf("%v/dockercli/busybox:t2", privateRegistryURL)
@@ -111,15 +111,15 @@
}
}
-func (s *DockerRegistrySuite) TestPushMultipleTags(c *check.C) {
+func (s *DockerRegistrySuite) TestPushMultipleTags(c *testing.T) {
testPushMultipleTags(c)
}
-func (s *DockerSchema1RegistrySuite) TestPushMultipleTags(c *check.C) {
+func (s *DockerSchema1RegistrySuite) TestPushMultipleTags(c *testing.T) {
testPushMultipleTags(c)
}
-func testPushEmptyLayer(c *check.C) {
+func testPushEmptyLayer(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/emptylayer", privateRegistryURL)
emptyTarball, err := ioutil.TempFile("", "empty_tarball")
assert.NilError(c, err, "Unable to create test file")
@@ -142,17 +142,17 @@
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)
}
-func (s *DockerSchema1RegistrySuite) TestPushEmptyLayer(c *check.C) {
+func (s *DockerSchema1RegistrySuite) TestPushEmptyLayer(c *testing.T) {
testPushEmptyLayer(c)
}
// testConcurrentPush pushes multiple tags to the same repo
// concurrently.
-func testConcurrentPush(c *check.C) {
+func testConcurrentPush(c *testing.T) {
repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
var repos []string
@@ -196,15 +196,15 @@
}
}
-func (s *DockerRegistrySuite) TestConcurrentPush(c *check.C) {
+func (s *DockerRegistrySuite) TestConcurrentPush(c *testing.T) {
testConcurrentPush(c)
}
-func (s *DockerSchema1RegistrySuite) TestConcurrentPush(c *check.C) {
+func (s *DockerSchema1RegistrySuite) TestConcurrentPush(c *testing.T) {
testConcurrentPush(c)
}
-func (s *DockerRegistrySuite) TestCrossRepositoryLayerPush(c *check.C) {
+func (s *DockerRegistrySuite) TestCrossRepositoryLayerPush(c *testing.T) {
sourceRepoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
// tag the image to upload it to the private registry
dockerCmd(c, "tag", "busybox", sourceRepoName)
@@ -246,7 +246,7 @@
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)
// tag the image to upload it to the private registry
dockerCmd(c, "tag", "busybox", sourceRepoName)
@@ -279,7 +279,7 @@
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)
dockerCmd(c, "tag", "busybox", repoName)
out, _, err := dockerCmdWithError("push", repoName)
@@ -289,7 +289,7 @@
}
// 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)
repoName := "test/busybox"
dockerCmd(c, "tag", "busybox", repoName)
@@ -316,7 +316,7 @@
}))
}
-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)
defer ts.Close()
s.setupRegistryWithTokenService(c, ts.URL)
@@ -328,7 +328,7 @@
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)
defer ts.Close()
s.setupRegistryWithTokenService(c, ts.URL)
@@ -341,7 +341,7 @@
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)
defer ts.Close()
s.setupRegistryWithTokenService(c, ts.URL)
@@ -356,7 +356,7 @@
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)
defer ts.Close()
s.setupRegistryWithTokenService(c, ts.URL)
@@ -369,7 +369,7 @@
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)
defer ts.Close()
s.setupRegistryWithTokenService(c, ts.URL)
diff --git a/integration-cli/docker_cli_registry_user_agent_test.go b/integration-cli/docker_cli_registry_user_agent_test.go
index 90f7c8e..c03fcb0 100644
--- a/integration-cli/docker_cli_registry_user_agent_test.go
+++ b/integration-cli/docker_cli_registry_user_agent_test.go
@@ -6,9 +6,9 @@
"net/http"
"os"
"regexp"
+ "testing"
"github.com/docker/docker/internal/test/registry"
- "github.com/go-check/check"
"gotest.tools/assert"
)
@@ -29,7 +29,7 @@
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>.+)")
substrArr := re.FindStringSubmatch(ua)
@@ -71,7 +71,7 @@
// TestUserAgentPassThrough verifies that when an image is pulled from
// a registry, the registry should see a User-Agent string of the form
// [docker engine UA] UpstreamClientSTREAM-CLIENT([client UA])
-func (s *DockerRegistrySuite) TestUserAgentPassThrough(c *check.C) {
+func (s *DockerRegistrySuite) TestUserAgentPassThrough(c *testing.T) {
var ua string
reg, err := registry.NewMock(c)
diff --git a/integration-cli/docker_cli_restart_test.go b/integration-cli/docker_cli_restart_test.go
index f6c41d5..9e1d99d 100644
--- a/integration-cli/docker_cli_restart_test.go
+++ b/integration-cli/docker_cli_restart_test.go
@@ -4,15 +4,16 @@
"os"
"strconv"
"strings"
+ "testing"
"time"
"github.com/docker/docker/integration-cli/checker"
- "github.com/go-check/check"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
+ "gotest.tools/poll"
)
-func (s *DockerSuite) TestRestartStoppedContainer(c *check.C) {
+func (s *DockerSuite) TestRestartStoppedContainer(c *testing.T) {
dockerCmd(c, "run", "--name=test", "busybox", "echo", "foobar")
cleanedContainerID := getIDByName(c, "test")
@@ -29,30 +30,30 @@
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'")
cleanedContainerID := strings.TrimSpace(out)
assert.NilError(c, waitRun(cleanedContainerID))
- getLogs := func(c *check.C) (interface{}, check.CommentInterface) {
+ getLogs := func(c *testing.T) (interface{}, string) {
out, _ := dockerCmd(c, "logs", cleanedContainerID)
- return out, nil
+ return out, ""
}
// Wait 10 seconds for the 'echo' to appear in the logs
- waitAndAssert(c, 10*time.Second, getLogs, checker.Equals, "foobar\n")
+ poll.WaitOn(c, pollCheck(c, getLogs, checker.Equals("foobar\n")), poll.WithTimeout(10*time.Second))
dockerCmd(c, "restart", "-t", "1", cleanedContainerID)
assert.NilError(c, waitRun(cleanedContainerID))
// Wait 10 seconds for first 'echo' appear (again) in the logs
- waitAndAssert(c, 10*time.Second, getLogs, checker.Equals, "foobar\nfoobar\n")
+ poll.WaitOn(c, pollCheck(c, getLogs, checker.Equals("foobar\nfoobar\n")), poll.WithTimeout(10*time.Second))
}
// 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()
out := runSleepingContainer(c, "-d", "-v", prefix+slash+"test")
@@ -77,7 +78,7 @@
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)
// Run a container on the default bridge network
@@ -94,7 +95,7 @@
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")
id := strings.TrimSpace(string(out))
@@ -102,7 +103,7 @@
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")
id := strings.TrimSpace(string(out))
@@ -115,7 +116,7 @@
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")
assert.ErrorContains(c, err, "", out)
assert.Assert(c, strings.Contains(out, "maximum retry count cannot be negative"))
@@ -150,7 +151,7 @@
// a good container with --restart=on-failure:3
// 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")
id := strings.TrimSpace(string(out))
@@ -164,11 +165,14 @@
assert.Equal(c, MaximumRetryCount, "3")
}
-func (s *DockerSuite) TestRestartContainerSuccess(c *check.C) {
+func (s *DockerSuite) TestRestartContainerSuccess(c *testing.T) {
+ testRequires(c, testEnv.IsLocalDaemon)
// Skipped for Hyper-V isolated containers. Test is currently written
// 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.
- testRequires(c, testEnv.IsLocalDaemon, IsolationIsProcess)
+ if DaemonIsWindows() {
+ testRequires(c, IsolationIsProcess)
+ }
out := runSleepingContainer(c, "-d", "--restart=always")
id := strings.TrimSpace(out)
@@ -193,7 +197,7 @@
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.
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon, NotUserNamespace, NotArm)
dockerCmd(c, "network", "create", "-d", "bridge", "udNet")
@@ -237,11 +241,14 @@
assert.NilError(c, err)
}
-func (s *DockerSuite) TestRestartPolicyAfterRestart(c *check.C) {
+func (s *DockerSuite) TestRestartPolicyAfterRestart(c *testing.T) {
+ testRequires(c, testEnv.IsLocalDaemon)
// Skipped for Hyper-V isolated containers. Test is currently written
// 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.
- testRequires(c, testEnv.IsLocalDaemon, IsolationIsProcess)
+ if DaemonIsWindows() {
+ testRequires(c, IsolationIsProcess)
+ }
out := runSleepingContainer(c, "-d", "--restart=always")
id := strings.TrimSpace(out)
@@ -270,7 +277,7 @@
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")
out2, _ := dockerCmd(c, "run", "-d", "--restart=always", "busybox", "false")
@@ -301,7 +308,7 @@
assert.NilError(c, err)
}
-func (s *DockerSuite) TestRestartAutoRemoveContainer(c *check.C) {
+func (s *DockerSuite) TestRestartAutoRemoveContainer(c *testing.T) {
out := runSleepingContainer(c, "--rm")
id := strings.TrimSpace(string(out))
diff --git a/integration-cli/docker_cli_rmi_test.go b/integration-cli/docker_cli_rmi_test.go
index d1445cf..f118289 100644
--- a/integration-cli/docker_cli_rmi_test.go
+++ b/integration-cli/docker_cli_rmi_test.go
@@ -3,18 +3,17 @@
import (
"fmt"
"strings"
+ "testing"
"time"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/pkg/stringid"
- "github.com/go-check/check"
"gotest.tools/assert"
"gotest.tools/icmd"
)
-func (s *DockerSuite) TestRmiWithContainerFails(c *check.C) {
+func (s *DockerSuite) TestRmiWithContainerFails(c *testing.T) {
errSubstr := "is using it"
// create a container
@@ -27,43 +26,42 @@
// Container is using image, should not be able to rmi
assert.ErrorContains(c, err, "")
// Container is using image, error message should contain errSubstr
- c.Assert(out, checker.Contains, errSubstr, check.Commentf("Container: %q", cleanedContainerID))
-
+ assert.Assert(c, strings.Contains(out, errSubstr), "Container: %q", cleanedContainerID)
// make sure it didn't delete the busybox name
images, _ := dockerCmd(c, "images")
// The name 'busybox' should not have been removed from images
- c.Assert(images, checker.Contains, "busybox")
+ assert.Assert(c, strings.Contains(images, "busybox"))
}
-func (s *DockerSuite) TestRmiTag(c *check.C) {
+func (s *DockerSuite) TestRmiTag(c *testing.T) {
imagesBefore, _ := dockerCmd(c, "images", "-a")
dockerCmd(c, "tag", "busybox", "utest:tag1")
dockerCmd(c, "tag", "busybox", "utest/docker:tag2")
dockerCmd(c, "tag", "busybox", "utest:5000/docker:tag3")
{
imagesAfter, _ := dockerCmd(c, "images", "-a")
- c.Assert(strings.Count(imagesAfter, "\n"), checker.Equals, strings.Count(imagesBefore, "\n")+3, check.Commentf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
+ assert.Equal(c, strings.Count(imagesAfter, "\n"), strings.Count(imagesBefore, "\n")+3, fmt.Sprintf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
}
dockerCmd(c, "rmi", "utest/docker:tag2")
{
imagesAfter, _ := dockerCmd(c, "images", "-a")
- c.Assert(strings.Count(imagesAfter, "\n"), checker.Equals, strings.Count(imagesBefore, "\n")+2, check.Commentf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
+ assert.Equal(c, strings.Count(imagesAfter, "\n"), strings.Count(imagesBefore, "\n")+2, fmt.Sprintf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
}
dockerCmd(c, "rmi", "utest:5000/docker:tag3")
{
imagesAfter, _ := dockerCmd(c, "images", "-a")
- c.Assert(strings.Count(imagesAfter, "\n"), checker.Equals, strings.Count(imagesBefore, "\n")+1, check.Commentf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
+ assert.Equal(c, strings.Count(imagesAfter, "\n"), strings.Count(imagesBefore, "\n")+1, fmt.Sprintf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
}
dockerCmd(c, "rmi", "utest:tag1")
{
imagesAfter, _ := dockerCmd(c, "images", "-a")
- c.Assert(strings.Count(imagesAfter, "\n"), checker.Equals, strings.Count(imagesBefore, "\n"), check.Commentf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
+ assert.Equal(c, strings.Count(imagesAfter, "\n"), strings.Count(imagesBefore, "\n"), fmt.Sprintf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
}
}
-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()
containerID := strings.TrimSpace(out)
@@ -81,7 +79,7 @@
imagesAfter := cli.DockerCmd(c, "images", "-a").Combined()
// tag busybox to create 2 more images with same imageID
- c.Assert(strings.Count(imagesAfter, "\n"), checker.Equals, strings.Count(imagesBefore, "\n")+2, check.Commentf("docker images shows: %q\n", imagesAfter))
+ assert.Equal(c, strings.Count(imagesAfter, "\n"), strings.Count(imagesBefore, "\n")+2, fmt.Sprintf("docker images shows: %q\n", imagesAfter))
imgID := inspectField(c, "busybox-one:tag1", "Id")
@@ -101,10 +99,10 @@
imagesAfter = cli.DockerCmd(c, "images", "-a").Combined()
// rmi -f failed, image still exists
- c.Assert(imagesAfter, checker.Not(checker.Contains), imgID[:12], check.Commentf("ImageID:%q; ImagesAfter: %q", imgID, imagesAfter))
+ assert.Assert(c, !strings.Contains(imagesAfter, imgID[:12]), "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()
containerID := strings.TrimSpace(out)
@@ -123,7 +121,7 @@
cli.DockerCmd(c, "tag", "busybox-test", "utest:5000/docker:tag4")
{
imagesAfter := cli.DockerCmd(c, "images", "-a").Combined()
- c.Assert(strings.Count(imagesAfter, "\n"), checker.Equals, strings.Count(imagesBefore, "\n")+4, check.Commentf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
+ assert.Equal(c, strings.Count(imagesAfter, "\n"), strings.Count(imagesBefore, "\n")+4, fmt.Sprintf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter))
}
imgID := inspectField(c, "busybox-test", "Id")
@@ -137,12 +135,12 @@
{
imagesAfter := cli.DockerCmd(c, "images", "-a").Combined()
// rmi failed, image still exists
- c.Assert(imagesAfter, checker.Not(checker.Contains), imgID[:12])
+ assert.Assert(c, !strings.Contains(imagesAfter, imgID[:12]))
}
}
// 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"
buildImageSuccessfully(c, "test-14116", build.WithDockerfile(dockerfile))
imgID := getIDByName(c, "test-14116")
@@ -154,10 +152,10 @@
out, _, err := dockerCmdWithError("rmi", "-f", imgID)
// rmi -f should not delete image with running containers
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "(cannot be forced) - image is being used by running container")
+ assert.Assert(c, strings.Contains(out, "(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"
newtag := "busybox:newtag"
bb := "busybox:latest"
@@ -166,10 +164,10 @@
dockerCmd(c, "run", "--name", container, bb, "/bin/true")
out, _ := dockerCmd(c, "rmi", newtag)
- c.Assert(strings.Count(out, "Untagged: "), checker.Equals, 1)
+ assert.Equal(c, strings.Count(out, "Untagged: "), 1)
}
-func (s *DockerSuite) TestRmiForceWithExistingContainers(c *check.C) {
+func (s *DockerSuite) TestRmiForceWithExistingContainers(c *testing.T) {
image := "busybox-clone"
icmd.RunCmd(icmd.Cmd{
@@ -183,7 +181,7 @@
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"
oldRepo := "busybox"
newTag := "busybox:test"
@@ -194,10 +192,10 @@
dockerCmd(c, "commit", "test", newTag)
out, _ := dockerCmd(c, "rmi", newTag)
- c.Assert(out, checker.Contains, "Untagged: "+newTag)
+ assert.Assert(c, strings.Contains(out, "Untagged: "+newTag))
}
-func (s *DockerSuite) TestRmiForceWithMultipleRepositories(c *check.C) {
+func (s *DockerSuite) TestRmiForceWithMultipleRepositories(c *testing.T) {
imageName := "rmiimage"
tag1 := imageName + ":tag1"
tag2 := imageName + ":tag2"
@@ -207,25 +205,24 @@
dockerCmd(c, "tag", tag1, tag2)
out, _ := dockerCmd(c, "rmi", "-f", tag2)
- c.Assert(out, checker.Contains, "Untagged: "+tag2)
- c.Assert(out, checker.Not(checker.Contains), "Untagged: "+tag1)
-
+ assert.Assert(c, strings.Contains(out, "Untagged: "+tag2))
+ assert.Assert(c, !strings.Contains(out, "Untagged: "+tag1))
// Check built image still exists
images, _ := dockerCmd(c, "images", "-a")
- c.Assert(images, checker.Contains, imageName, check.Commentf("Built image missing %q; Images: %q", imageName, images))
+ assert.Assert(c, strings.Contains(images, imageName), "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", " ")
// Should have failed to delete ' ' image
assert.ErrorContains(c, err, "")
// Wrong error message generated
- c.Assert(out, checker.Not(checker.Contains), "no such id", check.Commentf("out: %s", out))
+ assert.Assert(c, !strings.Contains(out, "no such id"), "out: %s", out)
// Expected error message not generated
- c.Assert(out, checker.Contains, "image name cannot be blank", check.Commentf("out: %s", out))
+ assert.Assert(c, strings.Contains(out, "image name cannot be blank"), "out: %s", out)
}
-func (s *DockerSuite) TestRmiContainerImageNotFound(c *check.C) {
+func (s *DockerSuite) TestRmiContainerImageNotFound(c *testing.T) {
// Build 2 images for testing.
imageNames := []string{"test1", "test2"}
imageIds := make([]string, 2)
@@ -247,11 +244,11 @@
out, _, err := dockerCmdWithError("rmi", "-f", imageIds[0])
// The image of the running container should not be removed.
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "image is being used by running container", check.Commentf("out: %s", out))
+ assert.Assert(c, strings.Contains(out, "image is being used by running container"), "out: %s", out)
}
// #13422
-func (s *DockerSuite) TestRmiUntagHistoryLayer(c *check.C) {
+func (s *DockerSuite) TestRmiUntagHistoryLayer(c *testing.T) {
image := "tmp1"
// Build an image for testing.
dockerfile := `FROM busybox
@@ -274,7 +271,7 @@
// See if the "tmp2" can be untagged.
out, _ = dockerCmd(c, "rmi", newTag)
// Expected 1 untagged entry
- c.Assert(strings.Count(out, "Untagged: "), checker.Equals, 1, check.Commentf("out: %s", out))
+ assert.Equal(c, strings.Count(out, "Untagged: "), 1, fmt.Sprintf("out: %s", out))
// Now let's add the tag again and create a container based on it.
dockerCmd(c, "tag", idToTag, newTag)
@@ -286,16 +283,15 @@
out, _, err := dockerCmdWithError("rmi", newTag)
// should not be untagged without the -f flag
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, cid[:12])
- c.Assert(out, checker.Contains, "(must force)")
-
+ assert.Assert(c, strings.Contains(out, cid[:12]))
+ assert.Assert(c, strings.Contains(out, "(must force)"))
// Add the -f flag and test again.
out, _ = dockerCmd(c, "rmi", "-f", newTag)
// should be allowed to untag with the -f flag
- c.Assert(out, checker.Contains, fmt.Sprintf("Untagged: %s:latest", newTag))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf("Untagged: %s:latest", newTag)))
}
-func (*DockerSuite) TestRmiParentImageFail(c *check.C) {
+func (*DockerSuite) TestRmiParentImageFail(c *testing.T) {
buildImageSuccessfully(c, "test", build.WithDockerfile(`
FROM busybox
RUN echo hello`))
@@ -308,7 +304,7 @@
}
}
-func (s *DockerSuite) TestRmiWithParentInUse(c *check.C) {
+func (s *DockerSuite) TestRmiWithParentInUse(c *testing.T) {
out, _ := dockerCmd(c, "create", "busybox")
cID := strings.TrimSpace(out)
@@ -325,7 +321,7 @@
}
// #18873
-func (s *DockerSuite) TestRmiByIDHardConflict(c *check.C) {
+func (s *DockerSuite) TestRmiByIDHardConflict(c *testing.T) {
dockerCmd(c, "create", "busybox")
imgID := inspectField(c, "busybox:latest", "Id")
@@ -335,5 +331,5 @@
// check that tag was not removed
imgID2 := inspectField(c, "busybox:latest", "Id")
- c.Assert(imgID, checker.Equals, imgID2)
+ assert.Equal(c, imgID, imgID2)
}
diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go
index 46e731a..7771f3f 100644
--- a/integration-cli/docker_cli_run_test.go
+++ b/integration-cli/docker_cli_run_test.go
@@ -20,10 +20,10 @@
"strconv"
"strings"
"sync"
+ "testing"
"time"
"github.com/docker/docker/client"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/internal/test/fakecontext"
@@ -35,13 +35,12 @@
"github.com/docker/go-connections/nat"
"github.com/docker/libnetwork/resolvconf"
"github.com/docker/libnetwork/types"
- "github.com/go-check/check"
"gotest.tools/assert"
"gotest.tools/icmd"
)
// "test123" should be printed by docker run
-func (s *DockerSuite) TestRunEchoStdout(c *check.C) {
+func (s *DockerSuite) TestRunEchoStdout(c *testing.T) {
out, _ := dockerCmd(c, "run", "busybox", "echo", "test123")
if out != "test123\n" {
c.Fatalf("container should've printed 'test123', got '%s'", out)
@@ -49,7 +48,7 @@
}
// "test" should be printed
-func (s *DockerSuite) TestRunEchoNamedContainer(c *check.C) {
+func (s *DockerSuite) TestRunEchoNamedContainer(c *testing.T) {
out, _ := dockerCmd(c, "run", "--name", "testfoonamedcontainer", "busybox", "echo", "test")
if out != "test\n" {
c.Errorf("container should've printed 'test'")
@@ -58,7 +57,7 @@
// docker run should not leak file descriptors. This test relies on Unix
// specific functionality and cannot run on Windows.
-func (s *DockerSuite) TestRunLeakyFileDescriptors(c *check.C) {
+func (s *DockerSuite) TestRunLeakyFileDescriptors(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "busybox", "ls", "-C", "/proc/self/fd")
@@ -70,7 +69,7 @@
// it should be possible to lookup Google DNS
// this will fail when Internet access is unavailable
-func (s *DockerSuite) TestRunLookupGoogleDNS(c *check.C) {
+func (s *DockerSuite) TestRunLookupGoogleDNS(c *testing.T) {
testRequires(c, Network, NotArm)
if testEnv.OSType == "windows" {
// nslookup isn't present in Windows busybox. Is built-in. Further,
@@ -83,19 +82,19 @@
}
// the exit code should be 0
-func (s *DockerSuite) TestRunExitCodeZero(c *check.C) {
+func (s *DockerSuite) TestRunExitCodeZero(c *testing.T) {
dockerCmd(c, "run", "busybox", "true")
}
// the exit code should be 1
-func (s *DockerSuite) TestRunExitCodeOne(c *check.C) {
+func (s *DockerSuite) TestRunExitCodeOne(c *testing.T) {
_, exitCode, err := dockerCmdWithError("run", "busybox", "false")
assert.ErrorContains(c, err, "")
assert.Equal(c, exitCode, 1)
}
// it should be possible to pipe in data via stdin to a process running in a container
-func (s *DockerSuite) TestRunStdinPipe(c *check.C) {
+func (s *DockerSuite) TestRunStdinPipe(c *testing.T) {
// TODO Windows: This needs some work to make compatible.
testRequires(c, DaemonIsLinux)
result := icmd.RunCmd(icmd.Cmd{
@@ -119,7 +118,7 @@
}
// the container's ID should be printed when starting a container in detached mode
-func (s *DockerSuite) TestRunDetachedContainerIDPrinting(c *check.C) {
+func (s *DockerSuite) TestRunDetachedContainerIDPrinting(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
out = strings.TrimSpace(out)
@@ -134,7 +133,7 @@
}
// the working directory should be set correctly
-func (s *DockerSuite) TestRunWorkingDirectory(c *check.C) {
+func (s *DockerSuite) TestRunWorkingDirectory(c *testing.T) {
dir := "/root"
image := "busybox"
if testEnv.OSType == "windows" {
@@ -157,7 +156,7 @@
}
// pinging Google's DNS resolver should fail when we disable the networking
-func (s *DockerSuite) TestRunWithoutNetworking(c *check.C) {
+func (s *DockerSuite) TestRunWithoutNetworking(c *testing.T) {
count := "-c"
image := "busybox"
if testEnv.OSType == "windows" {
@@ -176,7 +175,7 @@
}
//test --link use container name to link target
-func (s *DockerSuite) TestRunLinksContainerWithContainerName(c *check.C) {
+func (s *DockerSuite) TestRunLinksContainerWithContainerName(c *testing.T) {
// TODO Windows: This test cannot run on a Windows daemon as the networking
// settings are not populated back yet on inspect.
testRequires(c, DaemonIsLinux)
@@ -191,7 +190,7 @@
}
//test --link use container id to link target
-func (s *DockerSuite) TestRunLinksContainerWithContainerID(c *check.C) {
+func (s *DockerSuite) TestRunLinksContainerWithContainerID(c *testing.T) {
// TODO Windows: This test cannot run on a Windows daemon as the networking
// settings are not populated back yet on inspect.
testRequires(c, DaemonIsLinux)
@@ -206,18 +205,18 @@
}
}
-func (s *DockerSuite) TestUserDefinedNetworkLinks(c *check.C) {
+func (s *DockerSuite) TestUserDefinedNetworkLinks(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
dockerCmd(c, "network", "create", "-d", "bridge", "udlinkNet")
dockerCmd(c, "run", "-d", "--net=udlinkNet", "--name=first", "busybox", "top")
- c.Assert(waitRun("first"), check.IsNil)
+ assert.Assert(c, waitRun("first") == nil)
// run a container in user-defined network udlinkNet with a link for an existing container
// and a link for a container that doesn't exist
dockerCmd(c, "run", "-d", "--net=udlinkNet", "--name=second", "--link=first:foo",
"--link=third:bar", "busybox", "top")
- c.Assert(waitRun("second"), check.IsNil)
+ assert.Assert(c, waitRun("second") == nil)
// ping to first and its alias foo must succeed
_, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
@@ -233,7 +232,7 @@
// start third container now
dockerCmd(c, "run", "-d", "--net=udlinkNet", "--name=third", "busybox", "top")
- c.Assert(waitRun("third"), check.IsNil)
+ assert.Assert(c, waitRun("third") == nil)
// ping to third and its alias must succeed now
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "third")
@@ -242,16 +241,16 @@
assert.NilError(c, err)
}
-func (s *DockerSuite) TestUserDefinedNetworkLinksWithRestart(c *check.C) {
+func (s *DockerSuite) TestUserDefinedNetworkLinksWithRestart(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
dockerCmd(c, "network", "create", "-d", "bridge", "udlinkNet")
dockerCmd(c, "run", "-d", "--net=udlinkNet", "--name=first", "busybox", "top")
- c.Assert(waitRun("first"), check.IsNil)
+ assert.Assert(c, waitRun("first") == nil)
dockerCmd(c, "run", "-d", "--net=udlinkNet", "--name=second", "--link=first:foo",
"busybox", "top")
- c.Assert(waitRun("second"), check.IsNil)
+ assert.Assert(c, waitRun("second") == nil)
// ping to first and its alias foo must succeed
_, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
@@ -261,7 +260,7 @@
// Restart first container
dockerCmd(c, "restart", "first")
- c.Assert(waitRun("first"), check.IsNil)
+ assert.Assert(c, waitRun("first") == nil)
// ping to first and its alias foo must still succeed
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
@@ -271,7 +270,7 @@
// Restart second container
dockerCmd(c, "restart", "second")
- c.Assert(waitRun("second"), check.IsNil)
+ assert.Assert(c, waitRun("second") == nil)
// ping to first and its alias foo must still succeed
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
@@ -280,37 +279,35 @@
assert.NilError(c, err)
}
-func (s *DockerSuite) TestRunWithNetAliasOnDefaultNetworks(c *check.C) {
+func (s *DockerSuite) TestRunWithNetAliasOnDefaultNetworks(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
defaults := []string{"bridge", "host", "none"}
for _, net := range defaults {
out, _, err := dockerCmdWithError("run", "-d", "--net", net, "--net-alias", "alias_"+net, "busybox", "top")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error())
+ assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkAndAlias.Error()))
}
}
-func (s *DockerSuite) TestUserDefinedNetworkAlias(c *check.C) {
+func (s *DockerSuite) TestUserDefinedNetworkAlias(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
dockerCmd(c, "network", "create", "-d", "bridge", "net1")
cid1, _ := dockerCmd(c, "run", "-d", "--net=net1", "--name=first", "--net-alias=foo1", "--net-alias=foo2", "busybox:glibc", "top")
- c.Assert(waitRun("first"), check.IsNil)
+ assert.Assert(c, waitRun("first") == nil)
// Check if default short-id alias is added automatically
id := strings.TrimSpace(cid1)
aliases := inspectField(c, id, "NetworkSettings.Networks.net1.Aliases")
- c.Assert(aliases, checker.Contains, stringid.TruncateID(id))
-
+ assert.Assert(c, strings.Contains(aliases, stringid.TruncateID(id)))
cid2, _ := dockerCmd(c, "run", "-d", "--net=net1", "--name=second", "busybox:glibc", "top")
- c.Assert(waitRun("second"), check.IsNil)
+ assert.Assert(c, waitRun("second") == nil)
// Check if default short-id alias is added automatically
id = strings.TrimSpace(cid2)
aliases = inspectField(c, id, "NetworkSettings.Networks.net1.Aliases")
- c.Assert(aliases, checker.Contains, stringid.TruncateID(id))
-
+ assert.Assert(c, strings.Contains(aliases, stringid.TruncateID(id)))
// ping to first and its network-scoped aliases
_, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
assert.NilError(c, err)
@@ -324,7 +321,7 @@
// Restart first container
dockerCmd(c, "restart", "first")
- c.Assert(waitRun("first"), check.IsNil)
+ assert.Assert(c, waitRun("first") == nil)
// ping to first and its network-scoped aliases must succeed
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
@@ -339,14 +336,14 @@
}
// Issue 9677.
-func (s *DockerSuite) TestRunWithDaemonFlags(c *check.C) {
+func (s *DockerSuite) TestRunWithDaemonFlags(c *testing.T) {
out, _, err := dockerCmdWithError("--exec-opt", "foo=bar", "run", "-i", "busybox", "true")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "unknown flag: --exec-opt")
+ assert.Assert(c, strings.Contains(out, "unknown flag: --exec-opt"))
}
// Regression test for #4979
-func (s *DockerSuite) TestRunWithVolumesFromExited(c *check.C) {
+func (s *DockerSuite) TestRunWithVolumesFromExited(c *testing.T) {
var (
out string
@@ -376,7 +373,7 @@
// Volume path is a symlink which also exists on the host, and the host side is a file not a dir
// But the volume call is just a normal volume, not a bind mount
-func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir(c *check.C) {
+func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir(c *testing.T) {
var (
dockerFile string
containerPath string
@@ -420,7 +417,7 @@
}
// Volume path is a symlink in the container
-func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir2(c *check.C) {
+func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir2(c *testing.T) {
var (
dockerFile string
containerPath string
@@ -444,13 +441,13 @@
dockerCmd(c, "run", "-v", containerPath, name, cmd)
}
-func (s *DockerSuite) TestRunVolumesMountedAsReadonly(c *check.C) {
+func (s *DockerSuite) TestRunVolumesMountedAsReadonly(c *testing.T) {
if _, code, err := dockerCmdWithError("run", "-v", "/test:/test:ro", "busybox", "touch", "/test/somefile"); err == nil || code == 0 {
c.Fatalf("run should fail because volume is ro: exit code %d", code)
}
}
-func (s *DockerSuite) TestRunVolumesFromInReadonlyModeFails(c *check.C) {
+func (s *DockerSuite) TestRunVolumesFromInReadonlyModeFails(c *testing.T) {
var (
volumeDir string
fileInVol string
@@ -471,7 +468,7 @@
}
// Regression test for #1201
-func (s *DockerSuite) TestRunVolumesFromInReadWriteMode(c *check.C) {
+func (s *DockerSuite) TestRunVolumesFromInReadWriteMode(c *testing.T) {
var (
volumeDir string
fileInVol string
@@ -494,7 +491,7 @@
dockerCmd(c, "run", "--volumes-from", "parent", "busybox", "touch", fileInVol)
}
-func (s *DockerSuite) TestVolumesFromGetsProperMode(c *check.C) {
+func (s *DockerSuite) TestVolumesFromGetsProperMode(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
hostpath := RandomTmpDirPath("test", testEnv.OSType)
@@ -519,7 +516,7 @@
}
// Test for GH#10618
-func (s *DockerSuite) TestRunNoDupVolumes(c *check.C) {
+func (s *DockerSuite) TestRunNoDupVolumes(c *testing.T) {
path1 := RandomTmpDirPath("test1", testEnv.OSType)
path2 := RandomTmpDirPath("test2", testEnv.OSType)
@@ -571,7 +568,7 @@
}
// Test for #1351
-func (s *DockerSuite) TestRunApplyVolumesFromBeforeVolumes(c *check.C) {
+func (s *DockerSuite) TestRunApplyVolumesFromBeforeVolumes(c *testing.T) {
prefix := ""
if testEnv.OSType == "windows" {
prefix = `c:`
@@ -580,7 +577,7 @@
dockerCmd(c, "run", "--volumes-from", "parent", "-v", prefix+"/test", "busybox", "cat", prefix+"/test/foo")
}
-func (s *DockerSuite) TestRunMultipleVolumesFrom(c *check.C) {
+func (s *DockerSuite) TestRunMultipleVolumesFrom(c *testing.T) {
prefix := ""
if testEnv.OSType == "windows" {
prefix = `c:`
@@ -591,7 +588,7 @@
}
// this tests verifies the ID format for the container
-func (s *DockerSuite) TestRunVerifyContainerID(c *check.C) {
+func (s *DockerSuite) TestRunVerifyContainerID(c *testing.T) {
out, exit, err := dockerCmdWithError("run", "-d", "busybox", "true")
if err != nil {
c.Fatal(err)
@@ -610,7 +607,7 @@
}
// Test that creating a container with a volume doesn't crash. Regression test for #995.
-func (s *DockerSuite) TestRunCreateVolume(c *check.C) {
+func (s *DockerSuite) TestRunCreateVolume(c *testing.T) {
prefix := ""
if testEnv.OSType == "windows" {
prefix = `c:`
@@ -620,7 +617,7 @@
// Test that creating a volume with a symlink in its path works correctly. Test for #5152.
// Note that this bug happens only with symlinks with a target that starts with '/'.
-func (s *DockerSuite) TestRunCreateVolumeWithSymlink(c *check.C) {
+func (s *DockerSuite) TestRunCreateVolumeWithSymlink(c *testing.T) {
// Cannot run on Windows as relies on Linux-specific functionality (sh -c mount...)
testRequires(c, DaemonIsLinux)
workingDirectory, err := ioutil.TempDir("", "TestRunCreateVolumeWithSymlink")
@@ -656,7 +653,7 @@
}
// Tests that a volume path that has a symlink exists in a container mounting it with `--volumes-from`.
-func (s *DockerSuite) TestRunVolumesFromSymlinkPath(c *check.C) {
+func (s *DockerSuite) TestRunVolumesFromSymlinkPath(c *testing.T) {
// This test cannot run on a Windows daemon as
// Windows does not support symlinks inside a volume path
testRequires(c, DaemonIsLinux)
@@ -697,7 +694,7 @@
}
}
-func (s *DockerSuite) TestRunExitCode(c *check.C) {
+func (s *DockerSuite) TestRunExitCode(c *testing.T) {
var (
exit int
err error
@@ -713,7 +710,7 @@
}
}
-func (s *DockerSuite) TestRunUserDefaults(c *check.C) {
+func (s *DockerSuite) TestRunUserDefaults(c *testing.T) {
expected := "uid=0(root) gid=0(root)"
if testEnv.OSType == "windows" {
expected = "uid=0(root) gid=0(root) groups=0(root)"
@@ -724,7 +721,7 @@
}
}
-func (s *DockerSuite) TestRunUserByName(c *check.C) {
+func (s *DockerSuite) TestRunUserByName(c *testing.T) {
// TODO Windows: This test cannot run on a Windows daemon as Windows does
// not support the use of -u
testRequires(c, DaemonIsLinux)
@@ -734,7 +731,7 @@
}
}
-func (s *DockerSuite) TestRunUserByID(c *check.C) {
+func (s *DockerSuite) TestRunUserByID(c *testing.T) {
// TODO Windows: This test cannot run on a Windows daemon as Windows does
// not support the use of -u
testRequires(c, DaemonIsLinux)
@@ -744,7 +741,7 @@
}
}
-func (s *DockerSuite) TestRunUserByIDBig(c *check.C) {
+func (s *DockerSuite) TestRunUserByIDBig(c *testing.T) {
// TODO Windows: This test cannot run on a Windows daemon as Windows does
// not support the use of -u
testRequires(c, DaemonIsLinux, NotArm)
@@ -757,7 +754,7 @@
}
}
-func (s *DockerSuite) TestRunUserByIDNegative(c *check.C) {
+func (s *DockerSuite) TestRunUserByIDNegative(c *testing.T) {
// TODO Windows: This test cannot run on a Windows daemon as Windows does
// not support the use of -u
testRequires(c, DaemonIsLinux)
@@ -770,7 +767,7 @@
}
}
-func (s *DockerSuite) TestRunUserByIDZero(c *check.C) {
+func (s *DockerSuite) TestRunUserByIDZero(c *testing.T) {
// TODO Windows: This test cannot run on a Windows daemon as Windows does
// not support the use of -u
testRequires(c, DaemonIsLinux)
@@ -783,7 +780,7 @@
}
}
-func (s *DockerSuite) TestRunUserNotFound(c *check.C) {
+func (s *DockerSuite) TestRunUserNotFound(c *testing.T) {
// TODO Windows: This test cannot run on a Windows daemon as Windows does
// not support the use of -u
testRequires(c, DaemonIsLinux)
@@ -793,7 +790,7 @@
}
}
-func (s *DockerSuite) TestRunTwoConcurrentContainers(c *check.C) {
+func (s *DockerSuite) TestRunTwoConcurrentContainers(c *testing.T) {
sleepTime := "2"
group := sync.WaitGroup{}
group.Add(2)
@@ -815,7 +812,7 @@
}
}
-func (s *DockerSuite) TestRunEnvironment(c *check.C) {
+func (s *DockerSuite) TestRunEnvironment(c *testing.T) {
// TODO Windows: Environment handling is different between Linux and
// Windows and this test relies currently on unix functionality.
testRequires(c, DaemonIsLinux)
@@ -854,7 +851,7 @@
}
}
-func (s *DockerSuite) TestRunEnvironmentErase(c *check.C) {
+func (s *DockerSuite) TestRunEnvironmentErase(c *testing.T) {
// TODO Windows: Environment handling is different between Linux and
// Windows and this test relies currently on unix functionality.
testRequires(c, DaemonIsLinux)
@@ -887,7 +884,7 @@
}
}
-func (s *DockerSuite) TestRunEnvironmentOverride(c *check.C) {
+func (s *DockerSuite) TestRunEnvironmentOverride(c *testing.T) {
// TODO Windows: Environment handling is different between Linux and
// Windows and this test relies currently on unix functionality.
testRequires(c, DaemonIsLinux)
@@ -920,7 +917,7 @@
}
}
-func (s *DockerSuite) TestRunContainerNetwork(c *check.C) {
+func (s *DockerSuite) TestRunContainerNetwork(c *testing.T) {
if testEnv.OSType == "windows" {
// Windows busybox does not have ping. Use built in ping instead.
dockerCmd(c, "run", testEnv.PlatformDefaults.BaseImage, "ping", "-n", "1", "127.0.0.1")
@@ -929,7 +926,7 @@
}
}
-func (s *DockerSuite) TestRunNetHostNotAllowedWithLinks(c *check.C) {
+func (s *DockerSuite) TestRunNetHostNotAllowedWithLinks(c *testing.T) {
// TODO Windows: This is Linux specific as --link is not supported and
// this will be deprecated in favor of container networking model.
testRequires(c, DaemonIsLinux, NotUserNamespace)
@@ -946,7 +943,7 @@
// and use "--net=host" (as the original issue submitter did), as the same
// codepath is executed with "docker run -h <hostname>". Both were manually
// tested, but this testcase takes the simpler path of using "run -h .."
-func (s *DockerSuite) TestRunFullHostnameSet(c *check.C) {
+func (s *DockerSuite) TestRunFullHostnameSet(c *testing.T) {
// TODO Windows: -h is not yet functional.
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-h", "foo.bar.baz", "busybox", "hostname")
@@ -955,7 +952,7 @@
}
}
-func (s *DockerSuite) TestRunPrivilegedCanMknod(c *check.C) {
+func (s *DockerSuite) TestRunPrivilegedCanMknod(c *testing.T) {
// Not applicable for Windows as Windows daemon does not support
// the concept of --privileged, and mknod is a Unix concept.
testRequires(c, DaemonIsLinux, NotUserNamespace)
@@ -965,7 +962,7 @@
}
}
-func (s *DockerSuite) TestRunUnprivilegedCanMknod(c *check.C) {
+func (s *DockerSuite) TestRunUnprivilegedCanMknod(c *testing.T) {
// Not applicable for Windows as Windows daemon does not support
// the concept of --privileged, and mknod is a Unix concept.
testRequires(c, DaemonIsLinux, NotUserNamespace)
@@ -975,7 +972,7 @@
}
}
-func (s *DockerSuite) TestRunCapDropInvalid(c *check.C) {
+func (s *DockerSuite) TestRunCapDropInvalid(c *testing.T) {
// Not applicable for Windows as there is no concept of --cap-drop
testRequires(c, DaemonIsLinux)
out, _, err := dockerCmdWithError("run", "--cap-drop=CHPASS", "busybox", "ls")
@@ -984,7 +981,7 @@
}
}
-func (s *DockerSuite) TestRunCapDropCannotMknod(c *check.C) {
+func (s *DockerSuite) TestRunCapDropCannotMknod(c *testing.T) {
// Not applicable for Windows as there is no concept of --cap-drop or mknod
testRequires(c, DaemonIsLinux)
out, _, err := dockerCmdWithError("run", "--cap-drop=MKNOD", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
@@ -997,7 +994,7 @@
}
}
-func (s *DockerSuite) TestRunCapDropCannotMknodLowerCase(c *check.C) {
+func (s *DockerSuite) TestRunCapDropCannotMknodLowerCase(c *testing.T) {
// Not applicable for Windows as there is no concept of --cap-drop or mknod
testRequires(c, DaemonIsLinux)
out, _, err := dockerCmdWithError("run", "--cap-drop=mknod", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
@@ -1010,7 +1007,7 @@
}
}
-func (s *DockerSuite) TestRunCapDropALLCannotMknod(c *check.C) {
+func (s *DockerSuite) TestRunCapDropALLCannotMknod(c *testing.T) {
// Not applicable for Windows as there is no concept of --cap-drop or mknod
testRequires(c, DaemonIsLinux)
out, _, err := dockerCmdWithError("run", "--cap-drop=ALL", "--cap-add=SETGID", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
@@ -1022,7 +1019,7 @@
}
}
-func (s *DockerSuite) TestRunCapDropALLAddMknodCanMknod(c *check.C) {
+func (s *DockerSuite) TestRunCapDropALLAddMknodCanMknod(c *testing.T) {
// Not applicable for Windows as there is no concept of --cap-drop or mknod
testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmd(c, "run", "--cap-drop=ALL", "--cap-add=MKNOD", "--cap-add=SETGID", "busybox", "sh", "-c", "mknod /tmp/sda b 8 0 && echo ok")
@@ -1032,7 +1029,7 @@
}
}
-func (s *DockerSuite) TestRunCapAddInvalid(c *check.C) {
+func (s *DockerSuite) TestRunCapAddInvalid(c *testing.T) {
// Not applicable for Windows as there is no concept of --cap-add
testRequires(c, DaemonIsLinux)
out, _, err := dockerCmdWithError("run", "--cap-add=CHPASS", "busybox", "ls")
@@ -1041,7 +1038,7 @@
}
}
-func (s *DockerSuite) TestRunCapAddCanDownInterface(c *check.C) {
+func (s *DockerSuite) TestRunCapAddCanDownInterface(c *testing.T) {
// Not applicable for Windows as there is no concept of --cap-add
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "--cap-add=NET_ADMIN", "busybox", "sh", "-c", "ip link set eth0 down && echo ok")
@@ -1051,7 +1048,7 @@
}
}
-func (s *DockerSuite) TestRunCapAddALLCanDownInterface(c *check.C) {
+func (s *DockerSuite) TestRunCapAddALLCanDownInterface(c *testing.T) {
// Not applicable for Windows as there is no concept of --cap-add
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "--cap-add=ALL", "busybox", "sh", "-c", "ip link set eth0 down && echo ok")
@@ -1061,7 +1058,7 @@
}
}
-func (s *DockerSuite) TestRunCapAddALLDropNetAdminCanDownInterface(c *check.C) {
+func (s *DockerSuite) TestRunCapAddALLDropNetAdminCanDownInterface(c *testing.T) {
// Not applicable for Windows as there is no concept of --cap-add
testRequires(c, DaemonIsLinux)
out, _, err := dockerCmdWithError("run", "--cap-add=ALL", "--cap-drop=NET_ADMIN", "busybox", "sh", "-c", "ip link set eth0 down && echo ok")
@@ -1073,7 +1070,7 @@
}
}
-func (s *DockerSuite) TestRunGroupAdd(c *check.C) {
+func (s *DockerSuite) TestRunGroupAdd(c *testing.T) {
// Not applicable for Windows as there is no concept of --group-add
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "--group-add=audio", "--group-add=staff", "--group-add=777", "busybox", "sh", "-c", "id")
@@ -1084,7 +1081,7 @@
}
}
-func (s *DockerSuite) TestRunPrivilegedCanMount(c *check.C) {
+func (s *DockerSuite) TestRunPrivilegedCanMount(c *testing.T) {
// Not applicable for Windows as there is no concept of --privileged
testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmd(c, "run", "--privileged", "busybox", "sh", "-c", "mount -t tmpfs none /tmp && echo ok")
@@ -1094,7 +1091,7 @@
}
}
-func (s *DockerSuite) TestRunUnprivilegedCannotMount(c *check.C) {
+func (s *DockerSuite) TestRunUnprivilegedCannotMount(c *testing.T) {
// Not applicable for Windows as there is no concept of unprivileged
testRequires(c, DaemonIsLinux)
out, _, err := dockerCmdWithError("run", "busybox", "sh", "-c", "mount -t tmpfs none /tmp && echo ok")
@@ -1107,7 +1104,7 @@
}
}
-func (s *DockerSuite) TestRunSysNotWritableInNonPrivilegedContainers(c *check.C) {
+func (s *DockerSuite) TestRunSysNotWritableInNonPrivilegedContainers(c *testing.T) {
// Not applicable for Windows as there is no concept of unprivileged
testRequires(c, DaemonIsLinux, NotArm)
if _, code, err := dockerCmdWithError("run", "busybox", "touch", "/sys/kernel/profiling"); err == nil || code == 0 {
@@ -1115,7 +1112,7 @@
}
}
-func (s *DockerSuite) TestRunSysWritableInPrivilegedContainers(c *check.C) {
+func (s *DockerSuite) TestRunSysWritableInPrivilegedContainers(c *testing.T) {
// Not applicable for Windows as there is no concept of unprivileged
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
if _, code, err := dockerCmdWithError("run", "--privileged", "busybox", "touch", "/sys/kernel/profiling"); err != nil || code != 0 {
@@ -1123,7 +1120,7 @@
}
}
-func (s *DockerSuite) TestRunProcNotWritableInNonPrivilegedContainers(c *check.C) {
+func (s *DockerSuite) TestRunProcNotWritableInNonPrivilegedContainers(c *testing.T) {
// Not applicable for Windows as there is no concept of unprivileged
testRequires(c, DaemonIsLinux)
if _, code, err := dockerCmdWithError("run", "busybox", "touch", "/proc/sysrq-trigger"); err == nil || code == 0 {
@@ -1131,7 +1128,7 @@
}
}
-func (s *DockerSuite) TestRunProcWritableInPrivilegedContainers(c *check.C) {
+func (s *DockerSuite) TestRunProcWritableInPrivilegedContainers(c *testing.T) {
// Not applicable for Windows as there is no concept of --privileged
testRequires(c, DaemonIsLinux, NotUserNamespace)
if _, code := dockerCmd(c, "run", "--privileged", "busybox", "sh", "-c", "touch /proc/sysrq-trigger"); code != 0 {
@@ -1139,7 +1136,7 @@
}
}
-func (s *DockerSuite) TestRunDeviceNumbers(c *check.C) {
+func (s *DockerSuite) TestRunDeviceNumbers(c *testing.T) {
// Not applicable on Windows as /dev/ is a Unix specific concept
// TODO: NotUserNamespace could be removed here if "root" "root" is replaced w user
testRequires(c, DaemonIsLinux, NotUserNamespace)
@@ -1155,7 +1152,7 @@
}
}
-func (s *DockerSuite) TestRunThatCharacterDevicesActLikeCharacterDevices(c *check.C) {
+func (s *DockerSuite) TestRunThatCharacterDevicesActLikeCharacterDevices(c *testing.T) {
// Not applicable on Windows as /dev/ is a Unix specific concept
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "busybox", "sh", "-c", "dd if=/dev/zero of=/zero bs=1k count=5 2> /dev/null ; du -h /zero")
@@ -1164,13 +1161,13 @@
}
}
-func (s *DockerSuite) TestRunUnprivilegedWithChroot(c *check.C) {
+func (s *DockerSuite) TestRunUnprivilegedWithChroot(c *testing.T) {
// Not applicable on Windows as it does not support chroot
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "busybox", "chroot", "/", "true")
}
-func (s *DockerSuite) TestRunAddingOptionalDevices(c *check.C) {
+func (s *DockerSuite) TestRunAddingOptionalDevices(c *testing.T) {
// Not applicable on Windows as Windows does not support --device
testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmd(c, "run", "--device", "/dev/zero:/dev/nulo", "busybox", "sh", "-c", "ls /dev/nulo")
@@ -1179,7 +1176,7 @@
}
}
-func (s *DockerSuite) TestRunAddingOptionalDevicesNoSrc(c *check.C) {
+func (s *DockerSuite) TestRunAddingOptionalDevicesNoSrc(c *testing.T) {
// Not applicable on Windows as Windows does not support --device
testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmd(c, "run", "--device", "/dev/zero:rw", "busybox", "sh", "-c", "ls /dev/zero")
@@ -1188,7 +1185,7 @@
}
}
-func (s *DockerSuite) TestRunAddingOptionalDevicesInvalidMode(c *check.C) {
+func (s *DockerSuite) TestRunAddingOptionalDevicesInvalidMode(c *testing.T) {
// Not applicable on Windows as Windows does not support --device
testRequires(c, DaemonIsLinux, NotUserNamespace)
_, _, err := dockerCmdWithError("run", "--device", "/dev/zero:ro", "busybox", "sh", "-c", "ls /dev/zero")
@@ -1197,7 +1194,7 @@
}
}
-func (s *DockerSuite) TestRunModeHostname(c *check.C) {
+func (s *DockerSuite) TestRunModeHostname(c *testing.T) {
// Not applicable on Windows as Windows does not support -h
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace)
@@ -1218,7 +1215,7 @@
}
}
-func (s *DockerSuite) TestRunRootWorkdir(c *check.C) {
+func (s *DockerSuite) TestRunRootWorkdir(c *testing.T) {
out, _ := dockerCmd(c, "run", "--workdir", "/", "busybox", "pwd")
expected := "/\n"
if testEnv.OSType == "windows" {
@@ -1229,7 +1226,7 @@
}
}
-func (s *DockerSuite) TestRunAllowBindMountingRoot(c *check.C) {
+func (s *DockerSuite) TestRunAllowBindMountingRoot(c *testing.T) {
if testEnv.OSType == "windows" {
// Windows busybox will fail with Permission Denied on items such as pagefile.sys
dockerCmd(c, "run", "-v", `c:\:c:\host`, testEnv.PlatformDefaults.BaseImage, "cmd", "-c", "dir", `c:\host`)
@@ -1238,7 +1235,7 @@
}
}
-func (s *DockerSuite) TestRunDisallowBindMountingRootToRoot(c *check.C) {
+func (s *DockerSuite) TestRunDisallowBindMountingRootToRoot(c *testing.T) {
mount := "/:/"
targetDir := "/host"
if testEnv.OSType == "windows" {
@@ -1252,7 +1249,7 @@
}
// Verify that a container gets default DNS when only localhost resolvers exist
-func (s *DockerSuite) TestRunDNSDefaultOptions(c *check.C) {
+func (s *DockerSuite) TestRunDNSDefaultOptions(c *testing.T) {
// Not applicable on Windows as this is testing Unix specific functionality
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
@@ -1286,7 +1283,7 @@
}
}
-func (s *DockerSuite) TestRunDNSOptions(c *check.C) {
+func (s *DockerSuite) TestRunDNSOptions(c *testing.T) {
// Not applicable on Windows as Windows does not support --dns*, or
// the Unix-specific functionality of resolv.conf.
testRequires(c, DaemonIsLinux)
@@ -1310,7 +1307,7 @@
}
}
-func (s *DockerSuite) TestRunDNSRepeatOptions(c *check.C) {
+func (s *DockerSuite) TestRunDNSRepeatOptions(c *testing.T) {
testRequires(c, DaemonIsLinux)
out := cli.DockerCmd(c, "run", "--dns=1.1.1.1", "--dns=2.2.2.2", "--dns-search=mydomain", "--dns-search=mydomain2", "--dns-opt=ndots:9", "--dns-opt=timeout:3", "busybox", "cat", "/etc/resolv.conf").Stdout()
@@ -1320,7 +1317,7 @@
}
}
-func (s *DockerSuite) TestRunDNSOptionsBasedOnHostResolvConf(c *check.C) {
+func (s *DockerSuite) TestRunDNSOptionsBasedOnHostResolvConf(c *testing.T) {
// Not applicable on Windows as testing Unix specific functionality
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
@@ -1402,7 +1399,7 @@
// Test to see if a non-root user can resolve a DNS name. Also
// check if the container resolv.conf file has at least 0644 perm.
-func (s *DockerSuite) TestRunNonRootUserResolvName(c *check.C) {
+func (s *DockerSuite) TestRunNonRootUserResolvName(c *testing.T) {
// Not applicable on Windows as Windows does not support --user
testRequires(c, testEnv.IsLocalDaemon, Network, DaemonIsLinux, NotArm)
@@ -1424,7 +1421,7 @@
// Test if container resolv.conf gets updated the next time it restarts
// if host /etc/resolv.conf has changed. This only applies if the container
// uses the host's /etc/resolv.conf and does not have any dns options provided.
-func (s *DockerSuite) TestRunResolvconfUpdate(c *check.C) {
+func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
// Not applicable on Windows as testing unix specific functionality
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
c.Skip("Unstable test, to be re-activated once #19937 is resolved")
@@ -1578,7 +1575,7 @@
//cleanup, restore original resolv.conf happens in defer func()
}
-func (s *DockerSuite) TestRunAddHost(c *check.C) {
+func (s *DockerSuite) TestRunAddHost(c *testing.T) {
// Not applicable on Windows as it does not support --add-host
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "--add-host=extra:86.75.30.9", "busybox", "grep", "extra", "/etc/hosts")
@@ -1590,7 +1587,7 @@
}
// Regression test for #6983
-func (s *DockerSuite) TestRunAttachStdErrOnlyTTYMode(c *check.C) {
+func (s *DockerSuite) TestRunAttachStdErrOnlyTTYMode(c *testing.T) {
_, exitCode := dockerCmd(c, "run", "-t", "-a", "stderr", "busybox", "true")
if exitCode != 0 {
c.Fatalf("Container should have exited with error code 0")
@@ -1598,7 +1595,7 @@
}
// Regression test for #6983
-func (s *DockerSuite) TestRunAttachStdOutOnlyTTYMode(c *check.C) {
+func (s *DockerSuite) TestRunAttachStdOutOnlyTTYMode(c *testing.T) {
_, exitCode := dockerCmd(c, "run", "-t", "-a", "stdout", "busybox", "true")
if exitCode != 0 {
c.Fatalf("Container should have exited with error code 0")
@@ -1606,7 +1603,7 @@
}
// Regression test for #6983
-func (s *DockerSuite) TestRunAttachStdOutAndErrTTYMode(c *check.C) {
+func (s *DockerSuite) TestRunAttachStdOutAndErrTTYMode(c *testing.T) {
_, exitCode := dockerCmd(c, "run", "-t", "-a", "stdout", "-a", "stderr", "busybox", "true")
if exitCode != 0 {
c.Fatalf("Container should have exited with error code 0")
@@ -1615,7 +1612,7 @@
// Test for #10388 - this will run the same test as TestRunAttachStdOutAndErrTTYMode
// but using --attach instead of -a to make sure we read the flag correctly
-func (s *DockerSuite) TestRunAttachWithDetach(c *check.C) {
+func (s *DockerSuite) TestRunAttachWithDetach(c *testing.T) {
icmd.RunCommand(dockerBinary, "run", "-d", "--attach", "stdout", "busybox", "true").Assert(c, icmd.Expected{
ExitCode: 1,
Error: "exit status 1",
@@ -1623,7 +1620,7 @@
})
}
-func (s *DockerSuite) TestRunState(c *check.C) {
+func (s *DockerSuite) TestRunState(c *testing.T) {
// TODO Windows: This needs some rework as Windows busybox does not support top
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
@@ -1660,7 +1657,7 @@
}
// Test for #1737
-func (s *DockerSuite) TestRunCopyVolumeUIDGID(c *check.C) {
+func (s *DockerSuite) TestRunCopyVolumeUIDGID(c *testing.T) {
// Not applicable on Windows as it does not support uid or gid in this way
testRequires(c, DaemonIsLinux)
name := "testrunvolumesuidgid"
@@ -1678,7 +1675,7 @@
}
// Test for #1582
-func (s *DockerSuite) TestRunCopyVolumeContent(c *check.C) {
+func (s *DockerSuite) TestRunCopyVolumeContent(c *testing.T) {
// TODO Windows, post RS1. Windows does not yet support volume functionality
// that copies from the image to the volume.
testRequires(c, DaemonIsLinux)
@@ -1693,7 +1690,7 @@
}
}
-func (s *DockerSuite) TestRunCleanupCmdOnEntrypoint(c *check.C) {
+func (s *DockerSuite) TestRunCleanupCmdOnEntrypoint(c *testing.T) {
name := "testrunmdcleanuponentrypoint"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox
ENTRYPOINT ["echo"]
@@ -1718,7 +1715,7 @@
}
// TestRunWorkdirExistsAndIsFile checks that if 'docker run -w' with existing file can be detected
-func (s *DockerSuite) TestRunWorkdirExistsAndIsFile(c *check.C) {
+func (s *DockerSuite) TestRunWorkdirExistsAndIsFile(c *testing.T) {
existingFile := "/bin/cat"
expected := "not a directory"
if testEnv.OSType == "windows" {
@@ -1732,7 +1729,7 @@
}
}
-func (s *DockerSuite) TestRunExitOnStdinClose(c *check.C) {
+func (s *DockerSuite) TestRunExitOnStdinClose(c *testing.T) {
name := "testrunexitonstdinclose"
meow := "/bin/cat"
@@ -1789,7 +1786,7 @@
}
// Test run -i --restart xxx doesn't hang
-func (s *DockerSuite) TestRunInteractiveWithRestartPolicy(c *check.C) {
+func (s *DockerSuite) TestRunInteractiveWithRestartPolicy(c *testing.T) {
name := "test-inter-restart"
result := icmd.RunCmd(icmd.Cmd{
@@ -1804,7 +1801,7 @@
}
// Test for #2267
-func (s *DockerSuite) TestRunWriteSpecialFilesAndNotCommit(c *check.C) {
+func (s *DockerSuite) TestRunWriteSpecialFilesAndNotCommit(c *testing.T) {
// Cannot run on Windows as this files are not present in Windows
testRequires(c, DaemonIsLinux)
@@ -1813,7 +1810,7 @@
testRunWriteSpecialFilesAndNotCommit(c, "writeresolv", "/etc/resolv.conf")
}
-func testRunWriteSpecialFilesAndNotCommit(c *check.C, name, path string) {
+func testRunWriteSpecialFilesAndNotCommit(c *testing.T, name, path string) {
command := fmt.Sprintf("echo test2267 >> %s && cat %s", path, path)
out, _ := dockerCmd(c, "run", "--name", name, "busybox", "sh", "-c", command)
if !strings.Contains(out, "test2267") {
@@ -1826,7 +1823,7 @@
}
}
-func eqToBaseDiff(out string, c *check.C) bool {
+func eqToBaseDiff(out string, c *testing.T) bool {
name := "eqToBaseDiff" + testutil.GenerateRandomAlphaOnlyString(32)
dockerCmd(c, "run", "--name", name, "busybox", "echo", "hello")
cID := getIDByName(c, name)
@@ -1852,7 +1849,7 @@
return true
}
-func (s *DockerSuite) TestRunWithBadDevice(c *check.C) {
+func (s *DockerSuite) TestRunWithBadDevice(c *testing.T) {
// Cannot run on Windows as Windows does not support --device
testRequires(c, DaemonIsLinux)
name := "baddevice"
@@ -1867,7 +1864,7 @@
}
}
-func (s *DockerSuite) TestRunEntrypoint(c *check.C) {
+func (s *DockerSuite) TestRunEntrypoint(c *testing.T) {
name := "entrypoint"
out, _ := dockerCmd(c, "run", "--name", name, "--entrypoint", "echo", "busybox", "-n", "foobar")
@@ -1878,7 +1875,7 @@
}
}
-func (s *DockerSuite) TestRunBindMounts(c *check.C) {
+func (s *DockerSuite) TestRunBindMounts(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
if testEnv.OSType == "linux" {
testRequires(c, DaemonIsLinux, NotUserNamespace)
@@ -1934,7 +1931,7 @@
// Ensure that CIDFile gets deleted if it's empty
// Perform this test by making `docker run` fail
-func (s *DockerSuite) TestRunCidFileCleanupIfEmpty(c *check.C) {
+func (s *DockerSuite) TestRunCidFileCleanupIfEmpty(c *testing.T) {
// Skip on Windows. Base image on Windows has a CMD set in the image.
testRequires(c, DaemonIsLinux)
@@ -1965,7 +1962,7 @@
// #2098 - Docker cidFiles only contain short version of the containerId
//sudo docker run --cidfile /tmp/docker_tesc.cid ubuntu echo "test"
// TestRunCidFile tests that run --cidfile returns the longid
-func (s *DockerSuite) TestRunCidFileCheckIDLength(c *check.C) {
+func (s *DockerSuite) TestRunCidFileCheckIDLength(c *testing.T) {
tmpDir, err := ioutil.TempDir("", "TestRunCidFile")
if err != nil {
c.Fatal(err)
@@ -1989,7 +1986,7 @@
}
}
-func (s *DockerSuite) TestRunSetMacAddress(c *check.C) {
+func (s *DockerSuite) TestRunSetMacAddress(c *testing.T) {
mac := "12:34:56:78:9a:bc"
var out string
if testEnv.OSType == "windows" {
@@ -2005,7 +2002,7 @@
}
}
-func (s *DockerSuite) TestRunInspectMacAddress(c *check.C) {
+func (s *DockerSuite) TestRunInspectMacAddress(c *testing.T) {
// TODO Windows. Network settings are not propagated back to inspect.
testRequires(c, DaemonIsLinux)
mac := "12:34:56:78:9a:bc"
@@ -2019,7 +2016,7 @@
}
// test docker run use an invalid mac address
-func (s *DockerSuite) TestRunWithInvalidMacAddress(c *check.C) {
+func (s *DockerSuite) TestRunWithInvalidMacAddress(c *testing.T) {
out, _, err := dockerCmdWithError("run", "--mac-address", "92:d0:c6:0a:29", "busybox")
//use an invalid mac address should with an error out
if err == nil || !strings.Contains(out, "is not a valid mac address") {
@@ -2027,7 +2024,7 @@
}
}
-func (s *DockerSuite) TestRunDeallocatePortOnMissingIptablesRule(c *check.C) {
+func (s *DockerSuite) TestRunDeallocatePortOnMissingIptablesRule(c *testing.T) {
// TODO Windows. Network settings are not propagated back to inspect.
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
@@ -2043,7 +2040,7 @@
cli.DockerCmd(c, "run", "-d", "-p", "23:23", "busybox", "top")
}
-func (s *DockerSuite) TestRunPortInUse(c *check.C) {
+func (s *DockerSuite) TestRunPortInUse(c *testing.T) {
// TODO Windows. The duplicate NAT message returned by Windows will be
// changing as is currently completely undecipherable. Does need modifying
// to run sh rather than top though as top isn't in Windows busybox.
@@ -2062,7 +2059,7 @@
}
// https://github.com/docker/docker/issues/12148
-func (s *DockerSuite) TestRunAllocatePortInReservedRange(c *check.C) {
+func (s *DockerSuite) TestRunAllocatePortInReservedRange(c *testing.T) {
// TODO Windows. -P is not yet supported
testRequires(c, DaemonIsLinux)
// allocate a dynamic port to get the most recent
@@ -2083,7 +2080,7 @@
}
// Regression test for #7792
-func (s *DockerSuite) TestRunMountOrdering(c *check.C) {
+func (s *DockerSuite) TestRunMountOrdering(c *testing.T) {
// TODO Windows: Post RS1. Windows does not support nested mounts.
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace)
prefix, _ := getPrefixAndSlashFromDaemonPlatform()
@@ -2128,7 +2125,7 @@
}
// Regression test for https://github.com/docker/docker/issues/8259
-func (s *DockerSuite) TestRunReuseBindVolumeThatIsSymlink(c *check.C) {
+func (s *DockerSuite) TestRunReuseBindVolumeThatIsSymlink(c *testing.T) {
// Not applicable on Windows as Windows does not support volumes
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace)
prefix, _ := getPrefixAndSlashFromDaemonPlatform()
@@ -2154,7 +2151,7 @@
}
//GH#10604: Test an "/etc" volume doesn't overlay special bind mounts in container
-func (s *DockerSuite) TestRunCreateVolumeEtc(c *check.C) {
+func (s *DockerSuite) TestRunCreateVolumeEtc(c *testing.T) {
// While Windows supports volumes, it does not support --add-host hence
// this test is not applicable on Windows.
testRequires(c, DaemonIsLinux)
@@ -2175,7 +2172,7 @@
}
}
-func (s *DockerSuite) TestVolumesNoCopyData(c *check.C) {
+func (s *DockerSuite) TestVolumesNoCopyData(c *testing.T) {
// TODO Windows (Post RS1). Windows does not support volumes which
// are pre-populated such as is built in the dockerfile used in this test.
testRequires(c, DaemonIsLinux)
@@ -2195,7 +2192,7 @@
}
}
-func (s *DockerSuite) TestRunNoOutputFromPullInStdout(c *check.C) {
+func (s *DockerSuite) TestRunNoOutputFromPullInStdout(c *testing.T) {
// just run with unknown image
cmd := exec.Command(dockerBinary, "run", "asdfsg")
stdout := bytes.NewBuffer(nil)
@@ -2208,7 +2205,7 @@
}
}
-func (s *DockerSuite) TestRunVolumesCleanPaths(c *check.C) {
+func (s *DockerSuite) TestRunVolumesCleanPaths(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon)
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
buildImageSuccessfully(c, "run_volumes_clean_paths", build.WithDockerfile(`FROM busybox
@@ -2239,7 +2236,7 @@
}
// Regression test for #3631
-func (s *DockerSuite) TestRunSlowStdoutConsumer(c *check.C) {
+func (s *DockerSuite) TestRunSlowStdoutConsumer(c *testing.T) {
// TODO Windows: This should be able to run on Windows if can find an
// alternate to /dev/zero and /dev/stdout.
testRequires(c, DaemonIsLinux)
@@ -2267,7 +2264,7 @@
}
}
-func (s *DockerSuite) TestRunAllowPortRangeThroughExpose(c *check.C) {
+func (s *DockerSuite) TestRunAllowPortRangeThroughExpose(c *testing.T) {
// TODO Windows: -P is not currently supported. Also network
// settings are not propagated back.
testRequires(c, DaemonIsLinux)
@@ -2290,13 +2287,13 @@
}
}
-func (s *DockerSuite) TestRunExposePort(c *check.C) {
+func (s *DockerSuite) TestRunExposePort(c *testing.T) {
out, _, err := dockerCmdWithError("run", "--expose", "80000", "busybox")
- c.Assert(err, checker.NotNil, check.Commentf("--expose with an invalid port should error out"))
- c.Assert(out, checker.Contains, "invalid range format for --expose")
+ assert.Assert(c, err != nil, "--expose with an invalid port should error out")
+ assert.Assert(c, strings.Contains(out, "invalid range format for --expose"))
}
-func (s *DockerSuite) TestRunModeIpcHost(c *check.C) {
+func (s *DockerSuite) TestRunModeIpcHost(c *testing.T) {
// Not applicable on Windows as uses Unix-specific capabilities
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace)
@@ -2318,7 +2315,7 @@
}
}
-func (s *DockerSuite) TestRunModeIpcContainerNotExists(c *check.C) {
+func (s *DockerSuite) TestRunModeIpcContainerNotExists(c *testing.T) {
// Not applicable on Windows as uses Unix-specific capabilities
testRequires(c, DaemonIsLinux)
out, _, err := dockerCmdWithError("run", "-d", "--ipc", "container:abcd1234", "busybox", "top")
@@ -2327,7 +2324,7 @@
}
}
-func (s *DockerSuite) TestRunModeIpcContainerNotRunning(c *check.C) {
+func (s *DockerSuite) TestRunModeIpcContainerNotRunning(c *testing.T) {
// Not applicable on Windows as uses Unix-specific capabilities
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
@@ -2340,7 +2337,7 @@
}
}
-func (s *DockerSuite) TestRunModePIDContainer(c *check.C) {
+func (s *DockerSuite) TestRunModePIDContainer(c *testing.T) {
// Not applicable on Windows as uses Unix-specific capabilities
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
@@ -2365,7 +2362,7 @@
}
}
-func (s *DockerSuite) TestRunModePIDContainerNotExists(c *check.C) {
+func (s *DockerSuite) TestRunModePIDContainerNotExists(c *testing.T) {
// Not applicable on Windows as uses Unix-specific capabilities
testRequires(c, DaemonIsLinux)
out, _, err := dockerCmdWithError("run", "-d", "--pid", "container:abcd1234", "busybox", "top")
@@ -2374,7 +2371,7 @@
}
}
-func (s *DockerSuite) TestRunModePIDContainerNotRunning(c *check.C) {
+func (s *DockerSuite) TestRunModePIDContainerNotRunning(c *testing.T) {
// Not applicable on Windows as uses Unix-specific capabilities
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
@@ -2387,7 +2384,7 @@
}
}
-func (s *DockerSuite) TestRunMountShmMqueueFromHost(c *check.C) {
+func (s *DockerSuite) TestRunMountShmMqueueFromHost(c *testing.T) {
// Not applicable on Windows as uses Unix-specific capabilities
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace)
@@ -2411,7 +2408,7 @@
}
}
-func (s *DockerSuite) TestContainerNetworkMode(c *check.C) {
+func (s *DockerSuite) TestContainerNetworkMode(c *testing.T) {
// Not applicable on Windows as uses Unix-specific capabilities
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
@@ -2432,7 +2429,7 @@
}
}
-func (s *DockerSuite) TestRunModePIDHost(c *check.C) {
+func (s *DockerSuite) TestRunModePIDHost(c *testing.T) {
// Not applicable on Windows as uses Unix-specific capabilities
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace)
@@ -2454,7 +2451,7 @@
}
}
-func (s *DockerSuite) TestRunModeUTSHost(c *check.C) {
+func (s *DockerSuite) TestRunModeUTSHost(c *testing.T) {
// Not applicable on Windows as uses Unix-specific capabilities
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
@@ -2476,10 +2473,10 @@
}
out, _ = dockerCmdWithFail(c, "run", "-h=name", "--uts=host", "busybox", "ps")
- c.Assert(out, checker.Contains, runconfig.ErrConflictUTSHostname.Error())
+ assert.Assert(c, strings.Contains(out, runconfig.ErrConflictUTSHostname.Error()))
}
-func (s *DockerSuite) TestRunTLSVerify(c *check.C) {
+func (s *DockerSuite) TestRunTLSVerify(c *testing.T) {
// Remote daemons use TLS and this test is not applicable when TLS is required.
testRequires(c, testEnv.IsLocalDaemon)
if out, code, err := dockerCmdWithError("ps"); err != nil || code != 0 {
@@ -2495,7 +2492,7 @@
result.Assert(c, icmd.Expected{ExitCode: 1, Err: "cert"})
}
-func (s *DockerSuite) TestRunPortFromDockerRangeInUse(c *check.C) {
+func (s *DockerSuite) TestRunPortFromDockerRangeInUse(c *testing.T) {
// TODO Windows. Once moved to libnetwork/CNM, this may be able to be
// re-instated.
testRequires(c, DaemonIsLinux)
@@ -2527,7 +2524,7 @@
dockerCmd(c, "port", id)
}
-func (s *DockerSuite) TestRunTTYWithPipe(c *check.C) {
+func (s *DockerSuite) TestRunTTYWithPipe(c *testing.T) {
errChan := make(chan error)
go func() {
defer close(errChan)
@@ -2559,7 +2556,7 @@
}
}
-func (s *DockerSuite) TestRunNonLocalMacAddress(c *check.C) {
+func (s *DockerSuite) TestRunNonLocalMacAddress(c *testing.T) {
addr := "00:16:3E:08:00:50"
args := []string{"run", "--mac-address", addr}
expected := addr
@@ -2576,7 +2573,7 @@
}
}
-func (s *DockerSuite) TestRunNetHost(c *check.C) {
+func (s *DockerSuite) TestRunNetHost(c *testing.T) {
// Not applicable on Windows as uses Unix-specific capabilities
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace)
@@ -2598,7 +2595,7 @@
}
}
-func (s *DockerSuite) TestRunNetHostTwiceSameName(c *check.C) {
+func (s *DockerSuite) TestRunNetHostTwiceSameName(c *testing.T) {
// TODO Windows. As Windows networking evolves and converges towards
// CNM, this test may be possible to enable on Windows.
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace)
@@ -2607,7 +2604,7 @@
dockerCmd(c, "run", "--rm", "--name=thost", "--net=host", "busybox", "true")
}
-func (s *DockerSuite) TestRunNetContainerWhichHost(c *check.C) {
+func (s *DockerSuite) TestRunNetContainerWhichHost(c *testing.T) {
// Not applicable on Windows as uses Unix-specific capabilities
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace)
@@ -2625,7 +2622,7 @@
}
}
-func (s *DockerSuite) TestRunAllowPortRangeThroughPublish(c *check.C) {
+func (s *DockerSuite) TestRunAllowPortRangeThroughPublish(c *testing.T) {
// TODO Windows. This may be possible to enable in the future. However,
// Windows does not currently support --expose, or populate the network
// settings seen through inspect.
@@ -2649,7 +2646,7 @@
}
}
-func (s *DockerSuite) TestRunSetDefaultRestartPolicy(c *check.C) {
+func (s *DockerSuite) TestRunSetDefaultRestartPolicy(c *testing.T) {
runSleepingContainer(c, "--name=testrunsetdefaultrestartpolicy")
out := inspectField(c, "testrunsetdefaultrestartpolicy", "HostConfig.RestartPolicy.Name")
if out != "no" {
@@ -2657,7 +2654,7 @@
}
}
-func (s *DockerSuite) TestRunRestartMaxRetries(c *check.C) {
+func (s *DockerSuite) TestRunRestartMaxRetries(c *testing.T) {
out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "false")
timeout := 10 * time.Second
if testEnv.OSType == "windows" {
@@ -2680,11 +2677,11 @@
}
}
-func (s *DockerSuite) TestRunContainerWithWritableRootfs(c *check.C) {
+func (s *DockerSuite) TestRunContainerWithWritableRootfs(c *testing.T) {
dockerCmd(c, "run", "--rm", "busybox", "touch", "/file")
}
-func (s *DockerSuite) TestRunContainerWithReadonlyRootfs(c *check.C) {
+func (s *DockerSuite) TestRunContainerWithReadonlyRootfs(c *testing.T) {
// Not applicable on Windows which does not support --read-only
testRequires(c, DaemonIsLinux, UserNamespaceROMount)
@@ -2696,7 +2693,7 @@
testReadOnlyFile(c, testPriv, "/file", "/etc/hosts", "/etc/resolv.conf", "/etc/hostname")
}
-func (s *DockerSuite) TestPermissionsPtsReadonlyRootfs(c *check.C) {
+func (s *DockerSuite) TestPermissionsPtsReadonlyRootfs(c *testing.T) {
// Not applicable on Windows due to use of Unix specific functionality, plus
// the use of --read-only which is not supported.
testRequires(c, DaemonIsLinux, UserNamespaceROMount)
@@ -2712,7 +2709,7 @@
}
}
-func testReadOnlyFile(c *check.C, testPriv bool, filenames ...string) {
+func testReadOnlyFile(c *testing.T, testPriv bool, filenames ...string) {
touch := "touch " + strings.Join(filenames, " ")
out, _, err := dockerCmdWithError("run", "--read-only", "--rm", "busybox", "sh", "-c", touch)
assert.ErrorContains(c, err, "")
@@ -2735,7 +2732,7 @@
}
}
-func (s *DockerSuite) TestRunContainerWithReadonlyEtcHostsAndLinkedContainer(c *check.C) {
+func (s *DockerSuite) TestRunContainerWithReadonlyEtcHostsAndLinkedContainer(c *testing.T) {
// Not applicable on Windows which does not support --link
testRequires(c, DaemonIsLinux, UserNamespaceROMount)
@@ -2747,7 +2744,7 @@
}
}
-func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithDNSFlag(c *check.C) {
+func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithDNSFlag(c *testing.T) {
// Not applicable on Windows which does not support either --read-only or --dns.
testRequires(c, DaemonIsLinux, UserNamespaceROMount)
@@ -2757,7 +2754,7 @@
}
}
-func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithAddHostFlag(c *check.C) {
+func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithAddHostFlag(c *testing.T) {
// Not applicable on Windows which does not support --read-only
testRequires(c, DaemonIsLinux, UserNamespaceROMount)
@@ -2767,7 +2764,7 @@
}
}
-func (s *DockerSuite) TestRunVolumesFromRestartAfterRemoved(c *check.C) {
+func (s *DockerSuite) TestRunVolumesFromRestartAfterRemoved(c *testing.T) {
prefix, _ := getPrefixAndSlashFromDaemonPlatform()
runSleepingContainer(c, "--name=voltest", "-v", prefix+"/foo")
runSleepingContainer(c, "--name=restarter", "--volumes-from", "voltest")
@@ -2780,7 +2777,7 @@
}
// run container with --rm should remove container if exit code != 0
-func (s *DockerSuite) TestRunContainerWithRmFlagExitCodeNotEqualToZero(c *check.C) {
+func (s *DockerSuite) TestRunContainerWithRmFlagExitCodeNotEqualToZero(c *testing.T) {
existingContainers := ExistingContainerIDs(c)
name := "flowers"
cli.Docker(cli.Args("run", "--name", name, "--rm", "busybox", "ls", "/notexists")).Assert(c, icmd.Expected{
@@ -2794,7 +2791,7 @@
}
}
-func (s *DockerSuite) TestRunContainerWithRmFlagCannotStartContainer(c *check.C) {
+func (s *DockerSuite) TestRunContainerWithRmFlagCannotStartContainer(c *testing.T) {
existingContainers := ExistingContainerIDs(c)
name := "sparkles"
cli.Docker(cli.Args("run", "--name", name, "--rm", "busybox", "commandNotFound")).Assert(c, icmd.Expected{
@@ -2807,13 +2804,13 @@
}
}
-func (s *DockerSuite) TestRunPIDHostWithChildIsKillable(c *check.C) {
+func (s *DockerSuite) TestRunPIDHostWithChildIsKillable(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, DaemonIsLinux, NotUserNamespace)
name := "ibuildthecloud"
dockerCmd(c, "run", "-d", "--pid=host", "--name", name, "busybox", "sh", "-c", "sleep 30; echo hi")
- c.Assert(waitRun(name), check.IsNil)
+ assert.Assert(c, waitRun(name) == nil)
errchan := make(chan error)
go func() {
@@ -2830,7 +2827,7 @@
}
}
-func (s *DockerSuite) TestRunWithTooSmallMemoryLimit(c *check.C) {
+func (s *DockerSuite) TestRunWithTooSmallMemoryLimit(c *testing.T) {
// TODO Windows. This may be possible to enable once Windows supports
// memory limits on containers
testRequires(c, DaemonIsLinux)
@@ -2842,7 +2839,7 @@
}
}
-func (s *DockerSuite) TestRunWriteToProcAsound(c *check.C) {
+func (s *DockerSuite) TestRunWriteToProcAsound(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, DaemonIsLinux)
_, code, err := dockerCmdWithError("run", "busybox", "sh", "-c", "echo 111 >> /proc/asound/version")
@@ -2851,7 +2848,7 @@
}
}
-func (s *DockerSuite) TestRunReadProcTimer(c *check.C) {
+func (s *DockerSuite) TestRunReadProcTimer(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, DaemonIsLinux)
out, code, err := dockerCmdWithError("run", "busybox", "cat", "/proc/timer_stats")
@@ -2866,7 +2863,7 @@
}
}
-func (s *DockerSuite) TestRunReadProcLatency(c *check.C) {
+func (s *DockerSuite) TestRunReadProcLatency(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, DaemonIsLinux)
// some kernels don't have this configured so skip the test if this file is not found
@@ -2887,7 +2884,7 @@
}
}
-func (s *DockerSuite) TestRunReadFilteredProc(c *check.C) {
+func (s *DockerSuite) TestRunReadFilteredProc(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, Apparmor, DaemonIsLinux, NotUserNamespace)
@@ -2910,7 +2907,7 @@
}
}
-func (s *DockerSuite) TestMountIntoProc(c *check.C) {
+func (s *DockerSuite) TestMountIntoProc(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, DaemonIsLinux)
_, code, err := dockerCmdWithError("run", "-v", "/proc//sys", "busybox", "true")
@@ -2919,14 +2916,14 @@
}
}
-func (s *DockerSuite) TestMountIntoSys(c *check.C) {
+func (s *DockerSuite) TestMountIntoSys(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, DaemonIsLinux)
testRequires(c, NotUserNamespace)
dockerCmd(c, "run", "-v", "/sys/fs/cgroup", "busybox", "true")
}
-func (s *DockerSuite) TestRunUnshareProc(c *check.C) {
+func (s *DockerSuite) TestRunUnshareProc(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, Apparmor, DaemonIsLinux, NotUserNamespace)
@@ -2984,7 +2981,7 @@
}
}
-func (s *DockerSuite) TestRunPublishPort(c *check.C) {
+func (s *DockerSuite) TestRunPublishPort(c *testing.T) {
// TODO Windows: This may be possible once Windows moves to libnetwork and CNM
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--name", "test", "--expose", "8080", "busybox", "top")
@@ -2996,7 +2993,7 @@
}
// Issue #10184.
-func (s *DockerSuite) TestDevicePermissions(c *check.C) {
+func (s *DockerSuite) TestDevicePermissions(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, DaemonIsLinux)
const permissions = "crw-rw-rw-"
@@ -3009,7 +3006,7 @@
}
}
-func (s *DockerSuite) TestRunCapAddCHOWN(c *check.C) {
+func (s *DockerSuite) TestRunCapAddCHOWN(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "--cap-drop=ALL", "--cap-add=CHOWN", "busybox", "sh", "-c", "adduser -D -H newuser && chown newuser /home && echo ok")
@@ -3020,7 +3017,7 @@
}
// https://github.com/docker/docker/pull/14498
-func (s *DockerSuite) TestVolumeFromMixedRWOptions(c *check.C) {
+func (s *DockerSuite) TestVolumeFromMixedRWOptions(c *testing.T) {
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
dockerCmd(c, "run", "--name", "parent", "-v", prefix+"/test", "busybox", "true")
@@ -3043,7 +3040,7 @@
}
}
-func (s *DockerSuite) TestRunWriteFilteredProc(c *check.C) {
+func (s *DockerSuite) TestRunWriteFilteredProc(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, Apparmor, DaemonIsLinux, NotUserNamespace)
@@ -3070,7 +3067,7 @@
}
}
-func (s *DockerSuite) TestRunNetworkFilesBindMount(c *check.C) {
+func (s *DockerSuite) TestRunNetworkFilesBindMount(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
@@ -3094,7 +3091,7 @@
}
}
-func (s *DockerSuite) TestRunNetworkFilesBindMountRO(c *check.C) {
+func (s *DockerSuite) TestRunNetworkFilesBindMountRO(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
@@ -3116,7 +3113,7 @@
}
}
-func (s *DockerSuite) TestRunNetworkFilesBindMountROFilesystem(c *check.C) {
+func (s *DockerSuite) TestRunNetworkFilesBindMountROFilesystem(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, UserNamespaceROMount)
@@ -3145,7 +3142,7 @@
}
}
-func (s *DockerSuite) TestPtraceContainerProcsFromHost(c *check.C) {
+func (s *DockerSuite) TestPtraceContainerProcsFromHost(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
@@ -3160,7 +3157,7 @@
}
}
-func (s *DockerSuite) TestAppArmorDeniesPtrace(c *check.C) {
+func (s *DockerSuite) TestAppArmorDeniesPtrace(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, testEnv.IsLocalDaemon, Apparmor, DaemonIsLinux)
@@ -3172,7 +3169,7 @@
}
}
-func (s *DockerSuite) TestAppArmorTraceSelf(c *check.C) {
+func (s *DockerSuite) TestAppArmorTraceSelf(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon, Apparmor)
@@ -3182,7 +3179,7 @@
}
}
-func (s *DockerSuite) TestAppArmorDeniesChmodProc(c *check.C) {
+func (s *DockerSuite) TestAppArmorDeniesChmodProc(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, testEnv.IsLocalDaemon, Apparmor, DaemonIsLinux, NotUserNamespace)
_, exitCode, _ := dockerCmdWithError("run", "busybox", "chmod", "744", "/proc/cpuinfo")
@@ -3195,7 +3192,7 @@
}
}
-func (s *DockerSuite) TestRunCapAddSYSTIME(c *check.C) {
+func (s *DockerSuite) TestRunCapAddSYSTIME(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, DaemonIsLinux)
@@ -3203,31 +3200,31 @@
}
// run create container failed should clean up the container
-func (s *DockerSuite) TestRunCreateContainerFailedCleanUp(c *check.C) {
+func (s *DockerSuite) TestRunCreateContainerFailedCleanUp(c *testing.T) {
// TODO Windows. This may be possible to enable once link is supported
testRequires(c, DaemonIsLinux)
name := "unique_name"
_, _, err := dockerCmdWithError("run", "--name", name, "--link", "nothing:nothing", "busybox")
- c.Assert(err, check.NotNil, check.Commentf("Expected docker run to fail!"))
+ assert.Assert(c, err != nil, "Expected docker run to fail!")
containerID, err := inspectFieldWithError(name, "Id")
- c.Assert(err, checker.NotNil, check.Commentf("Expected not to have this container: %s!", containerID))
- c.Assert(containerID, check.Equals, "", check.Commentf("Expected not to have this container: %s!", containerID))
+ assert.Assert(c, err != nil, "Expected not to have this container: %s!", containerID)
+ assert.Equal(c, containerID, "", fmt.Sprintf("Expected not to have this container: %s!", containerID))
}
-func (s *DockerSuite) TestRunNamedVolume(c *check.C) {
+func (s *DockerSuite) TestRunNamedVolume(c *testing.T) {
prefix, _ := getPrefixAndSlashFromDaemonPlatform()
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "--name=test", "-v", "testing:"+prefix+"/foo", "busybox", "sh", "-c", "echo hello > "+prefix+"/foo/bar")
out, _ := dockerCmd(c, "run", "--volumes-from", "test", "busybox", "sh", "-c", "cat "+prefix+"/foo/bar")
- c.Assert(strings.TrimSpace(out), check.Equals, "hello")
+ assert.Equal(c, strings.TrimSpace(out), "hello")
out, _ = dockerCmd(c, "run", "-v", "testing:"+prefix+"/foo", "busybox", "sh", "-c", "cat "+prefix+"/foo/bar")
- c.Assert(strings.TrimSpace(out), check.Equals, "hello")
+ assert.Equal(c, strings.TrimSpace(out), "hello")
}
-func (s *DockerSuite) TestRunWithUlimits(c *check.C) {
+func (s *DockerSuite) TestRunWithUlimits(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, DaemonIsLinux)
@@ -3238,7 +3235,7 @@
}
}
-func (s *DockerSuite) TestRunContainerWithCgroupParent(c *check.C) {
+func (s *DockerSuite) TestRunContainerWithCgroupParent(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, DaemonIsLinux)
@@ -3249,7 +3246,7 @@
testRunContainerWithCgroupParent(c, "/cgroup-parent/test", "cgroup-test-absolute")
}
-func testRunContainerWithCgroupParent(c *check.C, cgroupParent, name string) {
+func testRunContainerWithCgroupParent(c *testing.T, cgroupParent, name string) {
out, _, err := dockerCmdWithError("run", "--cgroup-parent", cgroupParent, "--name", name, "busybox", "cat", "/proc/self/cgroup")
if err != nil {
c.Fatalf("unexpected failure when running container with --cgroup-parent option - %s\n%v", string(out), err)
@@ -3273,7 +3270,7 @@
}
// TestRunInvalidCgroupParent checks that a specially-crafted cgroup parent doesn't cause Docker to crash or start modifying /.
-func (s *DockerSuite) TestRunInvalidCgroupParent(c *check.C) {
+func (s *DockerSuite) TestRunInvalidCgroupParent(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
testRequires(c, DaemonIsLinux)
@@ -3282,7 +3279,7 @@
testRunInvalidCgroupParent(c, "/../../../../../../../../SHOULD_NOT_EXIST", "/SHOULD_NOT_EXIST", "cgroup-absolute-invalid-test")
}
-func testRunInvalidCgroupParent(c *check.C, cgroupParent, cleanCgroupParent, name string) {
+func testRunInvalidCgroupParent(c *testing.T, cgroupParent, cleanCgroupParent, name string) {
out, _, err := dockerCmdWithError("run", "--cgroup-parent", cgroupParent, "--name", name, "busybox", "cat", "/proc/self/cgroup")
if err != nil {
// XXX: This may include a daemon crash.
@@ -3312,7 +3309,7 @@
}
}
-func (s *DockerSuite) TestRunContainerWithCgroupMountRO(c *check.C) {
+func (s *DockerSuite) TestRunContainerWithCgroupMountRO(c *testing.T) {
// Not applicable on Windows as uses Unix specific functionality
// --read-only + userns has remount issues
testRequires(c, DaemonIsLinux, NotUserNamespace)
@@ -3328,7 +3325,7 @@
}
}
-func (s *DockerSuite) TestRunContainerNetworkModeToSelf(c *check.C) {
+func (s *DockerSuite) TestRunContainerNetworkModeToSelf(c *testing.T) {
// Not applicable on Windows which does not support --net=container
testRequires(c, DaemonIsLinux)
out, _, err := dockerCmdWithError("run", "--name=me", "--net=container:me", "busybox", "true")
@@ -3337,7 +3334,7 @@
}
}
-func (s *DockerSuite) TestRunContainerNetModeWithDNSMacHosts(c *check.C) {
+func (s *DockerSuite) TestRunContainerNetModeWithDNSMacHosts(c *testing.T) {
// Not applicable on Windows which does not support --net=container
testRequires(c, DaemonIsLinux)
out, _, err := dockerCmdWithError("run", "-d", "--name", "parent", "busybox", "top")
@@ -3361,7 +3358,7 @@
}
}
-func (s *DockerSuite) TestRunContainerNetModeWithExposePort(c *check.C) {
+func (s *DockerSuite) TestRunContainerNetModeWithExposePort(c *testing.T) {
// Not applicable on Windows which does not support --net=container
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--name", "parent", "busybox", "top")
@@ -3382,7 +3379,7 @@
}
}
-func (s *DockerSuite) TestRunLinkToContainerNetMode(c *check.C) {
+func (s *DockerSuite) TestRunLinkToContainerNetMode(c *testing.T) {
// Not applicable on Windows which does not support --net=container or --link
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "--name", "test", "-d", "busybox", "top")
@@ -3392,7 +3389,7 @@
dockerCmd(c, "run", "-d", "--link=child:child", "busybox", "top")
}
-func (s *DockerSuite) TestRunLoopbackOnlyExistsWhenNetworkingDisabled(c *check.C) {
+func (s *DockerSuite) TestRunLoopbackOnlyExistsWhenNetworkingDisabled(c *testing.T) {
// TODO Windows: This may be possible to convert.
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "--net=none", "busybox", "ip", "-o", "-4", "a", "show", "up")
@@ -3418,7 +3415,7 @@
}
// Issue #4681
-func (s *DockerSuite) TestRunLoopbackWhenNetworkDisabled(c *check.C) {
+func (s *DockerSuite) TestRunLoopbackWhenNetworkDisabled(c *testing.T) {
if testEnv.OSType == "windows" {
dockerCmd(c, "run", "--net=none", testEnv.PlatformDefaults.BaseImage, "ping", "-n", "1", "127.0.0.1")
} else {
@@ -3426,7 +3423,7 @@
}
}
-func (s *DockerSuite) TestRunModeNetContainerHostname(c *check.C) {
+func (s *DockerSuite) TestRunModeNetContainerHostname(c *testing.T) {
// Windows does not support --net=container
testRequires(c, DaemonIsLinux)
@@ -3439,7 +3436,7 @@
}
}
-func (s *DockerSuite) TestRunNetworkNotInitializedNoneMode(c *check.C) {
+func (s *DockerSuite) TestRunNetworkNotInitializedNoneMode(c *testing.T) {
// TODO Windows: Network settings are not currently propagated. This may
// be resolved in the future with the move to libnetwork and CNM.
testRequires(c, DaemonIsLinux)
@@ -3451,7 +3448,7 @@
}
}
-func (s *DockerSuite) TestTwoContainersInNetHost(c *check.C) {
+func (s *DockerSuite) TestTwoContainersInNetHost(c *testing.T) {
// Not applicable as Windows does not support --net=host
testRequires(c, DaemonIsLinux, NotUserNamespace, NotUserNamespace)
dockerCmd(c, "run", "-d", "--net=host", "--name=first", "busybox", "top")
@@ -3460,24 +3457,24 @@
dockerCmd(c, "stop", "second")
}
-func (s *DockerSuite) TestContainersInUserDefinedNetwork(c *check.C) {
+func (s *DockerSuite) TestContainersInUserDefinedNetwork(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork")
dockerCmd(c, "run", "-d", "--net=testnetwork", "--name=first", "busybox", "top")
- c.Assert(waitRun("first"), check.IsNil)
+ assert.Assert(c, waitRun("first") == nil)
dockerCmd(c, "run", "-t", "--net=testnetwork", "--name=second", "busybox", "ping", "-c", "1", "first")
}
-func (s *DockerSuite) TestContainersInMultipleNetworks(c *check.C) {
+func (s *DockerSuite) TestContainersInMultipleNetworks(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
// Create 2 networks using bridge driver
dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1")
dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork2")
// Run and connect containers to testnetwork1
dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=first", "busybox", "top")
- c.Assert(waitRun("first"), check.IsNil)
+ assert.Assert(c, waitRun("first") == nil)
dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=second", "busybox", "top")
- c.Assert(waitRun("second"), check.IsNil)
+ assert.Assert(c, waitRun("second") == nil)
// Check connectivity between containers in testnetwork2
dockerCmd(c, "exec", "first", "ping", "-c", "1", "second.testnetwork1")
// Connect containers to testnetwork2
@@ -3487,16 +3484,16 @@
dockerCmd(c, "exec", "second", "ping", "-c", "1", "first.testnetwork2")
}
-func (s *DockerSuite) TestContainersNetworkIsolation(c *check.C) {
+func (s *DockerSuite) TestContainersNetworkIsolation(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
// Create 2 networks using bridge driver
dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1")
dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork2")
// Run 1 container in testnetwork1 and another in testnetwork2
dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=first", "busybox", "top")
- c.Assert(waitRun("first"), check.IsNil)
+ assert.Assert(c, waitRun("first") == nil)
dockerCmd(c, "run", "-d", "--net=testnetwork2", "--name=second", "busybox", "top")
- c.Assert(waitRun("second"), check.IsNil)
+ assert.Assert(c, waitRun("second") == nil)
// Check Isolation between containers : ping must fail
_, _, err := dockerCmdWithError("exec", "first", "ping", "-c", "1", "second")
@@ -3514,15 +3511,15 @@
assert.ErrorContains(c, err, "")
}
-func (s *DockerSuite) TestNetworkRmWithActiveContainers(c *check.C) {
+func (s *DockerSuite) TestNetworkRmWithActiveContainers(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
// Create 2 networks using bridge driver
dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1")
// Run and connect containers to testnetwork1
dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=first", "busybox", "top")
- c.Assert(waitRun("first"), check.IsNil)
+ assert.Assert(c, waitRun("first") == nil)
dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=second", "busybox", "top")
- c.Assert(waitRun("second"), check.IsNil)
+ assert.Assert(c, waitRun("second") == nil)
// Network delete with active containers must fail
_, _, err := dockerCmdWithError("network", "rm", "testnetwork1")
assert.ErrorContains(c, err, "")
@@ -3532,7 +3529,7 @@
assert.ErrorContains(c, err, "")
}
-func (s *DockerSuite) TestContainerRestartInMultipleNetworks(c *check.C) {
+func (s *DockerSuite) TestContainerRestartInMultipleNetworks(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm)
// Create 2 networks using bridge driver
dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1")
@@ -3540,9 +3537,9 @@
// Run and connect containers to testnetwork1
dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=first", "busybox", "top")
- c.Assert(waitRun("first"), check.IsNil)
+ assert.Assert(c, waitRun("first") == nil)
dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=second", "busybox", "top")
- c.Assert(waitRun("second"), check.IsNil)
+ assert.Assert(c, waitRun("second") == nil)
// Check connectivity between containers in testnetwork2
dockerCmd(c, "exec", "first", "ping", "-c", "1", "second.testnetwork1")
// Connect containers to testnetwork2
@@ -3564,11 +3561,11 @@
dockerCmd(c, "exec", "second", "ping", "-c", "1", "first.testnetwork2")
}
-func (s *DockerSuite) TestContainerWithConflictingHostNetworks(c *check.C) {
+func (s *DockerSuite) TestContainerWithConflictingHostNetworks(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
// Run a container with --net=host
dockerCmd(c, "run", "-d", "--net=host", "--name=first", "busybox", "top")
- c.Assert(waitRun("first"), check.IsNil)
+ assert.Assert(c, waitRun("first") == nil)
// Create a network using bridge driver
dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1")
@@ -3578,13 +3575,13 @@
assert.ErrorContains(c, err, "")
}
-func (s *DockerSuite) TestContainerWithConflictingSharedNetwork(c *check.C) {
+func (s *DockerSuite) TestContainerWithConflictingSharedNetwork(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--name=first", "busybox", "top")
- c.Assert(waitRun("first"), check.IsNil)
+ assert.Assert(c, waitRun("first") == nil)
// Run second container in first container's network namespace
dockerCmd(c, "run", "-d", "--net=container:first", "--name=second", "busybox", "top")
- c.Assert(waitRun("second"), check.IsNil)
+ assert.Assert(c, waitRun("second") == nil)
// Create a network using bridge driver
dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1")
@@ -3592,13 +3589,13 @@
// Connecting to the user defined network must fail
out, _, err := dockerCmdWithError("network", "connect", "testnetwork1", "second")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, runconfig.ErrConflictSharedNetwork.Error())
+ assert.Assert(c, strings.Contains(out, runconfig.ErrConflictSharedNetwork.Error()))
}
-func (s *DockerSuite) TestContainerWithConflictingNoneNetwork(c *check.C) {
+func (s *DockerSuite) TestContainerWithConflictingNoneNetwork(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--net=none", "--name=first", "busybox", "top")
- c.Assert(waitRun("first"), check.IsNil)
+ assert.Assert(c, waitRun("first") == nil)
// Create a network using bridge driver
dockerCmd(c, "network", "create", "-d", "bridge", "testnetwork1")
@@ -3606,11 +3603,10 @@
// Connecting to the user defined network must fail
out, _, err := dockerCmdWithError("network", "connect", "testnetwork1", "first")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, runconfig.ErrConflictNoNetwork.Error())
-
+ assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNoNetwork.Error()))
// create a container connected to testnetwork1
dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=second", "busybox", "top")
- c.Assert(waitRun("second"), check.IsNil)
+ assert.Assert(c, waitRun("second") == nil)
// Connect second container to none network. it must fail as well
_, _, err = dockerCmdWithError("network", "connect", "none", "second")
@@ -3618,7 +3614,7 @@
}
// #11957 - stdin with no tty does not exit if stdin is not closed even though container exited
-func (s *DockerSuite) TestRunStdinBlockedAfterContainerExit(c *check.C) {
+func (s *DockerSuite) TestRunStdinBlockedAfterContainerExit(c *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-i", "--name=test", "busybox", "true")
in, err := cmd.StdinPipe()
assert.NilError(c, err)
@@ -3626,7 +3622,7 @@
stdout := bytes.NewBuffer(nil)
cmd.Stdout = stdout
cmd.Stderr = stdout
- c.Assert(cmd.Start(), check.IsNil)
+ assert.Assert(c, cmd.Start() == nil)
waitChan := make(chan error)
go func() {
@@ -3635,13 +3631,13 @@
select {
case err := <-waitChan:
- c.Assert(err, check.IsNil, check.Commentf(stdout.String()))
+ assert.Assert(c, err == nil, stdout.String())
case <-time.After(30 * time.Second):
c.Fatal("timeout waiting for command to exit")
}
}
-func (s *DockerSuite) TestRunWrongCpusetCpusFlagValue(c *check.C) {
+func (s *DockerSuite) TestRunWrongCpusetCpusFlagValue(c *testing.T) {
// TODO Windows: This needs validation (error out) in the daemon.
testRequires(c, DaemonIsLinux)
out, exitCode, err := dockerCmdWithError("run", "--cpuset-cpus", "1-10,11--", "busybox", "true")
@@ -3652,7 +3648,7 @@
}
}
-func (s *DockerSuite) TestRunWrongCpusetMemsFlagValue(c *check.C) {
+func (s *DockerSuite) TestRunWrongCpusetMemsFlagValue(c *testing.T) {
// TODO Windows: This needs validation (error out) in the daemon.
testRequires(c, DaemonIsLinux)
out, exitCode, err := dockerCmdWithError("run", "--cpuset-mems", "1-42--", "busybox", "true")
@@ -3664,7 +3660,7 @@
}
// TestRunNonExecutableCmd checks that 'docker run busybox foo' exits with error code 127'
-func (s *DockerSuite) TestRunNonExecutableCmd(c *check.C) {
+func (s *DockerSuite) TestRunNonExecutableCmd(c *testing.T) {
name := "testNonExecutableCmd"
icmd.RunCommand(dockerBinary, "run", "--name", name, "busybox", "foo").Assert(c, icmd.Expected{
ExitCode: 127,
@@ -3673,7 +3669,7 @@
}
// TestRunNonExistingCmd checks that 'docker run busybox /bin/foo' exits with code 127.
-func (s *DockerSuite) TestRunNonExistingCmd(c *check.C) {
+func (s *DockerSuite) TestRunNonExistingCmd(c *testing.T) {
name := "testNonExistingCmd"
icmd.RunCommand(dockerBinary, "run", "--name", name, "busybox", "/bin/foo").Assert(c, icmd.Expected{
ExitCode: 127,
@@ -3684,7 +3680,7 @@
// TestCmdCannotBeInvoked checks that 'docker run busybox /etc' exits with 126, or
// 127 on Windows. The difference is that in Windows, the container must be started
// as that's when the check is made (and yes, by its design...)
-func (s *DockerSuite) TestCmdCannotBeInvoked(c *check.C) {
+func (s *DockerSuite) TestCmdCannotBeInvoked(c *testing.T) {
expected := 126
if testEnv.OSType == "windows" {
expected = 127
@@ -3698,7 +3694,7 @@
// TestRunNonExistingImage checks that 'docker run foo' exits with error msg 125 and contains 'Unable to find image'
// FIXME(vdemeester) should be a unit test
-func (s *DockerSuite) TestRunNonExistingImage(c *check.C) {
+func (s *DockerSuite) TestRunNonExistingImage(c *testing.T) {
icmd.RunCommand(dockerBinary, "run", "foo").Assert(c, icmd.Expected{
ExitCode: 125,
Err: "Unable to find image",
@@ -3707,7 +3703,7 @@
// TestDockerFails checks that 'docker run -foo busybox' exits with 125 to signal docker run failed
// FIXME(vdemeester) should be a unit test
-func (s *DockerSuite) TestDockerFails(c *check.C) {
+func (s *DockerSuite) TestDockerFails(c *testing.T) {
icmd.RunCommand(dockerBinary, "run", "-foo", "busybox").Assert(c, icmd.Expected{
ExitCode: 125,
Error: "exit status 125",
@@ -3715,7 +3711,7 @@
}
// TestRunInvalidReference invokes docker run with a bad reference.
-func (s *DockerSuite) TestRunInvalidReference(c *check.C) {
+func (s *DockerSuite) TestRunInvalidReference(c *testing.T) {
out, exit, _ := dockerCmdWithError("run", "busybox@foo")
if exit == 0 {
c.Fatalf("expected non-zero exist code; received %d", exit)
@@ -3727,7 +3723,7 @@
}
// Test fix for issue #17854
-func (s *DockerSuite) TestRunInitLayerPathOwnership(c *check.C) {
+func (s *DockerSuite) TestRunInitLayerPathOwnership(c *testing.T) {
// Not applicable on Windows as it does not support Linux uid/gid ownership
testRequires(c, DaemonIsLinux)
name := "testetcfileownership"
@@ -3744,7 +3740,7 @@
}
}
-func (s *DockerSuite) TestRunWithOomScoreAdj(c *check.C) {
+func (s *DockerSuite) TestRunWithOomScoreAdj(c *testing.T) {
testRequires(c, DaemonIsLinux)
expected := "642"
@@ -3755,7 +3751,7 @@
}
}
-func (s *DockerSuite) TestRunWithOomScoreAdjInvalidRange(c *check.C) {
+func (s *DockerSuite) TestRunWithOomScoreAdjInvalidRange(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _, err := dockerCmdWithError("run", "--oom-score-adj", "1001", "busybox", "true")
@@ -3772,7 +3768,7 @@
}
}
-func (s *DockerSuite) TestRunVolumesMountedAsShared(c *check.C) {
+func (s *DockerSuite) TestRunVolumesMountedAsShared(c *testing.T) {
// Volume propagation is linux only. Also it creates directories for
// bind mounting, so needs to be same host.
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon, NotUserNamespace)
@@ -3803,7 +3799,7 @@
mount.Unmount(path.Join(tmpDir, "mnt1"))
}
-func (s *DockerSuite) TestRunVolumesMountedAsSlave(c *check.C) {
+func (s *DockerSuite) TestRunVolumesMountedAsSlave(c *testing.T) {
// Volume propagation is linux only. Also it creates directories for
// bind mounting, so needs to be same host.
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon, NotUserNamespace)
@@ -3852,14 +3848,14 @@
}
}
-func (s *DockerSuite) TestRunNamedVolumesMountedAsShared(c *check.C) {
+func (s *DockerSuite) TestRunNamedVolumesMountedAsShared(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
out, exitCode, _ := dockerCmdWithError("run", "-v", "foo:/test:shared", "busybox", "touch", "/test/somefile")
- c.Assert(exitCode, checker.Not(checker.Equals), 0)
- c.Assert(out, checker.Contains, "invalid mount config")
+ assert.Assert(c, exitCode != 0)
+ assert.Assert(c, strings.Contains(out, "invalid mount config"))
}
-func (s *DockerSuite) TestRunNamedVolumeCopyImageData(c *check.C) {
+func (s *DockerSuite) TestRunNamedVolumeCopyImageData(c *testing.T) {
testRequires(c, DaemonIsLinux)
testImg := "testvolumecopy"
@@ -3870,10 +3866,10 @@
dockerCmd(c, "run", "-v", "foo:/foo", testImg)
out, _ := dockerCmd(c, "run", "-v", "foo:/foo", "busybox", "cat", "/foo/hello")
- c.Assert(strings.TrimSpace(out), check.Equals, "hello")
+ assert.Equal(c, strings.TrimSpace(out), "hello")
}
-func (s *DockerSuite) TestRunNamedVolumeNotRemoved(c *check.C) {
+func (s *DockerSuite) TestRunNamedVolumeNotRemoved(c *testing.T) {
prefix, _ := getPrefixAndSlashFromDaemonPlatform()
dockerCmd(c, "volume", "create", "test")
@@ -3890,7 +3886,7 @@
assert.Assert(c, strings.Contains(out, "test"))
}
-func (s *DockerSuite) TestRunNamedVolumesFromNotRemoved(c *check.C) {
+func (s *DockerSuite) TestRunNamedVolumesFromNotRemoved(c *testing.T) {
prefix, _ := getPrefixAndSlashFromDaemonPlatform()
dockerCmd(c, "volume", "create", "test")
@@ -3909,7 +3905,7 @@
vname = v.Name
}
}
- c.Assert(vname, checker.Not(checker.Equals), "")
+ assert.Assert(c, vname != "")
// Remove the parent so there are not other references to the volumes
dockerCmd(c, "rm", "-f", "parent")
@@ -3918,10 +3914,10 @@
dockerCmd(c, "volume", "inspect", "test")
out, _ := dockerCmd(c, "volume", "ls", "-q")
assert.Assert(c, strings.Contains(out, "test"))
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), vname)
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), vname))
}
-func (s *DockerSuite) TestRunAttachFailedNoLeak(c *check.C) {
+func (s *DockerSuite) TestRunAttachFailedNoLeak(c *testing.T) {
// TODO @msabansal - https://github.com/moby/moby/issues/35023. Duplicate
// port mappings are not errored out on RS3 builds. Temporarily disabling
// this test pending further investigation. Note we parse kernel.GetKernelVersion
@@ -3942,35 +3938,35 @@
runSleepingContainer(c, "--name=test", "-p", "8000:8000")
// Wait until container is fully up and running
- c.Assert(waitRun("test"), check.IsNil)
+ assert.Assert(c, waitRun("test") == nil)
out, _, err := dockerCmdWithError("run", "--name=fail", "-p", "8000:8000", "busybox", "true")
// We will need the following `inspect` to diagnose the issue if test fails (#21247)
out1, err1 := dockerCmd(c, "inspect", "--format", "{{json .State}}", "test")
out2, err2 := dockerCmd(c, "inspect", "--format", "{{json .State}}", "fail")
- c.Assert(err, checker.NotNil, check.Commentf("Command should have failed but succeeded with: %s\nContainer 'test' [%+v]: %s\nContainer 'fail' [%+v]: %s", out, err1, out1, err2, out2))
+ assert.Assert(c, err != nil, "Command should have failed but succeeded with: %s\nContainer 'test' [%+v]: %s\nContainer 'fail' [%+v]: %s", out, err1, out1, err2, out2)
// check for windows error as well
// TODO Windows Post TP5. Fix the error message string
- c.Assert(strings.Contains(string(out), "port is already allocated") ||
+ assert.Assert(c, strings.Contains(string(out), "port is already allocated") ||
strings.Contains(string(out), "were not connected because a duplicate name exists") ||
strings.Contains(string(out), "The specified port already exists") ||
strings.Contains(string(out), "HNS failed with error : Failed to create endpoint") ||
- strings.Contains(string(out), "HNS failed with error : The object already exists"), checker.Equals, true, check.Commentf("Output: %s", out))
+ strings.Contains(string(out), "HNS failed with error : The object already exists"), fmt.Sprintf("Output: %s", out))
dockerCmd(c, "rm", "-f", "test")
// NGoroutines is not updated right away, so we need to wait before failing
- c.Assert(waitForGoroutines(nroutines), checker.IsNil)
+ assert.Assert(c, waitForGoroutines(nroutines) == nil)
}
// Test for one character directory name case (#20122)
-func (s *DockerSuite) TestRunVolumeWithOneCharacter(c *check.C) {
+func (s *DockerSuite) TestRunVolumeWithOneCharacter(c *testing.T) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-v", "/tmp/q:/foo", "busybox", "sh", "-c", "find /foo")
assert.Equal(c, strings.TrimSpace(out), "/foo")
}
-func (s *DockerSuite) TestRunVolumeCopyFlag(c *check.C) {
+func (s *DockerSuite) TestRunVolumeCopyFlag(c *testing.T) {
testRequires(c, DaemonIsLinux) // Windows does not support copying data from image to the volume
buildImageSuccessfully(c, "volumecopy", build.WithDockerfile(`FROM busybox
RUN mkdir /foo && echo hello > /foo/bar
@@ -4005,7 +4001,7 @@
}
// Test case for #21976
-func (s *DockerSuite) TestRunDNSInHostMode(c *check.C) {
+func (s *DockerSuite) TestRunDNSInHostMode(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
expectedOutput := "nameserver 127.0.0.1"
@@ -4034,31 +4030,31 @@
expectedOutput2 := "search example.com"
expectedOutput3 := "options timeout:3"
out := cli.DockerCmd(c, "run", "--dns=1.2.3.4", "--dns-search=example.com", "--dns-opt=timeout:3", "--net=host", "busybox", "cat", "/etc/resolv.conf").Combined()
- c.Assert(out, checker.Contains, expectedOutput1, check.Commentf("Expected '%s', but got %q", expectedOutput1, out))
- c.Assert(out, checker.Contains, expectedOutput2, check.Commentf("Expected '%s', but got %q", expectedOutput2, out))
- c.Assert(out, checker.Contains, expectedOutput3, check.Commentf("Expected '%s', but got %q", expectedOutput3, out))
+ assert.Assert(c, strings.Contains(out, expectedOutput1), "Expected '%s', but got %q", expectedOutput1, out)
+ assert.Assert(c, strings.Contains(out, expectedOutput2), "Expected '%s', but got %q", expectedOutput2, out)
+ assert.Assert(c, strings.Contains(out, expectedOutput3), "Expected '%s', but got %q", expectedOutput3, out)
}
// Test case for #21976
-func (s *DockerSuite) TestRunAddHostInHostMode(c *check.C) {
+func (s *DockerSuite) TestRunAddHostInHostMode(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
expectedOutput := "1.2.3.4\textra"
out, _ := dockerCmd(c, "run", "--add-host=extra:1.2.3.4", "--net=host", "busybox", "cat", "/etc/hosts")
- c.Assert(out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
+ assert.Assert(c, strings.Contains(out, expectedOutput), "Expected '%s', but got %q", expectedOutput, out)
}
-func (s *DockerSuite) TestRunRmAndWait(c *check.C) {
+func (s *DockerSuite) TestRunRmAndWait(c *testing.T) {
dockerCmd(c, "run", "--name=test", "--rm", "-d", "busybox", "sh", "-c", "sleep 3;exit 2")
out, code, err := dockerCmdWithError("wait", "test")
- c.Assert(err, checker.IsNil, check.Commentf("out: %s; exit code: %d", out, code))
+ assert.Assert(c, err == nil, "out: %s; exit code: %d", out, code)
assert.Equal(c, out, "2\n", "exit code: %d", code)
- c.Assert(code, checker.Equals, 0)
+ assert.Equal(c, code, 0)
}
// Test that auto-remove is performed by the daemon (API 1.25 and above)
-func (s *DockerSuite) TestRunRm(c *check.C) {
+func (s *DockerSuite) TestRunRm(c *testing.T) {
name := "miss-me-when-im-gone"
cli.DockerCmd(c, "run", "--name="+name, "--rm", "busybox")
@@ -4069,7 +4065,7 @@
}
// Test that auto-remove is performed by the client on API versions that do not support daemon-side api-remove (API < 1.25)
-func (s *DockerSuite) TestRunRmPre125Api(c *check.C) {
+func (s *DockerSuite) TestRunRmPre125Api(c *testing.T) {
name := "miss-me-when-im-gone"
envs := appendBaseEnv(os.Getenv("DOCKER_TLS_VERIFY") != "", "DOCKER_API_VERSION=1.24")
cli.Docker(cli.Args("run", "--name="+name, "--rm", "busybox"), cli.WithEnvironmentVariables(envs...)).Assert(c, icmd.Success)
@@ -4081,7 +4077,7 @@
}
// Test case for #23498
-func (s *DockerSuite) TestRunUnsetEntrypoint(c *check.C) {
+func (s *DockerSuite) TestRunUnsetEntrypoint(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "test-entrypoint"
dockerfile := `FROM busybox
@@ -4102,7 +4098,7 @@
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
out := cli.DockerCmd(c, "run", "--entrypoint=", "-t", name, "echo", "foo").Combined()
- c.Assert(strings.TrimSpace(out), check.Equals, "foo")
+ assert.Equal(c, strings.TrimSpace(out), "foo")
// CMD will be reset as well (the same as setting a custom entrypoint)
cli.Docker(cli.Args("run", "--entrypoint=", "-t", name)).Assert(c, icmd.Expected{
@@ -4111,7 +4107,7 @@
})
}
-func (s *DockerDaemonSuite) TestRunWithUlimitAndDaemonDefault(c *check.C) {
+func (s *DockerDaemonSuite) TestRunWithUlimitAndDaemonDefault(c *testing.T) {
s.d.StartWithBusybox(c, "--debug", "--default-ulimit=nofile=65535")
name := "test-A"
@@ -4121,8 +4117,7 @@
out, err := s.d.Cmd("inspect", "--format", "{{.HostConfig.Ulimits}}", name)
assert.NilError(c, err)
- c.Assert(out, checker.Contains, "[nofile=65535:65535]")
-
+ assert.Assert(c, strings.Contains(out, "[nofile=65535:65535]"))
name = "test-B"
_, err = s.d.Cmd("run", "--name", name, "--ulimit=nofile=42", "-d", "busybox", "top")
assert.NilError(c, err)
@@ -4133,21 +4128,20 @@
assert.Assert(c, strings.Contains(out, "[nofile=42:42]"))
}
-func (s *DockerSuite) TestRunStoppedLoggingDriverNoLeak(c *check.C) {
+func (s *DockerSuite) TestRunStoppedLoggingDriverNoLeak(c *testing.T) {
nroutines, err := getGoroutineNumber()
assert.NilError(c, err)
out, _, err := dockerCmdWithError("run", "--name=fail", "--log-driver=splunk", "busybox", "true")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "failed to initialize logging driver", check.Commentf("error should be about logging driver, got output %s", out))
-
+ assert.Assert(c, strings.Contains(out, "failed to initialize logging driver"), "error should be about logging driver, got output %s", out)
// NGoroutines is not updated right away, so we need to wait before failing
- c.Assert(waitForGoroutines(nroutines), checker.IsNil)
+ assert.Assert(c, waitForGoroutines(nroutines) == nil)
}
// Handles error conditions for --credentialspec. Validating E2E success cases
// requires additional infrastructure (AD for example) on CI servers.
-func (s *DockerSuite) TestRunCredentialSpecFailures(c *check.C) {
+func (s *DockerSuite) TestRunCredentialSpecFailures(c *testing.T) {
testRequires(c, DaemonIsWindows)
attempts := []struct{ value, expectedError string }{
@@ -4160,13 +4154,13 @@
}
for _, attempt := range attempts {
_, _, err := dockerCmdWithError("run", "--security-opt=credentialspec="+attempt.value, "busybox", "true")
- c.Assert(err, checker.NotNil, check.Commentf("%s expected non-nil err", attempt.value))
- c.Check(err.Error(), checker.Contains, attempt.expectedError, check.Commentf("%s expected %s got %s", attempt.value, attempt.expectedError, err))
+ assert.Assert(c, err != nil, "%s expected non-nil err", attempt.value)
+ assert.Assert(c, strings.Contains(err.Error(), attempt.expectedError), "%s expected %s got %s", attempt.value, attempt.expectedError, err)
}
}
// Windows specific test to validate credential specs with a well-formed spec.
-func (s *DockerSuite) TestRunCredentialSpecWellFormed(c *check.C) {
+func (s *DockerSuite) TestRunCredentialSpecWellFormed(c *testing.T) {
testRequires(c, DaemonIsWindows, testEnv.IsLocalDaemon)
validCredSpecs := readFile(`fixtures\credentialspecs\valid.json`, c)
@@ -4177,12 +4171,12 @@
// controller handy
out, _ := dockerCmd(c, "run", "--rm", "--security-opt=credentialspec="+value, minimalBaseImage(), "nltest", "/PARENTDOMAIN")
- c.Check(out, checker.Contains, "hyperv.local.")
- c.Check(out, checker.Contains, "The command completed successfully")
+ assert.Assert(c, strings.Contains(out, "hyperv.local."))
+ assert.Assert(c, strings.Contains(out, "The command completed successfully"))
}
}
-func (s *DockerSuite) TestRunDuplicateMount(c *check.C) {
+func (s *DockerSuite) TestRunDuplicateMount(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace)
tmpFile, err := ioutil.TempFile("", "touch-me")
@@ -4196,14 +4190,13 @@
name := "test"
out, _ := dockerCmd(c, "run", "--name", name, "-v", "/tmp:/tmp", "-v", "/tmp:/tmp", "busybox", "sh", "-c", "cat "+tmpFile.Name()+" && ls /")
- c.Assert(out, checker.Not(checker.Contains), "tmp:")
- c.Assert(out, checker.Contains, data)
-
+ assert.Assert(c, !strings.Contains(out, "tmp:"))
+ assert.Assert(c, strings.Contains(out, data))
out = inspectFieldJSON(c, name, "Config.Volumes")
- c.Assert(out, checker.Contains, "null")
+ assert.Assert(c, strings.Contains(out, "null"))
}
-func (s *DockerSuite) TestRunWindowsWithCPUCount(c *check.C) {
+func (s *DockerSuite) TestRunWindowsWithCPUCount(c *testing.T) {
testRequires(c, DaemonIsWindows)
out, _ := dockerCmd(c, "run", "--cpu-count=1", "--name", "test", "busybox", "echo", "testing")
@@ -4213,7 +4206,7 @@
assert.Equal(c, out, "1")
}
-func (s *DockerSuite) TestRunWindowsWithCPUShares(c *check.C) {
+func (s *DockerSuite) TestRunWindowsWithCPUShares(c *testing.T) {
testRequires(c, DaemonIsWindows)
out, _ := dockerCmd(c, "run", "--cpu-shares=1000", "--name", "test", "busybox", "echo", "testing")
@@ -4223,7 +4216,7 @@
assert.Equal(c, out, "1000")
}
-func (s *DockerSuite) TestRunWindowsWithCPUPercent(c *check.C) {
+func (s *DockerSuite) TestRunWindowsWithCPUPercent(c *testing.T) {
testRequires(c, DaemonIsWindows)
out, _ := dockerCmd(c, "run", "--cpu-percent=80", "--name", "test", "busybox", "echo", "testing")
@@ -4233,14 +4226,13 @@
assert.Equal(c, out, "80")
}
-func (s *DockerSuite) TestRunProcessIsolationWithCPUCountCPUSharesAndCPUPercent(c *check.C) {
- testRequires(c, DaemonIsWindows, IsolationIsProcess)
+func (s *DockerSuite) TestRunProcessIsolationWithCPUCountCPUSharesAndCPUPercent(c *testing.T) {
+ testRequires(c, IsolationIsProcess)
out, _ := dockerCmd(c, "run", "--cpu-count=1", "--cpu-shares=1000", "--cpu-percent=80", "--name", "test", "busybox", "echo", "testing")
- c.Assert(strings.TrimSpace(out), checker.Contains, "WARNING: Conflicting options: CPU count takes priority over CPU shares on Windows Server Containers. CPU shares discarded")
- c.Assert(strings.TrimSpace(out), checker.Contains, "WARNING: Conflicting options: CPU count takes priority over CPU percent on Windows Server Containers. CPU percent discarded")
- c.Assert(strings.TrimSpace(out), checker.Contains, "testing")
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), "WARNING: Conflicting options: CPU count takes priority over CPU shares on Windows Server Containers. CPU shares discarded"))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), "WARNING: Conflicting options: CPU count takes priority over CPU percent on Windows Server Containers. CPU percent discarded"))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), "testing"))
out = inspectField(c, "test", "HostConfig.CPUCount")
assert.Equal(c, out, "1")
@@ -4251,12 +4243,11 @@
assert.Equal(c, out, "0")
}
-func (s *DockerSuite) TestRunHypervIsolationWithCPUCountCPUSharesAndCPUPercent(c *check.C) {
- testRequires(c, DaemonIsWindows, IsolationIsHyperv)
+func (s *DockerSuite) TestRunHypervIsolationWithCPUCountCPUSharesAndCPUPercent(c *testing.T) {
+ testRequires(c, IsolationIsHyperv)
out, _ := dockerCmd(c, "run", "--cpu-count=1", "--cpu-shares=1000", "--cpu-percent=80", "--name", "test", "busybox", "echo", "testing")
- c.Assert(strings.TrimSpace(out), checker.Contains, "testing")
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), "testing"))
out = inspectField(c, "test", "HostConfig.CPUCount")
assert.Equal(c, out, "1")
@@ -4268,7 +4259,7 @@
}
// Test for #25099
-func (s *DockerSuite) TestRunEmptyEnv(c *check.C) {
+func (s *DockerSuite) TestRunEmptyEnv(c *testing.T) {
testRequires(c, DaemonIsLinux)
expectedOutput := "invalid environment variable:"
@@ -4287,7 +4278,7 @@
}
// #28658
-func (s *DockerSuite) TestSlowStdinClosing(c *check.C) {
+func (s *DockerSuite) TestSlowStdinClosing(c *testing.T) {
name := "testslowstdinclosing"
repeat := 3 // regression happened 50% of the time
for i := 0; i < repeat; i++ {
@@ -4318,7 +4309,7 @@
}
// #28823 (originally #28639)
-func (s *DockerSuite) TestRunMountReadOnlyDevShm(c *check.C) {
+func (s *DockerSuite) TestRunMountReadOnlyDevShm(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux, NotUserNamespace)
emptyDir, err := ioutil.TempDir("", "test-read-only-dev-shm")
assert.NilError(c, err)
@@ -4327,10 +4318,10 @@
"-v", fmt.Sprintf("%s:/dev/shm:ro", emptyDir),
"busybox", "touch", "/dev/shm/foo")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "Read-only file system")
+ assert.Assert(c, strings.Contains(out, "Read-only file system"))
}
-func (s *DockerSuite) TestRunMount(c *check.C) {
+func (s *DockerSuite) TestRunMount(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon, NotUserNamespace)
// mnt1, mnt2, and testCatFooBar are commonly used in multiple test cases
@@ -4495,14 +4486,11 @@
_, _, err := dockerCmdWithError(append([]string{"run", "-i", "-d", "--name", cName},
append(opts, []string{"busybox", "top"}...)...)...)
if testCase.valid {
- c.Assert(err, check.IsNil,
- check.Commentf("got error while creating a container with %v (%s)", opts, cName))
- c.Assert(testCase.fn(cName), check.IsNil,
- check.Commentf("got error while executing test for %v (%s)", opts, cName))
+ assert.Assert(c, err == nil, "got error while creating a container with %v (%s)", opts, cName)
+ assert.Assert(c, testCase.fn(cName) == nil, "got error while executing test for %v (%s)", opts, cName)
dockerCmd(c, "rm", "-f", cName)
} else {
- c.Assert(err, checker.NotNil,
- check.Commentf("got nil while creating a container with %v (%s)", opts, cName))
+ assert.Assert(c, err != nil, "got nil while creating a container with %v (%s)", opts, cName)
}
}
}
@@ -4510,7 +4498,7 @@
// Test that passing a FQDN as hostname properly sets hostname, and
// /etc/hostname. Test case for 29100
-func (s *DockerSuite) TestRunHostnameFQDN(c *check.C) {
+func (s *DockerSuite) TestRunHostnameFQDN(c *testing.T) {
testRequires(c, DaemonIsLinux)
expectedOutput := "foobar.example.com\nfoobar.example.com\nfoobar\nexample.com\nfoobar.example.com"
@@ -4519,11 +4507,11 @@
out, _ = dockerCmd(c, "run", "--hostname=foobar.example.com", "busybox", "sh", "-c", `cat /etc/hosts`)
expectedOutput = "foobar.example.com foobar"
- c.Assert(strings.TrimSpace(out), checker.Contains, expectedOutput)
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), expectedOutput))
}
// Test case for 29129
-func (s *DockerSuite) TestRunHostnameInHostMode(c *check.C) {
+func (s *DockerSuite) TestRunHostnameInHostMode(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
expectedOutput := "foobar\nfoobar"
@@ -4531,7 +4519,7 @@
assert.Equal(c, strings.TrimSpace(out), expectedOutput)
}
-func (s *DockerSuite) TestRunAddDeviceCgroupRule(c *check.C) {
+func (s *DockerSuite) TestRunAddDeviceCgroupRule(c *testing.T) {
testRequires(c, DaemonIsLinux)
deviceRule := "c 7:128 rwm"
@@ -4546,7 +4534,7 @@
}
// Verifies that running as local system is operating correctly on Windows
-func (s *DockerSuite) TestWindowsRunAsSystem(c *check.C) {
+func (s *DockerSuite) TestWindowsRunAsSystem(c *testing.T) {
testRequires(c, DaemonIsWindowsAtLeastBuild(15000))
out, _ := dockerCmd(c, "run", "--net=none", `--user=nt authority\system`, "--hostname=XYZZY", minimalBaseImage(), "cmd", "/c", `@echo %USERNAME%`)
assert.Equal(c, strings.TrimSpace(out), "XYZZY$")
diff --git a/integration-cli/docker_cli_run_unix_test.go b/integration-cli/docker_cli_run_unix_test.go
index 1675418..dc250a1 100644
--- a/integration-cli/docker_cli_run_unix_test.go
+++ b/integration-cli/docker_cli_run_unix_test.go
@@ -15,27 +15,26 @@
"strconv"
"strings"
"syscall"
+ "testing"
"time"
"github.com/creack/pty"
"github.com/docker/docker/client"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/pkg/homedir"
"github.com/docker/docker/pkg/mount"
"github.com/docker/docker/pkg/parsers"
"github.com/docker/docker/pkg/sysinfo"
- "github.com/go-check/check"
"gotest.tools/assert"
"gotest.tools/icmd"
)
// #6509
-func (s *DockerSuite) TestRunRedirectStdout(c *check.C) {
+func (s *DockerSuite) TestRunRedirectStdout(c *testing.T) {
checkRedirect := func(command string) {
_, tty, err := pty.Open()
- c.Assert(err, checker.IsNil, check.Commentf("Could not open pty"))
+ assert.Assert(c, err == nil, "Could not open pty")
cmd := exec.Command("sh", "-c", command)
cmd.Stdin = tty
cmd.Stdout = tty
@@ -51,7 +50,7 @@
case <-time.After(10 * time.Second):
c.Fatal("command timeout")
case err := <-ch:
- c.Assert(err, checker.IsNil, check.Commentf("wait err"))
+ assert.Assert(c, err == nil, "wait err")
}
}
@@ -60,7 +59,7 @@
}
// 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
testRequires(c, NotUserNamespace, testEnv.IsLocalDaemon)
tmpDir, err := ioutil.TempDir("", "docker_recursive_mount_test")
@@ -70,32 +69,31 @@
// Create a temporary tmpfs mount.
tmpfsDir := filepath.Join(tmpDir, "tmpfs")
- c.Assert(os.MkdirAll(tmpfsDir, 0777), checker.IsNil, check.Commentf("failed to mkdir at %s", tmpfsDir))
- c.Assert(mount.Mount("tmpfs", tmpfsDir, "tmpfs", ""), checker.IsNil, check.Commentf("failed to create a tmpfs mount at %s", tmpfsDir))
+ assert.Assert(c, os.MkdirAll(tmpfsDir, 0777) == nil, "failed to mkdir at %s", tmpfsDir)
+ assert.Assert(c, mount.Mount("tmpfs", tmpfsDir, "tmpfs", "") == nil, "failed to create a tmpfs mount at %s", tmpfsDir)
f, err := ioutil.TempFile(tmpfsDir, "touch-me")
assert.NilError(c, err)
defer f.Close()
out, _ := dockerCmd(c, "run", "--name", "test-data", "--volume", fmt.Sprintf("%s:/tmp:ro", tmpDir), "busybox:latest", "ls", "/tmp/tmpfs")
- c.Assert(out, checker.Contains, filepath.Base(f.Name()), check.Commentf("Recursive bind mount test failed. Expected file not found"))
+ assert.Assert(c, strings.Contains(out, filepath.Base(f.Name())), "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)
if _, err := os.Stat("/dev/snd"); err != nil {
c.Skip("Host does not have /dev/snd")
}
out, _ := dockerCmd(c, "run", "--device", "/dev/snd:/dev/snd", "busybox", "sh", "-c", "ls /dev/snd/")
- c.Assert(strings.Trim(out, "\r\n"), checker.Contains, "timer", check.Commentf("expected output /dev/snd/timer"))
-
+ assert.Assert(c, strings.Contains(strings.Trim(out, "\r\n"), "timer"), "expected output /dev/snd/timer")
out, _ = dockerCmd(c, "run", "--device", "/dev/snd:/dev/othersnd", "busybox", "sh", "-c", "ls /dev/othersnd/")
- c.Assert(strings.Trim(out, "\r\n"), checker.Contains, "seq", check.Commentf("expected output /dev/othersnd/seq"))
+ assert.Assert(c, strings.Contains(strings.Trim(out, "\r\n"), "seq"), "expected output /dev/othersnd/seq")
}
// 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"
dockerCmd(c, "run", "--name", name, "-itd", "busybox", "cat")
@@ -108,7 +106,7 @@
defer cpty.Close()
cmd.Stdin = tty
assert.NilError(c, cmd.Start())
- c.Assert(waitRun(name), check.IsNil)
+ assert.Assert(c, waitRun(name) == nil)
_, err = cpty.Write([]byte("hello\n"))
assert.NilError(c, err)
@@ -137,16 +135,16 @@
}
running := inspectField(c, name, "State.Running")
- c.Assert(running, checker.Equals, "true", check.Commentf("expected container to still be running"))
+ assert.Equal(c, running, "true", "expected container to still be running")
out, _ = dockerCmd(c, "events", "--since=0", "--until", daemonUnixTime(c), "-f", "container="+name)
// attach and detach event should be monitored
- c.Assert(out, checker.Contains, "attach")
- c.Assert(out, checker.Contains, "detach")
+ assert.Assert(c, strings.Contains(out, "attach"))
+ assert.Assert(c, strings.Contains(out, "detach"))
}
// 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"
keyCtrlA := []byte{1}
keyA := []byte{97}
@@ -167,7 +165,7 @@
if err := cmd.Start(); err != nil {
c.Fatal(err)
}
- c.Assert(waitRun(name), check.IsNil)
+ assert.Assert(c, waitRun(name) == nil)
if _, err := cpty.Write([]byte("hello\n")); err != nil {
c.Fatal(err)
@@ -203,14 +201,14 @@
}
running := inspectField(c, name, "State.Running")
- c.Assert(running, checker.Equals, "true", check.Commentf("expected container to still be running"))
+ assert.Equal(c, running, "true", "expected container to still be running")
}
// 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"
dockerCmd(c, "run", "--name", name, "-itd", "busybox", "top")
- c.Assert(waitRun(name), check.IsNil)
+ assert.Assert(c, waitRun(name) == nil)
// specify an invalid detach key, container will ignore it and use default
cmd := exec.Command(dockerBinary, "attach", "--detach-keys=ctrl-A,a", name)
@@ -240,7 +238,7 @@
}
// 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}
keyA := []byte{97}
@@ -283,7 +281,7 @@
if err := cmd.Start(); err != nil {
c.Fatal(err)
}
- c.Assert(waitRun(name), check.IsNil)
+ assert.Assert(c, waitRun(name) == nil)
if _, err := cpty.Write([]byte("hello\n")); err != nil {
c.Fatal(err)
@@ -319,11 +317,11 @@
}
running := inspectField(c, name, "State.Running")
- c.Assert(running, checker.Equals, "true", check.Commentf("expected container to still be running"))
+ assert.Equal(c, running, "true", "expected container to still be running")
}
// 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}
keyA := []byte{97}
@@ -366,7 +364,7 @@
if err := cmd.Start(); err != nil {
c.Fatal(err)
}
- c.Assert(waitRun(name), check.IsNil)
+ assert.Assert(c, waitRun(name) == nil)
if _, err := cpty.Write([]byte("hello\n")); err != nil {
c.Fatal(err)
@@ -402,10 +400,10 @@
}
running := inspectField(c, name, "State.Running")
- c.Assert(running, checker.Equals, "true", check.Commentf("expected container to still be running"))
+ assert.Equal(c, running, "true", "expected container to still be running")
}
-func (s *DockerSuite) TestRunAttachInvalidDetachKeySequencePreserved(c *check.C) {
+func (s *DockerSuite) TestRunAttachInvalidDetachKeySequencePreserved(c *testing.T) {
name := "attach-detach"
keyA := []byte{97}
keyB := []byte{98}
@@ -427,7 +425,7 @@
c.Fatal(err)
}
go cmd.Wait()
- c.Assert(waitRun(name), check.IsNil)
+ assert.Assert(c, waitRun(name) == nil)
// Invalid escape sequence aba, should print aba in output
if _, err := cpty.Write(keyA); err != nil {
@@ -456,7 +454,7 @@
}
// "test" should be printed
-func (s *DockerSuite) TestRunWithCPUQuota(c *check.C) {
+func (s *DockerSuite) TestRunWithCPUQuota(c *testing.T) {
testRequires(c, cpuCfsQuota)
file := "/sys/fs/cgroup/cpu/cpu.cfs_quota_us"
@@ -467,7 +465,7 @@
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)
file := "/sys/fs/cgroup/cpu/cpu.cfs_period_us"
@@ -481,7 +479,7 @@
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)
out, _, err := dockerCmdWithError("run", "--cpu-period", "900", "busybox", "true")
assert.ErrorContains(c, err, "")
@@ -497,7 +495,7 @@
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)
file := "/sys/fs/cgroup/memory/memory.kmem.limit_in_bytes"
@@ -510,7 +508,7 @@
})
}
-func (s *DockerSuite) TestRunWithInvalidKernelMemory(c *check.C) {
+func (s *DockerSuite) TestRunWithInvalidKernelMemory(c *testing.T) {
testRequires(c, DaemonIsLinux, kernelMemorySupport)
out, _, err := dockerCmdWithError("run", "--kernel-memory", "2M", "busybox", "true")
@@ -524,7 +522,7 @@
assert.Assert(c, strings.Contains(out, expected))
}
-func (s *DockerSuite) TestRunWithCPUShares(c *check.C) {
+func (s *DockerSuite) TestRunWithCPUShares(c *testing.T) {
testRequires(c, cpuShare)
file := "/sys/fs/cgroup/cpu/cpu.shares"
@@ -536,7 +534,7 @@
}
// "test" should be printed
-func (s *DockerSuite) TestRunEchoStdoutWithCPUSharesAndMemoryLimit(c *check.C) {
+func (s *DockerSuite) TestRunEchoStdoutWithCPUSharesAndMemoryLimit(c *testing.T) {
testRequires(c, cpuShare)
testRequires(c, memoryLimitSupport)
cli.DockerCmd(c, "run", "--cpu-shares", "1000", "-m", "32m", "busybox", "echo", "test").Assert(c, icmd.Expected{
@@ -544,7 +542,7 @@
})
}
-func (s *DockerSuite) TestRunWithCpusetCpus(c *check.C) {
+func (s *DockerSuite) TestRunWithCpusetCpus(c *testing.T) {
testRequires(c, cgroupCpuset)
file := "/sys/fs/cgroup/cpuset/cpuset.cpus"
@@ -555,7 +553,7 @@
assert.Equal(c, out, "0")
}
-func (s *DockerSuite) TestRunWithCpusetMems(c *check.C) {
+func (s *DockerSuite) TestRunWithCpusetMems(c *testing.T) {
testRequires(c, cgroupCpuset)
file := "/sys/fs/cgroup/cpuset/cpuset.mems"
@@ -566,7 +564,7 @@
assert.Equal(c, out, "0")
}
-func (s *DockerSuite) TestRunWithBlkioWeight(c *check.C) {
+func (s *DockerSuite) TestRunWithBlkioWeight(c *testing.T) {
testRequires(c, blkioWeight)
file := "/sys/fs/cgroup/blkio/blkio.weight"
@@ -577,7 +575,7 @@
assert.Equal(c, out, "300")
}
-func (s *DockerSuite) TestRunWithInvalidBlkioWeight(c *check.C) {
+func (s *DockerSuite) TestRunWithInvalidBlkioWeight(c *testing.T) {
testRequires(c, blkioWeight)
out, _, err := dockerCmdWithError("run", "--blkio-weight", "5", "busybox", "true")
assert.ErrorContains(c, err, "", out)
@@ -585,37 +583,37 @@
assert.Assert(c, strings.Contains(out, expected))
}
-func (s *DockerSuite) TestRunWithInvalidPathforBlkioWeightDevice(c *check.C) {
+func (s *DockerSuite) TestRunWithInvalidPathforBlkioWeightDevice(c *testing.T) {
testRequires(c, blkioWeight)
out, _, err := dockerCmdWithError("run", "--blkio-weight-device", "/dev/sdX:100", "busybox", "true")
assert.ErrorContains(c, err, "", out)
}
-func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceReadBps(c *check.C) {
+func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceReadBps(c *testing.T) {
testRequires(c, blkioWeight)
out, _, err := dockerCmdWithError("run", "--device-read-bps", "/dev/sdX:500", "busybox", "true")
assert.ErrorContains(c, err, "", out)
}
-func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceWriteBps(c *check.C) {
+func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceWriteBps(c *testing.T) {
testRequires(c, blkioWeight)
out, _, err := dockerCmdWithError("run", "--device-write-bps", "/dev/sdX:500", "busybox", "true")
assert.ErrorContains(c, err, "", out)
}
-func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceReadIOps(c *check.C) {
+func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceReadIOps(c *testing.T) {
testRequires(c, blkioWeight)
out, _, err := dockerCmdWithError("run", "--device-read-iops", "/dev/sdX:500", "busybox", "true")
assert.ErrorContains(c, err, "", out)
}
-func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceWriteIOps(c *check.C) {
+func (s *DockerSuite) TestRunWithInvalidPathforBlkioDeviceWriteIOps(c *testing.T) {
testRequires(c, blkioWeight)
out, _, err := dockerCmdWithError("run", "--device-write-iops", "/dev/sdX:500", "busybox", "true")
assert.ErrorContains(c, err, "", out)
}
-func (s *DockerSuite) TestRunOOMExitCode(c *check.C) {
+func (s *DockerSuite) TestRunOOMExitCode(c *testing.T) {
testRequires(c, memoryLimitSupport, swapMemorySupport, NotPpc64le)
errChan := make(chan error)
go func() {
@@ -635,7 +633,7 @@
}
}
-func (s *DockerSuite) TestRunWithMemoryLimit(c *check.C) {
+func (s *DockerSuite) TestRunWithMemoryLimit(c *testing.T) {
testRequires(c, memoryLimitSupport)
file := "/sys/fs/cgroup/memory/memory.limit_in_bytes"
@@ -651,14 +649,14 @@
// memory limit, this means the processes in the container can use
// 16M memory and as much swap memory as they need (if the host
// supports swap memory).
-func (s *DockerSuite) TestRunWithoutMemoryswapLimit(c *check.C) {
+func (s *DockerSuite) TestRunWithoutMemoryswapLimit(c *testing.T) {
testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport)
testRequires(c, swapMemorySupport)
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)
file := "/sys/fs/cgroup/memory/memory.swappiness"
out, _ := dockerCmd(c, "run", "--memory-swappiness", "0", "--name", "test", "busybox", "cat", file)
@@ -668,19 +666,18 @@
assert.Equal(c, out, "0")
}
-func (s *DockerSuite) TestRunWithSwappinessInvalid(c *check.C) {
+func (s *DockerSuite) TestRunWithSwappinessInvalid(c *testing.T) {
testRequires(c, memorySwappinessSupport)
out, _, err := dockerCmdWithError("run", "--memory-swappiness", "101", "busybox", "true")
assert.ErrorContains(c, err, "")
expected := "Valid memory swappiness range is 0-100"
- c.Assert(out, checker.Contains, expected, check.Commentf("Expected output to contain %q, not %q", out, expected))
-
+ assert.Assert(c, strings.Contains(out, expected), "Expected output to contain %q, not %q", out, expected)
out, _, err = dockerCmdWithError("run", "--memory-swappiness", "-10", "busybox", "true")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, expected, check.Commentf("Expected output to contain %q, not %q", out, expected))
+ assert.Assert(c, strings.Contains(out, expected), "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)
file := "/sys/fs/cgroup/memory/memory.soft_limit_in_bytes"
@@ -691,33 +688,32 @@
assert.Equal(c, out, "209715200")
}
-func (s *DockerSuite) TestRunWithMemoryReservationInvalid(c *check.C) {
+func (s *DockerSuite) TestRunWithMemoryReservationInvalid(c *testing.T) {
testRequires(c, memoryLimitSupport)
testRequires(c, testEnv.IsLocalDaemon, memoryReservationSupport)
out, _, err := dockerCmdWithError("run", "-m", "500M", "--memory-reservation", "800M", "busybox", "true")
assert.ErrorContains(c, err, "")
expected := "Minimum memory limit can not be less than memory reservation limit"
- c.Assert(strings.TrimSpace(out), checker.Contains, expected, check.Commentf("run container should fail with invalid memory reservation"))
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), expected), "run container should fail with invalid memory reservation")
out, _, err = dockerCmdWithError("run", "--memory-reservation", "1k", "busybox", "true")
assert.ErrorContains(c, err, "")
expected = "Minimum memory reservation allowed is 4MB"
- c.Assert(strings.TrimSpace(out), checker.Contains, expected, check.Commentf("run container should fail with invalid memory reservation"))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), expected), "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`)
containerID := strings.TrimSpace(out)
- c.Assert(waitRun(containerID), checker.IsNil)
+ assert.Assert(c, waitRun(containerID) == nil)
dockerCmd(c, "stop", containerID)
out, _ = dockerCmd(c, "logs", containerID)
- c.Assert(out, checker.Contains, "exit trapped", check.Commentf("Expected `exit trapped` in the log"))
+ assert.Assert(c, strings.Contains(out, "exit trapped"), "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, swapMemorySupport)
out, _, err := dockerCmdWithError("run", "-m", "16m", "--memory-swap", "15m", "busybox", "echo", "test")
@@ -727,7 +723,7 @@
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)
sysInfo := sysinfo.New(true)
@@ -746,7 +742,7 @@
assert.Assert(c, strings.Contains(out, expected))
}
-func (s *DockerSuite) TestRunInvalidCpusetMemsFlagValue(c *check.C) {
+func (s *DockerSuite) TestRunInvalidCpusetMemsFlagValue(c *testing.T) {
testRequires(c, cgroupCpuset)
sysInfo := sysinfo.New(true)
@@ -765,7 +761,7 @@
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)
out, _, err := dockerCmdWithError("run", "--cpu-shares", "1", "busybox", "echo", "test")
assert.ErrorContains(c, err, "", out)
@@ -783,7 +779,7 @@
assert.Assert(c, strings.Contains(out, expected))
}
-func (s *DockerSuite) TestRunWithDefaultShmSize(c *check.C) {
+func (s *DockerSuite) TestRunWithDefaultShmSize(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "shm-default"
@@ -793,10 +789,10 @@
c.Fatalf("Expected shm of 64MB in mount command, got %v", out)
}
shmSize := inspectField(c, name, "HostConfig.ShmSize")
- c.Assert(shmSize, check.Equals, "67108864")
+ assert.Equal(c, shmSize, "67108864")
}
-func (s *DockerSuite) TestRunWithShmSize(c *check.C) {
+func (s *DockerSuite) TestRunWithShmSize(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "shm"
@@ -806,18 +802,18 @@
c.Fatalf("Expected shm of 1GB in mount command, got %v", out)
}
shmSize := inspectField(c, name, "HostConfig.ShmSize")
- c.Assert(shmSize, check.Equals, "1073741824")
+ assert.Equal(c, shmSize, "1073741824")
}
-func (s *DockerSuite) TestRunTmpfsMountsEnsureOrdered(c *check.C) {
+func (s *DockerSuite) TestRunTmpfsMountsEnsureOrdered(c *testing.T) {
tmpFile, err := ioutil.TempFile("", "test")
assert.NilError(c, err)
defer tmpFile.Close()
out, _ := dockerCmd(c, "run", "--tmpfs", "/run", "-v", tmpFile.Name()+":/run/test", "busybox", "ls", "/run")
- c.Assert(out, checker.Contains, "test")
+ assert.Assert(c, strings.Contains(out, "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
// Windows does not support tmpfs mounts.
testRequires(c, DaemonIsLinux)
@@ -838,7 +834,7 @@
}
}
-func (s *DockerSuite) TestRunTmpfsMountsOverrideImageVolumes(c *check.C) {
+func (s *DockerSuite) TestRunTmpfsMountsOverrideImageVolumes(c *testing.T) {
name := "img-with-volumes"
buildImageSuccessfully(c, name, build.WithDockerfile(`
FROM busybox
@@ -846,37 +842,35 @@
RUN touch /run/stuff
`))
out, _ := dockerCmd(c, "run", "--tmpfs", "/run", name, "ls", "/run")
- c.Assert(out, checker.Not(checker.Contains), "stuff")
+ assert.Assert(c, !strings.Contains(out, "stuff"))
}
// Test case for #22420
-func (s *DockerSuite) TestRunTmpfsMountsWithOptions(c *check.C) {
+func (s *DockerSuite) TestRunTmpfsMountsWithOptions(c *testing.T) {
testRequires(c, DaemonIsLinux)
expectedOptions := []string{"rw", "nosuid", "nodev", "noexec", "relatime"}
out, _ := dockerCmd(c, "run", "--tmpfs", "/tmp", "busybox", "sh", "-c", "mount | grep 'tmpfs on /tmp'")
for _, option := range expectedOptions {
- c.Assert(out, checker.Contains, option)
+ assert.Assert(c, strings.Contains(out, option))
}
- c.Assert(out, checker.Not(checker.Contains), "size=")
-
+ assert.Assert(c, !strings.Contains(out, "size="))
expectedOptions = []string{"rw", "nosuid", "nodev", "noexec", "relatime"}
out, _ = dockerCmd(c, "run", "--tmpfs", "/tmp:rw", "busybox", "sh", "-c", "mount | grep 'tmpfs on /tmp'")
for _, option := range expectedOptions {
- c.Assert(out, checker.Contains, option)
+ assert.Assert(c, strings.Contains(out, option))
}
- c.Assert(out, checker.Not(checker.Contains), "size=")
-
+ assert.Assert(c, !strings.Contains(out, "size="))
expectedOptions = []string{"rw", "nosuid", "nodev", "relatime", "size=8192k"}
out, _ = dockerCmd(c, "run", "--tmpfs", "/tmp:rw,exec,size=8192k", "busybox", "sh", "-c", "mount | grep 'tmpfs on /tmp'")
for _, option := range expectedOptions {
- c.Assert(out, checker.Contains, option)
+ assert.Assert(c, strings.Contains(out, option))
}
expectedOptions = []string{"rw", "nosuid", "nodev", "noexec", "relatime", "size=4096k"}
out, _ = dockerCmd(c, "run", "--tmpfs", "/tmp:rw,size=8192k,exec,size=4096k,noexec", "busybox", "sh", "-c", "mount | grep 'tmpfs on /tmp'")
for _, option := range expectedOptions {
- c.Assert(out, checker.Contains, option)
+ assert.Assert(c, strings.Contains(out, option))
}
// We use debian:jessie as there is no findmnt in busybox. Also the output will be in the format of
@@ -886,32 +880,32 @@
expectedOptions = []string{"shared"}
out, _ = dockerCmd(c, "run", "--tmpfs", "/tmp:shared", "debian:jessie", "findmnt", "-o", "TARGET,PROPAGATION", "/tmp")
for _, option := range expectedOptions {
- c.Assert(out, checker.Contains, option)
+ assert.Assert(c, strings.Contains(out, option))
}
}
-func (s *DockerSuite) TestRunSysctls(c *check.C) {
+func (s *DockerSuite) TestRunSysctls(c *testing.T) {
testRequires(c, DaemonIsLinux)
var err error
out, _ := dockerCmd(c, "run", "--sysctl", "net.ipv4.ip_forward=1", "--name", "test", "busybox", "cat", "/proc/sys/net/ipv4/ip_forward")
- c.Assert(strings.TrimSpace(out), check.Equals, "1")
+ assert.Equal(c, strings.TrimSpace(out), "1")
out = inspectFieldJSON(c, "test", "HostConfig.Sysctls")
sysctls := make(map[string]string)
err = json.Unmarshal([]byte(out), &sysctls)
assert.NilError(c, err)
- c.Assert(sysctls["net.ipv4.ip_forward"], check.Equals, "1")
+ assert.Equal(c, sysctls["net.ipv4.ip_forward"], "1")
out, _ = dockerCmd(c, "run", "--sysctl", "net.ipv4.ip_forward=0", "--name", "test1", "busybox", "cat", "/proc/sys/net/ipv4/ip_forward")
- c.Assert(strings.TrimSpace(out), check.Equals, "0")
+ assert.Equal(c, strings.TrimSpace(out), "0")
out = inspectFieldJSON(c, "test1", "HostConfig.Sysctls")
err = json.Unmarshal([]byte(out), &sysctls)
assert.NilError(c, err)
- c.Assert(sysctls["net.ipv4.ip_forward"], check.Equals, "0")
+ assert.Equal(c, sysctls["net.ipv4.ip_forward"], "0")
icmd.RunCommand(dockerBinary, "run", "--sysctl", "kernel.foobar=1", "--name", "test2",
"busybox", "cat", "/proc/sys/kernel/foobar").Assert(c, icmd.Expected{
@@ -921,7 +915,7 @@
}
// 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)
jsonData := `{
"defaultAction": "SCMP_ACT_ALLOW",
@@ -950,7 +944,7 @@
}
// 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)
jsonData := `{
"defaultAction": "SCMP_ACT_ALLOW",
@@ -985,7 +979,7 @@
// 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.
-func (s *DockerSuite) TestRunSeccompProfileDenyUnshareUserns(c *check.C) {
+func (s *DockerSuite) TestRunSeccompProfileDenyUnshareUserns(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, NotArm, Apparmor)
// from sched.h
jsonData := fmt.Sprintf(`{
@@ -1023,7 +1017,7 @@
// TestRunSeccompProfileDenyCloneUserns checks that 'docker run syscall-test'
// 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)
ensureSyscallTest(c)
@@ -1035,7 +1029,7 @@
// TestRunSeccompUnconfinedCloneUserns checks that
// '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)
ensureSyscallTest(c)
@@ -1048,7 +1042,7 @@
// TestRunSeccompAllowPrivCloneUserns checks that 'docker run --privileged syscall-test'
// 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)
ensureSyscallTest(c)
@@ -1060,7 +1054,7 @@
// TestRunSeccompProfileAllow32Bit checks that 32 bit code can run on x86_64
// 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)
ensureSyscallTest(c)
@@ -1068,14 +1062,14 @@
}
// 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)
// 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)
}
-func (s *DockerSuite) TestRunSeccompDefaultProfileAcct(c *check.C) {
+func (s *DockerSuite) TestRunSeccompDefaultProfileAcct(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, NotUserNamespace)
ensureSyscallTest(c)
@@ -1105,7 +1099,7 @@
}
}
-func (s *DockerSuite) TestRunSeccompDefaultProfileNS(c *check.C) {
+func (s *DockerSuite) TestRunSeccompDefaultProfileNS(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, NotUserNamespace)
ensureSyscallTest(c)
@@ -1142,7 +1136,7 @@
// TestRunNoNewPrivSetuid checks that --security-opt='no-new-privileges=true' prevents
// 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)
ensureNNPTest(c)
@@ -1155,7 +1149,7 @@
// TestLegacyRunNoNewPrivSetuid checks that --security-opt=no-new-privileges prevents
// 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)
ensureNNPTest(c)
@@ -1166,7 +1160,7 @@
})
}
-func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChown(c *check.C) {
+func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChown(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
ensureSyscallTest(c)
@@ -1184,7 +1178,7 @@
})
}
-func (s *DockerSuite) TestUserNoEffectiveCapabilitiesDacOverride(c *check.C) {
+func (s *DockerSuite) TestUserNoEffectiveCapabilitiesDacOverride(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
ensureSyscallTest(c)
@@ -1197,7 +1191,7 @@
})
}
-func (s *DockerSuite) TestUserNoEffectiveCapabilitiesFowner(c *check.C) {
+func (s *DockerSuite) TestUserNoEffectiveCapabilitiesFowner(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
ensureSyscallTest(c)
@@ -1213,7 +1207,7 @@
// TODO CAP_KILL
-func (s *DockerSuite) TestUserNoEffectiveCapabilitiesSetuid(c *check.C) {
+func (s *DockerSuite) TestUserNoEffectiveCapabilitiesSetuid(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
ensureSyscallTest(c)
@@ -1231,7 +1225,7 @@
})
}
-func (s *DockerSuite) TestUserNoEffectiveCapabilitiesSetgid(c *check.C) {
+func (s *DockerSuite) TestUserNoEffectiveCapabilitiesSetgid(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
ensureSyscallTest(c)
@@ -1251,7 +1245,7 @@
// TODO CAP_SETPCAP
-func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetBindService(c *check.C) {
+func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetBindService(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
ensureSyscallTest(c)
@@ -1269,7 +1263,7 @@
})
}
-func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetRaw(c *check.C) {
+func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetRaw(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
ensureSyscallTest(c)
@@ -1287,7 +1281,7 @@
})
}
-func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChroot(c *check.C) {
+func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChroot(c *testing.T) {
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
ensureSyscallTest(c)
@@ -1305,7 +1299,7 @@
})
}
-func (s *DockerSuite) TestUserNoEffectiveCapabilitiesMknod(c *check.C) {
+func (s *DockerSuite) TestUserNoEffectiveCapabilitiesMknod(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace, testEnv.IsLocalDaemon)
ensureSyscallTest(c)
@@ -1327,7 +1321,7 @@
// TODO CAP_AUDIT_WRITE
// TODO CAP_SETFCAP
-func (s *DockerSuite) TestRunApparmorProcDirectory(c *check.C) {
+func (s *DockerSuite) TestRunApparmorProcDirectory(c *testing.T) {
testRequires(c, testEnv.IsLocalDaemon, Apparmor)
// running w seccomp unconfined tests the apparmor profile
@@ -1346,7 +1340,7 @@
// make sure the default profile can be successfully parsed (using unshare as it is
// 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)
out, _, err := dockerCmdWithError("run", "--security-opt", "seccomp=../profiles/seccomp/default.json", "debian:jessie", "unshare", "--map-root-user", "--user", "sh", "-c", "whoami")
@@ -1355,7 +1349,7 @@
}
// 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)
if _, err := os.Stat("/dev/zero"); err != nil {
c.Skip("Host does not have /dev/zero")
@@ -1391,20 +1385,18 @@
// md5sum of 'dd if=/dev/zero bs=4K count=8' is bb7df04e1b0a2570657527a7e108ae23
out, _ := dockerCmd(c, "run", "--device", symZero+":/dev/symzero", "busybox", "sh", "-c", "dd if=/dev/symzero bs=4K count=8 | md5sum")
- c.Assert(strings.Trim(out, "\r\n"), checker.Contains, "bb7df04e1b0a2570657527a7e108ae23", check.Commentf("expected output bb7df04e1b0a2570657527a7e108ae23"))
-
+ assert.Assert(c, strings.Contains(strings.Trim(out, "\r\n"), "bb7df04e1b0a2570657527a7e108ae23"), "expected output bb7df04e1b0a2570657527a7e108ae23")
// symlink "tmpDir/file" to a file "tmpDir/temp" will result in an error as it is not a device.
out, _, err = dockerCmdWithError("run", "--device", symFile+":/dev/symzero", "busybox", "sh", "-c", "dd if=/dev/symzero bs=4K count=8 | md5sum")
assert.ErrorContains(c, err, "")
- c.Assert(strings.Trim(out, "\r\n"), checker.Contains, "not a device node", check.Commentf("expected output 'not a device node'"))
-
+ assert.Assert(c, strings.Contains(strings.Trim(out, "\r\n"), "not a device node"), "expected output 'not a device node'")
// md5sum of 'dd if=/dev/zero bs=4K count=8' is bb7df04e1b0a2570657527a7e108ae23 (this time check with relative path backed, see #22271)
out, _ = dockerCmd(c, "run", "--device", "/dev/symzero:/dev/symzero", "busybox", "sh", "-c", "dd if=/dev/symzero bs=4K count=8 | md5sum")
- c.Assert(strings.Trim(out, "\r\n"), checker.Contains, "bb7df04e1b0a2570657527a7e108ae23", check.Commentf("expected output bb7df04e1b0a2570657527a7e108ae23"))
+ assert.Assert(c, strings.Contains(strings.Trim(out, "\r\n"), "bb7df04e1b0a2570657527a7e108ae23"), "expected output bb7df04e1b0a2570657527a7e108ae23")
}
// 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)
file := "/sys/fs/cgroup/pids/pids.max"
@@ -1415,7 +1407,7 @@
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)
file := "/sys/fs/cgroup/devices/devices.list"
@@ -1424,7 +1416,7 @@
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)
fi, err := os.Stat("/dev/snd/timer")
@@ -1438,10 +1430,10 @@
file := "/sys/fs/cgroup/devices/devices.list"
out, _ := dockerCmd(c, "run", "--device", "/dev/snd/timer:w", "busybox", "cat", file)
- c.Assert(out, checker.Contains, fmt.Sprintf("c %d:%d w", stat.Rdev/256, stat.Rdev%256))
+ assert.Assert(c, strings.Contains(out, 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)
s.d.StartWithBusybox(c)
@@ -1463,10 +1455,10 @@
out, err := s.d.Cmd("run", "--security-opt", "seccomp="+tmpFile.Name(), "busybox", "chmod", "777", ".")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "Operation not permitted")
+ assert.Assert(c, strings.Contains(out, "Operation not permitted"))
}
-func (s *DockerDaemonSuite) TestRunSeccompJSONNoNameAndNames(c *check.C) {
+func (s *DockerDaemonSuite) TestRunSeccompJSONNoNameAndNames(c *testing.T) {
testRequires(c, seccompEnabled)
s.d.StartWithBusybox(c)
@@ -1489,10 +1481,10 @@
out, err := s.d.Cmd("run", "--security-opt", "seccomp="+tmpFile.Name(), "busybox", "chmod", "777", ".")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "'name' and 'names' were specified in the seccomp profile, use either 'name' or 'names'")
+ assert.Assert(c, strings.Contains(out, "'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)
s.d.StartWithBusybox(c)
@@ -1526,10 +1518,10 @@
out, err := s.d.Cmd("run", "--security-opt", "seccomp="+tmpFile.Name(), "busybox", "chmod", "777", ".")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "'architectures' and 'archMap' were specified in the seccomp profile, use either 'architectures' or 'archMap'")
+ assert.Assert(c, strings.Contains(out, "'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)
s.d.StartWithBusybox(c)
@@ -1562,10 +1554,10 @@
out, err := s.d.Cmd("run", "busybox", "chmod", "777", ".")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "Operation not permitted")
+ assert.Assert(c, strings.Contains(out, "Operation not permitted"))
}
-func (s *DockerSuite) TestRunWithNanoCPUs(c *check.C) {
+func (s *DockerSuite) TestRunWithNanoCPUs(c *testing.T) {
testRequires(c, cpuCfsQuota, cpuCfsPeriod)
file1 := "/sys/fs/cgroup/cpu/cpu.cfs_quota_us"
@@ -1577,7 +1569,7 @@
assert.NilError(c, err)
inspect, err := clt.ContainerInspect(context.Background(), "test")
assert.NilError(c, err)
- c.Assert(inspect.HostConfig.NanoCPUs, checker.Equals, int64(500000000))
+ assert.Equal(c, inspect.HostConfig.NanoCPUs, int64(500000000))
out = inspectField(c, "test", "HostConfig.CpuQuota")
assert.Equal(c, out, "0", "CPU CFS quota should be 0")
@@ -1586,5 +1578,5 @@
out, _, err = dockerCmdWithError("run", "--cpus", "0.5", "--cpu-quota", "50000", "--cpu-period", "100000", "busybox", "sh")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "Conflicting options: Nano CPUs and CPU Period cannot both be set")
+ assert.Assert(c, strings.Contains(out, "Conflicting options: Nano CPUs and CPU Period cannot both be set"))
}
diff --git a/integration-cli/docker_cli_save_load_test.go b/integration-cli/docker_cli_save_load_test.go
index 67536d8..4bcd1d0 100644
--- a/integration-cli/docker_cli_save_load_test.go
+++ b/integration-cli/docker_cli_save_load_test.go
@@ -13,11 +13,10 @@
"regexp"
"sort"
"strings"
+ "testing"
"time"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli/build"
- "github.com/go-check/check"
"github.com/opencontainers/go-digest"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
@@ -25,7 +24,7 @@
)
// 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)
name := "test-save-xz-and-load-repo-stdout"
dockerCmd(c, "run", "--name", name, "busybox", "true")
@@ -54,7 +53,7 @@
}
// 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)
name := "test-save-xz-gz-and-load-repo-stdout"
dockerCmd(c, "run", "--name", name, "busybox", "true")
@@ -83,7 +82,7 @@
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)
repoName := "foobar-save-single-tag-test"
dockerCmd(c, "tag", "busybox:latest", fmt.Sprintf("%v:latest", repoName))
@@ -98,7 +97,7 @@
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)
repoName := "busybox:latest"
out, _ := dockerCmd(c, "inspect", repoName)
@@ -117,7 +116,7 @@
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)
repoName := "foobar-save-image-id-test"
dockerCmd(c, "tag", "emptyfs:latest", fmt.Sprintf("%v:latest", repoName))
@@ -129,21 +128,21 @@
cleanedShortImageID := strings.TrimSpace(out)
// Make sure IDs are not empty
- c.Assert(cleanedLongImageID, checker.Not(check.Equals), "", check.Commentf("Id should not be empty."))
- c.Assert(cleanedShortImageID, checker.Not(check.Equals), "", check.Commentf("Id should not be empty."))
+ assert.Assert(c, cleanedLongImageID != "", "Id should not be empty.")
+ assert.Assert(c, cleanedShortImageID != "", "Id should not be empty.")
saveCmd := exec.Command(dockerBinary, "save", cleanedShortImageID)
tarCmd := exec.Command("tar", "t")
var err error
tarCmd.Stdin, err = saveCmd.StdoutPipe()
- c.Assert(err, checker.IsNil, check.Commentf("cannot set stdout pipe for tar: %v", err))
+ assert.Assert(c, err == nil, "cannot set stdout pipe for tar: %v", err)
grepCmd := exec.Command("grep", cleanedLongImageID)
grepCmd.Stdin, err = tarCmd.StdoutPipe()
- c.Assert(err, checker.IsNil, check.Commentf("cannot set stdout pipe for grep: %v", err))
+ assert.Assert(c, err == nil, "cannot set stdout pipe for grep: %v", err)
- c.Assert(tarCmd.Start(), checker.IsNil, check.Commentf("tar failed with error: %v", err))
- c.Assert(saveCmd.Start(), checker.IsNil, check.Commentf("docker save failed with error: %v", err))
+ assert.Assert(c, tarCmd.Start() == nil, "tar failed with error: %v", err)
+ assert.Assert(c, saveCmd.Start() == nil, "docker save failed with error: %v", err)
defer func() {
saveCmd.Wait()
tarCmd.Wait()
@@ -152,11 +151,11 @@
out, _, err = runCommandWithOutput(grepCmd)
- c.Assert(err, checker.IsNil, check.Commentf("failed to save repo with image ID: %s, %v", out, err))
+ assert.Assert(c, err == nil, "failed to save repo with image ID: %s, %v", out, err)
}
// 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)
name := "test-save-and-load-repo-flags"
dockerCmd(c, "run", "--name", name, "busybox", "true")
@@ -177,7 +176,7 @@
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)
imgName := "foobar-non-existing-image"
@@ -187,7 +186,7 @@
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)
repoName := "foobar-save-multi-name-test"
@@ -205,7 +204,7 @@
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)
makeImage := func(from string, tag string) string {
var (
@@ -257,14 +256,14 @@
}
// 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)
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"}
name := "save-directory-permissions"
tmpDir, err := ioutil.TempDir("", "save-layers-with-directories")
- c.Assert(err, checker.IsNil, check.Commentf("failed to create temporary directory: %s", err))
+ assert.Assert(c, err == nil, "failed to create temporary directory: %s", err)
extractionDirectory := filepath.Join(tmpDir, "image-extraction-dir")
os.Mkdir(extractionDirectory, 0777)
@@ -331,7 +330,7 @@
// 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.
// 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
// very weird test
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
@@ -339,7 +338,7 @@
dockerCmd(c, "load", "-i", "testdata/emptyLayer.tar")
}
-func (s *DockerSuite) TestSaveLoadParents(c *check.C) {
+func (s *DockerSuite) TestSaveLoadParents(c *testing.T) {
testRequires(c, DaemonIsLinux)
makeImage := func(from string, addfile string) string {
@@ -378,7 +377,7 @@
assert.Equal(c, inspectOut, "")
}
-func (s *DockerSuite) TestSaveLoadNoTag(c *check.C) {
+func (s *DockerSuite) TestSaveLoadNoTag(c *testing.T) {
testRequires(c, DaemonIsLinux)
name := "saveloadnotag"
@@ -393,16 +392,15 @@
assert.NilError(c, err, "failed to save and load repo: %s, %v", out, err)
// Should not show 'name' but should show the image ID during the load
- c.Assert(out, checker.Not(checker.Contains), "Loaded image: ")
- c.Assert(out, checker.Contains, "Loaded image ID:")
- c.Assert(out, checker.Contains, id)
-
+ assert.Assert(c, !strings.Contains(out, "Loaded image: "))
+ assert.Assert(c, strings.Contains(out, "Loaded image ID:"))
+ assert.Assert(c, strings.Contains(out, id))
// Test to make sure that save by name shows that name during load
out, err = RunCommandPipelineWithOutput(
exec.Command(dockerBinary, "save", name),
exec.Command(dockerBinary, "load"))
assert.NilError(c, err, "failed to save and load repo: %s, %v", out, err)
- c.Assert(out, checker.Contains, "Loaded image: "+name+":latest")
- c.Assert(out, checker.Not(checker.Contains), "Loaded image ID:")
+ assert.Assert(c, strings.Contains(out, "Loaded image: "+name+":latest"))
+ assert.Assert(c, !strings.Contains(out, "Loaded image ID:"))
}
diff --git a/integration-cli/docker_cli_save_load_unix_test.go b/integration-cli/docker_cli_save_load_unix_test.go
index cbe1dd2..c1dfa01 100644
--- a/integration-cli/docker_cli_save_load_unix_test.go
+++ b/integration-cli/docker_cli_save_load_unix_test.go
@@ -9,17 +9,17 @@
"os"
"os/exec"
"strings"
+ "testing"
"time"
"github.com/creack/pty"
"github.com/docker/docker/integration-cli/cli/build"
- "github.com/go-check/check"
"gotest.tools/assert"
"gotest.tools/icmd"
)
// 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"
dockerCmd(c, "run", "--name", name, "busybox", "true")
@@ -70,7 +70,7 @@
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"
buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox
RUN touch aa
@@ -88,7 +88,7 @@
}
// 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()
assert.NilError(c, err)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
diff --git a/integration-cli/docker_cli_search_test.go b/integration-cli/docker_cli_search_test.go
index 4226453..a029c95 100644
--- a/integration-cli/docker_cli_search_test.go
+++ b/integration-cli/docker_cli_search_test.go
@@ -3,18 +3,18 @@
import (
"fmt"
"strings"
+ "testing"
- "github.com/go-check/check"
"gotest.tools/assert"
)
// 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")
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")
assert.ErrorContains(c, err, "", out)
assert.Assert(c, strings.Contains(out, "Invalid filter"), "couldn't find the invalid filter warning")
@@ -32,7 +32,7 @@
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")
assert.Assert(c, strings.Count(outSearchCmd, "\n") > 3, outSearchCmd)
@@ -60,12 +60,12 @@
}
// 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-")
}
// 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} {
out, _, err := dockerCmdWithError("search", fmt.Sprintf("--limit=%d", limit), "docker")
assert.NilError(c, err)
diff --git a/integration-cli/docker_cli_service_create_test.go b/integration-cli/docker_cli_service_create_test.go
index f1d875b..d9ca41b 100644
--- a/integration-cli/docker_cli_service_create_test.go
+++ b/integration-cli/docker_cli_service_create_test.go
@@ -7,64 +7,65 @@
"fmt"
"path/filepath"
"strings"
+ "testing"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/integration-cli/checker"
- "github.com/go-check/check"
"gotest.tools/assert"
+ "gotest.tools/poll"
)
-func (s *DockerSwarmSuite) TestServiceCreateMountVolume(c *check.C) {
+func (s *DockerSwarmSuite) TestServiceCreateMountVolume(c *testing.T) {
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")
assert.NilError(c, err, out)
id := strings.TrimSpace(out)
var tasks []swarm.Task
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
tasks = d.GetServiceTasks(c, id)
- return len(tasks) > 0, nil
- }, checker.Equals, true)
+ return len(tasks) > 0, ""
+ }, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout))
task := tasks[0]
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
if task.NodeID == "" || task.Status.ContainerStatus == nil {
task = d.GetTask(c, task.ID)
}
- return task.NodeID != "" && task.Status.ContainerStatus != nil, nil
- }, checker.Equals, true)
+ return task.NodeID != "" && task.Status.ContainerStatus != nil, ""
+ }, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout))
// check container mount config
out, err = s.nodeCmd(c, task.NodeID, "inspect", "--format", "{{json .HostConfig.Mounts}}", task.Status.ContainerStatus.ContainerID)
assert.NilError(c, err, out)
var mountConfig []mount.Mount
- c.Assert(json.Unmarshal([]byte(out), &mountConfig), checker.IsNil)
- c.Assert(mountConfig, checker.HasLen, 1)
+ assert.Assert(c, json.Unmarshal([]byte(out), &mountConfig) == nil)
+ assert.Equal(c, len(mountConfig), 1)
- c.Assert(mountConfig[0].Source, checker.Equals, "foo")
- c.Assert(mountConfig[0].Target, checker.Equals, "/foo")
- c.Assert(mountConfig[0].Type, checker.Equals, mount.TypeVolume)
- c.Assert(mountConfig[0].VolumeOptions, checker.NotNil)
- c.Assert(mountConfig[0].VolumeOptions.NoCopy, checker.True)
+ assert.Equal(c, mountConfig[0].Source, "foo")
+ assert.Equal(c, mountConfig[0].Target, "/foo")
+ assert.Equal(c, mountConfig[0].Type, mount.TypeVolume)
+ assert.Assert(c, mountConfig[0].VolumeOptions != nil)
+ assert.Assert(c, mountConfig[0].VolumeOptions.NoCopy)
// check container mounts actual
out, err = s.nodeCmd(c, task.NodeID, "inspect", "--format", "{{json .Mounts}}", task.Status.ContainerStatus.ContainerID)
assert.NilError(c, err, out)
var mounts []types.MountPoint
- c.Assert(json.Unmarshal([]byte(out), &mounts), checker.IsNil)
- c.Assert(mounts, checker.HasLen, 1)
+ assert.Assert(c, json.Unmarshal([]byte(out), &mounts) == nil)
+ assert.Equal(c, len(mounts), 1)
- c.Assert(mounts[0].Type, checker.Equals, mount.TypeVolume)
- c.Assert(mounts[0].Name, checker.Equals, "foo")
- c.Assert(mounts[0].Destination, checker.Equals, "/foo")
- c.Assert(mounts[0].RW, checker.Equals, true)
+ assert.Equal(c, mounts[0].Type, mount.TypeVolume)
+ assert.Equal(c, mounts[0].Name, "foo")
+ assert.Equal(c, mounts[0].Destination, "/foo")
+ assert.Equal(c, mounts[0].RW, true)
}
-func (s *DockerSwarmSuite) TestServiceCreateWithSecretSimple(c *check.C) {
+func (s *DockerSwarmSuite) TestServiceCreateWithSecretSimple(c *testing.T) {
d := s.AddDaemon(c, true, true)
serviceName := "test-service-secret"
@@ -75,7 +76,7 @@
},
Data: []byte("TESTINGDATA"),
})
- c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
+ assert.Assert(c, id != "", "secrets: %s", id)
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", serviceName, "--secret", testName, "busybox", "top")
assert.NilError(c, err, out)
@@ -84,21 +85,21 @@
assert.NilError(c, err)
var refs []swarm.SecretReference
- c.Assert(json.Unmarshal([]byte(out), &refs), checker.IsNil)
+ assert.Assert(c, json.Unmarshal([]byte(out), &refs) == nil)
assert.Equal(c, len(refs), 1)
- c.Assert(refs[0].SecretName, checker.Equals, testName)
- c.Assert(refs[0].File, checker.Not(checker.IsNil))
- c.Assert(refs[0].File.Name, checker.Equals, testName)
- c.Assert(refs[0].File.UID, checker.Equals, "0")
- c.Assert(refs[0].File.GID, checker.Equals, "0")
+ assert.Equal(c, refs[0].SecretName, testName)
+ assert.Assert(c, refs[0].File != nil)
+ assert.Equal(c, refs[0].File.Name, testName)
+ assert.Equal(c, refs[0].File.UID, "0")
+ assert.Equal(c, refs[0].File.GID, "0")
out, err = d.Cmd("service", "rm", serviceName)
assert.NilError(c, err, out)
d.DeleteSecret(c, testName)
}
-func (s *DockerSwarmSuite) TestServiceCreateWithSecretSourceTargetPaths(c *check.C) {
+func (s *DockerSwarmSuite) TestServiceCreateWithSecretSourceTargetPaths(c *testing.T) {
d := s.AddDaemon(c, true, true)
testPaths := map[string]string{
@@ -117,7 +118,7 @@
},
Data: []byte("TESTINGDATA " + testName + " " + testTarget),
})
- c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
+ assert.Assert(c, id != "", "secrets: %s", id)
secretFlags = append(secretFlags, "--secret", fmt.Sprintf("source=%s,target=%s", testName, testTarget))
}
@@ -133,22 +134,22 @@
assert.NilError(c, err)
var refs []swarm.SecretReference
- c.Assert(json.Unmarshal([]byte(out), &refs), checker.IsNil)
+ assert.Assert(c, json.Unmarshal([]byte(out), &refs) == nil)
assert.Equal(c, len(refs), len(testPaths))
var tasks []swarm.Task
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
tasks = d.GetServiceTasks(c, serviceName)
- return len(tasks) > 0, nil
- }, checker.Equals, true)
+ return len(tasks) > 0, ""
+ }, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout))
task := tasks[0]
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
if task.NodeID == "" || task.Status.ContainerStatus == nil {
task = d.GetTask(c, task.ID)
}
- return task.NodeID != "" && task.Status.ContainerStatus != nil, nil
- }, checker.Equals, true)
+ return task.NodeID != "" && task.Status.ContainerStatus != nil, ""
+ }, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout))
for testName, testTarget := range testPaths {
path := testTarget
@@ -164,7 +165,7 @@
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)
id := d.CreateSecret(c, swarm.SecretSpec{
@@ -173,7 +174,7 @@
},
Data: []byte("TESTINGDATA"),
})
- c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
+ assert.Assert(c, id != "", "secrets: %s", id)
serviceName := "svc"
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", serviceName, "--secret", "source=mysecret,target=target1", "--secret", "source=mysecret,target=target2", "busybox", "top")
@@ -183,22 +184,22 @@
assert.NilError(c, err)
var refs []swarm.SecretReference
- c.Assert(json.Unmarshal([]byte(out), &refs), checker.IsNil)
+ assert.Assert(c, json.Unmarshal([]byte(out), &refs) == nil)
assert.Equal(c, len(refs), 2)
var tasks []swarm.Task
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
tasks = d.GetServiceTasks(c, serviceName)
- return len(tasks) > 0, nil
- }, checker.Equals, true)
+ return len(tasks) > 0, ""
+ }, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout))
task := tasks[0]
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
if task.NodeID == "" || task.Status.ContainerStatus == nil {
task = d.GetTask(c, task.ID)
}
- return task.NodeID != "" && task.Status.ContainerStatus != nil, nil
- }, checker.Equals, true)
+ return task.NodeID != "" && task.Status.ContainerStatus != nil, ""
+ }, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout))
for _, target := range []string{"target1", "target2"} {
assert.NilError(c, err, out)
@@ -212,7 +213,7 @@
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)
serviceName := "test-service-config"
@@ -223,7 +224,7 @@
},
Data: []byte("TESTINGDATA"),
})
- c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("configs: %s", id))
+ assert.Assert(c, id != "", "configs: %s", id)
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", serviceName, "--config", testName, "busybox", "top")
assert.NilError(c, err, out)
@@ -232,21 +233,21 @@
assert.NilError(c, err)
var refs []swarm.ConfigReference
- c.Assert(json.Unmarshal([]byte(out), &refs), checker.IsNil)
+ assert.Assert(c, json.Unmarshal([]byte(out), &refs) == nil)
assert.Equal(c, len(refs), 1)
- c.Assert(refs[0].ConfigName, checker.Equals, testName)
- c.Assert(refs[0].File, checker.Not(checker.IsNil))
- c.Assert(refs[0].File.Name, checker.Equals, testName)
- c.Assert(refs[0].File.UID, checker.Equals, "0")
- c.Assert(refs[0].File.GID, checker.Equals, "0")
+ assert.Equal(c, refs[0].ConfigName, testName)
+ assert.Assert(c, refs[0].File != nil)
+ assert.Equal(c, refs[0].File.Name, testName)
+ assert.Equal(c, refs[0].File.UID, "0")
+ assert.Equal(c, refs[0].File.GID, "0")
out, err = d.Cmd("service", "rm", serviceName)
assert.NilError(c, err, out)
d.DeleteConfig(c, testName)
}
-func (s *DockerSwarmSuite) TestServiceCreateWithConfigSourceTargetPaths(c *check.C) {
+func (s *DockerSwarmSuite) TestServiceCreateWithConfigSourceTargetPaths(c *testing.T) {
d := s.AddDaemon(c, true, true)
testPaths := map[string]string{
@@ -264,7 +265,7 @@
},
Data: []byte("TESTINGDATA " + testName + " " + testTarget),
})
- c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("configs: %s", id))
+ assert.Assert(c, id != "", "configs: %s", id)
configFlags = append(configFlags, "--config", fmt.Sprintf("source=%s,target=%s", testName, testTarget))
}
@@ -280,22 +281,22 @@
assert.NilError(c, err)
var refs []swarm.ConfigReference
- c.Assert(json.Unmarshal([]byte(out), &refs), checker.IsNil)
+ assert.Assert(c, json.Unmarshal([]byte(out), &refs) == nil)
assert.Equal(c, len(refs), len(testPaths))
var tasks []swarm.Task
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
tasks = d.GetServiceTasks(c, serviceName)
- return len(tasks) > 0, nil
- }, checker.Equals, true)
+ return len(tasks) > 0, ""
+ }, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout))
task := tasks[0]
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
if task.NodeID == "" || task.Status.ContainerStatus == nil {
task = d.GetTask(c, task.ID)
}
- return task.NodeID != "" && task.Status.ContainerStatus != nil, nil
- }, checker.Equals, true)
+ return task.NodeID != "" && task.Status.ContainerStatus != nil, ""
+ }, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout))
for testName, testTarget := range testPaths {
path := testTarget
@@ -311,7 +312,7 @@
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)
id := d.CreateConfig(c, swarm.ConfigSpec{
@@ -320,7 +321,7 @@
},
Data: []byte("TESTINGDATA"),
})
- c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("configs: %s", id))
+ assert.Assert(c, id != "", "configs: %s", id)
serviceName := "svc"
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", serviceName, "--config", "source=myconfig,target=target1", "--config", "source=myconfig,target=target2", "busybox", "top")
@@ -330,22 +331,22 @@
assert.NilError(c, err)
var refs []swarm.ConfigReference
- c.Assert(json.Unmarshal([]byte(out), &refs), checker.IsNil)
+ assert.Assert(c, json.Unmarshal([]byte(out), &refs) == nil)
assert.Equal(c, len(refs), 2)
var tasks []swarm.Task
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
tasks = d.GetServiceTasks(c, serviceName)
- return len(tasks) > 0, nil
- }, checker.Equals, true)
+ return len(tasks) > 0, ""
+ }, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout))
task := tasks[0]
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
if task.NodeID == "" || task.Status.ContainerStatus == nil {
task = d.GetTask(c, task.ID)
}
- return task.NodeID != "" && task.Status.ContainerStatus != nil, nil
- }, checker.Equals, true)
+ return task.NodeID != "" && task.Status.ContainerStatus != nil, ""
+ }, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout))
for _, target := range []string{"target1", "target2"} {
assert.NilError(c, err, out)
@@ -359,52 +360,52 @@
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)
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)
id := strings.TrimSpace(out)
var tasks []swarm.Task
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
tasks = d.GetServiceTasks(c, id)
- return len(tasks) > 0, nil
- }, checker.Equals, true)
+ return len(tasks) > 0, ""
+ }, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout))
task := tasks[0]
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
if task.NodeID == "" || task.Status.ContainerStatus == nil {
task = d.GetTask(c, task.ID)
}
- return task.NodeID != "" && task.Status.ContainerStatus != nil, nil
- }, checker.Equals, true)
+ return task.NodeID != "" && task.Status.ContainerStatus != nil, ""
+ }, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout))
// check container mount config
out, err = s.nodeCmd(c, task.NodeID, "inspect", "--format", "{{json .HostConfig.Mounts}}", task.Status.ContainerStatus.ContainerID)
assert.NilError(c, err, out)
var mountConfig []mount.Mount
- c.Assert(json.Unmarshal([]byte(out), &mountConfig), checker.IsNil)
- c.Assert(mountConfig, checker.HasLen, 1)
+ assert.Assert(c, json.Unmarshal([]byte(out), &mountConfig) == nil)
+ assert.Equal(c, len(mountConfig), 1)
- c.Assert(mountConfig[0].Source, checker.Equals, "")
- c.Assert(mountConfig[0].Target, checker.Equals, "/foo")
- c.Assert(mountConfig[0].Type, checker.Equals, mount.TypeTmpfs)
- c.Assert(mountConfig[0].TmpfsOptions, checker.NotNil)
- c.Assert(mountConfig[0].TmpfsOptions.SizeBytes, checker.Equals, int64(1048576))
+ assert.Equal(c, mountConfig[0].Source, "")
+ assert.Equal(c, mountConfig[0].Target, "/foo")
+ assert.Equal(c, mountConfig[0].Type, mount.TypeTmpfs)
+ assert.Assert(c, mountConfig[0].TmpfsOptions != nil)
+ assert.Equal(c, mountConfig[0].TmpfsOptions.SizeBytes, int64(1048576))
// check container mounts actual
out, err = s.nodeCmd(c, task.NodeID, "inspect", "--format", "{{json .Mounts}}", task.Status.ContainerStatus.ContainerID)
assert.NilError(c, err, out)
var mounts []types.MountPoint
- c.Assert(json.Unmarshal([]byte(out), &mounts), checker.IsNil)
- c.Assert(mounts, checker.HasLen, 1)
+ assert.Assert(c, json.Unmarshal([]byte(out), &mounts) == nil)
+ assert.Equal(c, len(mounts), 1)
- c.Assert(mounts[0].Type, checker.Equals, mount.TypeTmpfs)
- c.Assert(mounts[0].Name, checker.Equals, "")
- c.Assert(mounts[0].Destination, checker.Equals, "/foo")
- c.Assert(mounts[0].RW, checker.Equals, true)
+ assert.Equal(c, mounts[0].Type, mount.TypeTmpfs)
+ assert.Equal(c, mounts[0].Name, "")
+ assert.Equal(c, mounts[0].Destination, "/foo")
+ assert.Equal(c, mounts[0].RW, true)
out, err = s.nodeCmd(c, task.NodeID, "logs", task.Status.ContainerStatus.ContainerID)
assert.NilError(c, err, out)
@@ -412,7 +413,7 @@
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)
out, err := d.Cmd("network", "create", "--scope=swarm", "test_swarm_br")
assert.NilError(c, err, out)
@@ -422,18 +423,18 @@
id := strings.TrimSpace(out)
var tasks []swarm.Task
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
tasks = d.GetServiceTasks(c, id)
- return len(tasks) > 0, nil
- }, checker.Equals, true)
+ return len(tasks) > 0, ""
+ }, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout))
task := tasks[0]
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
if task.NodeID == "" || task.Status.ContainerStatus == nil {
task = d.GetTask(c, task.ID)
}
- return task.NodeID != "" && task.Status.ContainerStatus != nil, nil
- }, checker.Equals, true)
+ return task.NodeID != "" && task.Status.ContainerStatus != nil, ""
+ }, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout))
// check container alias config
out, err = s.nodeCmd(c, task.NodeID, "inspect", "--format", "{{json .NetworkSettings.Networks.test_swarm_br.Aliases}}", task.Status.ContainerStatus.ContainerID)
@@ -441,8 +442,8 @@
// Make sure the only alias seen is the container-id
var aliases []string
- c.Assert(json.Unmarshal([]byte(out), &aliases), checker.IsNil)
- c.Assert(aliases, checker.HasLen, 1)
+ assert.Assert(c, json.Unmarshal([]byte(out), &aliases) == nil)
+ assert.Equal(c, len(aliases), 1)
- c.Assert(task.Status.ContainerStatus.ContainerID, checker.Contains, aliases[0])
+ assert.Assert(c, strings.Contains(task.Status.ContainerStatus.ContainerID, aliases[0]))
}
diff --git a/integration-cli/docker_cli_service_health_test.go b/integration-cli/docker_cli_service_health_test.go
index d72ad3f..6987459 100644
--- a/integration-cli/docker_cli_service_health_test.go
+++ b/integration-cli/docker_cli_service_health_test.go
@@ -5,20 +5,21 @@
import (
"strconv"
"strings"
+ "testing"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/daemon/cluster/executor/container"
"github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
- "github.com/go-check/check"
"gotest.tools/assert"
"gotest.tools/icmd"
+ "gotest.tools/poll"
)
// start a service, and then make its task unhealthy during running
// 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
d := s.AddDaemon(c, true, true)
@@ -39,39 +40,40 @@
id := strings.TrimSpace(out)
var tasks []swarm.Task
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
tasks = d.GetServiceTasks(c, id)
- return tasks, nil
- }, checker.HasLen, 1)
+ return tasks, ""
+ }, checker.HasLen(1)), poll.WithTimeout(defaultReconciliationTimeout))
task := tasks[0]
// wait for task to start
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
task = d.GetTask(c, task.ID)
- return task.Status.State, nil
- }, checker.Equals, swarm.TaskStateRunning)
+ return task.Status.State, ""
+ }, checker.Equals(swarm.TaskStateRunning)), poll.WithTimeout(defaultReconciliationTimeout))
+
containerID := task.Status.ContainerStatus.ContainerID
// wait for container to be healthy
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
out, _ := d.Cmd("inspect", "--format={{.State.Health.Status}}", containerID)
- return strings.TrimSpace(out), nil
- }, checker.Equals, "healthy")
+ return strings.TrimSpace(out), ""
+ }, checker.Equals("healthy")), poll.WithTimeout(defaultReconciliationTimeout))
// make it fail
d.Cmd("exec", containerID, "rm", "/status")
// wait for container to be unhealthy
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
out, _ := d.Cmd("inspect", "--format={{.State.Health.Status}}", containerID)
- return strings.TrimSpace(out), nil
- }, checker.Equals, "unhealthy")
+ return strings.TrimSpace(out), ""
+ }, checker.Equals("unhealthy")), poll.WithTimeout(defaultReconciliationTimeout))
// Task should be terminated
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
task = d.GetTask(c, task.ID)
- return task.Status.State, nil
- }, checker.Equals, swarm.TaskStateFailed)
+ return task.Status.State, ""
+ }, checker.Equals(swarm.TaskStateFailed)), poll.WithTimeout(defaultReconciliationTimeout))
if !strings.Contains(task.Status.Err, container.ErrContainerUnhealthy.Error()) {
c.Fatal("unhealthy task exits because of other error")
@@ -80,7 +82,7 @@
// start a service whose task is unhealthy at beginning
// 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
d := s.AddDaemon(c, true, true)
@@ -100,38 +102,39 @@
id := strings.TrimSpace(out)
var tasks []swarm.Task
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
tasks = d.GetServiceTasks(c, id)
- return tasks, nil
- }, checker.HasLen, 1)
+ return tasks, ""
+ }, checker.HasLen(1)), poll.WithTimeout(defaultReconciliationTimeout))
task := tasks[0]
// wait for task to start
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
task = d.GetTask(c, task.ID)
- return task.Status.State, nil
- }, checker.Equals, swarm.TaskStateStarting)
+ return task.Status.State, ""
+ }, checker.Equals(swarm.TaskStateStarting)), poll.WithTimeout(defaultReconciliationTimeout))
containerID := task.Status.ContainerStatus.ContainerID
// wait for health check to work
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
out, _ := d.Cmd("inspect", "--format={{.State.Health.FailingStreak}}", containerID)
failingStreak, _ := strconv.Atoi(strings.TrimSpace(out))
- return failingStreak, nil
- }, checker.GreaterThan, 0)
+ return failingStreak, ""
+ }, checker.GreaterThan(0)), poll.WithTimeout(defaultReconciliationTimeout))
// task should be blocked at starting status
task = d.GetTask(c, task.ID)
- c.Assert(task.Status.State, check.Equals, swarm.TaskStateStarting)
+ assert.Equal(c, task.Status.State, swarm.TaskStateStarting)
// make it healthy
d.Cmd("exec", containerID, "touch", "/status")
// Task should be at running status
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
task = d.GetTask(c, task.ID)
- return task.Status.State, nil
- }, checker.Equals, swarm.TaskStateRunning)
+ return task.Status.State, ""
+ }, checker.Equals(swarm.TaskStateRunning)), poll.WithTimeout(defaultReconciliationTimeout))
+
}
diff --git a/integration-cli/docker_cli_service_logs_test.go b/integration-cli/docker_cli_service_logs_test.go
index d852866..66842ae 100644
--- a/integration-cli/docker_cli_service_logs_test.go
+++ b/integration-cli/docker_cli_service_logs_test.go
@@ -8,13 +8,14 @@
"io"
"os/exec"
"strings"
+ "testing"
"time"
"github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/daemon"
- "github.com/go-check/check"
"gotest.tools/assert"
"gotest.tools/icmd"
+ "gotest.tools/poll"
)
type logMessage struct {
@@ -22,7 +23,7 @@
data []byte
}
-func (s *DockerSwarmSuite) TestServiceLogs(c *check.C) {
+func (s *DockerSwarmSuite) TestServiceLogs(c *testing.T) {
d := s.AddDaemon(c, true, true)
// we have multiple services here for detecting the goroutine issue #28915
@@ -39,9 +40,8 @@
}
// make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout,
- d.CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{"busybox:latest": len(services)})
+ poll.WaitOn(c, pollCheck(c,
+ d.CheckRunningTaskImages, checker.DeepEquals(map[string]int{"busybox:latest": len(services)})), poll.WithTimeout(defaultReconciliationTimeout))
for name, message := range services {
out, err := d.Cmd("service", "logs", name)
@@ -54,22 +54,22 @@
// countLogLines returns a closure that can be used with waitAndAssert to
// verify that a minimum number of expected container log messages have been
// output.
-func countLogLines(d *daemon.Daemon, name string) func(*check.C) (interface{}, check.CommentInterface) {
- return func(c *check.C) (interface{}, check.CommentInterface) {
+func countLogLines(d *daemon.Daemon, name string) func(*testing.T) (interface{}, string) {
+ return func(c *testing.T) (interface{}, string) {
result := icmd.RunCmd(d.Command("service", "logs", "-t", "--raw", name))
result.Assert(c, icmd.Expected{})
// if this returns an emptystring, trying to split it later will return
// an array containing emptystring. a valid log line will NEVER be
// emptystring because we ask for the timestamp.
if result.Stdout() == "" {
- return 0, check.Commentf("Empty stdout")
+ return 0, "Empty stdout"
}
lines := strings.Split(strings.TrimSpace(result.Stdout()), "\n")
- return len(lines), check.Commentf("output, %q", string(result.Stdout()))
+ return len(lines), fmt.Sprintf("output, %q", string(result.Stdout()))
}
}
-func (s *DockerSwarmSuite) TestServiceLogsCompleteness(c *check.C) {
+func (s *DockerSwarmSuite) TestServiceLogsCompleteness(c *testing.T) {
d := s.AddDaemon(c, true, true)
name := "TestServiceLogsCompleteness"
@@ -80,9 +80,9 @@
assert.Assert(c, strings.TrimSpace(out) != "")
// make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
// and make sure we have all the log lines
- waitAndAssert(c, defaultReconciliationTimeout, countLogLines(d, name), checker.Equals, 6)
+ poll.WaitOn(c, pollCheck(c, countLogLines(d, name), checker.Equals(6)), poll.WithTimeout(defaultReconciliationTimeout))
out, err = d.Cmd("service", "logs", name)
assert.NilError(c, err)
@@ -96,7 +96,7 @@
}
}
-func (s *DockerSwarmSuite) TestServiceLogsTail(c *check.C) {
+func (s *DockerSwarmSuite) TestServiceLogsTail(c *testing.T) {
d := s.AddDaemon(c, true, true)
name := "TestServiceLogsTail"
@@ -107,8 +107,8 @@
assert.Assert(c, strings.TrimSpace(out) != "")
// make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
- waitAndAssert(c, defaultReconciliationTimeout, countLogLines(d, name), checker.Equals, 6)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
+ poll.WaitOn(c, pollCheck(c, countLogLines(d, name), checker.Equals(6)), poll.WithTimeout(defaultReconciliationTimeout))
out, err = d.Cmd("service", "logs", "--tail=2", name)
assert.NilError(c, err)
@@ -120,7 +120,7 @@
}
}
-func (s *DockerSwarmSuite) TestServiceLogsSince(c *check.C) {
+func (s *DockerSwarmSuite) TestServiceLogsSince(c *testing.T) {
// See DockerSuite.TestLogsSince, which is where this comes from
d := s.AddDaemon(c, true, true)
@@ -129,9 +129,9 @@
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", name, "busybox", "sh", "-c", "for i in $(seq 1 3); do sleep .1; echo log$i; done; sleep 10000000")
assert.NilError(c, err)
assert.Assert(c, strings.TrimSpace(out) != "")
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
// wait a sec for the logs to come in
- waitAndAssert(c, defaultReconciliationTimeout, countLogLines(d, name), checker.Equals, 3)
+ poll.WaitOn(c, pollCheck(c, countLogLines(d, name), checker.Equals(3)), poll.WithTimeout(defaultReconciliationTimeout))
out, err = d.Cmd("service", "logs", "-t", name)
assert.NilError(c, err)
@@ -155,7 +155,7 @@
}
}
-func (s *DockerSwarmSuite) TestServiceLogsFollow(c *check.C) {
+func (s *DockerSwarmSuite) TestServiceLogsFollow(c *testing.T) {
d := s.AddDaemon(c, true, true)
name := "TestServiceLogsFollow"
@@ -165,7 +165,7 @@
assert.Assert(c, strings.TrimSpace(out) != "")
// make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
args := []string{"service", "logs", "-f", name}
cmd := exec.Command(dockerBinary, d.PrependHostArg(args)...)
@@ -201,7 +201,7 @@
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)
name := "TestServicelogsTaskLogs"
@@ -228,8 +228,8 @@
result.Assert(c, icmd.Expected{Out: id})
// make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, replicas)
- waitAndAssert(c, defaultReconciliationTimeout, countLogLines(d, name), checker.Equals, 6*replicas)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(replicas)), poll.WithTimeout(defaultReconciliationTimeout))
+ poll.WaitOn(c, pollCheck(c, countLogLines(d, name), checker.Equals(6*replicas)), poll.WithTimeout(defaultReconciliationTimeout))
// get the task ids
result = icmd.RunCmd(d.Command("service", "ps", "-q", name))
@@ -254,7 +254,7 @@
}
}
-func (s *DockerSwarmSuite) TestServiceLogsTTY(c *check.C) {
+func (s *DockerSwarmSuite) TestServiceLogsTTY(c *testing.T) {
d := s.AddDaemon(c, true, true)
name := "TestServiceLogsTTY"
@@ -281,9 +281,9 @@
result.Assert(c, icmd.Expected{Out: id})
// make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
// and make sure we have all the log lines
- waitAndAssert(c, defaultReconciliationTimeout, countLogLines(d, name), checker.Equals, 2)
+ poll.WaitOn(c, pollCheck(c, countLogLines(d, name), checker.Equals(2)), poll.WithTimeout(defaultReconciliationTimeout))
cmd := d.Command("service", "logs", "--raw", name)
result = icmd.RunCmd(cmd)
@@ -292,7 +292,7 @@
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)
name := "TestServiceLogsNoHangDeletedContainer"
@@ -315,9 +315,9 @@
assert.Assert(c, id != "")
// make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
// and make sure we have all the log lines
- waitAndAssert(c, defaultReconciliationTimeout, countLogLines(d, name), checker.Equals, 2)
+ poll.WaitOn(c, pollCheck(c, countLogLines(d, name), checker.Equals(2)), poll.WithTimeout(defaultReconciliationTimeout))
// now find and nuke the container
result = icmd.RunCmd(d.Command("ps", "-q"))
@@ -341,7 +341,7 @@
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)
name := "TestServiceLogsDetails"
@@ -368,9 +368,9 @@
assert.Assert(c, id != "")
// make sure task has been deployed
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
// and make sure we have all the log lines
- waitAndAssert(c, defaultReconciliationTimeout, countLogLines(d, name), checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, countLogLines(d, name), checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
// First, test without pretty printing
// call service logs with details. set raw to skip pretty printing
diff --git a/integration-cli/docker_cli_service_scale_test.go b/integration-cli/docker_cli_service_scale_test.go
index 25a0e14..9311275 100644
--- a/integration-cli/docker_cli_service_scale_test.go
+++ b/integration-cli/docker_cli_service_scale_test.go
@@ -5,12 +5,12 @@
import (
"fmt"
"strings"
+ "testing"
- "github.com/go-check/check"
"gotest.tools/assert"
)
-func (s *DockerSwarmSuite) TestServiceScale(c *check.C) {
+func (s *DockerSwarmSuite) TestServiceScale(c *testing.T) {
d := s.AddDaemon(c, true, true)
service1Name := "TestService1"
diff --git a/integration-cli/docker_cli_sni_test.go b/integration-cli/docker_cli_sni_test.go
index e64911d..1735471 100644
--- a/integration-cli/docker_cli_sni_test.go
+++ b/integration-cli/docker_cli_sni_test.go
@@ -9,12 +9,12 @@
"net/url"
"os/exec"
"strings"
+ "testing"
- "github.com/go-check/check"
"gotest.tools/assert"
)
-func (s *DockerSuite) TestClientSetsTLSServerName(c *check.C) {
+func (s *DockerSuite) TestClientSetsTLSServerName(c *testing.T) {
c.Skip("Flakey test")
// there may be more than one hit to the server for each registry request
var serverNameReceived []string
diff --git a/integration-cli/docker_cli_start_test.go b/integration-cli/docker_cli_start_test.go
index dfaf072..9d59e83 100644
--- a/integration-cli/docker_cli_start_test.go
+++ b/integration-cli/docker_cli_start_test.go
@@ -3,17 +3,16 @@
import (
"fmt"
"strings"
+ "testing"
"time"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli"
- "github.com/go-check/check"
"gotest.tools/assert"
"gotest.tools/icmd"
)
// 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
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "--name", "test", "busybox")
@@ -21,7 +20,7 @@
// Expect this to fail because the above container is stopped, this is what we want
out, _, err := dockerCmdWithError("run", "--name", "test2", "--link", "test:test", "busybox")
// err shouldn't be nil because container test2 try to link to stopped container
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
+ assert.Assert(c, err != nil, "out: %s", out)
ch := make(chan error)
go func() {
@@ -42,7 +41,7 @@
}
// 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)
out := cli.DockerCmd(c, "run", "-d", "busybox", "sh", "-c", "sleep 2; exit 1").Stdout()
out = strings.TrimSpace(out)
@@ -55,7 +54,7 @@
})
}
-func (s *DockerSuite) TestStartAttachSilent(c *check.C) {
+func (s *DockerSuite) TestStartAttachSilent(c *testing.T) {
name := "teststartattachcorrectexitcode"
dockerCmd(c, "run", "--name", name, "busybox", "echo", "test")
@@ -64,35 +63,34 @@
startOut, _ := dockerCmd(c, "start", "-a", name)
// start -a produced unexpected output
- c.Assert(startOut, checker.Equals, "test\n")
+ assert.Equal(c, startOut, "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.
testRequires(c, DaemonIsLinux)
// when container runs successfully, we should not have state.Error
dockerCmd(c, "run", "-d", "-p", "9999:9999", "--name", "test", "busybox", "top")
stateErr := inspectField(c, "test", "State.Error")
// Expected to not have state error
- c.Assert(stateErr, checker.Equals, "")
+ assert.Equal(c, stateErr, "")
// Expect this to fail and records error because of ports conflict
out, _, err := dockerCmdWithError("run", "-d", "--name", "test2", "-p", "9999:9999", "busybox", "top")
// err shouldn't be nil because docker run will fail
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
+ assert.Assert(c, err != nil, "out: %s", out)
stateErr = inspectField(c, "test2", "State.Error")
- c.Assert(stateErr, checker.Contains, "port is already allocated")
-
+ assert.Assert(c, strings.Contains(stateErr, "port is already allocated"))
// Expect the conflict to be resolved when we stop the initial container
dockerCmd(c, "stop", "test")
dockerCmd(c, "start", "test2")
stateErr = inspectField(c, "test2", "State.Error")
// Expected to not have state error but got one
- c.Assert(stateErr, checker.Equals, "")
+ assert.Equal(c, stateErr, "")
}
-func (s *DockerSuite) TestStartPausedContainer(c *check.C) {
+func (s *DockerSuite) TestStartPausedContainer(c *testing.T) {
// Windows does not support pausing containers
testRequires(c, IsPausable)
@@ -102,12 +100,12 @@
out, _, err := dockerCmdWithError("start", "testing")
// an error should have been shown that you cannot start paused container
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
+ assert.Assert(c, err != nil, "out: %s", out)
// an error should have been shown that you cannot start paused container
- c.Assert(strings.ToLower(out), checker.Contains, "cannot start a paused container, try unpause instead")
+ assert.Assert(c, strings.Contains(strings.ToLower(out), "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
testRequires(c, DaemonIsLinux)
// run a container named 'parent' and create two container link to `parent`
@@ -130,7 +128,7 @@
expErr := "failed to start containers: [child_first]"
out, _, err := dockerCmdWithError("start", "child_first", "parent", "child_second")
// err shouldn't be nil because start will fail
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
+ assert.Assert(c, err != nil, "out: %s", out)
// output does not correspond to what was expected
if !(strings.Contains(out, expOut) || strings.Contains(err.Error(), expErr)) {
c.Fatalf("Expected out: %v with err: %v but got out: %v with err: %v", expOut, expErr, out, err)
@@ -143,7 +141,7 @@
}
}
-func (s *DockerSuite) TestStartAttachMultipleContainers(c *check.C) {
+func (s *DockerSuite) TestStartAttachMultipleContainers(c *testing.T) {
// run multiple containers to test
for _, container := range []string{"test1", "test2", "test3"} {
runSleepingContainer(c, "--name", container)
@@ -158,9 +156,9 @@
for _, option := range []string{"-a", "-i", "-ai"} {
out, _, err := dockerCmdWithError("start", option, "test1", "test2", "test3")
// err shouldn't be nil because start will fail
- c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
+ assert.Assert(c, err != nil, "out: %s", out)
// output does not correspond to what was expected
- c.Assert(out, checker.Contains, "you cannot start and attach multiple containers at once")
+ assert.Assert(c, strings.Contains(out, "you cannot start and attach multiple containers at once"))
}
// confirm the state of all the containers be stopped
@@ -172,7 +170,7 @@
}
// Test case for #23716
-func (s *DockerSuite) TestStartAttachWithRename(c *check.C) {
+func (s *DockerSuite) TestStartAttachWithRename(c *testing.T) {
testRequires(c, DaemonIsLinux)
cli.DockerCmd(c, "create", "-t", "--name", "before", "busybox")
go func() {
@@ -184,18 +182,18 @@
result := cli.Docker(cli.Args("start", "-a", "before")).Assert(c, icmd.Expected{
ExitCode: 137,
})
- c.Assert(result.Stderr(), checker.Not(checker.Contains), "No such container")
+ assert.Assert(c, !strings.Contains(result.Stderr(), "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", "--rm", "--name", "withRm", "busybox", "sh", "-c", "exit 12")
out, exitCode, err := dockerCmdWithError("start", "-a", "withRestart")
assert.ErrorContains(c, err, "")
- c.Assert(exitCode, checker.Equals, 11, check.Commentf("out: %s", out))
+ assert.Equal(c, exitCode, 11, fmt.Sprintf("out: %s", out))
out, exitCode, err = dockerCmdWithError("start", "-a", "withRm")
assert.ErrorContains(c, err, "")
- c.Assert(exitCode, checker.Equals, 12, check.Commentf("out: %s", out))
+ assert.Equal(c, exitCode, 12, fmt.Sprintf("out: %s", out))
}
diff --git a/integration-cli/docker_cli_stats_test.go b/integration-cli/docker_cli_stats_test.go
index c21b730..71966e5 100644
--- a/integration-cli/docker_cli_stats_test.go
+++ b/integration-cli/docker_cli_stats_test.go
@@ -5,15 +5,15 @@
"os/exec"
"regexp"
"strings"
+ "testing"
"time"
"github.com/docker/docker/integration-cli/cli"
- "github.com/go-check/check"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
)
-func (s *DockerSuite) TestStatsNoStream(c *check.C) {
+func (s *DockerSuite) TestStatsNoStream(c *testing.T) {
// Windows does not support stats
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
@@ -42,7 +42,7 @@
}
}
-func (s *DockerSuite) TestStatsContainerNotFound(c *check.C) {
+func (s *DockerSuite) TestStatsContainerNotFound(c *testing.T) {
// Windows does not support stats
testRequires(c, DaemonIsLinux)
@@ -55,7 +55,7 @@
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
testRequires(c, DaemonIsLinux)
@@ -91,7 +91,7 @@
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
testRequires(c, DaemonIsLinux)
@@ -121,7 +121,7 @@
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
testRequires(c, DaemonIsLinux)
@@ -162,7 +162,7 @@
}
}
-func (s *DockerSuite) TestStatsFormatAll(c *check.C) {
+func (s *DockerSuite) TestStatsFormatAll(c *testing.T) {
// Windows does not support stats
testRequires(c, DaemonIsLinux)
diff --git a/integration-cli/docker_cli_swarm_test.go b/integration-cli/docker_cli_swarm_test.go
index 9800b5f..e597a09 100644
--- a/integration-cli/docker_cli_swarm_test.go
+++ b/integration-cli/docker_cli_swarm_test.go
@@ -15,6 +15,7 @@
"path/filepath"
"runtime"
"strings"
+ "testing"
"time"
"github.com/cloudflare/cfssl/helpers"
@@ -27,14 +28,14 @@
"github.com/docker/libnetwork/ipamapi"
remoteipam "github.com/docker/libnetwork/ipams/remote/api"
"github.com/docker/swarmkit/ca/keyutils"
- "github.com/go-check/check"
"github.com/vishvananda/netlink"
"gotest.tools/assert"
"gotest.tools/fs"
"gotest.tools/icmd"
+ "gotest.tools/poll"
)
-func (s *DockerSwarmSuite) TestSwarmUpdate(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmUpdate(c *testing.T) {
d := s.AddDaemon(c, true, true)
getSpec := func() swarm.Spec {
@@ -46,15 +47,15 @@
assert.NilError(c, err, out)
spec := getSpec()
- c.Assert(spec.CAConfig.NodeCertExpiry, checker.Equals, 30*time.Hour)
- c.Assert(spec.Dispatcher.HeartbeatPeriod, checker.Equals, 11*time.Second)
+ assert.Equal(c, spec.CAConfig.NodeCertExpiry, 30*time.Hour)
+ assert.Equal(c, spec.Dispatcher.HeartbeatPeriod, 11*time.Second)
// setting anything under 30m for cert-expiry is not allowed
out, err = d.Cmd("swarm", "update", "--cert-expiry", "15m")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "minimum certificate expiry time")
+ assert.Assert(c, strings.Contains(out, "minimum certificate expiry time"))
spec = getSpec()
- c.Assert(spec.CAConfig.NodeCertExpiry, checker.Equals, 30*time.Hour)
+ assert.Equal(c, spec.CAConfig.NodeCertExpiry, 30*time.Hour)
// passing an external CA (this is without starting a root rotation) does not fail
cli.Docker(cli.Args("swarm", "update", "--external-ca", "protocol=cfssl,url=https://something.org",
@@ -65,9 +66,9 @@
assert.NilError(c, err)
spec = getSpec()
- c.Assert(spec.CAConfig.ExternalCAs, checker.HasLen, 2)
- c.Assert(spec.CAConfig.ExternalCAs[0].CACert, checker.Equals, "")
- c.Assert(spec.CAConfig.ExternalCAs[1].CACert, checker.Equals, string(expected))
+ assert.Equal(c, len(spec.CAConfig.ExternalCAs), 2)
+ assert.Equal(c, spec.CAConfig.ExternalCAs[0].CACert, "")
+ assert.Equal(c, spec.CAConfig.ExternalCAs[1].CACert, string(expected))
// passing an invalid external CA fails
tempFile := fs.NewFile(c, "testfile", fs.WithContent("fakecert"))
@@ -82,7 +83,7 @@
})
}
-func (s *DockerSwarmSuite) TestSwarmInit(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmInit(c *testing.T) {
d := s.AddDaemon(c, false, false)
getSpec := func() swarm.Spec {
@@ -111,21 +112,21 @@
assert.NilError(c, err)
spec := getSpec()
- c.Assert(spec.CAConfig.NodeCertExpiry, checker.Equals, 30*time.Hour)
- c.Assert(spec.Dispatcher.HeartbeatPeriod, checker.Equals, 11*time.Second)
- c.Assert(spec.CAConfig.ExternalCAs, checker.HasLen, 2)
- c.Assert(spec.CAConfig.ExternalCAs[0].CACert, checker.Equals, "")
- c.Assert(spec.CAConfig.ExternalCAs[1].CACert, checker.Equals, string(expected))
+ assert.Equal(c, spec.CAConfig.NodeCertExpiry, 30*time.Hour)
+ assert.Equal(c, spec.Dispatcher.HeartbeatPeriod, 11*time.Second)
+ assert.Equal(c, len(spec.CAConfig.ExternalCAs), 2)
+ assert.Equal(c, spec.CAConfig.ExternalCAs[0].CACert, "")
+ assert.Equal(c, spec.CAConfig.ExternalCAs[1].CACert, string(expected))
- c.Assert(d.SwarmLeave(c, true), checker.IsNil)
+ assert.Assert(c, d.SwarmLeave(c, true) == nil)
cli.Docker(cli.Args("swarm", "init"), cli.Daemon(d)).Assert(c, icmd.Success)
spec = getSpec()
- c.Assert(spec.CAConfig.NodeCertExpiry, checker.Equals, 90*24*time.Hour)
- c.Assert(spec.Dispatcher.HeartbeatPeriod, checker.Equals, 5*time.Second)
+ assert.Equal(c, spec.CAConfig.NodeCertExpiry, 90*24*time.Hour)
+ assert.Equal(c, spec.Dispatcher.HeartbeatPeriod, 5*time.Second)
}
-func (s *DockerSwarmSuite) TestSwarmInitIPv6(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmInitIPv6(c *testing.T) {
testRequires(c, IPv6)
d1 := s.AddDaemon(c, false, false)
cli.Docker(cli.Args("swarm", "init", "--listen-add", "::1"), cli.Daemon(d1)).Assert(c, icmd.Success)
@@ -134,17 +135,17 @@
cli.Docker(cli.Args("swarm", "join", "::1"), cli.Daemon(d2)).Assert(c, icmd.Success)
out := cli.Docker(cli.Args("info"), cli.Daemon(d2)).Assert(c, icmd.Success).Combined()
- c.Assert(out, checker.Contains, "Swarm: active")
+ assert.Assert(c, strings.Contains(out, "Swarm: active"))
}
-func (s *DockerSwarmSuite) TestSwarmInitUnspecifiedAdvertiseAddr(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmInitUnspecifiedAdvertiseAddr(c *testing.T) {
d := s.AddDaemon(c, false, false)
out, err := d.Cmd("swarm", "init", "--advertise-addr", "0.0.0.0")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "advertise address must be a non-zero IP address")
+ assert.Assert(c, strings.Contains(out, "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
d := s.AddDaemon(c, true, true)
info := d.SwarmInfo(c)
@@ -156,37 +157,36 @@
assert.ErrorContains(c, err, "")
content, err := d.ReadLogFile()
assert.NilError(c, err)
- c.Assert(string(content), checker.Contains, "--cluster-store and --cluster-advertise daemon configurations are incompatible with swarm mode")
-
+ assert.Assert(c, strings.Contains(string(content), "--cluster-store and --cluster-advertise daemon configurations are incompatible with swarm mode"))
// start a daemon with --live-restore
err = d.StartWithError("--live-restore")
assert.ErrorContains(c, err, "")
content, err = d.ReadLogFile()
assert.NilError(c, err)
- c.Assert(string(content), checker.Contains, "--live-restore daemon configuration is incompatible with swarm mode")
+ assert.Assert(c, strings.Contains(string(content), "--live-restore daemon configuration is incompatible with swarm mode"))
// restart for teardown
d.StartNode(c)
}
-func (s *DockerSwarmSuite) TestSwarmServiceTemplatingHostname(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmServiceTemplatingHostname(c *testing.T) {
d := s.AddDaemon(c, true, true)
hostname, err := d.Cmd("node", "inspect", "--format", "{{.Description.Hostname}}", "self")
- c.Assert(err, checker.IsNil, check.Commentf("%s", hostname))
+ assert.Assert(c, err == nil, "%s", hostname)
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", "test", "--hostname", "{{.Service.Name}}-{{.Task.Slot}}-{{.Node.Hostname}}", "busybox", "top")
assert.NilError(c, err, out)
// make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
containers := d.ActiveContainers(c)
out, err = d.Cmd("inspect", "--type", "container", "--format", "{{.Config.Hostname}}", containers[0])
assert.NilError(c, err, out)
- c.Assert(strings.Split(out, "\n")[0], checker.Equals, "test-1-"+strings.Split(hostname, "\n")[0], check.Commentf("hostname with templating invalid"))
+ assert.Equal(c, strings.Split(out, "\n")[0], "test-1-"+strings.Split(hostname, "\n")[0], "hostname with templating invalid")
}
// Test case for #24270
-func (s *DockerSwarmSuite) TestSwarmServiceListFilter(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmServiceListFilter(c *testing.T) {
d := s.AddDaemon(c, true, true)
name1 := "redis-cluster-md5"
@@ -210,24 +210,22 @@
// We search checker.Contains with `name+" "` to prevent prefix only.
out, err = d.Cmd("service", "ls", "--filter", filter1)
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, name1+" ")
- c.Assert(out, checker.Not(checker.Contains), name2+" ")
- c.Assert(out, checker.Not(checker.Contains), name3+" ")
-
+ assert.Assert(c, strings.Contains(out, name1+" "))
+ assert.Assert(c, !strings.Contains(out, name2+" "))
+ assert.Assert(c, !strings.Contains(out, name3+" "))
out, err = d.Cmd("service", "ls", "--filter", filter2)
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, name1+" ")
- c.Assert(out, checker.Contains, name2+" ")
- c.Assert(out, checker.Not(checker.Contains), name3+" ")
-
+ assert.Assert(c, strings.Contains(out, name1+" "))
+ assert.Assert(c, strings.Contains(out, name2+" "))
+ assert.Assert(c, !strings.Contains(out, name3+" "))
out, err = d.Cmd("service", "ls")
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, name1+" ")
- c.Assert(out, checker.Contains, name2+" ")
- c.Assert(out, checker.Contains, name3+" ")
+ assert.Assert(c, strings.Contains(out, name1+" "))
+ assert.Assert(c, strings.Contains(out, name2+" "))
+ assert.Assert(c, strings.Contains(out, name3+" "))
}
-func (s *DockerSwarmSuite) TestSwarmNodeListFilter(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmNodeListFilter(c *testing.T) {
d := s.AddDaemon(c, true, true)
out, err := d.Cmd("node", "inspect", "--format", "{{ .Description.Hostname }}", "self")
@@ -239,14 +237,13 @@
out, err = d.Cmd("node", "ls", "--filter", filter)
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, name)
-
+ assert.Assert(c, strings.Contains(out, name))
out, err = d.Cmd("node", "ls", "--filter", "name=none")
assert.NilError(c, err, out)
- c.Assert(out, checker.Not(checker.Contains), name)
+ assert.Assert(c, !strings.Contains(out, name))
}
-func (s *DockerSwarmSuite) TestSwarmNodeTaskListFilter(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmNodeTaskListFilter(c *testing.T) {
d := s.AddDaemon(c, true, true)
name := "redis-cluster-md5"
@@ -255,25 +252,24 @@
assert.Assert(c, strings.TrimSpace(out) != "")
// make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 3)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(3)), poll.WithTimeout(defaultReconciliationTimeout))
filter := "name=redis-cluster"
out, err = d.Cmd("node", "ps", "--filter", filter, "self")
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, name+".1")
- c.Assert(out, checker.Contains, name+".2")
- c.Assert(out, checker.Contains, name+".3")
-
+ assert.Assert(c, strings.Contains(out, name+".1"))
+ assert.Assert(c, strings.Contains(out, name+".2"))
+ assert.Assert(c, strings.Contains(out, name+".3"))
out, err = d.Cmd("node", "ps", "--filter", "name=none", "self")
assert.NilError(c, err, out)
- c.Assert(out, checker.Not(checker.Contains), name+".1")
- c.Assert(out, checker.Not(checker.Contains), name+".2")
- c.Assert(out, checker.Not(checker.Contains), name+".3")
+ assert.Assert(c, !strings.Contains(out, name+".1"))
+ assert.Assert(c, !strings.Contains(out, name+".2"))
+ assert.Assert(c, !strings.Contains(out, name+".3"))
}
// Test case for #25375
-func (s *DockerSwarmSuite) TestSwarmPublishAdd(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmPublishAdd(c *testing.T) {
d := s.AddDaemon(c, true, true)
name := "top"
@@ -299,7 +295,7 @@
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)
name := "top"
@@ -308,7 +304,7 @@
assert.Assert(c, strings.TrimSpace(out) != "")
// make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
out, err = d.Cmd("ps", "-q")
assert.NilError(c, err, out)
@@ -321,7 +317,7 @@
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)
out, err := d.Cmd("network", "create", "--attachable", "-d", "overlay", "foo")
@@ -343,7 +339,7 @@
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)
out, err := d.Cmd("network", "create", "--attachable", "-d", "overlay", "foo")
@@ -368,7 +364,7 @@
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)
out, err := d.Cmd("network", "create", "--attachable", "-d", "overlay", "testnet")
@@ -387,16 +383,16 @@
out, err = d.Cmd("network", "rm", "testnet")
assert.NilError(c, err, out)
- checkNetwork := func(*check.C) (interface{}, check.CommentInterface) {
+ checkNetwork := func(*testing.T) (interface{}, string) {
out, err := d.Cmd("network", "ls")
assert.NilError(c, err)
- return out, nil
+ return out, ""
}
- waitAndAssert(c, 3*time.Second, checkNetwork, checker.Not(checker.Contains), "testnet")
+ poll.WaitOn(c, pollCheck(c, checkNetwork, checker.Not(checker.Contains("testnet"))), poll.WithTimeout(3*time.Second))
}
-func (s *DockerSwarmSuite) TestOverlayAttachable(c *check.C) {
+func (s *DockerSwarmSuite) TestOverlayAttachable(c *testing.T) {
d := s.AddDaemon(c, true, true)
out, err := d.Cmd("network", "create", "-d", "overlay", "--attachable", "ovnet")
@@ -418,7 +414,7 @@
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)
// Create an attachable swarm network
@@ -431,7 +427,7 @@
assert.NilError(c, err, out)
// Leave the swarm
- c.Assert(d.SwarmLeave(c, true), checker.IsNil)
+ assert.Assert(c, d.SwarmLeave(c, true) == nil)
// Check the container is disconnected
out, err = d.Cmd("inspect", "c1", "--format", "{{.NetworkSettings.Networks."+nwName+"}}")
@@ -441,10 +437,10 @@
// Check the network is gone
out, err = d.Cmd("network", "ls", "--format", "{{.Name}}")
assert.NilError(c, err, out)
- c.Assert(out, checker.Not(checker.Contains), nwName)
+ assert.Assert(c, !strings.Contains(out, nwName))
}
-func (s *DockerSwarmSuite) TestOverlayAttachableReleaseResourcesOnFailure(c *check.C) {
+func (s *DockerSwarmSuite) TestOverlayAttachableReleaseResourcesOnFailure(c *testing.T) {
d := s.AddDaemon(c, true, true)
// Create attachable network
@@ -468,7 +464,7 @@
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)
// Ingress network can be removed
@@ -488,8 +484,7 @@
// But only one is allowed
out, err = d.Cmd("network", "create", "-d", "overlay", "--ingress", "another-ingress")
assert.ErrorContains(c, err, "")
- c.Assert(strings.TrimSpace(out), checker.Contains, "is already present")
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), "is already present"))
// It cannot be removed if it is being used
out, err = d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", "srv1", "-p", "9000:8000", "busybox", "top")
assert.NilError(c, err, out)
@@ -510,19 +505,17 @@
// A service which needs the ingress network cannot be created if no ingress is present
out, err = d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", "srv2", "-p", "500:500", "busybox", "top")
assert.ErrorContains(c, err, "")
- c.Assert(strings.TrimSpace(out), checker.Contains, "no ingress network is present")
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), "no ingress network is present"))
// An existing service cannot be updated to use the ingress nw if the nw is not present
out, err = d.Cmd("service", "update", "--detach", "--publish-add", "9000:8000", "srv1")
assert.ErrorContains(c, err, "")
- c.Assert(strings.TrimSpace(out), checker.Contains, "no ingress network is present")
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), "no ingress network is present"))
// But services which do not need routing mesh can be created regardless
out, err = d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", "srv3", "--endpoint-mode", "dnsrr", "busybox", "top")
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)
// Remove ingress network
@@ -541,7 +534,7 @@
// Test case for #24108, also the case from:
// 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)
name := "redis-cluster-md5"
@@ -551,55 +544,50 @@
filter := "name=redis-cluster"
- checkNumTasks := func(*check.C) (interface{}, check.CommentInterface) {
+ checkNumTasks := func(*testing.T) (interface{}, string) {
out, err := d.Cmd("service", "ps", "--filter", filter, name)
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, "" // includes header and nl in last line
}
// wait until all tasks have been created
- waitAndAssert(c, defaultReconciliationTimeout, checkNumTasks, checker.Equals, 3)
+ poll.WaitOn(c, pollCheck(c, checkNumTasks, checker.Equals(3)), poll.WithTimeout(defaultReconciliationTimeout))
out, err = d.Cmd("service", "ps", "--filter", filter, name)
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, name+".1")
- c.Assert(out, checker.Contains, name+".2")
- c.Assert(out, checker.Contains, name+".3")
-
+ assert.Assert(c, strings.Contains(out, name+".1"))
+ assert.Assert(c, strings.Contains(out, name+".2"))
+ assert.Assert(c, strings.Contains(out, name+".3"))
out, err = d.Cmd("service", "ps", "--filter", "name="+name+".1", name)
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, name+".1")
- c.Assert(out, checker.Not(checker.Contains), name+".2")
- c.Assert(out, checker.Not(checker.Contains), name+".3")
-
+ assert.Assert(c, strings.Contains(out, name+".1"))
+ assert.Assert(c, !strings.Contains(out, name+".2"))
+ assert.Assert(c, !strings.Contains(out, name+".3"))
out, err = d.Cmd("service", "ps", "--filter", "name=none", name)
assert.NilError(c, err, out)
- c.Assert(out, checker.Not(checker.Contains), name+".1")
- c.Assert(out, checker.Not(checker.Contains), name+".2")
- c.Assert(out, checker.Not(checker.Contains), name+".3")
-
+ assert.Assert(c, !strings.Contains(out, name+".1"))
+ assert.Assert(c, !strings.Contains(out, name+".2"))
+ assert.Assert(c, !strings.Contains(out, name+".3"))
name = "redis-cluster-sha1"
out, err = d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", name, "--mode=global", "busybox", "top")
assert.NilError(c, err, out)
assert.Assert(c, strings.TrimSpace(out) != "")
- waitAndAssert(c, defaultReconciliationTimeout, checkNumTasks, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, checkNumTasks, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
filter = "name=redis-cluster"
out, err = d.Cmd("service", "ps", "--filter", filter, name)
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, name)
-
+ assert.Assert(c, strings.Contains(out, name))
out, err = d.Cmd("service", "ps", "--filter", "name="+name, name)
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, name)
-
+ assert.Assert(c, strings.Contains(out, name))
out, err = d.Cmd("service", "ps", "--filter", "name=none", name)
assert.NilError(c, err, out)
- c.Assert(out, checker.Not(checker.Contains), name)
+ assert.Assert(c, !strings.Contains(out, name))
}
-func (s *DockerSwarmSuite) TestPsListContainersFilterIsTask(c *check.C) {
+func (s *DockerSwarmSuite) TestPsListContainersFilterIsTask(c *testing.T) {
d := s.AddDaemon(c, true, true)
// Create a bare container
@@ -613,26 +601,26 @@
assert.Assert(c, strings.TrimSpace(out) != "")
// make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckServiceRunningTasks(name), checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckServiceRunningTasks(name), checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
// Filter non-tasks
out, err = d.Cmd("ps", "-a", "-q", "--filter=is-task=false")
assert.NilError(c, err, out)
psOut := strings.TrimSpace(out)
- c.Assert(psOut, checker.Equals, bareID, check.Commentf("Expected id %s, got %s for is-task label, output %q", bareID, psOut, out))
+ assert.Equal(c, psOut, bareID, fmt.Sprintf("Expected id %s, got %s for is-task label, output %q", bareID, psOut, out))
// Filter tasks
out, err = d.Cmd("ps", "-a", "-q", "--filter=is-task=true")
assert.NilError(c, err, out)
lines := strings.Split(strings.Trim(out, "\n "), "\n")
assert.Equal(c, len(lines), 1)
- c.Assert(lines[0], checker.Not(checker.Equals), bareID, check.Commentf("Expected not %s, but got it for is-task label, output %q", bareID, out))
+ assert.Assert(c, lines[0] != bareID, "Expected not %s, but got it for is-task label, output %q", bareID, out)
}
const globalNetworkPlugin = "global-network-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) {
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
@@ -800,10 +788,10 @@
assert.NilError(c, err)
}
-func (s *DockerSwarmSuite) TestSwarmNetworkPlugin(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmNetworkPlugin(c *testing.T) {
mux := http.NewServeMux()
s.server = httptest.NewServer(mux)
- c.Assert(s.server, check.NotNil) // check that HTTP server has started
+ assert.Assert(c, s.server != nil) // check that HTTP server has started
setupRemoteGlobalNetworkPlugin(c, mux, s.server.URL, globalNetworkPlugin, globalIPAMPlugin)
defer func() {
s.server.Close()
@@ -815,11 +803,11 @@
out, err := d.Cmd("network", "create", "-d", globalNetworkPlugin, "foo")
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "not supported in swarm mode")
+ assert.Assert(c, strings.Contains(out, "not supported in swarm mode"))
}
// Test case for #24712
-func (s *DockerSwarmSuite) TestSwarmServiceEnvFile(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmServiceEnvFile(c *testing.T) {
d := s.AddDaemon(c, true, true)
path := filepath.Join(d.Folder, "env.txt")
@@ -834,10 +822,10 @@
// The complete env is [VAR1=A VAR2=A VAR1=B VAR1=C VAR2= VAR2] and duplicates will be removed => [VAR1=C VAR2]
out, err = d.Cmd("inspect", "--format", "{{ .Spec.TaskTemplate.ContainerSpec.Env }}", name)
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, "[VAR1=C VAR2]")
+ assert.Assert(c, strings.Contains(out, "[VAR1=C VAR2]"))
}
-func (s *DockerSwarmSuite) TestSwarmServiceTTY(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmServiceTTY(c *testing.T) {
d := s.AddDaemon(c, true, true)
name := "top"
@@ -850,7 +838,7 @@
assert.NilError(c, err, out)
// Make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
// We need to get the container id.
out, err = d.Cmd("ps", "-q", "--no-trunc")
@@ -859,13 +847,12 @@
out, err = d.Cmd("exec", id, "cat", "/status")
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
-
+ assert.Assert(c, strings.Contains(out, expectedOutput), "Expected '%s', but got %q", expectedOutput, out)
// Remove service
out, err = d.Cmd("service", "rm", name)
assert.NilError(c, err, out)
// Make sure container has been destroyed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 0)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(0)), poll.WithTimeout(defaultReconciliationTimeout))
// With --tty
expectedOutput = "TTY"
@@ -873,7 +860,7 @@
assert.NilError(c, err, out)
// Make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
// We need to get the container id.
out, err = d.Cmd("ps", "-q", "--no-trunc")
@@ -882,10 +869,10 @@
out, err = d.Cmd("exec", id, "cat", "/status")
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
+ assert.Assert(c, strings.Contains(out, expectedOutput), "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)
// Create a service
@@ -894,7 +881,7 @@
assert.NilError(c, err, out)
// Make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
out, err = d.Cmd("service", "inspect", "--format", "{{ .Spec.TaskTemplate.ContainerSpec.TTY }}", name)
assert.NilError(c, err, out)
@@ -908,7 +895,7 @@
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)
result := icmd.RunCmd(d.Command("network", "create", "-d", "overlay", "foo"))
@@ -929,25 +916,23 @@
result.Assert(c, icmd.Success)
// Make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckRunningTaskNetworks, checker.DeepEquals,
- map[string]int{fooNetwork: 1, barNetwork: 1})
+ poll.WaitOn(c, pollCheck(c, d.CheckRunningTaskNetworks, checker.DeepEquals(map[string]int{fooNetwork: 1, barNetwork: 1})), poll.WithTimeout(defaultReconciliationTimeout))
// Remove a network
result = icmd.RunCmd(d.Command("service", "update", "--detach", "--network-rm", "foo", name))
result.Assert(c, icmd.Success)
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckRunningTaskNetworks, checker.DeepEquals,
- map[string]int{barNetwork: 1})
+ poll.WaitOn(c, pollCheck(c, d.CheckRunningTaskNetworks, checker.DeepEquals(map[string]int{barNetwork: 1})), poll.WithTimeout(defaultReconciliationTimeout))
// Add a network
result = icmd.RunCmd(d.Command("service", "update", "--detach", "--network-add", "baz", name))
result.Assert(c, icmd.Success)
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckRunningTaskNetworks, checker.DeepEquals,
- map[string]int{barNetwork: 1, bazNetwork: 1})
+ poll.WaitOn(c, pollCheck(c, d.CheckRunningTaskNetworks, checker.DeepEquals(map[string]int{barNetwork: 1, bazNetwork: 1})), poll.WithTimeout(defaultReconciliationTimeout))
+
}
-func (s *DockerSwarmSuite) TestDNSConfig(c *check.C) {
+func (s *DockerSwarmSuite) TestDNSConfig(c *testing.T) {
d := s.AddDaemon(c, true, true)
// Create a service
@@ -956,7 +941,7 @@
assert.NilError(c, err, out)
// Make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
// We need to get the container id.
out, err = d.Cmd("ps", "-a", "-q", "--no-trunc")
@@ -969,12 +954,12 @@
expectedOutput3 := "options timeout:3"
out, err = d.Cmd("exec", id, "cat", "/etc/resolv.conf")
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, expectedOutput1, check.Commentf("Expected '%s', but got %q", expectedOutput1, out))
- c.Assert(out, checker.Contains, expectedOutput2, check.Commentf("Expected '%s', but got %q", expectedOutput2, out))
- c.Assert(out, checker.Contains, expectedOutput3, check.Commentf("Expected '%s', but got %q", expectedOutput3, out))
+ assert.Assert(c, strings.Contains(out, expectedOutput1), "Expected '%s', but got %q", expectedOutput1, out)
+ assert.Assert(c, strings.Contains(out, expectedOutput2), "Expected '%s', but got %q", expectedOutput2, out)
+ assert.Assert(c, strings.Contains(out, expectedOutput3), "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)
// Create a service
@@ -983,7 +968,7 @@
assert.NilError(c, err, out)
// Make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
out, err = d.Cmd("service", "update", "--detach", "--dns-add=1.2.3.4", "--dns-search-add=example.com", "--dns-option-add=timeout:3", name)
assert.NilError(c, err, out)
@@ -993,44 +978,44 @@
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)
return info.LocalNodeState
}
-func checkKeyIsEncrypted(d *daemon.Daemon) func(*check.C) (interface{}, check.CommentInterface) {
- return func(c *check.C) (interface{}, check.CommentInterface) {
+func checkKeyIsEncrypted(d *daemon.Daemon) func(*testing.T) (interface{}, string) {
+ return func(c *testing.T) (interface{}, string) {
keyBytes, err := ioutil.ReadFile(filepath.Join(d.Folder, "root", "swarm", "certificates", "swarm-node.key"))
if err != nil {
- return fmt.Errorf("error reading key: %v", err), nil
+ return fmt.Errorf("error reading key: %v", err), ""
}
keyBlock, _ := pem.Decode(keyBytes)
if keyBlock == nil {
- return fmt.Errorf("invalid PEM-encoded private key"), nil
+ return fmt.Errorf("invalid PEM-encoded private key"), ""
}
- return keyutils.IsEncryptedPEMBlock(keyBlock), nil
+ return keyutils.IsEncryptedPEMBlock(keyBlock), ""
}
}
-func checkSwarmLockedToUnlocked(c *check.C, d *daemon.Daemon) {
+func checkSwarmLockedToUnlocked(c *testing.T, d *daemon.Daemon) {
// Wait for the PEM file to become unencrypted
- waitAndAssert(c, defaultReconciliationTimeout, checkKeyIsEncrypted(d), checker.Equals, false)
+ poll.WaitOn(c, pollCheck(c, checkKeyIsEncrypted(d), checker.Equals(false)), poll.WithTimeout(defaultReconciliationTimeout))
d.RestartNode(c)
- waitAndAssert(c, time.Second, d.CheckLocalNodeState, checker.Equals, swarm.LocalNodeStateActive)
+ poll.WaitOn(c, pollCheck(c, d.CheckLocalNodeState, checker.Equals(swarm.LocalNodeStateActive)), poll.WithTimeout(time.Second))
}
-func checkSwarmUnlockedToLocked(c *check.C, d *daemon.Daemon) {
+func checkSwarmUnlockedToLocked(c *testing.T, d *daemon.Daemon) {
// Wait for the PEM file to become encrypted
- waitAndAssert(c, defaultReconciliationTimeout, checkKeyIsEncrypted(d), checker.Equals, true)
+ poll.WaitOn(c, pollCheck(c, checkKeyIsEncrypted(d), checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout))
d.RestartNode(c)
- waitAndAssert(c, time.Second, d.CheckLocalNodeState, checker.Equals, swarm.LocalNodeStateLocked)
+ poll.WaitOn(c, pollCheck(c, d.CheckLocalNodeState, checker.Equals(swarm.LocalNodeStateLocked)), poll.WithTimeout(time.Second))
}
-func (s *DockerSwarmSuite) TestUnlockEngineAndUnlockedSwarm(c *check.C) {
+func (s *DockerSwarmSuite) TestUnlockEngineAndUnlockedSwarm(c *testing.T) {
d := s.AddDaemon(c, false, false)
// unlocking a normal engine should return an error - it does not even ask for the key
@@ -1039,9 +1024,8 @@
result.Assert(c, icmd.Expected{
ExitCode: 1,
})
- c.Assert(result.Combined(), checker.Contains, "Error: This node is not part of a swarm")
- c.Assert(result.Combined(), checker.Not(checker.Contains), "Please enter unlock key")
-
+ assert.Assert(c, strings.Contains(result.Combined(), "Error: This node is not part of a swarm"))
+ assert.Assert(c, !strings.Contains(result.Combined(), "Please enter unlock key"))
out, err := d.Cmd("swarm", "init")
assert.NilError(c, err, out)
@@ -1051,22 +1035,22 @@
result.Assert(c, icmd.Expected{
ExitCode: 1,
})
- c.Assert(result.Combined(), checker.Contains, "Error: swarm is not locked")
- c.Assert(result.Combined(), checker.Not(checker.Contains), "Please enter unlock key")
+ assert.Assert(c, strings.Contains(result.Combined(), "Error: swarm is not locked"))
+ assert.Assert(c, !strings.Contains(result.Combined(), "Please enter unlock key"))
}
-func (s *DockerSwarmSuite) TestSwarmInitLocked(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmInitLocked(c *testing.T) {
d := s.AddDaemon(c, false, false)
outs, err := d.Cmd("swarm", "init", "--autolock")
- c.Assert(err, checker.IsNil, check.Commentf("%s", outs))
+ assert.Assert(c, err == nil, "%s", outs)
unlockKey := getUnlockKey(d, c, outs)
- c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)
+ assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive)
// It starts off locked
d.RestartNode(c)
- c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateLocked)
+ assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateLocked)
cmd := d.Command("swarm", "unlock")
cmd.Stdin = bytes.NewBufferString("wrong-secret-key")
@@ -1075,33 +1059,32 @@
Err: "invalid key",
})
- c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateLocked)
+ assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateLocked)
cmd = d.Command("swarm", "unlock")
cmd.Stdin = bytes.NewBufferString(unlockKey)
icmd.RunCmd(cmd).Assert(c, icmd.Success)
- c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)
+ assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive)
outs, err = d.Cmd("node", "ls")
- c.Assert(err, checker.IsNil, check.Commentf("%s", outs))
- c.Assert(outs, checker.Not(checker.Contains), "Swarm is encrypted and needs to be unlocked")
-
+ assert.Assert(c, err == nil, "%s", outs)
+ assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
outs, err = d.Cmd("swarm", "update", "--autolock=false")
- c.Assert(err, checker.IsNil, check.Commentf("%s", outs))
+ assert.Assert(c, err == nil, "%s", outs)
checkSwarmLockedToUnlocked(c, d)
outs, err = d.Cmd("node", "ls")
- c.Assert(err, checker.IsNil, check.Commentf("%s", outs))
- c.Assert(outs, checker.Not(checker.Contains), "Swarm is encrypted and needs to be unlocked")
+ assert.Assert(c, err == nil, "%s", outs)
+ assert.Assert(c, !strings.Contains(outs, "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)
outs, err := d.Cmd("swarm", "init", "--autolock")
- c.Assert(err, checker.IsNil, check.Commentf("%s", outs))
+ assert.Assert(c, err == nil, "%s", outs)
// It starts off locked
d.RestartNode(c)
@@ -1110,41 +1093,39 @@
assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateLocked)
outs, _ = d.Cmd("node", "ls")
- c.Assert(outs, checker.Contains, "Swarm is encrypted and needs to be unlocked")
-
+ assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
// `docker swarm leave` a locked swarm without --force will return an error
outs, _ = d.Cmd("swarm", "leave")
- c.Assert(outs, checker.Contains, "Swarm is encrypted and locked.")
-
+ assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and locked."))
// It is OK for user to leave a locked swarm with --force
outs, err = d.Cmd("swarm", "leave", "--force")
- c.Assert(err, checker.IsNil, check.Commentf("%s", outs))
+ assert.Assert(c, err == nil, "%s", outs)
info = d.SwarmInfo(c)
assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateInactive)
outs, err = d.Cmd("swarm", "init")
- c.Assert(err, checker.IsNil, check.Commentf("%s", outs))
+ assert.Assert(c, err == nil, "%s", outs)
info = d.SwarmInfo(c)
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)
d2 := s.AddDaemon(c, true, true)
d3 := s.AddDaemon(c, true, true)
// they start off unlocked
d2.RestartNode(c)
- c.Assert(getNodeStatus(c, d2), checker.Equals, swarm.LocalNodeStateActive)
+ assert.Equal(c, getNodeStatus(c, d2), swarm.LocalNodeStateActive)
// stop this one so it does not get autolock info
d2.Stop(c)
// enable autolock
outs, err := d1.Cmd("swarm", "update", "--autolock")
- c.Assert(err, checker.IsNil, check.Commentf("%s", outs))
+ assert.Assert(c, err == nil, "%s", outs)
unlockKey := getUnlockKey(d1, c, outs)
// The ones that got the cluster update should be set to locked
@@ -1154,19 +1135,19 @@
cmd := d.Command("swarm", "unlock")
cmd.Stdin = bytes.NewBufferString(unlockKey)
icmd.RunCmd(cmd).Assert(c, icmd.Success)
- c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)
+ assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive)
}
// d2 never got the cluster update, so it is still set to unlocked
d2.StartNode(c)
- c.Assert(getNodeStatus(c, d2), checker.Equals, swarm.LocalNodeStateActive)
+ assert.Equal(c, getNodeStatus(c, d2), swarm.LocalNodeStateActive)
// d2 is now set to lock
checkSwarmUnlockedToLocked(c, d2)
// leave it locked, and set the cluster to no longer autolock
outs, err = d1.Cmd("swarm", "update", "--autolock=false")
- c.Assert(err, checker.IsNil, check.Commentf("out: %v", outs))
+ assert.Assert(c, err == nil, "out: %v", outs)
// the ones that got the update are now set to unlocked
for _, d := range []*daemon.Daemon{d1, d3} {
@@ -1174,13 +1155,13 @@
}
// d2 still locked
- c.Assert(getNodeStatus(c, d2), checker.Equals, swarm.LocalNodeStateLocked)
+ assert.Equal(c, getNodeStatus(c, d2), swarm.LocalNodeStateLocked)
// unlock it
cmd := d2.Command("swarm", "unlock")
cmd.Stdin = bytes.NewBufferString(unlockKey)
icmd.RunCmd(cmd).Assert(c, icmd.Success)
- c.Assert(getNodeStatus(c, d2), checker.Equals, swarm.LocalNodeStateActive)
+ assert.Equal(c, getNodeStatus(c, d2), swarm.LocalNodeStateActive)
// once it's caught up, d2 is set to not be locked
checkSwarmLockedToUnlocked(c, d2)
@@ -1188,27 +1169,26 @@
// managers who join now are never set to locked in the first place
d4 := s.AddDaemon(c, true, true)
d4.RestartNode(c)
- c.Assert(getNodeStatus(c, d4), checker.Equals, swarm.LocalNodeStateActive)
+ assert.Equal(c, getNodeStatus(c, d4), swarm.LocalNodeStateActive)
}
-func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *testing.T) {
d1 := s.AddDaemon(c, true, true)
// enable autolock
outs, err := d1.Cmd("swarm", "update", "--autolock")
- c.Assert(err, checker.IsNil, check.Commentf("out: %v", outs))
+ assert.Assert(c, err == nil, "out: %v", outs)
unlockKey := getUnlockKey(d1, c, outs)
// joined workers start off unlocked
d2 := s.AddDaemon(c, true, false)
d2.RestartNode(c)
- waitAndAssert(c, time.Second, d2.CheckLocalNodeState, checker.Equals, swarm.LocalNodeStateActive)
+ poll.WaitOn(c, pollCheck(c, d2.CheckLocalNodeState, checker.Equals(swarm.LocalNodeStateActive)), poll.WithTimeout(time.Second))
// promote worker
outs, err = d1.Cmd("node", "promote", d2.NodeID())
assert.NilError(c, err)
- c.Assert(outs, checker.Contains, "promoted to a manager in the swarm")
-
+ assert.Assert(c, strings.Contains(outs, "promoted to a manager in the swarm"))
// join new manager node
d3 := s.AddDaemon(c, true, true)
@@ -1219,59 +1199,57 @@
cmd := d.Command("swarm", "unlock")
cmd.Stdin = bytes.NewBufferString(unlockKey)
icmd.RunCmd(cmd).Assert(c, icmd.Success)
- c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)
+ assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive)
}
// demote manager back to worker - workers are not locked
outs, err = d1.Cmd("node", "demote", d3.NodeID())
assert.NilError(c, err)
- c.Assert(outs, checker.Contains, "demoted in the swarm")
-
+ assert.Assert(c, strings.Contains(outs, "demoted in the swarm"))
// Wait for it to actually be demoted, for the key and cert to be replaced.
// Then restart and assert that the node is not locked. If we don't wait for the cert
// to be replaced, then the node still has the manager TLS key which is still locked
// (because we never want a manager TLS key to be on disk unencrypted if the cluster
// is set to autolock)
- waitAndAssert(c, defaultReconciliationTimeout, d3.CheckControlAvailable, checker.False)
- waitAndAssert(c, defaultReconciliationTimeout, func(c *check.C) (interface{}, check.CommentInterface) {
+ poll.WaitOn(c, pollCheck(c, d3.CheckControlAvailable, checker.False()), poll.WithTimeout(defaultReconciliationTimeout))
+ poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
certBytes, err := ioutil.ReadFile(filepath.Join(d3.Folder, "root", "swarm", "certificates", "swarm-node.crt"))
if err != nil {
- return "", check.Commentf("error: %v", err)
+ return "", fmt.Sprintf("error: %v", err)
}
certs, err := helpers.ParseCertificatesPEM(certBytes)
if err == nil && len(certs) > 0 && len(certs[0].Subject.OrganizationalUnit) > 0 {
- return certs[0].Subject.OrganizationalUnit[0], nil
+ return certs[0].Subject.OrganizationalUnit[0], ""
}
- return "", check.Commentf("could not get organizational unit from certificate")
- }, checker.Equals, "swarm-worker")
+ return "", "could not get organizational unit from certificate"
+ }, checker.Equals("swarm-worker")), poll.WithTimeout(defaultReconciliationTimeout))
// by now, it should *never* be locked on restart
d3.RestartNode(c)
- waitAndAssert(c, time.Second, d3.CheckLocalNodeState, checker.Equals, swarm.LocalNodeStateActive)
+ poll.WaitOn(c, pollCheck(c, d3.CheckLocalNodeState, checker.Equals(swarm.LocalNodeStateActive)), poll.WithTimeout(time.Second))
}
-func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *testing.T) {
d := s.AddDaemon(c, true, true)
outs, err := d.Cmd("swarm", "update", "--autolock")
- c.Assert(err, checker.IsNil, check.Commentf("out: %v", outs))
+ assert.Assert(c, err == nil, "out: %v", outs)
unlockKey := getUnlockKey(d, c, outs)
// Rotate multiple times
for i := 0; i != 3; i++ {
outs, err = d.Cmd("swarm", "unlock-key", "-q", "--rotate")
- c.Assert(err, checker.IsNil, check.Commentf("out: %v", outs))
+ assert.Assert(c, err == nil, "out: %v", outs)
// Strip \n
newUnlockKey := outs[:len(outs)-1]
- c.Assert(newUnlockKey, checker.Not(checker.Equals), "")
- c.Assert(newUnlockKey, checker.Not(checker.Equals), unlockKey)
+ assert.Assert(c, newUnlockKey != "")
+ assert.Assert(c, newUnlockKey != unlockKey)
d.RestartNode(c)
- c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateLocked)
+ assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateLocked)
outs, _ = d.Cmd("node", "ls")
- c.Assert(outs, checker.Contains, "Swarm is encrypted and needs to be unlocked")
-
+ assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
cmd := d.Command("swarm", "unlock")
cmd.Stdin = bytes.NewBufferString(unlockKey)
result := icmd.RunCmd(cmd)
@@ -1299,13 +1277,12 @@
})
outs, _ = d.Cmd("node", "ls")
- c.Assert(outs, checker.Contains, "Swarm is encrypted and needs to be unlocked")
-
+ assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
cmd = d.Command("swarm", "unlock")
cmd.Stdin = bytes.NewBufferString(newUnlockKey)
icmd.RunCmd(cmd).Assert(c, icmd.Success)
- c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)
+ assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive)
retry := 0
for {
@@ -1319,7 +1296,7 @@
}
}
assert.NilError(c, err)
- c.Assert(outs, checker.Not(checker.Contains), "Swarm is encrypted and needs to be unlocked")
+ assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
break
}
@@ -1330,7 +1307,7 @@
// 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
// key rotated.
-func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *testing.T) {
if runtime.GOARCH == "s390x" {
c.Skip("Disabled on s390x")
}
@@ -1343,27 +1320,26 @@
d3 := s.AddDaemon(c, true, true)
outs, err := d1.Cmd("swarm", "update", "--autolock")
- c.Assert(err, checker.IsNil, check.Commentf("%s", outs))
+ assert.Assert(c, err == nil, "%s", outs)
unlockKey := getUnlockKey(d1, c, outs)
// Rotate multiple times
for i := 0; i != 3; i++ {
outs, err = d1.Cmd("swarm", "unlock-key", "-q", "--rotate")
- c.Assert(err, checker.IsNil, check.Commentf("%s", outs))
+ assert.Assert(c, err == nil, "%s", outs)
// Strip \n
newUnlockKey := outs[:len(outs)-1]
- c.Assert(newUnlockKey, checker.Not(checker.Equals), "")
- c.Assert(newUnlockKey, checker.Not(checker.Equals), unlockKey)
+ assert.Assert(c, newUnlockKey != "")
+ assert.Assert(c, newUnlockKey != unlockKey)
d2.RestartNode(c)
d3.RestartNode(c)
for _, d := range []*daemon.Daemon{d2, d3} {
- c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateLocked)
+ assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateLocked)
outs, _ := d.Cmd("node", "ls")
- c.Assert(outs, checker.Contains, "Swarm is encrypted and needs to be unlocked")
-
+ assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
cmd := d.Command("swarm", "unlock")
cmd.Stdin = bytes.NewBufferString(unlockKey)
result := icmd.RunCmd(cmd)
@@ -1391,13 +1367,12 @@
})
outs, _ = d.Cmd("node", "ls")
- c.Assert(outs, checker.Contains, "Swarm is encrypted and needs to be unlocked")
-
+ assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
cmd = d.Command("swarm", "unlock")
cmd.Stdin = bytes.NewBufferString(newUnlockKey)
icmd.RunCmd(cmd).Assert(c, icmd.Success)
- c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)
+ assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive)
retry := 0
for {
@@ -1410,8 +1385,8 @@
continue
}
}
- c.Assert(err, checker.IsNil, check.Commentf("%s", outs))
- c.Assert(outs, checker.Not(checker.Contains), "Swarm is encrypted and needs to be unlocked")
+ assert.Assert(c, err == nil, "%s", outs)
+ assert.Assert(c, !strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
break
}
}
@@ -1420,14 +1395,14 @@
}
}
-func (s *DockerSwarmSuite) TestSwarmAlternateLockUnlock(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmAlternateLockUnlock(c *testing.T) {
d := s.AddDaemon(c, true, true)
for i := 0; i < 2; i++ {
// set to lock
outs, err := d.Cmd("swarm", "update", "--autolock")
- c.Assert(err, checker.IsNil, check.Commentf("out: %v", outs))
- c.Assert(outs, checker.Contains, "docker swarm unlock")
+ assert.Assert(c, err == nil, "out: %v", outs)
+ assert.Assert(c, strings.Contains(outs, "docker swarm unlock"))
unlockKey := getUnlockKey(d, c, outs)
checkSwarmUnlockedToLocked(c, d)
@@ -1436,16 +1411,16 @@
cmd.Stdin = bytes.NewBufferString(unlockKey)
icmd.RunCmd(cmd).Assert(c, icmd.Success)
- c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)
+ assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateActive)
outs, err = d.Cmd("swarm", "update", "--autolock=false")
- c.Assert(err, checker.IsNil, check.Commentf("out: %v", outs))
+ assert.Assert(c, err == nil, "out: %v", outs)
checkSwarmLockedToUnlocked(c, d)
}
}
-func (s *DockerSwarmSuite) TestExtraHosts(c *check.C) {
+func (s *DockerSwarmSuite) TestExtraHosts(c *testing.T) {
d := s.AddDaemon(c, true, true)
// Create a service
@@ -1454,7 +1429,7 @@
assert.NilError(c, err, out)
// Make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
// We need to get the container id.
out, err = d.Cmd("ps", "-a", "-q", "--no-trunc")
@@ -1465,10 +1440,10 @@
expectedOutput := "1.2.3.4\texample.com"
out, err = d.Cmd("exec", id, "cat", "/etc/hosts")
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
+ assert.Assert(c, strings.Contains(out, expectedOutput), "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)
d2 := s.AddDaemon(c, true, false)
d3 := s.AddDaemon(c, true, false)
@@ -1489,7 +1464,7 @@
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)
out, err := d.Cmd("network", "create", "-d", "overlay", "--ipam-opt", "foo=bar", "foo")
@@ -1498,29 +1473,28 @@
out, err = d.Cmd("network", "inspect", "--format", "{{.IPAM.Options}}", "foo")
assert.NilError(c, err, out)
- c.Assert(strings.TrimSpace(out), checker.Contains, "foo:bar")
- c.Assert(strings.TrimSpace(out), checker.Contains, "com.docker.network.ipam.serial:true")
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), "foo:bar"))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), "com.docker.network.ipam.serial:true"))
out, err = d.Cmd("service", "create", "--detach", "--no-resolve-image", "--network=foo", "--name", "top", "busybox", "top")
assert.NilError(c, err, out)
// make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
out, err = d.Cmd("network", "inspect", "--format", "{{.IPAM.Options}}", "foo")
assert.NilError(c, err, out)
- c.Assert(strings.TrimSpace(out), checker.Contains, "foo:bar")
- c.Assert(strings.TrimSpace(out), checker.Contains, "com.docker.network.ipam.serial:true")
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), "foo:bar"))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), "com.docker.network.ipam.serial:true"))
}
// 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".
-func (s *DockerSwarmSuite) TestSwarmNetworkCreateIssue27866(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmNetworkCreateIssue27866(c *testing.T) {
d := s.AddDaemon(c, true, true)
out, err := d.Cmd("network", "inspect", "-f", "{{.Id}}", "ingress")
assert.NilError(c, err, "out: %v", out)
ingressID := strings.TrimSpace(out)
- c.Assert(ingressID, checker.Not(checker.Equals), "")
+ assert.Assert(c, ingressID != "")
// create a network of which name is the prefix of the ID of an overlay network
// (ingressID in this case)
@@ -1538,7 +1512,7 @@
// "network with name FOO already exists".
// Note that it is to ok have multiple networks with the same name if the operations are done
// in parallel. (#18864)
-func (s *DockerSwarmSuite) TestSwarmNetworkCreateDup(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmNetworkCreateDup(c *testing.T) {
d := s.AddDaemon(c, true, true)
drivers := []string{"bridge", "overlay"}
for i, driver1 := range drivers {
@@ -1549,8 +1523,7 @@
out, err := d.Cmd("network", "create", "--driver", driver1, nwName)
assert.NilError(c, err, "out: %v", out)
out, err = d.Cmd("network", "create", "--driver", driver2, nwName)
- c.Assert(out, checker.Contains,
- fmt.Sprintf("network with name %s already exists", nwName))
+ assert.Assert(c, strings.Contains(out, fmt.Sprintf("network with name %s already exists", nwName)))
assert.ErrorContains(c, err, "")
c.Logf("As expected, the attempt to network %q with %q failed: %s",
nwName, driver2, out)
@@ -1560,7 +1533,7 @@
}
}
-func (s *DockerSwarmSuite) TestSwarmPublishDuplicatePorts(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmPublishDuplicatePorts(c *testing.T) {
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")
@@ -1568,24 +1541,23 @@
id := strings.TrimSpace(out)
// make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
// Total len = 4, with 2 dynamic ports and 2 non-dynamic ports
// Dynamic ports are likely to be 30000 and 30001 but doesn't matter
out, err = d.Cmd("service", "inspect", "--format", "{{.Endpoint.Ports}} len={{len .Endpoint.Ports}}", id)
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, "len=4")
- c.Assert(out, checker.Contains, "{ tcp 80 5005 ingress}")
- c.Assert(out, checker.Contains, "{ tcp 80 5006 ingress}")
+ assert.Assert(c, strings.Contains(out, "len=4"))
+ assert.Assert(c, strings.Contains(out, "{ tcp 80 5005 ingress}"))
+ assert.Assert(c, strings.Contains(out, "{ tcp 80 5006 ingress}"))
}
-func (s *DockerSwarmSuite) TestSwarmJoinWithDrain(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmJoinWithDrain(c *testing.T) {
d := s.AddDaemon(c, true, true)
out, err := d.Cmd("node", "ls")
assert.NilError(c, err)
- c.Assert(out, checker.Not(checker.Contains), "Drain")
-
+ assert.Assert(c, !strings.Contains(out, "Drain"))
out, err = d.Cmd("swarm", "join-token", "-q", "manager")
assert.NilError(c, err)
assert.Assert(c, strings.TrimSpace(out) != "")
@@ -1600,14 +1572,13 @@
out, err = d.Cmd("node", "ls")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, "Drain")
-
+ assert.Assert(c, strings.Contains(out, "Drain"))
out, err = d1.Cmd("node", "ls")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, "Drain")
+ assert.Assert(c, strings.Contains(out, "Drain"))
}
-func (s *DockerSwarmSuite) TestSwarmInitWithDrain(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmInitWithDrain(c *testing.T) {
d := s.AddDaemon(c, false, false)
out, err := d.Cmd("swarm", "init", "--availability", "drain")
@@ -1615,10 +1586,10 @@
out, err = d.Cmd("node", "ls")
assert.NilError(c, err)
- c.Assert(out, checker.Contains, "Drain")
+ assert.Assert(c, strings.Contains(out, "Drain"))
}
-func (s *DockerSwarmSuite) TestSwarmReadonlyRootfs(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmReadonlyRootfs(c *testing.T) {
testRequires(c, DaemonIsLinux, UserNamespaceROMount)
d := s.AddDaemon(c, true, true)
@@ -1627,7 +1598,7 @@
assert.NilError(c, err, out)
// make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
out, err = d.Cmd("service", "inspect", "--format", "{{ .Spec.TaskTemplate.ContainerSpec.ReadOnly }}", "top")
assert.NilError(c, err, out)
@@ -1639,7 +1610,7 @@
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)
name := "foo"
@@ -1678,8 +1649,7 @@
// Name with duplicates
out, err = d.Cmd("network", "inspect", "--format", "{{.ID}}", name)
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "2 matches found based on name")
-
+ assert.Assert(c, strings.Contains(out, "2 matches found based on name"))
out, err = d.Cmd("network", "rm", n2.ID)
assert.NilError(c, err, out)
@@ -1701,10 +1671,10 @@
// Name with duplicates
out, err = d.Cmd("network", "inspect", "--format", "{{.ID}}", name)
assert.ErrorContains(c, err, "", out)
- c.Assert(out, checker.Contains, "2 matches found based on name")
+ assert.Assert(c, strings.Contains(out, "2 matches found based on name"))
}
-func (s *DockerSwarmSuite) TestSwarmStopSignal(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmStopSignal(c *testing.T) {
testRequires(c, DaemonIsLinux, UserNamespaceROMount)
d := s.AddDaemon(c, true, true)
@@ -1713,7 +1683,7 @@
assert.NilError(c, err, out)
// make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
out, err = d.Cmd("service", "inspect", "--format", "{{ .Spec.TaskTemplate.ContainerSpec.StopSignal }}", "top")
assert.NilError(c, err, out)
@@ -1732,7 +1702,7 @@
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)
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", "top1", "busybox", "top")
@@ -1744,38 +1714,36 @@
assert.Assert(c, strings.TrimSpace(out) != "")
// make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 2)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(2)), poll.WithTimeout(defaultReconciliationTimeout))
out, err = d.Cmd("service", "ls")
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, "top1")
- c.Assert(out, checker.Contains, "top2")
- c.Assert(out, checker.Not(checker.Contains), "localnet")
-
+ assert.Assert(c, strings.Contains(out, "top1"))
+ assert.Assert(c, strings.Contains(out, "top2"))
+ assert.Assert(c, !strings.Contains(out, "localnet"))
out, err = d.Cmd("service", "ls", "--filter", "mode=global")
- c.Assert(out, checker.Not(checker.Contains), "top1")
- c.Assert(out, checker.Contains, "top2")
+ assert.Assert(c, !strings.Contains(out, "top1"))
+ assert.Assert(c, strings.Contains(out, "top2"))
assert.NilError(c, err, out)
out, err = d.Cmd("service", "ls", "--filter", "mode=replicated")
assert.NilError(c, err, out)
- c.Assert(out, checker.Contains, "top1")
- c.Assert(out, checker.Not(checker.Contains), "top2")
+ assert.Assert(c, strings.Contains(out, "top1"))
+ assert.Assert(c, !strings.Contains(out, "top2"))
}
-func (s *DockerSwarmSuite) TestSwarmInitUnspecifiedDataPathAddr(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmInitUnspecifiedDataPathAddr(c *testing.T) {
d := s.AddDaemon(c, false, false)
out, err := d.Cmd("swarm", "init", "--data-path-addr", "0.0.0.0")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "data path address must be a non-zero IP")
-
+ assert.Assert(c, strings.Contains(out, "data path address must be a non-zero IP"))
out, err = d.Cmd("swarm", "init", "--data-path-addr", "0.0.0.0:2000")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "data path address must be a non-zero IP")
+ assert.Assert(c, strings.Contains(out, "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)
out, err := d.Cmd("swarm", "join-token", "-q", "worker")
@@ -1798,7 +1766,7 @@
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 {
c.Fatalf("retry count %d is invalid. It should be no less than 1", retry)
return ""
@@ -1825,7 +1793,7 @@
return ""
}
-func (s *DockerSwarmSuite) TestSwarmClusterEventsSource(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmClusterEventsSource(c *testing.T) {
d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, true)
d3 := s.AddDaemon(c, true, false)
@@ -1834,7 +1802,7 @@
out, err := d1.Cmd("network", "create", "--attachable", "-d", "overlay", "foo")
assert.NilError(c, err, out)
networkID := strings.TrimSpace(out)
- c.Assert(networkID, checker.Not(checker.Equals), "")
+ assert.Assert(c, networkID != "")
// d1, d2 are managers that can get swarm events
waitForEvent(c, d1, "0", "-f scope=swarm", "network create "+networkID, defaultRetryCount)
@@ -1842,10 +1810,10 @@
// d3 is a worker, not able to get cluster events
out = waitForEvent(c, d3, "0", "-f scope=swarm", "", 1)
- c.Assert(out, checker.Not(checker.Contains), "network create ")
+ assert.Assert(c, !strings.Contains(out, "network create "))
}
-func (s *DockerSwarmSuite) TestSwarmClusterEventsScope(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmClusterEventsScope(c *testing.T) {
d := s.AddDaemon(c, true, true)
// create a service
@@ -1855,18 +1823,17 @@
// scope swarm filters cluster events
out = waitForEvent(c, d, "0", "-f scope=swarm", "service create "+serviceID, defaultRetryCount)
- c.Assert(out, checker.Not(checker.Contains), "container create ")
-
+ assert.Assert(c, !strings.Contains(out, "container create "))
// all events are returned if scope is not specified
waitForEvent(c, d, "0", "", "service create "+serviceID, 1)
waitForEvent(c, d, "0", "", "container create ", defaultRetryCount)
// scope local only shows non-cluster events
out = waitForEvent(c, d, "0", "-f scope=local", "container create ", 1)
- c.Assert(out, checker.Not(checker.Contains), "service create ")
+ assert.Assert(c, !strings.Contains(out, "service create "))
}
-func (s *DockerSwarmSuite) TestSwarmClusterEventsType(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmClusterEventsType(c *testing.T) {
d := s.AddDaemon(c, true, true)
// create a service
@@ -1878,18 +1845,17 @@
out, err = d.Cmd("network", "create", "--attachable", "-d", "overlay", "foo")
assert.NilError(c, err, out)
networkID := strings.TrimSpace(out)
- c.Assert(networkID, checker.Not(checker.Equals), "")
+ assert.Assert(c, networkID != "")
// filter by service
out = waitForEvent(c, d, "0", "-f type=service", "service create "+serviceID, defaultRetryCount)
- c.Assert(out, checker.Not(checker.Contains), "network create")
-
+ assert.Assert(c, !strings.Contains(out, "network create"))
// filter by network
out = waitForEvent(c, d, "0", "-f type=network", "network create "+networkID, defaultRetryCount)
- c.Assert(out, checker.Not(checker.Contains), "service create")
+ assert.Assert(c, !strings.Contains(out, "service create"))
}
-func (s *DockerSwarmSuite) TestSwarmClusterEventsService(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmClusterEventsService(c *testing.T) {
d := s.AddDaemon(c, true, true)
// create a service
@@ -1906,21 +1872,18 @@
// wait for service update start
out = waitForEvent(c, d, t1, "-f scope=swarm", "service update "+serviceID, defaultRetryCount)
- c.Assert(out, checker.Contains, "updatestate.new=updating")
-
+ assert.Assert(c, strings.Contains(out, "updatestate.new=updating"))
// allow service update complete. This is a service with 1 instance
time.Sleep(400 * time.Millisecond)
out = waitForEvent(c, d, t1, "-f scope=swarm", "service update "+serviceID, defaultRetryCount)
- c.Assert(out, checker.Contains, "updatestate.new=completed, updatestate.old=updating")
-
+ assert.Assert(c, strings.Contains(out, "updatestate.new=completed, updatestate.old=updating"))
// scale service
t2 := daemonUnixTime(c)
out, err = d.Cmd("service", "scale", "test=3")
assert.NilError(c, err, out)
out = waitForEvent(c, d, t2, "-f scope=swarm", "service update "+serviceID, defaultRetryCount)
- c.Assert(out, checker.Contains, "replicas.new=3, replicas.old=1")
-
+ assert.Assert(c, strings.Contains(out, "replicas.new=3, replicas.old=1"))
// remove service
t3 := daemonUnixTime(c)
out, err = d.Cmd("service", "rm", "test")
@@ -1929,7 +1892,7 @@
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)
s.AddDaemon(c, true, true)
d3 := s.AddDaemon(c, true, true)
@@ -1943,8 +1906,7 @@
// filter by type
out = waitForEvent(c, d1, t1, "-f type=node", "node update "+d3ID, defaultRetryCount)
- c.Assert(out, checker.Contains, "availability.new=pause, availability.old=active")
-
+ assert.Assert(c, strings.Contains(out, "availability.new=pause, availability.old=active"))
t2 := daemonUnixTime(c)
out, err = d1.Cmd("node", "demote", d3ID)
assert.NilError(c, err, out)
@@ -1959,7 +1921,7 @@
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)
// create a network
@@ -1978,7 +1940,7 @@
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)
testName := "test_secret"
@@ -1988,7 +1950,7 @@
},
Data: []byte("TESTINGDATA"),
})
- c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
+ assert.Assert(c, id != "", "secrets: %s", id)
waitForEvent(c, d, "0", "-f scope=swarm", "secret create "+id, defaultRetryCount)
@@ -1998,7 +1960,7 @@
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)
testName := "test_config"
@@ -2008,7 +1970,7 @@
},
Data: []byte("TESTINGDATA"),
})
- c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("configs: %s", id))
+ assert.Assert(c, id != "", "configs: %s", id)
waitForEvent(c, d, "0", "-f scope=swarm", "config create "+id, defaultRetryCount)
@@ -2018,15 +1980,14 @@
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")
- c.Assert(err, checker.IsNil, check.Commentf("%s", unlockKey))
+ assert.Assert(c, err == nil, "%s", unlockKey)
unlockKey = strings.TrimSuffix(unlockKey, "\n")
// Check that "docker swarm init --autolock" or "docker swarm update --autolock"
// contains all the expected strings, including the unlock key
- c.Assert(autolockOutput, checker.Contains, "docker swarm unlock")
- c.Assert(autolockOutput, checker.Contains, unlockKey)
-
+ assert.Assert(c, strings.Contains(autolockOutput, "docker swarm unlock"))
+ assert.Assert(c, strings.Contains(autolockOutput, unlockKey))
return unlockKey
}
diff --git a/integration-cli/docker_cli_swarm_unix_test.go b/integration-cli/docker_cli_swarm_unix_test.go
index bfaa08b..ea51256 100644
--- a/integration-cli/docker_cli_swarm_unix_test.go
+++ b/integration-cli/docker_cli_swarm_unix_test.go
@@ -5,22 +5,23 @@
import (
"encoding/json"
"strings"
+ "testing"
"time"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/integration-cli/checker"
- "github.com/go-check/check"
"gotest.tools/assert"
+ "gotest.tools/poll"
)
-func (s *DockerSwarmSuite) TestSwarmVolumePlugin(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmVolumePlugin(c *testing.T) {
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")
assert.NilError(c, err, out)
// Make sure task stays pending before plugin is available
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckServiceTasksInStateWithError("top", swarm.TaskStatePending, "missing plugin on 1 node"), checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckServiceTasksInStateWithError("top", swarm.TaskStatePending, "missing plugin on 1 node"), checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
plugin := newVolumePlugin(c, "customvolumedriver")
defer plugin.Close()
@@ -34,7 +35,7 @@
// this long delay.
// make sure task has been deployed.
- waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
+ poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount, checker.Equals(1)), poll.WithTimeout(defaultReconciliationTimeout))
out, err = d.Cmd("ps", "-q")
assert.NilError(c, err)
@@ -55,7 +56,7 @@
}
// Test network plugin filter in swarm
-func (s *DockerSwarmSuite) TestSwarmNetworkPluginV2(c *check.C) {
+func (s *DockerSwarmSuite) TestSwarmNetworkPluginV2(c *testing.T) {
testRequires(c, IsAmd64)
d1 := s.AddDaemon(c, true, true)
d2 := s.AddDaemon(c, true, false)
@@ -80,7 +81,7 @@
assert.NilError(c, err)
// wait for tasks ready
- waitAndAssert(c, defaultReconciliationTimeout, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount), checker.Equals, 2)
+ poll.WaitOn(c, pollCheck(c, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount), checker.Equals(2)), poll.WithTimeout(defaultReconciliationTimeout))
// remove service
_, err = d1.Cmd("service", "rm", serviceName)
@@ -88,7 +89,7 @@
// wait to ensure all containers have exited before removing the plugin. Else there's a
// possibility of container exits erroring out due to plugins being unavailable.
- waitAndAssert(c, defaultReconciliationTimeout, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount), checker.Equals, 0)
+ poll.WaitOn(c, pollCheck(c, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount), checker.Equals(0)), poll.WithTimeout(defaultReconciliationTimeout))
// disable plugin on worker
_, err = d2.Cmd("plugin", "disable", "-f", pluginName)
@@ -101,6 +102,6 @@
_, err = d1.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", serviceName, "--mode=global", "--network", networkName, image, "top")
assert.NilError(c, err)
- waitAndAssert(c, defaultReconciliationTimeout, d1.CheckRunningTaskImages, checker.DeepEquals,
- map[string]int{image: 1})
+ poll.WaitOn(c, pollCheck(c, d1.CheckRunningTaskImages, checker.DeepEquals(map[string]int{image: 1})), poll.WithTimeout(defaultReconciliationTimeout))
+
}
diff --git a/integration-cli/docker_cli_top_test.go b/integration-cli/docker_cli_top_test.go
index b078b7b..219f9b0 100644
--- a/integration-cli/docker_cli_top_test.go
+++ b/integration-cli/docker_cli_top_test.go
@@ -2,13 +2,13 @@
import (
"strings"
+ "testing"
- "github.com/go-check/check"
"gotest.tools/assert"
"gotest.tools/icmd"
)
-func (s *DockerSuite) TestTopMultipleArgs(c *check.C) {
+func (s *DockerSuite) TestTopMultipleArgs(c *testing.T) {
out := runSleepingContainer(c, "-d")
cleanedContainerID := strings.TrimSpace(out)
@@ -23,7 +23,7 @@
result.Assert(c, expected)
}
-func (s *DockerSuite) TestTopNonPrivileged(c *check.C) {
+func (s *DockerSuite) TestTopNonPrivileged(c *testing.T) {
out := runSleepingContainer(c, "-d")
cleanedContainerID := strings.TrimSpace(out)
@@ -47,7 +47,7 @@
// TestTopWindowsCoreProcesses validates that there are lines for the critical
// processes which are found in a Windows container. Note Windows is architecturally
// very different to Linux in this regard.
-func (s *DockerSuite) TestTopWindowsCoreProcesses(c *check.C) {
+func (s *DockerSuite) TestTopWindowsCoreProcesses(c *testing.T) {
testRequires(c, DaemonIsWindows)
out := runSleepingContainer(c, "-d")
cleanedContainerID := strings.TrimSpace(out)
@@ -58,7 +58,7 @@
}
}
-func (s *DockerSuite) TestTopPrivileged(c *check.C) {
+func (s *DockerSuite) TestTopPrivileged(c *testing.T) {
// Windows does not support --privileged
testRequires(c, DaemonIsLinux, NotUserNamespace)
out, _ := dockerCmd(c, "run", "--privileged", "-i", "-d", "busybox", "top")
diff --git a/integration-cli/docker_cli_update_unix_test.go b/integration-cli/docker_cli_update_unix_test.go
index 16b1a82..a02e154 100644
--- a/integration-cli/docker_cli_update_unix_test.go
+++ b/integration-cli/docker_cli_update_unix_test.go
@@ -8,6 +8,7 @@
"fmt"
"os/exec"
"strings"
+ "testing"
"time"
"github.com/creack/pty"
@@ -15,11 +16,10 @@
"github.com/docker/docker/client"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/pkg/parsers/kernel"
- "github.com/go-check/check"
"gotest.tools/assert"
)
-func (s *DockerSuite) TestUpdateRunningContainer(c *check.C) {
+func (s *DockerSuite) TestUpdateRunningContainer(c *testing.T) {
testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport)
@@ -34,7 +34,7 @@
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, memoryLimitSupport)
@@ -50,7 +50,7 @@
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, memoryLimitSupport)
@@ -65,7 +65,7 @@
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, cpuShare)
@@ -82,7 +82,7 @@
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, memoryLimitSupport)
testRequires(c, cpuShare)
@@ -100,7 +100,7 @@
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, memoryLimitSupport)
@@ -112,7 +112,7 @@
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, memoryLimitSupport)
@@ -122,7 +122,7 @@
assert.ErrorContains(c, err, "")
}
-func (s *DockerSuite) TestUpdateKernelMemory(c *check.C) {
+func (s *DockerSuite) TestUpdateKernelMemory(c *testing.T) {
testRequires(c, DaemonIsLinux, kernelMemorySupport)
name := "test-update-container"
@@ -136,7 +136,7 @@
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)
isNewKernel := CheckKernelVersion(4, 6, 0)
@@ -183,7 +183,7 @@
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, memoryLimitSupport)
testRequires(c, swapMemorySupport)
@@ -199,7 +199,7 @@
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, memoryLimitSupport)
testRequires(c, swapMemorySupport)
@@ -224,7 +224,7 @@
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, memoryLimitSupport)
testRequires(c, cpuCfsQuota)
@@ -253,7 +253,7 @@
assert.Equal(c, preMemLimit, curMemLimit)
}
-func (s *DockerSuite) TestUpdateMemoryWithSwapMemory(c *check.C) {
+func (s *DockerSuite) TestUpdateMemoryWithSwapMemory(c *testing.T) {
testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport)
testRequires(c, swapMemorySupport)
@@ -267,7 +267,7 @@
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)
out, _ := dockerCmd(c, "run", "-tid", "--restart=always", "busybox", "sh")
@@ -295,7 +295,7 @@
assert.NilError(c, waitRun(id))
}
-func (s *DockerSuite) TestUpdateWithNanoCPUs(c *check.C) {
+func (s *DockerSuite) TestUpdateWithNanoCPUs(c *testing.T) {
testRequires(c, cpuCfsQuota, cpuCfsPeriod)
file1 := "/sys/fs/cgroup/cpu/cpu.cfs_quota_us"
diff --git a/integration-cli/docker_cli_userns_test.go b/integration-cli/docker_cli_userns_test.go
index c423f5c..b3b68c1 100644
--- a/integration-cli/docker_cli_userns_test.go
+++ b/integration-cli/docker_cli_userns_test.go
@@ -11,18 +11,17 @@
"path/filepath"
"strconv"
"strings"
+ "testing"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/pkg/system"
- "github.com/go-check/check"
"gotest.tools/assert"
)
// user namespaces test: run daemon with remapped root setting
// 1. validate uid/gid maps are set properly
// 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)
s.d.StartWithBusybox(c, "--userns-remap", "default")
@@ -38,7 +37,7 @@
// we need to find the uid and gid of the remapped root from the daemon's root dir info
uidgid := strings.Split(filepath.Base(s.d.Root), ".")
- c.Assert(uidgid, checker.HasLen, 2, check.Commentf("Should have gotten uid/gid strings from root dirname: %s", filepath.Base(s.d.Root)))
+ assert.Equal(c, len(uidgid), 2, fmt.Sprintf("Should have gotten uid/gid strings from root dirname: %s", filepath.Base(s.d.Root)))
uid, err := strconv.Atoi(uidgid[0])
assert.NilError(c, err, "Can't parse uid")
gid, err := strconv.Atoi(uidgid[1])
@@ -51,16 +50,16 @@
assert.NilError(c, err, "Output: %s", out)
user := s.findUser(c, "userns")
- c.Assert(uidgid[0], checker.Equals, user)
+ assert.Equal(c, uidgid[0], user)
// check that the created directory is owned by remapped uid:gid
statNotExists, err := system.Stat(tmpDirNotExists)
assert.NilError(c, err)
- c.Assert(statNotExists.UID(), checker.Equals, uint32(uid), check.Commentf("Created directory not owned by remapped root UID"))
- c.Assert(statNotExists.GID(), checker.Equals, uint32(gid), check.Commentf("Created directory not owned by remapped root GID"))
+ assert.Equal(c, statNotExists.UID(), uint32(uid), "Created directory not owned by remapped root UID")
+ assert.Equal(c, statNotExists.GID(), uint32(gid), "Created directory not owned by remapped root GID")
pid, err := s.d.Cmd("inspect", "--format={{.State.Pid}}", "userns")
- c.Assert(err, checker.IsNil, check.Commentf("Could not inspect running container: out: %q", pid))
+ assert.Assert(c, err == nil, "Could not inspect running container: out: %q", pid)
// check the uid and gid maps for the PID to ensure root is remapped
// (cmd = cat /proc/<pid>/uid_map | grep -E '0\s+9999\s+1')
_, err = RunCommandPipelineWithOutput(
@@ -76,21 +75,21 @@
// check that the touched file is owned by remapped uid:gid
stat, err := system.Stat(filepath.Join(tmpDir, "testfile"))
assert.NilError(c, err)
- c.Assert(stat.UID(), checker.Equals, uint32(uid), check.Commentf("Touched file not owned by remapped root UID"))
- c.Assert(stat.GID(), checker.Equals, uint32(gid), check.Commentf("Touched file not owned by remapped root GID"))
+ assert.Equal(c, stat.UID(), uint32(uid), "Touched file not owned by remapped root UID")
+ assert.Equal(c, stat.GID(), uint32(gid), "Touched file not owned by remapped root GID")
// use host usernamespace
out, err = s.d.Cmd("run", "-d", "--name", "userns_skip", "--userns", "host", "busybox", "sh", "-c", "touch /goofy/testfile; top")
- c.Assert(err, checker.IsNil, check.Commentf("Output: %s", out))
+ assert.Assert(c, err == nil, "Output: %s", out)
user = s.findUser(c, "userns_skip")
// userns are skipped, user is root
- c.Assert(user, checker.Equals, "root")
+ assert.Equal(c, user, "root")
}
// 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)
- c.Assert(err, checker.IsNil, check.Commentf("Output: %s", out))
+ assert.Assert(c, err == nil, "Output: %s", out)
rows := strings.Split(out, "\n")
if len(rows) < 2 {
// No process rows founds
diff --git a/integration-cli/docker_cli_v2_only_test.go b/integration-cli/docker_cli_v2_only_test.go
index aa15694..299ea50 100644
--- a/integration-cli/docker_cli_v2_only_test.go
+++ b/integration-cli/docker_cli_v2_only_test.go
@@ -5,9 +5,9 @@
"io/ioutil"
"net/http"
"os"
+ "testing"
"github.com/docker/docker/internal/test/registry"
- "github.com/go-check/check"
"gotest.tools/assert"
)
@@ -25,7 +25,7 @@
// TestV2Only ensures that a daemon does not
// 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)
defer reg.Close()
assert.NilError(c, err)
diff --git a/integration-cli/docker_cli_volume_test.go b/integration-cli/docker_cli_volume_test.go
index 8e6321f..f5fcf60 100644
--- a/integration-cli/docker_cli_volume_test.go
+++ b/integration-cli/docker_cli_volume_test.go
@@ -8,19 +8,18 @@
"os/exec"
"path/filepath"
"strings"
+ "testing"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/client"
- "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli/build"
- "github.com/go-check/check"
"gotest.tools/assert"
"gotest.tools/icmd"
)
-func (s *DockerSuite) TestVolumeCLICreate(c *check.C) {
+func (s *DockerSuite) TestVolumeCLICreate(c *testing.T) {
dockerCmd(c, "volume", "create")
_, _, err := dockerCmdWithError("volume", "create", "-d", "nosuchdriver")
@@ -29,31 +28,26 @@
// test using hidden --name option
out, _ := dockerCmd(c, "volume", "create", "--name=test")
name := strings.TrimSpace(out)
- c.Assert(name, check.Equals, "test")
+ assert.Equal(c, name, "test")
out, _ = dockerCmd(c, "volume", "create", "test2")
name = strings.TrimSpace(out)
- c.Assert(name, check.Equals, "test2")
+ assert.Equal(c, name, "test2")
}
-func (s *DockerSuite) TestVolumeCLIInspect(c *check.C) {
- c.Assert(
- exec.Command(dockerBinary, "volume", "inspect", "doesnotexist").Run(),
- check.Not(check.IsNil),
- check.Commentf("volume inspect should error on non-existent volume"),
- )
-
+func (s *DockerSuite) TestVolumeCLIInspect(c *testing.T) {
+ assert.Assert(c, exec.Command(dockerBinary, "volume", "inspect", "doesnotexist").Run() != nil, "volume inspect should error on non-existent volume")
out, _ := dockerCmd(c, "volume", "create")
name := strings.TrimSpace(out)
out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Name }}", name)
- c.Assert(strings.TrimSpace(out), check.Equals, name)
+ assert.Equal(c, strings.TrimSpace(out), name)
dockerCmd(c, "volume", "create", "test")
out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Name }}", "test")
- c.Assert(strings.TrimSpace(out), check.Equals, "test")
+ assert.Equal(c, strings.TrimSpace(out), "test")
}
-func (s *DockerSuite) TestVolumeCLIInspectMulti(c *check.C) {
+func (s *DockerSuite) TestVolumeCLIInspectMulti(c *testing.T) {
dockerCmd(c, "volume", "create", "test1")
dockerCmd(c, "volume", "create", "test2")
dockerCmd(c, "volume", "create", "test3")
@@ -65,12 +59,12 @@
})
out := result.Stdout()
- c.Assert(out, checker.Contains, "test1")
- c.Assert(out, checker.Contains, "test2")
- c.Assert(out, checker.Contains, "test3")
+ assert.Assert(c, strings.Contains(out, "test1"))
+ assert.Assert(c, strings.Contains(out, "test2"))
+ assert.Assert(c, strings.Contains(out, "test3"))
}
-func (s *DockerSuite) TestVolumeCLILs(c *check.C) {
+func (s *DockerSuite) TestVolumeCLILs(c *testing.T) {
prefix, _ := getPrefixAndSlashFromDaemonPlatform()
dockerCmd(c, "volume", "create", "aaa")
@@ -83,7 +77,7 @@
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", "test")
dockerCmd(c, "volume", "create", "soo")
@@ -92,7 +86,7 @@
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", "test")
dockerCmd(c, "volume", "create", "soo")
@@ -111,7 +105,7 @@
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")
for _, expect := range expected {
found := false
@@ -125,7 +119,7 @@
}
}
-func (s *DockerSuite) TestVolumeCLILsFilterDangling(c *check.C) {
+func (s *DockerSuite) TestVolumeCLILsFilterDangling(c *testing.T) {
prefix, _ := getPrefixAndSlashFromDaemonPlatform()
dockerCmd(c, "volume", "create", "testnotinuse1")
dockerCmd(c, "volume", "create", "testisinuse1")
@@ -139,55 +133,50 @@
out, _ := dockerCmd(c, "volume", "ls")
// No filter, all volumes should show
- c.Assert(out, checker.Contains, "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output"))
- c.Assert(out, checker.Contains, "testisinuse1\n", check.Commentf("expected volume 'testisinuse1' in output"))
- c.Assert(out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output"))
-
+ assert.Assert(c, strings.Contains(out, "testnotinuse1\n"), "expected volume 'testnotinuse1' in output")
+ assert.Assert(c, strings.Contains(out, "testisinuse1\n"), "expected volume 'testisinuse1' in output")
+ assert.Assert(c, strings.Contains(out, "testisinuse2\n"), "expected volume 'testisinuse2' in output")
out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=false")
// Explicitly disabling dangling
- c.Assert(out, check.Not(checker.Contains), "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output"))
- c.Assert(out, checker.Contains, "testisinuse1\n", check.Commentf("expected volume 'testisinuse1' in output"))
- c.Assert(out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output"))
-
+ assert.Assert(c, !strings.Contains(out, "testnotinuse1\n"), "expected volume 'testnotinuse1' in output")
+ assert.Assert(c, strings.Contains(out, "testisinuse1\n"), "expected volume 'testisinuse1' in output")
+ assert.Assert(c, strings.Contains(out, "testisinuse2\n"), "expected volume 'testisinuse2' in output")
out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=true")
// Filter "dangling" volumes; only "dangling" (unused) volumes should be in the output
- c.Assert(out, checker.Contains, "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output"))
- c.Assert(out, check.Not(checker.Contains), "testisinuse1\n", check.Commentf("volume 'testisinuse1' in output, but not expected"))
- c.Assert(out, check.Not(checker.Contains), "testisinuse2\n", check.Commentf("volume 'testisinuse2' in output, but not expected"))
-
+ assert.Assert(c, strings.Contains(out, "testnotinuse1\n"), "expected volume 'testnotinuse1' in output")
+ assert.Assert(c, !strings.Contains(out, "testisinuse1\n"), "volume 'testisinuse1' in output, but not expected")
+ assert.Assert(c, !strings.Contains(out, "testisinuse2\n"), "volume 'testisinuse2' in output, but not expected")
out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=1")
// Filter "dangling" volumes; only "dangling" (unused) volumes should be in the output, dangling also accept 1
- c.Assert(out, checker.Contains, "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output"))
- c.Assert(out, check.Not(checker.Contains), "testisinuse1\n", check.Commentf("volume 'testisinuse1' in output, but not expected"))
- c.Assert(out, check.Not(checker.Contains), "testisinuse2\n", check.Commentf("volume 'testisinuse2' in output, but not expected"))
-
+ assert.Assert(c, strings.Contains(out, "testnotinuse1\n"), "expected volume 'testnotinuse1' in output")
+ assert.Assert(c, !strings.Contains(out, "testisinuse1\n"), "volume 'testisinuse1' in output, but not expected")
+ assert.Assert(c, !strings.Contains(out, "testisinuse2\n"), "volume 'testisinuse2' in output, but not expected")
out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=0")
// dangling=0 is same as dangling=false case
- c.Assert(out, check.Not(checker.Contains), "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output"))
- c.Assert(out, checker.Contains, "testisinuse1\n", check.Commentf("expected volume 'testisinuse1' in output"))
- c.Assert(out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output"))
-
+ assert.Assert(c, !strings.Contains(out, "testnotinuse1\n"), "expected volume 'testnotinuse1' in output")
+ assert.Assert(c, strings.Contains(out, "testisinuse1\n"), "expected volume 'testisinuse1' in output")
+ assert.Assert(c, strings.Contains(out, "testisinuse2\n"), "expected volume 'testisinuse2' in output")
out, _ = dockerCmd(c, "volume", "ls", "--filter", "name=testisin")
- c.Assert(out, check.Not(checker.Contains), "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output"))
- c.Assert(out, checker.Contains, "testisinuse1\n", check.Commentf("expected volume 'testisinuse1' in output"))
- c.Assert(out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output"))
+ assert.Assert(c, !strings.Contains(out, "testnotinuse1\n"), "expected volume 'testnotinuse1' in output")
+ assert.Assert(c, strings.Contains(out, "testisinuse1\n"), "expected volume 'testisinuse1' in output")
+ assert.Assert(c, strings.Contains(out, "testisinuse2\n"), "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")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "Invalid filter")
+ assert.Assert(c, strings.Contains(out, "Invalid filter"))
}
-func (s *DockerSuite) TestVolumeCLILsWithIncorrectFilterValue(c *check.C) {
+func (s *DockerSuite) TestVolumeCLILsWithIncorrectFilterValue(c *testing.T) {
out, _, err := dockerCmdWithError("volume", "ls", "-f", "dangling=invalid")
assert.ErrorContains(c, err, "")
- c.Assert(out, checker.Contains, "Invalid filter")
+ assert.Assert(c, strings.Contains(out, "Invalid filter"))
}
-func (s *DockerSuite) TestVolumeCLIRm(c *check.C) {
+func (s *DockerSuite) TestVolumeCLIRm(c *testing.T) {
prefix, _ := getPrefixAndSlashFromDaemonPlatform()
out, _ := dockerCmd(c, "volume", "create")
id := strings.TrimSpace(out)
@@ -205,30 +194,25 @@
})
out, _ = dockerCmd(c, "run", "--volumes-from=test", "--name=test2", "busybox", "sh", "-c", "cat /foo/bar")
- c.Assert(strings.TrimSpace(out), check.Equals, "hello")
+ assert.Equal(c, strings.TrimSpace(out), "hello")
dockerCmd(c, "rm", "-fv", "test2")
dockerCmd(c, "volume", "inspect", volumeID)
dockerCmd(c, "rm", "-f", "test")
out, _ = dockerCmd(c, "run", "--name=test2", "-v", volumeID+":"+prefix+"/foo", "busybox", "sh", "-c", "cat /foo/bar")
- c.Assert(strings.TrimSpace(out), check.Equals, "hello", check.Commentf("volume data was removed"))
+ assert.Equal(c, strings.TrimSpace(out), "hello", "volume data was removed")
dockerCmd(c, "rm", "test2")
dockerCmd(c, "volume", "rm", volumeID)
- c.Assert(
- exec.Command("volume", "rm", "doesnotexist").Run(),
- check.Not(check.IsNil),
- check.Commentf("volume rm should fail with non-existent volume"),
- )
+ assert.Assert(c, exec.Command("volume", "rm", "doesnotexist").Run() != nil, "volume rm should fail with non-existent volume")
}
// 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")
// no args should produce the cmd usage output
usage := "Usage: docker volume COMMAND"
- c.Assert(out, checker.Contains, usage)
-
+ assert.Assert(c, strings.Contains(out, usage))
// invalid arg should error and show the command usage on stderr
icmd.RunCommand(dockerBinary, "volume", "somearg").Assert(c, icmd.Expected{
ExitCode: 1,
@@ -243,20 +227,20 @@
Error: "exit status 125",
Err: usage,
})
- c.Assert(result.Stderr(), checker.Contains, "unknown flag: --no-such-flag")
+ assert.Assert(c, strings.Contains(result.Stderr(), "unknown flag: --no-such-flag"))
}
-func (s *DockerSuite) TestVolumeCLIInspectTmplError(c *check.C) {
+func (s *DockerSuite) TestVolumeCLIInspectTmplError(c *testing.T) {
out, _ := dockerCmd(c, "volume", "create")
name := strings.TrimSpace(out)
out, exitCode, err := dockerCmdWithError("volume", "inspect", "--format='{{ .FooBar }}'", name)
- c.Assert(err, checker.NotNil, check.Commentf("Output: %s", out))
- c.Assert(exitCode, checker.Equals, 1, check.Commentf("Output: %s", out))
- c.Assert(out, checker.Contains, "Template parsing error")
+ assert.Assert(c, err != nil, "Output: %s", out)
+ assert.Equal(c, exitCode, 1, fmt.Sprintf("Output: %s", out))
+ assert.Assert(c, strings.Contains(out, "Template parsing error"))
}
-func (s *DockerSuite) TestVolumeCLICreateWithOpts(c *check.C) {
+func (s *DockerSuite) TestVolumeCLICreateWithOpts(c *testing.T) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "volume", "create", "-d", "local", "test", "--opt=type=tmpfs", "--opt=device=tmpfs", "--opt=o=size=1m,uid=1000")
@@ -269,18 +253,18 @@
found = true
info := strings.Fields(m)
// tmpfs on <path> type tmpfs (rw,relatime,size=1024k,uid=1000)
- c.Assert(info[0], checker.Equals, "tmpfs")
- c.Assert(info[2], checker.Equals, "/foo")
- c.Assert(info[4], checker.Equals, "tmpfs")
- c.Assert(info[5], checker.Contains, "uid=1000")
- c.Assert(info[5], checker.Contains, "size=1024k")
+ assert.Equal(c, info[0], "tmpfs")
+ assert.Equal(c, info[2], "/foo")
+ assert.Equal(c, info[4], "tmpfs")
+ assert.Assert(c, strings.Contains(info[5], "uid=1000"))
+ assert.Assert(c, strings.Contains(info[5], "size=1024k"))
break
}
}
- c.Assert(found, checker.Equals, true)
+ assert.Equal(c, found, true)
}
-func (s *DockerSuite) TestVolumeCLICreateLabel(c *check.C) {
+func (s *DockerSuite) TestVolumeCLICreateLabel(c *testing.T) {
testVol := "testvolcreatelabel"
testLabel := "foo"
testValue := "bar"
@@ -289,10 +273,10 @@
assert.NilError(c, err)
out, _ := dockerCmd(c, "volume", "inspect", "--format={{ .Labels."+testLabel+" }}", testVol)
- c.Assert(strings.TrimSpace(out), check.Equals, testValue)
+ assert.Equal(c, strings.TrimSpace(out), testValue)
}
-func (s *DockerSuite) TestVolumeCLICreateLabelMultiple(c *check.C) {
+func (s *DockerSuite) TestVolumeCLICreateLabelMultiple(c *testing.T) {
testVol := "testvolcreatelabel"
testLabels := map[string]string{
@@ -315,11 +299,11 @@
for k, v := range testLabels {
out, _ := dockerCmd(c, "volume", "inspect", "--format={{ .Labels."+k+" }}", testVol)
- c.Assert(strings.TrimSpace(out), check.Equals, v)
+ assert.Equal(c, strings.TrimSpace(out), v)
}
}
-func (s *DockerSuite) TestVolumeCLILsFilterLabels(c *check.C) {
+func (s *DockerSuite) TestVolumeCLILsFilterLabels(c *testing.T) {
testVol1 := "testvolcreatelabel-1"
_, _, err := dockerCmdWithError("volume", "create", "--label", "foo=bar1", testVol1)
assert.NilError(c, err)
@@ -331,25 +315,23 @@
out, _ := dockerCmd(c, "volume", "ls", "--filter", "label=foo")
// filter with label=key
- c.Assert(out, checker.Contains, "testvolcreatelabel-1\n", check.Commentf("expected volume 'testvolcreatelabel-1' in output"))
- c.Assert(out, checker.Contains, "testvolcreatelabel-2\n", check.Commentf("expected volume 'testvolcreatelabel-2' in output"))
-
+ assert.Assert(c, strings.Contains(out, "testvolcreatelabel-1\n"), "expected volume 'testvolcreatelabel-1' in output")
+ assert.Assert(c, strings.Contains(out, "testvolcreatelabel-2\n"), "expected volume 'testvolcreatelabel-2' in output")
out, _ = dockerCmd(c, "volume", "ls", "--filter", "label=foo=bar1")
// filter with label=key=value
- c.Assert(out, checker.Contains, "testvolcreatelabel-1\n", check.Commentf("expected volume 'testvolcreatelabel-1' in output"))
- c.Assert(out, check.Not(checker.Contains), "testvolcreatelabel-2\n", check.Commentf("expected volume 'testvolcreatelabel-2 in output"))
-
+ assert.Assert(c, strings.Contains(out, "testvolcreatelabel-1\n"), "expected volume 'testvolcreatelabel-1' in output")
+ assert.Assert(c, !strings.Contains(out, "testvolcreatelabel-2\n"), "expected volume 'testvolcreatelabel-2 in output")
out, _ = dockerCmd(c, "volume", "ls", "--filter", "label=non-exist")
outArr := strings.Split(strings.TrimSpace(out), "\n")
- c.Assert(len(outArr), check.Equals, 1, check.Commentf("\n%s", out))
+ assert.Equal(c, len(outArr), 1, fmt.Sprintf("\n%s", out))
out, _ = dockerCmd(c, "volume", "ls", "--filter", "label=foo=non-exist")
outArr = strings.Split(strings.TrimSpace(out), "\n")
- c.Assert(len(outArr), check.Equals, 1, check.Commentf("\n%s", out))
+ assert.Equal(c, len(outArr), 1, fmt.Sprintf("\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
testVol1 := "testvol-1"
_, _, err := dockerCmdWithError("volume", "create", testVol1)
@@ -361,26 +343,25 @@
// filter with driver=local
out, _ := dockerCmd(c, "volume", "ls", "--filter", "driver=local")
- c.Assert(out, checker.Contains, "testvol-1\n", check.Commentf("expected volume 'testvol-1' in output"))
- c.Assert(out, checker.Contains, "testvol-2\n", check.Commentf("expected volume 'testvol-2' in output"))
-
+ assert.Assert(c, strings.Contains(out, "testvol-1\n"), "expected volume 'testvol-1' in output")
+ assert.Assert(c, strings.Contains(out, "testvol-2\n"), "expected volume 'testvol-2' in output")
// filter with driver=invaliddriver
out, _ = dockerCmd(c, "volume", "ls", "--filter", "driver=invaliddriver")
outArr := strings.Split(strings.TrimSpace(out), "\n")
- c.Assert(len(outArr), check.Equals, 1, check.Commentf("\n%s", out))
+ assert.Equal(c, len(outArr), 1, fmt.Sprintf("\n%s", out))
// filter with driver=loca
out, _ = dockerCmd(c, "volume", "ls", "--filter", "driver=loca")
outArr = strings.Split(strings.TrimSpace(out), "\n")
- c.Assert(len(outArr), check.Equals, 1, check.Commentf("\n%s", out))
+ assert.Equal(c, len(outArr), 1, fmt.Sprintf("\n%s", out))
// filter with driver=
out, _ = dockerCmd(c, "volume", "ls", "--filter", "driver=")
outArr = strings.Split(strings.TrimSpace(out), "\n")
- c.Assert(len(outArr), check.Equals, 1, check.Commentf("\n%s", out))
+ assert.Equal(c, len(outArr), 1, fmt.Sprintf("\n%s", out))
}
-func (s *DockerSuite) TestVolumeCLIRmForceUsage(c *check.C) {
+func (s *DockerSuite) TestVolumeCLIRmForceUsage(c *testing.T) {
out, _ := dockerCmd(c, "volume", "create")
id := strings.TrimSpace(out)
@@ -388,13 +369,13 @@
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)
name := "test"
out, _ := dockerCmd(c, "volume", "create", name)
id := strings.TrimSpace(out)
- c.Assert(id, checker.Equals, name)
+ assert.Equal(c, id, name)
out, _ = dockerCmd(c, "volume", "inspect", "--format", "{{.Mountpoint}}", name)
assert.Assert(c, strings.TrimSpace(out) != "")
@@ -404,19 +385,19 @@
dockerCmd(c, "volume", "rm", "-f", name)
out, _ = dockerCmd(c, "volume", "ls")
- c.Assert(out, checker.Not(checker.Contains), name)
+ assert.Assert(c, !strings.Contains(out, name))
dockerCmd(c, "volume", "create", name)
out, _ = dockerCmd(c, "volume", "ls")
- c.Assert(out, checker.Contains, name)
+ assert.Assert(c, strings.Contains(out, name))
}
// 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
-func (s *DockerSuite) TestVolumeCLIRmForceInUse(c *check.C) {
+func (s *DockerSuite) TestVolumeCLIRmForceInUse(c *testing.T) {
name := "testvolume"
out, _ := dockerCmd(c, "volume", "create", name)
id := strings.TrimSpace(out)
- c.Assert(id, checker.Equals, name)
+ assert.Equal(c, id, name)
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
out, _ = dockerCmd(c, "create", "-v", "testvolume:"+prefix+slash+"foo", "busybox")
@@ -426,8 +407,7 @@
assert.ErrorContains(c, err, "")
assert.ErrorContains(c, err, "volume is in use")
out, _ = dockerCmd(c, "volume", "ls")
- c.Assert(out, checker.Contains, name)
-
+ assert.Assert(c, strings.Contains(out, name))
// The original issue did not _remove_ the volume from the list
// the first time. But a second call to `volume rm` removed it.
// Calling `volume rm` a second time to confirm it's not removed
@@ -436,29 +416,27 @@
assert.ErrorContains(c, err, "")
assert.ErrorContains(c, err, "volume is in use")
out, _ = dockerCmd(c, "volume", "ls")
- c.Assert(out, checker.Contains, name)
-
+ assert.Assert(c, strings.Contains(out, name))
// Verify removing the volume after the container is removed works
_, e := dockerCmd(c, "rm", cid)
- c.Assert(e, check.Equals, 0)
+ assert.Equal(c, e, 0)
_, e = dockerCmd(c, "volume", "rm", "-f", name)
- c.Assert(e, check.Equals, 0)
+ assert.Equal(c, e, 0)
out, e = dockerCmd(c, "volume", "ls")
- c.Assert(e, check.Equals, 0)
- c.Assert(out, checker.Not(checker.Contains), name)
+ assert.Equal(c, e, 0)
+ assert.Assert(c, !strings.Contains(out, name))
}
-func (s *DockerSuite) TestVolumeCliInspectWithVolumeOpts(c *check.C) {
+func (s *DockerSuite) TestVolumeCliInspectWithVolumeOpts(c *testing.T) {
testRequires(c, DaemonIsLinux)
// Without options
name := "test1"
dockerCmd(c, "volume", "create", "-d", "local", name)
out, _ := dockerCmd(c, "volume", "inspect", "--format={{ .Options }}", name)
- c.Assert(strings.TrimSpace(out), checker.Contains, "map[]")
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), "map[]"))
// With options
name = "test2"
k1, v1 := "type", "tmpfs"
@@ -466,13 +444,13 @@
k3, v3 := "o", "size=1m,uid=1000"
dockerCmd(c, "volume", "create", "-d", "local", name, "--opt", fmt.Sprintf("%s=%s", k1, v1), "--opt", fmt.Sprintf("%s=%s", k2, v2), "--opt", fmt.Sprintf("%s=%s", k3, v3))
out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Options }}", name)
- c.Assert(strings.TrimSpace(out), checker.Contains, fmt.Sprintf("%s:%s", k1, v1))
- c.Assert(strings.TrimSpace(out), checker.Contains, fmt.Sprintf("%s:%s", k2, v2))
- c.Assert(strings.TrimSpace(out), checker.Contains, fmt.Sprintf("%s:%s", k3, v3))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), fmt.Sprintf("%s:%s", k1, v1)))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), fmt.Sprintf("%s:%s", k2, v2)))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), fmt.Sprintf("%s:%s", k3, v3)))
}
// 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)
image := "vimage"
@@ -485,19 +463,18 @@
out, _ := dockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "data1")
data1 := strings.TrimSpace(out)
- c.Assert(data1, checker.Not(checker.Equals), "")
+ assert.Assert(c, data1 != "")
out, _ = dockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "data2")
data2 := strings.TrimSpace(out)
- c.Assert(data2, checker.Not(checker.Equals), "")
+ assert.Assert(c, data2 != "")
// Both volume should exist
out, _ = dockerCmd(c, "volume", "ls", "-q")
- c.Assert(strings.TrimSpace(out), checker.Contains, data1)
- c.Assert(strings.TrimSpace(out), checker.Contains, data2)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), data1))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), data2))
out, _, err := dockerCmdWithError("run", "--name=app", "--volumes-from=data1", "--volumes-from=data2", "-d", "busybox", "top")
- c.Assert(err, checker.IsNil, check.Commentf("Out: %s", out))
+ assert.Assert(c, err == nil, "Out: %s", out)
// Only the second volume will be referenced, this is backward compatible
out, _ = dockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "app")
@@ -509,12 +486,12 @@
// Both volume should not exist
out, _ = dockerCmd(c, "volume", "ls", "-q")
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), data1)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), data2)
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data1))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data2))
}
// 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)
image := "vimage"
@@ -527,38 +504,36 @@
out, _ := dockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "data1")
data1 := strings.TrimSpace(out)
- c.Assert(data1, checker.Not(checker.Equals), "")
+ assert.Assert(c, data1 != "")
out, _ = dockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "data2")
data2 := strings.TrimSpace(out)
- c.Assert(data2, checker.Not(checker.Equals), "")
+ assert.Assert(c, data2 != "")
// Both volume should exist
out, _ = dockerCmd(c, "volume", "ls", "-q")
- c.Assert(strings.TrimSpace(out), checker.Contains, data1)
- c.Assert(strings.TrimSpace(out), checker.Contains, data2)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), data1))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), data2))
// /tmp/data is automatically created, because we are not using the modern mount API here
out, _, err := dockerCmdWithError("run", "--name=app", "--volumes-from=data1", "--volumes-from=data2", "-v", "/tmp/data:/tmp/data", "-d", "busybox", "top")
- c.Assert(err, checker.IsNil, check.Commentf("Out: %s", out))
+ assert.Assert(c, err == nil, "Out: %s", out)
// No volume will be referenced (mount is /tmp/data), this is backward compatible
out, _ = dockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "app")
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), data1)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), data2)
-
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data1))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data2))
dockerCmd(c, "rm", "-f", "-v", "app")
dockerCmd(c, "rm", "-f", "-v", "data1")
dockerCmd(c, "rm", "-f", "-v", "data2")
// Both volume should not exist
out, _ = dockerCmd(c, "volume", "ls", "-q")
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), data1)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), data2)
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data1))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data2))
}
// 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)
image := "vimage"
@@ -571,17 +546,16 @@
out, _ := dockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "data1")
data1 := strings.TrimSpace(out)
- c.Assert(data1, checker.Not(checker.Equals), "")
+ assert.Assert(c, data1 != "")
out, _ = dockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "data2")
data2 := strings.TrimSpace(out)
- c.Assert(data2, checker.Not(checker.Equals), "")
+ assert.Assert(c, data2 != "")
// Both volume should exist
out, _ = dockerCmd(c, "volume", "ls", "-q")
- c.Assert(strings.TrimSpace(out), checker.Contains, data1)
- c.Assert(strings.TrimSpace(out), checker.Contains, data2)
-
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), data1))
+ assert.Assert(c, strings.Contains(strings.TrimSpace(out), data2))
err := os.MkdirAll("/tmp/data", 0755)
assert.NilError(c, err)
// Mounts is available in API
@@ -610,15 +584,14 @@
// No volume will be referenced (mount is /tmp/data), this is backward compatible
out, _ = dockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "app")
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), data1)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), data2)
-
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data1))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data2))
dockerCmd(c, "rm", "-f", "-v", "app")
dockerCmd(c, "rm", "-f", "-v", "data1")
dockerCmd(c, "rm", "-f", "-v", "data2")
// Both volume should not exist
out, _ = dockerCmd(c, "volume", "ls", "-q")
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), data1)
- c.Assert(strings.TrimSpace(out), checker.Not(checker.Contains), data2)
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data1))
+ assert.Assert(c, !strings.Contains(strings.TrimSpace(out), data2))
}
diff --git a/integration-cli/docker_deprecated_api_v124_test.go b/integration-cli/docker_deprecated_api_v124_test.go
index 03fc72d..b11e364 100644
--- a/integration-cli/docker_deprecated_api_v124_test.go
+++ b/integration-cli/docker_deprecated_api_v124_test.go
@@ -6,10 +6,10 @@
import (
"net/http"
"strings"
+ "testing"
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/internal/test/request"
- "github.com/go-check/check"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
)
@@ -18,7 +18,7 @@
return "/v1.23" + url
}
-func (s *DockerSuite) TestDeprecatedContainerAPIStartHostConfig(c *check.C) {
+func (s *DockerSuite) TestDeprecatedContainerAPIStartHostConfig(c *testing.T) {
name := "test-deprecated-api-124"
dockerCmd(c, "create", "--name", name, "busybox")
config := map[string]interface{}{
@@ -37,7 +37,7 @@
}
}
-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.
testRequires(c, DaemonIsLinux)
path := "/foo"
@@ -68,7 +68,7 @@
}
// 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
testRequires(c, DaemonIsLinux)
name := "testdups"
@@ -101,7 +101,7 @@
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
testRequires(c, DaemonIsLinux)
volName := "voltst"
@@ -134,7 +134,7 @@
}
// #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
testRequires(c, DaemonIsLinux)
dockerCmd(c, "create", "-v", "/foo", "--name=one", "busybox")
@@ -154,7 +154,7 @@
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
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "create", "busybox")
@@ -179,7 +179,7 @@
}
// #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.
// An alternate test could be written to validate the negative testing aspect of this
testRequires(c, DaemonIsLinux)
@@ -196,7 +196,7 @@
}
// #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.
// An alternate test could be written to validate the negative testing aspect of this
testRequires(c, DaemonIsLinux)
@@ -214,7 +214,7 @@
}
// #14640
-func (s *DockerSuite) TestDeprecatedPostContainersStartWithLinksInHostConfigIdLinked(c *check.C) {
+func (s *DockerSuite) TestDeprecatedPostContainersStartWithLinksInHostConfigIdLinked(c *testing.T) {
// Windows does not support links
testRequires(c, DaemonIsLinux)
name := "test-host-config-links"
@@ -233,7 +233,7 @@
b.Close()
}
-func (s *DockerSuite) TestDeprecatedStartWithNilDNS(c *check.C) {
+func (s *DockerSuite) TestDeprecatedStartWithNilDNS(c *testing.T) {
// TODO Windows: Add once DNS is supported
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "create", "busybox")
diff --git a/integration-cli/docker_deprecated_api_v124_unix_test.go b/integration-cli/docker_deprecated_api_v124_unix_test.go
index 0aae30b..06959eb 100644
--- a/integration-cli/docker_deprecated_api_v124_unix_test.go
+++ b/integration-cli/docker_deprecated_api_v124_unix_test.go
@@ -4,14 +4,14 @@
import (
"strings"
+ "testing"
"github.com/docker/docker/internal/test/request"
- "github.com/go-check/check"
"gotest.tools/assert"
)
// #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"
conName := "foo"
dockerCmd(c, "network", "create", netName)
diff --git a/integration-cli/docker_hub_pull_suite_test.go b/integration-cli/docker_hub_pull_suite_test.go
index 34fddac..476ae17 100644
--- a/integration-cli/docker_hub_pull_suite_test.go
+++ b/integration-cli/docker_hub_pull_suite_test.go
@@ -2,23 +2,14 @@
import (
"os/exec"
- "runtime"
"strings"
+ "testing"
- "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"
+ "gotest.tools/assert"
)
-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, ...).
@@ -39,26 +30,26 @@
}
// SetUpSuite starts the suite daemon.
-func (s *DockerHubPullSuite) SetUpSuite(c *check.C) {
+func (s *DockerHubPullSuite) SetUpSuite(c *testing.T) {
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) {
+func (s *DockerHubPullSuite) TearDownSuite(c *testing.T) {
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) {
+func (s *DockerHubPullSuite) SetUpTest(c *testing.T) {
testRequires(c, Network)
}
// 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")
images := strings.Split(out, "\n")
images = append([]string{"rmi", "-f"}, images...)
@@ -68,9 +59,9 @@
// 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 {
+func (s *DockerHubPullSuite) Cmd(c *testing.T, name string, arg ...string) string {
out, err := s.CmdWithError(name, arg...)
- c.Assert(err, checker.IsNil, check.Commentf("%q failed with errors: %s, %v", strings.Join(arg, " "), out, err))
+ assert.Assert(c, err == nil, "%q failed with errors: %s, %v", strings.Join(arg, " "), out, err)
return out
}
diff --git a/integration-cli/docker_utils_test.go b/integration-cli/docker_utils_test.go
index a95246f..3ee6b7c 100644
--- a/integration-cli/docker_utils_test.go
+++ b/integration-cli/docker_utils_test.go
@@ -12,15 +12,17 @@
"path/filepath"
"strconv"
"strings"
+ "testing"
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/daemon"
- "github.com/go-check/check"
"gotest.tools/assert"
+ "gotest.tools/assert/cmp"
"gotest.tools/icmd"
+ "gotest.tools/poll"
)
func deleteImages(images ...string) error {
@@ -38,7 +40,7 @@
}
// Deprecated: use cli.Docker or cli.DockerCmd
-func dockerCmd(c *check.C, args ...string) (string, int) {
+func dockerCmd(c testing.TB, args ...string) (string, int) {
result := cli.DockerCmd(c, args...)
return result.Combined(), result.ExitCode
}
@@ -48,12 +50,14 @@
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 {
+ c.Helper()
out, _ := dockerCmd(c, "inspect", fmt.Sprintf("--format='{{ .NetworkSettings.Networks.%s.IPAddress }}'", network), id)
return strings.Trim(out, " \r\n'")
}
-func getContainerCount(c *check.C) int {
+func getContainerCount(c *testing.T) int {
+ c.Helper()
const containers = "Containers:"
result := icmd.RunCommand(dockerBinary, "info")
@@ -73,11 +77,12 @@
return 0
}
-func inspectFieldAndUnmarshall(c *check.C, name, field string, output interface{}) {
+func inspectFieldAndUnmarshall(c *testing.T, name, field string, output interface{}) {
+ c.Helper()
str := inspectFieldJSON(c, name, field)
err := json.Unmarshal([]byte(str), output)
if c != nil {
- c.Assert(err, check.IsNil, check.Commentf("failed to unmarshal: %v", err))
+ assert.Assert(c, err == nil, "failed to unmarshal: %v", err)
}
}
@@ -97,7 +102,8 @@
}
// Deprecated: use cli.Inspect
-func inspectField(c *check.C, name, field string) string {
+func inspectField(c *testing.T, name, field string) string {
+ c.Helper()
out, err := inspectFilter(name, fmt.Sprintf(".%s", field))
if c != nil {
assert.NilError(c, err)
@@ -106,7 +112,8 @@
}
// Deprecated: use cli.Inspect
-func inspectFieldJSON(c *check.C, name, field string) string {
+func inspectFieldJSON(c *testing.T, name, field string) string {
+ c.Helper()
out, err := inspectFilter(name, fmt.Sprintf("json .%s", field))
if c != nil {
assert.NilError(c, err)
@@ -115,7 +122,8 @@
}
// Deprecated: use cli.Inspect
-func inspectFieldMap(c *check.C, name, path, field string) string {
+func inspectFieldMap(c *testing.T, name, path, field string) string {
+ c.Helper()
out, err := inspectFilter(name, fmt.Sprintf("index .%s %q", path, field))
if c != nil {
assert.NilError(c, err)
@@ -167,7 +175,8 @@
}
// Deprecated: use cli.Inspect
-func inspectImage(c *check.C, name, filter string) string {
+func inspectImage(c *testing.T, name, filter string) string {
+ c.Helper()
args := []string{"inspect", "--type", "image"}
if filter != "" {
format := fmt.Sprintf("{{%s}}", filter)
@@ -179,14 +188,16 @@
return strings.TrimSpace(result.Combined())
}
-func getIDByName(c *check.C, name string) string {
+func getIDByName(c *testing.T, name string) string {
+ c.Helper()
id, err := inspectFieldWithError(name, "Id")
assert.NilError(c, err)
return id
}
// Deprecated: use cli.Build
-func buildImageSuccessfully(c *check.C, name string, cmdOperators ...cli.CmdOperator) {
+func buildImageSuccessfully(c *testing.T, name string, cmdOperators ...cli.CmdOperator) {
+ c.Helper()
buildImage(name, cmdOperators...).Assert(c, icmd.Success)
}
@@ -199,9 +210,10 @@
// as well as any missing directories.
// The file is truncated if it already exists.
// Fail the test when error occurs.
-func writeFile(dst, content string, c *check.C) {
+func writeFile(dst, content string, c *testing.T) {
+ c.Helper()
// Create subdirectories if necessary
- c.Assert(os.MkdirAll(path.Dir(dst), 0700), check.IsNil)
+ assert.Assert(c, os.MkdirAll(path.Dir(dst), 0700) == nil)
f, err := os.OpenFile(dst, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0700)
assert.NilError(c, err)
defer f.Close()
@@ -212,7 +224,8 @@
// Return the contents of file at path `src`.
// Fail the test when error occurs.
-func readFile(src string, c *check.C) (content string) {
+func readFile(src string, c *testing.T) (content string) {
+ c.Helper()
data, err := ioutil.ReadFile(src)
assert.NilError(c, err)
@@ -224,7 +237,8 @@
}
// 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 {
+ c.Helper()
result := icmd.RunCommand(command, args...)
result.Assert(c, icmd.Success)
contID := strings.TrimSpace(result.Combined())
@@ -234,7 +248,8 @@
return readContainerFile(c, contID, filename)
}
-func readContainerFile(c *check.C, containerID, filename string) []byte {
+func readContainerFile(c *testing.T, containerID, filename string) []byte {
+ c.Helper()
f, err := os.Open(containerStorageFile(containerID, filename))
assert.NilError(c, err)
defer f.Close()
@@ -244,14 +259,16 @@
return content
}
-func readContainerFileWithExec(c *check.C, containerID, filename string) []byte {
+func readContainerFileWithExec(c *testing.T, containerID, filename string) []byte {
+ c.Helper()
result := icmd.RunCommand(dockerBinary, "exec", containerID, "cat", filename)
result.Assert(c, icmd.Success)
return []byte(result.Combined())
}
// daemonTime provides the current time on the daemon host
-func daemonTime(c *check.C) time.Time {
+func daemonTime(c *testing.T) time.Time {
+ c.Helper()
if testEnv.IsLocalDaemon() {
return time.Now()
}
@@ -263,13 +280,14 @@
assert.NilError(c, err)
dt, err := time.Parse(time.RFC3339Nano, info.SystemTime)
- c.Assert(err, check.IsNil, check.Commentf("invalid time format in GET /info response"))
+ assert.Assert(c, err == nil, "invalid time format in GET /info response")
return dt
}
// 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.
-func daemonUnixTime(c *check.C) string {
+func daemonUnixTime(c *testing.T) string {
+ c.Helper()
return parseEventTime(daemonTime(c))
}
@@ -304,7 +322,8 @@
return env
}
-func createTmpFile(c *check.C, content string) string {
+func createTmpFile(c *testing.T, content string) string {
+ c.Helper()
f, err := ioutil.TempFile("", "testfile")
assert.NilError(c, err)
@@ -335,7 +354,8 @@
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 {
+ c.Helper()
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion(version))
assert.NilError(c, err)
defer cli.Close()
@@ -346,13 +366,15 @@
// Run a long running idle task in a background container using the
// system-specific default image and command.
-func runSleepingContainer(c *check.C, extraArgs ...string) string {
+func runSleepingContainer(c *testing.T, extraArgs ...string) string {
+ c.Helper()
return runSleepingContainerInImage(c, "busybox", extraArgs...)
}
// Run a long running idle task in a background container using the specified
// 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 {
+ c.Helper()
args := []string{"run", "-d"}
args = append(args, extraArgs...)
args = append(args, image)
@@ -406,54 +428,50 @@
}
// 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 {
+ c.Helper()
var resp types.ErrorResponse
- c.Assert(json.Unmarshal(body, &resp), check.IsNil)
+ assert.Assert(c, json.Unmarshal(body, &resp) == nil)
return strings.TrimSpace(resp.Message)
}
-func waitAndAssert(c *check.C, timeout time.Duration, f checkF, checker check.Checker, args ...interface{}) {
- t1 := time.Now()
- defer func() {
- t2 := time.Now()
- c.Logf("waited for %v (out of %v)", t2.Sub(t1), timeout)
- }()
+type checkF func(*testing.T) (interface{}, string)
+type reducer func(...interface{}) interface{}
- after := time.After(timeout)
- for {
- v, comment := f(c)
- assert, _ := checker.Check(append([]interface{}{v}, args...), checker.Info().Params)
- select {
- case <-after:
- assert = true
- default:
- }
- if assert {
- if comment != nil {
- args = append(args, comment)
+func pollCheck(t *testing.T, f checkF, compare func(x interface{}) assert.BoolOrComparison) poll.Check {
+ return func(poll.LogT) poll.Result {
+ t.Helper()
+ v, comment := f(t)
+ r := compare(v)
+ switch r := r.(type) {
+ case bool:
+ if r {
+ return poll.Success()
}
- c.Assert(v, checker, args...)
- return
+ case cmp.Comparison:
+ if r().Success() {
+ return poll.Success()
+ }
+ default:
+ panic(fmt.Errorf("pollCheck: type %T not implemented", r))
}
- time.Sleep(100 * time.Millisecond)
+ return poll.Continue(comment)
}
}
-type checkF func(*check.C) (interface{}, check.CommentInterface)
-type reducer func(...interface{}) interface{}
-
func reducedCheck(r reducer, funcs ...checkF) checkF {
- return func(c *check.C) (interface{}, check.CommentInterface) {
+ return func(c *testing.T) (interface{}, string) {
+ c.Helper()
var values []interface{}
var comments []string
for _, f := range funcs {
v, comment := f(c)
values = append(values, v)
- if comment != nil {
- comments = append(comments, comment.CheckCommentString())
+ if len(comment) > 0 {
+ comments = append(comments, comment)
}
}
- return r(values...), check.Commentf("%v", strings.Join(comments, ", "))
+ return r(values...), fmt.Sprintf("%v", strings.Join(comments, ", "))
}
}
diff --git a/integration-cli/events_utils_test.go b/integration-cli/events_utils_test.go
index f63082a..0bd923d 100644
--- a/integration-cli/events_utils_test.go
+++ b/integration-cli/events_utils_test.go
@@ -8,9 +8,9 @@
"regexp"
"strconv"
"strings"
+ "testing"
eventstestutils "github.com/docker/docker/daemon/events/testutils"
- "github.com/go-check/check"
"github.com/sirupsen/logrus"
"gotest.tools/assert"
)
@@ -35,13 +35,13 @@
// newEventObserver creates the observer and initializes 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()
return newEventObserverWithBacklog(c, since, args...)
}
// 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)
cmdArgs := []string{"events", "--since", startTime}
if len(args) > 0 {
@@ -93,7 +93,7 @@
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
scannerOut := e.buffer.String()
@@ -144,14 +144,14 @@
// parseEventAction parses an event text and returns the action.
// 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)
return matches["action"]
}
// eventActionsByIDAndType returns the actions for a given id and type.
// 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
for _, event := range events {
matches := eventstestutils.ScanMap(event)
@@ -183,7 +183,7 @@
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")
for _, event := range events {
matches := eventstestutils.ScanMap(event)
@@ -193,7 +193,7 @@
}
}
-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")
for _, event := range events {
matches := eventstestutils.ScanMap(event)
diff --git a/integration-cli/fixtures_linux_daemon_test.go b/integration-cli/fixtures_linux_daemon_test.go
index ab152f4..de401b9 100644
--- a/integration-cli/fixtures_linux_daemon_test.go
+++ b/integration-cli/fixtures_linux_daemon_test.go
@@ -8,9 +8,9 @@
"path/filepath"
"runtime"
"strings"
+ "testing"
"github.com/docker/docker/internal/test/fixtures/load"
- "github.com/go-check/check"
"gotest.tools/assert"
)
@@ -23,7 +23,7 @@
Logf(string, ...interface{})
}
-func ensureSyscallTest(c *check.C) {
+func ensureSyscallTest(c *testing.T) {
defer testEnv.ProtectImage(c, "syscall-test:latest")
// If the image already exists, there's nothing left to do.
@@ -73,7 +73,7 @@
dockerCmd(c, buildArgs...)
}
-func ensureSyscallTestBuild(c *check.C) {
+func ensureSyscallTestBuild(c *testing.T) {
err := load.FrozenImagesLinux(testEnv.APIClient(), "buildpack-deps:jessie")
assert.NilError(c, err)
@@ -86,7 +86,7 @@
dockerCmd(c, buildArgs...)
}
-func ensureNNPTest(c *check.C) {
+func ensureNNPTest(c *testing.T) {
defer testEnv.ProtectImage(c, "nnp-test:latest")
// If the image already exists, there's nothing left to do.
@@ -128,7 +128,7 @@
dockerCmd(c, buildArgs...)
}
-func ensureNNPTestBuild(c *check.C) {
+func ensureNNPTestBuild(c *testing.T) {
err := load.FrozenImagesLinux(testEnv.APIClient(), "buildpack-deps:jessie")
assert.NilError(c, err)
diff --git a/integration-cli/requirement/requirement.go b/integration-cli/requirement/requirement.go
index 45a1bca..e05dffb 100644
--- a/integration-cli/requirement/requirement.go
+++ b/integration-cli/requirement/requirement.go
@@ -10,7 +10,7 @@
// SkipT is the interface required to skip tests
type SkipT interface {
- Skip(reason string)
+ Skip(...interface{})
}
// Test represent a function that can be used as a requirement validation.
diff --git a/integration-cli/requirements_test.go b/integration-cli/requirements_test.go
index fd3f4ef..658b558 100644
--- a/integration-cli/requirements_test.go
+++ b/integration-cli/requirements_test.go
@@ -190,6 +190,6 @@
// testRequires checks if the environment satisfies the requirements
// for the test to run or skips the tests.
-func testRequires(c requirement.SkipT, requirements ...requirement.Test) {
- requirement.Is(c, requirements...)
+func testRequires(c interface{}, requirements ...requirement.Test) {
+ requirement.Is(c.(requirement.SkipT), requirements...)
}
diff --git a/integration-cli/utils_test.go b/integration-cli/utils_test.go
index fd08368..9746f6c 100644
--- a/integration-cli/utils_test.go
+++ b/integration-cli/utils_test.go
@@ -6,9 +6,9 @@
"os/exec"
"path/filepath"
"strings"
+ "testing"
"github.com/docker/docker/internal/testutil"
- "github.com/go-check/check"
"github.com/pkg/errors"
"gotest.tools/icmd"
)
@@ -118,7 +118,7 @@
element, format string
}
-func existingElements(c *check.C, opts elementListOptions) []string {
+func existingElements(c *testing.T, opts elementListOptions) []string {
var args []string
switch opts.element {
case "container":
@@ -146,12 +146,12 @@
}
// 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}}"})
}
// 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}}"})
}
diff --git a/internal/test/fakegit/fakegit.go b/internal/test/fakegit/fakegit.go
index 605d1ba..30de769 100644
--- a/internal/test/fakegit/fakegit.go
+++ b/internal/test/fakegit/fakegit.go
@@ -28,7 +28,7 @@
}
type skipT interface {
- Skip(reason string)
+ Skip(...interface{})
}
type gitServer interface {
diff --git a/internal/test/fakestorage/storage.go b/internal/test/fakestorage/storage.go
index 77d6e2f..e229fd0 100644
--- a/internal/test/fakestorage/storage.go
+++ b/internal/test/fakestorage/storage.go
@@ -38,7 +38,7 @@
}
type skipT interface {
- Skip(reason string)
+ Skip(...interface{})
}
// Fake is a static file server. It might be running locally or remotely
diff --git a/internal/test/suite/interfaces.go b/internal/test/suite/interfaces.go
new file mode 100644
index 0000000..263de86
--- /dev/null
+++ b/internal/test/suite/interfaces.go
@@ -0,0 +1,33 @@
+package suite
+
+import "testing"
+
+// SetupAllSuite has a SetupSuite method, which will run before the
+// tests in the suite are run.
+type SetupAllSuite interface {
+ SetUpSuite(t *testing.T)
+}
+
+// SetupTestSuite has a SetupTest method, which will run before each
+// test in the suite.
+type SetupTestSuite interface {
+ SetUpTest(t *testing.T)
+}
+
+// TearDownAllSuite has a TearDownSuite method, which will run after
+// all the tests in the suite have been run.
+type TearDownAllSuite interface {
+ TearDownSuite(t *testing.T)
+}
+
+// TearDownTestSuite has a TearDownTest method, which will run after
+// each test in the suite.
+type TearDownTestSuite interface {
+ TearDownTest(t *testing.T)
+}
+
+// TimeoutTestSuite has a OnTimeout method, which will run after
+// a single test times out after a period specified by -timeout flag.
+type TimeoutTestSuite interface {
+ OnTimeout()
+}
diff --git a/internal/test/suite/suite.go b/internal/test/suite/suite.go
new file mode 100644
index 0000000..edb6e40
--- /dev/null
+++ b/internal/test/suite/suite.go
@@ -0,0 +1,72 @@
+// Package suite is a simplified version of testify's suite package which has unnecessary dependencies.
+// Please remove this package whenever possible.
+package suite
+
+import (
+ "flag"
+ "reflect"
+ "runtime/debug"
+ "strings"
+ "testing"
+)
+
+// TimeoutFlag is the flag to set a per-test timeout when running tests. Defaults to `-timeout`.
+var TimeoutFlag = flag.Duration("timeout", 0, "DO NOT USE")
+
+var typTestingT = reflect.TypeOf(new(testing.T))
+
+// Run takes a testing suite and runs all of the tests attached to it.
+func Run(t *testing.T, suite interface{}) {
+ defer failOnPanic(t)
+
+ suiteSetupDone := false
+
+ defer func() {
+ if suiteSetupDone {
+ if tearDownAllSuite, ok := suite.(TearDownAllSuite); ok {
+ tearDownAllSuite.TearDownSuite(t)
+ }
+ }
+ }()
+
+ methodFinder := reflect.TypeOf(suite)
+ for index := 0; index < methodFinder.NumMethod(); index++ {
+ method := methodFinder.Method(index)
+ if !methodFilter(method.Name, method.Type) {
+ continue
+ }
+ t.Run(method.Name, func(t *testing.T) {
+ defer failOnPanic(t)
+
+ if !suiteSetupDone {
+ if setupAllSuite, ok := suite.(SetupAllSuite); ok {
+ setupAllSuite.SetUpSuite(t)
+ }
+ suiteSetupDone = true
+ }
+
+ if setupTestSuite, ok := suite.(SetupTestSuite); ok {
+ setupTestSuite.SetUpTest(t)
+ }
+ defer func() {
+ if tearDownTestSuite, ok := suite.(TearDownTestSuite); ok {
+ tearDownTestSuite.TearDownTest(t)
+ }
+ }()
+
+ method.Func.Call([]reflect.Value{reflect.ValueOf(suite), reflect.ValueOf(t)})
+ })
+ }
+}
+
+func failOnPanic(t *testing.T) {
+ r := recover()
+ if r != nil {
+ t.Errorf("test suite panicked: %v\n%s", r, debug.Stack())
+ t.FailNow()
+ }
+}
+
+func methodFilter(name string, typ reflect.Type) bool {
+ return strings.HasPrefix(name, "Test") && typ.NumIn() == 2 && typ.In(1) == typTestingT // 2 params: method receiver and *testing.T
+}
diff --git a/internal/test/suite/testify.LICENSE b/internal/test/suite/testify.LICENSE
new file mode 100644
index 0000000..f38ec59
--- /dev/null
+++ b/internal/test/suite/testify.LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2012-2018 Mat Ryer and Tyler Bunnell
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/pkg/discovery/discovery_test.go b/pkg/discovery/discovery_test.go
index ffe8cb9..8166d4a 100644
--- a/pkg/discovery/discovery_test.go
+++ b/pkg/discovery/discovery_test.go
@@ -3,109 +3,107 @@
import (
"testing"
- "github.com/go-check/check"
+ "github.com/docker/docker/internal/test/suite"
+ "gotest.tools/assert"
)
// Hook up gocheck into the "go test" runner.
-func Test(t *testing.T) { check.TestingT(t) }
+func Test(t *testing.T) {
+ suite.Run(t, &DiscoverySuite{})
+}
type DiscoverySuite struct{}
-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")
- c.Assert(err, check.IsNil)
- c.Assert(entry.Equals(&Entry{Host: "127.0.0.1", Port: "2375"}), check.Equals, true)
- c.Assert(entry.String(), check.Equals, "127.0.0.1:2375")
+ assert.Assert(c, err == nil)
+ assert.Equal(c, entry.Equals(&Entry{Host: "127.0.0.1", Port: "2375"}), true)
+ assert.Equal(c, entry.String(), "127.0.0.1:2375")
entry, err = NewEntry("[2001:db8:0:f101::2]:2375")
- c.Assert(err, check.IsNil)
- c.Assert(entry.Equals(&Entry{Host: "2001:db8:0:f101::2", Port: "2375"}), check.Equals, true)
- c.Assert(entry.String(), check.Equals, "[2001:db8:0:f101::2]:2375")
+ assert.Assert(c, err == nil)
+ assert.Equal(c, entry.Equals(&Entry{Host: "2001:db8:0:f101::2", Port: "2375"}), true)
+ assert.Equal(c, entry.String(), "[2001:db8:0:f101::2]:2375")
_, err = NewEntry("127.0.0.1")
- c.Assert(err, check.NotNil)
+ assert.Assert(c, err != nil)
}
-func (s *DiscoverySuite) TestParse(c *check.C) {
+func (s *DiscoverySuite) TestParse(c *testing.T) {
scheme, uri := parse("127.0.0.1:2375")
- c.Assert(scheme, check.Equals, "nodes")
- c.Assert(uri, check.Equals, "127.0.0.1:2375")
+ assert.Equal(c, scheme, "nodes")
+ assert.Equal(c, uri, "127.0.0.1:2375")
scheme, uri = parse("localhost:2375")
- c.Assert(scheme, check.Equals, "nodes")
- c.Assert(uri, check.Equals, "localhost:2375")
+ assert.Equal(c, scheme, "nodes")
+ assert.Equal(c, uri, "localhost:2375")
scheme, uri = parse("scheme://127.0.0.1:2375")
- c.Assert(scheme, check.Equals, "scheme")
- c.Assert(uri, check.Equals, "127.0.0.1:2375")
+ assert.Equal(c, scheme, "scheme")
+ assert.Equal(c, uri, "127.0.0.1:2375")
scheme, uri = parse("scheme://localhost:2375")
- c.Assert(scheme, check.Equals, "scheme")
- c.Assert(uri, check.Equals, "localhost:2375")
+ assert.Equal(c, scheme, "scheme")
+ assert.Equal(c, uri, "localhost:2375")
scheme, uri = parse("")
- c.Assert(scheme, check.Equals, "nodes")
- c.Assert(uri, check.Equals, "")
+ assert.Equal(c, scheme, "nodes")
+ assert.Equal(c, uri, "")
}
-func (s *DiscoverySuite) TestCreateEntries(c *check.C) {
+func (s *DiscoverySuite) TestCreateEntries(c *testing.T) {
entries, err := CreateEntries(nil)
- c.Assert(entries, check.DeepEquals, Entries{})
- c.Assert(err, check.IsNil)
+ assert.DeepEqual(c, entries, Entries{})
+ assert.Assert(c, err == nil)
entries, err = CreateEntries([]string{"127.0.0.1:2375", "127.0.0.2:2375", "[2001:db8:0:f101::2]:2375", ""})
- c.Assert(err, check.IsNil)
+ assert.Assert(c, err == nil)
expected := Entries{
&Entry{Host: "127.0.0.1", Port: "2375"},
&Entry{Host: "127.0.0.2", Port: "2375"},
&Entry{Host: "2001:db8:0:f101::2", Port: "2375"},
}
- c.Assert(entries.Equals(expected), check.Equals, true)
+ assert.Equal(c, entries.Equals(expected), true)
_, err = CreateEntries([]string{"127.0.0.1", "127.0.0.2"})
- c.Assert(err, check.NotNil)
+ assert.Assert(c, err != nil)
}
-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", ""})
- c.Assert(err, check.IsNil)
- c.Assert(entries.Contains(&Entry{Host: "127.0.0.1", Port: "2375"}), check.Equals, true)
- c.Assert(entries.Contains(&Entry{Host: "127.0.0.3", Port: "2375"}), check.Equals, false)
+ assert.Assert(c, err == nil)
+ assert.Equal(c, entries.Contains(&Entry{Host: "127.0.0.1", Port: "2375"}), true)
+ assert.Equal(c, entries.Contains(&Entry{Host: "127.0.0.3", Port: "2375"}), false)
}
-func (s *DiscoverySuite) TestEntriesEquality(c *check.C) {
+func (s *DiscoverySuite) TestEntriesEquality(c *testing.T) {
entries := Entries{
&Entry{Host: "127.0.0.1", Port: "2375"},
&Entry{Host: "127.0.0.2", Port: "2375"},
}
// Same
- c.Assert(entries.Equals(Entries{
+ assert.Assert(c, entries.Equals(Entries{
&Entry{Host: "127.0.0.1", Port: "2375"},
&Entry{Host: "127.0.0.2", Port: "2375"},
- }), check.
- Equals, true)
+ }))
// Different size
- c.Assert(entries.Equals(Entries{
+ assert.Assert(c, !entries.Equals(Entries{
&Entry{Host: "127.0.0.1", Port: "2375"},
&Entry{Host: "127.0.0.2", Port: "2375"},
&Entry{Host: "127.0.0.3", Port: "2375"},
- }), check.
- Equals, false)
+ }))
// Different content
- c.Assert(entries.Equals(Entries{
+ assert.Assert(c, !entries.Equals(Entries{
&Entry{Host: "127.0.0.1", Port: "2375"},
&Entry{Host: "127.0.0.42", Port: "2375"},
- }), check.
- Equals, false)
+ }))
}
-func (s *DiscoverySuite) TestEntriesDiff(c *check.C) {
+func (s *DiscoverySuite) TestEntriesDiff(c *testing.T) {
entry1 := &Entry{Host: "1.1.1.1", Port: "1111"}
entry2 := &Entry{Host: "2.2.2.2", Port: "2222"}
entry3 := &Entry{Host: "3.3.3.3", Port: "3333"}
@@ -113,25 +111,25 @@
// No diff
added, removed := entries.Diff(Entries{entry2, entry1})
- c.Assert(added, check.HasLen, 0)
- c.Assert(removed, check.HasLen, 0)
+ assert.Equal(c, len(added), 0)
+ assert.Equal(c, len(removed), 0)
// Add
added, removed = entries.Diff(Entries{entry2, entry3, entry1})
- c.Assert(added, check.HasLen, 1)
- c.Assert(added.Contains(entry3), check.Equals, true)
- c.Assert(removed, check.HasLen, 0)
+ assert.Equal(c, len(added), 1)
+ assert.Equal(c, added.Contains(entry3), true)
+ assert.Equal(c, len(removed), 0)
// Remove
added, removed = entries.Diff(Entries{entry2})
- c.Assert(added, check.HasLen, 0)
- c.Assert(removed, check.HasLen, 1)
- c.Assert(removed.Contains(entry1), check.Equals, true)
+ assert.Equal(c, len(added), 0)
+ assert.Equal(c, len(removed), 1)
+ assert.Equal(c, removed.Contains(entry1), true)
// Add and remove
added, removed = entries.Diff(Entries{entry1, entry3})
- c.Assert(added, check.HasLen, 1)
- c.Assert(added.Contains(entry3), check.Equals, true)
- c.Assert(removed, check.HasLen, 1)
- c.Assert(removed.Contains(entry2), check.Equals, true)
+ assert.Equal(c, len(added), 1)
+ assert.Equal(c, added.Contains(entry3), true)
+ assert.Equal(c, len(removed), 1)
+ assert.Equal(c, removed.Contains(entry2), true)
}
diff --git a/pkg/discovery/file/file_test.go b/pkg/discovery/file/file_test.go
index 010e941..78a1798 100644
--- a/pkg/discovery/file/file_test.go
+++ b/pkg/discovery/file/file_test.go
@@ -5,50 +5,50 @@
"os"
"testing"
+ "github.com/docker/docker/internal/test/suite"
"github.com/docker/docker/pkg/discovery"
-
- "github.com/go-check/check"
+ "gotest.tools/assert"
)
// Hook up gocheck into the "go test" runner.
-func Test(t *testing.T) { check.TestingT(t) }
+func Test(t *testing.T) {
+ suite.Run(t, &DiscoverySuite{})
+}
type DiscoverySuite struct{}
-var _ = check.Suite(&DiscoverySuite{})
-
-func (s *DiscoverySuite) TestInitialize(c *check.C) {
+func (s *DiscoverySuite) TestInitialize(c *testing.T) {
d := &Discovery{}
d.Initialize("/path/to/file", 1000, 0, nil)
- c.Assert(d.path, check.Equals, "/path/to/file")
+ assert.Equal(c, d.path, "/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)
- c.Assert(err, check.IsNil)
- c.Assert(d.(*Discovery).path, check.Equals, "/path/to/file")
+ assert.Assert(c, err == nil)
+ assert.Equal(c, d.(*Discovery).path, "/path/to/file")
}
-func (s *DiscoverySuite) TestContent(c *check.C) {
+func (s *DiscoverySuite) TestContent(c *testing.T) {
data := `
1.1.1.[1:2]:1111
2.2.2.[2:4]:2222
`
ips := parseFileContent([]byte(data))
- c.Assert(ips, check.HasLen, 5)
- c.Assert(ips[0], check.Equals, "1.1.1.1:1111")
- c.Assert(ips[1], check.Equals, "1.1.1.2:1111")
- c.Assert(ips[2], check.Equals, "2.2.2.2:2222")
- c.Assert(ips[3], check.Equals, "2.2.2.3:2222")
- c.Assert(ips[4], check.Equals, "2.2.2.4:2222")
+ assert.Equal(c, len(ips), 5)
+ assert.Equal(c, ips[0], "1.1.1.1:1111")
+ assert.Equal(c, ips[1], "1.1.1.2:1111")
+ assert.Equal(c, ips[2], "2.2.2.2:2222")
+ assert.Equal(c, ips[3], "2.2.2.3:2222")
+ assert.Equal(c, ips[4], "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"}
- c.Assert(discovery.Register("0.0.0.0"), check.NotNil)
+ assert.Assert(c, discovery.Register("0.0.0.0") != nil)
}
-func (s *DiscoverySuite) TestParsingContentsWithComments(c *check.C) {
+func (s *DiscoverySuite) TestParsingContentsWithComments(c *testing.T) {
data := `
### test ###
1.1.1.1:1111 # inline comment
@@ -58,12 +58,12 @@
### test ###
`
ips := parseFileContent([]byte(data))
- c.Assert(ips, check.HasLen, 2)
- c.Assert("1.1.1.1:1111", check.Equals, ips[0])
- c.Assert("3.3.3.3:3333", check.Equals, ips[1])
+ assert.Equal(c, len(ips), 2)
+ assert.Equal(c, "1.1.1.1:1111", ips[0])
+ assert.Equal(c, "3.3.3.3:3333", ips[1])
}
-func (s *DiscoverySuite) TestWatch(c *check.C) {
+func (s *DiscoverySuite) TestWatch(c *testing.T) {
data := `
1.1.1.1:1111
2.2.2.2:2222
@@ -75,9 +75,9 @@
// Create a temporary file and remove it.
tmp, err := ioutil.TempFile(os.TempDir(), "discovery-file-test")
- c.Assert(err, check.IsNil)
- c.Assert(tmp.Close(), check.IsNil)
- c.Assert(os.Remove(tmp.Name()), check.IsNil)
+ assert.Assert(c, err == nil)
+ assert.Assert(c, tmp.Close() == nil)
+ assert.Assert(c, os.Remove(tmp.Name()) == nil)
// Set up file discovery.
d := &Discovery{}
@@ -86,7 +86,7 @@
ch, errCh := d.Watch(stopCh)
// Make sure it fires errors since the file doesn't exist.
- c.Assert(<-errCh, check.NotNil)
+ assert.Assert(c, <-errCh != nil)
// We have to drain the error channel otherwise Watch will get stuck.
go func() {
for range errCh {
@@ -94,21 +94,21 @@
}()
// Write the file and make sure we get the expected value back.
- c.Assert(ioutil.WriteFile(tmp.Name(), []byte(data), 0600), check.IsNil)
- c.Assert(<-ch, check.DeepEquals, expected)
+ assert.Assert(c, ioutil.WriteFile(tmp.Name(), []byte(data), 0600) == nil)
+ assert.DeepEqual(c, <-ch, expected)
// Add a new entry and look it up.
expected = append(expected, &discovery.Entry{Host: "3.3.3.3", Port: "3333"})
f, err := os.OpenFile(tmp.Name(), os.O_APPEND|os.O_WRONLY, 0600)
- c.Assert(err, check.IsNil)
- c.Assert(f, check.NotNil)
+ assert.Assert(c, err == nil)
+ assert.Assert(c, f != nil)
_, err = f.WriteString("\n3.3.3.3:3333\n")
- c.Assert(err, check.IsNil)
+ assert.Assert(c, err == nil)
f.Close()
- c.Assert(<-ch, check.DeepEquals, expected)
+ assert.DeepEqual(c, <-ch, expected)
// Stop and make sure it closes all channels.
close(stopCh)
- c.Assert(<-ch, check.IsNil)
- c.Assert(<-errCh, check.IsNil)
+ assert.Assert(c, <-ch == nil)
+ assert.Assert(c, <-errCh == nil)
}
diff --git a/pkg/discovery/generator_test.go b/pkg/discovery/generator_test.go
index 5126df5..bfc8fb0 100644
--- a/pkg/discovery/generator_test.go
+++ b/pkg/discovery/generator_test.go
@@ -1,53 +1,54 @@
package discovery // import "github.com/docker/docker/pkg/discovery"
-
import (
- "github.com/go-check/check"
+ "testing"
+
+ "gotest.tools/assert"
)
-func (s *DiscoverySuite) TestGeneratorNotGenerate(c *check.C) {
+func (s *DiscoverySuite) TestGeneratorNotGenerate(c *testing.T) {
ips := Generate("127.0.0.1")
- c.Assert(len(ips), check.Equals, 1)
- c.Assert(ips[0], check.Equals, "127.0.0.1")
+ assert.Equal(c, len(ips), 1)
+ assert.Equal(c, ips[0], "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")
- c.Assert(len(ips), check.Equals, 1)
- c.Assert(ips[0], check.Equals, "127.0.0.1:8080")
+ assert.Equal(c, len(ips), 1)
+ assert.Equal(c, ips[0], "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]")
- c.Assert(len(ips), check.Equals, 1)
- c.Assert(ips[0], check.Equals, "127.0.0.[1]")
+ assert.Equal(c, len(ips), 1)
+ assert.Equal(c, ips[0], "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")
- c.Assert(len(ips), check.Equals, 11)
- c.Assert(ips[0], check.Equals, "127.0.0.1:2375")
- c.Assert(ips[1], check.Equals, "127.0.0.2:2375")
- c.Assert(ips[2], check.Equals, "127.0.0.3:2375")
- c.Assert(ips[3], check.Equals, "127.0.0.4:2375")
- c.Assert(ips[4], check.Equals, "127.0.0.5:2375")
- c.Assert(ips[5], check.Equals, "127.0.0.6:2375")
- c.Assert(ips[6], check.Equals, "127.0.0.7:2375")
- c.Assert(ips[7], check.Equals, "127.0.0.8:2375")
- c.Assert(ips[8], check.Equals, "127.0.0.9:2375")
- c.Assert(ips[9], check.Equals, "127.0.0.10:2375")
- c.Assert(ips[10], check.Equals, "127.0.0.11:2375")
+ assert.Equal(c, len(ips), 11)
+ assert.Equal(c, ips[0], "127.0.0.1:2375")
+ assert.Equal(c, ips[1], "127.0.0.2:2375")
+ assert.Equal(c, ips[2], "127.0.0.3:2375")
+ assert.Equal(c, ips[3], "127.0.0.4:2375")
+ assert.Equal(c, ips[4], "127.0.0.5:2375")
+ assert.Equal(c, ips[5], "127.0.0.6:2375")
+ assert.Equal(c, ips[6], "127.0.0.7:2375")
+ assert.Equal(c, ips[7], "127.0.0.8:2375")
+ assert.Equal(c, ips[8], "127.0.0.9:2375")
+ assert.Equal(c, ips[9], "127.0.0.10:2375")
+ assert.Equal(c, ips[10], "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"
ips := Generate(malformedInput)
- c.Assert(len(ips), check.Equals, 1)
- c.Assert(ips[0], check.Equals, malformedInput)
+ assert.Equal(c, len(ips), 1)
+ assert.Equal(c, ips[0], malformedInput)
}
-func (s *DiscoverySuite) TestGenerateWithMalformedInputAtRangeEnd(c *check.C) {
+func (s *DiscoverySuite) TestGenerateWithMalformedInputAtRangeEnd(c *testing.T) {
malformedInput := "127.0.0.[1:x]:2375"
ips := Generate(malformedInput)
- c.Assert(len(ips), check.Equals, 1)
- c.Assert(ips[0], check.Equals, malformedInput)
+ assert.Equal(c, len(ips), 1)
+ assert.Equal(c, ips[0], malformedInput)
}
diff --git a/pkg/discovery/kv/kv_test.go b/pkg/discovery/kv/kv_test.go
index 79fd91c..5394038 100644
--- a/pkg/discovery/kv/kv_test.go
+++ b/pkg/discovery/kv/kv_test.go
@@ -8,20 +8,21 @@
"testing"
"time"
+ "github.com/docker/docker/internal/test/suite"
"github.com/docker/docker/pkg/discovery"
"github.com/docker/libkv"
"github.com/docker/libkv/store"
- "github.com/go-check/check"
+ "gotest.tools/assert"
)
// Hook up gocheck into the "go test" runner.
-func Test(t *testing.T) { check.TestingT(t) }
+func Test(t *testing.T) {
+ suite.Run(t, &DiscoverySuite{})
+}
type DiscoverySuite struct{}
-var _ = check.Suite(&DiscoverySuite{})
-
-func (ds *DiscoverySuite) TestInitialize(c *check.C) {
+func (ds *DiscoverySuite) TestInitialize(c *testing.T) {
storeMock := &FakeStore{
Endpoints: []string{"127.0.0.1"},
}
@@ -30,9 +31,9 @@
d.store = storeMock
s := d.store.(*FakeStore)
- c.Assert(s.Endpoints, check.HasLen, 1)
- c.Assert(s.Endpoints[0], check.Equals, "127.0.0.1")
- c.Assert(d.path, check.Equals, defaultDiscoveryPath)
+ assert.Equal(c, len(s.Endpoints), 1)
+ assert.Equal(c, s.Endpoints[0], "127.0.0.1")
+ assert.Equal(c, d.path, defaultDiscoveryPath)
storeMock = &FakeStore{
Endpoints: []string{"127.0.0.1:1234"},
@@ -42,9 +43,9 @@
d.store = storeMock
s = d.store.(*FakeStore)
- c.Assert(s.Endpoints, check.HasLen, 1)
- c.Assert(s.Endpoints[0], check.Equals, "127.0.0.1:1234")
- c.Assert(d.path, check.Equals, "path/"+defaultDiscoveryPath)
+ assert.Equal(c, len(s.Endpoints), 1)
+ assert.Equal(c, s.Endpoints[0], "127.0.0.1:1234")
+ assert.Equal(c, d.path, "path/"+defaultDiscoveryPath)
storeMock = &FakeStore{
Endpoints: []string{"127.0.0.1:1234", "127.0.0.2:1234", "127.0.0.3:1234"},
@@ -54,12 +55,12 @@
d.store = storeMock
s = d.store.(*FakeStore)
- c.Assert(s.Endpoints, check.HasLen, 3)
- c.Assert(s.Endpoints[0], check.Equals, "127.0.0.1:1234")
- c.Assert(s.Endpoints[1], check.Equals, "127.0.0.2:1234")
- c.Assert(s.Endpoints[2], check.Equals, "127.0.0.3:1234")
+ assert.Equal(c, len(s.Endpoints), 3)
+ assert.Equal(c, s.Endpoints[0], "127.0.0.1:1234")
+ assert.Equal(c, s.Endpoints[1], "127.0.0.2:1234")
+ assert.Equal(c, s.Endpoints[2], "127.0.0.3:1234")
- c.Assert(d.path, check.Equals, "path/"+defaultDiscoveryPath)
+ assert.Equal(c, d.path, "path/"+defaultDiscoveryPath)
}
// Extremely limited mock store so we can test initialization
@@ -131,7 +132,7 @@
func (s *Mock) Close() {
}
-func (ds *DiscoverySuite) TestInitializeWithCerts(c *check.C) {
+func (ds *DiscoverySuite) TestInitializeWithCerts(c *testing.T) {
cert := `-----BEGIN CERTIFICATE-----
MIIDCDCCAfKgAwIBAgIICifG7YeiQOEwCwYJKoZIhvcNAQELMBIxEDAOBgNVBAMT
B1Rlc3QgQ0EwHhcNMTUxMDAxMjMwMDAwWhcNMjAwOTI5MjMwMDAwWjASMRAwDgYD
@@ -181,12 +182,12 @@
-----END RSA PRIVATE KEY-----
`
certFile, err := ioutil.TempFile("", "cert")
- c.Assert(err, check.IsNil)
+ assert.Assert(c, err == nil)
defer os.Remove(certFile.Name())
certFile.Write([]byte(cert))
certFile.Close()
keyFile, err := ioutil.TempFile("", "key")
- c.Assert(err, check.IsNil)
+ assert.Assert(c, err == nil)
defer os.Remove(keyFile.Name())
keyFile.Write([]byte(key))
keyFile.Close()
@@ -198,14 +199,14 @@
"kv.certfile": certFile.Name(),
"kv.keyfile": keyFile.Name(),
})
- c.Assert(err, check.IsNil)
+ assert.Assert(c, err == nil)
s := d.store.(*Mock)
- c.Assert(s.Options.TLS, check.NotNil)
- c.Assert(s.Options.TLS.RootCAs, check.NotNil)
- c.Assert(s.Options.TLS.Certificates, check.HasLen, 1)
+ assert.Assert(c, s.Options.TLS != nil)
+ assert.Assert(c, s.Options.TLS.RootCAs != nil)
+ assert.Equal(c, len(s.Options.TLS.Certificates), 1)
}
-func (ds *DiscoverySuite) TestWatch(c *check.C) {
+func (ds *DiscoverySuite) TestWatch(c *testing.T) {
mockCh := make(chan []*store.KVPair)
storeMock := &FakeStore{
@@ -230,7 +231,7 @@
ch, errCh := d.Watch(stopCh)
// It should fire an error since the first WatchTree call failed.
- c.Assert(<-errCh, check.ErrorMatches, "test error")
+ assert.ErrorContains(c, <-errCh, "test error")
// We have to drain the error channel otherwise Watch will get stuck.
go func() {
for range errCh {
@@ -239,13 +240,13 @@
// Push the entries into the store channel and make sure discovery emits.
mockCh <- kvs
- c.Assert(<-ch, check.DeepEquals, expected)
+ assert.DeepEqual(c, <-ch, expected)
// Add a new entry.
expected = append(expected, &discovery.Entry{Host: "3.3.3.3", Port: "3333"})
kvs = append(kvs, &store.KVPair{Key: path.Join("path", defaultDiscoveryPath, "3.3.3.3"), Value: []byte("3.3.3.3:3333")})
mockCh <- kvs
- c.Assert(<-ch, check.DeepEquals, expected)
+ assert.DeepEqual(c, <-ch, expected)
close(mockCh)
// Give it enough time to call WatchTree.
@@ -253,8 +254,8 @@
// Stop and make sure it closes all channels.
close(stopCh)
- c.Assert(<-ch, check.IsNil)
- c.Assert(<-errCh, check.IsNil)
+ assert.Assert(c, <-ch == nil)
+ assert.Assert(c, <-errCh == nil)
}
// FakeStore implements store.Store methods. It mocks all store
diff --git a/pkg/discovery/memory/memory_test.go b/pkg/discovery/memory/memory_test.go
index 1d937f0..f54807a 100644
--- a/pkg/discovery/memory/memory_test.go
+++ b/pkg/discovery/memory/memory_test.go
@@ -3,18 +3,19 @@
import (
"testing"
+ "github.com/docker/docker/internal/test/suite"
"github.com/docker/docker/pkg/discovery"
- "github.com/go-check/check"
+ "gotest.tools/assert"
)
// Hook up gocheck into the "go test" runner.
-func Test(t *testing.T) { check.TestingT(t) }
+func Test(t *testing.T) {
+ suite.Run(t, &discoverySuite{})
+}
type discoverySuite struct{}
-var _ = check.Suite(&discoverySuite{})
-
-func (s *discoverySuite) TestWatch(c *check.C) {
+func (s *discoverySuite) TestWatch(c *testing.T) {
d := &Discovery{}
d.Initialize("foo", 1000, 0, nil)
stopCh := make(chan struct{})
@@ -30,19 +31,19 @@
&discovery.Entry{Host: "1.1.1.1", Port: "1111"},
}
- c.Assert(d.Register("1.1.1.1:1111"), check.IsNil)
- c.Assert(<-ch, check.DeepEquals, expected)
+ assert.Assert(c, d.Register("1.1.1.1:1111") == nil)
+ assert.DeepEqual(c, <-ch, expected)
expected = discovery.Entries{
&discovery.Entry{Host: "1.1.1.1", Port: "1111"},
&discovery.Entry{Host: "2.2.2.2", Port: "2222"},
}
- c.Assert(d.Register("2.2.2.2:2222"), check.IsNil)
- c.Assert(<-ch, check.DeepEquals, expected)
+ assert.Assert(c, d.Register("2.2.2.2:2222") == nil)
+ assert.DeepEqual(c, <-ch, expected)
// Stop and make sure it closes all channels.
close(stopCh)
- c.Assert(<-ch, check.IsNil)
- c.Assert(<-errCh, check.IsNil)
+ assert.Assert(c, <-ch == nil)
+ assert.Assert(c, <-errCh == nil)
}
diff --git a/pkg/discovery/nodes/nodes_test.go b/pkg/discovery/nodes/nodes_test.go
index f9b43ab..1212512 100644
--- a/pkg/discovery/nodes/nodes_test.go
+++ b/pkg/discovery/nodes/nodes_test.go
@@ -3,38 +3,38 @@
import (
"testing"
+ "github.com/docker/docker/internal/test/suite"
"github.com/docker/docker/pkg/discovery"
-
- "github.com/go-check/check"
+ "gotest.tools/assert"
)
// Hook up gocheck into the "go test" runner.
-func Test(t *testing.T) { check.TestingT(t) }
+func Test(t *testing.T) {
+ suite.Run(t, &DiscoverySuite{})
+}
type DiscoverySuite struct{}
-var _ = check.Suite(&DiscoverySuite{})
-
-func (s *DiscoverySuite) TestInitialize(c *check.C) {
+func (s *DiscoverySuite) TestInitialize(c *testing.T) {
d := &Discovery{}
d.Initialize("1.1.1.1:1111,2.2.2.2:2222", 0, 0, nil)
- c.Assert(len(d.entries), check.Equals, 2)
- c.Assert(d.entries[0].String(), check.Equals, "1.1.1.1:1111")
- c.Assert(d.entries[1].String(), check.Equals, "2.2.2.2:2222")
+ assert.Equal(c, len(d.entries), 2)
+ assert.Equal(c, d.entries[0].String(), "1.1.1.1:1111")
+ assert.Equal(c, d.entries[1].String(), "2.2.2.2:2222")
}
-func (s *DiscoverySuite) TestInitializeWithPattern(c *check.C) {
+func (s *DiscoverySuite) TestInitializeWithPattern(c *testing.T) {
d := &Discovery{}
d.Initialize("1.1.1.[1:2]:1111,2.2.2.[2:4]:2222", 0, 0, nil)
- c.Assert(len(d.entries), check.Equals, 5)
- c.Assert(d.entries[0].String(), check.Equals, "1.1.1.1:1111")
- c.Assert(d.entries[1].String(), check.Equals, "1.1.1.2:1111")
- c.Assert(d.entries[2].String(), check.Equals, "2.2.2.2:2222")
- c.Assert(d.entries[3].String(), check.Equals, "2.2.2.3:2222")
- c.Assert(d.entries[4].String(), check.Equals, "2.2.2.4:2222")
+ assert.Equal(c, len(d.entries), 5)
+ assert.Equal(c, d.entries[0].String(), "1.1.1.1:1111")
+ assert.Equal(c, d.entries[1].String(), "1.1.1.2:1111")
+ assert.Equal(c, d.entries[2].String(), "2.2.2.2:2222")
+ assert.Equal(c, d.entries[3].String(), "2.2.2.3:2222")
+ assert.Equal(c, d.entries[4].String(), "2.2.2.4:2222")
}
-func (s *DiscoverySuite) TestWatch(c *check.C) {
+func (s *DiscoverySuite) TestWatch(c *testing.T) {
d := &Discovery{}
d.Initialize("1.1.1.1:1111,2.2.2.2:2222", 0, 0, nil)
expected := discovery.Entries{
@@ -42,10 +42,10 @@
&discovery.Entry{Host: "2.2.2.2", Port: "2222"},
}
ch, _ := d.Watch(nil)
- c.Assert(expected.Equals(<-ch), check.Equals, true)
+ assert.Equal(c, expected.Equals(<-ch), true)
}
-func (s *DiscoverySuite) TestRegister(c *check.C) {
+func (s *DiscoverySuite) TestRegister(c *testing.T) {
d := &Discovery{}
- c.Assert(d.Register("0.0.0.0"), check.NotNil)
+ assert.Assert(c, d.Register("0.0.0.0") != nil)
}
diff --git a/pkg/mount/mount.go b/pkg/mount/mount.go
index 4afd63c..be0631c 100644
--- a/pkg/mount/mount.go
+++ b/pkg/mount/mount.go
@@ -102,13 +102,13 @@
// specified like the mount or fstab unix commands: "opt1=val1,opt2=val2". See
// flags.go for supported option flags.
func Mount(device, target, mType, options string) error {
- flag, _ := parseOptions(options)
+ flag, data := parseOptions(options)
if flag&REMOUNT != REMOUNT {
if mounted, err := Mounted(target); err != nil || mounted {
return err
}
}
- return ForceMount(device, target, mType, options)
+ return mount(device, target, mType, uintptr(flag), data)
}
// ForceMount will mount a filesystem according to the specified configuration,
diff --git a/pkg/mount/sharedsubtree_linux.go b/pkg/mount/sharedsubtree_linux.go
index 8a100f0..db38828 100644
--- a/pkg/mount/sharedsubtree_linux.go
+++ b/pkg/mount/sharedsubtree_linux.go
@@ -3,49 +3,49 @@
// MakeShared ensures a mounted filesystem has the SHARED mount option enabled.
// See the supported options in flags.go for further reference.
func MakeShared(mountPoint string) error {
- return ensureMountedAs(mountPoint, "shared")
+ return ensureMountedAs(mountPoint, SHARED)
}
// MakeRShared ensures a mounted filesystem has the RSHARED mount option enabled.
// See the supported options in flags.go for further reference.
func MakeRShared(mountPoint string) error {
- return ensureMountedAs(mountPoint, "rshared")
+ return ensureMountedAs(mountPoint, RSHARED)
}
// MakePrivate ensures a mounted filesystem has the PRIVATE mount option enabled.
// See the supported options in flags.go for further reference.
func MakePrivate(mountPoint string) error {
- return ensureMountedAs(mountPoint, "private")
+ return ensureMountedAs(mountPoint, PRIVATE)
}
// MakeRPrivate ensures a mounted filesystem has the RPRIVATE mount option
// enabled. See the supported options in flags.go for further reference.
func MakeRPrivate(mountPoint string) error {
- return ensureMountedAs(mountPoint, "rprivate")
+ return ensureMountedAs(mountPoint, RPRIVATE)
}
// MakeSlave ensures a mounted filesystem has the SLAVE mount option enabled.
// See the supported options in flags.go for further reference.
func MakeSlave(mountPoint string) error {
- return ensureMountedAs(mountPoint, "slave")
+ return ensureMountedAs(mountPoint, SLAVE)
}
// MakeRSlave ensures a mounted filesystem has the RSLAVE mount option enabled.
// See the supported options in flags.go for further reference.
func MakeRSlave(mountPoint string) error {
- return ensureMountedAs(mountPoint, "rslave")
+ return ensureMountedAs(mountPoint, RSLAVE)
}
// MakeUnbindable ensures a mounted filesystem has the UNBINDABLE mount option
// enabled. See the supported options in flags.go for further reference.
func MakeUnbindable(mountPoint string) error {
- return ensureMountedAs(mountPoint, "unbindable")
+ return ensureMountedAs(mountPoint, UNBINDABLE)
}
// MakeRUnbindable ensures a mounted filesystem has the RUNBINDABLE mount
// option enabled. See the supported options in flags.go for further reference.
func MakeRUnbindable(mountPoint string) error {
- return ensureMountedAs(mountPoint, "runbindable")
+ return ensureMountedAs(mountPoint, RUNBINDABLE)
}
// MakeMount ensures that the file or directory given is a mount point,
@@ -59,13 +59,13 @@
return nil
}
- return Mount(mnt, mnt, "none", "bind")
+ return mount(mnt, mnt, "none", uintptr(BIND), "")
}
-func ensureMountedAs(mountPoint, options string) error {
- if err := MakeMount(mountPoint); err != nil {
+func ensureMountedAs(mnt string, flags int) error {
+ if err := MakeMount(mnt); err != nil {
return err
}
- return ForceMount("", mountPoint, "none", options)
+ return mount("", mnt, "none", uintptr(flags), "")
}
diff --git a/vendor.conf b/vendor.conf
index 23013b0..3538f85 100644
--- a/vendor.conf
+++ b/vendor.conf
@@ -2,7 +2,6 @@
github.com/Microsoft/hcsshim 672e52e9209d1e53718c1b6a7d68cc9272654ab5
github.com/Microsoft/go-winio 6c72808b55902eae4c5943626030429ff20f3b63 # v0.4.14
github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a
-github.com/go-check/check 4ed411733c5785b40214c70bce814c3a3a689609 https://github.com/cpuguy83/check.git
github.com/golang/gddo 9b12a26f3fbd7397dee4e20939ddca719d840d2a
github.com/google/uuid 0cd6bf5da1e1c83f8b45653022c74f71af0538a4 # v1.1.1
github.com/gorilla/mux ed099d42384823742bba0bf9a72b53b55c9e2e38 # v1.7.2
@@ -13,7 +12,6 @@
github.com/mattn/go-shellwords a72fbe27a1b0ed0df2f02754945044ce1456608b # v1.0.5
github.com/sirupsen/logrus 8bdbc7bcc01dcbb8ec23dc8a28e332258d25251f # v1.4.1
github.com/tchap/go-patricia a7f0089c6f496e8e70402f61733606daa326cac5 # v2.3.0
-github.com/vdemeester/shakers 24d7f1d6a71aa5d9cbe7390e4afb66b7eef9e1b3 # v0.1.0
golang.org/x/net f3200d17e092c607f615320ecaad13d87ad9a2b3
golang.org/x/sys 4c4f7f33c9ed00de01c4c741d2177abfcfe19307
github.com/docker/go-units 519db1ee28dcc9fd2474ae59fca29a810482bfb1 # v0.4.0
diff --git a/vendor/github.com/go-check/check/LICENSE b/vendor/github.com/go-check/check/LICENSE
deleted file mode 100644
index 545cf2d..0000000
--- a/vendor/github.com/go-check/check/LICENSE
+++ /dev/null
@@ -1,25 +0,0 @@
-Gocheck - A rich testing framework for Go
-
-Copyright (c) 2010-2013 Gustavo Niemeyer <gustavo@niemeyer.net>
-
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/github.com/go-check/check/README.md b/vendor/github.com/go-check/check/README.md
deleted file mode 100644
index 0ca78d9..0000000
--- a/vendor/github.com/go-check/check/README.md
+++ /dev/null
@@ -1,10 +0,0 @@
-Go-check
-========
-
-This is a fork of https://github.com/go-check/check
-
-The intention of this fork is not to change any of the original behavior, but add
-some specific behaviors needed for some of my projects already using this test suite.
-For documentation on the main behavior of go-check see the aforementioned repo.
-
-The original branch is intact at `orig_v1`
diff --git a/vendor/github.com/go-check/check/benchmark.go b/vendor/github.com/go-check/check/benchmark.go
deleted file mode 100644
index 46ea9dc..0000000
--- a/vendor/github.com/go-check/check/benchmark.go
+++ /dev/null
@@ -1,187 +0,0 @@
-// Copyright (c) 2012 The Go Authors. All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-package check
-
-import (
- "fmt"
- "runtime"
- "time"
-)
-
-var memStats runtime.MemStats
-
-// testingB is a type passed to Benchmark functions to manage benchmark
-// timing and to specify the number of iterations to run.
-type timer struct {
- start time.Time // Time test or benchmark started
- duration time.Duration
- N int
- bytes int64
- timerOn bool
- benchTime time.Duration
- // The initial states of memStats.Mallocs and memStats.TotalAlloc.
- startAllocs uint64
- startBytes uint64
- // The net total of this test after being run.
- netAllocs uint64
- netBytes uint64
-}
-
-// StartTimer starts timing a test. This function is called automatically
-// before a benchmark starts, but it can also used to resume timing after
-// a call to StopTimer.
-func (c *C) StartTimer() {
- if !c.timerOn {
- c.start = time.Now()
- c.timerOn = true
-
- runtime.ReadMemStats(&memStats)
- c.startAllocs = memStats.Mallocs
- c.startBytes = memStats.TotalAlloc
- }
-}
-
-// StopTimer stops timing a test. This can be used to pause the timer
-// while performing complex initialization that you don't
-// want to measure.
-func (c *C) StopTimer() {
- if c.timerOn {
- c.duration += time.Now().Sub(c.start)
- c.timerOn = false
- runtime.ReadMemStats(&memStats)
- c.netAllocs += memStats.Mallocs - c.startAllocs
- c.netBytes += memStats.TotalAlloc - c.startBytes
- }
-}
-
-// ResetTimer sets the elapsed benchmark time to zero.
-// It does not affect whether the timer is running.
-func (c *C) ResetTimer() {
- if c.timerOn {
- c.start = time.Now()
- runtime.ReadMemStats(&memStats)
- c.startAllocs = memStats.Mallocs
- c.startBytes = memStats.TotalAlloc
- }
- c.duration = 0
- c.netAllocs = 0
- c.netBytes = 0
-}
-
-// SetBytes informs the number of bytes that the benchmark processes
-// on each iteration. If this is called in a benchmark it will also
-// report MB/s.
-func (c *C) SetBytes(n int64) {
- c.bytes = n
-}
-
-func (c *C) nsPerOp() int64 {
- if c.N <= 0 {
- return 0
- }
- return c.duration.Nanoseconds() / int64(c.N)
-}
-
-func (c *C) mbPerSec() float64 {
- if c.bytes <= 0 || c.duration <= 0 || c.N <= 0 {
- return 0
- }
- return (float64(c.bytes) * float64(c.N) / 1e6) / c.duration.Seconds()
-}
-
-func (c *C) timerString() string {
- if c.N <= 0 {
- return fmt.Sprintf("%3.3fs", float64(c.duration.Nanoseconds())/1e9)
- }
- mbs := c.mbPerSec()
- mb := ""
- if mbs != 0 {
- mb = fmt.Sprintf("\t%7.2f MB/s", mbs)
- }
- nsop := c.nsPerOp()
- ns := fmt.Sprintf("%10d ns/op", nsop)
- if c.N > 0 && nsop < 100 {
- // The format specifiers here make sure that
- // the ones digits line up for all three possible formats.
- if nsop < 10 {
- ns = fmt.Sprintf("%13.2f ns/op", float64(c.duration.Nanoseconds())/float64(c.N))
- } else {
- ns = fmt.Sprintf("%12.1f ns/op", float64(c.duration.Nanoseconds())/float64(c.N))
- }
- }
- memStats := ""
- if c.benchMem {
- allocedBytes := fmt.Sprintf("%8d B/op", int64(c.netBytes)/int64(c.N))
- allocs := fmt.Sprintf("%8d allocs/op", int64(c.netAllocs)/int64(c.N))
- memStats = fmt.Sprintf("\t%s\t%s", allocedBytes, allocs)
- }
- return fmt.Sprintf("%8d\t%s%s%s", c.N, ns, mb, memStats)
-}
-
-func min(x, y int) int {
- if x > y {
- return y
- }
- return x
-}
-
-func max(x, y int) int {
- if x < y {
- return y
- }
- return x
-}
-
-// roundDown10 rounds a number down to the nearest power of 10.
-func roundDown10(n int) int {
- var tens = 0
- // tens = floor(log_10(n))
- for n > 10 {
- n = n / 10
- tens++
- }
- // result = 10^tens
- result := 1
- for i := 0; i < tens; i++ {
- result *= 10
- }
- return result
-}
-
-// roundUp rounds x up to a number of the form [1eX, 2eX, 5eX].
-func roundUp(n int) int {
- base := roundDown10(n)
- if n < (2 * base) {
- return 2 * base
- }
- if n < (5 * base) {
- return 5 * base
- }
- return 10 * base
-}
diff --git a/vendor/github.com/go-check/check/check.go b/vendor/github.com/go-check/check/check.go
deleted file mode 100644
index a4e6090..0000000
--- a/vendor/github.com/go-check/check/check.go
+++ /dev/null
@@ -1,939 +0,0 @@
-// Package check is a rich testing extension for Go's testing package.
-//
-// For details about the project, see:
-//
-// http://labix.org/gocheck
-//
-package check
-
-import (
- "bytes"
- "errors"
- "fmt"
- "io"
- "math/rand"
- "os"
- "path"
- "path/filepath"
- "reflect"
- "regexp"
- "runtime"
- "strconv"
- "strings"
- "sync"
- "sync/atomic"
- "time"
-)
-
-// -----------------------------------------------------------------------
-// Internal type which deals with suite method calling.
-
-const (
- fixtureKd = iota
- testKd
-)
-
-type funcKind int
-
-const (
- succeededSt = iota
- failedSt
- skippedSt
- panickedSt
- fixturePanickedSt
- missedSt
-)
-
-type funcStatus uint32
-
-// A method value can't reach its own Method structure.
-type methodType struct {
- reflect.Value
- Info reflect.Method
-}
-
-func newMethod(receiver reflect.Value, i int) *methodType {
- return &methodType{receiver.Method(i), receiver.Type().Method(i)}
-}
-
-func (method *methodType) PC() uintptr {
- return method.Info.Func.Pointer()
-}
-
-func (method *methodType) suiteName() string {
- t := method.Info.Type.In(0)
- if t.Kind() == reflect.Ptr {
- t = t.Elem()
- }
- return t.Name()
-}
-
-func (method *methodType) String() string {
- return method.suiteName() + "." + method.Info.Name
-}
-
-func (method *methodType) matches(re *regexp.Regexp) bool {
- return (re.MatchString(method.Info.Name) ||
- re.MatchString(method.suiteName()) ||
- re.MatchString(method.String()))
-}
-
-type C struct {
- method *methodType
- kind funcKind
- testName string
- _status funcStatus
- logb *logger
- logw io.Writer
- done chan *C
- reason string
- mustFail bool
- tempDir *tempDir
- benchMem bool
- startTime time.Time
- timer
-}
-
-func (c *C) status() funcStatus {
- return funcStatus(atomic.LoadUint32((*uint32)(&c._status)))
-}
-
-func (c *C) setStatus(s funcStatus) {
- atomic.StoreUint32((*uint32)(&c._status), uint32(s))
-}
-
-func (c *C) stopNow() {
- runtime.Goexit()
-}
-
-// logger is a concurrency safe byte.Buffer
-type logger struct {
- sync.Mutex
- writer bytes.Buffer
-}
-
-func (l *logger) Write(buf []byte) (int, error) {
- l.Lock()
- defer l.Unlock()
- return l.writer.Write(buf)
-}
-
-func (l *logger) WriteTo(w io.Writer) (int64, error) {
- l.Lock()
- defer l.Unlock()
- return l.writer.WriteTo(w)
-}
-
-func (l *logger) String() string {
- l.Lock()
- defer l.Unlock()
- return l.writer.String()
-}
-
-// -----------------------------------------------------------------------
-// Handling of temporary files and directories.
-
-type tempDir struct {
- sync.Mutex
- path string
- counter int
-}
-
-func (td *tempDir) newPath() string {
- td.Lock()
- defer td.Unlock()
- if td.path == "" {
- var err error
- for i := 0; i != 100; i++ {
- path := fmt.Sprintf("%s%ccheck-%d", os.TempDir(), os.PathSeparator, rand.Int())
- if err = os.Mkdir(path, 0700); err == nil {
- td.path = path
- break
- }
- }
- if td.path == "" {
- panic("Couldn't create temporary directory: " + err.Error())
- }
- }
- result := filepath.Join(td.path, strconv.Itoa(td.counter))
- td.counter += 1
- return result
-}
-
-func (td *tempDir) removeAll() {
- td.Lock()
- defer td.Unlock()
- if td.path != "" {
- err := os.RemoveAll(td.path)
- if err != nil {
- fmt.Fprintf(os.Stderr, "WARNING: Error cleaning up temporaries: "+err.Error())
- }
- }
-}
-
-// Create a new temporary directory which is automatically removed after
-// the suite finishes running.
-func (c *C) MkDir() string {
- path := c.tempDir.newPath()
- if err := os.Mkdir(path, 0700); err != nil {
- panic(fmt.Sprintf("Couldn't create temporary directory %s: %s", path, err.Error()))
- }
- return path
-}
-
-// -----------------------------------------------------------------------
-// Low-level logging functions.
-
-func (c *C) log(args ...interface{}) {
- c.writeLog([]byte(fmt.Sprint(args...) + "\n"))
-}
-
-func (c *C) logf(format string, args ...interface{}) {
- c.writeLog([]byte(fmt.Sprintf(format+"\n", args...)))
-}
-
-func (c *C) logNewLine() {
- c.writeLog([]byte{'\n'})
-}
-
-func (c *C) writeLog(buf []byte) {
- c.logb.Write(buf)
- if c.logw != nil {
- c.logw.Write(buf)
- }
-}
-
-func hasStringOrError(x interface{}) (ok bool) {
- _, ok = x.(fmt.Stringer)
- if ok {
- return
- }
- _, ok = x.(error)
- return
-}
-
-func (c *C) logValue(label string, value interface{}) {
- if label == "" {
- if hasStringOrError(value) {
- c.logf("... %#v (%q)", value, value)
- } else {
- c.logf("... %#v", value)
- }
- } else if value == nil {
- c.logf("... %s = nil", label)
- } else {
- if hasStringOrError(value) {
- fv := fmt.Sprintf("%#v", value)
- qv := fmt.Sprintf("%q", value)
- if fv != qv {
- c.logf("... %s %s = %s (%s)", label, reflect.TypeOf(value), fv, qv)
- return
- }
- }
- if s, ok := value.(string); ok && isMultiLine(s) {
- c.logf(`... %s %s = "" +`, label, reflect.TypeOf(value))
- c.logMultiLine(s)
- } else {
- c.logf("... %s %s = %#v", label, reflect.TypeOf(value), value)
- }
- }
-}
-
-func (c *C) logMultiLine(s string) {
- b := make([]byte, 0, len(s)*2)
- i := 0
- n := len(s)
- for i < n {
- j := i + 1
- for j < n && s[j-1] != '\n' {
- j++
- }
- b = append(b, "... "...)
- b = strconv.AppendQuote(b, s[i:j])
- if j < n {
- b = append(b, " +"...)
- }
- b = append(b, '\n')
- i = j
- }
- c.writeLog(b)
-}
-
-func isMultiLine(s string) bool {
- for i := 0; i+1 < len(s); i++ {
- if s[i] == '\n' {
- return true
- }
- }
- return false
-}
-
-func (c *C) logString(issue string) {
- c.log("... ", issue)
-}
-
-func (c *C) logCaller(skip int) {
- // This is a bit heavier than it ought to be.
- skip += 1 // Our own frame.
- pc, callerFile, callerLine, ok := runtime.Caller(skip)
- if !ok {
- return
- }
- var testFile string
- var testLine int
- testFunc := runtime.FuncForPC(c.method.PC())
- if runtime.FuncForPC(pc) != testFunc {
- for {
- skip += 1
- if pc, file, line, ok := runtime.Caller(skip); ok {
- // Note that the test line may be different on
- // distinct calls for the same test. Showing
- // the "internal" line is helpful when debugging.
- if runtime.FuncForPC(pc) == testFunc {
- testFile, testLine = file, line
- break
- }
- } else {
- break
- }
- }
- }
- if testFile != "" && (testFile != callerFile || testLine != callerLine) {
- c.logCode(testFile, testLine)
- }
- c.logCode(callerFile, callerLine)
-}
-
-func (c *C) logCode(path string, line int) {
- c.logf("%s:%d:", nicePath(path), line)
- code, err := printLine(path, line)
- if code == "" {
- code = "..." // XXX Open the file and take the raw line.
- if err != nil {
- code += err.Error()
- }
- }
- c.log(indent(code, " "))
-}
-
-var valueGo = filepath.Join("reflect", "value.go")
-var asmGo = filepath.Join("runtime", "asm_")
-
-func (c *C) logPanic(skip int, value interface{}) {
- skip++ // Our own frame.
- initialSkip := skip
- for ; ; skip++ {
- if pc, file, line, ok := runtime.Caller(skip); ok {
- if skip == initialSkip {
- c.logf("... Panic: %s (PC=0x%X)\n", value, pc)
- }
- name := niceFuncName(pc)
- path := nicePath(file)
- if strings.Contains(path, "/gopkg.in/check.v") {
- continue
- }
- if name == "Value.call" && strings.HasSuffix(path, valueGo) {
- continue
- }
- if (name == "call16" || name == "call32") && strings.Contains(path, asmGo) {
- continue
- }
- c.logf("%s:%d\n in %s", nicePath(file), line, name)
- } else {
- break
- }
- }
-}
-
-func (c *C) logSoftPanic(issue string) {
- c.log("... Panic: ", issue)
-}
-
-func (c *C) logArgPanic(method *methodType, expectedType string) {
- c.logf("... Panic: %s argument should be %s",
- niceFuncName(method.PC()), expectedType)
-}
-
-// -----------------------------------------------------------------------
-// Some simple formatting helpers.
-
-var initWD, initWDErr = os.Getwd()
-
-func init() {
- if initWDErr == nil {
- initWD = strings.Replace(initWD, "\\", "/", -1) + "/"
- }
-}
-
-func nicePath(path string) string {
- if initWDErr == nil {
- if strings.HasPrefix(path, initWD) {
- return path[len(initWD):]
- }
- }
- return path
-}
-
-func niceFuncPath(pc uintptr) string {
- function := runtime.FuncForPC(pc)
- if function != nil {
- filename, line := function.FileLine(pc)
- return fmt.Sprintf("%s:%d", nicePath(filename), line)
- }
- return "<unknown path>"
-}
-
-func niceFuncName(pc uintptr) string {
- function := runtime.FuncForPC(pc)
- if function != nil {
- name := path.Base(function.Name())
- if i := strings.Index(name, "."); i > 0 {
- name = name[i+1:]
- }
- if strings.HasPrefix(name, "(*") {
- if i := strings.Index(name, ")"); i > 0 {
- name = name[2:i] + name[i+1:]
- }
- }
- if i := strings.LastIndex(name, ".*"); i != -1 {
- name = name[:i] + "." + name[i+2:]
- }
- if i := strings.LastIndex(name, "·"); i != -1 {
- name = name[:i] + "." + name[i+2:]
- }
- return name
- }
- return "<unknown function>"
-}
-
-// -----------------------------------------------------------------------
-// Result tracker to aggregate call results.
-
-type Result struct {
- Succeeded int
- Failed int
- Skipped int
- Panicked int
- FixturePanicked int
- ExpectedFailures int
- Missed int // Not even tried to run, related to a panic in the fixture.
- RunError error // Houston, we've got a problem.
- WorkDir string // If KeepWorkDir is true
-}
-
-type resultTracker struct {
- result Result
- _lastWasProblem bool
- _waiting int
- _missed int
- _expectChan chan *C
- _doneChan chan *C
- _stopChan chan bool
-}
-
-func newResultTracker() *resultTracker {
- return &resultTracker{_expectChan: make(chan *C), // Synchronous
- _doneChan: make(chan *C, 32), // Asynchronous
- _stopChan: make(chan bool)} // Synchronous
-}
-
-func (tracker *resultTracker) start() {
- go tracker._loopRoutine()
-}
-
-func (tracker *resultTracker) waitAndStop() {
- <-tracker._stopChan
-}
-
-func (tracker *resultTracker) expectCall(c *C) {
- tracker._expectChan <- c
-}
-
-func (tracker *resultTracker) callDone(c *C) {
- tracker._doneChan <- c
-}
-
-func (tracker *resultTracker) _loopRoutine() {
- for {
- var c *C
- if tracker._waiting > 0 {
- // Calls still running. Can't stop.
- select {
- // XXX Reindent this (not now to make diff clear)
- case c = <-tracker._expectChan:
- tracker._waiting += 1
- case c = <-tracker._doneChan:
- tracker._waiting -= 1
- switch c.status() {
- case succeededSt:
- if c.kind == testKd {
- if c.mustFail {
- tracker.result.ExpectedFailures++
- } else {
- tracker.result.Succeeded++
- }
- }
- case failedSt:
- tracker.result.Failed++
- case panickedSt:
- if c.kind == fixtureKd {
- tracker.result.FixturePanicked++
- } else {
- tracker.result.Panicked++
- }
- case fixturePanickedSt:
- // Track it as missed, since the panic
- // was on the fixture, not on the test.
- tracker.result.Missed++
- case missedSt:
- tracker.result.Missed++
- case skippedSt:
- if c.kind == testKd {
- tracker.result.Skipped++
- }
- }
- }
- } else {
- // No calls. Can stop, but no done calls here.
- select {
- case tracker._stopChan <- true:
- return
- case c = <-tracker._expectChan:
- tracker._waiting += 1
- case c = <-tracker._doneChan:
- panic("Tracker got an unexpected done call.")
- }
- }
- }
-}
-
-// -----------------------------------------------------------------------
-// The underlying suite runner.
-
-type suiteRunner struct {
- suite interface{}
- setUpSuite, tearDownSuite *methodType
- setUpTest, tearDownTest *methodType
- onTimeout *methodType
- tests []*methodType
- tracker *resultTracker
- tempDir *tempDir
- keepDir bool
- output *outputWriter
- reportedProblemLast bool
- benchTime time.Duration
- benchMem bool
- checkTimeout time.Duration
-}
-
-type RunConf struct {
- Output io.Writer
- Stream bool
- Verbose bool
- Filter string
- Benchmark bool
- BenchmarkTime time.Duration // Defaults to 1 second
- BenchmarkMem bool
- KeepWorkDir bool
- CheckTimeout time.Duration
-}
-
-// Create a new suiteRunner able to run all methods in the given suite.
-func newSuiteRunner(suite interface{}, runConf *RunConf) *suiteRunner {
- var conf RunConf
- if runConf != nil {
- conf = *runConf
- }
- if conf.Output == nil {
- conf.Output = os.Stdout
- }
- if conf.Benchmark {
- conf.Verbose = true
- }
-
- suiteType := reflect.TypeOf(suite)
- suiteNumMethods := suiteType.NumMethod()
- suiteValue := reflect.ValueOf(suite)
-
- runner := &suiteRunner{
- suite: suite,
- output: newOutputWriter(conf.Output, conf.Stream, conf.Verbose),
- tracker: newResultTracker(),
- benchTime: conf.BenchmarkTime,
- benchMem: conf.BenchmarkMem,
- tempDir: &tempDir{},
- keepDir: conf.KeepWorkDir,
- tests: make([]*methodType, 0, suiteNumMethods),
- checkTimeout: conf.CheckTimeout,
- }
- if runner.benchTime == 0 {
- runner.benchTime = 1 * time.Second
- }
-
- var filterRegexp *regexp.Regexp
- if conf.Filter != "" {
- if regexp, err := regexp.Compile(conf.Filter); err != nil {
- msg := "Bad filter expression: " + err.Error()
- runner.tracker.result.RunError = errors.New(msg)
- return runner
- } else {
- filterRegexp = regexp
- }
- }
-
- for i := 0; i != suiteNumMethods; i++ {
- method := newMethod(suiteValue, i)
- switch method.Info.Name {
- case "SetUpSuite":
- runner.setUpSuite = method
- case "TearDownSuite":
- runner.tearDownSuite = method
- case "SetUpTest":
- runner.setUpTest = method
- case "TearDownTest":
- runner.tearDownTest = method
- case "OnTimeout":
- runner.onTimeout = method
- default:
- prefix := "Test"
- if conf.Benchmark {
- prefix = "Benchmark"
- }
- if !strings.HasPrefix(method.Info.Name, prefix) {
- continue
- }
- if filterRegexp == nil || method.matches(filterRegexp) {
- runner.tests = append(runner.tests, method)
- }
- }
- }
- return runner
-}
-
-// Run all methods in the given suite.
-func (runner *suiteRunner) run() *Result {
- if runner.tracker.result.RunError == nil && len(runner.tests) > 0 {
- runner.tracker.start()
- if runner.checkFixtureArgs() {
- c := runner.runFixture(runner.setUpSuite, "", nil)
- if c == nil || c.status() == succeededSt {
- for i := 0; i != len(runner.tests); i++ {
- c := runner.runTest(runner.tests[i])
- if c.status() == fixturePanickedSt {
- runner.skipTests(missedSt, runner.tests[i+1:])
- break
- }
- }
- } else if c != nil && c.status() == skippedSt {
- runner.skipTests(skippedSt, runner.tests)
- } else {
- runner.skipTests(missedSt, runner.tests)
- }
- runner.runFixture(runner.tearDownSuite, "", nil)
- } else {
- runner.skipTests(missedSt, runner.tests)
- }
- runner.tracker.waitAndStop()
- if runner.keepDir {
- runner.tracker.result.WorkDir = runner.tempDir.path
- } else {
- runner.tempDir.removeAll()
- }
- }
- return &runner.tracker.result
-}
-
-// Create a call object with the given suite method, and fork a
-// goroutine with the provided dispatcher for running it.
-func (runner *suiteRunner) forkCall(method *methodType, kind funcKind, testName string, logb *logger, dispatcher func(c *C)) *C {
- var logw io.Writer
- if runner.output.Stream {
- logw = runner.output
- }
- if logb == nil {
- logb = new(logger)
- }
- c := &C{
- method: method,
- kind: kind,
- testName: testName,
- logb: logb,
- logw: logw,
- tempDir: runner.tempDir,
- done: make(chan *C, 1),
- timer: timer{benchTime: runner.benchTime},
- startTime: time.Now(),
- benchMem: runner.benchMem,
- }
- runner.tracker.expectCall(c)
- go (func() {
- runner.reportCallStarted(c)
- defer runner.callDone(c)
- dispatcher(c)
- })()
- return c
-}
-
-type timeoutErr struct {
- method *methodType
- t time.Duration
-}
-
-func (e timeoutErr) Error() string {
- return fmt.Sprintf("%s test timed out after %v", e.method.String(), e.t)
-}
-
-func isTimeout(e error) bool {
- if e == nil {
- return false
- }
- _, ok := e.(timeoutErr)
- return ok
-}
-
-// Same as forkCall(), but wait for call to finish before returning.
-func (runner *suiteRunner) runFunc(method *methodType, kind funcKind, testName string, logb *logger, dispatcher func(c *C)) *C {
- var timeout <-chan time.Time
- if runner.checkTimeout != 0 {
- timeout = time.After(runner.checkTimeout)
- }
- c := runner.forkCall(method, kind, testName, logb, dispatcher)
- select {
- case <-c.done:
- case <-timeout:
- if runner.onTimeout != nil {
- // run the OnTimeout callback, allowing the suite to collect any sort of debug information it can
- // `runFixture` is syncronous, so run this in a separate goroutine with a timeout
- cChan := make(chan *C)
- go func() {
- cChan <- runner.runFixture(runner.onTimeout, c.testName, c.logb)
- }()
- select {
- case <-cChan:
- case <-time.After(runner.checkTimeout):
- }
- }
- panic(timeoutErr{method, runner.checkTimeout})
- }
- return c
-}
-
-// Handle a finished call. If there were any panics, update the call status
-// accordingly. Then, mark the call as done and report to the tracker.
-func (runner *suiteRunner) callDone(c *C) {
- value := recover()
- if value != nil {
- switch v := value.(type) {
- case *fixturePanic:
- if v.status == skippedSt {
- c.setStatus(skippedSt)
- } else {
- c.logSoftPanic("Fixture has panicked (see related PANIC)")
- c.setStatus(fixturePanickedSt)
- }
- default:
- c.logPanic(1, value)
- c.setStatus(panickedSt)
- }
- }
- if c.mustFail {
- switch c.status() {
- case failedSt:
- c.setStatus(succeededSt)
- case succeededSt:
- c.setStatus(failedSt)
- c.logString("Error: Test succeeded, but was expected to fail")
- c.logString("Reason: " + c.reason)
- }
- }
-
- runner.reportCallDone(c)
- c.done <- c
-}
-
-// Runs a fixture call synchronously. The fixture will still be run in a
-// goroutine like all suite methods, but this method will not return
-// while the fixture goroutine is not done, because the fixture must be
-// run in a desired order.
-func (runner *suiteRunner) runFixture(method *methodType, testName string, logb *logger) *C {
- if method != nil {
- c := runner.runFunc(method, fixtureKd, testName, logb, func(c *C) {
- c.ResetTimer()
- c.StartTimer()
- defer c.StopTimer()
- c.method.Call([]reflect.Value{reflect.ValueOf(c)})
- })
- return c
- }
- return nil
-}
-
-// Run the fixture method with runFixture(), but panic with a fixturePanic{}
-// in case the fixture method panics. This makes it easier to track the
-// fixture panic together with other call panics within forkTest().
-func (runner *suiteRunner) runFixtureWithPanic(method *methodType, testName string, logb *logger, skipped *bool) *C {
- if skipped != nil && *skipped {
- return nil
- }
- c := runner.runFixture(method, testName, logb)
- if c != nil && c.status() != succeededSt {
- if skipped != nil {
- *skipped = c.status() == skippedSt
- }
- panic(&fixturePanic{c.status(), method})
- }
- return c
-}
-
-type fixturePanic struct {
- status funcStatus
- method *methodType
-}
-
-// Run the suite test method, together with the test-specific fixture,
-// asynchronously.
-func (runner *suiteRunner) forkTest(method *methodType) *C {
- testName := method.String()
- return runner.forkCall(method, testKd, testName, nil, func(c *C) {
- var skipped bool
- defer runner.runFixtureWithPanic(runner.tearDownTest, testName, nil, &skipped)
- defer c.StopTimer()
- benchN := 1
- for {
- runner.runFixtureWithPanic(runner.setUpTest, testName, c.logb, &skipped)
- mt := c.method.Type()
- if mt.NumIn() != 1 || mt.In(0) != reflect.TypeOf(c) {
- // Rather than a plain panic, provide a more helpful message when
- // the argument type is incorrect.
- c.setStatus(panickedSt)
- c.logArgPanic(c.method, "*check.C")
- return
- }
-
- if strings.HasPrefix(c.method.Info.Name, "Test") {
- c.ResetTimer()
- c.StartTimer()
- c.method.Call([]reflect.Value{reflect.ValueOf(c)})
- return
- }
-
- if !strings.HasPrefix(c.method.Info.Name, "Benchmark") {
- panic("unexpected method prefix: " + c.method.Info.Name)
- }
-
- runtime.GC()
- c.N = benchN
- c.ResetTimer()
- c.StartTimer()
-
- c.method.Call([]reflect.Value{reflect.ValueOf(c)})
- c.StopTimer()
- if c.status() != succeededSt || c.duration >= c.benchTime || benchN >= 1e9 {
- return
- }
- perOpN := int(1e9)
- if c.nsPerOp() != 0 {
- perOpN = int(c.benchTime.Nanoseconds() / c.nsPerOp())
- }
-
- // Logic taken from the stock testing package:
- // - Run more iterations than we think we'll need for a second (1.5x).
- // - Don't grow too fast in case we had timing errors previously.
- // - Be sure to run at least one more than last time.
- benchN = max(min(perOpN+perOpN/2, 100*benchN), benchN+1)
- benchN = roundUp(benchN)
-
- skipped = true // Don't run the deferred one if this panics.
- runner.runFixtureWithPanic(runner.tearDownTest, testName, nil, nil)
- skipped = false
- }
- })
-}
-
-// Same as forkTest(), but wait for the test to finish before returning.
-func (runner *suiteRunner) runTest(method *methodType) *C {
- var timeout <-chan time.Time
- if runner.checkTimeout != 0 {
- timeout = time.After(runner.checkTimeout)
- }
- c := runner.forkTest(method)
- select {
- case <-c.done:
- case <-timeout:
- if runner.onTimeout != nil {
- // run the OnTimeout callback, allowing the suite to collect any sort of debug information it can
- // `runFixture` is syncronous, so run this in a separate goroutine with a timeout
- cChan := make(chan *C)
- go func() {
- cChan <- runner.runFixture(runner.onTimeout, c.testName, c.logb)
- }()
- select {
- case <-cChan:
- case <-time.After(runner.checkTimeout):
- }
- }
- panic(timeoutErr{method, runner.checkTimeout})
- }
- return c
-}
-
-// Helper to mark tests as skipped or missed. A bit heavy for what
-// it does, but it enables homogeneous handling of tracking, including
-// nice verbose output.
-func (runner *suiteRunner) skipTests(status funcStatus, methods []*methodType) {
- for _, method := range methods {
- runner.runFunc(method, testKd, "", nil, func(c *C) {
- c.setStatus(status)
- })
- }
-}
-
-// Verify if the fixture arguments are *check.C. In case of errors,
-// log the error as a panic in the fixture method call, and return false.
-func (runner *suiteRunner) checkFixtureArgs() bool {
- succeeded := true
- argType := reflect.TypeOf(&C{})
- for _, method := range []*methodType{runner.setUpSuite, runner.tearDownSuite, runner.setUpTest, runner.tearDownTest, runner.onTimeout} {
- if method != nil {
- mt := method.Type()
- if mt.NumIn() != 1 || mt.In(0) != argType {
- succeeded = false
- runner.runFunc(method, fixtureKd, "", nil, func(c *C) {
- c.logArgPanic(method, "*check.C")
- c.setStatus(panickedSt)
- })
- }
- }
- }
- return succeeded
-}
-
-func (runner *suiteRunner) reportCallStarted(c *C) {
- runner.output.WriteCallStarted("START", c)
-}
-
-func (runner *suiteRunner) reportCallDone(c *C) {
- runner.tracker.callDone(c)
- switch c.status() {
- case succeededSt:
- if c.mustFail {
- runner.output.WriteCallSuccess("FAIL EXPECTED", c)
- } else {
- runner.output.WriteCallSuccess("PASS", c)
- }
- case skippedSt:
- runner.output.WriteCallSuccess("SKIP", c)
- case failedSt:
- runner.output.WriteCallProblem("FAIL", c)
- case panickedSt:
- runner.output.WriteCallProblem("PANIC", c)
- case fixturePanickedSt:
- // That's a testKd call reporting that its fixture
- // has panicked. The fixture call which caused the
- // panic itself was tracked above. We'll report to
- // aid debugging.
- runner.output.WriteCallProblem("PANIC", c)
- case missedSt:
- runner.output.WriteCallSuccess("MISS", c)
- }
-}
diff --git a/vendor/github.com/go-check/check/checkers.go b/vendor/github.com/go-check/check/checkers.go
deleted file mode 100644
index bac3387..0000000
--- a/vendor/github.com/go-check/check/checkers.go
+++ /dev/null
@@ -1,458 +0,0 @@
-package check
-
-import (
- "fmt"
- "reflect"
- "regexp"
-)
-
-// -----------------------------------------------------------------------
-// CommentInterface and Commentf helper, to attach extra information to checks.
-
-type comment struct {
- format string
- args []interface{}
-}
-
-// Commentf returns an infomational value to use with Assert or Check calls.
-// If the checker test fails, the provided arguments will be passed to
-// fmt.Sprintf, and will be presented next to the logged failure.
-//
-// For example:
-//
-// c.Assert(v, Equals, 42, Commentf("Iteration #%d failed.", i))
-//
-// Note that if the comment is constant, a better option is to
-// simply use a normal comment right above or next to the line, as
-// it will also get printed with any errors:
-//
-// c.Assert(l, Equals, 8192) // Ensure buffer size is correct (bug #123)
-//
-func Commentf(format string, args ...interface{}) CommentInterface {
- return &comment{format, args}
-}
-
-// CommentInterface must be implemented by types that attach extra
-// information to failed checks. See the Commentf function for details.
-type CommentInterface interface {
- CheckCommentString() string
-}
-
-func (c *comment) CheckCommentString() string {
- return fmt.Sprintf(c.format, c.args...)
-}
-
-// -----------------------------------------------------------------------
-// The Checker interface.
-
-// The Checker interface must be provided by checkers used with
-// the Assert and Check verification methods.
-type Checker interface {
- Info() *CheckerInfo
- Check(params []interface{}, names []string) (result bool, error string)
-}
-
-// See the Checker interface.
-type CheckerInfo struct {
- Name string
- Params []string
-}
-
-func (info *CheckerInfo) Info() *CheckerInfo {
- return info
-}
-
-// -----------------------------------------------------------------------
-// Not checker logic inverter.
-
-// The Not checker inverts the logic of the provided checker. The
-// resulting checker will succeed where the original one failed, and
-// vice-versa.
-//
-// For example:
-//
-// c.Assert(a, Not(Equals), b)
-//
-func Not(checker Checker) Checker {
- return ¬Checker{checker}
-}
-
-type notChecker struct {
- sub Checker
-}
-
-func (checker *notChecker) Info() *CheckerInfo {
- info := *checker.sub.Info()
- info.Name = "Not(" + info.Name + ")"
- return &info
-}
-
-func (checker *notChecker) Check(params []interface{}, names []string) (result bool, error string) {
- result, error = checker.sub.Check(params, names)
- result = !result
- return
-}
-
-// -----------------------------------------------------------------------
-// IsNil checker.
-
-type isNilChecker struct {
- *CheckerInfo
-}
-
-// The IsNil checker tests whether the obtained value is nil.
-//
-// For example:
-//
-// c.Assert(err, IsNil)
-//
-var IsNil Checker = &isNilChecker{
- &CheckerInfo{Name: "IsNil", Params: []string{"value"}},
-}
-
-func (checker *isNilChecker) Check(params []interface{}, names []string) (result bool, error string) {
- return isNil(params[0]), ""
-}
-
-func isNil(obtained interface{}) (result bool) {
- if obtained == nil {
- result = true
- } else {
- switch v := reflect.ValueOf(obtained); v.Kind() {
- case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
- return v.IsNil()
- }
- }
- return
-}
-
-// -----------------------------------------------------------------------
-// NotNil checker. Alias for Not(IsNil), since it's so common.
-
-type notNilChecker struct {
- *CheckerInfo
-}
-
-// The NotNil checker verifies that the obtained value is not nil.
-//
-// For example:
-//
-// c.Assert(iface, NotNil)
-//
-// This is an alias for Not(IsNil), made available since it's a
-// fairly common check.
-//
-var NotNil Checker = ¬NilChecker{
- &CheckerInfo{Name: "NotNil", Params: []string{"value"}},
-}
-
-func (checker *notNilChecker) Check(params []interface{}, names []string) (result bool, error string) {
- return !isNil(params[0]), ""
-}
-
-// -----------------------------------------------------------------------
-// Equals checker.
-
-type equalsChecker struct {
- *CheckerInfo
-}
-
-// The Equals checker verifies that the obtained value is equal to
-// the expected value, according to usual Go semantics for ==.
-//
-// For example:
-//
-// c.Assert(value, Equals, 42)
-//
-var Equals Checker = &equalsChecker{
- &CheckerInfo{Name: "Equals", Params: []string{"obtained", "expected"}},
-}
-
-func (checker *equalsChecker) Check(params []interface{}, names []string) (result bool, error string) {
- defer func() {
- if v := recover(); v != nil {
- result = false
- error = fmt.Sprint(v)
- }
- }()
- return params[0] == params[1], ""
-}
-
-// -----------------------------------------------------------------------
-// DeepEquals checker.
-
-type deepEqualsChecker struct {
- *CheckerInfo
-}
-
-// The DeepEquals checker verifies that the obtained value is deep-equal to
-// the expected value. The check will work correctly even when facing
-// slices, interfaces, and values of different types (which always fail
-// the test).
-//
-// For example:
-//
-// c.Assert(value, DeepEquals, 42)
-// c.Assert(array, DeepEquals, []string{"hi", "there"})
-//
-var DeepEquals Checker = &deepEqualsChecker{
- &CheckerInfo{Name: "DeepEquals", Params: []string{"obtained", "expected"}},
-}
-
-func (checker *deepEqualsChecker) Check(params []interface{}, names []string) (result bool, error string) {
- return reflect.DeepEqual(params[0], params[1]), ""
-}
-
-// -----------------------------------------------------------------------
-// HasLen checker.
-
-type hasLenChecker struct {
- *CheckerInfo
-}
-
-// The HasLen checker verifies that the obtained value has the
-// provided length. In many cases this is superior to using Equals
-// in conjuction with the len function because in case the check
-// fails the value itself will be printed, instead of its length,
-// providing more details for figuring the problem.
-//
-// For example:
-//
-// c.Assert(list, HasLen, 5)
-//
-var HasLen Checker = &hasLenChecker{
- &CheckerInfo{Name: "HasLen", Params: []string{"obtained", "n"}},
-}
-
-func (checker *hasLenChecker) Check(params []interface{}, names []string) (result bool, error string) {
- n, ok := params[1].(int)
- if !ok {
- return false, "n must be an int"
- }
- value := reflect.ValueOf(params[0])
- switch value.Kind() {
- case reflect.Map, reflect.Array, reflect.Slice, reflect.Chan, reflect.String:
- default:
- return false, "obtained value type has no length"
- }
- return value.Len() == n, ""
-}
-
-// -----------------------------------------------------------------------
-// ErrorMatches checker.
-
-type errorMatchesChecker struct {
- *CheckerInfo
-}
-
-// The ErrorMatches checker verifies that the error value
-// is non nil and matches the regular expression provided.
-//
-// For example:
-//
-// c.Assert(err, ErrorMatches, "perm.*denied")
-//
-var ErrorMatches Checker = errorMatchesChecker{
- &CheckerInfo{Name: "ErrorMatches", Params: []string{"value", "regex"}},
-}
-
-func (checker errorMatchesChecker) Check(params []interface{}, names []string) (result bool, errStr string) {
- if params[0] == nil {
- return false, "Error value is nil"
- }
- err, ok := params[0].(error)
- if !ok {
- return false, "Value is not an error"
- }
- params[0] = err.Error()
- names[0] = "error"
- return matches(params[0], params[1])
-}
-
-// -----------------------------------------------------------------------
-// Matches checker.
-
-type matchesChecker struct {
- *CheckerInfo
-}
-
-// The Matches checker verifies that the string provided as the obtained
-// value (or the string resulting from obtained.String()) matches the
-// regular expression provided.
-//
-// For example:
-//
-// c.Assert(err, Matches, "perm.*denied")
-//
-var Matches Checker = &matchesChecker{
- &CheckerInfo{Name: "Matches", Params: []string{"value", "regex"}},
-}
-
-func (checker *matchesChecker) Check(params []interface{}, names []string) (result bool, error string) {
- return matches(params[0], params[1])
-}
-
-func matches(value, regex interface{}) (result bool, error string) {
- reStr, ok := regex.(string)
- if !ok {
- return false, "Regex must be a string"
- }
- valueStr, valueIsStr := value.(string)
- if !valueIsStr {
- if valueWithStr, valueHasStr := value.(fmt.Stringer); valueHasStr {
- valueStr, valueIsStr = valueWithStr.String(), true
- }
- }
- if valueIsStr {
- matches, err := regexp.MatchString("^"+reStr+"$", valueStr)
- if err != nil {
- return false, "Can't compile regex: " + err.Error()
- }
- return matches, ""
- }
- return false, "Obtained value is not a string and has no .String()"
-}
-
-// -----------------------------------------------------------------------
-// Panics checker.
-
-type panicsChecker struct {
- *CheckerInfo
-}
-
-// The Panics checker verifies that calling the provided zero-argument
-// function will cause a panic which is deep-equal to the provided value.
-//
-// For example:
-//
-// c.Assert(func() { f(1, 2) }, Panics, &SomeErrorType{"BOOM"}).
-//
-//
-var Panics Checker = &panicsChecker{
- &CheckerInfo{Name: "Panics", Params: []string{"function", "expected"}},
-}
-
-func (checker *panicsChecker) Check(params []interface{}, names []string) (result bool, error string) {
- f := reflect.ValueOf(params[0])
- if f.Kind() != reflect.Func || f.Type().NumIn() != 0 {
- return false, "Function must take zero arguments"
- }
- defer func() {
- // If the function has not panicked, then don't do the check.
- if error != "" {
- return
- }
- params[0] = recover()
- names[0] = "panic"
- result = reflect.DeepEqual(params[0], params[1])
- }()
- f.Call(nil)
- return false, "Function has not panicked"
-}
-
-type panicMatchesChecker struct {
- *CheckerInfo
-}
-
-// The PanicMatches checker verifies that calling the provided zero-argument
-// function will cause a panic with an error value matching
-// the regular expression provided.
-//
-// For example:
-//
-// c.Assert(func() { f(1, 2) }, PanicMatches, `open.*: no such file or directory`).
-//
-//
-var PanicMatches Checker = &panicMatchesChecker{
- &CheckerInfo{Name: "PanicMatches", Params: []string{"function", "expected"}},
-}
-
-func (checker *panicMatchesChecker) Check(params []interface{}, names []string) (result bool, errmsg string) {
- f := reflect.ValueOf(params[0])
- if f.Kind() != reflect.Func || f.Type().NumIn() != 0 {
- return false, "Function must take zero arguments"
- }
- defer func() {
- // If the function has not panicked, then don't do the check.
- if errmsg != "" {
- return
- }
- obtained := recover()
- names[0] = "panic"
- if e, ok := obtained.(error); ok {
- params[0] = e.Error()
- } else if _, ok := obtained.(string); ok {
- params[0] = obtained
- } else {
- errmsg = "Panic value is not a string or an error"
- return
- }
- result, errmsg = matches(params[0], params[1])
- }()
- f.Call(nil)
- return false, "Function has not panicked"
-}
-
-// -----------------------------------------------------------------------
-// FitsTypeOf checker.
-
-type fitsTypeChecker struct {
- *CheckerInfo
-}
-
-// The FitsTypeOf checker verifies that the obtained value is
-// assignable to a variable with the same type as the provided
-// sample value.
-//
-// For example:
-//
-// c.Assert(value, FitsTypeOf, int64(0))
-// c.Assert(value, FitsTypeOf, os.Error(nil))
-//
-var FitsTypeOf Checker = &fitsTypeChecker{
- &CheckerInfo{Name: "FitsTypeOf", Params: []string{"obtained", "sample"}},
-}
-
-func (checker *fitsTypeChecker) Check(params []interface{}, names []string) (result bool, error string) {
- obtained := reflect.ValueOf(params[0])
- sample := reflect.ValueOf(params[1])
- if !obtained.IsValid() {
- return false, ""
- }
- if !sample.IsValid() {
- return false, "Invalid sample value"
- }
- return obtained.Type().AssignableTo(sample.Type()), ""
-}
-
-// -----------------------------------------------------------------------
-// Implements checker.
-
-type implementsChecker struct {
- *CheckerInfo
-}
-
-// The Implements checker verifies that the obtained value
-// implements the interface specified via a pointer to an interface
-// variable.
-//
-// For example:
-//
-// var e os.Error
-// c.Assert(err, Implements, &e)
-//
-var Implements Checker = &implementsChecker{
- &CheckerInfo{Name: "Implements", Params: []string{"obtained", "ifaceptr"}},
-}
-
-func (checker *implementsChecker) Check(params []interface{}, names []string) (result bool, error string) {
- obtained := reflect.ValueOf(params[0])
- ifaceptr := reflect.ValueOf(params[1])
- if !obtained.IsValid() {
- return false, ""
- }
- if !ifaceptr.IsValid() || ifaceptr.Kind() != reflect.Ptr || ifaceptr.Elem().Kind() != reflect.Interface {
- return false, "ifaceptr should be a pointer to an interface variable"
- }
- return obtained.Type().Implements(ifaceptr.Elem().Type()), ""
-}
diff --git a/vendor/github.com/go-check/check/helpers.go b/vendor/github.com/go-check/check/helpers.go
deleted file mode 100644
index 58a733b..0000000
--- a/vendor/github.com/go-check/check/helpers.go
+++ /dev/null
@@ -1,231 +0,0 @@
-package check
-
-import (
- "fmt"
- "strings"
- "time"
-)
-
-// TestName returns the current test name in the form "SuiteName.TestName"
-func (c *C) TestName() string {
- return c.testName
-}
-
-// -----------------------------------------------------------------------
-// Basic succeeding/failing logic.
-
-// Failed returns whether the currently running test has already failed.
-func (c *C) Failed() bool {
- return c.status() == failedSt
-}
-
-// Fail marks the currently running test as failed.
-//
-// Something ought to have been previously logged so the developer can tell
-// what went wrong. The higher level helper functions will fail the test
-// and do the logging properly.
-func (c *C) Fail() {
- c.setStatus(failedSt)
-}
-
-// FailNow marks the currently running test as failed and stops running it.
-// Something ought to have been previously logged so the developer can tell
-// what went wrong. The higher level helper functions will fail the test
-// and do the logging properly.
-func (c *C) FailNow() {
- c.Fail()
- c.stopNow()
-}
-
-// Succeed marks the currently running test as succeeded, undoing any
-// previous failures.
-func (c *C) Succeed() {
- c.setStatus(succeededSt)
-}
-
-// SucceedNow marks the currently running test as succeeded, undoing any
-// previous failures, and stops running the test.
-func (c *C) SucceedNow() {
- c.Succeed()
- c.stopNow()
-}
-
-// ExpectFailure informs that the running test is knowingly broken for
-// the provided reason. If the test does not fail, an error will be reported
-// to raise attention to this fact. This method is useful to temporarily
-// disable tests which cover well known problems until a better time to
-// fix the problem is found, without forgetting about the fact that a
-// failure still exists.
-func (c *C) ExpectFailure(reason string) {
- if reason == "" {
- panic("Missing reason why the test is expected to fail")
- }
- c.mustFail = true
- c.reason = reason
-}
-
-// Skip skips the running test for the provided reason. If run from within
-// SetUpTest, the individual test being set up will be skipped, and if run
-// from within SetUpSuite, the whole suite is skipped.
-func (c *C) Skip(reason string) {
- if reason == "" {
- panic("Missing reason why the test is being skipped")
- }
- c.reason = reason
- c.setStatus(skippedSt)
- c.stopNow()
-}
-
-// -----------------------------------------------------------------------
-// Basic logging.
-
-// GetTestLog returns the current test error output.
-func (c *C) GetTestLog() string {
- return c.logb.String()
-}
-
-// Log logs some information into the test error output.
-// The provided arguments are assembled together into a string with fmt.Sprint.
-func (c *C) Log(args ...interface{}) {
- c.log(args...)
-}
-
-// Log logs some information into the test error output.
-// The provided arguments are assembled together into a string with fmt.Sprintf.
-func (c *C) Logf(format string, args ...interface{}) {
- c.logf(format, args...)
-}
-
-// Output enables *C to be used as a logger in functions that require only
-// the minimum interface of *log.Logger.
-func (c *C) Output(calldepth int, s string) error {
- d := time.Now().Sub(c.startTime)
- msec := d / time.Millisecond
- sec := d / time.Second
- min := d / time.Minute
-
- c.Logf("[LOG] %d:%02d.%03d %s", min, sec%60, msec%1000, s)
- return nil
-}
-
-// Error logs an error into the test error output and marks the test as failed.
-// The provided arguments are assembled together into a string with fmt.Sprint.
-func (c *C) Error(args ...interface{}) {
- c.logCaller(1)
- c.logString(fmt.Sprint("Error: ", fmt.Sprint(args...)))
- c.logNewLine()
- c.Fail()
-}
-
-// Errorf logs an error into the test error output and marks the test as failed.
-// The provided arguments are assembled together into a string with fmt.Sprintf.
-func (c *C) Errorf(format string, args ...interface{}) {
- c.logCaller(1)
- c.logString(fmt.Sprintf("Error: "+format, args...))
- c.logNewLine()
- c.Fail()
-}
-
-// Fatal logs an error into the test error output, marks the test as failed, and
-// stops the test execution. The provided arguments are assembled together into
-// a string with fmt.Sprint.
-func (c *C) Fatal(args ...interface{}) {
- c.logCaller(1)
- c.logString(fmt.Sprint("Error: ", fmt.Sprint(args...)))
- c.logNewLine()
- c.FailNow()
-}
-
-// Fatlaf logs an error into the test error output, marks the test as failed, and
-// stops the test execution. The provided arguments are assembled together into
-// a string with fmt.Sprintf.
-func (c *C) Fatalf(format string, args ...interface{}) {
- c.logCaller(1)
- c.logString(fmt.Sprint("Error: ", fmt.Sprintf(format, args...)))
- c.logNewLine()
- c.FailNow()
-}
-
-// -----------------------------------------------------------------------
-// Generic checks and assertions based on checkers.
-
-// Check verifies if the first value matches the expected value according
-// to the provided checker. If they do not match, an error is logged, the
-// test is marked as failed, and the test execution continues.
-//
-// Some checkers may not need the expected argument (e.g. IsNil).
-//
-// Extra arguments provided to the function are logged next to the reported
-// problem when the matching fails.
-func (c *C) Check(obtained interface{}, checker Checker, args ...interface{}) bool {
- return c.internalCheck("Check", obtained, checker, args...)
-}
-
-// Assert ensures that the first value matches the expected value according
-// to the provided checker. If they do not match, an error is logged, the
-// test is marked as failed, and the test execution stops.
-//
-// Some checkers may not need the expected argument (e.g. IsNil).
-//
-// Extra arguments provided to the function are logged next to the reported
-// problem when the matching fails.
-func (c *C) Assert(obtained interface{}, checker Checker, args ...interface{}) {
- if !c.internalCheck("Assert", obtained, checker, args...) {
- c.stopNow()
- }
-}
-
-func (c *C) internalCheck(funcName string, obtained interface{}, checker Checker, args ...interface{}) bool {
- if checker == nil {
- c.logCaller(2)
- c.logString(fmt.Sprintf("%s(obtained, nil!?, ...):", funcName))
- c.logString("Oops.. you've provided a nil checker!")
- c.logNewLine()
- c.Fail()
- return false
- }
-
- // If the last argument is a bug info, extract it out.
- var comment CommentInterface
- if len(args) > 0 {
- if c, ok := args[len(args)-1].(CommentInterface); ok {
- comment = c
- args = args[:len(args)-1]
- }
- }
-
- params := append([]interface{}{obtained}, args...)
- info := checker.Info()
-
- if len(params) != len(info.Params) {
- names := append([]string{info.Params[0], info.Name}, info.Params[1:]...)
- c.logCaller(2)
- c.logString(fmt.Sprintf("%s(%s):", funcName, strings.Join(names, ", ")))
- c.logString(fmt.Sprintf("Wrong number of parameters for %s: want %d, got %d", info.Name, len(names), len(params)+1))
- c.logNewLine()
- c.Fail()
- return false
- }
-
- // Copy since it may be mutated by Check.
- names := append([]string{}, info.Params...)
-
- // Do the actual check.
- result, error := checker.Check(params, names)
- if !result || error != "" {
- c.logCaller(2)
- for i := 0; i != len(params); i++ {
- c.logValue(names[i], params[i])
- }
- if comment != nil {
- c.logString(comment.CheckCommentString())
- }
- if error != "" {
- c.logString(error)
- }
- c.logNewLine()
- c.Fail()
- return false
- }
- return true
-}
diff --git a/vendor/github.com/go-check/check/printer.go b/vendor/github.com/go-check/check/printer.go
deleted file mode 100644
index e0f7557..0000000
--- a/vendor/github.com/go-check/check/printer.go
+++ /dev/null
@@ -1,168 +0,0 @@
-package check
-
-import (
- "bytes"
- "go/ast"
- "go/parser"
- "go/printer"
- "go/token"
- "os"
-)
-
-func indent(s, with string) (r string) {
- eol := true
- for i := 0; i != len(s); i++ {
- c := s[i]
- switch {
- case eol && c == '\n' || c == '\r':
- case c == '\n' || c == '\r':
- eol = true
- case eol:
- eol = false
- s = s[:i] + with + s[i:]
- i += len(with)
- }
- }
- return s
-}
-
-func printLine(filename string, line int) (string, error) {
- fset := token.NewFileSet()
- file, err := os.Open(filename)
- if err != nil {
- return "", err
- }
- fnode, err := parser.ParseFile(fset, filename, file, parser.ParseComments)
- if err != nil {
- return "", err
- }
- config := &printer.Config{Mode: printer.UseSpaces, Tabwidth: 4}
- lp := &linePrinter{fset: fset, fnode: fnode, line: line, config: config}
- ast.Walk(lp, fnode)
- result := lp.output.Bytes()
- // Comments leave \n at the end.
- n := len(result)
- for n > 0 && result[n-1] == '\n' {
- n--
- }
- return string(result[:n]), nil
-}
-
-type linePrinter struct {
- config *printer.Config
- fset *token.FileSet
- fnode *ast.File
- line int
- output bytes.Buffer
- stmt ast.Stmt
-}
-
-func (lp *linePrinter) emit() bool {
- if lp.stmt != nil {
- lp.trim(lp.stmt)
- lp.printWithComments(lp.stmt)
- lp.stmt = nil
- return true
- }
- return false
-}
-
-func (lp *linePrinter) printWithComments(n ast.Node) {
- nfirst := lp.fset.Position(n.Pos()).Line
- nlast := lp.fset.Position(n.End()).Line
- for _, g := range lp.fnode.Comments {
- cfirst := lp.fset.Position(g.Pos()).Line
- clast := lp.fset.Position(g.End()).Line
- if clast == nfirst-1 && lp.fset.Position(n.Pos()).Column == lp.fset.Position(g.Pos()).Column {
- for _, c := range g.List {
- lp.output.WriteString(c.Text)
- lp.output.WriteByte('\n')
- }
- }
- if cfirst >= nfirst && cfirst <= nlast && n.End() <= g.List[0].Slash {
- // The printer will not include the comment if it starts past
- // the node itself. Trick it into printing by overlapping the
- // slash with the end of the statement.
- g.List[0].Slash = n.End() - 1
- }
- }
- node := &printer.CommentedNode{n, lp.fnode.Comments}
- lp.config.Fprint(&lp.output, lp.fset, node)
-}
-
-func (lp *linePrinter) Visit(n ast.Node) (w ast.Visitor) {
- if n == nil {
- if lp.output.Len() == 0 {
- lp.emit()
- }
- return nil
- }
- first := lp.fset.Position(n.Pos()).Line
- last := lp.fset.Position(n.End()).Line
- if first <= lp.line && last >= lp.line {
- // Print the innermost statement containing the line.
- if stmt, ok := n.(ast.Stmt); ok {
- if _, ok := n.(*ast.BlockStmt); !ok {
- lp.stmt = stmt
- }
- }
- if first == lp.line && lp.emit() {
- return nil
- }
- return lp
- }
- return nil
-}
-
-func (lp *linePrinter) trim(n ast.Node) bool {
- stmt, ok := n.(ast.Stmt)
- if !ok {
- return true
- }
- line := lp.fset.Position(n.Pos()).Line
- if line != lp.line {
- return false
- }
- switch stmt := stmt.(type) {
- case *ast.IfStmt:
- stmt.Body = lp.trimBlock(stmt.Body)
- case *ast.SwitchStmt:
- stmt.Body = lp.trimBlock(stmt.Body)
- case *ast.TypeSwitchStmt:
- stmt.Body = lp.trimBlock(stmt.Body)
- case *ast.CaseClause:
- stmt.Body = lp.trimList(stmt.Body)
- case *ast.CommClause:
- stmt.Body = lp.trimList(stmt.Body)
- case *ast.BlockStmt:
- stmt.List = lp.trimList(stmt.List)
- }
- return true
-}
-
-func (lp *linePrinter) trimBlock(stmt *ast.BlockStmt) *ast.BlockStmt {
- if !lp.trim(stmt) {
- return lp.emptyBlock(stmt)
- }
- stmt.Rbrace = stmt.Lbrace
- return stmt
-}
-
-func (lp *linePrinter) trimList(stmts []ast.Stmt) []ast.Stmt {
- for i := 0; i != len(stmts); i++ {
- if !lp.trim(stmts[i]) {
- stmts[i] = lp.emptyStmt(stmts[i])
- break
- }
- }
- return stmts
-}
-
-func (lp *linePrinter) emptyStmt(n ast.Node) *ast.ExprStmt {
- return &ast.ExprStmt{&ast.Ellipsis{n.Pos(), nil}}
-}
-
-func (lp *linePrinter) emptyBlock(n ast.Node) *ast.BlockStmt {
- p := n.Pos()
- return &ast.BlockStmt{p, []ast.Stmt{lp.emptyStmt(n)}, p}
-}
diff --git a/vendor/github.com/go-check/check/reporter.go b/vendor/github.com/go-check/check/reporter.go
deleted file mode 100644
index fb04f76..0000000
--- a/vendor/github.com/go-check/check/reporter.go
+++ /dev/null
@@ -1,88 +0,0 @@
-package check
-
-import (
- "fmt"
- "io"
- "sync"
-)
-
-// -----------------------------------------------------------------------
-// Output writer manages atomic output writing according to settings.
-
-type outputWriter struct {
- m sync.Mutex
- writer io.Writer
- wroteCallProblemLast bool
- Stream bool
- Verbose bool
-}
-
-func newOutputWriter(writer io.Writer, stream, verbose bool) *outputWriter {
- return &outputWriter{writer: writer, Stream: stream, Verbose: verbose}
-}
-
-func (ow *outputWriter) Write(content []byte) (n int, err error) {
- ow.m.Lock()
- n, err = ow.writer.Write(content)
- ow.m.Unlock()
- return
-}
-
-func (ow *outputWriter) WriteCallStarted(label string, c *C) {
- if ow.Stream {
- header := renderCallHeader(label, c, "", "\n")
- ow.m.Lock()
- ow.writer.Write([]byte(header))
- ow.m.Unlock()
- }
-}
-
-func (ow *outputWriter) WriteCallProblem(label string, c *C) {
- var prefix string
- if !ow.Stream {
- prefix = "\n-----------------------------------" +
- "-----------------------------------\n"
- }
- header := renderCallHeader(label, c, prefix, "\n\n")
- ow.m.Lock()
- ow.wroteCallProblemLast = true
- ow.writer.Write([]byte(header))
- if !ow.Stream {
- c.logb.WriteTo(ow.writer)
- }
- ow.m.Unlock()
-}
-
-func (ow *outputWriter) WriteCallSuccess(label string, c *C) {
- if ow.Stream || (ow.Verbose && c.kind == testKd) {
- // TODO Use a buffer here.
- var suffix string
- if c.reason != "" {
- suffix = " (" + c.reason + ")"
- }
- if c.status() == succeededSt {
- suffix += "\t" + c.timerString()
- }
- suffix += "\n"
- if ow.Stream {
- suffix += "\n"
- }
- header := renderCallHeader(label, c, "", suffix)
- ow.m.Lock()
- // Resist temptation of using line as prefix above due to race.
- if !ow.Stream && ow.wroteCallProblemLast {
- header = "\n-----------------------------------" +
- "-----------------------------------\n" +
- header
- }
- ow.wroteCallProblemLast = false
- ow.writer.Write([]byte(header))
- ow.m.Unlock()
- }
-}
-
-func renderCallHeader(label string, c *C, prefix, suffix string) string {
- pc := c.method.PC()
- return fmt.Sprintf("%s%s: %s: %s%s", prefix, label, niceFuncPath(pc),
- niceFuncName(pc), suffix)
-}
diff --git a/vendor/github.com/go-check/check/run.go b/vendor/github.com/go-check/check/run.go
deleted file mode 100644
index f721196..0000000
--- a/vendor/github.com/go-check/check/run.go
+++ /dev/null
@@ -1,183 +0,0 @@
-package check
-
-import (
- "bufio"
- "flag"
- "fmt"
- "os"
- "testing"
- "time"
-)
-
-// -----------------------------------------------------------------------
-// Test suite registry.
-
-var allSuites []interface{}
-
-// Suite registers the given value as a test suite to be run. Any methods
-// starting with the Test prefix in the given value will be considered as
-// a test method.
-func Suite(suite interface{}) interface{} {
- allSuites = append(allSuites, suite)
- return suite
-}
-
-// -----------------------------------------------------------------------
-// Public running interface.
-
-var (
- oldFilterFlag = flag.String("gocheck.f", "", "Regular expression selecting which tests and/or suites to run")
- oldVerboseFlag = flag.Bool("gocheck.v", false, "Verbose mode")
- oldStreamFlag = flag.Bool("gocheck.vv", false, "Super verbose mode (disables output caching)")
- oldBenchFlag = flag.Bool("gocheck.b", false, "Run benchmarks")
- oldBenchTime = flag.Duration("gocheck.btime", 1*time.Second, "approximate run time for each benchmark")
- oldListFlag = flag.Bool("gocheck.list", false, "List the names of all tests that will be run")
- oldWorkFlag = flag.Bool("gocheck.work", false, "Display and do not remove the test working directory")
-
- newFilterFlag = flag.String("check.f", "", "Regular expression selecting which tests and/or suites to run")
- newVerboseFlag = flag.Bool("check.v", false, "Verbose mode")
- newStreamFlag = flag.Bool("check.vv", false, "Super verbose mode (disables output caching)")
- newBenchFlag = flag.Bool("check.b", false, "Run benchmarks")
- newBenchTime = flag.Duration("check.btime", 1*time.Second, "approximate run time for each benchmark")
- newBenchMem = flag.Bool("check.bmem", false, "Report memory benchmarks")
- newListFlag = flag.Bool("check.list", false, "List the names of all tests that will be run")
- newWorkFlag = flag.Bool("check.work", false, "Display and do not remove the test working directory")
- checkTimeout = flag.String("check.timeout", "", "Panic if test runs longer than specified duration")
-)
-
-// TestingT runs all test suites registered with the Suite function,
-// printing results to stdout, and reporting any failures back to
-// the "testing" package.
-func TestingT(testingT *testing.T) {
- benchTime := *newBenchTime
- if benchTime == 1*time.Second {
- benchTime = *oldBenchTime
- }
- conf := &RunConf{
- Filter: *oldFilterFlag + *newFilterFlag,
- Verbose: *oldVerboseFlag || *newVerboseFlag,
- Stream: *oldStreamFlag || *newStreamFlag,
- Benchmark: *oldBenchFlag || *newBenchFlag,
- BenchmarkTime: benchTime,
- BenchmarkMem: *newBenchMem,
- KeepWorkDir: *oldWorkFlag || *newWorkFlag,
- }
- if *checkTimeout != "" {
- timeout, err := time.ParseDuration(*checkTimeout)
- if err != nil {
- testingT.Fatalf("error parsing specified timeout flag: %v", err)
- }
- conf.CheckTimeout = timeout
- }
- if *oldListFlag || *newListFlag {
- w := bufio.NewWriter(os.Stdout)
- for _, name := range ListAll(conf) {
- fmt.Fprintln(w, name)
- }
- w.Flush()
- return
- }
- result := RunAll(conf)
- println(result.String())
- if !result.Passed() {
- testingT.Fail()
- }
-}
-
-// RunAll runs all test suites registered with the Suite function, using the
-// provided run configuration.
-func RunAll(runConf *RunConf) *Result {
- result := Result{}
- for _, suite := range allSuites {
- result.Add(Run(suite, runConf))
- }
- return &result
-}
-
-// Run runs the provided test suite using the provided run configuration.
-func Run(suite interface{}, runConf *RunConf) *Result {
- runner := newSuiteRunner(suite, runConf)
- return runner.run()
-}
-
-// ListAll returns the names of all the test functions registered with the
-// Suite function that will be run with the provided run configuration.
-func ListAll(runConf *RunConf) []string {
- var names []string
- for _, suite := range allSuites {
- names = append(names, List(suite, runConf)...)
- }
- return names
-}
-
-// List returns the names of the test functions in the given
-// suite that will be run with the provided run configuration.
-func List(suite interface{}, runConf *RunConf) []string {
- var names []string
- runner := newSuiteRunner(suite, runConf)
- for _, t := range runner.tests {
- names = append(names, t.String())
- }
- return names
-}
-
-// -----------------------------------------------------------------------
-// Result methods.
-
-func (r *Result) Add(other *Result) {
- r.Succeeded += other.Succeeded
- r.Skipped += other.Skipped
- r.Failed += other.Failed
- r.Panicked += other.Panicked
- r.FixturePanicked += other.FixturePanicked
- r.ExpectedFailures += other.ExpectedFailures
- r.Missed += other.Missed
- if r.WorkDir != "" && other.WorkDir != "" {
- r.WorkDir += ":" + other.WorkDir
- } else if other.WorkDir != "" {
- r.WorkDir = other.WorkDir
- }
-}
-
-func (r *Result) Passed() bool {
- return (r.Failed == 0 && r.Panicked == 0 &&
- r.FixturePanicked == 0 && r.Missed == 0 &&
- r.RunError == nil)
-}
-
-func (r *Result) String() string {
- if r.RunError != nil {
- return "ERROR: " + r.RunError.Error()
- }
-
- var value string
- if r.Failed == 0 && r.Panicked == 0 && r.FixturePanicked == 0 &&
- r.Missed == 0 {
- value = "OK: "
- } else {
- value = "OOPS: "
- }
- value += fmt.Sprintf("%d passed", r.Succeeded)
- if r.Skipped != 0 {
- value += fmt.Sprintf(", %d skipped", r.Skipped)
- }
- if r.ExpectedFailures != 0 {
- value += fmt.Sprintf(", %d expected failures", r.ExpectedFailures)
- }
- if r.Failed != 0 {
- value += fmt.Sprintf(", %d FAILED", r.Failed)
- }
- if r.Panicked != 0 {
- value += fmt.Sprintf(", %d PANICKED", r.Panicked)
- }
- if r.FixturePanicked != 0 {
- value += fmt.Sprintf(", %d FIXTURE-PANICKED", r.FixturePanicked)
- }
- if r.Missed != 0 {
- value += fmt.Sprintf(", %d MISSED", r.Missed)
- }
- if r.WorkDir != "" {
- value += "\nWORK=" + r.WorkDir
- }
- return value
-}
diff --git a/vendor/github.com/vdemeester/shakers/LICENSE b/vendor/github.com/vdemeester/shakers/LICENSE
deleted file mode 100644
index e9e9e84..0000000
--- a/vendor/github.com/vdemeester/shakers/LICENSE
+++ /dev/null
@@ -1,191 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- https://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- Copyright 2015-2016 Vincent Demeester
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- https://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/vendor/github.com/vdemeester/shakers/README.md b/vendor/github.com/vdemeester/shakers/README.md
deleted file mode 100644
index 165bc96..0000000
--- a/vendor/github.com/vdemeester/shakers/README.md
+++ /dev/null
@@ -1,30 +0,0 @@
-# Shakers
-🐹 + 🐙 = 😽 [![Circle CI](https://circleci.com/gh/vdemeester/shakers.svg?style=svg)](https://circleci.com/gh/vdemeester/shakers)
-
-A collection of `go-check` Checkers to ease the use of it.
-
-## Building and testing it
-
-You need either [docker](https://github.com/docker/docker), or `go`
-and `glide` in order to build and test shakers.
-
-### Using Docker and Makefile
-
-You need to run the ``test-unit`` target.
-```bash
-$ make test-unit
-docker build -t "shakers-dev:master" .
-# […]
-docker run --rm -it "shakers-dev:master" ./script/make.sh test-unit
----> Making bundle: test-unit (in .)
-+ go test -cover -coverprofile=cover.out .
-ok github.com/vdemeester/shakers 0.015s coverage: 96.0% of statements
-
-Test success
-```
-
-### Using glide and `GO15VENDOREXPERIMENT`
-
-- Get the dependencies with `glide up` (or use `go get` but you have no garantuees over the version of the dependencies)
-- If you're using glide (and not standard `go get`) export `GO15VENDOREXPERIMENT` with `export GO15VENDOREXPERIMENT=1`
-- Run tests with `go test .`
diff --git a/vendor/github.com/vdemeester/shakers/bool.go b/vendor/github.com/vdemeester/shakers/bool.go
deleted file mode 100644
index ab2a993..0000000
--- a/vendor/github.com/vdemeester/shakers/bool.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package shakers
-
-import (
- "github.com/go-check/check"
-)
-
-// True checker verifies the obtained value is true
-//
-// c.Assert(myBool, True)
-//
-var True check.Checker = &boolChecker{
- &check.CheckerInfo{
- Name: "True",
- Params: []string{"obtained"},
- },
- true,
-}
-
-// False checker verifies the obtained value is false
-//
-// c.Assert(myBool, False)
-//
-var False check.Checker = &boolChecker{
- &check.CheckerInfo{
- Name: "False",
- Params: []string{"obtained"},
- },
- false,
-}
-
-type boolChecker struct {
- *check.CheckerInfo
- expected bool
-}
-
-func (checker *boolChecker) Check(params []interface{}, names []string) (bool, string) {
- return is(checker.expected, params[0])
-}
-
-func is(expected bool, obtained interface{}) (bool, string) {
- obtainedBool, ok := obtained.(bool)
- if !ok {
- return false, "obtained value must be a bool."
- }
- return obtainedBool == expected, ""
-}
diff --git a/vendor/github.com/vdemeester/shakers/common.go b/vendor/github.com/vdemeester/shakers/common.go
deleted file mode 100644
index a2245c6..0000000
--- a/vendor/github.com/vdemeester/shakers/common.go
+++ /dev/null
@@ -1,310 +0,0 @@
-package shakers
-
-import (
- "reflect"
- "time"
-
- "github.com/go-check/check"
-)
-
-// As a commodity, we bring all check.Checker variables into the current namespace to avoid having
-// to think about check.X versus checker.X.
-var (
- DeepEquals = check.DeepEquals
- ErrorMatches = check.ErrorMatches
- FitsTypeOf = check.FitsTypeOf
- HasLen = check.HasLen
- Implements = check.Implements
- IsNil = check.IsNil
- Matches = check.Matches
- Not = check.Not
- NotNil = check.NotNil
- PanicMatches = check.PanicMatches
- Panics = check.Panics
-)
-
-// Equaler is an interface implemented if the type has a Equal method.
-// This is used to compare struct using shakers.Equals.
-type Equaler interface {
- Equal(Equaler) bool
-}
-
-// Equals checker verifies the obtained value is equal to the specified one.
-// It's is smart in a wait that it supports several *types* (built-in, Equaler,
-// time.Time)
-//
-// c.Assert(myStruct, Equals, aStruct, check.Commentf("bouuuhh"))
-// c.Assert(myTime, Equals, aTime, check.Commentf("bouuuhh"))
-//
-var Equals check.Checker = &equalChecker{
- &check.CheckerInfo{
- Name: "Equals",
- Params: []string{"obtained", "expected"},
- },
-}
-
-type equalChecker struct {
- *check.CheckerInfo
-}
-
-func (checker *equalChecker) Check(params []interface{}, names []string) (bool, string) {
- return isEqual(params[0], params[1])
-}
-
-func isEqual(obtained, expected interface{}) (bool, string) {
- switch obtained.(type) {
- case time.Time:
- return timeEquals(obtained, expected)
- case Equaler:
- return equalerEquals(obtained, expected)
- default:
- if reflect.TypeOf(obtained) != reflect.TypeOf(expected) {
- return false, "obtained value and expected value have not the same type."
- }
- return obtained == expected, ""
- }
-}
-
-func equalerEquals(obtained, expected interface{}) (bool, string) {
- expectedEqualer, ok := expected.(Equaler)
- if !ok {
- return false, "expected value must be an Equaler - implementing Equal(Equaler)."
- }
- obtainedEqualer, ok := obtained.(Equaler)
- if !ok {
- return false, "obtained value must be an Equaler - implementing Equal(Equaler)."
- }
- return obtainedEqualer.Equal(expectedEqualer), ""
-}
-
-// GreaterThan checker verifies the obtained value is greater than the specified one.
-// It's is smart in a wait that it supports several *types* (built-in, time.Time)
-//
-// c.Assert(myTime, GreaterThan, aTime, check.Commentf("bouuuhh"))
-// c.Assert(myInt, GreaterThan, 2, check.Commentf("bouuuhh"))
-//
-var GreaterThan check.Checker = &greaterThanChecker{
- &check.CheckerInfo{
- Name: "GreaterThan",
- Params: []string{"obtained", "expected"},
- },
-}
-
-type greaterThanChecker struct {
- *check.CheckerInfo
-}
-
-func (checker *greaterThanChecker) Check(params []interface{}, names []string) (bool, string) {
- return greaterThan(params[0], params[1])
-}
-
-func greaterThan(obtained, expected interface{}) (bool, string) {
- if _, ok := obtained.(time.Time); ok {
- return isAfter(obtained, expected)
- }
- if reflect.TypeOf(obtained) != reflect.TypeOf(expected) {
- return false, "obtained value and expected value have not the same type."
- }
- switch v := obtained.(type) {
- case float32:
- return v > expected.(float32), ""
- case float64:
- return v > expected.(float64), ""
- case int:
- return v > expected.(int), ""
- case int8:
- return v > expected.(int8), ""
- case int16:
- return v > expected.(int16), ""
- case int32:
- return v > expected.(int32), ""
- case int64:
- return v > expected.(int64), ""
- case uint:
- return v > expected.(uint), ""
- case uint8:
- return v > expected.(uint8), ""
- case uint16:
- return v > expected.(uint16), ""
- case uint32:
- return v > expected.(uint32), ""
- case uint64:
- return v > expected.(uint64), ""
- default:
- return false, "obtained value type not supported."
- }
-}
-
-// GreaterOrEqualThan checker verifies the obtained value is greater or equal than the specified one.
-// It's is smart in a wait that it supports several *types* (built-in, time.Time)
-//
-// c.Assert(myTime, GreaterOrEqualThan, aTime, check.Commentf("bouuuhh"))
-// c.Assert(myInt, GreaterOrEqualThan, 2, check.Commentf("bouuuhh"))
-//
-var GreaterOrEqualThan check.Checker = &greaterOrEqualThanChecker{
- &check.CheckerInfo{
- Name: "GreaterOrEqualThan",
- Params: []string{"obtained", "expected"},
- },
-}
-
-type greaterOrEqualThanChecker struct {
- *check.CheckerInfo
-}
-
-func (checker *greaterOrEqualThanChecker) Check(params []interface{}, names []string) (bool, string) {
- return greaterOrEqualThan(params[0], params[1])
-}
-
-func greaterOrEqualThan(obtained, expected interface{}) (bool, string) {
- if _, ok := obtained.(time.Time); ok {
- return isAfter(obtained, expected)
- }
- if reflect.TypeOf(obtained) != reflect.TypeOf(expected) {
- return false, "obtained value and expected value have not the same type."
- }
- switch v := obtained.(type) {
- case float32:
- return v >= expected.(float32), ""
- case float64:
- return v >= expected.(float64), ""
- case int:
- return v >= expected.(int), ""
- case int8:
- return v >= expected.(int8), ""
- case int16:
- return v >= expected.(int16), ""
- case int32:
- return v >= expected.(int32), ""
- case int64:
- return v >= expected.(int64), ""
- case uint:
- return v >= expected.(uint), ""
- case uint8:
- return v >= expected.(uint8), ""
- case uint16:
- return v >= expected.(uint16), ""
- case uint32:
- return v >= expected.(uint32), ""
- case uint64:
- return v >= expected.(uint64), ""
- default:
- return false, "obtained value type not supported."
- }
-}
-
-// LessThan checker verifies the obtained value is less than the specified one.
-// It's is smart in a wait that it supports several *types* (built-in, time.Time)
-//
-// c.Assert(myTime, LessThan, aTime, check.Commentf("bouuuhh"))
-// c.Assert(myInt, LessThan, 2, check.Commentf("bouuuhh"))
-//
-var LessThan check.Checker = &lessThanChecker{
- &check.CheckerInfo{
- Name: "LessThan",
- Params: []string{"obtained", "expected"},
- },
-}
-
-type lessThanChecker struct {
- *check.CheckerInfo
-}
-
-func (checker *lessThanChecker) Check(params []interface{}, names []string) (bool, string) {
- return lessThan(params[0], params[1])
-}
-
-func lessThan(obtained, expected interface{}) (bool, string) {
- if _, ok := obtained.(time.Time); ok {
- return isBefore(obtained, expected)
- }
- if reflect.TypeOf(obtained) != reflect.TypeOf(expected) {
- return false, "obtained value and expected value have not the same type."
- }
- switch v := obtained.(type) {
- case float32:
- return v < expected.(float32), ""
- case float64:
- return v < expected.(float64), ""
- case int:
- return v < expected.(int), ""
- case int8:
- return v < expected.(int8), ""
- case int16:
- return v < expected.(int16), ""
- case int32:
- return v < expected.(int32), ""
- case int64:
- return v < expected.(int64), ""
- case uint:
- return v < expected.(uint), ""
- case uint8:
- return v < expected.(uint8), ""
- case uint16:
- return v < expected.(uint16), ""
- case uint32:
- return v < expected.(uint32), ""
- case uint64:
- return v < expected.(uint64), ""
- default:
- return false, "obtained value type not supported."
- }
-}
-
-// LessOrEqualThan checker verifies the obtained value is less or equal than the specified one.
-// It's is smart in a wait that it supports several *types* (built-in, time.Time)
-//
-// c.Assert(myTime, LessThan, aTime, check.Commentf("bouuuhh"))
-// c.Assert(myInt, LessThan, 2, check.Commentf("bouuuhh"))
-//
-var LessOrEqualThan check.Checker = &lessOrEqualThanChecker{
- &check.CheckerInfo{
- Name: "LessOrEqualThan",
- Params: []string{"obtained", "expected"},
- },
-}
-
-type lessOrEqualThanChecker struct {
- *check.CheckerInfo
-}
-
-func (checker *lessOrEqualThanChecker) Check(params []interface{}, names []string) (bool, string) {
- return lessOrEqualThan(params[0], params[1])
-}
-
-func lessOrEqualThan(obtained, expected interface{}) (bool, string) {
- if _, ok := obtained.(time.Time); ok {
- return isBefore(obtained, expected)
- }
- if reflect.TypeOf(obtained) != reflect.TypeOf(expected) {
- return false, "obtained value and expected value have not the same type."
- }
- switch v := obtained.(type) {
- case float32:
- return v <= expected.(float32), ""
- case float64:
- return v <= expected.(float64), ""
- case int:
- return v <= expected.(int), ""
- case int8:
- return v <= expected.(int8), ""
- case int16:
- return v <= expected.(int16), ""
- case int32:
- return v <= expected.(int32), ""
- case int64:
- return v <= expected.(int64), ""
- case uint:
- return v <= expected.(uint), ""
- case uint8:
- return v <= expected.(uint8), ""
- case uint16:
- return v <= expected.(uint16), ""
- case uint32:
- return v <= expected.(uint32), ""
- case uint64:
- return v <= expected.(uint64), ""
- default:
- return false, "obtained value type not supported."
- }
-}
diff --git a/vendor/github.com/vdemeester/shakers/string.go b/vendor/github.com/vdemeester/shakers/string.go
deleted file mode 100644
index 75ecb10..0000000
--- a/vendor/github.com/vdemeester/shakers/string.go
+++ /dev/null
@@ -1,168 +0,0 @@
-// Package shakers provide some checker implementation the go-check.Checker interface.
-package shakers
-
-import (
- "fmt"
- "strings"
-
- "github.com/go-check/check"
-)
-
-// Contains checker verifies that obtained value contains a substring.
-var Contains check.Checker = &substringChecker{
- &check.CheckerInfo{
- Name: "Contains",
- Params: []string{"obtained", "substring"},
- },
- strings.Contains,
-}
-
-// ContainsAny checker verifies that any Unicode code points in chars
-// are in the obtained string.
-var ContainsAny check.Checker = &substringChecker{
- &check.CheckerInfo{
- Name: "ContainsAny",
- Params: []string{"obtained", "chars"},
- },
- strings.ContainsAny,
-}
-
-// HasPrefix checker verifies that obtained value has the specified substring as prefix
-var HasPrefix check.Checker = &substringChecker{
- &check.CheckerInfo{
- Name: "HasPrefix",
- Params: []string{"obtained", "prefix"},
- },
- strings.HasPrefix,
-}
-
-// HasSuffix checker verifies that obtained value has the specified substring as prefix
-var HasSuffix check.Checker = &substringChecker{
- &check.CheckerInfo{
- Name: "HasSuffix",
- Params: []string{"obtained", "suffix"},
- },
- strings.HasSuffix,
-}
-
-// EqualFold checker verifies that obtained value is, interpreted as UTF-8 strings, are equal under Unicode case-folding.
-var EqualFold check.Checker = &substringChecker{
- &check.CheckerInfo{
- Name: "EqualFold",
- Params: []string{"obtained", "expected"},
- },
- strings.EqualFold,
-}
-
-type substringChecker struct {
- *check.CheckerInfo
- substringFunction func(string, string) bool
-}
-
-func (checker *substringChecker) Check(params []interface{}, names []string) (bool, string) {
- obtained := params[0]
- substring := params[1]
- substringStr, ok := substring.(string)
- if !ok {
- return false, fmt.Sprintf("%s value must be a string.", names[1])
- }
- obtainedString, obtainedIsStr := obtained.(string)
- if !obtainedIsStr {
- if obtainedWithStringer, obtainedHasStringer := obtained.(fmt.Stringer); obtainedHasStringer {
- obtainedString, obtainedIsStr = obtainedWithStringer.String(), true
- }
- }
- if obtainedIsStr {
- return checker.substringFunction(obtainedString, substringStr), ""
- }
- return false, "obtained value is not a string and has no .String()."
-}
-
-// IndexAny checker verifies that the index of the first instance of any Unicode code point from chars in the obtained value is equal to expected
-var IndexAny check.Checker = &substringCountChecker{
- &check.CheckerInfo{
- Name: "IndexAny",
- Params: []string{"obtained", "chars", "expected"},
- },
- strings.IndexAny,
-}
-
-// Index checker verifies that the index of the first instance of sep in the obtained value is equal to expected
-var Index check.Checker = &substringCountChecker{
- &check.CheckerInfo{
- Name: "Index",
- Params: []string{"obtained", "sep", "expected"},
- },
- strings.Index,
-}
-
-// Count checker verifies that obtained value has the specified number of non-overlapping instances of sep
-var Count check.Checker = &substringCountChecker{
- &check.CheckerInfo{
- Name: "Count",
- Params: []string{"obtained", "sep", "expected"},
- },
- strings.Count,
-}
-
-type substringCountChecker struct {
- *check.CheckerInfo
- substringFunction func(string, string) int
-}
-
-func (checker *substringCountChecker) Check(params []interface{}, names []string) (bool, string) {
- obtained := params[0]
- substring := params[1]
- expected := params[2]
- substringStr, ok := substring.(string)
- if !ok {
- return false, fmt.Sprintf("%s value must be a string.", names[1])
- }
- obtainedString, obtainedIsStr := obtained.(string)
- if !obtainedIsStr {
- if obtainedWithStringer, obtainedHasStringer := obtained.(fmt.Stringer); obtainedHasStringer {
- obtainedString, obtainedIsStr = obtainedWithStringer.String(), true
- }
- }
- if obtainedIsStr {
- return checker.substringFunction(obtainedString, substringStr) == expected, ""
- }
- return false, "obtained value is not a string and has no .String()."
-}
-
-// IsLower checker verifies that the obtained value is in lower case
-var IsLower check.Checker = &stringTransformChecker{
- &check.CheckerInfo{
- Name: "IsLower",
- Params: []string{"obtained"},
- },
- strings.ToLower,
-}
-
-// IsUpper checker verifies that the obtained value is in lower case
-var IsUpper check.Checker = &stringTransformChecker{
- &check.CheckerInfo{
- Name: "IsUpper",
- Params: []string{"obtained"},
- },
- strings.ToUpper,
-}
-
-type stringTransformChecker struct {
- *check.CheckerInfo
- stringFunction func(string) string
-}
-
-func (checker *stringTransformChecker) Check(params []interface{}, names []string) (bool, string) {
- obtained := params[0]
- obtainedString, obtainedIsStr := obtained.(string)
- if !obtainedIsStr {
- if obtainedWithStringer, obtainedHasStringer := obtained.(fmt.Stringer); obtainedHasStringer {
- obtainedString, obtainedIsStr = obtainedWithStringer.String(), true
- }
- }
- if obtainedIsStr {
- return checker.stringFunction(obtainedString) == obtainedString, ""
- }
- return false, "obtained value is not a string and has no .String()."
-}
diff --git a/vendor/github.com/vdemeester/shakers/time.go b/vendor/github.com/vdemeester/shakers/time.go
deleted file mode 100644
index 0da8d00..0000000
--- a/vendor/github.com/vdemeester/shakers/time.go
+++ /dev/null
@@ -1,234 +0,0 @@
-package shakers
-
-import (
- "fmt"
- "time"
-
- "github.com/go-check/check"
-)
-
-// Default format when parsing (in addition to RFC and default time formats..)
-const shortForm = "2006-01-02"
-
-// IsBefore checker verifies the specified value is before the specified time.
-// It is exclusive.
-//
-// c.Assert(myTime, IsBefore, theTime, check.Commentf("bouuuhhh"))
-//
-var IsBefore check.Checker = &isBeforeChecker{
- &check.CheckerInfo{
- Name: "IsBefore",
- Params: []string{"obtained", "expected"},
- },
-}
-
-type isBeforeChecker struct {
- *check.CheckerInfo
-}
-
-func (checker *isBeforeChecker) Check(params []interface{}, names []string) (bool, string) {
- return isBefore(params[0], params[1])
-}
-
-func isBefore(value, t interface{}) (bool, string) {
- tTime, ok := parseTime(t)
- if !ok {
- return false, "expected must be a Time struct, or parseable."
- }
- valueTime, valueIsTime := parseTime(value)
- if valueIsTime {
- return valueTime.Before(tTime), ""
- }
- return false, "obtained value is not a time.Time struct or parseable as a time."
-}
-
-// IsAfter checker verifies the specified value is before the specified time.
-// It is exclusive.
-//
-// c.Assert(myTime, IsAfter, theTime, check.Commentf("bouuuhhh"))
-//
-var IsAfter check.Checker = &isAfterChecker{
- &check.CheckerInfo{
- Name: "IsAfter",
- Params: []string{"obtained", "expected"},
- },
-}
-
-type isAfterChecker struct {
- *check.CheckerInfo
-}
-
-func (checker *isAfterChecker) Check(params []interface{}, names []string) (bool, string) {
- return isAfter(params[0], params[1])
-}
-
-func isAfter(value, t interface{}) (bool, string) {
- tTime, ok := parseTime(t)
- if !ok {
- return false, "expected must be a Time struct, or parseable."
- }
- valueTime, valueIsTime := parseTime(value)
- if valueIsTime {
- return valueTime.After(tTime), ""
- }
- return false, "obtained value is not a time.Time struct or parseable as a time."
-}
-
-// IsBetween checker verifies the specified time is between the specified start
-// and end. It's exclusive so if the specified time is at the tip of the interval.
-//
-// c.Assert(myTime, IsBetween, startTime, endTime, check.Commentf("bouuuhhh"))
-//
-var IsBetween check.Checker = &isBetweenChecker{
- &check.CheckerInfo{
- Name: "IsBetween",
- Params: []string{"obtained", "start", "end"},
- },
-}
-
-type isBetweenChecker struct {
- *check.CheckerInfo
-}
-
-func (checker *isBetweenChecker) Check(params []interface{}, names []string) (bool, string) {
- return isBetween(params[0], params[1], params[2])
-}
-
-func isBetween(value, start, end interface{}) (bool, string) {
- startTime, ok := parseTime(start)
- if !ok {
- return false, "start must be a Time struct, or parseable."
- }
- endTime, ok := parseTime(end)
- if !ok {
- return false, "end must be a Time struct, or parseable."
- }
- valueTime, valueIsTime := parseTime(value)
- if valueIsTime {
- return valueTime.After(startTime) && valueTime.Before(endTime), ""
- }
- return false, "obtained value is not a time.Time struct or parseable as a time."
-}
-
-// TimeEquals checker verifies the specified time is the equal to the expected
-// time.
-//
-// c.Assert(myTime, TimeEquals, expected, check.Commentf("bouhhh"))
-//
-// It's possible to ignore some part of the time (like hours, minutes, etc..) using
-// the TimeIgnore checker with it.
-//
-// c.Assert(myTime, TimeIgnore(TimeEquals, time.Hour), expected, check.Commentf("... bouh.."))
-//
-var TimeEquals check.Checker = &timeEqualsChecker{
- &check.CheckerInfo{
- Name: "TimeEquals",
- Params: []string{"obtained", "expected"},
- },
-}
-
-type timeEqualsChecker struct {
- *check.CheckerInfo
-}
-
-func (checker *timeEqualsChecker) Check(params []interface{}, names []string) (bool, string) {
- return timeEquals(params[0], params[1])
-}
-
-func timeEquals(obtained, expected interface{}) (bool, string) {
- expectedTime, ok := parseTime(expected)
- if !ok {
- return false, "expected must be a Time struct, or parseable."
- }
- valueTime, valueIsTime := parseTime(obtained)
- if valueIsTime {
- return valueTime.Equal(expectedTime), ""
- }
- return false, "obtained value is not a time.Time struct or parseable as a time."
-}
-
-// TimeIgnore checker will ignore some part of the time on the encapsulated checker.
-//
-// c.Assert(myTime, TimeIgnore(IsBetween, time.Second), start, end)
-//
-// FIXME use interface{} for ignore (to enable "Month", ..
-func TimeIgnore(checker check.Checker, ignore time.Duration) check.Checker {
- return &timeIgnoreChecker{
- sub: checker,
- ignore: ignore,
- }
-}
-
-type timeIgnoreChecker struct {
- sub check.Checker
- ignore time.Duration
-}
-
-func (checker *timeIgnoreChecker) Info() *check.CheckerInfo {
- info := *checker.sub.Info()
- info.Name = fmt.Sprintf("TimeIgnore(%s, %v)", info.Name, checker.ignore)
- return &info
-}
-
-func (checker *timeIgnoreChecker) Check(params []interface{}, names []string) (bool, string) {
- // Naive implementation : all params are supposed to be date
- mParams := make([]interface{}, len(params))
- for index, param := range params {
- paramTime, ok := parseTime(param)
- if !ok {
- return false, fmt.Sprintf("%s must be a Time struct, or parseable.", names[index])
- }
- year := paramTime.Year()
- month := paramTime.Month()
- day := paramTime.Day()
- hour := paramTime.Hour()
- min := paramTime.Minute()
- sec := paramTime.Second()
- nsec := paramTime.Nanosecond()
- location := paramTime.Location()
- switch checker.ignore {
- case time.Hour:
- hour = 0
- fallthrough
- case time.Minute:
- min = 0
- fallthrough
- case time.Second:
- sec = 0
- fallthrough
- case time.Millisecond:
- fallthrough
- case time.Microsecond:
- fallthrough
- case time.Nanosecond:
- nsec = 0
- }
- mParams[index] = time.Date(year, month, day, hour, min, sec, nsec, location)
- }
- return checker.sub.Check(mParams, names)
-}
-
-func parseTime(datetime interface{}) (time.Time, bool) {
- switch datetime.(type) {
- case time.Time:
- return datetime.(time.Time), true
- case string:
- return parseTimeAsString(datetime.(string))
- default:
- if datetimeWithStr, ok := datetime.(fmt.Stringer); ok {
- return parseTimeAsString(datetimeWithStr.String())
- }
- return time.Time{}, false
- }
-}
-
-func parseTimeAsString(timeAsStr string) (time.Time, bool) {
- forms := []string{shortForm, time.RFC3339, time.RFC3339Nano, time.RFC822, time.RFC822Z}
- for _, form := range forms {
- datetime, err := time.Parse(form, timeAsStr)
- if err == nil {
- return datetime, true
- }
- }
- return time.Time{}, false
-}