@@ -82,6 +82,7 @@ func TestClientIntegration(t *testing.T) {
82
82
testSSHMount ,
83
83
testStdinClosed ,
84
84
testHostnameLookup ,
85
+ testBasicInlineCacheImportExport ,
85
86
},
86
87
integration .WithMirroredImages (integration .OfficialImages ("busybox:latest" , "alpine:latest" )),
87
88
)
@@ -1252,6 +1253,79 @@ func testBasicLocalCacheImportExport(t *testing.T, sb integration.Sandbox) {
1252
1253
testBasicCacheImportExport (t , sb , o )
1253
1254
}
1254
1255
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
+
1255
1329
func testCachedMounts (t * testing.T , sb integration.Sandbox ) {
1256
1330
requiresLinux (t )
1257
1331
c , err := New (context .TODO (), sb .Address ())
0 commit comments