From 0d44e3eb7cc2e71f8449903640343dcfbb9ac165 Mon Sep 17 00:00:00 2001 From: Oleksii Kliukin Date: Fri, 26 Feb 2016 18:00:11 +0100 Subject: [PATCH] Add simple API tests for 2 nodes, to be extended. --- features/patroni_api.feature | 12 +++++++++++- features/patroni_api.py | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/features/patroni_api.feature b/features/patroni_api.feature index 3ff28584..3649337f 100644 --- a/features/patroni_api.feature +++ b/features/patroni_api.feature @@ -18,4 +18,14 @@ Scenario: check API requests on a stand-alone server And I receive a response text "failover is not possible: cluster does not have members except leader" When I issue an empty POST request to http://127.0.0.1:8008/failover Then I receive a response code 503 - And I receive a response text "No values given for required parameters leader and member" \ No newline at end of file + And I receive a response text "No values given for required parameters leader and member" + +Scenario: check API requests for the primary-replica pair + Given I start postgres1 + And replication works after 10 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 + And I receive a response role replica + When I issue an empty POST request to http://127.0.0.1:8009/reinitialize + Then I receive a response code 200 diff --git a/features/patroni_api.py b/features/patroni_api.py index 96d6e04a..188f93cb 100644 --- a/features/patroni_api.py +++ b/features/patroni_api.py @@ -79,5 +79,12 @@ class PatroniAPISteps(object): assert component in self.response, "{0} is not part of the response".format(component) assert self.response[component] == data, "{0} does not contain {1}".format(component, data) + def replication_works(self, step, time_limit): + '''And replication works after (\d+) seconds''' + step.behave_as(""" + When I add the table foo to postgres0 + Then table foo is present on postgres1 after {0} seconds + """.format(time_limit)) + PatroniAPISteps(world)