X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/9d4bc458b767e4c05024dfe02207283745e1ba06..143a5f355100b837daa428231df0370b525a1f9f:/services/keepstore/keepstore_test.go diff --git a/services/keepstore/keepstore_test.go b/services/keepstore/keepstore_test.go index 8874674592..b89925f5bd 100644 --- a/services/keepstore/keepstore_test.go +++ b/services/keepstore/keepstore_test.go @@ -60,7 +60,7 @@ func TestGetBlock(t *testing.T) { } // Check that GetBlock returns success. - result, err := GetBlock(TEST_HASH, false) + result, err := GetBlock(TEST_HASH) if err != nil { t.Errorf("GetBlock error: %s", err) } @@ -80,7 +80,7 @@ func TestGetBlockMissing(t *testing.T) { defer KeepVM.Close() // Check that GetBlock returns failure. - result, err := GetBlock(TEST_HASH, false) + result, err := GetBlock(TEST_HASH) if err != NotFoundError { t.Errorf("Expected NotFoundError, got %v", result) } @@ -101,7 +101,7 @@ func TestGetBlockCorrupt(t *testing.T) { vols[0].Put(TEST_HASH, BAD_BLOCK) // Check that GetBlock returns failure. - result, err := GetBlock(TEST_HASH, false) + result, err := GetBlock(TEST_HASH) if err != DiskHashError { t.Errorf("Expected DiskHashError, got %v (buf: %v)", err, result) } @@ -156,7 +156,7 @@ func TestPutBlockOneVol(t *testing.T) { t.Fatalf("PutBlock: %v", err) } - result, err := GetBlock(TEST_HASH, false) + result, err := GetBlock(TEST_HASH) if err != nil { t.Fatalf("GetBlock: %v", err) } @@ -185,7 +185,7 @@ func TestPutBlockMD5Fail(t *testing.T) { } // Confirm that GetBlock fails to return anything. - if result, err := GetBlock(TEST_HASH, false); err != NotFoundError { + if result, err := GetBlock(TEST_HASH); err != NotFoundError { t.Errorf("GetBlock succeeded after a corrupt block store (result = %s, err = %v)", string(result), err) } @@ -210,7 +210,7 @@ func TestPutBlockCorrupt(t *testing.T) { } // The block on disk should now match TEST_BLOCK. - if block, err := GetBlock(TEST_HASH, false); err != nil { + if block, err := GetBlock(TEST_HASH); err != nil { t.Errorf("GetBlock: %v", err) } else if bytes.Compare(block, TEST_BLOCK) != 0 { t.Errorf("GetBlock returned: '%s'", string(block)) @@ -394,8 +394,10 @@ func TestIndex(t *testing.T) { vols[0].Put(TEST_HASH+".meta", []byte("metadata")) vols[1].Put(TEST_HASH_2+".meta", []byte("metadata")) - index := vols[0].Index("") + vols[1].Index("") - index_rows := strings.Split(index, "\n") + buf := new(bytes.Buffer) + vols[0].IndexTo("", buf) + vols[1].IndexTo("", buf) + index_rows := strings.Split(string(buf.Bytes()), "\n") sort.Strings(index_rows) sorted_index := strings.Join(index_rows, "\n") expected := `^\n` + TEST_HASH + `\+\d+ \d+\n` + @@ -405,50 +407,13 @@ func TestIndex(t *testing.T) { match, err := regexp.MatchString(expected, sorted_index) if err == nil { if !match { - t.Errorf("IndexLocators returned:\n%s", index) + t.Errorf("IndexLocators returned:\n%s", string(buf.Bytes())) } } else { t.Errorf("regexp.MatchString: %s", err) } } -// TestNodeStatus -// Test that GetNodeStatus returns valid info about available volumes. -// -// TODO(twp): set up appropriate interfaces to permit more rigorous -// testing. -// -func TestNodeStatus(t *testing.T) { - defer teardown() - - // Set up test Keep volumes with some blocks. - KeepVM = MakeTestVolumeManager(2) - defer KeepVM.Close() - - vols := KeepVM.AllReadable() - vols[0].Put(TEST_HASH, TEST_BLOCK) - vols[1].Put(TEST_HASH_2, TEST_BLOCK_2) - - // Get node status and make a basic sanity check. - st := GetNodeStatus() - for i := range vols { - volinfo := st.Volumes[i] - mtp := volinfo.MountPoint - if mtp != "/bogo" { - t.Errorf("GetNodeStatus mount_point %s, expected /bogo", mtp) - } - if volinfo.DeviceNum == 0 { - t.Errorf("uninitialized device_num in %v", volinfo) - } - if volinfo.BytesFree == 0 { - t.Errorf("uninitialized bytes_free in %v", volinfo) - } - if volinfo.BytesUsed == 0 { - t.Errorf("uninitialized bytes_used in %v", volinfo) - } - } -} - // ======================================== // Helper functions for unit tests. // ========================================