projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into 7167-keep-rsync-test-setup
[arvados.git]
/
services
/
keepstore
/
keepstore_test.go
diff --git
a/services/keepstore/keepstore_test.go
b/services/keepstore/keepstore_test.go
index 380731770dc7e28dd2b6963b833d2fdeaf3dcd32..9b132927c6a773a1d396e53da813e306698b5242 100644
(file)
--- a/
services/keepstore/keepstore_test.go
+++ b/
services/keepstore/keepstore_test.go
@@
-26,6
+26,10
@@
var TestHash3 = "eed29bbffbc2dbe5e5ee0bb71888e61f"
// It must not match any test hashes.
var BadBlock = []byte("The magic words are squeamish ossifrage.")
// It must not match any test hashes.
var BadBlock = []byte("The magic words are squeamish ossifrage.")
+// Empty block
+var EmptyHash = "d41d8cd98f00b204e9800998ecf8427e"
+var EmptyBlock = []byte("")
+
// TODO(twp): Tests still to be written
//
// * TestPutBlockFull
// TODO(twp): Tests still to be written
//
// * TestPutBlockFull
@@
-122,8
+126,8
@@
func TestPutBlockOK(t *testing.T) {
defer KeepVM.Close()
// Check that PutBlock stores the data as expected.
defer KeepVM.Close()
// Check that PutBlock stores the data as expected.
- if
err := PutBlock(TestBlock, TestHash); err != nil
{
- t.Fatalf("PutBlock:
%v"
, err)
+ if
n, err := PutBlock(TestBlock, TestHash); err != nil || n < 1
{
+ t.Fatalf("PutBlock:
n %d err %v", n
, err)
}
vols := KeepVM.AllReadable()
}
vols := KeepVM.AllReadable()
@@
-152,8
+156,8
@@
func TestPutBlockOneVol(t *testing.T) {
vols[0].(*MockVolume).Bad = true
// Check that PutBlock stores the data as expected.
vols[0].(*MockVolume).Bad = true
// Check that PutBlock stores the data as expected.
- if
err := PutBlock(TestBlock, TestHash); err != nil
{
- t.Fatalf("PutBlock:
%v"
, err)
+ if
n, err := PutBlock(TestBlock, TestHash); err != nil || n < 1
{
+ t.Fatalf("PutBlock:
n %d err %v", n
, err)
}
result, err := GetBlock(TestHash)
}
result, err := GetBlock(TestHash)
@@
-180,7
+184,7
@@
func TestPutBlockMD5Fail(t *testing.T) {
// Check that PutBlock returns the expected error when the hash does
// not match the block.
// Check that PutBlock returns the expected error when the hash does
// not match the block.
- if err := PutBlock(BadBlock, TestHash); err != RequestHashError {
+ if
_,
err := PutBlock(BadBlock, TestHash); err != RequestHashError {
t.Error("Expected RequestHashError, got %v", err)
}
t.Error("Expected RequestHashError, got %v", err)
}
@@
-205,8
+209,8
@@
func TestPutBlockCorrupt(t *testing.T) {
// Store a corrupted block under TestHash.
vols := KeepVM.AllWritable()
vols[0].Put(TestHash, BadBlock)
// Store a corrupted block under TestHash.
vols := KeepVM.AllWritable()
vols[0].Put(TestHash, BadBlock)
- if
err := PutBlock(TestBlock, TestHash); err != nil
{
- t.Errorf("PutBlock:
%v"
, err)
+ if
n, err := PutBlock(TestBlock, TestHash); err != nil || n < 1
{
+ t.Errorf("PutBlock:
n %d err %v", n
, err)
}
// The block on disk should now match TestBlock.
}
// The block on disk should now match TestBlock.
@@
-235,10
+239,10
@@
func TestPutBlockCollision(t *testing.T) {
// Store one block, then attempt to store the other. Confirm that
// PutBlock reported a CollisionError.
// Store one block, then attempt to store the other. Confirm that
// PutBlock reported a CollisionError.
- if err := PutBlock(b1, locator); err != nil {
+ if
_,
err := PutBlock(b1, locator); err != nil {
t.Error(err)
}
t.Error(err)
}
- if err := PutBlock(b2, locator); err == nil {
+ if
_,
err := PutBlock(b2, locator); err == nil {
t.Error("PutBlock did not report a collision")
} else if err != CollisionError {
t.Errorf("PutBlock returned %v", err)
t.Error("PutBlock did not report a collision")
} else if err != CollisionError {
t.Errorf("PutBlock returned %v", err)
@@
-269,8
+273,8
@@
func TestPutBlockTouchFails(t *testing.T) {
// vols[0].Touch will fail on the next call, so the volume
// manager will store a copy on vols[1] instead.
vols[0].(*MockVolume).Touchable = false
// vols[0].Touch will fail on the next call, so the volume
// manager will store a copy on vols[1] instead.
vols[0].(*MockVolume).Touchable = false
- if
err := PutBlock(TestBlock, TestHash); err != nil
{
- t.Fatalf("PutBlock:
%v"
, err)
+ if
n, err := PutBlock(TestBlock, TestHash); err != nil || n < 1
{
+ t.Fatalf("PutBlock:
n %d err %v", n
, err)
}
vols[0].(*MockVolume).Touchable = true
}
vols[0].(*MockVolume).Touchable = true
@@
-329,8
+333,8
@@
func TestDiscoverTmpfs(t *testing.T) {
f.Close()
ProcMounts = f.Name()
f.Close()
ProcMounts = f.Name()
- var resultVols volumeSet
- added :=
resultVols
.Discover()
+ resultVols := volumeSet{}
+ added :=
(&unixVolumeAdder{&resultVols})
.Discover()
if added != len(resultVols) {
t.Errorf("Discover returned %d, but added %d volumes",
if added != len(resultVols) {
t.Errorf("Discover returned %d, but added %d volumes",
@@
-369,8
+373,8
@@
func TestDiscoverNone(t *testing.T) {
f.Close()
ProcMounts = f.Name()
f.Close()
ProcMounts = f.Name()
- var resultVols volumeSet
- added :=
resultVols
.Discover()
+ resultVols := volumeSet{}
+ added :=
(&unixVolumeAdder{&resultVols})
.Discover()
if added != 0 || len(resultVols) != 0 {
t.Fatalf("got %d, %v; expected 0, []", added, resultVols)
}
if added != 0 || len(resultVols) != 0 {
t.Fatalf("got %d, %v; expected 0, []", added, resultVols)
}