[ARVADOS] updated: 1080ec939aa8739d53384f70bf872fc42fdbd370

git at public.curoverse.com git at public.curoverse.com
Thu Aug 21 16:34:47 EDT 2014


Summary of changes:
 services/keepstore/handler_test.go | 28 ++++++++++++++++++++++++++++
 services/keepstore/volume.go       |  3 +++
 2 files changed, 31 insertions(+)

       via  1080ec939aa8739d53384f70bf872fc42fdbd370 (commit)
      from  dc2bf5c81e26595f336b4fee9cbb3f138ed76d31 (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 1080ec939aa8739d53384f70bf872fc42fdbd370
Author: Tim Pierce <twp at curoverse.com>
Date:   Thu Aug 21 16:33:50 2014 -0400

    3448: unit tests for deleting new blocks
    
    Added cases to TestDeleteHandler to test that blocks newer than
    -permission_ttl will not be removed from the volume even if
    volume.Delete() returned true.
    
    Refs #3448.

diff --git a/services/keepstore/handler_test.go b/services/keepstore/handler_test.go
index 64a417f..200e1b1 100644
--- a/services/keepstore/handler_test.go
+++ b/services/keepstore/handler_test.go
@@ -451,6 +451,11 @@ func TestDeleteHandler(t *testing.T) {
 	vols := KeepVM.Volumes()
 	vols[0].Put(TEST_HASH, TEST_BLOCK)
 
+	// Explicitly set the permission_ttl to 0 for these
+	// tests, to ensure the MockVolume deletes the blocks
+	// even though they have just been created.
+	permission_ttl = time.Duration(0)
+
 	// Set up a REST router for testing the handlers.
 	rest := MakeRESTRouter()
 
@@ -536,6 +541,29 @@ func TestDeleteHandler(t *testing.T) {
 	if !block_deleted {
 		t.Error("superuser_existing_block_req: block not deleted")
 	}
+
+	// A DELETE request on a block newer than permission_ttl should return
+	// success but leave the block on the volume.
+	vols[0].Put(TEST_HASH, TEST_BLOCK)
+	permission_ttl = time.Duration(1) * time.Hour
+
+	response = IssueRequest(rest, superuser_existing_block_req)
+	ExpectStatusCode(t,
+		"data manager request, existing block",
+		http.StatusOK,
+		response)
+	// Expect response {"copies_deleted":1,"copies_failed":0}
+	expected_dc = deletecounter{1, 0}
+	json.NewDecoder(response.Body).Decode(&response_dc)
+	if response_dc != expected_dc {
+		t.Errorf("superuser_existing_block_req\nexpected: %+v\nreceived: %+v",
+			expected_dc, response_dc)
+	}
+	// Confirm the block has NOT been deleted.
+	_, err = vols[0].Get(TEST_HASH)
+	if err != nil {
+		t.Errorf("testing delete on new block: %s\n", err)
+	}
 }
 
 // ====================
diff --git a/services/keepstore/volume.go b/services/keepstore/volume.go
index fbf63b7..0406c3d 100644
--- a/services/keepstore/volume.go
+++ b/services/keepstore/volume.go
@@ -79,6 +79,9 @@ func (v *MockVolume) Index(prefix string) string {
 
 func (v *MockVolume) Delete(loc string) error {
 	if _, ok := v.Store[loc]; ok {
+		if time.Since(v.Timestamps[loc]) < permission_ttl {
+			return nil
+		}
 		delete(v.Store, loc)
 		return nil
 	}

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list