Skip to content

Commit

Permalink
tests: frontend/dockerfile: update integration tests for windows/wcow
Browse files Browse the repository at this point in the history
This is a continuation for the integration tests work #4485
We had some tests that we marked as Revit during our first pass
through the tests.

This commit addresses the following tests in `frontend/dockerfile`:

- [x] `testNamedOCILayoutContext`
- [x] `testArgDefaultExpansion`
- [x] `testTargetStageNameArg`
- [x] `testContextChangeDirToFile` (once reported flaky, fixes #5384 )
- [x] `testGlobalArgErrors`
- [x] `testCopyThroughSymlinkMultiStage`
- [x] `testTarContextExternalDockerfile`
- [x] `testTarContext`
- [x] `testOutlineArgs`

Count: 8 (+1)

> WIP: more being added.

Signed-off-by: Anthony Nandaa <[email protected]>
  • Loading branch information
profnandaa committed Dec 18, 2024
1 parent 4ea0679 commit 723060b
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 50 deletions.
49 changes: 41 additions & 8 deletions frontend/dockerfile/dockerfile_outline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ var outlineTests = integration.TestFuncs(
)

func testOutlineArgs(t *testing.T, sb integration.Sandbox) {
integration.SkipOnPlatform(t, "windows")
workers.CheckFeatureCompat(t, sb, workers.FeatureFrontendOutline)
f := getFrontend(t, sb)
if _, ok := f.(*clientFrontend); !ok {
t.Skip("only test with client frontend")
}

dockerfile := []byte(`ARG inherited=box
dockerfile := []byte(integration.UnixOrWindows(
`
ARG inherited=box
ARG inherited2=box2
ARG unused=abc${inherited2}
# sfx is a suffix
Expand All @@ -58,7 +59,35 @@ FROM third AS target
COPY --from=first /etc/passwd /
FROM second
`)
`,
`
ARG inherited=server
ARG inherited2=server2
ARG unused=abc${inherited2}
# sfx is a suffix
ARG sfx="ano${inherited}"
FROM n${sfx} AS first
# this is not assigned to anything
ARG FOO=123
# BAR is a number
ARG BAR=456
RUN exit 0
FROM nanoserver${unused} AS second
ARG BAZ
RUN exit 0
FROM nanoserver AS third
ARG ABC=a
# target defines build target
FROM third AS target
COPY --from=first /License.txt /license
FROM second
`,
))

dir := integration.Tmpdir(
t,
Expand Down Expand Up @@ -97,24 +126,28 @@ FROM second

require.Equal(t, 5, len(outline.Args))

// TODO(profnandaa): to find out why Windows is +1
// for arg.Location.Ranges[0].Start.Line
lineAdjust := integration.UnixOrWindows(0, 1)

arg := outline.Args[0]
require.Equal(t, "inherited", arg.Name)
require.Equal(t, "box", arg.Value)
require.Equal(t, integration.UnixOrWindows("box", "server"), arg.Value)
require.Equal(t, "", arg.Description)
require.Equal(t, int32(0), arg.Location.SourceIndex)
require.Equal(t, int32(1), arg.Location.Ranges[0].Start.Line)
require.Equal(t, int32(1+lineAdjust), arg.Location.Ranges[0].Start.Line)

Check failure on line 138 in frontend/dockerfile/dockerfile_outline_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd, ./frontend/dockerfile, integration)

Failed: frontend/dockerfile/TestIntegration/TestOutlineArgs/worker=containerd/frontend=client

=== RUN TestIntegration/TestOutlineArgs/worker=containerd/frontend=client === PAUSE TestIntegration/TestOutlineArgs/worker=containerd/frontend=client === CONT TestIntegration/TestOutlineArgs/worker=containerd/frontend=client dockerfile_outline_test.go:138: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:138 /src/frontend/gateway/grpcclient/client.go:215 /src/client/build.go:58 /src/client/solve.go:295 /src/vendor/golang.org/x/sync/errgroup/errgroup.go:78 /usr/local/go/src/runtime/asm_amd64.s:1700 Error: Not equal: expected: 1 actual : 2 Test: TestIntegration/TestOutlineArgs/worker=containerd/frontend=client dockerfile_outline_test.go:172: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:172 /src/util/testutil/integration/run.go:98 /src/util/testutil/integration/run.go:212 Error: Should be true Test: TestIntegration/TestOutlineArgs/worker=containerd/frontend=client sandbox.go:187: stdout: /usr/bin/buildkitd --containerd-worker-gc=false --containerd-worker=true --containerd-worker-addr /tmp/bktest_containerd1405531285/containerd.sock --containerd-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --oci-worker=false --config=/tmp/bktest_config440582141/buildkitd.toml --root /tmp/bktest_buildkitd2471920743 --addr unix:///tmp/bktest_buildkitd2471920743/buildkitd.sock --debugaddr unix:///tmp/bktest_buildkitd2471920743/buildkitd-debug.sock --debug sandbox.go:187: stderr: /usr/bin/buildkitd --containerd-worker-gc=false --containerd-worker=true --containerd-worker-addr /tmp/bktest_containerd1405531285/containerd.sock --containerd-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --oci-worker=false --config=/tmp/bktest_config440582141/buildkitd.toml --root /tmp/bktest_buildkitd2471920743 --addr unix:///tmp/bktest_buildkitd2471920743/buildkitd.sock --debugaddr unix:///tmp/bktest_buildkitd2471920743/buildkitd-debug.sock --debug sandbox.go:190: > StartCmd 2024-12-18 07:55:57.356024417 +0000 UTC m=+93.250853074 /usr/bin/buildkitd --containerd-worker-gc=false --containerd-worker=true --containerd-worker-addr /tmp/bktest_containerd1405531285/containerd.sock --containerd-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --oci-worker=false --config=/tmp/bktest_config440582141/buildkitd.toml --root /tmp/bktest_buildkitd2471920743 --addr unix:///tmp/bktest_buildkitd2471920743/buildkitd.sock --debugaddr unix:///tmp/bktest_buildkitd2471920743/buildkitd-debug.sock --debug sandbox.go:190: time="2024-12-18T07:55:57Z" level=debug msg="debug handlers listening at unix:///tmp/bktest_buildkitd2471920743/buildkitd-debug.sock" sandbox.go:190: time="2024-12-18T07:55:57Z" level=debug msg="could not read \"/tmp/bktest_buildkitd2471920743/net/cni\" for cleanup: open /tmp/bktest_buildkitd2471920743/net/cni: no such file or directory" sandbox.go:190: time="2024-12-18T07:55:57Z" level=debug msg="creating new network namespace rdkj9jvw74d2ywys3c198777b" sandbox.go:190: time="2024-12-18T07:55:57Z" level=debug msg="finished creating network namespace rdkj9jvw74d2ywys3c198777b" sandbox.go:190: time="2024-12-18T07:55:57Z" level=debug msg="finished setting up network namespace rdkj9jvw74d2ywys3c198777b" sandbox.go:190: time="2024-12-18T07:55:57Z" level=debug msg="remote introspection plugin filters" filters="[type==io.containerd.runtime.v1 type==io.containerd.runtime.v2]" sandbox.go:190: time="2024-12-18T07:55:57Z" level=info msg="found worker \"qvjtqj2ka78zxvrmo8pr0zvtz\", labels=map[org.mobyproject.buildkit.worker.containerd.namespace:buildkit org.mobyproject.buildkit.worker.containerd.uuid:54a812e6-bb43-469d-be29-fd844270891f org.mobyproject.buildkit.worker.executor:containerd org.mobyproject.buildkit.worker.hostname:61b1cf85a81a org.mobyproject.buildkit.w

Check failure on line 138 in frontend/dockerfile/dockerfile_outline_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-rootless, ./frontend/dockerfile, integration)

