[ARVADOS] updated: 87892d98eac028934480c378748cfb65a780d1cc

git at public.curoverse.com git at public.curoverse.com
Tue Sep 22 18:16:49 EDT 2015


Summary of changes:
 services/api/app/models/keep_service.rb            |   9 ++
 services/api/test/unit/keep_service_test.rb        |  32 +++++-
 services/arv-git-httpd/gitolite_test.go            |   4 +-
 .../keepstore/volume_keepstore_generic_test.go     | 117 +++++++++++++++++++++
 services/keepstore/volume_unix_test.go             |  18 ++++
 5 files changed, 175 insertions(+), 5 deletions(-)
 create mode 100644 services/keepstore/volume_keepstore_generic_test.go

       via  87892d98eac028934480c378748cfb65a780d1cc (commit)
       via  0fc6e0671e822cd4c5671519c7e7c58cff06c91f (commit)
       via  783a6278efb607b201df2781942a0b1c6a385929 (commit)
       via  7a029b844a155d7b90ccfbf4b81f80c886770591 (commit)
       via  61dbb7823ba00e7ae677956dab7994669ceff16d (commit)
       via  d37d7308827b4cc64272b5cc71f2adc4faf895a3 (commit)
      from  67c6f66d2b954f1f0f887011b7b6d5153b2d7bf1 (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 87892d98eac028934480c378748cfb65a780d1cc
Author: radhika <radhika at curoverse.com>
Date:   Tue Sep 22 18:16:15 2015 -0400

    7329: add generic volume based keepstore tests to have better functional test coverage.

diff --git a/services/keepstore/volume_keepstore_generic_test.go b/services/keepstore/volume_keepstore_generic_test.go
new file mode 100644
index 0000000..0e5df5b
--- /dev/null
+++ b/services/keepstore/volume_keepstore_generic_test.go
@@ -0,0 +1,117 @@
+package main
+
+import (
+	"bytes"
+	"testing"
+)
+
+// A TestableVolumeManagerFactory creates a volume manager with one or more TestableVolumes.
+// The factory function, and the TestableVolumes it returns, can use "t" to write
+// logs, fail the current test, etc.
+type TestableVolumeManagerFactory func(t *testing.T) []TestableVolume
+
+// DoGenericVolumeTests runs a set of tests that every TestableVolume
+// is expected to pass. It calls factory to create a new TestableVolume
+// for each test case, to avoid leaking state between tests.
+func DoGenericVolumeFunctionalTests(t *testing.T, factory TestableVolumeManagerFactory) {
+	testGetBlock(t, factory, TestHash, TestBlock)
+	testGetBlock(t, factory, EmptyHash, EmptyBlock)
+	testPutRawBadDataGetBlock(t, factory, TestHash, TestBlock, []byte("baddata"))
+	testPutRawBadDataGetBlock(t, factory, EmptyHash, EmptyBlock, []byte("baddata"))
+	testPutBlock(t, factory, TestHash, TestBlock)
+	testPutBlock(t, factory, EmptyHash, EmptyBlock)
+	testPutBlockCorrupt(t, factory, TestHash, TestBlock, []byte("baddata"))
+	testPutBlockCorrupt(t, factory, EmptyHash, EmptyBlock, []byte("baddata"))
+}
+
+// Put a block using PutRaw in just one volume and Get it using GetBlock
+func testGetBlock(t *testing.T, factory TestableVolumeManagerFactory, testHash string, testBlock []byte) {
+	testableVolumes := factory(t)
+	defer testableVolumes[0].Teardown()
+	defer testableVolumes[1].Teardown()
+	defer KeepVM.Close()
+
+	// Put testBlock in one volume
+	testableVolumes[1].PutRaw(testHash, testBlock)
+
+	// Get should pass
+	buf, err := GetBlock(testHash)
+	if err != nil {
+		t.Fatalf("Error while getting block %s", err)
+	}
+	if bytes.Compare(buf, testBlock) != 0 {
+		t.Errorf("Put succeeded but Get returned %+v, expected %+v", buf, testBlock)
+	}
+}
+
+// Put a bad block using PutRaw and get it.
+func testPutRawBadDataGetBlock(t *testing.T, factory TestableVolumeManagerFactory,
+	testHash string, testBlock []byte, badData []byte) {
+	testableVolumes := factory(t)
+	defer testableVolumes[0].Teardown()
+	defer testableVolumes[1].Teardown()
+	defer KeepVM.Close()
+
+	// Put bad data for testHash in both volumes
+	testableVolumes[0].PutRaw(testHash, badData)
+	testableVolumes[1].PutRaw(testHash, badData)
+
+	// Get should fail
+	_, err := GetBlock(testHash)
+	if err == nil {
+		t.Fatalf("Expected error while getting corrupt block %v", testHash)
+	}
+}
+
+// Invoke PutBlock twice to ensure CompareAndTouch path is tested.
+func testPutBlock(t *testing.T, factory TestableVolumeManagerFactory, testHash string, testBlock []byte) {
+	testableVolumes := factory(t)
+	defer testableVolumes[0].Teardown()
+	defer testableVolumes[1].Teardown()
+	defer KeepVM.Close()
+
+	// PutBlock
+	if err := PutBlock(testBlock, testHash); err != nil {
+		t.Fatalf("Error during PutBlock: %s", err)
+	}
+
+	// Check that PutBlock succeeds again even after CompareAndTouch
+	if err := PutBlock(testBlock, testHash); err != nil {
+		t.Fatalf("Error during PutBlock: %s", err)
+	}
+
+	// Check that PutBlock stored the data as expected
+	buf, err := GetBlock(testHash)
+	if err != nil {
+		t.Fatalf("Error during GetBlock for %q: %s", testHash, err)
+	} else if bytes.Compare(buf, testBlock) != 0 {
+		t.Errorf("Get response incorrect. Expected %q; found %q", testBlock, buf)
+	}
+}
+
+// Put a bad block using PutRaw, overwrite it using PutBlock and get it.
+func testPutBlockCorrupt(t *testing.T, factory TestableVolumeManagerFactory,
+	testHash string, testBlock []byte, badData []byte) {
+	testableVolumes := factory(t)
+	defer testableVolumes[0].Teardown()
+	defer testableVolumes[1].Teardown()
+	defer KeepVM.Close()
+
+	// Put bad data for testHash in both volumes
+	testableVolumes[0].PutRaw(testHash, badData)
+	testableVolumes[1].PutRaw(testHash, badData)
+
+	// Check that PutBlock with good data succeeds
+	if err := PutBlock(testBlock, testHash); err != nil {
+		t.Fatalf("Error during PutBlock for %q: %s", testHash, err)
+	}
+
+	// Put succeeded and overwrote the badData in one volume,
+	// and Get should return the testBlock now, ignoring the bad data.
+	buf, err := GetBlock(testHash)
+	if err != nil {
+		t.Fatalf("Error during GetBlock for %q: %s", testHash, err)
+	} else if bytes.Compare(buf, testBlock) != 0 {
+		t.Errorf("Get response incorrect. Expected %q; found %q", testBlock, buf)
+	}
+}
diff --git a/services/keepstore/volume_unix_test.go b/services/keepstore/volume_unix_test.go
index 35cf457..4fd6a30 100644
--- a/services/keepstore/volume_unix_test.go
+++ b/services/keepstore/volume_unix_test.go
@@ -85,6 +85,24 @@ func TestUnixVolumeWithGenericTestsSerialized(t *testing.T) {
 	})
 }
 
+// serialize = false; readonly = false
+func TestUnixVolumeManagerWithGenericTests(t *testing.T) {
+	DoGenericVolumeFunctionalTests(t, func(t *testing.T) []TestableVolume {
+		vols := make([]Volume, 2)
+		testableUnixVols := make([]TestableVolume, 2)
+
+		for i := range vols {
+			v := NewTestableUnixVolume(t, false, false)
+			vols[i] = v
+			testableUnixVols[i] = v
+		}
+
+		KeepVM = MakeRRVolumeManager(vols)
+
+		return testableUnixVols
+	})
+}
+
 func TestGetNotFound(t *testing.T) {
 	v := NewTestableUnixVolume(t, false, false)
 	defer v.Teardown()

commit 0fc6e0671e822cd4c5671519c7e7c58cff06c91f
Merge: 67c6f66 783a627
Author: radhika <radhika at curoverse.com>
Date:   Tue Sep 22 12:47:26 2015 -0400

    Merge branch 'master' into 7329-empty-block-issue


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


hooks/post-receive
-- 




More information about the arvados-commits mailing list