[ARVADOS] updated: 9067fd12d2c4259a2988286663098c59af18c854

git at public.curoverse.com git at public.curoverse.com
Mon Apr 14 15:53:41 EDT 2014


Summary of changes:
 services/keep/keep.go      |   10 +++++-----
 services/keep/keep_test.go |   33 +++++++++++++++++++++++++++++----
 2 files changed, 34 insertions(+), 9 deletions(-)

       via  9067fd12d2c4259a2988286663098c59af18c854 (commit)
      from  8e69317214ad56a6255f56725fa3b966c663eda3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 9067fd12d2c4259a2988286663098c59af18c854
Author: Tim Pierce <twp at curoverse.com>
Date:   Mon Apr 14 15:54:26 2014 -0400

    Added rudimentary GetNodeStatus test. (refs #2561)
    
    Added GetNodeStatus unit test.
    Revised structure of NodeStatus struct to reflect the desired output format.

diff --git a/services/keep/keep.go b/services/keep/keep.go
index 6906610..7323c89 100644
--- a/services/keep/keep.go
+++ b/services/keep/keep.go
@@ -241,7 +241,7 @@ type VolumeStatus struct {
 }
 
 type NodeStatus struct {
-	Volumes map[string]*VolumeStatus `json:"volumes"`
+	Volumes []*VolumeStatus `json:"volumes"`
 }
 
 func StatusHandler(w http.ResponseWriter, req *http.Request) {
@@ -259,12 +259,12 @@ func StatusHandler(w http.ResponseWriter, req *http.Request) {
 //     Returns a NodeStatus struct describing this Keep
 //     node's current status.
 //
-func GetNodeStatus() NodeStatus {
+func GetNodeStatus() *NodeStatus {
 	st := new(NodeStatus)
 
-	st.Volumes = make(map[string]*VolumeStatus)
-	for _, vol := range KeepVolumes {
-		st.Volumes[vol] = GetVolumeStatus(vol)
+	st.Volumes = make([]*VolumeStatus, len(KeepVolumes))
+	for i, vol := range KeepVolumes {
+		st.Volumes[i] = GetVolumeStatus(vol)
 	}
 	return st
 }
diff --git a/services/keep/keep_test.go b/services/keep/keep_test.go
index 508e0cd..05eb410 100644
--- a/services/keep/keep_test.go
+++ b/services/keep/keep_test.go
@@ -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.
 // ========================================

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list