Browse Source

integration: test snapshot inflights metrics

Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
Gyuho Lee 6 years ago
parent
commit
a4badc33a3
1 changed files with 19 additions and 1 deletions
  1. 19 1
      integration/v3_watch_restore_test.go

+ 19 - 1
integration/v3_watch_restore_test.go

@@ -71,7 +71,25 @@ func TestV3WatchRestoreSnapshotUnsync(t *testing.T) {
 	// trigger snapshot send from leader to this slow follower
 	// trigger snapshot send from leader to this slow follower
 	// which then calls watchable store Restore
 	// which then calls watchable store Restore
 	clus.Members[0].RecoverPartition(t, clus.Members[1:]...)
 	clus.Members[0].RecoverPartition(t, clus.Members[1:]...)
-	clus.WaitLeader(t)
+	lead := clus.WaitLeader(t)
+
+	sends, err := clus.Members[lead].Metric("etcd_network_snapshot_send_inflights_total")
+	if err != nil {
+		t.Fatal(err)
+	}
+	if sends != "0" && sends != "1" {
+		// 0 if already sent, 1 if sending
+		t.Fatalf("inflight snapshot sends expected 0 or 1, got %q", sends)
+	}
+	receives, err := clus.Members[(lead+1)%3].Metric("etcd_network_snapshot_receive_inflights_total")
+	if err != nil {
+		t.Fatal(err)
+	}
+	if receives != "0" && receives != "1" {
+		// 0 if already received, 1 if receiving
+		t.Fatalf("inflight snapshot receives expected 0 or 1, got %q", receives)
+	}
+
 	time.Sleep(2 * time.Second)
 	time.Sleep(2 * time.Second)
 
 
 	// slow follower now applies leader snapshot
 	// slow follower now applies leader snapshot