mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-09-01 17:19:31 +00:00
Implement acceptance test for dynamic configuration functionality
and fix some bugs revealed by acceptance tests
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import json
|
||||
import psycopg2 as pg
|
||||
import requests
|
||||
|
||||
from behave import step, then
|
||||
from time import sleep, time
|
||||
@@ -52,3 +54,31 @@ def replication_works(context, master, replica, time_limit):
|
||||
When I add the table test_{0} to {1}
|
||||
Then table test_{0} is present on {2} after {3} seconds
|
||||
""".format(int(time()), master, replica, time_limit))
|
||||
|
||||
|
||||
def patch_config_with_data(config, data):
|
||||
for name, value in data.items():
|
||||
if isinstance(value, dict):
|
||||
patch_config_with_data(config[name], value)
|
||||
else:
|
||||
config[name] = value
|
||||
|
||||
|
||||
@step('I patch global configuration with {data}')
|
||||
def patch_config(context, data):
|
||||
data = json.loads(data)
|
||||
config = json.loads(context.dcs_ctl.query('config'))
|
||||
patch_config_with_data(config, data)
|
||||
context.dcs_ctl.set('config', json.dumps(config))
|
||||
|
||||
|
||||
@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
|
||||
sleep(1)
|
||||
else:
|
||||
assert False,\
|
||||
"Value {0} is not present in response after {1} seconds".format(value, timeout)
|
||||
|
||||
Reference in New Issue
Block a user