Skip to content

Commit 8c237af

Browse files
authored
Merge pull request moby#5239 from billywr/wcow-integration-test-part2
tests: frontend/dockerfile: update integration tests for windows/wcow (part 3)
2 parents ea6f91e + 99c771e commit 8c237af

File tree

1 file changed

+49
-21
lines changed

1 file changed

+49
-21
lines changed

frontend/dockerfile/dockerfile_provenance_test.go

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import (
4343
)
4444

4545
func testProvenanceAttestation(t *testing.T, sb integration.Sandbox) {
46-
integration.SkipOnPlatform(t, "windows")
4746
workers.CheckFeatureCompat(t, sb, workers.FeatureDirectPush, workers.FeatureProvenance)
4847
ctx := sb.Context()
4948

@@ -59,10 +58,18 @@ func testProvenanceAttestation(t *testing.T, sb integration.Sandbox) {
5958

6059
f := getFrontend(t, sb)
6160

62-
dockerfile := []byte(`
61+
dockerfile := []byte(integration.UnixOrWindows(
62+
`
6363
FROM busybox:latest
6464
RUN echo "ok" > /foo
65-
`)
65+
`,
66+
`
67+
FROM nanoserver
68+
USER ContainerAdministrator
69+
RUN echo ok> /foo
70+
`,
71+
))
72+
6673
dir := integration.Tmpdir(
6774
t,
6875
fstest.CreateFile("Dockerfile", dockerfile, 0600),
@@ -115,7 +122,9 @@ RUN echo "ok" > /foo
115122

116123
img := imgs.Find(platforms.Format(platforms.Normalize(platforms.DefaultSpec())))
117124
require.NotNil(t, img)
118-
require.Equal(t, []byte("ok\n"), img.Layers[1]["foo"].Data)
125+
outFile := integration.UnixOrWindows("foo", "Files/foo")
126+
expectedFileData := integration.UnixOrWindows([]byte("ok\n"), []byte("ok\r\n"))
127+
require.Equal(t, expectedFileData, img.Layers[1][outFile].Data)
119128

120129
att := imgs.Find("unknown/unknown")
121130
require.NotNil(t, att)
@@ -179,7 +188,9 @@ RUN echo "ok" > /foo
179188
require.Equal(t, "https://xxxxx:[email protected]/foo.html", args["context:foo"])
180189
}
181190

182-
expectedBase := "pkg:docker/busybox@latest?platform=" + url.PathEscape(platforms.Format(platforms.Normalize(platforms.DefaultSpec())))
191+
expectedBaseImage := integration.UnixOrWindows("busybox", "nanoserver")
192+
escapedPlatform := url.PathEscape(platforms.Format(platforms.Normalize(platforms.DefaultSpec())))
193+
expectedBase := fmt.Sprintf("pkg:docker/%s@latest?platform=%s", expectedBaseImage, escapedPlatform)
183194
if isGateway {
184195
require.Equal(t, 2, len(pred.Materials), "%+v", pred.Materials)
185196
require.Contains(t, pred.Materials[0].URI, "docker/buildkit_test")
@@ -693,7 +704,6 @@ func testClientFrontendProvenance(t *testing.T, sb integration.Sandbox) {
693704
}
694705

695706
func testClientLLBProvenance(t *testing.T, sb integration.Sandbox) {
696-
integration.SkipOnPlatform(t, "windows")
697707
workers.CheckFeatureCompat(t, sb, workers.FeatureDirectPush, workers.FeatureProvenance)
698708
ctx := sb.Context()
699709

@@ -736,7 +746,7 @@ func testClientLLBProvenance(t *testing.T, sb integration.Sandbox) {
736746
return nil, err
737747
}
738748

739-
st = llb.Image("alpine").File(llb.Mkfile("/foo", 0600, dt))
749+
st = llb.Image(integration.UnixOrWindows("alpine", "nanoserver")).File(llb.Mkfile("/foo", 0600, dt))
740750
def, err = st.Marshal(ctx)
741751
if err != nil {
742752
return nil, err
@@ -776,8 +786,9 @@ func testClientLLBProvenance(t *testing.T, sb integration.Sandbox) {
776786
nativePlatform := platforms.Format(platforms.Normalize(platforms.DefaultSpec()))
777787

778788
img := imgs.Find(nativePlatform)
789+
fileName := integration.UnixOrWindows("foo", "Files/foo")
779790
require.NotNil(t, img)
780-
require.Contains(t, string(img.Layers[1]["foo"].Data), "The Moby Project")
791+
require.Contains(t, string(img.Layers[1][fileName].Data), "The Moby Project")
781792

782793
att := imgs.FindAttestation(nativePlatform)
783794
require.NotNil(t, att)
@@ -803,7 +814,7 @@ func testClientLLBProvenance(t *testing.T, sb integration.Sandbox) {
803814
require.Equal(t, 0, len(pred.Invocation.Parameters.Locals))
804815

805816
require.Equal(t, 2, len(pred.Materials), "%+v", pred.Materials)
806-
require.Contains(t, pred.Materials[0].URI, "docker/alpine")
817+
require.Contains(t, pred.Materials[0].URI, integration.UnixOrWindows("docker/alpine", "docker/nanoserver"))
807818
require.Contains(t, pred.Materials[1].URI, "README.md")
808819
}
809820

@@ -1020,7 +1031,6 @@ EOF
10201031
}
10211032

10221033
func testNilProvenance(t *testing.T, sb integration.Sandbox) {
1023-
integration.SkipOnPlatform(t, "windows")
10241034
workers.CheckFeatureCompat(t, sb, workers.FeatureProvenance)
10251035
ctx := sb.Context()
10261036

@@ -1030,10 +1040,16 @@ func testNilProvenance(t *testing.T, sb integration.Sandbox) {
10301040

10311041
f := getFrontend(t, sb)
10321042

1033-
dockerfile := []byte(`
1043+
dockerfile := []byte(integration.UnixOrWindows(
1044+
`
10341045
FROM scratch
10351046
ENV FOO=bar
1036-
`)
1047+
`,
1048+
`
1049+
FROM scratch
1050+
ENV FOO=bar
1051+
`,
1052+
))
10371053
dir := integration.Tmpdir(
10381054
t,
10391055
fstest.CreateFile("Dockerfile", dockerfile, 0600),
@@ -1058,7 +1074,6 @@ ENV FOO=bar
10581074

10591075
// https://github.com/moby/buildkit/issues/3562
10601076
func testDuplicatePlatformProvenance(t *testing.T, sb integration.Sandbox) {
1061-
integration.SkipOnPlatform(t, "windows")
10621077
workers.CheckFeatureCompat(t, sb, workers.FeatureProvenance)
10631078
ctx := sb.Context()
10641079

@@ -1068,12 +1083,17 @@ func testDuplicatePlatformProvenance(t *testing.T, sb integration.Sandbox) {
10681083

10691084
f := getFrontend(t, sb)
10701085

1071-
dockerfile := []byte(`FROM alpine`)
1086+
dockerfile := []byte(
1087+
`
1088+
FROM alpine as base-linux
1089+
FROM nanoserver as base-windows
1090+
FROM base-$TARGETOS
1091+
`,
1092+
)
10721093
dir := integration.Tmpdir(
10731094
t,
10741095
fstest.CreateFile("Dockerfile", dockerfile, 0600),
10751096
)
1076-
10771097
_, err = f.Solve(sb.Context(), c, client.SolveOpt{
10781098
FrontendAttrs: map[string]string{
10791099
"attest:provenance": "mode=max",
@@ -1089,13 +1109,19 @@ func testDuplicatePlatformProvenance(t *testing.T, sb integration.Sandbox) {
10891109

10901110
// https://github.com/moby/buildkit/issues/3928
10911111
func testDockerIgnoreMissingProvenance(t *testing.T, sb integration.Sandbox) {
1092-
integration.SkipOnPlatform(t, "windows")
10931112
workers.CheckFeatureCompat(t, sb, workers.FeatureProvenance)
10941113
c, err := client.New(sb.Context(), sb.Address())
10951114
require.NoError(t, err)
10961115
defer c.Close()
10971116

1098-
dockerfile := []byte(`FROM alpine`)
1117+
dockerfile := []byte(integration.UnixOrWindows(
1118+
`
1119+
FROM alpine
1120+
`,
1121+
`
1122+
FROM nanoserver
1123+
`,
1124+
))
10991125
dirDockerfile := integration.Tmpdir(
11001126
t,
11011127
fstest.CreateFile("Dockerfile", dockerfile, 0600),
@@ -1250,20 +1276,22 @@ ADD bar bar`)
12501276
}
12511277

12521278
func testFrontendDeduplicateSources(t *testing.T, sb integration.Sandbox) {
1253-
integration.SkipOnPlatform(t, "windows")
12541279
ctx := sb.Context()
12551280

12561281
c, err := client.New(ctx, sb.Address())
12571282
require.NoError(t, err)
12581283
defer c.Close()
12591284

1260-
dockerfile := []byte(`
1261-
FROM scratch as base
1285+
dockerfile := []byte(fmt.Sprintf(
1286+
`
1287+
FROM %s as base
12621288
COPY foo foo2
12631289
12641290
FROM linked
12651291
COPY bar bar2
1266-
`)
1292+
`,
1293+
integration.UnixOrWindows("scratch", "nanoserver")),
1294+
)
12671295

12681296
dir := integration.Tmpdir(
12691297
t,

0 commit comments

Comments
 (0)