-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request moby#48278 from robmry/v6only/not_windows_or_swarm
IPv6 only: IPv4 is required for Windows and Swarm networks
- Loading branch information
Showing
5 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package nat // import "github.com/docker/docker/integration/network/nat" | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"testing" | ||
|
||
"github.com/docker/docker/testutil" | ||
"github.com/docker/docker/testutil/environment" | ||
"go.opentelemetry.io/otel" | ||
"go.opentelemetry.io/otel/codes" | ||
) | ||
|
||
var ( | ||
testEnv *environment.Execution | ||
baseContext context.Context | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
shutdown := testutil.ConfigureTracing() | ||
ctx, span := otel.Tracer("").Start(context.Background(), "integration/network/nat.TestMain") | ||
baseContext = ctx | ||
|
||
var err error | ||
testEnv, err = environment.New(ctx) | ||
if err != nil { | ||
span.SetStatus(codes.Error, err.Error()) | ||
span.End() | ||
shutdown(ctx) | ||
panic(err) | ||
} | ||
|
||
err = environment.EnsureFrozenImagesLinux(ctx, testEnv) | ||
if err != nil { | ||
span.SetStatus(codes.Error, err.Error()) | ||
span.End() | ||
shutdown(ctx) | ||
panic(err) | ||
} | ||
|
||
testEnv.Print() | ||
code := m.Run() | ||
if code != 0 { | ||
span.SetStatus(codes.Error, "m.Run() returned non-zero exit code") | ||
} | ||
span.End() | ||
shutdown(ctx) | ||
os.Exit(code) | ||
} | ||
|
||
func setupTest(t *testing.T) context.Context { | ||
ctx := testutil.StartSpan(baseContext, t) | ||
environment.ProtectAll(ctx, t, testEnv) | ||
t.Cleanup(func() { testEnv.Clean(ctx, t) }) | ||
return ctx | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package nat // import "github.com/docker/docker/integration/network/nat" | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/docker/docker/integration/internal/network" | ||
"gotest.tools/v3/assert" | ||
is "gotest.tools/v3/assert/cmp" | ||
) | ||
|
||
func TestWindowsNoDisableIPv4(t *testing.T) { | ||
ctx := setupTest(t) | ||
c := testEnv.APIClient() | ||
|
||
_, err := network.Create(ctx, c, "ipv6only", | ||
network.WithDriver("nat"), | ||
network.WithIPv4(false), | ||
) | ||
// This error message should change to "IPv4 cannot be disabled on Windows" | ||
// when "--experimental" is no longer required to disable IPv4. But, there's | ||
// no way to start a second daemon with "--experimental" in Windows CI. | ||
assert.Check(t, is.ErrorContains(err, | ||
"IPv4 can only be disabled if experimental features are enabled")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters