diff --git a/features/patroni_api.feature b/features/patroni_api.feature index a94ad8bc..0702f308 100644 --- a/features/patroni_api.feature +++ b/features/patroni_api.feature @@ -29,17 +29,19 @@ Scenario: check local configuration reload Scenario: check dynamic configuration change via DCS Given I issue a PATCH request to http://127.0.0.1:8008/config with {"ttl": 20, "loop_wait": 1, "postgresql": {"parameters": {"max_connections": 101}}} - And I start postgres1 - And replication works from postgres0 to postgres1 after 20 seconds + Then I receive a response code 200 + And I receive a response loop_wait 1 + And Response on GET http://127.0.0.1:8008/patroni contains restart_pending after 11 seconds When I issue a GET request to http://127.0.0.1:8008/config Then I receive a response code 200 And I receive a response loop_wait 1 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 restart_pending True And I receive a response tags {'tag': 'new_value'} Scenario: check API requests for the primary-replica pair + Given I start postgres1 + And replication works from postgres0 to postgres1 after 20 seconds When I issue a GET request to http://127.0.0.1:8009/replica Then I receive a response code 200 And I receive a response state running diff --git a/features/steps/patroni_api.py b/features/steps/patroni_api.py index 1ecd1af7..90c38564 100644 --- a/features/steps/patroni_api.py +++ b/features/steps/patroni_api.py @@ -106,3 +106,15 @@ def scheduled_failover(context, at_url, from_host, to_host, in_seconds): @step('I add tag {tag:w} {value:w} to {pg_name:w} config') def add_tag_to_config(context, tag, value, pg_name): context.pctl.add_tag_to_config(pg_name, tag, value) + + +@then('Response on GET {url} contains {value} after {timeout:d} seconds') +def check_http_response(context, url, value, timeout): + for _ in range(int(timeout)): + r = requests.get(url) + if value in r.content.decode('utf-8'): + break + time.sleep(1) + else: + assert False,\ + "Value {0} is not present in response after {1} seconds".format(value, timeout)