Skip to content

Commit 4b1a6be

Browse files
committed
Proofing
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
1 parent 27f0c49 commit 4b1a6be

File tree

11 files changed

+469
-20
lines changed

11 files changed

+469
-20
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,18 @@ jobs:
138138
# To avoid that, we explicitly list the architectures we do want emulation for.
139139
docker run --privileged --rm tonistiigi/binfmt --install linux/amd64
140140
docker run --privileged --rm tonistiigi/binfmt --install linux/arm64
141+
- name: "Mock services"
142+
run: |
143+
CLI=docker ./mod/proofing/spoof.sh server::start ./mod/proofing/.env
141144
- name: "Run integration tests"
142-
run: docker run -t --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky=false
145+
run: |
146+
docker run -t --rm \
147+
--env PROOFING_IP=$(docker inspect proofing-spoofer -f '{{ .NetworkSettings.IPAddress }}') \
148+
--privileged test-integration ./hack/test-integration.sh -test.only-flaky=false
143149
- name: "Run integration tests (flaky)"
144-
run: docker run -t --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky=true
150+
run: |
151+
docker run -t --rm \
152+
--privileged test-integration ./hack/test-integration.sh -test.only-flaky=true
145153
146154
test-integration-ipv6:
147155
needs: build-dependencies

