mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-01-27 18:20:05 +00:00
First of all, this patch changes the behavior of `on_start`/`on_restart` callbacks, they will be called only when postgres is started or restarted without role changes. In case if the member is promoted or demoted only the `on_role_change` callback will be executed. `on_role_change` was never called for standby leader, only `on_start`/`on_restart` and with a wrong role argument. Before that `on_role_change` was never called for standby leader, only `on_start`/`on_restart` and with a wrong role argument. In addition to that, the REST API will return standby_leader role for the leader of the standby cluster. Closes https://github.com/zalando/patroni/issues/988
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
import json
|
|
import time
|
|
|
|
from behave import step, then
|
|
|
|
|
|
@step('I configure and start {name:w} with a tag {tag_name:w} {tag_value:w}')
|
|
def start_patroni_with_a_name_value_tag(context, name, tag_name, tag_value):
|
|
return context.pctl.start(name, custom_config={'tags': {tag_name: tag_value}})
|
|
|
|
|
|
@then('There is a {label} with "{content}" in {name:w} data directory')
|
|
def check_label(context, label, content, name):
|
|
label = context.pctl.read_label(name, label)
|
|
label = label.replace('\n', '\\n')
|
|
assert label == content, "{0} is not equal to {1}".format(label, content)
|
|
|
|
|
|
@step('I create label with "{content:w}" in {name:w} data directory')
|
|
def write_label(context, content, name):
|
|
context.pctl.write_label(name, content)
|
|
|
|
|
|
@step('"{name}" key in DCS has {key:w}={value:w} after {time_limit:d} seconds')
|
|
def check_member(context, name, key, value, time_limit):
|
|
time_limit *= context.timeout_multiplier
|
|
max_time = time.time() + int(time_limit)
|
|
while time.time() < max_time:
|
|
try:
|
|
response = json.loads(context.dcs_ctl.query(name))
|
|
if response.get(key) == value:
|
|
return
|
|
except Exception:
|
|
pass
|
|
time.sleep(1)
|
|
assert False, "{0} does not have {1}={2} in dcs after {3} seconds".format(name, key, value, time_limit)
|