[ARVADOS] updated: 20abe07b6780abb3a67292af4f4f8ffab988f9ca

git at public.curoverse.com git at public.curoverse.com
Tue Sep 8 00:38:56 EDT 2015


Summary of changes:
 services/keepstore/volume_generic_test.go | 46 +++++++++++++++++++++++++++++++
 services/keepstore/volume_unix_test.go    | 39 ++++----------------------
 2 files changed, 52 insertions(+), 33 deletions(-)
 create mode 100644 services/keepstore/volume_generic_test.go

       via  20abe07b6780abb3a67292af4f4f8ffab988f9ca (commit)
      from  8dd54802b2ada6da4fd6faac6e4fba2e82d2fb11 (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 20abe07b6780abb3a67292af4f4f8ffab988f9ca
Author: Tom Clegg <tom at curoverse.com>
Date:   Tue Sep 8 00:38:41 2015 -0400

    7179: Start a set of generic volume tests.

diff --git a/services/keepstore/volume_generic_test.go b/services/keepstore/volume_generic_test.go
new file mode 100644
index 0000000..20faf8f
--- /dev/null
+++ b/services/keepstore/volume_generic_test.go
@@ -0,0 +1,46 @@
+package main
+
+import (
+	"bytes"
+	"os"
+	"testing"
+	"time"
+)
+
+type TestableVolumeFactory func(t *testing.T) TestableVolume
+
+func DoGenericVolumeTests(t *testing.T, factory TestableVolumeFactory) {
+	testDeleteNewBlock(t, factory)
+	testDeleteOldBlock(t, factory)
+}
+
+func testDeleteNewBlock(t *testing.T, factory TestableVolumeFactory) {
+	v := factory(t)
+	defer v.Teardown()
+	v.Put(TEST_HASH, TEST_BLOCK)
+
+	if err := v.Delete(TEST_HASH); err != nil {
+		t.Error(err)
+	}
+	// This isn't reported as an error, but the block should not
+	// have been deleted: it's newer than blob_signature_ttl.
+	if data, err := v.Get(TEST_HASH); err != nil {
+		t.Error(err)
+	} else if bytes.Compare(data, TEST_BLOCK) != 0 {
+		t.Error("Block still present, but content is incorrect: %+v != %+v", data, TEST_BLOCK)
+	}
+}
+
+func testDeleteOldBlock(t *testing.T, factory TestableVolumeFactory) {
+	v := factory(t)
+	defer v.Teardown()
+	v.Put(TEST_HASH, TEST_BLOCK)
+	v.TouchWithDate(TEST_HASH, time.Now().Add(-2*blob_signature_ttl*time.Second))
+
+	if err := v.Delete(TEST_HASH); err != nil {
+		t.Error(err)
+	}
+	if _, err := v.Get(TEST_HASH); err == nil || !os.IsNotExist(err) {
+		t.Errorf("os.IsNotExist(%v) should have been true", err.Error())
+	}
+}
diff --git a/services/keepstore/volume_unix_test.go b/services/keepstore/volume_unix_test.go
index 83df9ce..b47bedb 100644
--- a/services/keepstore/volume_unix_test.go
+++ b/services/keepstore/volume_unix_test.go
@@ -59,6 +59,12 @@ func (v *TestableUnixVolume) Teardown() {
 	}
 }
 
+func TestUnixVolumeWithGenericTests(t *testing.T) {
+	DoGenericVolumeTests(t, func(t *testing.T) TestableVolume {
+		return NewTestableUnixVolume(t, false, false)
+	})
+}
+
 func TestGet(t *testing.T) {
 	v := NewTestableUnixVolume(t, false, false)
 	defer v.Teardown()
@@ -180,39 +186,6 @@ func TestUnixVolumeReadonly(t *testing.T) {
 	}
 }
 
-func TestUnixVolumeDeleteNewBlock(t *testing.T) {
-	v := NewTestableUnixVolume(t, false, false)
-	defer v.Teardown()
-
-	v.Put(TEST_HASH, TEST_BLOCK)
-
-	if err := v.Delete(TEST_HASH); err != nil {
-		t.Error(err)
-	}
-	// This isn't reported as an error, but the block should not
-	// have been deleted: it's newer than blob_signature_ttl.
-	if data, err := v.Get(TEST_HASH); err != nil {
-		t.Error(err)
-	} else if bytes.Compare(data, TEST_BLOCK) != 0 {
-		t.Error("Content incorrect after delete failed")
-	}
-}
-
-func TestUnixVolumeDeleteOldBlock(t *testing.T) {
-	v := NewTestableUnixVolume(t, false, false)
-	defer v.Teardown()
-
-	v.Put(TEST_HASH, TEST_BLOCK)
-	v.TouchWithDate(TEST_HASH, time.Now().Add(-2*blob_signature_ttl*time.Second))
-
-	if err := v.Delete(TEST_HASH); err != nil {
-		t.Error(err)
-	}
-	if _, err := v.Get(TEST_HASH); !os.IsNotExist(err) {
-		t.Errorf("os.IsNotExist(%v) should have been true", err.Error())
-	}
-}
-
 // TestPutTouch
 //     Test that when applying PUT to a block that already exists,
 //     the block's modification time is updated.

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list