mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Improve replication_state=streaming check in behave (#3269)
it was somewhat flaky
This commit is contained in:
@@ -13,9 +13,7 @@ Feature: standby cluster
|
|||||||
When I start postgres-0
|
When I start postgres-0
|
||||||
Then "members/postgres-0" key in DCS has state=running after 10 seconds
|
Then "members/postgres-0" key in DCS has state=running after 10 seconds
|
||||||
And replication works from postgres-1 to postgres-0 after 15 seconds
|
And replication works from postgres-1 to postgres-0 after 15 seconds
|
||||||
When I issue a GET request to http://127.0.0.1:8008/patroni
|
And Response on GET http://127.0.0.1:8008/patroni contains replication_state=streaming after 10 seconds
|
||||||
Then I receive a response code 200
|
|
||||||
And I receive a response replication_state streaming
|
|
||||||
And "members/postgres-0" key in DCS has replication_state=streaming after 10 seconds
|
And "members/postgres-0" key in DCS has replication_state=streaming after 10 seconds
|
||||||
|
|
||||||
@slot-advance
|
@slot-advance
|
||||||
@@ -35,9 +33,7 @@ Feature: standby cluster
|
|||||||
Then postgres-1 is a leader of batman1 after 10 seconds
|
Then postgres-1 is a leader of batman1 after 10 seconds
|
||||||
When I add the table foo to postgres-0
|
When I add the table foo to postgres-0
|
||||||
Then table foo is present on postgres-1 after 20 seconds
|
Then table foo is present on postgres-1 after 20 seconds
|
||||||
When I issue a GET request to http://127.0.0.1:8009/patroni
|
And Response on GET http://127.0.0.1:8009/patroni contains replication_state=streaming after 10 seconds
|
||||||
Then I receive a response code 200
|
|
||||||
And I receive a response replication_state streaming
|
|
||||||
And I sleep for 3 seconds
|
And I sleep for 3 seconds
|
||||||
When I issue a GET request to http://127.0.0.1:8009/primary
|
When I issue a GET request to http://127.0.0.1:8009/primary
|
||||||
Then I receive a response code 503
|
Then I receive a response code 503
|
||||||
@@ -49,9 +45,7 @@ Feature: standby cluster
|
|||||||
Then postgres-2 role is the replica after 24 seconds
|
Then postgres-2 role is the replica after 24 seconds
|
||||||
And postgres-2 is replicating from postgres-1 after 10 seconds
|
And postgres-2 is replicating from postgres-1 after 10 seconds
|
||||||
And table foo is present on postgres-2 after 20 seconds
|
And table foo is present on postgres-2 after 20 seconds
|
||||||
When I issue a GET request to http://127.0.0.1:8010/patroni
|
And Response on GET http://127.0.0.1:8010/patroni contains replication_state=streaming after 10 seconds
|
||||||
Then I receive a response code 200
|
|
||||||
And I receive a response replication_state streaming
|
|
||||||
And postgres-1 does not have a replication slot named test_logical
|
And postgres-1 does not have a replication slot named test_logical
|
||||||
|
|
||||||
Scenario: check switchover
|
Scenario: check switchover
|
||||||
|
|||||||
@@ -160,9 +160,24 @@ def check_http_response(context, url, value, timeout, negate=False):
|
|||||||
if context.certfile:
|
if context.certfile:
|
||||||
url = url.replace('http://', 'https://')
|
url = url.replace('http://', 'https://')
|
||||||
timeout *= context.timeout_multiplier
|
timeout *= context.timeout_multiplier
|
||||||
|
if '=' in value:
|
||||||
|
key, val = value.split('=', 1)
|
||||||
|
else:
|
||||||
|
key, val = value, None
|
||||||
for _ in range(int(timeout)):
|
for _ in range(int(timeout)):
|
||||||
r = context.request_executor.request('GET', url)
|
r = context.request_executor.request('GET', url)
|
||||||
if (value in r.data.decode('utf-8')) != negate:
|
data = r.data.decode('utf-8')
|
||||||
|
if val is not None:
|
||||||
|
try:
|
||||||
|
data = json.loads(data)
|
||||||
|
if negate:
|
||||||
|
if key not in data or data[key] != val:
|
||||||
|
break
|
||||||
|
elif key in data and data[key] == val:
|
||||||
|
break
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
elif (value in r.data.decode('utf-8')) != negate:
|
||||||
break
|
break
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user