Failed: frontend/dockerfile/TestIntegration/TestOutlineArgs/worker=containerd-rootless/frontend=client

=== RUN TestIntegration/TestOutlineArgs/worker=containerd-rootless/frontend=client === PAUSE TestIntegration/TestOutlineArgs/worker=containerd-rootless/frontend=client === CONT TestIntegration/TestOutlineArgs/worker=containerd-rootless/frontend=client dockerfile_outline_test.go:138: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:138 /src/frontend/gateway/grpcclient/client.go:215 /src/client/build.go:58 /src/client/solve.go:295 /src/vendor/golang.org/x/sync/errgroup/errgroup.go:78 /usr/local/go/src/runtime/asm_amd64.s:1700 Error: Not equal: expected: 1 actual : 2 Test: TestIntegration/TestOutlineArgs/worker=containerd-rootless/frontend=client dockerfile_outline_test.go:172: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:172 /src/util/testutil/integration/run.go:98 /src/util/testutil/integration/run.go:212 Error: Should be true Test: TestIntegration/TestOutlineArgs/worker=containerd-rootless/frontend=client sandbox.go:187: stderr: /usr/bin/sudo -u #1000 -i -- exec nsenter -U --preserve-credentials -m -t 26558 buildkitd --containerd-worker-gc=false --containerd-worker=true --containerd-worker-addr /tmp/bktest_containerd1501766266/containerd.sock --containerd-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --oci-worker=false --containerd-worker-snapshotter=native --containerd-worker-snapshotter=native --config=/tmp/bktest_config1936236213/buildkitd.toml --root /tmp/bktest_buildkitd4034416343 --addr unix:///tmp/bktest_buildkitd4034416343/buildkitd.sock --debugaddr unix:///tmp/bktest_buildkitd4034416343/buildkitd-debug.sock --debug sandbox.go:190: > StartCmd 2024-12-18 07:54:41.441935242 +0000 UTC m=+26.153405656 /usr/bin/sudo -u #1000 -i -- exec nsenter -U --preserve-credentials -m -t 26558 buildkitd --containerd-worker-gc=false --containerd-worker=true --containerd-worker-addr /tmp/bktest_containerd1501766266/containerd.sock --containerd-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --oci-worker=false --containerd-worker-snapshotter=native --containerd-worker-snapshotter=native --config=/tmp/bktest_config1936236213/buildkitd.toml --root /tmp/bktest_buildkitd4034416343 --addr unix:///tmp/bktest_buildkitd4034416343/buildkitd.sock --debugaddr unix:///tmp/bktest_buildkitd4034416343/buildkitd-debug.sock --debug sandbox.go:190: warning: GOCOVERDIR not set, no coverage data emitted sandbox.go:190: time="2024-12-18T07:54:41Z" level=debug msg="debug handlers listening at unix:///tmp/bktest_buildkitd4034416343/buildkitd-debug.sock" sandbox.go:190: time="2024-12-18T07:54:41Z" level=debug msg="running in rootless mode" sandbox.go:190: time="2024-12-18T07:54:41Z" level=debug msg="remote introspection plugin filters" filters="[type==io.containerd.runtime.v1 type==io.containerd.runtime.v2]" sandbox.go:190: time="2024-12-18T07:54:41Z" level=info msg="found worker \"wj5ogo2dg2epcus053knkvxvb\", labels=map[org.mobyproject.buildkit.worker.containerd.namespace:buildkit org.mobyproject.buildkit.worker.containerd.uuid:8b1c0558-2a42-4795-805f-a33ca7131c98 org.mobyproject.buildkit.worker.executor:containerd org.mobyproject.buildkit.worker.hostname:112356c3e774 org.mobyproject.buildkit.worker.network:host org.mobyproject.buildkit.worker.sandbox:true org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:native], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/arm/v7 linux/arm/v6]" sandbox.go:190: time="2024-12-18T07:54:41Z" level=info msg="found 1 workers, default=\"wj5ogo2dg2epcus053knkvxvb\"" sandbox.go:190: time="2024-12-18T07:54:41Z" level=warning msg="currently, only the default worker can be used." sandbox.go:190: time="202

Check failure on line 138 in frontend/dockerfile/dockerfile_outline_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-1.6, ./frontend/dockerfile, integration)

Failed: frontend/dockerfile/TestIntegration/TestOutlineArgs/worker=containerd-1.6/frontend=client

