test: check for any stat change

The memstore doesn't seem to refresh kb_used, so we wait for anything to
change. It looks like num_objects changes for memstore.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
This commit is contained in:
Noah Watkins 2014-11-27 16:16:39 -08:00
parent a5f7bb1350
commit 802930e9e5
1 changed files with 14 additions and 7 deletions

View File

@ -85,16 +85,24 @@ func TestGetClusterStats(t *testing.T) {
pool, err := conn.OpenPool(poolname)
assert.NoError(t, err)
buf := make([]byte, 1<<22)
pool.Write("obj", buf, 0)
// grab current stats
prev_stat, err := conn.GetClusterStats()
assert.NoError(t, err)
// make some changes to the cluster
buf := make([]byte, 1<<20)
for i := 0; i < 10; i++ {
objname := GetUUID()
pool.Write(objname, buf, 0)
}
// wait a while for the stats to change
for i := 0; i < 30; i++ {
stat, err := conn.GetClusterStats()
assert.NoError(t, err)
// wait a second if stats are zero
if stat.Kb == 0 || stat.Kb_used == 0 ||
stat.Kb_avail == 0 || stat.Num_objects == 0 {
// wait for something to change
if stat == prev_stat {
fmt.Println("waiting for cluster stats to refresh")
time.Sleep(time.Second)
} else {
@ -104,9 +112,8 @@ func TestGetClusterStats(t *testing.T) {
}
}
t.Error("Cluster stats are zero")
conn.Shutdown()
t.Error("Cluster stats aren't changing")
}
func TestGetFSID(t *testing.T) {