def test_generate_recovery_conf(self, rsync_pg_mock, tmpdir):
     """
     Test the generation of recovery.conf file
     """
     # Build basic folder/files structure
     recovery_info = {
         'configuration_files': ['postgresql.conf', 'postgresql.auto.conf'],
         'tempdir': tmpdir.strpath,
         'results': {'changes': [], 'warnings': []},
         'get_wal': False,
     }
     backup_info = testing_helpers.build_test_backup_info()
     dest = tmpdir.mkdir('destination')
     # Build a recovery executor using a real server
     server = testing_helpers.build_real_server()
     executor = RecoveryExecutor(server.backup_manager)
     executor.generate_recovery_conf(recovery_info, backup_info,
                                     dest.strpath,
                                     True, 'remote@command',
                                     'target_name',
                                     '2015-06-03 16:11:03.71038+02', '2',
                                     '')
     # Check that the recovery.conf file exists
     recovery_conf_file = tmpdir.join("recovery.conf")
     assert recovery_conf_file.check()
     # Parse the generated recovery.conf
     recovery_conf = {}
     for line in recovery_conf_file.readlines():
         key, value = (s.strip() for s in line.strip().split('=', 1))
         recovery_conf[key] = value
     # check for contents
     assert 'recovery_end_command' in recovery_conf
     assert 'recovery_target_time' in recovery_conf
     assert 'recovery_target_timeline' in recovery_conf
     assert 'recovery_target_xid' not in recovery_conf
     assert 'recovery_target_name' in recovery_conf
     assert recovery_conf['recovery_end_command'] == "'rm -fr barman_xlog'"
     assert recovery_conf['recovery_target_time'] == \
         "'2015-06-03 16:11:03.71038+02'"
     assert recovery_conf['recovery_target_timeline'] == '2'
     assert recovery_conf['recovery_target_name'] == "'target_name'"
Exemple #2
0
 def test_generate_recovery_conf(self, rsync_pg_mock, tmpdir):
     """
     Test the generation of recovery.conf file
     """
     # Build basic folder/files structure
     recovery_info = {
         'configuration_files': ['postgresql.conf', 'postgresql.auto.conf'],
         'tempdir': tmpdir.strpath,
         'results': {'changes': [], 'warnings': []},
         'get_wal': False,
     }
     backup_info = testing_helpers.build_test_backup_info()
     dest = tmpdir.mkdir('destination')
     # Build a recovery executor using a real server
     server = testing_helpers.build_real_server()
     executor = RecoveryExecutor(server.backup_manager)
     executor.generate_recovery_conf(recovery_info, backup_info,
                                     dest.strpath,
                                     True, 'remote@command',
                                     'target_name',
                                     '2015-06-03 16:11:03.71038+02', '2',
                                     '')
     # Check that the recovery.conf file exists
     recovery_conf_file = tmpdir.join("recovery.conf")
     assert recovery_conf_file.check()
     # Parse the generated recovery.conf
     recovery_conf = {}
     for line in recovery_conf_file.readlines():
         key, value = (s.strip() for s in line.strip().split('=', 1))
         recovery_conf[key] = value
     # check for contents
     assert 'recovery_end_command' in recovery_conf
     assert 'recovery_target_time' in recovery_conf
     assert 'recovery_target_timeline' in recovery_conf
     assert 'recovery_target_xid' not in recovery_conf
     assert 'recovery_target_name' in recovery_conf
     assert recovery_conf['recovery_end_command'] == "'rm -fr barman_xlog'"
     assert recovery_conf['recovery_target_time'] == \
         "'2015-06-03 16:11:03.71038+02'"
     assert recovery_conf['recovery_target_timeline'] == '2'
     assert recovery_conf['recovery_target_name'] == "'target_name'"