mirror of
https://github.com/moby/moby.git
synced 2026-08-04 23:21:00 +00:00
Move integration/network/bridge_test.go to bridge subdir
Also make it Linux-only, as the bridge driver is Linux only and all of the tests had skips for Windows. Signed-off-by: Rob Murray <rob.murray@docker.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package network
|
||||
package bridge
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -19,7 +19,6 @@ import (
|
||||
)
|
||||
|
||||
func TestCreateWithMultiNetworks(t *testing.T) {
|
||||
skip.If(t, testEnv.DaemonInfo.OSType == "windows")
|
||||
skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.44"), "requires API v1.44")
|
||||
|
||||
ctx := setupTest(t)
|
||||
@@ -49,9 +48,6 @@ func TestCreateWithMultiNetworks(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateWithIPv6DefaultsToULAPrefix(t *testing.T) {
|
||||
// On Windows, network creation fails with this error message: Error response from daemon: this request is not supported by the 'windows' ipam driver
|
||||
skip.If(t, testEnv.DaemonInfo.OSType == "windows")
|
||||
|
||||
ctx := setupTest(t)
|
||||
apiClient := testEnv.APIClient()
|
||||
|
||||
@@ -73,7 +69,6 @@ func TestCreateWithIPv6DefaultsToULAPrefix(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateWithIPv6WithoutEnableIPv6Flag(t *testing.T) {
|
||||
skip.If(t, testEnv.DaemonInfo.OSType == "windows") // d.Start fails on Windows with `protocol not available`
|
||||
ctx := setupTest(t)
|
||||
|
||||
d := daemon.New(t)
|
||||
@@ -103,7 +98,6 @@ func TestCreateWithIPv6WithoutEnableIPv6Flag(t *testing.T) {
|
||||
// Check that it's possible to create IPv6 networks with a 64-bit ip-range,
|
||||
// in 64-bit and bigger subnets, with and without a gateway.
|
||||
func Test64BitIPRange(t *testing.T) {
|
||||
skip.If(t, testEnv.DaemonInfo.OSType == "windows", "no bridge or IPv6 on Windows")
|
||||
ctx := setupTest(t)
|
||||
c := testEnv.APIClient()
|
||||
|
||||
@@ -139,7 +133,6 @@ func Test64BitIPRange(t *testing.T) {
|
||||
// Demonstrate a limitation of the IP address allocator, it can't
|
||||
// allocate the last address in range that ends on a 64-bit boundary.
|
||||
func TestIPRangeAt64BitLimit(t *testing.T) {
|
||||
skip.If(t, testEnv.DaemonInfo.OSType == "windows", "no bridge or IPv6 on Windows")
|
||||
ctx := setupTest(t)
|
||||
c := testEnv.APIClient()
|
||||
|
||||
56
integration/network/bridge/main_test.go
Normal file
56
integration/network/bridge/main_test.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package bridge // import "github.com/docker/docker/integration/network/bridge"
|
||||
|
||||
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/bridge.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
|
||||
}
|
||||
Reference in New Issue
Block a user