Skip to content

Commit aab2e30

Browse files
committed
tests: client: enable a batch of integration tests for wcow
A number of tests have been skipped on Windows. Enable the following tests in `client/`, with minor modifications to run/unskip on Windows: - [x] `testStdinClosed` - [x] `testHostnameLookup` - [x] `testHostnameSpecifying` - [x] `testFileOpCopyAlwaysReplaceExistingDestPaths` - [x] `testFileOpInputSwap` - [x] `testLocalSourceDiffer` - [x] `testLocalSourceWithDiffer` - [x] `testBuildHTTPSource` - [x] `testBuildHTTPSourceEtagScope` - [x] `testNoTarOCIIndexMediaType` - [x] `testOCIIndexMediatype` - [x] `testFrontendMetadataReturn` - [x] `testFrontendUseSolveResults` - [x] `testExporterTargetExists` - [x] `testLazyImagePush` - [x] `testRegistryEmptyCacheExport` - [x] `testExportLocalNoPlatformSplit` - [x] `testExportLocalNoPlatformSplitOverwrite` - [x] `testSchema1Image` - [x] `testSourceMapFromRef` count: +20 Addressing moby#4485 Signed-off-by: Anthony Nandaa <[email protected]>
1 parent 55a7483 commit aab2e30

File tree

1 file changed

+55
-35
lines changed

1 file changed

+55
-35
lines changed

client/client_test.go

Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,6 @@ func testExportBusyboxLocal(t *testing.T, sb integration.Sandbox) {
584584
}
585585

