Browse code

Update migration test to use graphdriver env

Signed-off-by: Derek McGowan <derek@mcg.dev>

Derek McGowan authored on 2025/07/10 11:14:24
Showing 7 changed files
... ...
@@ -27,7 +27,7 @@ env:
27 27
   ITG_CLI_MATRIX_SIZE: 6
28 28
   DOCKER_EXPERIMENTAL: 1
29 29
   DOCKER_GRAPHDRIVER: ${{ inputs.storage == 'snapshotter' && 'overlayfs' || 'overlay2' }}
30
-  TEST_INTEGRATION_USE_SNAPSHOTTER: ${{ inputs.storage == 'snapshotter' && '1' || '' }}
30
+  TEST_INTEGRATION_USE_GRAPHDRIVER: ${{ inputs.storage == 'graphdriver' && '1' || '' }}
31 31
   SETUP_BUILDX_VERSION: edge
32 32
   SETUP_BUILDKIT_IMAGE: moby/buildkit:latest
33 33
 
... ...
@@ -364,10 +364,10 @@ jobs:
364 364
               "--exec-root=$env:TEMP\moby-exec", `
365 365
               "--pidfile=$env:TEMP\docker.pid", `
366 366
               "--register-service"
367
-          If ("${{ inputs.storage }}" -eq "snapshotter") {
367
+          If ("${{ inputs.storage }}" -eq "graphdriver") {
368 368
             # Make the env-var visible to the service-managed dockerd, as there's no CLI flag for this option.
369
-            & reg add "HKLM\SYSTEM\CurrentControlSet\Services\docker" /v Environment /t REG_MULTI_SZ /s '@' /d TEST_INTEGRATION_USE_SNAPSHOTTER=1 
370
-            echo "TEST_INTEGRATION_USE_SNAPSHOTTER=1" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
369
+            & reg add "HKLM\SYSTEM\CurrentControlSet\Services\docker" /v Environment /t REG_MULTI_SZ /s '@' /d TEST_INTEGRATION_USE_GRAPHDRIVER=1
370
+            echo "TEST_INTEGRATION_USE_GRAPHDRIVER=1" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
371 371
           }
372 372
           Write-Host "Starting service"
373 373
           Start-Service -Name docker
... ...
@@ -54,7 +54,7 @@ DOCKER_ENVS := \
54 54
 	-e GITHUB_ACTIONS \
55 55
 	-e TEST_FORCE_VALIDATE \
56 56
 	-e TEST_INTEGRATION_DIR \
57
-	-e TEST_INTEGRATION_USE_SNAPSHOTTER \
57
+	-e TEST_INTEGRATION_USE_GRAPHDRIVER \
58 58
 	-e TEST_INTEGRATION_FAIL_FAST \
59 59
 	-e TEST_SKIP_INTEGRATION \
60 60
 	-e TEST_SKIP_INTEGRATION_CLI \
... ...
@@ -210,7 +210,7 @@ test_env() {
210 210
 			PATH="$PATH" \
211 211
 			TEMP="$TEMP" \
212 212
 			TEST_CLIENT_BINARY="$TEST_CLIENT_BINARY" \
213
-			TEST_INTEGRATION_USE_SNAPSHOTTER="$TEST_INTEGRATION_USE_SNAPSHOTTER" \
213
+			TEST_INTEGRATION_USE_GRAPHDRIVER="$TEST_INTEGRATION_USE_GRAPHDRIVER" \
214 214
 			OTEL_EXPORTER_OTLP_ENDPOINT="$OTEL_EXPORTER_OTLP_ENDPOINT" \
215 215
 			OTEL_SERVICE_NAME="$OTEL_SERVICE_NAME" \
216 216
 			"$@"
... ...
@@ -15,7 +15,7 @@ source hack/make/.integration-test-helpers
15 15
 : "${PY_TEST_OPTIONS:=--junitxml=${DEST}/junit-report.xml}"
16 16
 
17 17
 # build --squash is not supported with containerd integration.
18
-if [ -n "$TEST_INTEGRATION_USE_SNAPSHOTTER" ]; then
18
+if [ -z "$TEST_INTEGRATION_USE_GRAPHDRIVER" ]; then
19 19
 	PY_TEST_OPTIONS="$PY_TEST_OPTIONS --deselect=tests/integration/api_build_test.py::BuildTest::test_build_squash"
20 20
 fi
21 21
 
... ...
@@ -9,6 +9,7 @@ import (
9 9
 
10 10
 	containertypes "github.com/moby/moby/api/types/container"
11 11
 	"github.com/moby/moby/api/types/image"
12
+	"github.com/moby/moby/client"
12 13
 	"github.com/moby/moby/v2/integration/internal/container"
13 14
 	"github.com/moby/moby/v2/testutil"
14 15
 	"github.com/moby/moby/v2/testutil/daemon"
... ...
@@ -27,7 +28,7 @@ func TestMigrateNativeSnapshotter(t *testing.T) {
27 27
 
28 28
 func testMigrateSnapshotter(t *testing.T, graphdriver, snapshotter string) {
29 29
 	skip.If(t, runtime.GOOS != "linux")
30
-	skip.If(t, os.Getenv("TEST_INTEGRATION_USE_SNAPSHOTTER") != "")
30
+	skip.If(t, os.Getenv("TEST_INTEGRATION_USE_GRAPHDRIVER") == "")
31 31
 
32 32
 	ctx := testutil.StartSpan(baseContext, t)
33 33
 
... ...
@@ -89,7 +90,7 @@ func testMigrateSnapshotter(t *testing.T, graphdriver, snapshotter string) {
89 89
 
90 90
 func TestMigrateSaveLoad(t *testing.T) {
91 91
 	skip.If(t, runtime.GOOS != "linux")
92
-	skip.If(t, os.Getenv("TEST_INTEGRATION_USE_SNAPSHOTTER") != "")
92
+	skip.If(t, os.Getenv("TEST_INTEGRATION_USE_GRAPHDRIVER") == "")
93 93
 
94 94
 	var (
95 95
 		ctx         = testutil.StartSpan(baseContext, t)
... ...
@@ -125,7 +126,7 @@ func TestMigrateSaveLoad(t *testing.T) {
125 125
 	apiClient := d.NewClientT(t)
126 126
 
127 127
 	// Save image to buffer
128
-	rdr, err := apiClient.ImageSave(ctx, []string{"busybox:latest"}, image.SaveOptions{})
128
+	rdr, err := apiClient.ImageSave(ctx, []string{"busybox:latest"})
129 129
 	assert.NilError(t, err)
130 130
 	buf := bytes.NewBuffer(nil)
131 131
 	io.Copy(buf, rdr)
... ...
@@ -135,7 +136,7 @@ func TestMigrateSaveLoad(t *testing.T) {
135 135
 	list, err := apiClient.ImageList(ctx, image.ListOptions{})
136 136
 	assert.NilError(t, err)
137 137
 	for _, i := range list {
138
-		_, err = apiClient.ImageRemove(ctx, i.ID, image.RemoveOptions{})
138
+		_, err = apiClient.ImageRemove(ctx, i.ID, image.RemoveOptions{Force: true})
139 139
 		assert.NilError(t, err)
140 140
 	}
141 141
 
... ...
@@ -144,7 +145,7 @@ func TestMigrateSaveLoad(t *testing.T) {
144 144
 	assert.Equal(t, info.Images, 0)
145 145
 
146 146
 	// Import
147
-	lr, err := apiClient.ImageLoad(ctx, bytes.NewReader(buf.Bytes()), image.LoadOptions{Quiet: true})
147
+	lr, err := apiClient.ImageLoad(ctx, bytes.NewReader(buf.Bytes()), client.ImageLoadWithQuiet(true))
148 148
 	assert.NilError(t, err)
149 149
 	io.Copy(io.Discard, lr.Body)
150 150
 	lr.Body.Close()
... ...
@@ -189,10 +189,9 @@ func (e *Execution) IsUserNamespaceInKernel() bool {
189 189
 }
190 190
 
191 191
 // UsingSnapshotter returns whether containerd snapshotters are used for the
192
-// tests by checking if the "TEST_INTEGRATION_USE_SNAPSHOTTER" is set to a
193
-// non-empty value.
192
+// tests by checking if the "TEST_INTEGRATION_USE_GRAPHDRIVER" is empty
194 193
 func (e *Execution) UsingSnapshotter() bool {
195
-	return os.Getenv("TEST_INTEGRATION_USE_SNAPSHOTTER") != ""
194
+	return os.Getenv("TEST_INTEGRATION_USE_GRAPHDRIVER") == ""
196 195
 }
197 196
 
198 197
 // HasExistingImage checks whether there is an image with the given reference.