2020-05-21 17:32:32 +00:00
|
|
|
package network // import "github.com/docker/docker/integration/network"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2023-08-25 18:25:58 +00:00
|
|
|
containertypes "github.com/docker/docker/api/types/container"
|
2020-05-21 17:32:32 +00:00
|
|
|
"github.com/docker/docker/integration/internal/container"
|
|
|
|
"github.com/docker/docker/integration/internal/network"
|
2023-07-14 18:02:38 +00:00
|
|
|
"github.com/docker/docker/testutil"
|
2020-05-21 17:32:32 +00:00
|
|
|
"github.com/docker/docker/testutil/daemon"
|
|
|
|
"gotest.tools/v3/poll"
|
|
|
|
"gotest.tools/v3/skip"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestDaemonDNSFallback(t *testing.T) {
|
|
|
|
skip.If(t, testEnv.IsRemoteDaemon, "cannot start daemon on remote test run")
|
|
|
|
skip.If(t, testEnv.DaemonInfo.OSType != "linux")
|
2021-08-12 07:12:04 +00:00
|
|
|
skip.If(t, testEnv.IsUserNamespace)
|
2023-07-14 18:02:38 +00:00
|
|
|
ctx := testutil.StartSpan(baseContext, t)
|
2020-05-21 17:32:32 +00:00
|
|
|
|
|
|
|
d := daemon.New(t)
|
2023-07-14 18:02:38 +00:00
|
|
|
d.StartWithBusybox(ctx, t, "-b", "none", "--dns", "127.127.127.1", "--dns", "8.8.8.8")
|
2020-05-21 17:32:32 +00:00
|
|
|
defer d.Stop(t)
|
|
|
|
|
|
|
|
c := d.NewClientT(t)
|
|
|
|
|
|
|
|
network.CreateNoError(ctx, t, c, "test")
|
|
|
|
defer c.NetworkRemove(ctx, "test")
|
|
|
|
|
|
|
|
cid := container.Run(ctx, t, c, container.WithNetworkMode("test"), container.WithCmd("nslookup", "docker.com"))
|
2023-08-25 18:25:58 +00:00
|
|
|
defer c.ContainerRemove(ctx, cid, containertypes.RemoveOptions{Force: true})
|
2020-05-21 17:32:32 +00:00
|
|
|
|
2020-06-30 03:06:03 +00:00
|
|
|
poll.WaitOn(t, container.IsSuccessful(ctx, c, cid), poll.WithDelay(100*time.Millisecond), poll.WithTimeout(10*time.Second))
|
2020-05-21 17:32:32 +00:00
|
|
|
}
|