=== RUN TestIntegration/TestOutlineArgs/worker=containerd-1.6/frontend=client === PAUSE TestIntegration/TestOutlineArgs/worker=containerd-1.6/frontend=client === CONT TestIntegration/TestOutlineArgs/worker=containerd-1.6/frontend=client dockerfile_outline_test.go:138: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:138 /src/frontend/gateway/grpcclient/client.go:215 /src/client/build.go:58 /src/client/solve.go:295 /src/vendor/golang.org/x/sync/errgroup/errgroup.go:78 /usr/local/go/src/runtime/asm_amd64.s:1700 Error: Not equal: expected: 1 actual : 2 Test: TestIntegration/TestOutlineArgs/worker=containerd-1.6/frontend=client dockerfile_outline_test.go:172: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:172 /src/util/testutil/integration/run.go:98 /src/util/testutil/integration/run.go:212 Error: Should be true Test: TestIntegration/TestOutlineArgs/worker=containerd-1.6/frontend=client sandbox.go:187: stdout: /opt/containerd-alt-16/bin/containerd --config /tmp/bktest_containerd2948634309/config.toml sandbox.go:187: stderr: /opt/containerd-alt-16/bin/containerd --config /tmp/bktest_containerd2948634309/config.toml sandbox.go:190: > StartCmd 2024-12-18 07:55:39.887800233 +0000 UTC m=+80.628875824 /opt/containerd-alt-16/bin/containerd --config /tmp/bktest_containerd2948634309/config.toml sandbox.go:190: time="2024-12-18T07:55:39.920055253Z" level=info msg="starting containerd" revision=88c3d9bc5b5a193f40b7c14fa996d23532d6f956 version=v1.6.36 sandbox.go:190: time="2024-12-18T07:55:39.939218423Z" level=info msg="loading plugin \"io.containerd.content.v1.content\"..." type=io.containerd.content.v1 sandbox.go:190: time="2024-12-18T07:55:39.939633849Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.devmapper\"..." type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:55:39.939662983Z" level=warning msg="failed to load plugin io.containerd.snapshotter.v1.devmapper" error="devmapper not configured" sandbox.go:190: time="2024-12-18T07:55:39.939683431Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.native\"..." type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:55:39.939774680Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.overlayfs\"..." type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:55:39.940054961Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.aufs\"..." type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:55:39.941525408Z" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.aufs\"..." error="aufs is not supported (modprobe aufs failed: exit status 1 \"modprobe: can't change directory to '/lib/modules': No such file or directory\\n\"): skip plugin" type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:55:39.941565732Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.zfs\"..." type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:55:39.941837989Z" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.zfs\"..." error="path /tmp/bktest_containerd2948634309/root/io.containerd.snapshotter.v1.zfs must be a zfs filesystem to be used with the zfs snapshotter: skip plugin" type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:55:39.941857815Z" level=info msg="loading plugin \"io.containerd.metadata.v1.bolt\"..." type=io.containerd.metadata.v1 sandbox.go:190: time="2024-12-18T07:55:39.941939768Z" level=warning msg="could not use snapshotter devmapper in metadata plugin" error="devmapper not configured" sandbox.go:190: time="2024-12-18T07:55:39.941954906Z" level=info msg="metadata content store policy set" policy=

Check failure on line 138 in frontend/dockerfile/dockerfile_outline_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-1.7, ./frontend/dockerfile, integration)

Failed: frontend/dockerfile/TestIntegration/TestOutlineArgs/worker=containerd-1.7/frontend=client

=== RUN TestIntegration/TestOutlineArgs/worker=containerd-1.7/frontend=client === PAUSE TestIntegration/TestOutlineArgs/worker=containerd-1.7/frontend=client === CONT TestIntegration/TestOutlineArgs/worker=containerd-1.7/frontend=client dockerfile_outline_test.go:138: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:138 /src/frontend/gateway/grpcclient/client.go:215 /src/client/build.go:58 /src/client/solve.go:295 /src/vendor/golang.org/x/sync/errgroup/errgroup.go:78 /usr/local/go/src/runtime/asm_amd64.s:1700 Error: Not equal: expected: 1 actual : 2 Test: TestIntegration/TestOutlineArgs/worker=containerd-1.7/frontend=client dockerfile_outline_test.go:172: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:172 /src/util/testutil/integration/run.go:98 /src/util/testutil/integration/run.go:212 Error: Should be true Test: TestIntegration/TestOutlineArgs/worker=containerd-1.7/frontend=client sandbox.go:187: stdout: /opt/containerd-alt-17/bin/containerd --config /tmp/bktest_containerd313774321/config.toml sandbox.go:187: stderr: /opt/containerd-alt-17/bin/containerd --config /tmp/bktest_containerd313774321/config.toml sandbox.go:190: > StartCmd 2024-12-18 07:54:33.00484963 +0000 UTC m=+15.509695048 /opt/containerd-alt-17/bin/containerd --config /tmp/bktest_containerd313774321/config.toml sandbox.go:190: time="2024-12-18T07:54:33.030122613Z" level=info msg="starting containerd" revision=57f17b0a6295a39009d861b89e3b3b87b005ca27 version=v1.7.23 sandbox.go:190: time="2024-12-18T07:54:33.070536129Z" level=info msg="loading plugin \"io.containerd.event.v1.exchange\"..." type=io.containerd.event.v1 sandbox.go:190: time="2024-12-18T07:54:33.070587425Z" level=info msg="loading plugin \"io.containerd.internal.v1.opt\"..." type=io.containerd.internal.v1 sandbox.go:190: time="2024-12-18T07:54:33.070637739Z" level=info msg="loading plugin \"io.containerd.warning.v1.deprecations\"..." type=io.containerd.warning.v1 sandbox.go:190: time="2024-12-18T07:54:33.070652988Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.blockfile\"..." type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:54:33.070736645Z" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.blockfile\"..." error="no scratch file generator: skip plugin" type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:54:33.070749950Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.devmapper\"..." type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:54:33.070763916Z" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.devmapper\"..." error="devmapper not configured: skip plugin" type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:54:33.070774215Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.native\"..." type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:54:33.070862771Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.overlayfs\"..." type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:54:33.071125043Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.aufs\"..." type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:54:33.075103325Z" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.aufs\"..." error="aufs is not supported (modprobe aufs failed: exit status 1 \"modprobe: can't change directory to '/lib/modules': No such file or directory\\n\"): skip plugin" type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:54:33.075212840Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.zfs\"..." type=io.containerd.snapshotter.v1 sandbox

Check failure on line 138 in frontend/dockerfile/dockerfile_outline_test.go

View workflow job for this annotation

GitHub Actions / test / run (containerd-snapshotter-stargz, ./frontend/dockerfile, integration)

Failed: frontend/dockerfile/TestIntegration/TestOutlineArgs/worker=containerd-snapshotter-stargz/frontend=client

