X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f69d2824c997c53caa11d30ba816768bad52e12b..4d6e05c25c6a5d72afee37f8165b006267b4183d:/services/keepstore/volume_unix_test.go diff --git a/services/keepstore/volume_unix_test.go b/services/keepstore/volume_unix_test.go index 6b39f8ff60..6bafa7c1ca 100644 --- a/services/keepstore/volume_unix_test.go +++ b/services/keepstore/volume_unix_test.go @@ -15,19 +15,20 @@ func TempUnixVolume(t *testing.T, serialize bool, readonly bool) *UnixVolume { if err != nil { t.Fatal(err) } - return MakeUnixVolume(d, serialize, readonly) + return &UnixVolume{ + root: d, + serialize: serialize, + readonly: readonly, + } } func _teardown(v *UnixVolume) { - if v.queue != nil { - close(v.queue) - } os.RemoveAll(v.root) } -// store writes a Keep block directly into a UnixVolume, for testing -// UnixVolume methods. -// +// _store writes a Keep block directly into a UnixVolume, bypassing +// the overhead and safeguards of Put(). Useful for storing bogus data +// and isolating unit tests from Put() behavior. func _store(t *testing.T, vol *UnixVolume, filename string, block []byte) { blockdir := fmt.Sprintf("%s/%s", vol.root, filename[:3]) if err := os.MkdirAll(blockdir, 0755); err != nil { @@ -325,3 +326,23 @@ func TestIsFull(t *testing.T) { t.Errorf("%s: should no longer be full", v) } } + +func TestNodeStatus(t *testing.T) { + v := TempUnixVolume(t, false, false) + defer _teardown(v) + + // Get node status and make a basic sanity check. + volinfo := v.Status() + if volinfo.MountPoint != v.root { + t.Errorf("GetNodeStatus mount_point %s, expected %s", volinfo.MountPoint, v.root) + } + 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) + } +}