Skip to content

Commit

Permalink
Merge pull request #5474 from profnandaa/tests-client-int-test-setup
Browse files Browse the repository at this point in the history
tests: client: set up for wcow integration tests
  • Loading branch information
tonistiigi authored Oct 31, 2024
2 parents 354f2d1 + dfe57c3 commit e91be04
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
45 changes: 26 additions & 19 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"strconv"
"strings"
"syscall"
Expand Down Expand Up @@ -229,15 +228,21 @@ func TestIntegration(t *testing.T) {
}

func testIntegration(t *testing.T, funcs ...func(t *testing.T, sb integration.Sandbox)) {
mirroredImages := integration.OfficialImages("busybox:latest", "alpine:latest")
mirroredImages["tonistiigi/test:nolayers"] = "docker.io/tonistiigi/test:nolayers"
mirroredImages["cpuguy83/buildkit-foreign:latest"] = "docker.io/cpuguy83/buildkit-foreign:latest"
mirroredImagesUnix := integration.OfficialImages("busybox:latest", "alpine:latest")
mirroredImagesUnix["tonistiigi/test:nolayers"] = "docker.io/tonistiigi/test:nolayers"
mirroredImagesUnix["cpuguy83/buildkit-foreign:latest"] = "docker.io/cpuguy83/buildkit-foreign:latest"
mirroredImagesWin := integration.OfficialImages("nanoserver:latest", "nanoserver:plus")

mirroredImages := integration.UnixOrWindows(mirroredImagesUnix, mirroredImagesWin)
mirrors := integration.WithMirroredImages(mirroredImages)

tests := integration.TestFuncs(funcs...)
tests = append(tests, diffOpTestCases()...)
integration.Run(t, tests, mirrors)

// the rest of the tests are meant for non-Windows, skipping on Windows.
integration.SkipOnPlatform(t, "windows")

integration.Run(t, integration.TestFuncs(
testSecurityMode,
testSecurityModeSysfs,
Expand All @@ -260,16 +265,14 @@ func testIntegration(t *testing.T, funcs ...func(t *testing.T, sb integration.Sa
}),
)

if runtime.GOOS != "windows" {
integration.Run(
t,
integration.TestFuncs(testBridgeNetworkingDNSNoRootless),
mirrors,
integration.WithMatrix("netmode", map[string]interface{}{
"dns": bridgeDNSNetwork,
}),
)
}
integration.Run(
t,
integration.TestFuncs(testBridgeNetworkingDNSNoRootless),
mirrors,
integration.WithMatrix("netmode", map[string]interface{}{
"dns": bridgeDNSNetwork,
}),
)
}

func newContainerd(cdAddress string) (*containerd.Client, error) {
Expand Down Expand Up @@ -414,7 +417,6 @@ func testHostNetworking(t *testing.T, sb integration.Sandbox) {
}

func testExportedImageLabels(t *testing.T, sb integration.Sandbox) {
integration.SkipOnPlatform(t, "windows")
c, err := New(sb.Context(), sb.Address())
require.NoError(t, err)
defer c.Close()
Expand All @@ -426,7 +428,14 @@ func testExportedImageLabels(t *testing.T, sb integration.Sandbox) {

ctx := sb.Context()

def, err := llb.Image("busybox").Run(llb.Shlexf("echo foo > /foo")).Marshal(ctx)
imgName := integration.UnixOrWindows("busybox", "nanoserver")
prefix := integration.UnixOrWindows(
"",
"cmd /C ", // TODO(profnandaa): currently needs the shell prefix, to be fixed
)
def, err := llb.Image(imgName).
Run(llb.Shlexf(fmt.Sprintf("%secho foo > /foo", prefix))).
Marshal(ctx)
require.NoError(t, err)

target := "docker.io/buildkit/build/exporter:labels"
Expand Down Expand Up @@ -7766,9 +7775,7 @@ func chainRunShells(base llb.State, cmdss ...[]string) llb.State {
}

func requiresLinux(t *testing.T) {
if runtime.GOOS != "linux" {
t.Skipf("unsupported GOOS: %s", runtime.GOOS)
}
integration.SkipOnPlatform(t, "!linux")
}

// ensurePruneAll tries to ensure Prune completes with retries.
Expand Down
11 changes: 10 additions & 1 deletion util/testutil/integration/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,16 @@ func prepareValueMatrix(tc testConf) []matrixValue {

// Skips tests on platform
func SkipOnPlatform(t *testing.T, goos string) {
if runtime.GOOS == goos {
skip := false
// support for negation
if strings.HasPrefix(goos, "!") {
goos = strings.TrimPrefix(goos, "!")
skip = runtime.GOOS != goos
} else {
skip = runtime.GOOS == goos
}

if skip {
t.Skipf("Skipped on %s", goos)
}
}
Expand Down

0 comments on commit e91be04

Please sign in to comment.