=== RUN TestIntegration/TestOutlineArgs/worker=containerd-snapshotter-stargz/frontend=client === PAUSE TestIntegration/TestOutlineArgs/worker=containerd-snapshotter-stargz/frontend=client === CONT TestIntegration/TestOutlineArgs/worker=containerd-snapshotter-stargz/frontend=client dockerfile_outline_test.go:138: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:138 /src/frontend/gateway/grpcclient/client.go:215 /src/client/build.go:58 /src/client/solve.go:295 /src/vendor/golang.org/x/sync/errgroup/errgroup.go:78 /usr/local/go/src/runtime/asm_amd64.s:1700 Error: Not equal: expected: 1 actual : 2 Test: TestIntegration/TestOutlineArgs/worker=containerd-snapshotter-stargz/frontend=client dockerfile_outline_test.go:172: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:172 /src/util/testutil/integration/run.go:98 /src/util/testutil/integration/run.go:212 Error: Should be true Test: TestIntegration/TestOutlineArgs/worker=containerd-snapshotter-stargz/frontend=client sandbox.go:187: stderr: /usr/bin/containerd --config /tmp/bktest_containerd760481589/config.toml sandbox.go:190: > StartCmd 2024-12-18 07:55:52.483114059 +0000 UTC m=+99.877561255 /usr/bin/containerd --config /tmp/bktest_containerd760481589/config.toml sandbox.go:190: time="2024-12-18T07:55:52.503287950Z" level=info msg="starting containerd" revision= version=2.0.0+unknown sandbox.go:190: time="2024-12-18T07:55:52.514805109Z" level=warning msg="Configuration migrated from version 2, use `containerd config migrate` to avoid migration" t="3.247µs" sandbox.go:190: time="2024-12-18T07:55:52.514832870Z" level=info msg="loading plugin" id=io.containerd.image-verifier.v1.bindir type=io.containerd.image-verifier.v1 sandbox.go:190: time="2024-12-18T07:55:52.514854050Z" level=info msg="loading plugin" id=io.containerd.internal.v1.opt type=io.containerd.internal.v1 sandbox.go:190: time="2024-12-18T07:55:52.514894696Z" level=info msg="loading plugin" id=io.containerd.warning.v1.deprecations type=io.containerd.warning.v1 sandbox.go:190: time="2024-12-18T07:55:52.514915715Z" level=info msg="loading plugin" id=io.containerd.content.v1.content type=io.containerd.content.v1 sandbox.go:190: time="2024-12-18T07:55:52.514978101Z" level=info msg="loading plugin" id=io.containerd.snapshotter.v1.blockfile type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:55:52.515276818Z" level=info msg="skip loading plugin" error="no scratch file generator: skip plugin" id=io.containerd.snapshotter.v1.blockfile type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:55:52.515294091Z" level=info msg="loading plugin" id=io.containerd.snapshotter.v1.devmapper type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:55:52.515316563Z" level=info msg="skip loading plugin" error="devmapper not configured: skip plugin" id=io.containerd.snapshotter.v1.devmapper type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:55:52.515331571Z" level=info msg="loading plugin" id=io.containerd.snapshotter.v1.native type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:55:52.515422340Z" level=info msg="loading plugin" id=io.containerd.snapshotter.v1.overlayfs type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:55:52.515654362Z" level=info msg="loading plugin" id=io.containerd.snapshotter.v1.zfs type=io.containerd.snapshotter.v1 sandbox.go:190: time="2024-12-18T07:55:52.515691211Z" level=info msg="skip loading plugin" error="lstat /tmp/bktest_containerd760481589/root/io.containerd.snapshotter.v1.zfs: no such file or directory: skip plugin" id=io.containerd.snapshotter.v1.zfs type=io.containerd.snapshotter.v1 sandbox.go:190: time

Check failure on line 138 in frontend/dockerfile/dockerfile_outline_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci, ./frontend/dockerfile, integration)

Failed: frontend/dockerfile/TestIntegration/TestOutlineArgs/worker=oci/frontend=client

=== RUN TestIntegration/TestOutlineArgs/worker=oci/frontend=client === PAUSE TestIntegration/TestOutlineArgs/worker=oci/frontend=client === CONT TestIntegration/TestOutlineArgs/worker=oci/frontend=client dockerfile_outline_test.go:138: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:138 /src/frontend/gateway/grpcclient/client.go:215 /src/client/build.go:58 /src/client/solve.go:295 /src/vendor/golang.org/x/sync/errgroup/errgroup.go:78 /usr/local/go/src/runtime/asm_amd64.s:1700 Error: Not equal: expected: 1 actual : 2 Test: TestIntegration/TestOutlineArgs/worker=oci/frontend=client dockerfile_outline_test.go:172: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:172 /src/util/testutil/integration/run.go:98 /src/util/testutil/integration/run.go:212 Error: Should be true Test: TestIntegration/TestOutlineArgs/worker=oci/frontend=client sandbox.go:187: stdout: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config1437139642/buildkitd.toml --root /tmp/bktest_buildkitd4150875662 --addr unix:///tmp/bktest_buildkitd4150875662/buildkitd.sock --debugaddr unix:///tmp/bktest_buildkitd4150875662/buildkitd-debug.sock --debug sandbox.go:187: stderr: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config1437139642/buildkitd.toml --root /tmp/bktest_buildkitd4150875662 --addr unix:///tmp/bktest_buildkitd4150875662/buildkitd.sock --debugaddr unix:///tmp/bktest_buildkitd4150875662/buildkitd-debug.sock --debug sandbox.go:190: > StartCmd 2024-12-18 07:54:38.390318893 +0000 UTC m=+9.014798755 /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config1437139642/buildkitd.toml --root /tmp/bktest_buildkitd4150875662 --addr unix:///tmp/bktest_buildkitd4150875662/buildkitd.sock --debugaddr unix:///tmp/bktest_buildkitd4150875662/buildkitd-debug.sock --debug sandbox.go:190: time="2024-12-18T07:54:38Z" level=debug msg="debug handlers listening at unix:///tmp/bktest_buildkitd4150875662/buildkitd-debug.sock" sandbox.go:190: time="2024-12-18T07:54:38Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:190: time="2024-12-18T07:54:38Z" level=debug msg="could not read \"/tmp/bktest_buildkitd4150875662/net/cni\" for cleanup: open /tmp/bktest_buildkitd4150875662/net/cni: no such file or directory" sandbox.go:190: time="2024-12-18T07:54:38Z" level=debug msg="creating new network namespace pp4zjv0jawjc0z41uzwca611j" sandbox.go:190: time="2024-12-18T07:54:38Z" level=debug msg="finished creating network namespace pp4zjv0jawjc0z41uzwca611j" sandbox.go:190: time="2024-12-18T07:54:38Z" level=debug msg="finished setting up network namespace pp4zjv0jawjc0z41uzwca611j" sandbox.go:190: time="2024-12-18T07:54:38Z" level=info msg="found worker \"3obqnxrz9d0z1abfnadc3iscq\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:d03ee4ddfaa9 org.mobyproject.buildkit.worker.network:cni org.mobyproject.buildkit.worker.oci.process-mode:sandbox org.mobyproject.buildkit.worker.sandbox:true org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/arm/v7 linux/arm/v6]" sandbox.go:190: time="2024-12-18T07:54:38Z" level=info msg="found 1 workers, default=\"3obqnxrz9d0z1abfnadc3iscq\"" sandbox.go:190: time="2024-12-1

