IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 5, 2019, 3:18:35 PM (7 years ago)
Author:
fairlamb
Message:

merge of branch ipp-350 into trunk

Location:
trunk/backups
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/backups

  • trunk/backups/jira_backup_test.py

    r40967 r41067  
    3333        , 'target_filename' : 'jira.tar.gz'
    3434        , 'prefix_date' : 'True'
     35        }
     36    config['RSYNC'] = \
     37        { 'sources' : (f"{os.path.join(tmpdir, 'rsync_source_dir1')},"
     38                       f"{os.path.join(tmpdir, 'rsync_source_dir2')}")
     39        , 'additional_args' : '-a --delete-after'
     40        , 'sub-dirs' : 'jira_subdir1, jira_subdir2'
    3541        }
    3642    config['MYSQLDUMP'] = \
     
    8187    assert os.path.exists(jira_attachment_2_filepath)
    8288
     89    # Create a few folders to be rsync'd
     90    rsync_source_dir1 = os.path.join(tmpdir, "rsync_source_dir1")
     91    rsync_source_dir2 = os.path.join(tmpdir, "rsync_source_dir2")
     92    file_in_rsync_dir1 = os.path.join(rsync_source_dir1, "some_file_to_rsync")
     93    file_in_rsync_dir2 = os.path.join(rsync_source_dir2, "some_other_file_to_rsync")
     94    os.makedirs(rsync_source_dir1)
     95    os.makedirs(rsync_source_dir2)
     96    Path(file_in_rsync_dir1).touch()
     97    Path(file_in_rsync_dir2).touch()
     98    assert os.path.exists(file_in_rsync_dir1)
     99    assert os.path.exists(file_in_rsync_dir2)
     100
    83101
    84102class TestArguments(object):
     
    288306        assert os.path.exists(expected_jira_bak1_tar)
    289307        assert os.path.exists(expected_jira_bak2_tar)
     308
     309
     310class TestRsyncOfFiles(object):
     311
     312    def test_jira_rsync_with_subdirs(self, tmpdir):
     313        """This should be similar to the regular Backup version"""
     314        create_items_for_full_jira_backup_test(tmpdir)
     315        config = make_config(tmpdir)
     316
     317        jb = JiraBackup(config_file=config)
     318
     319        # Expected resulting rsync directories
     320        expected_jira_host_rsync1 = os.path.join(tmpdir, "host_backup_path", "jira_subdir1", "rsync_source_dir1")
     321        expected_jira_bak1_rsync1 = os.path.join(tmpdir, "backup_1_path",    "jira_subdir1", "rsync_source_dir1")
     322        expected_jira_bak2_rsync1 = os.path.join(tmpdir, "backup_2_path",    "jira_subdir1", "rsync_source_dir1")
     323        expected_jira_host_rsync2 = os.path.join(tmpdir, "host_backup_path", "jira_subdir2", "rsync_source_dir2")
     324        expected_jira_bak1_rsync2 = os.path.join(tmpdir, "backup_1_path",    "jira_subdir2", "rsync_source_dir2")
     325        expected_jira_bak2_rsync2 = os.path.join(tmpdir, "backup_2_path",    "jira_subdir2", "rsync_source_dir2")
     326        assert not os.path.exists(expected_jira_host_rsync1)
     327        assert not os.path.exists(expected_jira_bak1_rsync1)
     328        assert not os.path.exists(expected_jira_bak2_rsync1)
     329        assert not os.path.exists(expected_jira_host_rsync2)
     330        assert not os.path.exists(expected_jira_bak1_rsync2)
     331        assert not os.path.exists(expected_jira_bak2_rsync2)
     332        # Expected resulting rsync files
     333        expected_file_host_dir1 = os.path.join( expected_jira_host_rsync1, "some_file_to_rsync")
     334        expected_file_bak1_dir1 = os.path.join( expected_jira_bak1_rsync1, "some_file_to_rsync")
     335        expected_file_bak2_dir1 = os.path.join( expected_jira_bak2_rsync1, "some_file_to_rsync")
     336        expected_file_host_dir2 = os.path.join( expected_jira_host_rsync2, "some_other_file_to_rsync")
     337        expected_file_bak1_dir2 = os.path.join( expected_jira_bak1_rsync2, "some_other_file_to_rsync")
     338        expected_file_bak2_dir2 = os.path.join( expected_jira_bak2_rsync2, "some_other_file_to_rsync")
     339        assert not os.path.exists(expected_file_host_dir1)
     340        assert not os.path.exists(expected_file_bak1_dir1)
     341        assert not os.path.exists(expected_file_bak2_dir1)
     342        assert not os.path.exists(expected_file_host_dir2)
     343        assert not os.path.exists(expected_file_bak1_dir2)
     344        assert not os.path.exists(expected_file_bak2_dir2)
     345
     346        rsync_result = jb._run_rsync()
     347        assert rsync_result == 0
     348
     349        # All files Rsync'd
     350        assert os.path.exists(expected_jira_host_rsync1)
     351        assert os.path.exists(expected_jira_bak1_rsync1)
     352        assert os.path.exists(expected_jira_bak2_rsync1)
     353        assert os.path.exists(expected_jira_host_rsync2)
     354        assert os.path.exists(expected_jira_bak1_rsync2)
     355        assert os.path.exists(expected_jira_bak2_rsync2)
     356        assert os.path.exists(expected_file_host_dir1)
     357        assert os.path.exists(expected_file_bak1_dir1)
     358        assert os.path.exists(expected_file_bak2_dir1)
     359        assert os.path.exists(expected_file_host_dir2)
     360        assert os.path.exists(expected_file_bak1_dir2)
     361        assert os.path.exists(expected_file_bak2_dir2)
Note: See TracChangeset for help on using the changeset viewer.