Changeset 41059
- Timestamp:
- Nov 5, 2019, 9:17:31 AM (7 years ago)
- Location:
- branches/ipp-350_add_to_jira_conf_backups
- Files:
-
- 7 edited
-
backup.py (modified) (2 diffs)
-
confluence_backup.py (modified) (1 diff)
-
confluence_backup_test.py (modified) (3 diffs)
-
jira_backup.py (modified) (1 diff)
-
jira_backup_test.py (modified) (3 diffs)
-
testing/confluence_test.config (modified) (1 diff)
-
testing/jira_test.config (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/ipp-350_add_to_jira_conf_backups/backup.py
r40973 r41059 83 83 84 84 self.read_config_and_schema(config, schema) 85 # self.read_copy_config_section(config, schema)86 # self.read_tar_config_section(config, schema)87 # self.read_rsync_config_section(config, schema)88 # self.read_mysqldump_config_section(config, schema)89 85 90 86 def read_config_and_schema(self, config: ConfigParser, schema: ConfigSchema): … … 206 202 self.target_backup_paths_ok(raise_error=True) 207 203 backup_paths = self.default_dict['backup_paths'] 208 for bp in backup_paths: 209 # if not path.exists(bp): 210 # raise errs.ValidationError(f"ValidationError: target path does not exist: {bp}") 211 212 for s in self.rsync_dict['sources']: 213 if not path.exists(s): 204 205 sources = self.rsync_dict['sources'] 206 for i in range(0, len(sources)): 207 s = sources[i] 208 if not path.exists(s): 214 209 raise errs.ValidationError(f"ValidationError: target path does not exist: {s}") 210 211 for bp in backup_paths: 215 212 try: 216 213 args = [s, bp] 214 217 215 if 'additional_args' in self.rsync_dict.keys(): 218 216 args = args + self.rsync_dict['additional_args'] 219 217 sub_utils.local_rsync_wrapper(args) 218 220 219 except errs.SubprocessError as e: 221 220 raise errs.SubprocessError( f"Error: rsync\n" -
branches/ipp-350_add_to_jira_conf_backups/confluence_backup.py
r40967 r41059 32 32 , ConfigSchemaLine('target_filename', True, str) 33 33 , ConfigSchemaLine('prefix_date', True, bool) 34 ]) 35 , ConfigSchemaSection('RSYNC', 36 [ ConfigSchemaLine('sources', True, list, 37 cfg_help.SpecialSchemaProcessing.commma_separated) 38 , ConfigSchemaLine('additional_args', False, list, 39 cfg_help.SpecialSchemaProcessing.space_separated) 34 40 ]) 35 41 , ConfigSchemaSection('MYSQLDUMP', -
branches/ipp-350_add_to_jira_conf_backups/confluence_backup_test.py
r40967 r41059 34 34 , 'target_filename' : 'confluence.tar.gz' 35 35 , 'prefix_date' : 'True' 36 } 37 config['RSYNC'] = \ 38 { 'sources' : (f"{os.path.join(tmpdir, 'rsync_source_dir1')}," 39 f"{os.path.join(tmpdir, 'rsync_source_dir2')}") 40 , 'additional_args' : '-a --delete-after' 36 41 } 37 42 config['MYSQLDUMP'] = \ … … 82 87 assert os.path.exists(confluence_attachment_2_filepath) 83 88 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 84 101 85 102 class TestArguments(object): … … 287 304 assert os.path.exists(expected_confluence_bak1_tar) 288 305 assert os.path.exists(expected_confluence_bak2_tar) 306 307 308 class TestRsyncOfFiles(object): 309 310 def test_confluence_rsync(self, tmpdir): 311 """This should be similar to the regular Backup version""" 312 create_items_for_full_confluence_backup_test(tmpdir) 313 config = make_config(tmpdir) 314 315 cb = ConfluenceBackup(config_file=config) 316 317 # Expected resulting rsync directories 318 expected_confluence_host_rsync1 = os.path.join(tmpdir, "host_backup_path", "rsync_source_dir1") 319 expected_confluence_bak1_rsync1 = os.path.join(tmpdir, "backup_1_path", "rsync_source_dir1") 320 expected_confluence_bak2_rsync1 = os.path.join(tmpdir, "backup_2_path", "rsync_source_dir1") 321 expected_confluence_host_rsync2 = os.path.join(tmpdir, "host_backup_path", "rsync_source_dir2") 322 expected_confluence_bak1_rsync2 = os.path.join(tmpdir, "backup_1_path", "rsync_source_dir2") 323 expected_confluence_bak2_rsync2 = os.path.join(tmpdir, "backup_2_path", "rsync_source_dir2") 324 assert not os.path.exists(expected_confluence_host_rsync1) 325 assert not os.path.exists(expected_confluence_bak1_rsync1) 326 assert not os.path.exists(expected_confluence_bak2_rsync1) 327 assert not os.path.exists(expected_confluence_host_rsync2) 328 assert not os.path.exists(expected_confluence_bak1_rsync2) 329 assert not os.path.exists(expected_confluence_bak2_rsync2) 330 # Expected resulting rsync files 331 expected_file_host_dir1 = os.path.join( expected_confluence_host_rsync1, "some_file_to_rsync") 332 expected_file_bak1_dir1 = os.path.join( expected_confluence_bak1_rsync1, "some_file_to_rsync") 333 expected_file_bak2_dir1 = os.path.join( expected_confluence_bak2_rsync1, "some_file_to_rsync") 334 expected_file_host_dir2 = os.path.join( expected_confluence_host_rsync2, "some_other_file_to_rsync") 335 expected_file_bak1_dir2 = os.path.join( expected_confluence_bak1_rsync2, "some_other_file_to_rsync") 336 expected_file_bak2_dir2 = os.path.join( expected_confluence_bak2_rsync2, "some_other_file_to_rsync") 337 assert not os.path.exists(expected_file_host_dir1) 338 assert not os.path.exists(expected_file_bak1_dir1) 339 assert not os.path.exists(expected_file_bak2_dir1) 340 assert not os.path.exists(expected_file_host_dir2) 341 assert not os.path.exists(expected_file_bak1_dir2) 342 assert not os.path.exists(expected_file_bak2_dir2) 343 344 rsync_result = cb._run_rsync() 345 assert rsync_result == 0 346 347 # All files Rsync'd 348 assert os.path.exists(expected_confluence_host_rsync1) 349 assert os.path.exists(expected_confluence_bak1_rsync1) 350 assert os.path.exists(expected_confluence_bak2_rsync1) 351 assert os.path.exists(expected_confluence_host_rsync2) 352 assert os.path.exists(expected_confluence_bak1_rsync2) 353 assert os.path.exists(expected_confluence_bak2_rsync2) 354 assert os.path.exists(expected_file_host_dir1) 355 assert os.path.exists(expected_file_bak1_dir1) 356 assert os.path.exists(expected_file_bak2_dir1) 357 assert os.path.exists(expected_file_host_dir2) 358 assert os.path.exists(expected_file_bak1_dir2) 359 assert os.path.exists(expected_file_bak2_dir2) -
branches/ipp-350_add_to_jira_conf_backups/jira_backup.py
r40967 r41059 32 32 , ConfigSchemaLine('target_filename', True, str) 33 33 , ConfigSchemaLine('prefix_date', True, bool) 34 ]) 35 , ConfigSchemaSection('RSYNC', 36 [ ConfigSchemaLine('sources', True, list, 37 cfg_help.SpecialSchemaProcessing.commma_separated) 38 , ConfigSchemaLine('additional_args', False, list, 39 cfg_help.SpecialSchemaProcessing.space_separated) 34 40 ]) 35 41 , ConfigSchemaSection('MYSQLDUMP', -
branches/ipp-350_add_to_jira_conf_backups/jira_backup_test.py
r40967 r41059 33 33 , 'target_filename' : 'jira.tar.gz' 34 34 , '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' 35 40 } 36 41 config['MYSQLDUMP'] = \ … … 81 86 assert os.path.exists(jira_attachment_2_filepath) 82 87 88 # Create a few folders to be rsync'd 89 rsync_source_dir1 = os.path.join(tmpdir, "rsync_source_dir1") 90 rsync_source_dir2 = os.path.join(tmpdir, "rsync_source_dir2") 91 file_in_rsync_dir1 = os.path.join(rsync_source_dir1, "some_file_to_rsync") 92 file_in_rsync_dir2 = os.path.join(rsync_source_dir2, "some_other_file_to_rsync") 93 os.makedirs(rsync_source_dir1) 94 os.makedirs(rsync_source_dir2) 95 Path(file_in_rsync_dir1).touch() 96 Path(file_in_rsync_dir2).touch() 97 assert os.path.exists(file_in_rsync_dir1) 98 assert os.path.exists(file_in_rsync_dir2) 99 83 100 84 101 class TestArguments(object): … … 288 305 assert os.path.exists(expected_jira_bak1_tar) 289 306 assert os.path.exists(expected_jira_bak2_tar) 307 308 309 class TestRsyncOfFiles(object): 310 311 def test_jira_rsync(self, tmpdir): 312 """This should be similar to the regular Backup version""" 313 create_items_for_full_jira_backup_test(tmpdir) 314 config = make_config(tmpdir) 315 316 jb = JiraBackup(config_file=config) 317 318 # Expected resulting rsync directories 319 expected_jira_host_rsync1 = os.path.join(tmpdir, "host_backup_path", "rsync_source_dir1") 320 expected_jira_bak1_rsync1 = os.path.join(tmpdir, "backup_1_path", "rsync_source_dir1") 321 expected_jira_bak2_rsync1 = os.path.join(tmpdir, "backup_2_path", "rsync_source_dir1") 322 expected_jira_host_rsync2 = os.path.join(tmpdir, "host_backup_path", "rsync_source_dir2") 323 expected_jira_bak1_rsync2 = os.path.join(tmpdir, "backup_1_path", "rsync_source_dir2") 324 expected_jira_bak2_rsync2 = os.path.join(tmpdir, "backup_2_path", "rsync_source_dir2") 325 assert not os.path.exists(expected_jira_host_rsync1) 326 assert not os.path.exists(expected_jira_bak1_rsync1) 327 assert not os.path.exists(expected_jira_bak2_rsync1) 328 assert not os.path.exists(expected_jira_host_rsync2) 329 assert not os.path.exists(expected_jira_bak1_rsync2) 330 assert not os.path.exists(expected_jira_bak2_rsync2) 331 # Expected resulting rsync files 332 expected_file_host_dir1 = os.path.join( expected_jira_host_rsync1, "some_file_to_rsync") 333 expected_file_bak1_dir1 = os.path.join( expected_jira_bak1_rsync1, "some_file_to_rsync") 334 expected_file_bak2_dir1 = os.path.join( expected_jira_bak2_rsync1, "some_file_to_rsync") 335 expected_file_host_dir2 = os.path.join( expected_jira_host_rsync2, "some_other_file_to_rsync") 336 expected_file_bak1_dir2 = os.path.join( expected_jira_bak1_rsync2, "some_other_file_to_rsync") 337 expected_file_bak2_dir2 = os.path.join( expected_jira_bak2_rsync2, "some_other_file_to_rsync") 338 assert not os.path.exists(expected_file_host_dir1) 339 assert not os.path.exists(expected_file_bak1_dir1) 340 assert not os.path.exists(expected_file_bak2_dir1) 341 assert not os.path.exists(expected_file_host_dir2) 342 assert not os.path.exists(expected_file_bak1_dir2) 343 assert not os.path.exists(expected_file_bak2_dir2) 344 345 rsync_result = jb._run_rsync() 346 assert rsync_result == 0 347 348 # All files Rsync'd 349 assert os.path.exists(expected_jira_host_rsync1) 350 assert os.path.exists(expected_jira_bak1_rsync1) 351 assert os.path.exists(expected_jira_bak2_rsync1) 352 assert os.path.exists(expected_jira_host_rsync2) 353 assert os.path.exists(expected_jira_bak1_rsync2) 354 assert os.path.exists(expected_jira_bak2_rsync2) 355 assert os.path.exists(expected_file_host_dir1) 356 assert os.path.exists(expected_file_bak1_dir1) 357 assert os.path.exists(expected_file_bak2_dir1) 358 assert os.path.exists(expected_file_host_dir2) 359 assert os.path.exists(expected_file_bak1_dir2) 360 assert os.path.exists(expected_file_bak2_dir2) -
branches/ipp-350_add_to_jira_conf_backups/testing/confluence_test.config
r40967 r41059 17 17 prefix_date = True 18 18 19 [RSYNC] 20 sources = /opt/atlassian, /var/atlassian 21 additional_args = -a --delete-after 22 19 23 [MYSQLDUMP] 20 24 user = dumper -
branches/ipp-350_add_to_jira_conf_backups/testing/jira_test.config
r40967 r41059 16 16 prefix_date = True 17 17 18 [RSYNC] 19 sources = /opt/atlassian, /var/atlassian 20 additional_args = -a --delete-after 21 18 22 [MYSQLDUMP] 19 23 user = dumper
Note:
See TracChangeset
for help on using the changeset viewer.
