diff --git a/integration/daemon/daemon_test.go b/integration/daemon/daemon_test.go index 863b90e53e..98aa91e284 100644 --- a/integration/daemon/daemon_test.go +++ b/integration/daemon/daemon_test.go @@ -206,6 +206,12 @@ func TestDaemonProxy(t *testing.T) { defer func() { _ = c.Close() }() ctx := context.Background() d.Start(t) + defer d.Stop(t) + + info := d.Info(t) + assert.Check(t, is.Equal(info.HTTPProxy, proxyServer.URL)) + assert.Check(t, is.Equal(info.HTTPSProxy, proxyServer.URL)) + assert.Check(t, is.Equal(info.NoProxy, "example.com")) _, err := c.ImagePull(ctx, "example.org:5000/some/image:latest", types.ImagePullOptions{}) assert.ErrorContains(t, err, "", "pulling should have failed") @@ -215,12 +221,6 @@ func TestDaemonProxy(t *testing.T) { _, err = c.ImagePull(ctx, "example.com/some/image:latest", types.ImagePullOptions{}) assert.ErrorContains(t, err, "", "pulling should have failed") assert.Equal(t, received, "example.org:5000", "should not have used proxy") - - info := d.Info(t) - assert.Equal(t, info.HTTPProxy, proxyServer.URL) - assert.Equal(t, info.HTTPSProxy, proxyServer.URL) - assert.Equal(t, info.NoProxy, "example.com") - d.Stop(t) }) // Configure proxy through command-line flags @@ -234,6 +234,7 @@ func TestDaemonProxy(t *testing.T) { d := daemon.New(t) d.Start(t, "--http-proxy", proxyServer.URL, "--https-proxy", proxyServer.URL, "--no-proxy", "example.com") + defer d.Stop(t) logs, err := d.ReadLogFile() assert.NilError(t, err) @@ -247,6 +248,11 @@ func TestDaemonProxy(t *testing.T) { defer func() { _ = c.Close() }() ctx := context.Background() + info := d.Info(t) + assert.Check(t, is.Equal(info.HTTPProxy, proxyServer.URL)) + assert.Check(t, is.Equal(info.HTTPSProxy, proxyServer.URL)) + assert.Check(t, is.Equal(info.NoProxy, "example.com")) + _, err = c.ImagePull(ctx, "example.org:5001/some/image:latest", types.ImagePullOptions{}) assert.ErrorContains(t, err, "", "pulling should have failed") assert.Equal(t, received, "example.org:5001") @@ -255,13 +261,6 @@ func TestDaemonProxy(t *testing.T) { _, err = c.ImagePull(ctx, "example.com/some/image:latest", types.ImagePullOptions{}) assert.ErrorContains(t, err, "", "pulling should have failed") assert.Equal(t, received, "example.org:5001", "should not have used proxy") - - info := d.Info(t) - assert.Equal(t, info.HTTPProxy, proxyServer.URL) - assert.Equal(t, info.HTTPSProxy, proxyServer.URL) - assert.Equal(t, info.NoProxy, "example.com") - - d.Stop(t) }) // Configure proxy through configuration file @@ -283,6 +282,12 @@ func TestDaemonProxy(t *testing.T) { assert.NilError(t, os.WriteFile(configFile, []byte(configJSON), 0644)) d.Start(t, "--config-file", configFile) + defer d.Stop(t) + + info := d.Info(t) + assert.Check(t, is.Equal(info.HTTPProxy, proxyServer.URL)) + assert.Check(t, is.Equal(info.HTTPSProxy, proxyServer.URL)) + assert.Check(t, is.Equal(info.NoProxy, "example.com")) logs, err := d.ReadLogFile() assert.NilError(t, err) @@ -301,11 +306,6 @@ func TestDaemonProxy(t *testing.T) { assert.ErrorContains(t, err, "", "pulling should have failed") assert.Equal(t, received, "example.org:5002", "should not have used proxy") - info := d.Info(t) - assert.Equal(t, info.HTTPProxy, proxyServer.URL) - assert.Equal(t, info.HTTPSProxy, proxyServer.URL) - assert.Equal(t, info.NoProxy, "example.com") - d.Stop(t) })