tests: add unsupported features detection skeleton

Signed-off-by: Justin Chadwell <me@jedevc.com>
pull/1987/head
Justin Chadwell 1 year ago
parent 4e7709e54c
commit 5e46d8057d

@ -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
}

@ -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
}

@ -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
}

@ -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...)
}

@ -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
}

Loading…
Cancel
Save