|
50 | 50 | noCriu bool |
51 | 51 | supportsCriu bool |
52 | 52 | testNamespace = "testing" |
| 53 | + testSnapshotter = DefaultSnapshotter |
53 | 54 | ctrdStdioFilePath string |
54 | 55 |
|
55 | 56 | ctrd = &daemon{} |
@@ -132,11 +133,30 @@ func TestMain(m *testing.M) { |
132 | 133 |
|
133 | 134 | // allow comparison with containerd under test |
134 | 135 | log.G(ctx).WithFields(logrus.Fields{ |
135 | | - "version": version.Version, |
136 | | - "revision": version.Revision, |
137 | | - "runtime": os.Getenv("TEST_RUNTIME"), |
| 136 | + "version": version.Version, |
| 137 | + "revision": version.Revision, |
| 138 | + "runtime": os.Getenv("TEST_RUNTIME"), |
| 139 | + "snapshotter": os.Getenv("TEST_SNAPSHOTTER"), |
138 | 140 | }).Info("running tests against containerd") |
139 | 141 |
|
| 142 | + snapshotter := DefaultSnapshotter |
| 143 | + if ss := os.Getenv("TEST_SNAPSHOTTER"); ss != "" { |
| 144 | + snapshotter = ss |
| 145 | + } |
| 146 | + |
| 147 | + ns, ok := namespaces.Namespace(ctx) |
| 148 | + if !ok { |
| 149 | + fmt.Fprintln(os.Stderr, "error getting namespace") |
| 150 | + os.Exit(1) |
| 151 | + } |
| 152 | + err = client.NamespaceService().SetLabel(ctx, ns, defaults.DefaultSnapshotterNSLabel, snapshotter) |
| 153 | + if err != nil { |
| 154 | + fmt.Fprintf(os.Stderr, "error setting %s's default snapshotter as %s: %s\n", ns, snapshotter, err) |
| 155 | + os.Exit(1) |
| 156 | + } |
| 157 | + |
| 158 | + testSnapshotter = snapshotter |
| 159 | + |
140 | 160 | // pull a seed image |
141 | 161 | log.G(ctx).WithField("image", testImage).Info("start to pull seed image") |
142 | 162 | if _, err = client.Pull(ctx, testImage, WithPullUnpack); err != nil { |
@@ -285,7 +305,7 @@ func TestImagePullWithDiscardContent(t *testing.T) { |
285 | 305 | t.Fatalf("there is no layers in the target image(parent: %v)", img.Target()) |
286 | 306 | } |
287 | 307 | var ( |
288 | | - sn = client.SnapshotService("") |
| 308 | + sn = client.SnapshotService(testSnapshotter) |
289 | 309 | chain []digest.Digest |
290 | 310 | ) |
291 | 311 | for i, dgst := range layers { |
|
0 commit comments