Check failure on line 138 in frontend/dockerfile/dockerfile_outline_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci-rootless, ./frontend/dockerfile, integration)

Failed: frontend/dockerfile/TestIntegration/TestOutlineArgs/worker=oci-rootless/frontend=client

=== RUN TestIntegration/TestOutlineArgs/worker=oci-rootless/frontend=client === PAUSE TestIntegration/TestOutlineArgs/worker=oci-rootless/frontend=client === CONT TestIntegration/TestOutlineArgs/worker=oci-rootless/frontend=client dockerfile_outline_test.go:138: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:138 /src/frontend/gateway/grpcclient/client.go:215 /src/client/build.go:58 /src/client/solve.go:295 /src/vendor/golang.org/x/sync/errgroup/errgroup.go:78 /usr/local/go/src/runtime/asm_amd64.s:1700 Error: Not equal: expected: 1 actual : 2 Test: TestIntegration/TestOutlineArgs/worker=oci-rootless/frontend=client dockerfile_outline_test.go:172: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:172 /src/util/testutil/integration/run.go:98 /src/util/testutil/integration/run.go:212 Error: Should be true Test: TestIntegration/TestOutlineArgs/worker=oci-rootless/frontend=client sandbox.go:187: stderr: /usr/bin/sudo -u #1000 -i -- exec rootlesskit buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config2801199008/buildkitd.toml --root /tmp/bktest_buildkitd2098116306 --addr unix:///tmp/bktest_buildkitd2098116306/buildkitd.sock --debugaddr unix:///tmp/bktest_buildkitd2098116306/buildkitd-debug.sock --debug sandbox.go:190: > StartCmd 2024-12-18 07:55:19.801166873 +0000 UTC m=+49.909039250 /usr/bin/sudo -u #1000 -i -- exec rootlesskit buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config2801199008/buildkitd.toml --root /tmp/bktest_buildkitd2098116306 --addr unix:///tmp/bktest_buildkitd2098116306/buildkitd.sock --debugaddr unix:///tmp/bktest_buildkitd2098116306/buildkitd-debug.sock --debug sandbox.go:190: warning: GOCOVERDIR not set, no coverage data emitted sandbox.go:190: time="2024-12-18T07:55:19Z" level=debug msg="debug handlers listening at unix:///tmp/bktest_buildkitd2098116306/buildkitd-debug.sock" sandbox.go:190: time="2024-12-18T07:55:19Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:190: time="2024-12-18T07:55:19Z" level=debug msg="running in rootless mode" sandbox.go:190: time="2024-12-18T07:55:19Z" level=info msg="found worker \"jktywm4b7buh5hnidprmwgnyv\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:02ce97c3dc27 org.mobyproject.buildkit.worker.network:host org.mobyproject.buildkit.worker.oci.process-mode:sandbox org.mobyproject.buildkit.worker.sandbox:true org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/arm/v7 linux/arm/v6]" sandbox.go:190: time="2024-12-18T07:55:19Z" level=info msg="found 1 workers, default=\"jktywm4b7buh5hnidprmwgnyv\"" sandbox.go:190: time="2024-12-18T07:55:19Z" level=warning msg="currently, only the default worker can be used." sandbox.go:190: time="2024-12-18T07:55:19Z" level=info msg="running server on /tmp/bktest_buildkitd2098116306/buildkitd.sock" sandbox.go:190: time="2024-12-18T07:55:19Z" level=debug msg="session started" spanID=baf16bb5460bd283 traceID=f70b55a3d9369d2d7da9d85c324bb933 sandbox.go:190: time="2024-12-18T07:55:19Z" level=debug msg="new ref for local: 8jqe0bbbrqvblzvovt10fmxs0" span="[internal] load build definition from Dockerfile" spanID=3a161a2a4a15cf31 traceID=2c47ffb74373c2052846376ce815ce65 sandbox.go:190: time="2024-12-18T07:55:19Z" level=debug msg="diffcopy took: 1.649507ms" span="[internal] load build defini

Check failure on line 138 in frontend/dockerfile/dockerfile_outline_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci-rootless-slirp4netns-detachnetns, ./frontend/dockerfile, integration)

Failed: frontend/dockerfile/TestIntegration/TestOutlineArgs/worker=oci-rootless-slirp4netns-detachnetns/frontend=client

