[ARVADOS] updated: 2b37f7a8e843638431dc9e8031c1c2c2a81c1e7e

Git user git at public.curoverse.com
Thu Jan 26 23:22:50 EST 2017


Summary of changes:
 sdk/go/keepclient/collectionreader.go      |  6 +++-
 sdk/go/keepclient/collectionreader_test.go | 48 ++++++++++++++++++++----------
 2 files changed, 38 insertions(+), 16 deletions(-)

       via  2b37f7a8e843638431dc9e8031c1c2c2a81c1e7e (commit)
      from  1b8106da867aafbe6e4653485d5e644faee4c35d (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 2b37f7a8e843638431dc9e8031c1c2c2a81c1e7e
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Jan 26 22:46:06 2017 -0500

    10990: Fix collectionreader tests.

diff --git a/sdk/go/keepclient/collectionreader.go b/sdk/go/keepclient/collectionreader.go
index ca53ee5..d2a8260 100644
--- a/sdk/go/keepclient/collectionreader.go
+++ b/sdk/go/keepclient/collectionreader.go
@@ -51,7 +51,11 @@ func (kc *KeepClient) ManifestFileReader(m manifest.Manifest, filename string) (
 	f := &file{
 		kc: kc,
 	}
-	return f, f.load(m, filename)
+	err := f.load(m, filename)
+	if err != nil {
+		return nil, err
+	}
+	return f, nil
 }
 
 type file struct {
diff --git a/sdk/go/keepclient/collectionreader_test.go b/sdk/go/keepclient/collectionreader_test.go
index be4f386..6f49c59 100644
--- a/sdk/go/keepclient/collectionreader_test.go
+++ b/sdk/go/keepclient/collectionreader_test.go
@@ -121,6 +121,7 @@ func (s *CollectionReaderUnit) TestCollectionReaderContent(c *check.C) {
 		{mt: mt, f: "segmented/frob", want: "frob"},
 		{mt: mt, f: "segmented/oof", want: "oof"},
 	} {
+		c.Logf("%#v", testCase)
 		rdr, err := s.kc.CollectionFileReader(map[string]interface{}{"manifest_text": testCase.mt}, testCase.f)
 		switch want := testCase.want.(type) {
 		case error:
@@ -136,6 +137,23 @@ func (s *CollectionReaderUnit) TestCollectionReaderContent(c *check.C) {
 				c.Check(n, check.Equals, 0)
 				c.Check(err, check.Equals, io.EOF)
 			}
+
+			for a := len(want) - 2; a >= 0; a-- {
+				for b := a + 1; b <= len(want); b++ {
+					offset, err := rdr.Seek(int64(a), io.SeekStart)
+					c.Logf("...a=%d, b=%d", a, b)
+					c.Check(err, check.IsNil)
+					c.Check(offset, check.Equals, int64(a))
+					buf := make([]byte, b-a)
+					n, err := io.ReadFull(rdr, buf)
+					c.Check(n, check.Equals, b-a)
+					c.Check(string(buf), check.Equals, want[a:b])
+				}
+			}
+			offset, err := rdr.Seek(-1, io.SeekStart)
+			c.Check(err, check.NotNil)
+			c.Check(offset, check.Equals, int64(len(want)))
+
 			c.Check(rdr.Close(), check.Equals, nil)
 		}
 	}
@@ -168,13 +186,16 @@ func (s *CollectionReaderUnit) TestCollectionReaderManyBlocks(c *check.C) {
 }
 
 func (s *CollectionReaderUnit) TestCollectionReaderCloseEarly(c *check.C) {
+	s.kc.BlockCache = &BlockCache{}
 	s.kc.PutB([]byte("foo"))
+	s.kc.PutB([]byte("bar"))
+	s.kc.PutB([]byte("baz"))
 
 	mt := ". "
-	for i := 0; i < 1000; i++ {
-		mt += "acbd18db4cc2f85cedef654fccc4a4d8+3 "
+	for i := 0; i < 300; i++ {
+		mt += "acbd18db4cc2f85cedef654fccc4a4d8+3 37b51d194a7513e45b56f6524f2d51f2+3 73feffa4b7f6bb68e44cf984c85f6e88+3 "
 	}
-	mt += "0:3000:foo1000.txt\n"
+	mt += "0:2700:foo900.txt\n"
 
 	// Grab the stub server's lock, ensuring our cfReader doesn't
 	// get anything back from its first call to kc.Get() before we
@@ -182,17 +203,16 @@ func (s *CollectionReaderUnit) TestCollectionReaderCloseEarly(c *check.C) {
 	s.handler.lock <- struct{}{}
 	opsBeforeRead := *s.handler.ops
 
-	rdr, err := s.kc.CollectionFileReader(map[string]interface{}{"manifest_text": mt}, "foo1000.txt")
+	rdr, err := s.kc.CollectionFileReader(map[string]interface{}{"manifest_text": mt}, "foo900.txt")
 	c.Assert(err, check.IsNil)
 
 	firstReadDone := make(chan struct{})
 	go func() {
-		rdr.Read(make([]byte, 6))
-		firstReadDone <- struct{}{}
+		n, err := rdr.Read(make([]byte, 3))
+		c.Check(n, check.Equals, 3)
+		c.Check(err, check.IsNil)
+		close(firstReadDone)
 	}()
-	err = rdr.Close()
-	c.Assert(err, check.IsNil)
-	c.Assert(rdr.(*cfReader).Error(), check.IsNil)
 
 	// Release the stub server's lock. The first GET operation will proceed.
 	<-s.handler.lock
@@ -201,13 +221,11 @@ func (s *CollectionReaderUnit) TestCollectionReaderCloseEarly(c *check.C) {
 	// received from the first GET.
 	<-firstReadDone
 
-	// doGet() should close toRead before sending any more bufs to it.
-	if what, ok := <-rdr.(*cfReader).toRead; ok {
-		c.Errorf("Got %q, expected toRead to be closed", what)
-	}
+	err = rdr.Close()
+	c.Check(err, check.IsNil)
 
 	// Stub should have handled exactly one GET request.
-	c.Assert(*s.handler.ops, check.Equals, opsBeforeRead+1)
+	c.Check(*s.handler.ops, check.Equals, opsBeforeRead+1)
 }
 
 func (s *CollectionReaderUnit) TestCollectionReaderDataError(c *check.C) {
@@ -220,5 +238,5 @@ func (s *CollectionReaderUnit) TestCollectionReaderDataError(c *check.C) {
 		c.Check(err, check.NotNil)
 		c.Check(err, check.Not(check.Equals), io.EOF)
 	}
-	c.Check(rdr.Close(), check.NotNil)
+	c.Check(rdr.Close(), check.IsNil)
 }

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list