Make create_replica_method a YAML array.

Make sure the absense of this key or empty value in it is handled
correctly. Update tests and sample configuration files.
This commit is contained in:
Oleksii Kliukin
2015-11-25 10:29:17 +01:00
parent be9e525739
commit 14b8dfa3e8
4 changed files with 11 additions and 6 deletions
+3 -3
View File
@@ -240,9 +240,9 @@ class Postgresql:
# defined by the user. this is a list, so we need to
# loop through all methods the user supplies
connstring = leader.conn_url
# get list of replica methods from config
replica_list = self.config.get('create_replica_method', 'basebackup')
replica_methods = [rm.strip() for rm in replica_list.split(',')]
# get list of replica methods from config.
# If there is no configuration key, or no value is specified, use basebackup
replica_methods = self.config.get('create_replica_method') or ['basebackup']
# go through them in priority order
ret = 1
for replica_method in replica_methods:
+3 -1
View File
@@ -68,7 +68,9 @@ postgresql:
admin:
username: admin
password: admin
create_replica_method: basebackup
create_replica_method:
- basebackup
# - wal_e
# commented-out example for wal-e provisioning
#create_replica_method: wal_e, basebackup
#wal_e:
+4 -1
View File
@@ -69,7 +69,10 @@ postgresql:
username: admin
password: admin
# commented-out example for wal-e provisioning
#create_replica_method: wal_e, basebackup
create_replica_method:
- basebackup
# - wal_e
# commented-out example for wal-e provisioning
#wal_e:
#command: /patroni/scripts/wale_restore.py
#env_dir: /home/postgres/etc/wal-e.d/env
+1 -1
View File
@@ -284,7 +284,7 @@ class TestPostgresql(unittest.TestCase):
with patch('subprocess.call', Mock(side_effect=[Exception(), 0])):
self.assertEquals(self.p.create_replica(self.leader, ''), 0)
self.p.config['create_replica_method'] = 'wale, basebackup'
self.p.config['create_replica_method'] = ['wale', 'basebackup']
self.p.config['wale'] = {'command': 'foo'}
with patch('subprocess.call', Mock(return_value=0)):
self.assertEquals(self.p.create_replica(self.leader, ''), 0)