=== RUN TestIntegration/TestOutlineArgs/worker=oci-rootless-slirp4netns-detachnetns/frontend=client === PAUSE TestIntegration/TestOutlineArgs/worker=oci-rootless-slirp4netns-detachnetns/frontend=client === CONT TestIntegration/TestOutlineArgs/worker=oci-rootless-slirp4netns-detachnetns/frontend=client dockerfile_outline_test.go:138: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:138 /src/frontend/gateway/grpcclient/client.go:215 /src/client/build.go:58 /src/client/solve.go:295 /src/vendor/golang.org/x/sync/errgroup/errgroup.go:78 /usr/local/go/src/runtime/asm_amd64.s:1700 Error: Not equal: expected: 1 actual : 2 Test: TestIntegration/TestOutlineArgs/worker=oci-rootless-slirp4netns-detachnetns/frontend=client dockerfile_outline_test.go:172: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:172 /src/util/testutil/integration/run.go:98 /src/util/testutil/integration/run.go:212 Error: Should be true Test: TestIntegration/TestOutlineArgs/worker=oci-rootless-slirp4netns-detachnetns/frontend=client sandbox.go:187: stdout: /usr/bin/sudo -u #1000 -i -- exec rootlesskit --net=slirp4netns --copy-up=/etc --disable-host-loopback --detach-netns buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config1589048186/buildkitd.toml --root /tmp/bktest_buildkitd1022386418 --addr unix:///tmp/bktest_buildkitd1022386418/buildkitd.sock --debugaddr unix:///tmp/bktest_buildkitd1022386418/buildkitd-debug.sock --debug sandbox.go:187: stderr: /usr/bin/sudo -u #1000 -i -- exec rootlesskit --net=slirp4netns --copy-up=/etc --disable-host-loopback --detach-netns buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config1589048186/buildkitd.toml --root /tmp/bktest_buildkitd1022386418 --addr unix:///tmp/bktest_buildkitd1022386418/buildkitd.sock --debugaddr unix:///tmp/bktest_buildkitd1022386418/buildkitd-debug.sock --debug sandbox.go:190: > StartCmd 2024-12-18 07:54:38.503108606 +0000 UTC m=+9.035947078 /usr/bin/sudo -u #1000 -i -- exec rootlesskit --net=slirp4netns --copy-up=/etc --disable-host-loopback --detach-netns buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config1589048186/buildkitd.toml --root /tmp/bktest_buildkitd1022386418 --addr unix:///tmp/bktest_buildkitd1022386418/buildkitd.sock --debugaddr unix:///tmp/bktest_buildkitd1022386418/buildkitd-debug.sock --debug sandbox.go:190: warning: GOCOVERDIR not set, no coverage data emitted sandbox.go:190: time="2024-12-18T07:54:38Z" level=debug msg="debug handlers listening at unix:///tmp/bktest_buildkitd1022386418/buildkitd-debug.sock" sandbox.go:190: time="2024-12-18T07:54:38Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:190: time="2024-12-18T07:54:38Z" level=debug msg="running in rootless mode" sandbox.go:190: time="2024-12-18T07:54:38Z" level=info msg="found worker \"qosqr5w4z7tgxej3jeos8zrt3\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:4c2ad676b9e2 org.mobyproject.buildkit.worker.network:host org.mobyproject.buildkit.worker.oci.process-mode:sandbox org.mobyproject.buildkit.worker.sandbox:true org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/arm/v7 linux/arm/v6]" sandbox.go:190: time="2024-12-18T07:54:38Z" level=info msg="found 1 workers, default

Check failure on line 138 in frontend/dockerfile/dockerfile_outline_test.go

View workflow job for this annotation

GitHub Actions / test / run (oci-snapshotter-stargz, ./frontend/dockerfile, integration)

Failed: frontend/dockerfile/TestIntegration/TestOutlineArgs/worker=oci-snapshotter-stargz/frontend=client

=== RUN TestIntegration/TestOutlineArgs/worker=oci-snapshotter-stargz/frontend=client === PAUSE TestIntegration/TestOutlineArgs/worker=oci-snapshotter-stargz/frontend=client === CONT TestIntegration/TestOutlineArgs/worker=oci-snapshotter-stargz/frontend=client dockerfile_outline_test.go:138: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:138 /src/frontend/gateway/grpcclient/client.go:215 /src/client/build.go:58 /src/client/solve.go:295 /src/vendor/golang.org/x/sync/errgroup/errgroup.go:78 /usr/local/go/src/runtime/asm_amd64.s:1700 Error: Not equal: expected: 1 actual : 2 Test: TestIntegration/TestOutlineArgs/worker=oci-snapshotter-stargz/frontend=client dockerfile_outline_test.go:172: Error Trace: /src/frontend/dockerfile/dockerfile_outline_test.go:172 /src/util/testutil/integration/run.go:98 /src/util/testutil/integration/run.go:212 Error: Should be true Test: TestIntegration/TestOutlineArgs/worker=oci-snapshotter-stargz/frontend=client sandbox.go:187: stdout: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --oci-worker-snapshotter=stargz --config=/tmp/bktest_config2716472068/buildkitd.toml --root /tmp/bktest_buildkitd1845175981 --addr unix:///tmp/bktest_buildkitd1845175981/buildkitd.sock --debugaddr unix:///tmp/bktest_buildkitd1845175981/buildkitd-debug.sock --debug sandbox.go:187: stderr: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --oci-worker-snapshotter=stargz --config=/tmp/bktest_config2716472068/buildkitd.toml --root /tmp/bktest_buildkitd1845175981 --addr unix:///tmp/bktest_buildkitd1845175981/buildkitd.sock --debugaddr unix:///tmp/bktest_buildkitd1845175981/buildkitd-debug.sock --debug sandbox.go:190: > StartCmd 2024-12-18 07:54:45.370727382 +0000 UTC m=+34.714976787 /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --oci-worker-snapshotter=stargz --config=/tmp/bktest_config2716472068/buildkitd.toml --root /tmp/bktest_buildkitd1845175981 --addr unix:///tmp/bktest_buildkitd1845175981/buildkitd.sock --debugaddr unix:///tmp/bktest_buildkitd1845175981/buildkitd-debug.sock --debug sandbox.go:190: time="2024-12-18T07:54:45Z" level=debug msg="debug handlers listening at unix:///tmp/bktest_buildkitd1845175981/buildkitd-debug.sock" sandbox.go:190: time="2024-12-18T07:54:45Z" level=debug msg="could not read \"/tmp/bktest_buildkitd1845175981/net/cni\" for cleanup: open /tmp/bktest_buildkitd1845175981/net/cni: no such file or directory" sandbox.go:190: time="2024-12-18T07:54:45Z" level=debug msg="creating new network namespace xvgguq97zh5c5iyxdlo6urg6k" sandbox.go:190: time="2024-12-18T07:54:45Z" level=debug msg="finished creating network namespace xvgguq97zh5c5iyxdlo6urg6k" sandbox.go:190: time="2024-12-18T07:54:45Z" level=debug msg="finished setting up network namespace xvgguq97zh5c5iyxdlo6urg6k" sandbox.go:190: time="2024-12-18T07:54:45Z" level=info msg="found worker \"vezhyc72ohrrdvms2ymaxa4it\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:83cf1913431c org.mobyproject.buildkit.worker.network:cni org.mobyproject.buildkit.worker.oci.process-mode:sandbox org.mobyproject.buildkit.worker.sandbox:true org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:stargz], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/arm/v7 linux/arm/v6]" sandbox.go:190: time="2024-12-18T07:54:45Z" level=info msg="f

