File: custom_bootstrap.py

package info (click to toggle)
patroni 4.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,704 kB
  • sloc: python: 29,743; sh: 573; makefile: 29
file content (27 lines) | stat: -rw-r--r-- 972 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import time

from behave import step, then


@step('I start {name:name} in a cluster {cluster_name:w} as a clone of {name2:name}')
def start_cluster_clone(context, name, cluster_name, name2):
    context.pctl.clone(name2, cluster_name, name)


@step('I start {name:name} in a cluster {cluster_name:w} from backup')
def start_cluster_from_backup(context, name, cluster_name):
    context.pctl.bootstrap_from_backup(name, cluster_name)


@then('{name:name} is a leader of {cluster_name:w} after {time_limit:d} seconds')
def is_a_leader(context, name, cluster_name, time_limit):
    time_limit *= context.timeout_multiplier
    max_time = time.time() + int(time_limit)
    while (context.dcs_ctl.query("leader", scope=cluster_name) != name):
        time.sleep(1)
        assert time.time() < max_time, "{0} is not a leader in dcs after {1} seconds".format(name, time_limit)


@step('I do a backup of {name:name}')
def do_backup(context, name):
    context.pctl.backup(name)