mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-01-27 10:20:10 +00:00
Improve replication_state=streaming check in behave (#3269)
it was somewhat flaky
This commit is contained in:
committed by
GitHub
parent
c97ad83396
commit
8de904e556
@@ -13,9 +13,7 @@ Feature: standby cluster
|
||||
When I start postgres-0
|
||||
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
|
||||
When I issue a GET request to http://127.0.0.1:8008/patroni
|
||||
Then I receive a response code 200
|
||||
And I receive a response replication_state streaming
|
||||
And Response on GET http://127.0.0.1:8008/patroni contains replication_state=streaming after 10 seconds
|
||||
And "members/postgres-0" key in DCS has replication_state=streaming after 10 seconds
|
||||
|
||||
@slot-advance
|
||||
@@ -35,9 +33,7 @@ Feature: standby cluster
|
||||
Then postgres-1 is a leader of batman1 after 10 seconds
|
||||
When I add the table foo to postgres-0
|
||||
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
|
||||
Then I receive a response code 200
|
||||
And I receive a response replication_state streaming
|
||||
And Response on GET http://127.0.0.1:8009/patroni contains replication_state=streaming after 10 seconds
|
||||
And I sleep for 3 seconds
|
||||
When I issue a GET request to http://127.0.0.1:8009/primary
|
||||
Then I receive a response code 503
|
||||
@@ -49,9 +45,7 @@ Feature: standby cluster
|
||||
Then postgres-2 role is the replica after 24 seconds
|
||||
And postgres-2 is replicating from postgres-1 after 10 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
|
||||
Then I receive a response code 200
|
||||
And I receive a response replication_state streaming
|
||||
And Response on GET http://127.0.0.1:8010/patroni contains replication_state=streaming after 10 seconds
|
||||
And postgres-1 does not have a replication slot named test_logical
|
||||
|
||||
Scenario: check switchover
|
||||
|
||||
@@ -160,9 +160,24 @@ def check_http_response(context, url, value, timeout, negate=False):
|
||||
if context.certfile:
|
||||
url = url.replace('http://', 'https://')
|
||||
timeout *= context.timeout_multiplier
|
||||
if '=' in value:
|
||||
key, val = value.split('=', 1)
|
||||
else:
|
||||
key, val = value, None
|
||||
for _ in range(int(timeout)):
|
||||
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
|
||||
time.sleep(1)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user