IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40892


Ignore:
Timestamp:
Sep 20, 2019, 4:01:54 PM (7 years ago)
Author:
fairlamb
Message:

Added the mysql dump part and refactored some testing

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

Legend:

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

    r40885 r40892  
    66import os.path as path
    77import shutil
     8import subprocess
    89import sys
    910
     
    2930
    3031DEFAULT_VERBOSITY = False
     32
     33
     34class SubprocessError(Exception):
     35    """Errors in Popen stderr subprocess"""
    3136
    3237
     
    198203            # If any failed: delete latest, move tmp back
    199204            _move_dir_contents_to_dir(tmp_paths, latest_paths)
     205            return 5
    200206
    201207        # TODO:clean-up old files (to save space)
     
    290296        return 0
    291297
    292     def make_mysql_dump(self):
     298    def make_mysql_dump(self, dump_password, dump_name=None):
    293299        # do this as the dumper user
    294300
     301        latest_paths = self.target_paths("latest")
     302        if not self.target_backup_paths_ok():
     303            return 1
     304
    295305        # make sure target file does not exist (or it will fail)
    296 
    297         # verify mysql checksum?
     306        if dump_name is None:
     307            date = datetime.date.today().strftime("%Y_%m_%d")
     308            dump_filepath = path.join(latest_paths[0], '{0}_mysql_dump.sql'.format(date))
     309        else:
     310            dump_filepath = path.join(latest_paths[0], dump_name)
     311        if path.exists(dump_filepath):
     312            print("Warning: SQL dump already exists: ", dump_filepath)
     313            return 2
     314
     315        # Setup the commands:
     316        mysqldump_args = [ 'mysqldump', '-u', 'dumper', '-p{0}'.format(dump_password)
     317                         , '--databases', 'jiradb', 'confluencedb'
     318                         ]
     319        with open(dump_filepath, "w+") as df:
     320            mysqldump_process = subprocess.Popen(mysqldump_args, stdout=df, stderr=subprocess.PIPE)
     321            dump_result = mysqldump_process.communicate()
     322
     323        # Get the piped std err. See it contains the word error
     324        stdo, stde = dump_result
     325        if stde is not None:
     326            decoded_stderr = stde.decode()
     327            if decoded_stderr.casefold().find('error'.casefold()) > -1:
     328                raise SubprocessError()
    298329
    299330        # move the dump file to the correct locations
     331        if not path.exists(dump_filepath):
     332            return 2
     333        cp_1 = sub_utils.cp_wrapper([dump_filepath, latest_paths[1]])
     334        cp_2 = sub_utils.cp_wrapper([dump_filepath, latest_paths[2]])
     335        if cp_1 != 0:
     336            return cp_1
     337        if cp_2 != 0:
     338            return cp_2
    300339        return 0
    301340
  • branches/ipp-132_automate_jira_conf_backups/backups/backup_atlassian_applications_test.py

    r40885 r40892  
    22import datetime
    33import os
     4import pytest
    45
    56from pathlib import Path
     7
     8import full_atlassian_backup_test as fab_test
     9
    610from backup_atlassian_applications import AtlassianBackups
    711
     
    118122            assert os.path.exists(expected_old)
    119123
    120     def test_subsequent_backup_subdirs_not_created_if_first_fails(self, tmpdir):
    121         ab = AtlassianBackups()
    122         ab.jira_path = tmpdir
    123         ab.conf_path = tmpdir
    124 
    125         backup_paths = [ os.path.join(tmpdir, 'host')
    126                        , os.path.join(tmpdir, 'backup_1')
    127                        , os.path.join(tmpdir, 'backup_2')
    128                        ]
    129 
    130         for bp in backup_paths:
    131 
    132             # make the parent dir
    133             os.makedirs(bp)
    134             ab.bp = bp
    135             assert os.path.exists(bp)
    136 
    137             # Expected subdirs
    138             expected_latest = os.path.join(bp, 'latest')
    139             expected_tmp = os.path.join(bp, 'tmp')
    140             expected_old = os.path.join(bp, 'old')
    141             assert not os.path.exists(expected_latest)
    142             assert not os.path.exists(expected_tmp)
    143             assert not os.path.exists(expected_old)
    144 
    145             # all_paths_ok will call subdir creation
    146             ab._make_destination_subdirs_if_needed(bp)
    147             assert os.path.exists(expected_latest)
    148             assert os.path.exists(expected_tmp)
    149             assert os.path.exists(expected_old)
    150 
    151124
    152125class TestMovingBackups(object):
    153126
    154     def test_target_paths_function(self):
     127    def test_target_paths_with_defaults_function(self):
    155128        ab = AtlassianBackups()
    156129
     
    174147        assert another_subdir[2] == "/bk/two/a_different_subdir"
    175148
    176     def test_move_aborts_if_source_and_destination_paths_not_equal(self):
     149    def test_move_aborts_if_source_and_destination_path_lists_are_different_lengths(self):
    177150        source_paths = [ "/Just/one/path" ]
    178151        destination_paths = [ "/Two", "/paths"]
     
    258231class TestCopyingBackups(object):
    259232
    260     def create_fake_paths_and_files(self, atlas_class: AtlassianBackups, directory) -> AtlassianBackups:
    261         ab = atlas_class
    262 
    263         tmpdir_jira = os.path.join(directory, "jira")
    264         tmpdir_conf = os.path.join(directory, "conf")
    265         tmpdir_host = os.path.join(directory, "host")
    266         tmpdir_bak1 = os.path.join(directory, "bak1")
    267         tmpdir_bak2 = os.path.join(directory, "bak2")
    268         os.makedirs(tmpdir_jira)
    269         os.makedirs(tmpdir_conf)
    270         os.makedirs(tmpdir_host)
    271         os.makedirs(tmpdir_bak1)
    272         os.makedirs(tmpdir_bak2)
    273 
    274         jira_date = ab.get_jira_backup_date_format()
    275         jira_file = "{0}--1234.zip".format(jira_date)
    276         jira_fullpath = os.path.join(tmpdir_jira, jira_file)
    277         assert not os.path.exists(jira_fullpath)
    278         Path(jira_fullpath).touch()
    279         assert os.path.exists(jira_fullpath)
    280 
    281         conf_date = ab.get_confluence_backup_date_format()
    282         conf_file = "confluence-xml-backup-{0}.zip".format(conf_date)
    283         conf_fullpath = os.path.join(tmpdir_conf, conf_file)
    284         assert not os.path.exists(conf_fullpath)
    285         Path(conf_fullpath).touch()
    286         assert os.path.exists(conf_fullpath)
    287 
    288         ab.jira_backup_path = tmpdir_jira
    289         ab.conf_backup_path = tmpdir_conf
    290         ab.host_backup_path = tmpdir_host
    291         ab.backup_1_path = tmpdir_bak1
    292         ab.backup_2_path = tmpdir_bak2
    293 
    294         assert os.path.exists(jira_fullpath)
    295         assert os.path.exists(conf_fullpath)
    296 
    297         return ab
    298 
    299233    def test_get_jira_backup_date_format(self):
    300234        ab = AtlassianBackups()
     
    313247    def test_jira_copy(self, tmpdir):
    314248        ab = AtlassianBackups()
    315         self.create_fake_paths_and_files(ab, tmpdir)
     249        ab = fab_test.create_all_paths_and_folders(ab, tmpdir)
    316250
    317251        return_value = ab._copy_jira_backup()
     
    326260    def test_confluence_copy(self, tmpdir):
    327261        ab = AtlassianBackups()
    328         self.create_fake_paths_and_files(ab, tmpdir)
     262        ab = fab_test.create_all_paths_and_folders(ab, tmpdir)
    329263
    330264        return_value = ab._copy_confluence_backup()
     
    333267    def test_full_copy(self, tmpdir):
    334268        ab = AtlassianBackups()
    335         self.create_fake_paths_and_files(ab, tmpdir)
     269        ab = fab_test.create_all_paths_and_folders(ab, tmpdir)
    336270
    337271        result = ab.perform_atlassian_backups()
     
    341275    def test_atlsssian_copying_fails_when_paths_do_not_exist(self, tmpdir):
    342276        ab = AtlassianBackups()
     277        fake_path = "/not/a/real/path"
     278        ab.jira_backup_path = fake_path
     279        ab.conf_backup_path = fake_path
     280        ab.host_backup_path = fake_path
     281        ab.backup_1_path = fake_path
     282        ab.backup_2_path = fake_path
    343283        assert not os.path.exists(ab.jira_backup_path)
    344284        assert not os.path.exists(ab.conf_backup_path)
     
    356296
    357297        ab = AtlassianBackups()
    358         ab = create_all_paths_and_folders(ab, tmpdir)
     298        ab = fab_test.create_all_paths_and_folders(ab, tmpdir)
    359299
    360300        today = datetime.date.today().strftime("%Y_%m_%d")
     
    384324        assert os.path.exists(expected_conf_bak2_tar)
    385325
    386 # class TestMysqlBackup(object):
    387 
    388 #     def test_mysql_dump_is_ok(self):
    389 #         assert False is True
    390 
     326
     327@pytest.mark.skip(reason="Requires a fake database to be setup")
     328class TestMysqlBackup(object):
     329    """ The mySQL dump tests require the machine on which they are
     330running to have a mysql database running with a user called
     331'dumper' and the password listed below.
     332
     333UPDATE mysql.user SET authentication_string = PASSWORD('NEW_USER_PASSWORD')WHERE User = 'user-name' AND Host = 'localhost';FLUSH PRIVILEGES;
     334
     335Note that the actual password used for the backups is not included here,
     336or in the main backup code for security.
     337"""
     338
     339    dumper_password = "not_a_real_password"
     340
     341    def test_mysql_dump_is_ok(self, tmpdir):
     342        ab = AtlassianBackups()
     343        ab = fab_test.create_all_paths_and_folders(ab, tmpdir)
     344
     345        date = datetime.date.today().strftime("%Y_%m_%d")
     346        expected_dump = os.path.join(ab.host_backup_path, "latest", '{0}_mysql_dump.sql'.format(date))
     347        print(expected_dump)
     348        assert not os.path.exists(expected_dump)
     349
     350        mysqldump_result = ab.make_mysql_dump(self.dumper_password)
     351        assert mysqldump_result == 0
     352
     353        assert os.path.exists(expected_dump)
     354
     355    def test_mysql_dump_is_ok_to_custom_file(self, tmpdir):
     356        ab = AtlassianBackups()
     357        ab = fab_test.create_all_paths_and_folders(ab, tmpdir)
     358
     359        expected_dump = os.path.join(ab.host_backup_path, "latest", "humptydumpy.sql")
     360        print(expected_dump)
     361        assert not os.path.exists(expected_dump)
     362
     363        mysqldump_result = ab.make_mysql_dump(self.dumper_password, "humptydumpy.sql")
     364        assert mysqldump_result == 0
     365
     366        assert os.path.exists(expected_dump)
     367
     368    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):
     373            ab.make_mysql_dump("Not the correct password")
    391374
    392375# class TestTidyingOfFiles(object):
     
    394377#     def test_tidying(self):
    395378#         assert False is True
    396 
    397 def create_all_paths_and_folders(ab_class: AtlassianBackups, tmpdir) -> AtlassianBackups:
    398 
    399         # Create all folders needed
    400 
    401         host_backup_path = os.path.join(tmpdir, "host_backup")
    402         backup_1_path = os.path.join(tmpdir, "backup_1")
    403         backup_2_path = os.path.join(tmpdir, "backup_2")
    404         jira_backup_path = os.path.join(tmpdir, "jira_home/zip_in_here")
    405         conf_backup_path = os.path.join(tmpdir, "conf_home/zip_in_here")
    406         jira_attachments_path = os.path.join(tmpdir, "jira_home/attachments")
    407         conf_attachments_path = os.path.join(tmpdir, "conf_home/attachments")
    408         os.makedirs(host_backup_path)
    409         os.makedirs(backup_1_path)
    410         os.makedirs(backup_2_path)
    411         os.makedirs(jira_backup_path)
    412         os.makedirs(conf_backup_path)
    413         os.makedirs(jira_attachments_path)
    414         os.makedirs(conf_attachments_path)
    415         assert os.path.exists(host_backup_path)
    416         assert os.path.exists(backup_1_path)
    417         assert os.path.exists(backup_2_path)
    418         assert os.path.exists(jira_backup_path)
    419         assert os.path.exists(conf_backup_path)
    420         assert os.path.exists(jira_attachments_path)
    421         assert os.path.exists(conf_attachments_path)
    422 
    423         # And the some of the subdirs (only one of the backups has all of them)
    424         os.makedirs(os.path.join(host_backup_path, "latest"))
    425         os.makedirs(os.path.join(backup_1_path, "old"))
    426         os.makedirs(os.path.join(backup_2_path, "old"))
    427         os.makedirs(os.path.join(backup_2_path, "tmp"))
    428         os.makedirs(os.path.join(backup_2_path, "latest"))
    429         assert os.path.exists(os.path.join(host_backup_path, "latest"))
    430         assert os.path.exists(os.path.join(backup_1_path, "old"))
    431         assert os.path.exists(os.path.join(backup_2_path, "old"))
    432         assert os.path.exists(os.path.join(backup_2_path, "tmp"))
    433         assert os.path.exists(os.path.join(backup_2_path, "latest"))
    434 
    435         # set them on the class
    436         ab_class.host_backup_path = host_backup_path
    437         ab_class.backup_1_path = backup_1_path
    438         ab_class.backup_2_path = backup_2_path
    439         ab_class.jira_backup_path = jira_backup_path
    440         ab_class.conf_backup_path = conf_backup_path
    441         ab_class.jira_attachments_path = jira_attachments_path
    442         ab_class.conf_attachments_path = conf_attachments_path
    443         assert ab_class.host_backup_path      == os.path.join(tmpdir, "host_backup")
    444         assert ab_class.backup_1_path         == os.path.join(tmpdir, "backup_1")
    445         assert ab_class.backup_2_path         == os.path.join(tmpdir, "backup_2")
    446         assert ab_class.jira_backup_path      == os.path.join(tmpdir, "jira_home/zip_in_here")
    447         assert ab_class.conf_backup_path      == os.path.join(tmpdir, "conf_home/zip_in_here")
    448         assert ab_class.jira_attachments_path == os.path.join(tmpdir, "jira_home/attachments")
    449         assert ab_class.conf_attachments_path == os.path.join(tmpdir, "conf_home/attachments")
    450 
    451         # Create backup files
    452         jira_backup_name = ab_class.get_jira_backup_date_format() + "_jira_test_file.zip"
    453         jira_backup_filepath = os.path.join(jira_backup_path + jira_backup_name)
    454         Path(jira_backup_filepath).touch()
    455         assert os.path.exists(jira_backup_filepath)
    456 
    457         conf_backup_name = ab_class.get_confluence_backup_date_format() + "_conf_test_file.zip"
    458         conf_backup_filepath = os.path.join(conf_backup_path + conf_backup_name)
    459         Path(conf_backup_filepath).touch()
    460         assert os.path.exists(conf_backup_filepath)
    461 
    462         # Create some files that are attchments
    463         jira_attachment_1_name = "attachment_1.zip"
    464         jira_attachment_2_name = "attachment_2.txt"
    465         jira_attachment_1_filepath = os.path.join(jira_attachments_path + jira_attachment_1_name)
    466         jira_attachment_2_filepath = os.path.join(jira_attachments_path + jira_attachment_2_name)
    467         Path(jira_attachment_1_filepath).touch()
    468         Path(jira_attachment_2_filepath).touch()
    469         assert os.path.exists(jira_attachment_1_filepath)
    470         assert os.path.exists(jira_attachment_2_filepath)
    471 
    472         conf_attachment_1_name = "attachment_1.zip"
    473         conf_attachment_2_name = "attachment_2.txt"
    474         conf_attachment_1_filepath = os.path.join(conf_attachments_path + conf_attachment_1_name)
    475         conf_attachment_2_filepath = os.path.join(conf_attachments_path + conf_attachment_2_name)
    476         Path(conf_attachment_1_filepath).touch()
    477         Path(conf_attachment_2_filepath).touch()
    478         assert os.path.exists(conf_attachment_1_filepath)
    479         assert os.path.exists(conf_attachment_2_filepath)
    480 
    481         # Have some old and latest versions in the backup dirs:
    482         old_date = datetime.date(2019, 8, 13)
    483         latest_date = datetime.date(2019, 9, 1)
    484         jira_old_backup_name    = ab_class.get_jira_backup_date_format(old_date)          + "_jira_old_file.zip"
    485         jira_latest_backup_name = ab_class.get_jira_backup_date_format(latest_date)       + "_jira_prev_latest_file.zip"
    486         conf_old_backup_name    = ab_class.get_confluence_backup_date_format(old_date)    + "_conf_old_file.zip"
    487         conf_latest_backup_name = ab_class.get_confluence_backup_date_format(latest_date) + "_conf_prev_latest_file.zip"
    488 
    489         def assert_not_create_assert_exists(root_path, subdir, filename):
    490             filepath = os.path.join(root_path, subdir, filename)
    491             assert not os.path.exists(filepath)
    492             Path(filepath).touch()
    493             assert os.path.exists(filepath)
    494 
    495         assert_not_create_assert_exists(host_backup_path, "latest", jira_latest_backup_name)
    496         assert_not_create_assert_exists(host_backup_path, "latest", conf_latest_backup_name)
    497         assert_not_create_assert_exists(backup_1_path,    "old",    jira_old_backup_name)
    498         assert_not_create_assert_exists(backup_1_path,    "old",    conf_old_backup_name)
    499         assert_not_create_assert_exists(backup_2_path,    "old",    jira_old_backup_name)
    500         assert_not_create_assert_exists(backup_2_path,    "old",    conf_old_backup_name)
    501         assert_not_create_assert_exists(backup_2_path,    "latest", jira_latest_backup_name)
    502         assert_not_create_assert_exists(backup_2_path,    "latest", conf_latest_backup_name)
    503 
    504         return ab_class
  • branches/ipp-132_automate_jira_conf_backups/backups/full_atlassian_backup_test.py

    r40885 r40892  
     1import datetime
     2import os
    13
    2 import backup_atlassian_applications_test as baat
     4from pathlib import Path
    35
    46from backup_atlassian_applications import AtlassianBackups
     7
     8
     9def create_all_paths_and_folders(ab_class: AtlassianBackups, tmpdir) -> AtlassianBackups:
     10    """This creates all paths and files needed for thorough testing of the
     11atlassian backup class. The class returned will have all the paths set too.
     12Assertions are made that the files exist and they are set on the class object.
     13
     14    The directory strucutre is as follows:
     15
     16    tmpdir/host_backup/latest/2019-09-01_jira_prev_latest_file.zip
     17                             /2019_09_01_conf_prev_latest_file.zip
     18          /backup_1/old/2019-08-13_jira_old_file.zip
     19                       /2019_08_13_conf_old_file.zip
     20          /backup_2/latest/2019-09-01_jira_prev_latest_file.zip
     21                          /2019_09_01_conf_prev_latest_file.zip
     22                   /old/2019-08-13_jira_old_file.zip
     23                       /2019_08_13_conf_old_file.zip
     24                   /tmp
     25
     26    # Directories where the original files come from (date will be todays)
     27    tmpdir/jira_home/zip_in_here/2019-11-23_jira_test_file.zip
     28                    /attachments/attachment_1.zip
     29                    /attachments/attachment_2.txt
     30    tmpdir/conf_home/zip_in_here/2019_11_23_conf_test_file.zip
     31                    /attachments/attachment_1.zip
     32                    /attachments/attachment_2.txt
     33
     34"""
     35
     36    # Create all main paths required
     37    host_backup_path = os.path.join(tmpdir, "host_backup")
     38    backup_1_path = os.path.join(tmpdir, "backup_1")
     39    backup_2_path = os.path.join(tmpdir, "backup_2")
     40    jira_backup_path = os.path.join(tmpdir, "jira_home", "zip_in_here")
     41    conf_backup_path = os.path.join(tmpdir, "conf_home", "zip_in_here")
     42    jira_attachments_path = os.path.join(tmpdir, "jira_home", "attachments")
     43    conf_attachments_path = os.path.join(tmpdir, "conf_home", "attachments")
     44    os.makedirs(host_backup_path)
     45    os.makedirs(backup_1_path)
     46    os.makedirs(backup_2_path)
     47    os.makedirs(jira_backup_path)
     48    os.makedirs(conf_backup_path)
     49    os.makedirs(jira_attachments_path)
     50    os.makedirs(conf_attachments_path)
     51    assert os.path.exists(host_backup_path)
     52    assert os.path.exists(backup_1_path)
     53    assert os.path.exists(backup_2_path)
     54    assert os.path.exists(jira_backup_path)
     55    assert os.path.exists(conf_backup_path)
     56    assert os.path.exists(jira_attachments_path)
     57    assert os.path.exists(conf_attachments_path)
     58
     59    # And the some of the subdirs (only one of the backups has all of them)
     60    os.makedirs(os.path.join(host_backup_path, "latest"))
     61    os.makedirs(os.path.join(backup_1_path, "old"))
     62    os.makedirs(os.path.join(backup_2_path, "old"))
     63    os.makedirs(os.path.join(backup_2_path, "tmp"))
     64    os.makedirs(os.path.join(backup_2_path, "latest"))
     65    assert os.path.exists(os.path.join(host_backup_path, "latest"))
     66    assert os.path.exists(os.path.join(backup_1_path, "old"))
     67    assert os.path.exists(os.path.join(backup_2_path, "old"))
     68    assert os.path.exists(os.path.join(backup_2_path, "tmp"))
     69    assert os.path.exists(os.path.join(backup_2_path, "latest"))
     70
     71    # set them on the class
     72    ab_class.host_backup_path = host_backup_path
     73    ab_class.backup_1_path = backup_1_path
     74    ab_class.backup_2_path = backup_2_path
     75    ab_class.jira_backup_path = jira_backup_path
     76    ab_class.conf_backup_path = conf_backup_path
     77    ab_class.jira_attachments_path = jira_attachments_path
     78    ab_class.conf_attachments_path = conf_attachments_path
     79
     80    # Create backup files
     81    jira_backup_name = ab_class.get_jira_backup_date_format() + "_jira_test_file.zip"
     82    jira_backup_filepath = os.path.join(jira_backup_path, jira_backup_name)
     83    Path(jira_backup_filepath).touch()
     84    assert os.path.exists(jira_backup_filepath)
     85
     86    conf_backup_name = ab_class.get_confluence_backup_date_format() + "_conf_test_file.zip"
     87    conf_backup_filepath = os.path.join(conf_backup_path, conf_backup_name)
     88    Path(conf_backup_filepath).touch()
     89    assert os.path.exists(conf_backup_filepath)
     90
     91    # Create some files that are attchments
     92    jira_attachment_1_name = "attachment_1.zip"
     93    jira_attachment_2_name = "attachment_2.txt"
     94    jira_attachment_1_filepath = os.path.join(jira_attachments_path, jira_attachment_1_name)
     95    jira_attachment_2_filepath = os.path.join(jira_attachments_path, jira_attachment_2_name)
     96    Path(jira_attachment_1_filepath).touch()
     97    Path(jira_attachment_2_filepath).touch()
     98    assert os.path.exists(jira_attachment_1_filepath)
     99    assert os.path.exists(jira_attachment_2_filepath)
     100
     101    conf_attachment_1_name = "attachment_1.zip"
     102    conf_attachment_2_name = "attachment_2.txt"
     103    conf_attachment_1_filepath = os.path.join(conf_attachments_path, conf_attachment_1_name)
     104    conf_attachment_2_filepath = os.path.join(conf_attachments_path, conf_attachment_2_name)
     105    Path(conf_attachment_1_filepath).touch()
     106    Path(conf_attachment_2_filepath).touch()
     107    assert os.path.exists(conf_attachment_1_filepath)
     108    assert os.path.exists(conf_attachment_2_filepath)
     109
     110    # Have some old and latest versions in the backup dirs:
     111    old_date = datetime.date(2019, 8, 13)
     112    latest_date = datetime.date(2019, 9, 1)
     113    jira_old_backup_name    = ab_class.get_jira_backup_date_format(old_date)          + "_jira_old_file.zip"
     114    jira_latest_backup_name = ab_class.get_jira_backup_date_format(latest_date)       + "_jira_prev_latest_file.zip"
     115    conf_old_backup_name    = ab_class.get_confluence_backup_date_format(old_date)    + "_conf_old_file.zip"
     116    conf_latest_backup_name = ab_class.get_confluence_backup_date_format(latest_date) + "_conf_prev_latest_file.zip"
     117
     118    def assert_not_create_assert_exists(root_path, subdir, filename):
     119        filepath = os.path.join(root_path, subdir, filename)
     120        assert not os.path.exists(filepath)
     121        Path(filepath).touch()
     122        assert os.path.exists(filepath)
     123
     124    assert_not_create_assert_exists(host_backup_path, "latest", jira_latest_backup_name)
     125    assert_not_create_assert_exists(host_backup_path, "latest", conf_latest_backup_name)
     126    assert_not_create_assert_exists(backup_1_path,    "old",    jira_old_backup_name)
     127    assert_not_create_assert_exists(backup_1_path,    "old",    conf_old_backup_name)
     128    assert_not_create_assert_exists(backup_2_path,    "old",    jira_old_backup_name)
     129    assert_not_create_assert_exists(backup_2_path,    "old",    conf_old_backup_name)
     130    assert_not_create_assert_exists(backup_2_path,    "latest", jira_latest_backup_name)
     131    assert_not_create_assert_exists(backup_2_path,    "latest", conf_latest_backup_name)
     132
     133    return ab_class
    5134
    6135
     
    9138    def test_entire_process(self, tmpdir):
    10139        ab = AtlassianBackups()
    11         ab = baat.create_all_paths_and_folders(ab, tmpdir)
     140        ab = create_all_paths_and_folders(ab, tmpdir)
    12141
    13         ab.perform_atlassian_backups()
     142        result = ab.perform_atlassian_backups()
    14143
    15         # Check backups in correct place
    16 
    17         # old backups have been moved
    18 
    19         # Check tar is ok (inc contents?)
    20 
    21         # old attachments have been moved
    22 
    23         # Check mysql dump
    24 
    25         # check old dump moved
    26 
    27         assert False is True
     144        assert result == 0
Note: See TracChangeset for help on using the changeset viewer.