mirror of https://github.com/ceph/go-ceph
test: add data to cluster before stat
For an empty cluster we need to write data into the cluster so cluster stats come back as non-zero. This also adds a max 30 second delay to wait for the stats to update. Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
This commit is contained in:
parent
b8609f826c
commit
222a935b40
|
@ -74,12 +74,35 @@ func TestGetClusterStats(t *testing.T) {
|
||||||
conn.ReadDefaultConfigFile()
|
conn.ReadDefaultConfigFile()
|
||||||
conn.Connect()
|
conn.Connect()
|
||||||
|
|
||||||
|
poolname := GetUUID()
|
||||||
|
err := conn.MakePool(poolname)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
pool, err := conn.OpenPool(poolname)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
buf := make([]byte, 1<<22)
|
||||||
|
pool.Write("obj", buf, 0)
|
||||||
|
|
||||||
|
for i := 0; i < 30; i++ {
|
||||||
stat, err := conn.GetClusterStats()
|
stat, err := conn.GetClusterStats()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.True(t, stat.Kb > 0)
|
|
||||||
assert.True(t, stat.Kb_used > 0)
|
// wait a second if stats are zero
|
||||||
assert.True(t, stat.Kb_avail > 0)
|
if stat.Kb == 0 || stat.Kb_used == 0 ||
|
||||||
assert.True(t, stat.Num_objects > 0)
|
stat.Kb_avail == 0 || stat.Num_objects == 0 {
|
||||||
|
fmt.Println("waiting for cluster stats to refresh")
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
} else {
|
||||||
|
// success
|
||||||
|
conn.Shutdown()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Error("Cluster stats are zero")
|
||||||
|
|
||||||
|
conn.Shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetFSID(t *testing.T) {
|
func TestGetFSID(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue