Added rudimentary GetNodeStatus test. (refs #2561)
[arvados.git] / services / keep / keep_test.go
index 508e0cd5a07c86792f32756479feb159fee0f3ba..05eb410dd6c7c98db8f10cb434ba36a37d264170 100644 (file)
@@ -37,10 +37,6 @@ var BAD_BLOCK = []byte("The magic words are squeamish ossifrage.")
 //           - use an interface to mock ioutil.TempFile with a File
 //             object that always returns an error on write
 //
-//   * TestNodeStatus
-//       - test that GetNodeStatus returns a structure with expected
-//         values: need to mock FreeDiskSpace or Statfs, or use a tmpfs
-//
 // ========================================
 // GetBlock tests.
 // ========================================
@@ -320,6 +316,35 @@ func TestIndex(t *testing.T) {
        }
 }
 
+// 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.
+       KeepVolumes = setup(t, 2)
+
+       // Get node status and make a basic sanity check.
+       st := GetNodeStatus()
+       for i, vol := range KeepVolumes {
+               volinfo := st.Volumes[i]
+               mtp := volinfo.MountPoint
+               if mtp != vol {
+                       t.Errorf("GetNodeStatus mount_point %s != KeepVolume %s", mtp, vol)
+               }
+               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.
 // ========================================