Skip to content

Commit

Permalink
Tests build with local cache export
Browse files Browse the repository at this point in the history
   - to detect infinite loop caused by circular dependencies

Signed-off-by: Anca Iordache <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
  • Loading branch information
Anca Iordache authored and tonistiigi committed Mar 3, 2020
1 parent 0010996 commit 8c65b5b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func TestIntegration(t *testing.T) {
mirrors := integration.WithMirroredImages(integration.OfficialImages("busybox:latest", "alpine:latest"))

integration.Run(t, []integration.Test{
testLocalCacheExport,
testRelativeWorkDir,
testFileOpMkdirMkfile,
testFileOpCopyRm,
Expand Down Expand Up @@ -135,6 +136,41 @@ func newContainerd(cdAddress string) (*containerd.Client, error) {
return containerd.New(cdAddress, containerd.WithTimeout(60*time.Second), containerd.WithDefaultRuntime("io.containerd.runtime.v1.linux"))
}

func testLocalCacheExport(t *testing.T, sb integration.Sandbox) {
c, err := New(context.TODO(), sb.Address())
require.NoError(t, err)
defer c.Close()

tmpdir, err := ioutil.TempDir("", "buildkit-buildctl")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

err = ioutil.WriteFile(filepath.Join(tmpdir, "foo"), []byte("foodata"), 0600)
require.NoError(t, err)

buildbase := llb.Image("alpine:latest").File(llb.Copy(llb.Local("mylocal"), "foo", "foo"))
intermed := llb.Image("alpine:latest").File(llb.Copy(buildbase, "foo", "foo"))
final := llb.Scratch().File(llb.Copy(intermed, "foo", "foooooo"))

def, err := final.Marshal()
require.NoError(t, err)

_, err = c.Solve(context.TODO(), def, SolveOpt{
CacheExports: []CacheOptionsEntry{
{
Type: "local",
Attrs: map[string]string{
"dest": filepath.Join(tmpdir, "cache"),
},
},
},
LocalDirs: map[string]string{
"mylocal": tmpdir,
},
}, nil)
require.NoError(t, err)
}

func testBridgeNetworking(t *testing.T, sb integration.Sandbox) {
if os.Getenv("BUILDKIT_RUN_NETWORK_INTEGRATION_TESTS") == "" {
t.SkipNow()
Expand Down

0 comments on commit 8c65b5b

Please sign in to comment.