Skip to content

Commit f9d88ab

Browse files
committed
logical replication
1 parent 2afc7b0 commit f9d88ab

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/bwc/test_rolling_upgrade.py

+32
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import time
12
import unittest
23
from crate.client import connect
34
from crate.client.exceptions import ProgrammingError
@@ -88,6 +89,9 @@ def _test_rolling_upgrade(self, path, nodes):
8889
}
8990
cluster = self._new_cluster(path.from_version, nodes, settings=settings)
9091
cluster.start()
92+
replica_cluster = self._new_cluster(path.from_version, 1, settings=settings)
93+
replica_cluster.start()
94+
cluster.node()
9195
with connect(cluster.node().http_url, error_trace=True) as conn:
9296
c = conn.cursor()
9397
c.execute("create user arthur with (password = 'secret')")
@@ -133,6 +137,15 @@ def _test_rolling_upgrade(self, path, nodes):
133137
# Add the shards of the new partition primaries
134138
expected_active_shards += shards
135139

140+
c.execute("create table doc.x (a int)")
141+
c.execute("create publication p for table doc.x")
142+
with connect(replica_cluster.node().http_url, error_trace=True) as replica_conn:
143+
rc = replica_conn.cursor()
144+
rc.execute(f"create subscription rs connection 'crate://{cluster.node().http_url}?user=crate&sslmode=sniff' publication p")
145+
rc.execute("create table doc.rx (a int)")
146+
rc.execute("create publication rp for table doc.rx")
147+
c.execute(f"create subscription s connection 'crate://{replica_cluster.node().http_url}?user=crate&sslmode=sniff' publication rp")
148+
136149
for idx, node in enumerate(cluster):
137150
# Enforce an old version node be a handler to make sure that an upgraded node can serve 'select *' from an old version node.
138151
# Otherwise upgraded node simply requests N-1 columns from old version with N columns and it always works.
@@ -236,6 +249,25 @@ def _test_rolling_upgrade(self, path, nodes):
236249
# Add the shards of the new partition primaries
237250
expected_active_shards += shards
238251

252+
with connect(replica_cluster.node().http_url, error_trace=True) as replica_conn:
253+
rc = replica_conn.cursor()
254+
# Ensure publishing to remote cluster works
255+
rc.execute("select count(*) from doc.x")
256+
count = rc.fetchall()[0][0]
257+
c.execute("insert into doc.x values (1)")
258+
rc.execute("refresh table doc.x")
259+
time.sleep(1) # replication delay...
260+
rc.execute("select count(*) from doc.x")
261+
self.assertEqual(rc.fetchall()[0][0], count + 1)
262+
263+
# Ensure subscription from remote cluster works
264+
c.execute("select count(*) from doc.rx")
265+
count = c.fetchall()[0][0]
266+
rc.execute("insert into doc.rx values (1)")
267+
time.sleep(1) # replication delay...
268+
c.execute("select count(*) from doc.rx")
269+
self.assertEqual(c.fetchall()[0][0], count + 1)
270+
239271
# Finally validate that all shards (primaries and replicas) of all partitions are started
240272
# and writes into the partitioned table while upgrading were successful
241273
with connect(cluster.node().http_url, error_trace=True) as conn:

0 commit comments

Comments
 (0)