Skip to content

Commit faa0cc7

Browse files
authored
Merge pull request moby#4029 from thaJeztah/0.12_backport_move_testutil
2 parents 18fc875 + ad68d6c commit faa0cc7

File tree

3 files changed

+41
-32
lines changed

3 files changed

+41
-32
lines changed

client/client_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import (
5757
"github.com/moby/buildkit/util/contentutil"
5858
"github.com/moby/buildkit/util/entitlements"
5959
"github.com/moby/buildkit/util/testutil"
60+
containerdutil "github.com/moby/buildkit/util/testutil/containerd"
6061
"github.com/moby/buildkit/util/testutil/echoserver"
6162
"github.com/moby/buildkit/util/testutil/httpserver"
6263
"github.com/moby/buildkit/util/testutil/integration"
@@ -3090,7 +3091,7 @@ func testSourceDateEpochImageExporter(t *testing.T, sb integration.Sandbox) {
30903091
t.SkipNow()
30913092
}
30923093
// https://github.com/containerd/containerd/commit/133ddce7cf18a1db175150e7a69470dea1bb3132
3093-
integration.CheckContainerdVersion(t, cdAddress, ">= 1.7.0-beta.1")
3094+
containerdutil.CheckVersion(t, cdAddress, ">= 1.7.0-beta.1")
30943095

30953096
integration.CheckFeatureCompat(t, sb, integration.FeatureSourceDateEpoch)
30963097
requiresLinux(t)
@@ -6260,7 +6261,7 @@ func testSourceMapFromRef(t *testing.T, sb integration.Sandbox) {
62606261

62616262
frontend := func(ctx context.Context, c gateway.Client) (*gateway.Result, error) {
62626263
st := llb.Scratch().File(
6263-
llb.Mkdir("foo/bar", 0600), //fails because /foo doesn't exist
6264+
llb.Mkdir("foo/bar", 0600), // fails because /foo doesn't exist
62646265
sm.Location([]*pb.Range{{Start: pb.Position{Line: 3, Character: 1}}}),
62656266
)
62666267

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package containerd
2+
3+
import (
4+
"context"
5+
"testing"
6+
"time"
7+
8+
"github.com/Masterminds/semver/v3"
9+
containerdpkg "github.com/containerd/containerd"
10+
)
11+
12+
func CheckVersion(t *testing.T, cdAddress, constraint string) {
13+
t.Helper()
14+
constraintSemVer, err := semver.NewConstraint(constraint)
15+
if err != nil {
16+
t.Fatal(err)
17+
}
18+
19+
cdClient, err := containerdpkg.New(cdAddress, containerdpkg.WithTimeout(60*time.Second))
20+
if err != nil {
21+
t.Fatal(err)
22+
}
23+
defer cdClient.Close()
24+
ctx := context.TODO()
25+
cdVersion, err := cdClient.Version(ctx)
26+
if err != nil {
27+
t.Fatal(err)
28+
}
29+
30+
cdVersionSemVer, err := semver.NewVersion(cdVersion.Version)
31+
if err != nil {
32+
t.Fatal(err)
33+
}
34+
35+
if !constraintSemVer.Check(cdVersionSemVer) {
36+
t.Skipf("containerd version %q does not satisfy the constraint %q", cdVersion.Version, constraint)
37+
}
38+
}

util/testutil/integration/sandbox.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313
"testing"
1414
"time"
1515

16-
"github.com/Masterminds/semver/v3"
17-
containerdpkg "github.com/containerd/containerd"
1816
"github.com/google/shlex"
1917
"github.com/moby/buildkit/util/bklog"
2018
"github.com/pkg/errors"
@@ -369,31 +367,3 @@ func CheckFeatureCompat(t *testing.T, sb Sandbox, reason ...string) {
369367
t.Skipf("%s worker can not currently run this test due to missing features (%s)", sb.Name(), strings.Join(ereasons, ", "))
370368
}
371369
}
372-
373-
func CheckContainerdVersion(t *testing.T, cdAddress, constraint string) {
374-
t.Helper()
375-
constraintSemVer, err := semver.NewConstraint(constraint)
376-
if err != nil {
377-
t.Fatal(err)
378-
}
379-
380-
cdClient, err := containerdpkg.New(cdAddress, containerdpkg.WithTimeout(60*time.Second))
381-
if err != nil {
382-
t.Fatal(err)
383-
}
384-
defer cdClient.Close()
385-
ctx := context.TODO()
386-
cdVersion, err := cdClient.Version(ctx)
387-
if err != nil {
388-
t.Fatal(err)
389-
}
390-
391-
cdVersionSemVer, err := semver.NewVersion(cdVersion.Version)
392-
if err != nil {
393-
t.Fatal(err)
394-
}
395-
396-
if !constraintSemVer.Check(cdVersionSemVer) {
397-
t.Skipf("containerd version %q does not satisfy the constraint %q", cdVersion.Version, constraint)
398-
}
399-
}

0 commit comments

Comments
 (0)