From 5e46d8057dcaaa956ba0f0d7e232b23d9fa62ac9 Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Fri, 4 Aug 2023 11:25:57 +0100 Subject: [PATCH] tests: add unsupported features detection skeleton Signed-off-by: Justin Chadwell --- tests/workers/backend.go | 4 ++-- tests/workers/docker-container.go | 7 +++++-- tests/workers/docker.go | 9 ++++++--- tests/workers/features.go | 13 +++++++++++++ tests/workers/remote.go | 9 ++++++--- 5 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 tests/workers/features.go diff --git a/tests/workers/backend.go b/tests/workers/backend.go index c3e3b59b..87eb5808 100644 --- a/tests/workers/backend.go +++ b/tests/workers/backend.go @@ -35,7 +35,7 @@ func (s *backend) Rootless() bool { return false } -func (b backend) Supports(feature string) bool { +func (s backend) Supports(feature string) bool { if enabledFeatures := os.Getenv("BUILDKIT_TEST_ENABLE_FEATURES"); enabledFeatures != "" { for _, enabledFeature := range strings.Split(enabledFeatures, ",") { if feature == enabledFeature { @@ -50,7 +50,7 @@ func (b backend) Supports(feature string) bool { } } } - for _, unsupportedFeature := range b.unsupportedFeatures { + for _, unsupportedFeature := range s.unsupportedFeatures { if feature == unsupportedFeature { return false } diff --git a/tests/workers/docker-container.go b/tests/workers/docker-container.go index de6a78bd..5035c7dc 100644 --- a/tests/workers/docker-container.go +++ b/tests/workers/docker-container.go @@ -20,6 +20,8 @@ func InitDockerContainerWorker() { type containerWorker struct { id string + unsupported []string + docker integration.Backend dockerClose func() error dockerErr error @@ -65,8 +67,9 @@ func (w *containerWorker) New(ctx context.Context, cfg *integration.BackendConfi } return &backend{ - context: w.docker.DockerAddress(), - builder: name, + context: w.docker.DockerAddress(), + builder: name, + unsupportedFeatures: w.unsupported, }, cl, nil } diff --git a/tests/workers/docker.go b/tests/workers/docker.go index 347ca87d..a48fcbab 100644 --- a/tests/workers/docker.go +++ b/tests/workers/docker.go @@ -7,6 +7,7 @@ import ( "github.com/moby/buildkit/identity" "github.com/moby/buildkit/util/testutil/integration" + bkworkers "github.com/moby/buildkit/util/testutil/workers" "github.com/pkg/errors" ) @@ -23,6 +24,7 @@ func InitDockerWorker() { type dockerWorker struct { id string containerdSnapshotter bool + unsupported []string } func (c dockerWorker) Name() string { @@ -34,7 +36,7 @@ func (c dockerWorker) Rootless() bool { } func (c dockerWorker) New(ctx context.Context, cfg *integration.BackendConfig) (b integration.Backend, cl func() error, err error) { - moby := integration.Moby{ + moby := bkworkers.Moby{ ID: c.id, ContainerdSnapshotter: c.containerdSnapshotter, } @@ -66,8 +68,9 @@ func (c dockerWorker) New(ctx context.Context, cfg *integration.BackendConfig) ( } return &backend{ - builder: name, - context: name, + builder: name, + context: name, + unsupportedFeatures: c.unsupported, }, cl, nil } diff --git a/tests/workers/features.go b/tests/workers/features.go new file mode 100644 index 00000000..b289d308 --- /dev/null +++ b/tests/workers/features.go @@ -0,0 +1,13 @@ +package workers + +import ( + "testing" + + "github.com/moby/buildkit/util/testutil/integration" +) + +var features = map[string]struct{}{} + +func CheckFeatureCompat(t *testing.T, sb integration.Sandbox, reason ...string) { + integration.CheckFeatureCompat(t, sb, features, reason...) +} diff --git a/tests/workers/remote.go b/tests/workers/remote.go index e1d08ab8..ab788487 100644 --- a/tests/workers/remote.go +++ b/tests/workers/remote.go @@ -7,6 +7,7 @@ import ( "github.com/moby/buildkit/identity" "github.com/moby/buildkit/util/testutil/integration" + bkworkers "github.com/moby/buildkit/util/testutil/workers" "github.com/pkg/errors" ) @@ -17,7 +18,8 @@ func InitRemoteWorker() { } type remoteWorker struct { - id string + id string + unsupported []string } func (w remoteWorker) Name() string { @@ -29,7 +31,7 @@ func (w remoteWorker) Rootless() bool { } func (w remoteWorker) New(ctx context.Context, cfg *integration.BackendConfig) (b integration.Backend, cl func() error, err error) { - oci := integration.OCI{ID: w.id} + oci := bkworkers.OCI{ID: w.id} bk, bkclose, err := oci.New(ctx, cfg) if err != nil { return bk, cl, err @@ -60,7 +62,8 @@ func (w remoteWorker) New(ctx context.Context, cfg *integration.BackendConfig) ( } return &backend{ - builder: name, + builder: name, + unsupportedFeatures: w.unsupported, }, cl, nil }