X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/da57a99777f022ae6f6a4122c7940d00339f5503..66380d0e89c00559123ceda8e74e3b1487f4a95a:/services/keepstore/keepstore_test.go diff --git a/services/keepstore/keepstore_test.go b/services/keepstore/keepstore_test.go index 8874674592..e01b01363d 100644 --- a/services/keepstore/keepstore_test.go +++ b/services/keepstore/keepstore_test.go @@ -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. // ========================================