def test_svn_action_rep_view_mapping_exclude_certain_file_0(self): '''Exclude test_dir_parent/a.* ''' test_case = 'svn_action_rep_view_mapping_exclude_certain_file_0' src_docker_cli = self.docker_svn_clients['svn_0'] dst_docker_cli = self.docker_p4d_clients['p4d_0'] src_depot_dir = '/%s' % test_case exc_path = self.svn_exclusion_construct_source_repos(src_depot_dir) for idx, exclude_path in enumerate([exc_path, exc_path + '_1']): dst_depot = '//depot/buildtest%s_%s/...' % (src_depot_dir, idx) dst_mapping = ((dst_depot, './...'), ) exclude_mapping = '-%s/a.*' % exclude_path src_mapping = ((src_depot_dir, ' '), (exclude_mapping, ' ')) excluded_files = [ os.path.join(exclude_path[len(src_depot_dir) + 1:], fn) for fn in [ 'a.exe', 'a.json', 'a.txt', ] ] replicate_SvnP4Replicate(src_mapping, dst_mapping, src_docker_cli, dst_docker_cli) verify_replication(src_mapping, dst_mapping, src_docker_cli, dst_docker_cli, excluded_files=excluded_files) obliterate_all_depots(dst_docker_cli)
def test_svn_action_rep_view_mapping_exclude_external_subdirs(self): '''Exclude a whole external: test_dir_parent/deploy ''' test_case = 'svn_action_rep_view_mapping_exclude_externals_subdirs' src_docker_cli = self.docker_svn_clients['svn_0'] dst_docker_cli = self.docker_p4d_clients['p4d_0'] src_depot_dir = '/%s' % test_case exc_path = self.svn_exclusion_construct_source_repos(src_depot_dir) for idx, exclude_path in enumerate([exc_path, exc_path + '_1']): dst_depot = '//depot/buildtest%s_%s/...' % (src_depot_dir, idx) dst_mapping = ((dst_depot, './...'), ) exclude_path = '-%s/deploy' % exclude_path src_mapping = ((src_depot_dir, ' '), (exclude_path, ' ')) verification_exclude = exclude_path[len('-') + len(src_depot_dir):] exclude_subdir = [ verification_exclude, ] replicate_SvnP4Replicate(src_mapping, dst_mapping, src_docker_cli, dst_docker_cli) verify_replication(src_mapping, dst_mapping, src_docker_cli, dst_docker_cli, excluded_subdirs=exclude_subdir) obliterate_all_depots(dst_docker_cli)
def test_svn_action_rep_view_mapping_rel_externals_include_subsubdir(self): '''Exclude external: test_dir_parent/hadoop/hadoop_src but keep test_dir_parent/hadoop/hadoop_src/resources/images ''' test_case = 'svn_action_rep_view_mapping_rel_externals_include_subsubdir' src_docker_cli = self.docker_svn_clients['svn_0'] dst_docker_cli = self.docker_p4d_clients['p4d_0'] src_depot_dir = '/%s' % test_case exc_path = self.svn_exclusion_construct_source_repos(src_depot_dir) for idx, exclude_path in enumerate([exc_path, exc_path + '_1']): dst_depot = '//depot/buildtest%s_%s/...' % (src_depot_dir, idx) dst_mapping = ((dst_depot, './...'), ) exclude_dir = '-%s/hadoop/hadoop_src' % exclude_path include_dir = '+%s/hadoop/hadoop_src/resources/images' % exclude_path src_mapping = ( (src_depot_dir, ' '), (exclude_dir, ' '), (include_dir, ' '), ) external_files_to_exclude = [ 'resources/css/site.css', 'site.xml', 'xdoc/index.xml', 'xdoc/irc-channel.xml', 'xdoc/issue-tracking.xml', 'xdoc/mail-lists.xml', 'xdoc/release-notes.xml', 'xdoc/team-list.xml', ] excluded_files = [ os.path.join(exclude_path[len(src_depot_dir) + 1:], 'hadoop/hadoop_src/%s' % fn) for fn in external_files_to_exclude ] replicate_SvnP4Replicate(src_mapping, dst_mapping, src_docker_cli, dst_docker_cli) verify_replication(src_mapping, dst_mapping, src_docker_cli, dst_docker_cli, excluded_files=excluded_files) obliterate_all_depots(dst_docker_cli)
def test_replicate_sample_commit_message_reformat_review(self): '''verify that "#review" in commit message is changed to "# review" ''' test_case = 'copy_commit_message_reformat_review' src_docker_cli = self.docker_clients[0] dst_docker_cli = self.docker_clients[1] src_dir = '/depot/Talkhouse/main-dev' orig_desc = 'add new file, and testing review in comments\n' orig_desc += '#review-22\n' orig_desc += '##review-22review\n' expected_desc = 'add new file, and testing review in comments\n' expected_desc += '# review-22\n' expected_desc += '## review-22review\n' with get_p4d_from_docker(src_docker_cli, src_dir) as p4: clientspec = p4.fetch_client(p4.client) ws_root = clientspec._root test_file = os.path.join(ws_root, 'testfile') with open(test_file, 'wt') as fo: fo.write('My name is %s!\n' % test_file) p4.run_add('-f', test_file) output_lines = p4.run_submit('-d', orig_desc) for line in output_lines: if 'submittedChange' in line: src_rev = line['submittedChange'] dst_depot = self.replicate_sample_dir_withdocker( src_dir, src_docker_cli=src_docker_cli, dst_docker_cli=dst_docker_cli, do_change_desc_verification=False, obliterate=False) dst_dir = dst_depot[1:-4] with get_p4d_from_docker(dst_docker_cli, dst_dir) as p4: changes = p4.run_changes('-l', '...') last_change = changes[0] desc = last_change['desc'] self.assertTrue(expected_desc in desc, desc) obliterate_all_depots(dst_docker_cli) logger.passed(test_case)
def test_svn_action_rep_view_mapping_exclude_subdir_inc_one_file(self): test_case = 'svn_action_rep_view_mapping_exclude_subdir_inc_one_file' src_docker_cli = self.docker_svn_clients['svn_0'] dst_docker_cli = self.docker_p4d_clients['p4d_0'] src_depot_dir = '/%s' % test_case exc_path = self.svn_exclusion_construct_source_repos(src_depot_dir) #exc_path = exc_path[len(src_depot_dir):] for idx, exclude_path in enumerate([exc_path, exc_path + '_1']): dst_depot = '//depot/buildtest%s_%s/...' % (src_depot_dir, idx) dst_mapping = ((dst_depot, './...'), ) logger.error(exc_path) exclude_mapping = '-%s/*.exe' % exclude_path include_mapping = '+%s/b.exe' % exclude_path src_mapping = ( (src_depot_dir, ' '), (exclude_mapping, ' '), (include_mapping, ' '), ) excluded_files = [ os.path.join(exclude_path[len(src_depot_dir) + 1:], fn) for fn in [ 'a.exe', 'c.exe/a.json', 'c.exe/a.txt', 'c.exe/b.txt', ] ] replicate_SvnP4Replicate(src_mapping, dst_mapping, src_docker_cli, dst_docker_cli) verify_replication(src_mapping, dst_mapping, src_docker_cli, dst_docker_cli, excluded_files=excluded_files) obliterate_all_depots(dst_docker_cli)
def test_svn_action_rep_review_commitmsgs(self): orig_desc = 'add new file, and testing review in comments\n' orig_desc += '#review-22\n' orig_desc += '##review-22review\n' expected_desc = 'add new file, and testing review in comments\n' expected_desc += '# review-22\n' expected_desc += '## review-22review\n' dst_depot = self.svn_action_rep_action('remove_review_commitmsg', self.svn_test_action_commitmsg, commit_msg=['utf-8', orig_desc]) dst_docker_cli = self.docker_p4d_clients['p4d_0'] dst_dir = dst_depot[1:-4] with get_p4d_from_docker(dst_docker_cli, dst_dir) as p4: changes = p4.run_changes('-l', '...') last_change = changes[0] desc = last_change['desc'] self.assertTrue(expected_desc in desc, desc) obliterate_all_depots(dst_docker_cli)
def test_svn_action_rep_view_mapping_externals_include_subdir(self): '''Exclude external: test_dir_parent/tests but keep test_dir_parent/tests/test-artifacts ''' test_case = 'svn_action_rep_view_mapping_externals_include_subdir' src_docker_cli = self.docker_svn_clients['svn_0'] dst_docker_cli = self.docker_p4d_clients['p4d_0'] src_depot_dir = '/%s' % test_case exc_path = self.svn_exclusion_construct_source_repos(src_depot_dir) for idx, exclude_path in enumerate([exc_path, exc_path + '_1']): dst_depot = '//depot/buildtest%s_%s/...' % (src_depot_dir, idx) dst_mapping = ((dst_depot, './...'), ) exclude_dir = '-%s/tests' % exclude_path include_dir = '+%s/tests/test-artifacts' % exclude_path src_mapping = ( (src_depot_dir, ' '), (exclude_dir, ' '), (include_dir, ' '), ) verification_exclude = exclude_dir[len('-') + len(src_depot_dir):] exclude_subdir = [ os.path.join(verification_exclude, 'test-execution'), ] replicate_SvnP4Replicate(src_mapping, dst_mapping, src_docker_cli, dst_docker_cli) verify_replication(src_mapping, dst_mapping, src_docker_cli, dst_docker_cli, excluded_subdirs=exclude_subdir) obliterate_all_depots(dst_docker_cli)
def svn_action_rep_action(self, action, act_func, **kwargs): '''create test env, run test, and verify replication @param action, string of action to be tested @param act_func, function to be called to create test svn repo @param **kwargs, other arguments used to create test repo ''' test_case = 'svn_action_rep_%s' % action src_depot_dir = '/reptest_%s' % action dst_depot_dir = src_depot_dir src_docker_cli = self.docker_svn_clients['svn_0'] dst_docker_cli = kwargs.get('dst_docker_cli') if not dst_docker_cli: dst_docker_cli = self.docker_p4d_clients['p4d_0'] else: del kwargs['dst_docker_cli'] group_num = kwargs.get('group_num') if group_num: del kwargs['group_num'] test_dir = act_func(src_docker_cli, src_depot_dir, **kwargs) if test_dir: src_depot_dir = test_dir dst_depot = '//depot/buildtest%s/...' % dst_depot_dir dst_view = ((dst_depot, './...'), ) if kwargs.get('replicate_only_branch_dir'): src_depot_dir = os.path.join(src_depot_dir, 'branches') del kwargs['replicate_only_branch_dir'] src_mapping = ((src_depot_dir, ' '), ) dst_mapping = dst_view replicate_SvnP4Replicate(src_mapping, dst_mapping, src_docker_cli, dst_docker_cli, **kwargs) verify_replication(src_mapping, dst_mapping, src_docker_cli, dst_docker_cli, **kwargs) if group_num == None: return dst_depot obliterate_all_depots(dst_docker_cli) svn_revs = get_svn_rev_list(src_docker_cli, src_depot_dir) num_replicate = group_num svn_revs.insert(0, 0) for src_counter in svn_revs[::num_replicate]: replicate_SvnP4Replicate(src_mapping, dst_mapping, src_docker_cli, dst_docker_cli, src_counter=0, replicate_change_num=num_replicate, **kwargs) verify_replication(src_mapping, dst_mapping, src_docker_cli, dst_docker_cli, src_counter=src_counter, replicate_change_num=num_replicate, **kwargs) logger.passed(test_case) return dst_depot
def setUp(self): '''Obliterate all p4 depots due to file number limit of trial license ''' dst_docker_cli = self.docker_p4d_clients['p4d_0'] obliterate_all_depots(dst_docker_cli)