arg = outline.Args[1]
require.Equal(t, "sfx", arg.Name)
require.Equal(t, "usybox", arg.Value)
require.Equal(t, integration.UnixOrWindows("usybox", "anoserver"), arg.Value)
require.Equal(t, "is a suffix", arg.Description)
require.Equal(t, int32(5), arg.Location.Ranges[0].Start.Line)
require.Equal(t, int32(5+lineAdjust), arg.Location.Ranges[0].Start.Line) // 6

arg = outline.Args[2]
require.Equal(t, "FOO", arg.Name)
require.Equal(t, "123", arg.Value)
require.Equal(t, "", arg.Description)
require.Equal(t, int32(9), arg.Location.Ranges[0].Start.Line)
require.Equal(t, int32(9+lineAdjust), arg.Location.Ranges[0].Start.Line) // 10

arg = outline.Args[3]
require.Equal(t, "BAR", arg.Name)
Expand Down
132 changes: 90 additions & 42 deletions frontend/dockerfile/dockerfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1422,16 +1422,24 @@ COPY link/foo .
}

func testCopyThroughSymlinkMultiStage(t *testing.T, sb integration.Sandbox) {
integration.SkipOnPlatform(t, "windows")
f := getFrontend(t, sb)

dockerfile := []byte(`
dockerfile := []byte(integration.UnixOrWindows(
`
FROM busybox AS build
RUN mkdir -p /out/sub && ln -s /out/sub /sub && ln -s out/sub /sub2 && echo -n "data" > /sub/foo
FROM scratch
COPY --from=build /sub/foo .
COPY --from=build /sub2/foo bar
`)
`,
`
FROM nanoserver AS build
RUN mkdir out\sub && mklink /D sub out\sub && mklink /D sub2 out\sub && echo data> sub\foo
FROM nanoserver
COPY --from=build /sub/foo .
COPY --from=build /sub2/foo bar
`,
))

dir := integration.Tmpdir(
t,
Expand Down Expand Up @@ -1460,7 +1468,8 @@ COPY --from=build /sub2/foo bar

dt, err := os.ReadFile(filepath.Join(destDir, "foo"))
require.NoError(t, err)
require.Equal(t, "data", string(dt))
lineEnd := integration.UnixOrWindows("", "\r\n")
require.Equal(t, fmt.Sprintf("data%s", lineEnd), string(dt))
}

func testCopySocket(t *testing.T, sb integration.Sandbox) {
Expand Down Expand Up @@ -1599,13 +1608,13 @@ COPY --from=build /out .
}

func testGlobalArgErrors(t *testing.T, sb integration.Sandbox) {
integration.SkipOnPlatform(t, "windows")
f := getFrontend(t, sb)

dockerfile := []byte(`
imgName := integration.UnixOrWindows("busybox", "nanoserver")
dockerfile := []byte(fmt.Sprintf(`
ARG FOO=${FOO:?"custom error"}
FROM busybox
`)
FROM %s
`, imgName))

dir := integration.Tmpdir(
t,
Expand Down Expand Up @@ -1639,14 +1648,13 @@ FROM busybox
}

func testArgDefaultExpansion(t *testing.T, sb integration.Sandbox) {
integration.SkipOnPlatform(t, "windows")
f := getFrontend(t, sb)

dockerfile := []byte(`
FROM scratch
dockerfile := []byte(fmt.Sprintf(`
FROM %s
ARG FOO
ARG BAR=${FOO:?"foo missing"}
`)
`, integration.UnixOrWindows("scratch", "nanoserver")))

dir := integration.Tmpdir(
t,
Expand Down Expand Up @@ -1837,10 +1845,10 @@ COPY Dockerfile .
}

func testTargetStageNameArg(t *testing.T, sb integration.Sandbox) {
integration.SkipOnPlatform(t, "windows")
f := getFrontend(t, sb)

dockerfile := []byte(`
dockerfile := []byte(integration.UnixOrWindows(
`
FROM alpine AS base
WORKDIR /out
RUN echo -n "value:$TARGETSTAGE" > /out/first
Expand All @@ -1852,7 +1860,21 @@ COPY --from=base /out/ /
FROM scratch
COPY --from=base /out/ /
`)
`,
`
FROM nanoserver AS base
WORKDIR /out
RUN echo value:%TARGETSTAGE%> /out/first
ARG TARGETSTAGE
RUN echo value:%TARGETSTAGE%> /out/second
FROM nanoserver AS foo
COPY --from=base /out/ /
FROM nanoserver
COPY --from=base /out/ /
`,
))

dir := integration.Tmpdir(
t,
Expand Down Expand Up @@ -1884,11 +1906,13 @@ COPY --from=base /out/ /

dt, err := os.ReadFile(filepath.Join(destDir, "first"))
require.NoError(t, err)
require.Equal(t, "value:", string(dt))
valueStr := integration.UnixOrWindows("value:", "value:%TARGETSTAGE%\r\n")
require.Equal(t, valueStr, string(dt))

dt, err = os.ReadFile(filepath.Join(destDir, "second"))
require.NoError(t, err)
require.Equal(t, "value:foo", string(dt))
lineEnd := integration.UnixOrWindows("", "\r\n")
require.Equal(t, fmt.Sprintf("value:foo%s", lineEnd), string(dt))

destDir = t.TempDir()

Expand All @@ -1908,18 +1932,19 @@ COPY --from=base /out/ /

dt, err = os.ReadFile(filepath.Join(destDir, "first"))
require.NoError(t, err)
require.Equal(t, "value:", string(dt))
require.Equal(t, valueStr, string(dt))

dt, err = os.ReadFile(filepath.Join(destDir, "second"))
require.NoError(t, err)
require.Equal(t, "value:default", string(dt))
require.Equal(t, fmt.Sprintf("value:default%s", lineEnd), string(dt))

// stage name defined in Dockerfile but not passed in request
dockerfile = append(dockerfile, []byte(`
imgName := integration.UnixOrWindows("scratch", "nanoserver")
dockerfile = append(dockerfile, []byte(fmt.Sprintf(`
FROM scratch AS final
FROM %s AS final
COPY --from=base /out/ /
`)...)
`, imgName))...)

