From e35858d2e0139091c924e74e43bc34f118152b85 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Thu, 15 Jul 2021 09:42:21 -0400 Subject: [PATCH] 17394: Use BlockWrite interface in crunch-run. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- lib/crunchrun/crunchrun.go | 2 +- lib/crunchrun/crunchrun_test.go | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/crunchrun/crunchrun.go b/lib/crunchrun/crunchrun.go index 3c9c381619..23fbc430b4 100644 --- a/lib/crunchrun/crunchrun.go +++ b/lib/crunchrun/crunchrun.go @@ -55,7 +55,7 @@ var ErrCancelled = errors.New("Cancelled") // IKeepClient is the minimal Keep API methods used by crunch-run. type IKeepClient interface { - PutB(buf []byte) (string, int, error) + BlockWrite(context.Context, arvados.BlockWriteOptions) (arvados.BlockWriteResponse, error) ReadAt(locator string, p []byte, off int) (int, error) ManifestFileReader(m manifest.Manifest, filename string) (arvados.File, error) LocalLocator(locator string) (string, error) diff --git a/lib/crunchrun/crunchrun_test.go b/lib/crunchrun/crunchrun_test.go index 4b1bf84255..42a2cf3ad8 100644 --- a/lib/crunchrun/crunchrun_test.go +++ b/lib/crunchrun/crunchrun_test.go @@ -307,9 +307,11 @@ func (client *KeepTestClient) LocalLocator(locator string) (string, error) { return locator, nil } -func (client *KeepTestClient) PutB(buf []byte) (string, int, error) { - client.Content = buf - return fmt.Sprintf("%x+%d", md5.Sum(buf), len(buf)), len(buf), nil +func (client *KeepTestClient) BlockWrite(_ context.Context, opts arvados.BlockWriteOptions) (arvados.BlockWriteResponse, error) { + client.Content = opts.Data + return arvados.BlockWriteResponse{ + Locator: fmt.Sprintf("%x+%d", md5.Sum(opts.Data), len(opts.Data)), + }, nil } func (client *KeepTestClient) ReadAt(string, []byte, int) (int, error) { @@ -455,8 +457,8 @@ func (*KeepErrorTestClient) ManifestFileReader(manifest.Manifest, string) (arvad return nil, errors.New("KeepError") } -func (*KeepErrorTestClient) PutB(buf []byte) (string, int, error) { - return "", 0, errors.New("KeepError") +func (*KeepErrorTestClient) BlockWrite(context.Context, arvados.BlockWriteOptions) (arvados.BlockWriteResponse, error) { + return arvados.BlockWriteResponse{}, errors.New("KeepError") } func (*KeepErrorTestClient) LocalLocator(string) (string, error) { -- 2.30.2