[ARVADOS] updated: 2.1.0-1056-g137121e22

Git user git at public.arvados.org
Thu Jul 15 13:44:47 UTC 2021


Summary of changes:
 lib/crunchrun/crunchrun.go           |  2 +-
 lib/crunchrun/crunchrun_test.go      | 12 ++++++-----
 sdk/go/arvados/fs_collection_test.go | 18 ++++++++---------
 sdk/go/keepclient/keepclient_test.go | 39 +++++++++++++++++++++++-------------
 4 files changed, 42 insertions(+), 29 deletions(-)

       via  137121e2292836e5f84155cb43410fb9049fbe2b (commit)
       via  e35858d2e0139091c924e74e43bc34f118152b85 (commit)
       via  599b46792b1b91662f9cea68193e9491ab03da83 (commit)
      from  3f38a38ae453390856b3d5cf2b4d5705df06ee13 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 137121e2292836e5f84155cb43410fb9049fbe2b
Author: Tom Clegg <tom at curii.com>
Date:   Thu Jul 15 09:44:17 2021 -0400

    17394: Update callback name.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/sdk/go/arvados/fs_collection_test.go b/sdk/go/arvados/fs_collection_test.go
index 74757bf7c..c032b0716 100644
--- a/sdk/go/arvados/fs_collection_test.go
+++ b/sdk/go/arvados/fs_collection_test.go
@@ -32,7 +32,7 @@ var _ = check.Suite(&CollectionFSSuite{})
 type keepClientStub struct {
 	blocks      map[string][]byte
 	refreshable map[string]bool
-	onPut       func(bufcopy []byte) // called from PutB, before acquiring lock
+	onWrite     func(bufcopy []byte) // called from WriteBlock, before acquiring lock
 	authToken   string               // client's auth token (used for signing locators)
 	sigkey      string               // blob signing key
 	sigttl      time.Duration        // blob signing ttl
@@ -58,8 +58,8 @@ func (kcs *keepClientStub) BlockWrite(_ context.Context, opts BlockWriteOptions)
 	locator := SignLocator(fmt.Sprintf("%x+%d", md5.Sum(opts.Data), len(opts.Data)), kcs.authToken, time.Now().Add(kcs.sigttl), kcs.sigttl, []byte(kcs.sigkey))
 	buf := make([]byte, len(opts.Data))
 	copy(buf, opts.Data)
-	if kcs.onPut != nil {
-		kcs.onPut(buf)
+	if kcs.onWrite != nil {
+		kcs.onWrite(buf)
 	}
 	for _, sc := range opts.StorageClasses {
 		if sc != "default" {
@@ -1086,7 +1086,7 @@ func (s *CollectionFSSuite) TestFlushFullBlocksWritingLongFile(c *check.C) {
 	proceed := make(chan struct{})
 	var started, concurrent int32
 	blk2done := false
-	s.kc.onPut = func([]byte) {
+	s.kc.onWrite = func([]byte) {
 		atomic.AddInt32(&concurrent, 1)
 		switch atomic.AddInt32(&started, 1) {
 		case 1:
@@ -1152,7 +1152,7 @@ func (s *CollectionFSSuite) TestFlushAll(c *check.C) {
 	fs, err := (&Collection{}).FileSystem(s.client, s.kc)
 	c.Assert(err, check.IsNil)
 
-	s.kc.onPut = func([]byte) {
+	s.kc.onWrite = func([]byte) {
 		// discard flushed data -- otherwise the stub will use
 		// unlimited memory
 		time.Sleep(time.Millisecond)
@@ -1196,7 +1196,7 @@ func (s *CollectionFSSuite) TestFlushFullBlocksOnly(c *check.C) {
 	c.Assert(err, check.IsNil)
 
 	var flushed int64
-	s.kc.onPut = func(p []byte) {
+	s.kc.onWrite = func(p []byte) {
 		atomic.AddInt64(&flushed, int64(len(p)))
 	}
 
@@ -1264,7 +1264,7 @@ func (s *CollectionFSSuite) TestMaxUnflushed(c *check.C) {
 	time.AfterFunc(10*time.Second, func() { close(timeout) })
 	var putCount, concurrency int64
 	var unflushed int64
-	s.kc.onPut = func(p []byte) {
+	s.kc.onWrite = func(p []byte) {
 		defer atomic.AddInt64(&unflushed, -int64(len(p)))
 		cur := atomic.AddInt64(&concurrency, 1)
 		defer atomic.AddInt64(&concurrency, -1)
@@ -1327,7 +1327,7 @@ func (s *CollectionFSSuite) TestFlushStress(c *check.C) {
 	})
 
 	wrote := 0
-	s.kc.onPut = func(p []byte) {
+	s.kc.onWrite = func(p []byte) {
 		s.kc.Lock()
 		s.kc.blocks = map[string][]byte{}
 		wrote++
@@ -1358,7 +1358,7 @@ func (s *CollectionFSSuite) TestFlushStress(c *check.C) {
 }
 
 func (s *CollectionFSSuite) TestFlushShort(c *check.C) {
-	s.kc.onPut = func([]byte) {
+	s.kc.onWrite = func([]byte) {
 		s.kc.Lock()
 		s.kc.blocks = map[string][]byte{}
 		s.kc.Unlock()

commit e35858d2e0139091c924e74e43bc34f118152b85
Author: Tom Clegg <tom at curii.com>
Date:   Thu Jul 15 09:42:21 2021 -0400

    17394: Use BlockWrite interface in crunch-run.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/lib/crunchrun/crunchrun.go b/lib/crunchrun/crunchrun.go
index 3c9c38161..23fbc430b 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 4b1bf8425..42a2cf3ad 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) {

commit 599b46792b1b91662f9cea68193e9491ab03da83
Author: Tom Clegg <tom at curii.com>
Date:   Thu Jul 15 09:27:25 2021 -0400

    17394: Test BlockWrite storage classes precedence.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/sdk/go/keepclient/keepclient_test.go b/sdk/go/keepclient/keepclient_test.go
index 724c66e13..c52e07b8f 100644
--- a/sdk/go/keepclient/keepclient_test.go
+++ b/sdk/go/keepclient/keepclient_test.go
@@ -6,6 +6,7 @@ package keepclient
 
 import (
 	"bytes"
+	"context"
 	"crypto/md5"
 	"errors"
 	"fmt"
@@ -20,6 +21,7 @@ import (
 	"testing"
 	"time"
 
+	"git.arvados.org/arvados.git/sdk/go/arvados"
 	"git.arvados.org/arvados.git/sdk/go/arvadosclient"
 	"git.arvados.org/arvados.git/sdk/go/arvadostest"
 	. "gopkg.in/check.v1"
@@ -244,19 +246,25 @@ func (s *StandaloneSuite) TestUploadWithStorageClasses(c *C) {
 func (s *StandaloneSuite) TestPutWithStorageClasses(c *C) {
 	nServers := 5
 	for _, trial := range []struct {
-		replicas    int
-		classes     []string
-		minRequests int
-		maxRequests int
-		success     bool
+		replicas      int
+		clientClasses []string
+		putClasses    []string // putClasses takes precedence over clientClasses
+		minRequests   int
+		maxRequests   int
+		success       bool
 	}{
-		{1, []string{"class1"}, 1, 1, true},
-		{2, []string{"class1"}, 1, 2, true},
-		{3, []string{"class1"}, 2, 3, true},
-		{1, []string{"class1", "class2"}, 1, 1, true},
-		{nServers*2 + 1, []string{"class1"}, nServers, nServers, false},
-		{1, []string{"class404"}, nServers, nServers, false},
-		{1, []string{"class1", "class404"}, nServers, nServers, false},
+		{1, []string{"class1"}, nil, 1, 1, true},
+		{2, []string{"class1"}, nil, 1, 2, true},
+		{3, []string{"class1"}, nil, 2, 3, true},
+		{1, []string{"class1", "class2"}, nil, 1, 1, true},
+		{3, nil, []string{"class1"}, 2, 3, true},
+		{1, nil, []string{"class1", "class2"}, 1, 1, true},
+		{1, []string{"class404"}, []string{"class1", "class2"}, 1, 1, true},
+		{1, []string{"class1"}, []string{"class404", "class2"}, nServers, nServers, false},
+		{nServers*2 + 1, []string{"class1"}, nil, nServers, nServers, false},
+		{1, []string{"class404"}, nil, nServers, nServers, false},
+		{1, []string{"class1", "class404"}, nil, nServers, nServers, false},
+		{1, nil, []string{"class1", "class404"}, nServers, nServers, false},
 	} {
 		c.Logf("%+v", trial)
 		st := &StubPutHandler{
@@ -272,7 +280,7 @@ func (s *StandaloneSuite) TestPutWithStorageClasses(c *C) {
 		arv, _ := arvadosclient.MakeArvadosClient()
 		kc, _ := MakeKeepClient(arv)
 		kc.Want_replicas = trial.replicas
-		kc.StorageClasses = trial.classes
+		kc.StorageClasses = trial.clientClasses
 		arv.ApiToken = "abc123"
 		localRoots := make(map[string]string)
 		writableLocalRoots := make(map[string]string)
@@ -283,7 +291,10 @@ func (s *StandaloneSuite) TestPutWithStorageClasses(c *C) {
 		}
 		kc.SetServiceRoots(localRoots, writableLocalRoots, nil)
 
-		_, _, err := kc.PutB([]byte("foo"))
+		_, err := kc.BlockWrite(context.Background(), arvados.BlockWriteOptions{
+			Data:           []byte("foo"),
+			StorageClasses: trial.putClasses,
+		})
 		if trial.success {
 			c.Check(err, check.IsNil)
 		} else {

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list