dir = integration.Tmpdir(
t,
Expand All @@ -1944,11 +1969,11 @@ COPY --from=base /out/ /

dt, err = os.ReadFile(filepath.Join(destDir, "first"))
require.NoError(t, err)
require.Equal(t, "value:", string(dt))
require.Equal(t, valueStr, string(dt))

dt, err = os.ReadFile(filepath.Join(destDir, "second"))
require.NoError(t, err)
require.Equal(t, "value:final", string(dt))
require.Equal(t, fmt.Sprintf("value:final%s", lineEnd), string(dt))
}

func testPowershellInDefaultPathOnWindows(t *testing.T, sb integration.Sandbox) {
Expand Down Expand Up @@ -2132,8 +2157,6 @@ COPY arch-$TARGETARCH whoami

// tonistiigi/fsutil#46
func testContextChangeDirToFile(t *testing.T, sb integration.Sandbox) {
// TODO(profnandaa): investigating flakyness on Windows CI
integration.SkipOnPlatform(t, "windows")
f := getFrontend(t, sb)

dockerfile := []byte(integration.UnixOrWindows(
Expand Down Expand Up @@ -6429,12 +6452,12 @@ COPY --from=build out /
}

func testTarContext(t *testing.T, sb integration.Sandbox) {
integration.SkipOnPlatform(t, "windows")
f := getFrontend(t, sb)

dockerfile := []byte(`
FROM scratch
COPY foo /`)
imgName := integration.UnixOrWindows("scratch", "nanoserver")
dockerfile := []byte(fmt.Sprintf(`
FROM %s
COPY foo /`, imgName))

foo := []byte("contents")

Expand Down Expand Up @@ -6478,7 +6501,6 @@ COPY foo /`)
}

func testTarContextExternalDockerfile(t *testing.T, sb integration.Sandbox) {
integration.SkipOnPlatform(t, "windows")
f := getFrontend(t, sb)

foo := []byte("contents")
Expand All @@ -6497,10 +6519,11 @@ func testTarContextExternalDockerfile(t *testing.T, sb integration.Sandbox) {
err = tw.Close()
require.NoError(t, err)

dockerfile := []byte(`
FROM scratch
imgName := integration.UnixOrWindows("scratch", "nanoserver")
dockerfile := []byte(fmt.Sprintf(`
FROM %s
COPY foo bar
`)
`, imgName))
dir := integration.Tmpdir(
t,
fstest.CreateFile("Dockerfile", dockerfile, 0600),
Expand Down Expand Up @@ -7664,7 +7687,6 @@ COPY --from=base /another /out2
}

func testNamedOCILayoutContext(t *testing.T, sb integration.Sandbox) {
integration.SkipOnPlatform(t, "windows")
workers.CheckFeatureCompat(t, sb, workers.FeatureOCIExporter, workers.FeatureOCILayout)
// how this test works:
// 1- we use a regular builder with a dockerfile to create an image two files: "out" with content "first", "out2" with content "second"
Expand All @@ -7680,13 +7702,22 @@ func testNamedOCILayoutContext(t *testing.T, sb integration.Sandbox) {
// create a tempdir where we will store the OCI layout
ocidir := t.TempDir()

ociDockerfile := []byte(`
ociDockerfile := []byte(integration.UnixOrWindows(
`
FROM busybox:latest
WORKDIR /test
RUN sh -c "echo -n first > out"
RUN sh -c "echo -n second > out2"
ENV foo=bar
`)
`,
`
FROM nanoserver
WORKDIR /test
RUN echo first> out"
RUN echo second> out2"
ENV foo=bar
`,
))
inDir := integration.Tmpdir(
t,
fstest.CreateFile("Dockerfile", ociDockerfile, 0600),
Expand Down Expand Up @@ -7744,7 +7775,8 @@ func testNamedOCILayoutContext(t *testing.T, sb integration.Sandbox) {
// 2. we override the context for `foo` to be our local OCI store, which has an `ENV foo=bar` override.
// As such, the `RUN echo $foo` step should have `$foo` set to `"bar"`, and so
// when we `COPY --from=imported`, it should have the content of `/outfoo` as `"bar"`
dockerfile := []byte(`
dockerfile := []byte(integration.UnixOrWindows(
`
FROM busybox AS base
RUN cat /etc/alpine-release > out
Expand All @@ -7754,7 +7786,20 @@ RUN echo -n $foo > outfoo
FROM scratch
COPY --from=base /test/o* /
COPY --from=imported /test/outfoo /
`)
`,
`
FROM nanoserver AS base
USER ContainerAdministrator
RUN ver > out
FROM foo AS imported
RUN echo %foo%> outfoo
FROM nanoserver
COPY --from=base /test/o* /
COPY --from=imported /test/outfoo /
`,
))

dir := integration.Tmpdir(
t,
Expand Down Expand Up @@ -7784,20 +7829,23 @@ COPY --from=imported /test/outfoo /
}, nil)
require.NoError(t, err)

// echo for Windows adds a \n
newLine := integration.UnixOrWindows("", "\r\n")

dt, err := os.ReadFile(filepath.Join(destDir, "out"))
require.NoError(t, err)
require.Greater(t, len(dt), 0)
require.Equal(t, []byte("first"), dt)
require.Equal(t, []byte("first"+newLine), dt)

dt, err = os.ReadFile(filepath.Join(destDir, "out2"))
require.NoError(t, err)
require.Greater(t, len(dt), 0)
require.Equal(t, []byte("second"), dt)
require.Equal(t, []byte("second"+newLine), dt)

dt, err = os.ReadFile(filepath.Join(destDir, "outfoo"))
require.NoError(t, err)
require.Greater(t, len(dt), 0)
require.Equal(t, []byte("bar"), dt)
require.Equal(t, []byte("bar"+newLine), dt)
}

func testNamedOCILayoutContextExport(t *testing.T, sb integration.Sandbox) {
Expand Down

0 comments on commit 723060b

Please sign in to comment.