-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
integration: basic s3 cache test #3398
Conversation
c42d841
to
2b76f8c
Compare
e4b5c2c
to
3782abf
Compare
53b4e00
to
0aaf62b
Compare
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
0aaf62b
to
05c4d57
Compare
@@ -4672,6 +4673,44 @@ func testBasicLocalCacheImportExport(t *testing.T, sb integration.Sandbox) { | |||
testBasicCacheImportExport(t, sb, []CacheOptionsEntry{im}, []CacheOptionsEntry{ex}) | |||
} | |||
|
|||
func testBasicS3CacheImportExport(t *testing.T, sb integration.Sandbox) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only one case. @crazy-max do you want help for others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the basic one is fine for this use case:
buildkit/client/client_test.go
Lines 4556 to 4616 in 05c4d57
func testBasicCacheImportExport(t *testing.T, sb integration.Sandbox, cacheOptionsEntryImport, cacheOptionsEntryExport []CacheOptionsEntry) { | |
requiresLinux(t) | |
c, err := New(sb.Context(), sb.Address()) | |
require.NoError(t, err) | |
defer c.Close() | |
busybox := llb.Image("busybox:latest") | |
st := llb.Scratch() | |
run := func(cmd string) { | |
st = busybox.Run(llb.Shlex(cmd), llb.Dir("/wd")).AddMount("/wd", st) | |
} | |
run(`sh -c "echo -n foobar > const"`) | |
run(`sh -c "cat /dev/urandom | head -c 100 | sha256sum > unique"`) | |
def, err := st.Marshal(sb.Context()) | |
require.NoError(t, err) | |
destDir := t.TempDir() | |
_, err = c.Solve(sb.Context(), def, SolveOpt{ | |
Exports: []ExportEntry{ | |
{ | |
Type: ExporterLocal, | |
OutputDir: destDir, | |
}, | |
}, | |
CacheExports: cacheOptionsEntryExport, | |
}, nil) | |
require.NoError(t, err) | |
dt, err := os.ReadFile(filepath.Join(destDir, "const")) | |
require.NoError(t, err) | |
require.Equal(t, string(dt), "foobar") | |
dt, err = os.ReadFile(filepath.Join(destDir, "unique")) | |
require.NoError(t, err) | |
ensurePruneAll(t, c, sb) | |
destDir = t.TempDir() | |
_, err = c.Solve(sb.Context(), def, SolveOpt{ | |
Exports: []ExportEntry{ | |
{ | |
Type: ExporterLocal, | |
OutputDir: destDir, | |
}}, | |
CacheImports: cacheOptionsEntryImport, | |
}, nil) | |
require.NoError(t, err) | |
dt2, err := os.ReadFile(filepath.Join(destDir, "const")) | |
require.NoError(t, err) | |
require.Equal(t, string(dt2), "foobar") | |
dt2, err = os.ReadFile(filepath.Join(destDir, "unique")) | |
require.NoError(t, err) | |
require.Equal(t, string(dt), string(dt2)) | |
} |
If you think about ones specific to s3, we can do that in follow-ups.
@bpaquet As discussed with @tonistiigi I will open a follow-up to check the bucket content like you've done. If you want to do it, let me know. |
Is this fixing importing cache from several targets (multi stage builds)? Currently that's not working very well and I cannot find much documentation to ping-pong what's going on. |
Adds basic integration test for s3 cache so we can get rid of the one from hack folder. Also pin busybox in current azblob_test related to #3469.
cc @bpaquet