586586
func testHostnameLookup(t *testing.T, sb integration.Sandbox) {
587-
integration.SkipOnPlatform(t, "windows")
588587
if sb.Rootless() { // bridge is not used by default, even with detach-netns
589588
t.SkipNow()
590589
}
@@ -593,7 +592,12 @@ func testHostnameLookup(t *testing.T, sb integration.Sandbox) {
593592
require.NoError(t, err)
594593
defer c.Close()
595594

596-
st := llb.Image("busybox:latest").Run(llb.Shlex(`sh -c "ping -c 1 $(hostname)"`))
595+
imgName := integration.UnixOrWindows("busybox:latest", "nanoserver:latest")
596+
cmdStr := integration.UnixOrWindows(
597+
`sh -c "ping -c 1 $(hostname)"`,
598+
"cmd /C ping -n 1 %COMPUTERNAME%",
599+
)
600+
st := llb.Image(imgName).Run(llb.Shlex(cmdStr))
597601

598602
def, err := st.Marshal(sb.Context())
599603
require.NoError(t, err)
@@ -604,7 +608,6 @@ func testHostnameLookup(t *testing.T, sb integration.Sandbox) {
604608

605609
// moby/buildkit#1301
606610
func testHostnameSpecifying(t *testing.T, sb integration.Sandbox) {
607-
integration.SkipOnPlatform(t, "windows")
608611
if sb.Rootless() { // bridge is not used by default, even with detach-netns
609612
t.SkipNow()
610613
}
@@ -614,9 +617,21 @@ func testHostnameSpecifying(t *testing.T, sb integration.Sandbox) {
614617
defer c.Close()
615618

616619
hostname := "testtest"
617-
st := llb.Image("busybox:latest").With(llb.Hostname(hostname)).
618-
Run(llb.Shlexf("sh -c 'echo $HOSTNAME | grep %s'", hostname)).
619-
Run(llb.Shlexf("sh -c 'echo $(hostname) | grep %s'", hostname))
620+
// NOTE: Windows capitalizes the hostname hence
621+
// case insensitive findstr (findstr /I)
622+
// testtest --> TESTTEST
623+
cmdStr1 := integration.UnixOrWindows(
624+
"sh -c 'echo $HOSTNAME | grep %s'",
625+
"cmd /C echo %%COMPUTERNAME%% | findstr /I %s",
626+
)
627+
cmdStr2 := integration.UnixOrWindows(
628+
"sh -c 'echo $(hostname) | grep %s'",
629+
"cmd /C echo %%COMPUTERNAME%% | findstr /I %s",
630+
)
631+
imgName := integration.UnixOrWindows("busybox:latest", "nanoserver:latest")
632+
st := llb.Image(imgName).With(llb.Hostname(hostname)).
633+
Run(llb.Shlexf(cmdStr1, hostname)).
634+
Run(llb.Shlexf(cmdStr2, hostname))
620635

621636
def, err := st.Marshal(sb.Context())
622637
require.NoError(t, err)
@@ -629,12 +644,13 @@ func testHostnameSpecifying(t *testing.T, sb integration.Sandbox) {
629644

630645
// moby/buildkit#614
631646
func testStdinClosed(t *testing.T, sb integration.Sandbox) {
632-
integration.SkipOnPlatform(t, "windows")
633647
c, err := New(sb.Context(), sb.Address())
634648
require.NoError(t, err)
635649
defer c.Close()
636650

637-
st := llb.Image("busybox:latest").Run(llb.Shlex("cat"))
651+
imgName := integration.UnixOrWindows("busybox:latest", "nanoserver:latest")
652+
cmdStr := integration.UnixOrWindows("cat", "cmd /C more")
653+
st := llb.Image(imgName).Run(llb.Shlex(cmdStr))
638654

639655
def, err := st.Marshal(sb.Context())
640656
require.NoError(t, err)
@@ -1186,7 +1202,6 @@ func testSecurityModeErrors(t *testing.T, sb integration.Sandbox) {
11861202
}
11871203

11881204
func testFrontendImageNaming(t *testing.T, sb integration.Sandbox) {
1189-
requiresLinux(t)
11901205
c, err := New(sb.Context(), sb.Address())
11911206
require.NoError(t, err)
11921207
defer c.Close()
@@ -1918,7 +1933,6 @@ func testFileOpCopyIncludeExclude(t *testing.T, sb integration.Sandbox) {
19181933
}
19191934

19201935
func testFileOpCopyAlwaysReplaceExistingDestPaths(t *testing.T, sb integration.Sandbox) {
1921-
requiresLinux(t)
19221936
c, err := New(sb.Context(), sb.Address())
19231937
require.NoError(t, err)
19241938
defer c.Close()
@@ -1993,7 +2007,6 @@ func testFileOpCopyAlwaysReplaceExistingDestPaths(t *testing.T, sb integration.S
19932007

19942008
// testFileOpInputSwap is a regression test that cache is invalidated when subset of fileop is built
19952009
func testFileOpInputSwap(t *testing.T, sb integration.Sandbox) {
1996-
requiresLinux(t)
19972010
c, err := New(sb.Context(), sb.Address())
19982011
require.NoError(t, err)
19992012
defer c.Close()
@@ -2018,7 +2031,11 @@ func testFileOpInputSwap(t *testing.T, sb integration.Sandbox) {
20182031

20192032
_, err = c.Solve(sb.Context(), def, SolveOpt{}, nil)
20202033
require.Error(t, err)
2021-
require.Contains(t, err.Error(), "bar: no such file")
2034+
errStr := integration.UnixOrWindows(
2035+
"bar: no such file",
2036+
"bar: The system cannot find the file specified",
2037+
)
2038+
require.Contains(t, err.Error(), errStr)
20222039
}
20232040

20242041
func testLocalSourceDiffer(t *testing.T, sb integration.Sandbox) {
@@ -2030,7 +2047,6 @@ func testLocalSourceDiffer(t *testing.T, sb integration.Sandbox) {
20302047
}
20312048

20322049
func testLocalSourceWithDiffer(t *testing.T, sb integration.Sandbox, d llb.DiffType) {
2033-
requiresLinux(t)
20342050
c, err := New(context.TODO(), sb.Address())
20352051
require.NoError(t, err)
20362052
defer c.Close()
@@ -2628,7 +2644,6 @@ func testBuildExportScratch(t *testing.T, sb integration.Sandbox) {
26282644
}
26292645

26302646
func testBuildHTTPSource(t *testing.T, sb integration.Sandbox) {
2631-
integration.SkipOnPlatform(t, "windows")
26322647
c, err := New(sb.Context(), sb.Address())
26332648
require.NoError(t, err)
26342649
defer c.Close()
@@ -2738,8 +2753,11 @@ func testBuildHTTPSource(t *testing.T, sb integration.Sandbox) {
27382753
require.Equal(t, "gzip", allReqs[3].Header.Get("Accept-Encoding"))
27392754

27402755
// test extra options
2741-
st = llb.HTTP(server.URL+"/foo", llb.Filename("bar"), llb.Chmod(0741), llb.Chown(1000, 1000))
2742-
2756+
// llb.Chown not supported on Windows
2757+
st = integration.UnixOrWindows(
2758+
llb.HTTP(server.URL+"/foo", llb.Filename("bar"), llb.Chmod(0741), llb.Chown(1000, 1000)),
2759+
llb.HTTP(server.URL+"/foo", llb.Filename("bar"), llb.Chmod(0741)),
2760+
)
27432761
def, err = st.Marshal(sb.Context())
27442762
require.NoError(t, err)
27452763

@@ -2763,7 +2781,10 @@ func testBuildHTTPSource(t *testing.T, sb integration.Sandbox) {
27632781
fi, err := os.Stat(filepath.Join(tmpdir, "bar"))
27642782
require.NoError(t, err)
27652783
require.Equal(t, fi.ModTime().Format(http.TimeFormat), modTime.Format(http.TimeFormat))
2766-
require.Equal(t, 0741, int(fi.Mode()&0777))
2784+
2785+
// no support for llb.Chmod on Windows, default is returned
2786+
fMode := integration.UnixOrWindows(0741, 0666)
2787+
require.Equal(t, fMode, int(fi.Mode()&0777))
27672788

27682789
checkAllReleasable(t, c, sb, true)
27692790

@@ -2772,7 +2793,6 @@ func testBuildHTTPSource(t *testing.T, sb integration.Sandbox) {
27722793

27732794
// docker/buildx#2803
27742795
func testBuildHTTPSourceEtagScope(t *testing.T, sb integration.Sandbox) {
2775-
integration.SkipOnPlatform(t, "windows")
27762796
c, err := New(sb.Context(), sb.Address())
27772797
require.NoError(t, err)
27782798
defer c.Close()
@@ -3304,12 +3324,16 @@ func testOCIExporterContentStore(t *testing.T, sb integration.Sandbox) {
33043324

33053325
func testNoTarOCIIndexMediaType(t *testing.T, sb integration.Sandbox) {
33063326
workers.CheckFeatureCompat(t, sb, workers.FeatureOCIExporter)
3307-
requiresLinux(t)
33083327
c, err := New(sb.Context(), sb.Address())
33093328
require.NoError(t, err)
33103329
defer c.Close()
33113330

3312-
st := llb.Image("busybox:latest").Run(llb.Shlex(`sh -c "echo -n hello > hello"`))
3331+
imgName := integration.UnixOrWindows("busybox:latest", "nanoserver:latest")
3332+
cmdStr := integration.UnixOrWindows(
3333+
`sh -c "echo -n hello > hello"`,
3334+
`cmd /C "echo hello> hello"`,
3335+
)
3336+
st := llb.Image(imgName).Run(llb.Shlex(cmdStr))
33133337
def, err := st.Marshal(sb.Context())
33143338
require.NoError(t, err)
33153339

@@ -3347,12 +3371,16 @@ func testNoTarOCIIndexMediaType(t *testing.T, sb integration.Sandbox) {
33473371

33483372
func testOCIIndexMediatype(t *testing.T, sb integration.Sandbox) {
33493373
workers.CheckFeatureCompat(t, sb, workers.FeatureOCIExporter)
3350-
requiresLinux(t)
33513374
c, err := New(sb.Context(), sb.Address())
33523375
require.NoError(t, err)
33533376
defer c.Close()
33543377

3355-
st := llb.Image("busybox:latest").Run(llb.Shlex(`sh -c "echo -n hello > hello"`))
3378+
imgName := integration.UnixOrWindows("busybox:latest", "nanoserver:latest")
3379+
cmdStr := integration.UnixOrWindows(
3380+
`sh -c "echo -n hello > hello"`,
3381+
`cmd /C "echo hello> hello"`,
3382+
)
3383+
st := llb.Image(imgName).Run(llb.Shlex(cmdStr))
33563384
def, err := st.Marshal(sb.Context())
33573385
require.NoError(t, err)
33583386

@@ -3798,7 +3826,6 @@ func testSourceDateEpochImageExporter(t *testing.T, sb integration.Sandbox) {
37983826
}
37993827

38003828
func testFrontendMetadataReturn(t *testing.T, sb integration.Sandbox) {
3801-
requiresLinux(t)
38023829
c, err := New(sb.Context(), sb.Address())
38033830
require.NoError(t, err)
38043831
defer c.Close()
@@ -3839,7 +3866,6 @@ func testFrontendMetadataReturn(t *testing.T, sb integration.Sandbox) {
38393866
}
38403867

38413868
func testFrontendUseSolveResults(t *testing.T, sb integration.Sandbox) {
3842-
requiresLinux(t)
38433869
c, err := New(sb.Context(), sb.Address())
38443870
require.NoError(t, err)
38453871
defer c.Close()
@@ -3904,12 +3930,12 @@ func testFrontendUseSolveResults(t *testing.T, sb integration.Sandbox) {
39043930

39053931
func testExporterTargetExists(t *testing.T, sb integration.Sandbox) {
39063932
workers.CheckFeatureCompat(t, sb, workers.FeatureOCIExporter)
3907-
requiresLinux(t)
39083933
c, err := New(sb.Context(), sb.Address())
39093934
require.NoError(t, err)
39103935
defer c.Close()
39113936

3912-
st := llb.Image("busybox:latest")
3937+
imgName := integration.UnixOrWindows("busybox:latest", "nanoserver:latest")
3938+
st := llb.Image(imgName)
39133939
def, err := st.Marshal(sb.Context())
39143940
require.NoError(t, err)
39153941

@@ -5229,7 +5255,6 @@ func testStargzLazyPull(t *testing.T, sb integration.Sandbox) {
52295255

52305256
func testLazyImagePush(t *testing.T, sb integration.Sandbox) {
52315257
workers.CheckFeatureCompat(t, sb, workers.FeatureDirectPush)
5232-
requiresLinux(t)
52335258
cdAddress := sb.ContainerdAddress()
52345259
if cdAddress == "" {
52355260
t.Skip("test requires containerd worker")
@@ -5252,7 +5277,7 @@ func testLazyImagePush(t *testing.T, sb integration.Sandbox) {
52525277
defer c.Close()
52535278

52545279
// push the busybox image to the mutable registry
5255-
sourceImage := "busybox:latest"
5280+
sourceImage := integration.UnixOrWindows("busybox:latest", "nanoserver:latest")
52565281
def, err := llb.Image(sourceImage).Marshal(sb.Context())
52575282
require.NoError(t, err)
52585283

@@ -5359,7 +5384,8 @@ func testLazyImagePush(t *testing.T, sb integration.Sandbox) {
53595384
}
53605385

53615386
// check that a subsequent build can use the previously lazy image in an exec
5362-
def, err = llb.Image(target2).Run(llb.Args([]string{"true"})).Marshal(sb.Context())
5387+
cmdStr := integration.UnixOrWindows("true", "cmd /C exit 0")
5388+
def, err = llb.Image(target2).Run(llb.Args([]string{cmdStr})).Marshal(sb.Context())
53635389
require.NoError(t, err)
53645390

53655391
_, err = c.Solve(sb.Context(), def, SolveOpt{}, nil)
@@ -6104,8 +6130,6 @@ func testBasicGhaCacheImportExportExtraTimeout(t *testing.T, sb integration.Sand
61046130
}
61056131

61066132
func testRegistryEmptyCacheExport(t *testing.T, sb integration.Sandbox) {
6107-
requiresLinux(t)
6108-
61096133
workers.CheckFeatureCompat(t, sb,
61106134
workers.FeatureCacheExport,
61116135
workers.FeatureCacheBackendRegistry,
@@ -6371,7 +6395,6 @@ func testSnapshotWithMultipleBlobs(t *testing.T, sb integration.Sandbox) {
63716395
}
63726396

63736397
func testExportLocalNoPlatformSplit(t *testing.T, sb integration.Sandbox) {
6374-
integration.SkipOnPlatform(t, "windows")
63756398
workers.CheckFeatureCompat(t, sb, workers.FeatureOCIExporter, workers.FeatureMultiPlatform)
63766399
c, err := New(sb.Context(), sb.Address())
63776400
require.NoError(t, err)
@@ -6449,7 +6472,6 @@ func testExportLocalNoPlatformSplit(t *testing.T, sb integration.Sandbox) {
64496472
}
64506473

64516474
func testExportLocalNoPlatformSplitOverwrite(t *testing.T, sb integration.Sandbox) {
6452-
integration.SkipOnPlatform(t, "windows")
64536475
workers.CheckFeatureCompat(t, sb, workers.FeatureOCIExporter, workers.FeatureMultiPlatform)
64546476
c, err := New(sb.Context(), sb.Address())
64556477
require.NoError(t, err)
@@ -6999,7 +7021,6 @@ func testMoveParentDir(t *testing.T, sb integration.Sandbox) {
69997021

70007022
// #296
70017023
func testSchema1Image(t *testing.T, sb integration.Sandbox) {
7002-
integration.SkipOnPlatform(t, "windows")
70037024
c, err := New(sb.Context(), sb.Address())
70047025
require.NoError(t, err)
70057026
defer c.Close()
@@ -7127,7 +7148,6 @@ func testSourceMap(t *testing.T, sb integration.Sandbox) {
71277148
}
71287149

71297150
func testSourceMapFromRef(t *testing.T, sb integration.Sandbox) {
7130-
requiresLinux(t)
71317151
c, err := New(sb.Context(), sb.Address())
71327152
require.NoError(t, err)
71337153
defer c.Close()

0 commit comments

Comments
 (0)