Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -138,9 +138,7 @@ func NewDaemon(workingDir string, ops ...Option) (*Daemon, error) {
|
| 138 | 138 |
// $DOCKER_INTEGRATION_DAEMON_DEST or $DEST. |
| 139 | 139 |
// The daemon will not automatically start. |
| 140 | 140 |
func New(t testing.TB, ops ...Option) *Daemon {
|
| 141 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 142 |
- ht.Helper() |
|
| 143 |
- } |
|
| 141 |
+ t.Helper() |
|
| 144 | 142 |
dest := os.Getenv("DOCKER_INTEGRATION_DAEMON_DEST")
|
| 145 | 143 |
if dest == "" {
|
| 146 | 144 |
dest = os.Getenv("DEST")
|
| ... | ... |
@@ -219,9 +217,7 @@ func (d *Daemon) NewClient(extraOpts ...client.Opt) (*client.Client, error) {
|
| 219 | 219 |
|
| 220 | 220 |
// Cleanup cleans the daemon files : exec root (network namespaces, ...), swarmkit files |
| 221 | 221 |
func (d *Daemon) Cleanup(t testing.TB) {
|
| 222 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 223 |
- ht.Helper() |
|
| 224 |
- } |
|
| 222 |
+ t.Helper() |
|
| 225 | 223 |
// Cleanup swarmkit wal files if present |
| 226 | 224 |
cleanupRaftDir(t, d.Root) |
| 227 | 225 |
cleanupNetworkNamespace(t, d.execRoot) |
| ... | ... |
@@ -229,9 +225,7 @@ func (d *Daemon) Cleanup(t testing.TB) {
|
| 229 | 229 |
|
| 230 | 230 |
// Start starts the daemon and return once it is ready to receive requests. |
| 231 | 231 |
func (d *Daemon) Start(t testing.TB, args ...string) {
|
| 232 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 233 |
- ht.Helper() |
|
| 234 |
- } |
|
| 232 |
+ t.Helper() |
|
| 235 | 233 |
if err := d.StartWithError(args...); err != nil {
|
| 236 | 234 |
t.Fatalf("failed to start daemon with arguments %v : %v", args, err)
|
| 237 | 235 |
} |
| ... | ... |
@@ -385,9 +379,7 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
|
| 385 | 385 |
// StartWithBusybox will first start the daemon with Daemon.Start() |
| 386 | 386 |
// then save the busybox image from the main daemon and load it into this Daemon instance. |
| 387 | 387 |
func (d *Daemon) StartWithBusybox(t testing.TB, arg ...string) {
|
| 388 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 389 |
- ht.Helper() |
|
| 390 |
- } |
|
| 388 |
+ t.Helper() |
|
| 391 | 389 |
d.Start(t, arg...) |
| 392 | 390 |
d.LoadBusybox(t) |
| 393 | 391 |
} |
| ... | ... |
@@ -444,9 +436,7 @@ func (d *Daemon) DumpStackAndQuit() {
|
| 444 | 444 |
// instantiate a new one with NewDaemon. |
| 445 | 445 |
// If an error occurs while starting the daemon, the test will fail. |
| 446 | 446 |
func (d *Daemon) Stop(t testing.TB) {
|
| 447 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 448 |
- ht.Helper() |
|
| 449 |
- } |
|
| 447 |
+ t.Helper() |
|
| 450 | 448 |
err := d.StopWithError() |
| 451 | 449 |
if err != nil {
|
| 452 | 450 |
if err != errDaemonNotStarted {
|
| ... | ... |
@@ -532,9 +522,7 @@ out2: |
| 532 | 532 |
// Restart will restart the daemon by first stopping it and the starting it. |
| 533 | 533 |
// If an error occurs while starting the daemon, the test will fail. |
| 534 | 534 |
func (d *Daemon) Restart(t testing.TB, args ...string) {
|
| 535 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 536 |
- ht.Helper() |
|
| 537 |
- } |
|
| 535 |
+ t.Helper() |
|
| 538 | 536 |
d.Stop(t) |
| 539 | 537 |
d.Start(t, args...) |
| 540 | 538 |
} |
| ... | ... |
@@ -732,9 +720,7 @@ func (d *Daemon) Info(t assert.TestingT) types.Info {
|
| 732 | 732 |
} |
| 733 | 733 |
|
| 734 | 734 |
func cleanupRaftDir(t testing.TB, rootPath string) {
|
| 735 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 736 |
- ht.Helper() |
|
| 737 |
- } |
|
| 735 |
+ t.Helper() |
|
| 738 | 736 |
for _, p := range []string{"wal", "wal-v3-encrypted", "snap-v3-encrypted"} {
|
| 739 | 737 |
dir := filepath.Join(rootPath, "swarm/raft", p) |
| 740 | 738 |
if err := os.RemoveAll(dir); err != nil {
|
| ... | ... |
@@ -9,15 +9,12 @@ import ( |
| 9 | 9 |
"strings" |
| 10 | 10 |
"testing" |
| 11 | 11 |
|
| 12 |
- "github.com/docker/docker/testutil" |
|
| 13 | 12 |
"golang.org/x/sys/unix" |
| 14 | 13 |
"gotest.tools/assert" |
| 15 | 14 |
) |
| 16 | 15 |
|
| 17 | 16 |
func cleanupNetworkNamespace(t testing.TB, execRoot string) {
|
| 18 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 19 |
- ht.Helper() |
|
| 20 |
- } |
|
| 17 |
+ t.Helper() |
|
| 21 | 18 |
// Cleanup network namespaces in the exec root of this |
| 22 | 19 |
// daemon because this exec root is specific to this |
| 23 | 20 |
// daemon instance and has no chance of getting |
| ... | ... |
@@ -23,25 +23,19 @@ var ( |
| 23 | 23 |
|
| 24 | 24 |
// StartNode (re)starts the daemon |
| 25 | 25 |
func (d *Daemon) StartNode(t testing.TB) {
|
| 26 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 27 |
- ht.Helper() |
|
| 28 |
- } |
|
| 26 |
+ t.Helper() |
|
| 29 | 27 |
d.Start(t, startArgs...) |
| 30 | 28 |
} |
| 31 | 29 |
|
| 32 | 30 |
// StartNodeWithBusybox starts daemon to be used as a swarm node, and loads the busybox image |
| 33 | 31 |
func (d *Daemon) StartNodeWithBusybox(t testing.TB) {
|
| 34 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 35 |
- ht.Helper() |
|
| 36 |
- } |
|
| 32 |
+ t.Helper() |
|
| 37 | 33 |
d.StartWithBusybox(t, startArgs...) |
| 38 | 34 |
} |
| 39 | 35 |
|
| 40 | 36 |
// RestartNode restarts a daemon to be used as a swarm node |
| 41 | 37 |
func (d *Daemon) RestartNode(t testing.TB) {
|
| 42 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 43 |
- ht.Helper() |
|
| 44 |
- } |
|
| 38 |
+ t.Helper() |
|
| 45 | 39 |
// avoid networking conflicts |
| 46 | 40 |
d.Stop(t) |
| 47 | 41 |
d.Start(t, startArgs...) |
| ... | ... |
@@ -55,9 +49,7 @@ func (d *Daemon) StartAndSwarmInit(t testing.TB) {
|
| 55 | 55 |
|
| 56 | 56 |
// StartAndSwarmJoin starts the daemon (with busybox) and join the specified swarm as worker or manager |
| 57 | 57 |
func (d *Daemon) StartAndSwarmJoin(t testing.TB, leader *Daemon, manager bool) {
|
| 58 |
- if th, ok := t.(testutil.HelperT); ok {
|
|
| 59 |
- th.Helper() |
|
| 60 |
- } |
|
| 58 |
+ t.Helper() |
|
| 61 | 59 |
d.StartNodeWithBusybox(t) |
| 62 | 60 |
|
| 63 | 61 |
tokens := leader.JoinTokens(t) |
| ... | ... |
@@ -9,14 +9,11 @@ import ( |
| 9 | 9 |
"testing" |
| 10 | 10 |
|
| 11 | 11 |
"github.com/docker/docker/pkg/archive" |
| 12 |
- "github.com/docker/docker/testutil" |
|
| 13 | 12 |
) |
| 14 | 13 |
|
| 15 | 14 |
// New creates a fake build context |
| 16 | 15 |
func New(t testing.TB, dir string, modifiers ...func(*Fake) error) *Fake {
|
| 17 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 18 |
- ht.Helper() |
|
| 19 |
- } |
|
| 16 |
+ t.Helper() |
|
| 20 | 17 |
fakeContext := &Fake{Dir: dir}
|
| 21 | 18 |
if dir == "" {
|
| 22 | 19 |
if err := newDir(fakeContext); err != nil {
|
| ... | ... |
@@ -116,9 +113,7 @@ func (f *Fake) Close() error {
|
| 116 | 116 |
|
| 117 | 117 |
// AsTarReader returns a ReadCloser with the contents of Dir as a tar archive. |
| 118 | 118 |
func (f *Fake) AsTarReader(t testing.TB) io.ReadCloser {
|
| 119 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 120 |
- ht.Helper() |
|
| 121 |
- } |
|
| 119 |
+ t.Helper() |
|
| 122 | 120 |
reader, err := archive.TarWithOptions(f.Dir, &archive.TarOptions{})
|
| 123 | 121 |
if err != nil {
|
| 124 | 122 |
t.Fatalf("Failed to create tar from %s: %s", f.Dir, err)
|
| ... | ... |
@@ -10,7 +10,6 @@ import ( |
| 10 | 10 |
"path/filepath" |
| 11 | 11 |
"testing" |
| 12 | 12 |
|
| 13 |
- "github.com/docker/docker/testutil" |
|
| 14 | 13 |
"github.com/docker/docker/testutil/fakecontext" |
| 15 | 14 |
"github.com/docker/docker/testutil/fakestorage" |
| 16 | 15 |
) |
| ... | ... |
@@ -48,9 +47,7 @@ func (g *FakeGit) Close() {
|
| 48 | 48 |
|
| 49 | 49 |
// New create a fake git server that can be used for git related tests |
| 50 | 50 |
func New(c testing.TB, name string, files map[string]string, enforceLocalServer bool) *FakeGit {
|
| 51 |
- if ht, ok := c.(testutil.HelperT); ok {
|
|
| 52 |
- ht.Helper() |
|
| 53 |
- } |
|
| 51 |
+ c.Helper() |
|
| 54 | 52 |
ctx := fakecontext.New(c, "", fakecontext.WithFiles(files)) |
| 55 | 53 |
defer ctx.Close() |
| 56 | 54 |
curdir, err := os.Getwd() |
| ... | ... |
@@ -12,16 +12,13 @@ import ( |
| 12 | 12 |
|
| 13 | 13 |
"github.com/docker/docker/api/types" |
| 14 | 14 |
"github.com/docker/docker/pkg/archive" |
| 15 |
- "github.com/docker/docker/testutil" |
|
| 16 | 15 |
"gotest.tools/assert" |
| 17 | 16 |
) |
| 18 | 17 |
|
| 19 | 18 |
var ensureHTTPServerOnce sync.Once |
| 20 | 19 |
|
| 21 | 20 |
func ensureHTTPServerImage(t testing.TB) {
|
| 22 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 23 |
- ht.Helper() |
|
| 24 |
- } |
|
| 21 |
+ t.Helper() |
|
| 25 | 22 |
var doIt bool |
| 26 | 23 |
ensureHTTPServerOnce.Do(func() {
|
| 27 | 24 |
doIt = true |
| ... | ... |
@@ -41,9 +41,7 @@ func SetTestEnvironment(env *environment.Execution) {
|
| 41 | 41 |
|
| 42 | 42 |
// New returns a static file server that will be use as build context. |
| 43 | 43 |
func New(t testing.TB, dir string, modifiers ...func(*fakecontext.Fake) error) Fake {
|
| 44 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 45 |
- ht.Helper() |
|
| 46 |
- } |
|
| 44 |
+ t.Helper() |
|
| 47 | 45 |
if testEnv == nil {
|
| 48 | 46 |
t.Fatal("fakstorage package requires SetTestEnvironment() to be called before use.")
|
| 49 | 47 |
} |
| ... | ... |
@@ -45,9 +45,7 @@ type Config struct {
|
| 45 | 45 |
|
| 46 | 46 |
// NewV2 creates a v2 registry server |
| 47 | 47 |
func NewV2(t testing.TB, ops ...func(*Config)) *V2 {
|
| 48 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 49 |
- ht.Helper() |
|
| 50 |
- } |
|
| 48 |
+ t.Helper() |
|
| 51 | 49 |
c := &Config{
|
| 52 | 50 |
registryURL: DefaultURL, |
| 53 | 51 |
} |
| ... | ... |
@@ -130,9 +128,7 @@ http: |
| 130 | 130 |
|
| 131 | 131 |
// WaitReady waits for the registry to be ready to serve requests (or fail after a while) |
| 132 | 132 |
func (r *V2) WaitReady(t testing.TB) {
|
| 133 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 134 |
- ht.Helper() |
|
| 135 |
- } |
|
| 133 |
+ t.Helper() |
|
| 136 | 134 |
var err error |
| 137 | 135 |
for i := 0; i != 50; i++ {
|
| 138 | 136 |
if err = r.Ping(); err == nil {
|
| ... | ... |
@@ -202,9 +198,7 @@ func (r *V2) WriteBlobContents(t assert.TestingT, blobDigest digest.Digest, data |
| 202 | 202 |
// TempMoveBlobData moves the existing data file aside, so that we can replace it with a |
| 203 | 203 |
// malicious blob of data for example. |
| 204 | 204 |
func (r *V2) TempMoveBlobData(t testing.TB, blobDigest digest.Digest) (undo func()) {
|
| 205 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 206 |
- ht.Helper() |
|
| 207 |
- } |
|
| 205 |
+ t.Helper() |
|
| 208 | 206 |
tempFile, err := ioutil.TempFile("", "registry-temp-blob-")
|
| 209 | 207 |
assert.NilError(t, err, "unable to get temporary blob file") |
| 210 | 208 |
tempFile.Close() |
| ... | ... |
@@ -7,8 +7,6 @@ import ( |
| 7 | 7 |
"strings" |
| 8 | 8 |
"sync" |
| 9 | 9 |
"testing" |
| 10 |
- |
|
| 11 |
- "github.com/docker/docker/testutil" |
|
| 12 | 10 |
) |
| 13 | 11 |
|
| 14 | 12 |
type handlerFunc func(w http.ResponseWriter, r *http.Request) |
| ... | ... |
@@ -30,9 +28,7 @@ func (tr *Mock) RegisterHandler(path string, h handlerFunc) {
|
| 30 | 30 |
|
| 31 | 31 |
// NewMock creates a registry mock |
| 32 | 32 |
func NewMock(t testing.TB) (*Mock, error) {
|
| 33 |
- if ht, ok := t.(testutil.HelperT); ok {
|
|
| 34 |
- ht.Helper() |
|
| 35 |
- } |
|
| 33 |
+ t.Helper() |
|
| 36 | 34 |
testReg := &Mock{handlers: make(map[string]handlerFunc)}
|
| 37 | 35 |
|
| 38 | 36 |
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|