TestDaemonProxy: check proxy settings early
Allows tests to report their proxy settings for easier troubleshooting
on failures.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit 8197752d68
)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
b97c8a0325
commit
2434546510
1 changed files with 18 additions and 18 deletions
|
@ -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)
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue