[ARVADOS] updated: a7ef84a9780f37b7ea27f29df6326d67869a03ac

git at public.curoverse.com git at public.curoverse.com
Wed Apr 2 01:19:25 EDT 2014


Summary of changes:
 services/keep/keep_test.go |   60 ++++++++++++++++++++++++++++++++++++++------
 1 files changed, 52 insertions(+), 8 deletions(-)

       via  a7ef84a9780f37b7ea27f29df6326d67869a03ac (commit)
      from  1a825caf53f352f63cafe10ef6211f4f689177e0 (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 a7ef84a9780f37b7ea27f29df6326d67869a03ac
Author: Tim Pierce <twp at curoverse.com>
Date:   Tue Apr 1 18:42:51 2014 -0400

    Added TestPutBlockOneVol and TestPutBlockCorrupt. (refs #2292, refs #2449)

diff --git a/services/keep/keep_test.go b/services/keep/keep_test.go
index 4795dad..81907e3 100644
--- a/services/keep/keep_test.go
+++ b/services/keep/keep_test.go
@@ -100,19 +100,35 @@ func TestPutBlockOK(t *testing.T) {
 	KeepVolumes = setup(t, 2)
 
 	// Check that PutBlock stores the data as expected.
-	err := PutBlock(TEST_BLOCK, TEST_HASH)
-	if err == nil {
-		t.Log("err is nil")
+	if err := PutBlock(TEST_BLOCK, TEST_HASH); err != nil {
+		t.Fatalf("PutBlock: %v", err)
 	}
+
+	result, err := GetBlock(TEST_HASH)
 	if err != nil {
-		t.Fatalf("PutBlock: %v", err)
+		t.Fatalf("GetBlock: %s", err.Error())
 	}
+	if string(result) != string(TEST_BLOCK) {
+		t.Error("PutBlock/GetBlock mismatch")
+		t.Fatalf("PutBlock stored '%s', GetBlock retrieved '%s'",
+			string(TEST_BLOCK), string(result))
+	}
+}
+
+// Test storing a block when only one volume (of many) is not available.
+func TestPutBlockOneVol(t *testing.T) {
+	defer teardown()
 
-	var result []byte
-	result, err = GetBlock(TEST_HASH)
-	t.Log("result = %v", result)
-	t.Log("err = %v", err)
+	// Create two test Keep volumes, but cripple one of them.
+	KeepVolumes = setup(t, 2)
+	os.Chmod(KeepVolumes[0], 000)
 
+	// Check that PutBlock stores the data as expected.
+	if err := PutBlock(TEST_BLOCK, TEST_HASH); err != nil {
+		t.Fatalf("PutBlock: %v", err)
+	}
+
+	result, err := GetBlock(TEST_HASH)
 	if err != nil {
 		t.Fatalf("GetBlock: %s", err.Error())
 	}
@@ -123,6 +139,34 @@ func TestPutBlockOK(t *testing.T) {
 	}
 }
 
+// TestPutBlockCorrupt
+//     Check that PutBlock returns an error if passed a block and hash that
+//     do not match.
+//
+func TestPutBlockCorrupt(t *testing.T) {
+	defer teardown()
+
+	// Create two test Keep volumes.
+	KeepVolumes = setup(t, 2)
+
+	// Check that PutBlock returns the expected error when the hash does
+	// not match the block.
+	if err := PutBlock(BAD_BLOCK, TEST_HASH); err == nil {
+		t.Error("PutBlock succeeded despite a block mismatch")
+	} else {
+		ke := err.(*KeepError)
+		if ke.HTTPCode != 401 || ke.Err.Error() != "MD5Fail" {
+			t.Errorf("PutBlock returned the wrong error (%v)", ke)
+		}
+	}
+
+	// Confirm that GetBlock fails to return anything.
+	if result, err := GetBlock(TEST_HASH); err == nil {
+		t.Errorf("GetBlock succeded after a corrupt block store, returned '%s'",
+			string(result))
+	}
+}
+
 // Test finding Keep volumes.
 func TestFindKeepVolumes(t *testing.T) {
 	defer teardown()

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list