mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Merge basic failover and basic replication scenarios in one feature.
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
Feature: basic failover
|
||||
In order to check that failover works
|
||||
As observers
|
||||
We start the primary and the replica,
|
||||
shut down the primary
|
||||
and check that the replica assumed the primary role.
|
||||
|
||||
Scenario: check the basic failover
|
||||
Given basic replication
|
||||
When I shut down postgres0
|
||||
Then postgres1 role is the primary after 10 seconds
|
||||
When I start postgres0
|
||||
Then postgres0 role is the secondary after 10 seconds
|
||||
@@ -1,33 +0,0 @@
|
||||
from lettuce import world, steps
|
||||
|
||||
PATRONI_CONFIG = '{}.yml'
|
||||
|
||||
|
||||
@steps
|
||||
class BasicFailoverSteps(object):
|
||||
|
||||
def __init__(self, environ):
|
||||
self.env = environ
|
||||
|
||||
def basic_replication(self, step):
|
||||
'''Basic replication'''
|
||||
step.behave_as("""
|
||||
Given I start postgres0
|
||||
And I start postgres1
|
||||
When I add the table foo to postgres0
|
||||
Then table foo is present on postgres1 after 10 seconds
|
||||
""")
|
||||
|
||||
def start_patroni(self, step, pg_name):
|
||||
'''I start (\w+)'''
|
||||
return world.pctl.start_patroni(pg_name)
|
||||
|
||||
def stop_patroni(self, step, pg_name):
|
||||
'''I shut down (\w+)'''
|
||||
return world.pctl.stop_patroni(pg_name)
|
||||
|
||||
def check_role(self, step, pg_name, pg_role, max_promotion_timeout):
|
||||
'''(\w+) role is the (\w+) after (\d+) seconds'''
|
||||
return world.pctl.check_role_has_changed_to(pg_name, pg_role, timeout=int(max_promotion_timeout))
|
||||
|
||||
BasicFailoverSteps(world)
|
||||
@@ -4,9 +4,19 @@ Feature: basic replication
|
||||
We start the primary and the replica
|
||||
add a table on the primary
|
||||
and check that it gets replicated to the replica over time.
|
||||
We stop the primary and check that the replica promotes itself to primary
|
||||
We start the old primary and check that it rejoins as a replica.
|
||||
|
||||
Scenario: check replication of a single table
|
||||
Given I start postgres0
|
||||
And I start postgres1
|
||||
When I add the table foo to postgres0
|
||||
Then table foo is present on postgres1 after 10 seconds
|
||||
|
||||
Scenario: check the basic failover
|
||||
When I shut down postgres0
|
||||
Then postgres1 role is the primary after 10 seconds
|
||||
When I start postgres0
|
||||
Then postgres0 role is the secondary after 10 seconds
|
||||
When I add the table bar to postgres1
|
||||
Then table bar is present on postgres1 after 10 seconds
|
||||
@@ -34,4 +34,9 @@ class BasicReplicationSteps(object):
|
||||
assert False,\
|
||||
"Table {0} is not present on {1} after {2} seconds".format(table_name, pg_name, max_replication_delay)
|
||||
|
||||
def check_role(self, step, pg_name, pg_role, max_promotion_timeout):
|
||||
'''(\w+) role is the (\w+) after (\d+) seconds'''
|
||||
return world.pctl.check_role_has_changed_to(pg_name, pg_role, timeout=int(max_promotion_timeout))
|
||||
|
||||
|
||||
BasicReplicationSteps(world)
|
||||
|
||||
+1
-1
@@ -224,7 +224,7 @@ def etcd_cleanup():
|
||||
assert False, "Unable to cleanup etcd: {0}".format(e)
|
||||
|
||||
|
||||
@after.each_scenario
|
||||
@after.each_feature
|
||||
def cleanup(scenario):
|
||||
patroni_cleanup_all()
|
||||
etcd_cleanup()
|
||||
|
||||
Reference in New Issue
Block a user