Skip to content

Commit b6a4965

Browse files
committed
client: add inline remote cache tests
Signed-off-by: Tonis Tiigi <[email protected]>
1 parent a09ba7c commit b6a4965

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

client/client_test.go

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ func TestClientIntegration(t *testing.T) {
8282
testSSHMount,
8383
testStdinClosed,
8484
testHostnameLookup,
85+
testBasicInlineCacheImportExport,
8586
},
8687
integration.WithMirroredImages(integration.OfficialImages("busybox:latest", "alpine:latest")),
8788
)
@@ -1252,6 +1253,79 @@ func testBasicLocalCacheImportExport(t *testing.T, sb integration.Sandbox) {
12521253
testBasicCacheImportExport(t, sb, o)
12531254
}
12541255

1256+
func testBasicInlineCacheImportExport(t *testing.T, sb integration.Sandbox) {
1257+
requiresLinux(t)
1258+
registry, err := sb.NewRegistry()
1259+
if errors.Cause(err) == integration.ErrorRequirements {
1260+
t.Skip(err.Error())
1261+
}
1262+
require.NoError(t, err)
1263+
1264+
c, err := New(context.TODO(), sb.Address())
1265+
require.NoError(t, err)
1266+
defer c.Close()
1267+
1268+
busybox := llb.Image("busybox:latest")
1269+
st := llb.Scratch()
1270+
1271+
run := func(cmd string) {
1272+
st = busybox.Run(llb.Shlex(cmd), llb.Dir("/wd")).AddMount("/wd", st)
1273+
}
1274+
1275+
run(`sh -c "echo -n foobar > const"`)
1276+
run(`sh -c "cat /dev/urandom | head -c 100 | sha256sum > unique"`)
1277+
1278+
def, err := st.Marshal()
1279+
require.NoError(t, err)
1280+
1281+
target := registry + "/buildkit/testexportinline:latest"
1282+
1283+
resp, err := c.Solve(context.TODO(), def, SolveOpt{
1284+
Exporter: ExporterImage,
1285+
ExporterAttrs: map[string]string{
1286+
"name": target,
1287+
"push": "true",
1288+
},
1289+
CacheExports: []CacheOptionsEntry{
1290+
{
1291+
Type: "inline",
1292+
},
1293+
},
1294+
}, nil)
1295+
require.NoError(t, err)
1296+
1297+
dgst, ok := resp.ExporterResponse["containerimage.digest"]
1298+
require.Equal(t, ok, true)
1299+
1300+
err = c.Prune(context.TODO(), nil, PruneAll)
1301+
require.NoError(t, err)
1302+
1303+
checkAllRemoved(t, c, sb)
1304+
1305+
resp, err = c.Solve(context.TODO(), def, SolveOpt{
1306+
Exporter: ExporterImage,
1307+
CacheExports: []CacheOptionsEntry{
1308+
{
1309+
Type: "inline",
1310+
},
1311+
},
1312+
CacheImports: []CacheOptionsEntry{
1313+
{
1314+
Type: "registry",
1315+
Attrs: map[string]string{
1316+
"ref": target,
1317+
},
1318+
},
1319+
},
1320+
}, nil)
1321+
require.NoError(t, err)
1322+
1323+
dgst2, ok := resp.ExporterResponse["containerimage.digest"]
1324+
require.Equal(t, ok, true)
1325+
1326+
require.Equal(t, dgst, dgst2)
1327+
}
1328+
12551329
func testCachedMounts(t *testing.T, sb integration.Sandbox) {
12561330
requiresLinux(t)
12571331
c, err := New(context.TODO(), sb.Address())

0 commit comments

Comments
 (0)