mirror of https://github.com/ceph/go-ceph
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:
parent
a5f7bb1350
commit
802930e9e5
|
@ -85,16 +85,24 @@ func TestGetClusterStats(t *testing.T) {
|
||||||
pool, err := conn.OpenPool(poolname)
|
pool, err := conn.OpenPool(poolname)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
buf := make([]byte, 1<<22)
|
// grab current stats
|
||||||
pool.Write("obj", buf, 0)
|
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++ {
|
for i := 0; i < 30; i++ {
|
||||||
stat, err := conn.GetClusterStats()
|
stat, err := conn.GetClusterStats()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
// wait a second if stats are zero
|
// wait for something to change
|
||||||
if stat.Kb == 0 || stat.Kb_used == 0 ||
|
if stat == prev_stat {
|
||||||
stat.Kb_avail == 0 || stat.Num_objects == 0 {
|
|
||||||
fmt.Println("waiting for cluster stats to refresh")
|
fmt.Println("waiting for cluster stats to refresh")
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
} else {
|
} else {
|
||||||
|
@ -104,9 +112,8 @@ func TestGetClusterStats(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Error("Cluster stats are zero")
|
|
||||||
|
|
||||||
conn.Shutdown()
|
conn.Shutdown()
|
||||||
|
t.Error("Cluster stats aren't changing")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetFSID(t *testing.T) {
|
func TestGetFSID(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue