[ARVADOS] updated: bde7e79b31d4265793e8617882bf411056a05c58

Git user git at public.curoverse.com
Tue Jul 19 23:41:53 EDT 2016


Summary of changes:
 services/keepstore/s3_volume_test.go | 91 ++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)

       via  bde7e79b31d4265793e8617882bf411056a05c58 (commit)
      from  5f2748238ff44a858c664b273156941e9bd90a6c (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 bde7e79b31d4265793e8617882bf411056a05c58
Author: Tom Clegg <tom at curoverse.com>
Date:   Tue Jul 19 23:41:49 2016 -0400

    8555: Test various storage states.

diff --git a/services/keepstore/s3_volume_test.go b/services/keepstore/s3_volume_test.go
index 73c6b76..f63e03f 100644
--- a/services/keepstore/s3_volume_test.go
+++ b/services/keepstore/s3_volume_test.go
@@ -2,8 +2,10 @@ package main
 
 import (
 	"bytes"
+	"crypto/md5"
 	"fmt"
 	"log"
+	"os"
 	"time"
 
 	"github.com/AdRoll/goamz/aws"
@@ -109,6 +111,95 @@ func (s *StubbedS3Suite) TestIndex(c *check.C) {
 	}
 }
 
+func (s *StubbedS3Suite) TestRaceStates(c *check.C) {
+	defer func(tl, bs time.Duration) {
+		trashLifetime = tl
+		blobSignatureTTL = bs
+	}(trashLifetime, blobSignatureTTL)
+	trashLifetime = time.Hour
+	blobSignatureTTL = time.Hour
+
+	v :=  NewTestableS3Volume(c, time.Minute, false, 2)
+	var none time.Time
+
+	stubKey := func(t time.Time, key string, data []byte) {
+		if t == none {
+			return
+		}
+		v.serverClock.now = &t
+		v.Bucket.Put(key, data, "application/octet-stream", s3ACL, s3.Options{})
+	}
+
+	t0 := time.Now()
+	nextKey := 0
+	for _, test := range []struct{
+		data time.Time
+		recent time.Time
+		trash time.Time
+		canGet bool
+		canTrash bool
+		canGetAfterTrash bool
+		canUntrash bool
+		canUntrashAfterEmpty bool
+	} {
+		{
+			// No related objects
+			none, none, none,
+			false, false, false, false, false},
+		{
+			// Stored by older version: recent/X missing
+			t0.Add(-2*time.Hour), none, none,
+			true, true, true, false, false},
+		{
+			// Normal, untrashed
+			t0.Add(-24*time.Hour), t0.Add(-2*time.Hour), none,
+			true, true, false, false, false},
+		{
+			// Normal, untrashed, too new to trash
+			t0.Add(-24*time.Hour), t0.Add(-30*time.Minute), none,
+			true, true, true, false, false},
+	} {
+		var loc string
+		var blk []byte
+
+		setup := func() {
+			nextKey++
+			blk = []byte(fmt.Sprintf("%d", nextKey))
+			loc = fmt.Sprintf("%x", md5.Sum(blk))
+			stubKey(test.data, loc, blk)
+			stubKey(test.recent, "recent/"+loc, nil)
+			stubKey(test.trash, "trash/"+loc, blk)
+			v.serverClock.now = &t0
+		}
+
+		setup()
+		buf := make([]byte, len(blk))
+		_, err := v.Get(loc, buf)
+		c.Check(err == nil, check.Equals, test.canGet)
+		if err != nil {
+			c.Check(os.IsNotExist(err), check.Equals, true)
+		}
+
+		setup()
+		err = v.Trash(loc)
+		c.Check(err == nil, check.Equals, test.canTrash)
+		_, err = v.Get(loc, buf)
+		c.Check(err == nil, check.Equals, test.canGetAfterTrash)
+		if err != nil {
+			c.Check(os.IsNotExist(err), check.Equals, true)
+		}
+
+		setup()
+		err = v.Untrash(loc)
+		c.Check(err == nil, check.Equals, test.canUntrash)
+
+		setup()
+		v.EmptyTrash()
+		err = v.Untrash(loc)
+		c.Check(err == nil, check.Equals, test.canUntrashAfterEmpty)
+	}
+}
+
 // PutRaw skips the ContentMD5 test
 func (v *TestableS3Volume) PutRaw(loc string, block []byte) {
 	err := v.Bucket.Put(loc, block, "application/octet-stream", s3ACL, s3.Options{})

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list