cmd/nerdctl/builder/builder_builder_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ CMD ["echo", "nerdctl-builder-debug-test-string"]`, testutil.CommonImage)
152152
// FIXME: this test should be rewritten to dynamically retrieve the ids, and use images
153153
// available on all platforms
154154
oldImage := testutil.BusyboxImage
155-
oldImageSha := "7b3ccabffc97de872a30dfd234fd972a66d247c8cfc69b0550f276481852627c"
155+
oldImageSha := "07b7d0e283515a078e1d5b23d41e0db4d41211878612de51c0935490c76aec1c"
156156
newImage := testutil.AlpineImage
157-
newImageSha := "ec14c7992a97fc11425907e908340c6c3d6ff602f5f13d899e6b7027c9b4133a"
157+
newImageSha := "00b9b8f7ecae6f64741cf4f8f96abce0ac070ccac85fa7866890a0b6dcfb0aad"
158158

159159
helpers.Ensure("pull", "--quiet", oldImage)
160160
helpers.Ensure("tag", oldImage, newImage)

cmd/nerdctl/container/container_run_mount_linux_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package container
1818

1919
import (
2020
"fmt"
21+
"github.com/containerd/nerdctl/mod/tigron/tig"
2122
"os"
2223
"path/filepath"
2324
"strings"
@@ -307,7 +308,7 @@ func TestRunBindMountTmpfs(t *testing.T) {
307308
}
308309

309310
func mountExistsWithOpt(mountPoint, mountOpt string) test.Comparator {
310-
return func(stdout, info string, t *testing.T) {
311+
return func(stdout string, t tig.T) {
311312
lines := strings.Split(strings.TrimSpace(stdout), "\n")
312313
mountOutput := []string{}
313314
for _, line := range lines {

cmd/nerdctl/image/image_history_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,22 +134,22 @@ func TestImageHistory(t *testing.T) {
134134
Expected: test.Expects(0, nil, func(stdout string, t tig.T) {
135135
history, err := decode(stdout)
136136
assert.NilError(t, err, "decode should not fail")
137-
assert.Equal(t, history[1].Snapshot, "sha256:56bf55b8eed1f0b4794a30386e4d1d3da949c25bcb5155e898097cd75dc77c2a")
137+
assert.Equal(t, history[1].Snapshot, "sha256:a16e98724c05975ee8c40d8fe389c3481373d34ab20a1cf52ea2accc43f71f4c")
138138
assert.Equal(t, history[1].CreatedBy, "/bin/sh -c #(nop) ADD file:3b16ffee2b26d8af5db152fcc582aaccd9e1ec9e3343874e9969a205550fe07d in / ")
139139
}),
140140
},
141141
{
142142
Description: "Quiet has no effect with format, so, go no-json, no-trunc",
143143
Command: test.Command("image", "history", "--human=false", "--no-trunc", "--quiet", testutil.CommonImage),
144144
Expected: test.Expects(0, nil, func(stdout string, t tig.T) {
145-
assert.Equal(t, stdout, "<missing>\nsha256:56bf55b8eed1f0b4794a30386e4d1d3da949c25bcb5155e898097cd75dc77c2a\n")
145+
assert.Equal(t, stdout, "<missing>\nsha256:a16e98724c05975ee8c40d8fe389c3481373d34ab20a1cf52ea2accc43f71f4c\n")
146146
}),
147147
},
148148
{
149149
Description: "With quiet, trunc has no effect",
150150
Command: test.Command("image", "history", "--human=false", "--no-trunc", "--quiet", testutil.CommonImage),
151151
Expected: test.Expects(0, nil, func(stdout string, t tig.T) {
152-
assert.Equal(t, stdout, "<missing>\nsha256:56bf55b8eed1f0b4794a30386e4d1d3da949c25bcb5155e898097cd75dc77c2a\n")
152+
assert.Equal(t, stdout, "<missing>\nsha256:a16e98724c05975ee8c40d8fe389c3481373d34ab20a1cf52ea2accc43f71f4c\n")
153153
}),
154154
},
155155
},

hack/test-integration.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ if [[ "$(id -u)" = "0" ]]; then
2626
fi
2727
fi
2828

29+
# If we are being asked to use the proofing system, configure it
30+
if [ "${PROOFING_IP:-}" != "" ]; then
31+
"$root"/mod/proofing/spoof.sh guest::configure "$root"/mod/proofing/.env "$PROOFING_IP"
32+
fi
33+
2934
readonly timeout="60m"
3035
readonly retries="2"
3136
readonly needsudo="${WITH_SUDO:-}"

mod/proofing/.env

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This is the minimal env file you need to have
2+
# You must at least point to a usable docker registry image
3+
REGISTRY=registry:3.0.0@sha256:1fc7de654f2ac1247f0b67e8a459e273b0993be7d2beda1f3f56fbf1001ed3e7
4+
5+
# You can then add below whatever image you want mocked, for any origin.
6+
# Short syntax is accepted (eg: `busybox`, or `library:busybox`) though you MUST provide a tag AND a digest
7+
8+
# Examples:
9+
# NANOSERVER=mcr.microsoft.com/windows/nanoserver:ltsc2022@sha256:16b61ffac72961551c4b5312a7ab3da7c3dc3258510e40bee309e6e51f006ac6
10+
# DEBIAN=debian:bookworm-slim@sha256:b1211f6d19afd012477bd34fdcabb6b663d680e0f4b0537da6e6b0fd057a3ec3

mod/proofing/forward.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright The containerd Authors.
4+
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# shellcheck disable=SC2034,SC2015
18+
set -o errexit -o errtrace -o functrace -o nounset -o pipefail
19+
20+
# Extract the list of domains from image names in the environment
21+
extract::domains(){
22+
local fd="$1"
23+
24+
local image
25+
local domain
26+
local ignore
27+
28+
while read -r image; do
29+
IFS=" " read -r domain ignore <<<"$image"
30+
printf "%s\n" "$domain"
31+
done < <(extract::images "$1") | sort | uniq
32+
}
33+
34+
# Extract the list of images from the file.
35+
extract::images(){
36+
local fd="$1"
37+
local image
38+
local ref
39+
local domain
40+
local owner
41+
local name
42+
local tag
43+
local digest
44+
45+
while read -r image; do
46+
[ "$image" != "" ] && [ "${image:0:1}" != "#" ] || continue
47+
image="${image#*=}"
48+
digest="${image#*@}"
49+
tag="${image#*:}"
50+
tag="${tag%@*}"
51+
ref="${image%%:*}"
52+
53+
IFS=/ read -r domain owner name <<<"$ref"
54+
[ "$owner" != "" ] || {
55+
name="$domain"
56+
owner=library
57+
domain=docker.io
58+
}
59+
[ "$name" != "" ] || {
60+
name="$owner"
61+
owner="$domain"
62+
domain=docker.io
63+
}
64+
65+
printf "%s %s %s %s\n" "$domain" "$owner/$name" "$tag" "$digest"
66+
done <"$fd" | sort | uniq
67+
}
68+
69+
"extract::$1" "$2"

0 commit comments

Comments
 (0)