From a9501be1df8366d55746284b88a79cf44dd8675c Mon Sep 17 00:00:00 2001
From: Georgy Moshkin <gmoshkin@picodata.io>
Date: Fri, 10 Nov 2023 19:17:48 +0300
Subject: [PATCH] test: check vshard is reconfigured upon incarnation change

---
 test/conftest.py          |  6 +++++-
 test/int/test_sharding.py | 22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 test/int/test_sharding.py

diff --git a/test/conftest.py b/test/conftest.py
index e0bedd2fa2..b7afc3716c 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -832,7 +832,9 @@ class Instance:
             "leader_id": status.leader_id,
         } == {"raft_state": state, "leader_id": leader_id}
 
-    def wait_online(self, timeout: int | float = 6, rps: int | float = 5):
+    def wait_online(
+        self, timeout: int | float = 6, rps: int | float = 5, expected_incarnation=None
+    ):
         """Wait until instance attains Online grade
 
         Args:
@@ -869,6 +871,8 @@ class Instance:
             assert isinstance(myself, dict)
             assert isinstance(myself["current_grade"], dict)
             assert myself["current_grade"]["variant"] == "Online"
+            if expected_incarnation is not None:
+                assert myself["current_grade"]["incarnation"] == expected_incarnation
 
         Retriable(timeout, rps, fatal=ProcessDead).call(fetch_info)
         eprint(f"{self} is online")
diff --git a/test/int/test_sharding.py b/test/int/test_sharding.py
new file mode 100644
index 0000000000..ea4b2eef07
--- /dev/null
+++ b/test/int/test_sharding.py
@@ -0,0 +1,22 @@
+from conftest import (
+    Cluster,
+)
+
+
+def test_sharding_reinitializes_on_restart(cluster: Cluster):
+    [i1] = cluster.deploy(instance_count=1)
+
+    assert i1.call("vshard.router.info") is not None
+
+    incarnation = i1.eval("return pico.instance_info().current_grade.incarnation")
+
+    # Instance silently dies without it's grade being updated
+    i1.kill()
+
+    # Instance restarts, it's incarnation is updated and governor reconfigures
+    # all the subsystems
+    i1.start()
+    i1.wait_online(expected_incarnation=incarnation + 1)
+
+    # Vshard is configured even though the configuration didn't change
+    assert i1.call("vshard.router.info") is not None
-- 
GitLab