Exemple #1
0
 def test_analyse_temporary_config_files(self, tmpdir):
     """
     Test the method that identifies dangerous options into
     the configuration files
     """
     # Build directory/files structure for testing
     tempdir = tmpdir.mkdir('tempdir')
     recovery_info = {
         'configuration_files': ['postgresql.conf', 'postgresql.auto.conf'],
         'tempdir': tempdir.strpath,
         'temporary_configuration_files': [],
         'results': {
             'changes': [],
             'warnings': []
         }
     }
     postgresql_conf = tempdir.join('postgresql.conf')
     postgresql_auto = tempdir.join('postgresql.auto.conf')
     postgresql_conf.write('archive_command = something\n'
                           'data_directory = something\n'
                           'include = something\n'
                           'include "without braces"')
     postgresql_auto.write('archive_command = something\n'
                           'data_directory = something')
     recovery_info['temporary_configuration_files'].append(
         postgresql_conf.strpath)
     recovery_info['temporary_configuration_files'].append(
         postgresql_auto.strpath)
     # Build a RecoveryExecutor object (using a mock as server and backup
     # manager.
     backup_manager = testing_helpers.build_backup_manager()
     executor = RecoveryExecutor(backup_manager)
     # Identify dangerous options into config files for remote recovery
     executor._analyse_temporary_config_files(recovery_info)
     assert len(recovery_info['results']['changes']) == 2
     assert len(recovery_info['results']['warnings']) == 4
     # Clean for a local recovery test
     recovery_info['results']['changes'] = []
     recovery_info['results']['warnings'] = []
     # Identify dangerous options for local recovery
     executor._analyse_temporary_config_files(recovery_info)
     assert len(recovery_info['results']['changes']) == 2
     assert len(recovery_info['results']['warnings']) == 4
 def test_analyse_temporary_config_files(self, tmpdir):
     """
     Test the method that identifies dangerous options into
     the configuration files
     """
     # Build directory/files structure for testing
     tempdir = tmpdir.mkdir("tempdir")
     recovery_info = {
         "configuration_files": ["postgresql.conf", "postgresql.auto.conf"],
         "tempdir": tempdir.strpath,
         "temporary_configuration_files": [],
         "results": {"changes": [], "warnings": []},
     }
     postgresql_conf = tempdir.join("postgresql.conf")
     postgresql_auto = tempdir.join("postgresql.auto.conf")
     postgresql_conf.write(
         "archive_command = something\n"
         "data_directory = something\n"
         "include = something\n"
         'include "without braces"'
     )
     postgresql_auto.write(
         "archive_command = something\n" "data_directory = something"
     )
     recovery_info["temporary_configuration_files"].append(postgresql_conf.strpath)
     recovery_info["temporary_configuration_files"].append(postgresql_auto.strpath)
     # Build a RecoveryExecutor object (using a mock as server and backup
     # manager.
     backup_manager = testing_helpers.build_backup_manager()
     executor = RecoveryExecutor(backup_manager)
     # Identify dangerous options into config files for remote recovery
     executor._analyse_temporary_config_files(recovery_info)
     assert len(recovery_info["results"]["changes"]) == 2
     assert len(recovery_info["results"]["warnings"]) == 4
     # Clean for a local recovery test
     recovery_info["results"]["changes"] = []
     recovery_info["results"]["warnings"] = []
     # Identify dangerous options for local recovery
     executor._analyse_temporary_config_files(recovery_info)
     assert len(recovery_info["results"]["changes"]) == 2
     assert len(recovery_info["results"]["warnings"]) == 4
 def test_analyse_temporary_config_files(self, tmpdir):
     """
     Test the method that identifies dangerous options into
     the configuration files
     """
     # Build directory/files structure for testing
     tempdir = tmpdir.mkdir("tempdir")
     recovery_info = {
         "configuration_files": ["postgresql.conf", "postgresql.auto.conf"],
         "tempdir": tempdir.strpath,
         "temporary_configuration_files": [],
         "results": {"changes": [], "warnings": []},
     }
     postgresql_conf = tempdir.join("postgresql.conf")
     postgresql_auto = tempdir.join("postgresql.auto.conf")
     postgresql_conf.write(
         "archive_command = something\n"
         "data_directory = something\n"
         "include = something\n"
         'include "without braces"'
     )
     postgresql_auto.write("archive_command = something\n" "data_directory = something")
     recovery_info["temporary_configuration_files"].append(postgresql_conf.strpath)
     recovery_info["temporary_configuration_files"].append(postgresql_auto.strpath)
     # Build a RecoveryExecutor object (using a mock as server and backup
     # manager.
     backup_manager = testing_helpers.build_backup_manager()
     executor = RecoveryExecutor(backup_manager)
     # Identify dangerous options into config files for remote recovery
     executor._analyse_temporary_config_files(recovery_info)
     assert len(recovery_info["results"]["changes"]) == 2
     assert len(recovery_info["results"]["warnings"]) == 4
     # Clean for a local recovery test
     recovery_info["results"]["changes"] = []
     recovery_info["results"]["warnings"] = []
     # Identify dangerous options for local recovery
     executor._analyse_temporary_config_files(recovery_info)
     assert len(recovery_info["results"]["changes"]) == 2
     assert len(recovery_info["results"]["warnings"]) == 4