IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40893


Ignore:
Timestamp:
Sep 24, 2019, 9:51:49 AM (7 years ago)
Author:
fairlamb
Message:

extracted defaults out to depend on a config, added some verbosity options

Location:
branches/ipp-132_automate_jira_conf_backups/backups
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/ipp-132_automate_jira_conf_backups/backups/backup_atlassian_applications.py

    r40892 r40893  
    11import argparse
     2import configparser
    23import datetime
    34import glob
    4 import operator
    55import os
    66import os.path as path
     
    1616
    1717
    18 DEFAULT_ATLASSIAN_HOST = "ippops4"
    19 DEFAULT_BACKUP_MACHINE_1 = "ippops3"
    20 DEFAULT_BACKUP_MACHINE_2 = "ippops5"
    21 DEFAULT_BACKUP_HOST = "/export/{0}.0/atlassian_backups".format(DEFAULT_ATLASSIAN_HOST)
    22 DEFAULT_BACKUP_1_DIR = "/data/{0}.0/atlassian_backups".format(DEFAULT_BACKUP_MACHINE_1)
    23 DEFAULT_BACKUP_2_DIR = "/data/{0}.0/atlassian_backups".format(DEFAULT_BACKUP_MACHINE_2)
    24 
    25 DEFAULT_ATLASSIAN_HOME_DIR = "/var/atlassian/application-data/"
    26 DEFAULT_JIRA_BACKUP_DIR = path.join(DEFAULT_ATLASSIAN_HOME_DIR, "jira/export")
    27 DEFAULT_CONF_BACKUP_DIR = path.join(DEFAULT_ATLASSIAN_HOME_DIR, "confluence/backups")
    28 DEFAULT_JIRA_ATTACHMENTS_DIR = path.join(DEFAULT_ATLASSIAN_HOME_DIR, "jira/data")
    29 DEFAULT_CONF_ATTACHMENTS_DIR = path.join(DEFAULT_ATLASSIAN_HOME_DIR, "confluence/attachments")
    30 
    31 DEFAULT_VERBOSITY = False
    32 
    33 
    34 class SubprocessError(Exception):
    35     """Errors in Popen stderr subprocess"""
    36 
    37 
    38 def _move_dir_contents_to_dir(source_dirs: [str], destination_dirs: [str]):
     18DEFAULT_CONFIG_FILE = path.abspath('./atlassian_backups.config')
     19
     20
     21class ConfigError(Exception):
     22    """Error in loading the config file"""
     23
     24    def __init__(self, config_item, message):
     25        self.config_item = config_item
     26        self.message = message
     27
     28
     29def _move_dir_contents_to_dir(source_dirs: [str], destination_dirs: [str], verbose: bool=False):
    3930    """ Moves all files from inside source paths to the destination dits.
    4031It's important to note that it moves index to index
     
    6455        try:
    6556            for fp in filepaths:
    66                 print("Moving: {0} -> {1}".format(fp, destination_dirs[i]))
     57                if verbose:
     58                    print("Moving: {0} -> {1}".format(fp, destination_dirs[i]))
    6759                command_and_args = ["mv", fp, destination_dirs[i]]
    6860                # shutil.move(fp, destination_dirs[i])
     
    7769class AtlassianBackups():
    7870
    79     def __init__(self,
    80                  host_backup_path=None,
    81                  backup_1_path=None,
    82                  backup_2_path=None,
    83                  jira_backup_path=None,
    84                  conf_backup_path=None,
    85                  jira_attachments_path=None,
    86                  conf_attachments_path=None,
    87                  verbose=None):
    88 
    89         self.host_backup_path      = DEFAULT_BACKUP_HOST          if host_backup_path      is None else host_backup_path
    90         self.backup_1_path         = DEFAULT_BACKUP_1_DIR         if backup_1_path         is None else backup_1_path
    91         self.backup_2_path         = DEFAULT_BACKUP_2_DIR         if backup_2_path         is None else backup_2_path
    92         self.jira_backup_path      = DEFAULT_JIRA_BACKUP_DIR      if jira_backup_path      is None else jira_backup_path
    93         self.conf_backup_path      = DEFAULT_CONF_BACKUP_DIR      if conf_backup_path      is None else conf_backup_path
    94         self.jira_attachments_path = DEFAULT_JIRA_ATTACHMENTS_DIR if jira_attachments_path is None else jira_attachments_path
    95         self.conf_attachments_path = DEFAULT_CONF_ATTACHMENTS_DIR if conf_attachments_path is None else conf_attachments_path
    96         self.verbose               = DEFAULT_VERBOSITY            if verbose               is None else verbose
    97 
    98     host_backup_path = property(operator.attrgetter('_host_backup_path'))
    99 
    100     @host_backup_path.setter
    101     def host_backup_path(self, value):
    102         self._host_backup_path = value
    103 
    104     backup_1_path = property(operator.attrgetter('_backup_1_path'))
    105 
    106     @backup_1_path.setter
    107     def backup_1_path(self, value):
    108         self._backup_1_path = value
    109 
    110     backup_2_path = property(operator.attrgetter('_backup_2_path'))
    111 
    112     @backup_2_path.setter
    113     def backup_2_path(self, value):
    114         self._backup_2_path = value
    115 
    116     jira_backup_path = property(operator.attrgetter('_jira_backup_path'))
    117 
    118     @jira_backup_path.setter
    119     def jira_backup_path(self, value):
    120         self._jira_backup_path = value
    121 
    122     conf_backup_path = property(operator.attrgetter('_conf_backup_path'))
    123 
    124     @conf_backup_path.setter
    125     def conf_backup_path(self, value):
    126         self._conf_backup_path = value
    127 
    128     jira_attachments_path = property(operator.attrgetter('_jira_attachments_path'))
    129 
    130     @jira_attachments_path.setter
    131     def jira_attachments_path(self, value):
    132         self._jira_attachments_path = value
    133 
    134     conf_attachments_path = property(operator.attrgetter('_conf_attachments_path'))
    135 
    136     @conf_attachments_path.setter
    137     def conf_attachments_path(self, value):
    138         self._conf_attachments_path = value
    139 
    140     verbose = property(operator.attrgetter('_verbose'))
    141 
    142     @verbose.setter
    143     def verbose(self, home_dir):
    144         self._verbose = home_dir
     71    def __init__(self, config_file=None):
     72        self.config_file = DEFAULT_CONFIG_FILE if config_file is None else config_file
     73        self.load_config(self.config_file)
     74
     75    def load_config(self, config_class_or_filepath):
     76        """Accepts a filepath to a config file, or """
     77
     78        config = configparser.ConfigParser()
     79        if config_class_or_filepath is None:
     80            raise ConfigError(config_class_or_filepath, "Neither config settings or filepath of config given")
     81        elif isinstance(config_class_or_filepath, configparser.ConfigParser):
     82            config = config_class_or_filepath
     83        elif path.exists(config_class_or_filepath):
     84            config.read(config_class_or_filepath)
     85
     86        def _get_str_key_from_section(config, section, key):
     87            if config.has_option(section, key):
     88                return config[section][key]
     89            raise ConfigError(config, "ConfigError: KeyError: no key found for {0}".format(key))
     90
     91        section = 'atlassian_backups'
     92        self.host_backup_path      = _get_str_key_from_section(config, section, 'host_backup_path')
     93        self.backup_1_path         = _get_str_key_from_section(config, section, 'backup_1_path')
     94        self.backup_2_path         = _get_str_key_from_section(config, section, 'backup_2_path')
     95        self.jira_backup_path      = _get_str_key_from_section(config, section, 'jira_backup_path')
     96        self.conf_backup_path      = _get_str_key_from_section(config, section, 'conf_backup_path')
     97        self.jira_attachments_path = _get_str_key_from_section(config, section, 'jira_attachments_path')
     98        self.conf_attachments_path = _get_str_key_from_section(config, section, 'conf_attachments_path')
     99        self.verbose               = config.getboolean('atlassian_backups', 'verbose')
    145100
    146101    def target_backup_paths_ok(self) -> bool:
     
    184139
    185140        # Move latest to tmp (and delete if move ok)
    186         _move_dir_contents_to_dir(latest_paths, tmp_paths)
     141        _move_dir_contents_to_dir(latest_paths, tmp_paths, self.verbose)
    187142
    188143        # copy jira
    189         jira_return = self._copy_jira_backup()
     144        jira_return = self._copy_jira_backup(self.verbose)
    190145
    191146        # copy confluence
    192         conf_return = self._copy_confluence_backup()
     147        conf_return = self._copy_confluence_backup(self.verbose)
    193148
    194149        # tarfiles:
    195150        tar_return = self._tar_attachments()
    196151
    197         # make mysql dump
    198 
    199152        # If successful: move tmp to old
    200153        if jira_return == 0 and conf_return == 0 and tar_return == 0:
    201             _move_dir_contents_to_dir(tmp_paths, old_paths)
     154            _move_dir_contents_to_dir(tmp_paths, old_paths, self.verbose)
    202155        else:
    203156            # If any failed: delete latest, move tmp back
    204             _move_dir_contents_to_dir(tmp_paths, latest_paths)
     157            _move_dir_contents_to_dir(tmp_paths, latest_paths, self.verbose)
    205158            return 5
    206159
     
    216169        return datetime.date.today().strftime(jira_format)
    217170
    218     def _copy_jira_backup(self):
     171    def _copy_jira_backup(self, verbose=False):
    219172        if not self.target_backup_paths_ok():
    220173            return 2
     
    222175        jira_wildcard_search = "{0}/{1}*".format(self.jira_backup_path, self.get_jira_backup_date_format())
    223176        jira_xml_filepaths = glob.glob(jira_wildcard_search)
    224         print(len(jira_xml_filepaths))
    225177        if len(jira_xml_filepaths) == 0:
    226178            print("Copy Failure: No jira backups found at: ", jira_wildcard_search)
     
    233185                    return 2
    234186                try:
    235                     print("Copying: {0} to {1}".format(jfile, tpath))
     187                    if verbose:
     188                        print("Copying: {0} to {1}".format(jfile, tpath))
    236189                    shutil.copy2(jfile, tpath)
     190                    sub_utils.chmod_wrapper(['774', os.path.join(tpath, os.path.basename(jfile))])
    237191                except IOError as e:
    238192                    print("Error: copying jira backup.\n  copying: {0}\n  to: {1}".format(e.filename, e.filename2))
     
    248202        return datetime.date.today().strftime(conf_format)
    249203
    250     def _copy_confluence_backup(self):
     204    def _copy_confluence_backup(self, verbose=False):
    251205        if not self.target_backup_paths_ok():
    252206            print("Copy Failure: target path failure")
     
    255209        conf_wildcard_search = "{0}/*{1}*.zip".format(self.conf_backup_path, self.get_confluence_backup_date_format())
    256210        conf_xml_filepaths = glob.glob(conf_wildcard_search)
    257         print(len(conf_xml_filepaths))
    258211        if len(conf_xml_filepaths) == 0:
    259212            print("Copy Failure: No confluence backups found at: ", conf_wildcard_search)
     
    263216            for tpath in target_paths:
    264217                try:
    265                     print("using cp wrapper")
    266218                    sub_utils.cp_wrapper([cfile, tpath])
     219                    sub_utils.chmod_wrapper(['774', os.path.join(tpath, os.path.basename(cfile))])
    267220                except Exception as e:
    268221                    print(e)
     
    279232        jira_tar_filepath = path.join(latest_paths[0], jira_tar_name)
    280233        jira_tar_args = ["-cf", jira_tar_filepath, self.jira_attachments_path]
    281         print(jira_tar_args)
    282234        sub_utils.tar_wrapper(jira_tar_args)
     235        sub_utils.chmod_wrapper(['774', jira_tar_filepath])
    283236        # copy to backups
    284237        sub_utils.cp_wrapper([ jira_tar_filepath, latest_paths[1]])
     
    289242        confluence_tar_filepath = path.join(latest_paths[0], confluence_tar_name)
    290243        confluence_tar_args = ["-cf", confluence_tar_filepath, self.conf_attachments_path]
    291         print(confluence_tar_args)
    292244        sub_utils.tar_wrapper(confluence_tar_args)
     245        sub_utils.chmod_wrapper(['774', confluence_tar_filepath])
    293246        # copy to backups
    294247        sub_utils.cp_wrapper([ confluence_tar_filepath, latest_paths[1]])
     
    326279            decoded_stderr = stde.decode()
    327280            if decoded_stderr.casefold().find('error'.casefold()) > -1:
    328                 raise SubprocessError()
     281                raise sub_utils.SubprocessError()
    329282
    330283        # move the dump file to the correct locations
     
    343296
    344297    def run(self):
    345         self.perform_atlassian_backups()
    346         return 0
     298        return self.perform_atlassian_backups()
    347299
    348300
     
    351303    args_dict = vars(args)
    352304    ab = AtlassianBackups(**args_dict)
    353     ab.run()
     305    return ab.run()
    354306
    355307
     
    359311        description='Performs backup of atlassian applications\nYou should run this on the machine hosting the atlassian applications')
    360312
    361     parser.add_argument('--host_backup_path',
     313    parser.add_argument('--config_file',
    362314        nargs='?',
    363         help='absolute path of where the backups should be copied to on the host',
    364         default=DEFAULT_BACKUP_HOST)
    365     parser.add_argument('--backup_1_dir',
    366         nargs='?',
    367         help='directory of where backups should be copied to',
    368         default=DEFAULT_BACKUP_1_DIR)
    369     parser.add_argument('--backup_2_dir',
    370         nargs='?',
    371         help='second directory of where backups should be copied to',
    372         default=DEFAULT_BACKUP_1_DIR)
    373     parser.add_argument('--jira_backup_dir',
    374         nargs='?',
    375         help='directory where the zipped xml backups are located',
    376         default=DEFAULT_JIRA_BACKUP_DIR)
    377     parser.add_argument('--conf_backup_dir',
    378         nargs='?',
    379         help='directory where the confluence xml backups are located',
    380         default=DEFAULT_CONF_BACKUP_DIR)
    381     parser.add_argument('--jira_attachments_dir',
    382         nargs='?',
    383         help='direcory of where the jira attachments are located',
    384         default=DEFAULT_JIRA_ATTACHMENTS_DIR)
    385     parser.add_argument('--conf_attachments_dir',
    386         nargs='?',
    387         help='directory of where the confluence attachments are located',
    388         default=DEFAULT_CONF_ATTACHMENTS_DIR)
    389     parser.add_argument('--verbose', '-v',
    390         action='store_true',
    391         help='will print some verbose messages')
     315        help='contains config for all paths and mysqldump details',
     316        default=DEFAULT_CONFIG_FILE)
    392317
    393318    return parser.parse_args()
  • branches/ipp-132_automate_jira_conf_backups/backups/backup_atlassian_applications_test.py

    r40892 r40893  
    11import backup_atlassian_applications as baa
     2import configparser
    23import datetime
    34import os
     
    78
    89import full_atlassian_backup_test as fab_test
     10import utils.subprocess_utils as sub_utils
    911
    1012from backup_atlassian_applications import AtlassianBackups
    1113
     14TEST_DEFAULT_CONFIG_FILE = "./testing/test.config"
     15
     16
     17def make_config(tmpdir) -> configparser.ConfigParser:
     18    config = configparser.ConfigParser()
     19    config['atlassian_backups'] = \
     20    {
     21        'host_backup_path'      : os.path.join(tmpdir, 'host_backup_path'),
     22        'backup_1_path'         : os.path.join(tmpdir, 'backup_1_path'),
     23        'backup_2_path'         : os.path.join(tmpdir, 'backup_2_path'),
     24        'jira_backup_path'      : os.path.join(tmpdir, 'jira_backup_path'),
     25        'conf_backup_path'      : os.path.join(tmpdir, 'conf_backup_path'),
     26        'jira_attachments_path' : os.path.join(tmpdir, 'jira_attachments_path'),
     27        'conf_attachments_path' : os.path.join(tmpdir, 'conf_attachments_path')
     28    }
     29
    1230
    1331class TestArguments(object):
    1432
    15     def test_default_arguments(self):
    16 
     33    def test_load_from_config_file(self):
     34
     35        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
     36
     37        assert ab.host_backup_path      == "/export/ippops4.0/atlassian_backups"
     38        assert ab.backup_1_path         == "/data/ippops3.0/atlassian_backups"
     39        assert ab.backup_2_path         == "/data/ippops5.0/atlassian_backups"
     40        assert ab.jira_backup_path      == "/var/atlassian/application-data/jira/export"
     41        assert ab.conf_backup_path      == "/var/atlassian/application-data/confluence/backups"
     42        assert ab.jira_attachments_path == "/var/atlassian/application-data/jira/data"
     43        assert ab.conf_attachments_path == "/var/atlassian/application-data/confluence/attachments"
     44        assert ab.verbose is True
     45
     46    def test_default_config_loads_with_no_args(self):
     47        assert os.path.exists("./atlassian_backups.config")
    1748        ab = AtlassianBackups()
    1849        assert ab.host_backup_path      == "/export/ippops4.0/atlassian_backups"
     
    2455        assert ab.conf_attachments_path == "/var/atlassian/application-data/confluence/attachments"
    2556
    26     def test_providing_args(self):
    27         ab = AtlassianBackups(host_backup_path="/host/backup/path",
    28                               backup_1_path="/backup/1/path",
    29                               backup_2_path="/backup/2/path",
    30                               jira_backup_path="/jira/backup/path",
    31                               conf_backup_path="/conf/backup/path",
    32                               jira_attachments_path="/jira/attachments/path",
    33                               conf_attachments_path="/conf/attachments/path",
    34                               verbose=True)
    35 
    36         assert ab.host_backup_path      == "/host/backup/path"
    37         assert ab.backup_1_path         == "/backup/1/path"
    38         assert ab.backup_2_path         == "/backup/2/path"
    39         assert ab.jira_backup_path      == "/jira/backup/path"
    40         assert ab.conf_backup_path      == "/conf/backup/path"
    41         assert ab.jira_attachments_path == "/jira/attachments/path"
    42         assert ab.conf_attachments_path == "/conf/attachments/path"
     57    def test_default_arguments(self):
     58
     59        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
     60        assert ab.host_backup_path      == "/export/ippops4.0/atlassian_backups"
     61        assert ab.backup_1_path         == "/data/ippops3.0/atlassian_backups"
     62        assert ab.backup_2_path         == "/data/ippops5.0/atlassian_backups"
     63        assert ab.jira_backup_path      == "/var/atlassian/application-data/jira/export"
     64        assert ab.conf_backup_path      == "/var/atlassian/application-data/confluence/backups"
     65        assert ab.jira_attachments_path == "/var/atlassian/application-data/jira/data"
     66        assert ab.conf_attachments_path == "/var/atlassian/application-data/confluence/attachments"
     67
     68    def test_providing_config_directly(self):
     69        config = configparser.ConfigParser()
     70        config.add_section("atlassian_backups")
     71        config.set('atlassian_backups', 'host_backup_path',      'custom_config1')
     72        config.set('atlassian_backups', 'backup_1_path',         'custom_config2')
     73        config.set('atlassian_backups', 'backup_2_path',         'custom_config3')
     74        config.set('atlassian_backups', 'jira_backup_path',      'custom_config4')
     75        config.set('atlassian_backups', 'conf_backup_path',      'custom_config5')
     76        config.set('atlassian_backups', 'jira_attachments_path', 'custom_config6')
     77        config.set('atlassian_backups', 'conf_attachments_path', 'custom_config7')
     78        config.set('atlassian_backups', 'verbose', 'False')
     79
     80        ab = AtlassianBackups(config_file=config)
     81
     82        assert ab.host_backup_path      == 'custom_config1'
     83        assert ab.backup_1_path         == 'custom_config2'
     84        assert ab.backup_2_path         == 'custom_config3'
     85        assert ab.jira_backup_path      == 'custom_config4'
     86        assert ab.conf_backup_path      == 'custom_config5'
     87        assert ab.jira_attachments_path == 'custom_config6'
     88        assert ab.conf_attachments_path == 'custom_config7'
     89        assert ab.verbose is False
     90
     91    def test_nonexistant_config_file_raises_error(self):
     92        with pytest.raises(baa.ConfigError):
     93            AtlassianBackups("not a real file path")
     94
     95    def test_default_config_loads_from_main_call(self):
     96        try:
     97            baa.main()
     98        except Exception:
     99            pytest.fail("An error was raised when it should not")
    43100
    44101
     
    46103
    47104    def test_default_target_paths_do_not_exists_in_testing(self):
    48         ab = AtlassianBackups()
     105        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
    49106        assert ab.target_backup_paths_ok() is False
    50107
    51108    def test_an_incorrect_path_then_correct_path(self, tmpdir):
    52         ab = AtlassianBackups()
     109        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
    53110
    54111        assert os.path.exists(ab.jira_backup_path) is False
     
    57114
    58115    def test_each_path_individually(self, tmpdir):
    59         ab = AtlassianBackups()
     116        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
    60117
    61118        assert os.path.exists(ab.host_backup_path) is False
     
    92149
    93150    def test_backup_subdirs_are_created_if_missing(self, tmpdir):
    94         ab = AtlassianBackups()
     151        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
    95152        ab.jira_path = tmpdir
    96153        ab.conf_path = tmpdir
     
    126183
    127184    def test_target_paths_with_defaults_function(self):
    128         ab = AtlassianBackups()
     185        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
    129186
    130187        default = ab.target_paths('default_paths')
     
    135192
    136193    def test_target_paths_function_after_changing_paths(self):
    137         ab = AtlassianBackups()
     194        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
    138195
    139196        ab.host_backup_path = "/different_path/for_host"
     
    232289
    233290    def test_get_jira_backup_date_format(self):
    234         ab = AtlassianBackups()
     291        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
    235292        today = datetime.date.today()
    236293        expected_format = today.strftime("%Y-%b-%d")
     
    238295
    239296    def test_copying_fails_if_paths_not_present(self):
    240         ab = AtlassianBackups()
     297        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
    241298        return_value = ab._copy_jira_backup()
    242299        assert return_value != 0
     
    246303
    247304    def test_jira_copy(self, tmpdir):
    248         ab = AtlassianBackups()
     305        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
    249306        ab = fab_test.create_all_paths_and_folders(ab, tmpdir)
    250307
     
    253310
    254311    def test_get_confluence_backup_date_format(self):
    255         ab = AtlassianBackups()
     312        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
    256313        today = datetime.date.today()
    257314        expected_format = today.strftime("%Y_%m_%d")
     
    259316
    260317    def test_confluence_copy(self, tmpdir):
    261         ab = AtlassianBackups()
     318        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
    262319        ab = fab_test.create_all_paths_and_folders(ab, tmpdir)
    263320
     
    266323
    267324    def test_full_copy(self, tmpdir):
    268         ab = AtlassianBackups()
     325        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
    269326        ab = fab_test.create_all_paths_and_folders(ab, tmpdir)
    270327
     
    274331
    275332    def test_atlsssian_copying_fails_when_paths_do_not_exist(self, tmpdir):
    276         ab = AtlassianBackups()
     333        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
    277334        fake_path = "/not/a/real/path"
    278335        ab.jira_backup_path = fake_path
     
    295352    def test_attachments_tar(self, tmpdir):
    296353
    297         ab = AtlassianBackups()
     354        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
    298355        ab = fab_test.create_all_paths_and_folders(ab, tmpdir)
    299356
     
    340397
    341398    def test_mysql_dump_is_ok(self, tmpdir):
    342         ab = AtlassianBackups()
     399        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
    343400        ab = fab_test.create_all_paths_and_folders(ab, tmpdir)
    344401
     
    354411
    355412    def test_mysql_dump_is_ok_to_custom_file(self, tmpdir):
    356         ab = AtlassianBackups()
     413        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
    357414        ab = fab_test.create_all_paths_and_folders(ab, tmpdir)
    358415
     
    367424
    368425    def test_mysql_dump_fails_with_incorrect_password(self, tmpdir):
    369         ab = AtlassianBackups()
    370         ab = fab_test.create_all_paths_and_folders(ab, tmpdir)
    371 
    372         with pytest.raises(baa.SubprocessError):
     426        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
     427        ab = fab_test.create_all_paths_and_folders(ab, tmpdir)
     428
     429        with pytest.raises(sub_utils.SubprocessError):
    373430            ab.make_mysql_dump("Not the correct password")
    374 
    375 # class TestTidyingOfFiles(object):
    376 
    377 #     def test_tidying(self):
    378 #         assert False is True
  • branches/ipp-132_automate_jira_conf_backups/backups/full_atlassian_backup_test.py

    r40892 r40893  
    11import datetime
    22import os
     3import backup_atlassian_applications as baa
    34
    45from pathlib import Path
    56
    67from backup_atlassian_applications import AtlassianBackups
     8
     9TEST_DEFAULT_CONFIG_FILE = "./testing/test.config"
    710
    811
     
    137140
    138141    def test_entire_process(self, tmpdir):
    139         ab = AtlassianBackups()
     142        ab = AtlassianBackups(config_file=TEST_DEFAULT_CONFIG_FILE)
    140143        ab = create_all_paths_and_folders(ab, tmpdir)
    141144
Note: See TracChangeset for help on using the changeset viewer.