def svn_test_action_commitmsg(self, docker_cli, depot_dir, commit_msg): with get_svn_from_docker(docker_cli) as (svn, svn_root): testdir = os.path.join(svn_root, depot_dir[1:]) testfile = os.path.join(testdir, 'repo_test_file') os.mkdir(testdir) act_str = 'adding %s\n' % testdir with open(testfile, 'wt') as f: f.write(act_str) svn.run_add(testdir) svn.run_checkin(testdir, '%s' % act_str) encoding, act_str_orig = commit_msg act_str = act_str_orig[:] with open(testfile, 'a') as f: f.write(act_str.encode(encoding)) act_str = act_str.encode(encoding) cmd = "--encoding %s -m '%s'" % (encoding, act_str) svn.run('commit', cmd) # more tests for utf-8 encoding = 'utf-8' act_str = act_str_orig[:] with open(testfile, 'a') as f: f.write(act_str.encode(encoding)) act_str = act_str.encode(encoding) cmd = "--encoding %s -m '%s'" % (encoding, act_str) svn.run('commit', cmd)
def svn_test_russian_filename(self, docker_cli, depot_dir): with get_svn_from_docker(docker_cli) as (svn, svn_root): testdir = os.path.join(svn_root, depot_dir[1:]) os.mkdir(testdir) import locale sys_locale = locale.getdefaultlocale() filename = u'следовательносуществую.txt' filename = filename.encode(sys_locale[1]) filename = os.path.join(testdir, filename) with open(filename, 'w') as f: f.write(filename) from subprocess import Popen, check_output, PIPE p = Popen('svn add %s' % testdir, stdout=PIPE, stderr=PIPE, shell=True) out, err = p.communicate() logger.info('%s, %s' % (out, err)) p = Popen('svn commit -m russianfilename', stdout=PIPE, stderr=PIPE, shell=True) out, err = p.communicate() logger.info('%s, %s' % (out, err))
def svn_test_externals_9(self, docker_cli, depot_dir): external_cfg = '../bigtop/branches/hadoop-0.23/bigtop-deploy bigtop-deploy' src_svn = self.docker_svn_clients['svn_0'] with get_svn_from_docker(docker_cli) as (svn, svn_root): testdir = os.path.join(svn_root, depot_dir[1:]) testfile = os.path.join(testdir, 'repo_test_file') os.mkdir(testdir) action = 'adding %s\n' % testdir with open(testfile, 'wt') as f: f.write(action) svn.run_add(testdir) svn.propset('svn:externals', external_cfg, testdir) svn.run_checkin(testdir, '%s' % action) action = 'editing %s\n' % testfile with open(testfile, 'a') as f: f.write(action) svn.run_checkin(testfile, '%s' % action) bigtop_repos = os.path.join(svn_root, 'bigtop/branches/hadoop-0.23') svn.run_update(bigtop_repos, update_arg='--set-depth infinity') testdir = os.path.join(bigtop_repos, 'bigtop-deploy') action = 'delete %s' % testdir svn.run_remove(testdir) svn.run_checkin(testdir, action)
def svn_test_externals_special1(self, docker_cli, depot_dir, external_cfgs): '''this function generates a test directory with interleaving externals and files ''' src_svn = self.docker_svn_clients['svn_0'] with get_svn_from_docker(docker_cli) as (svn, svn_root): testdir = os.path.join(svn_root, depot_dir[1:]) testfile = os.path.join(testdir, 'repo_test_file') os.mkdir(testdir) action = 'adding %s\n' % testdir with open(testfile, 'wt') as f: f.write(action) svn.run_add(testdir) svn.run_checkin(testdir, '%s' % action) # set external for external_cfg in external_cfgs: svn.run_update(testdir) external_todir_rel = external_cfg.split()[1] external_todir_rel_root = external_todir_rel.split('/')[0] dir_to_add = os.path.join(testdir, external_todir_rel_root) external_todir_abs = os.path.join(testdir, external_todir_rel) external_todir_base = os.path.split(external_todir_abs)[0] os.makedirs(external_todir_base) testfile = os.path.join(external_todir_base, 'test_file') action = 'adding %s\n' % testfile with open(testfile, 'wt') as f: f.write(action) svn.run_add(dir_to_add) svn.run_checkin(dir_to_add, '%s' % action) svn.run_update(testdir) if not external_cfg: svn.propdel('svn:externals', testdir) else: svn.propset('svn:externals', external_cfg, testdir) svn.run_checkin(testdir, 'added external %s' % external_cfg) action = 'editing %s\n' % testfile with open(testfile, 'a') as f: f.write(action) svn.run_checkin(testfile, '%s' % action) # delete external svn.run_update(testdir) svn.propdel('svn:externals', testdir) svn.run_checkin(testdir, 'del external') action = 'editing %s\n' % testfile with open(testfile, 'a') as f: f.write(action) svn.run_checkin(testfile, '%s' % action)
def svn_test_action_add(self, docker_cli, depot_dir): with get_svn_from_docker(docker_cli) as (svn, svn_root): testdir = os.path.join(svn_root, depot_dir[1:]) testfile = os.path.join(testdir, 'repo_test_file') os.mkdir(testdir) action = 'adding %s\n' % testdir with open(testfile, 'wt') as f: f.write(action) svn.run_add(testdir) svn.run_checkin(testdir, '%s' % action)
def svn_test_setup_src_branch(self, docker_cli, depot_dir, edits_in_other_folder_before_copy=False): with get_svn_from_docker(docker_cli) as (svn, svn_root): test_dir = os.path.join(svn_root, depot_dir[1:]) trunk_dir = os.path.join(test_dir, 'trunk') branch_dir_1 = os.path.join(test_dir, 'branches_1') branch_dir_2 = os.path.join(test_dir, 'branches_2') src_dir = os.path.join(trunk_dir, 'src') for directory in [ test_dir, trunk_dir, branch_dir_1, branch_dir_2, src_dir ]: os.mkdir(directory) action = 'adding %s\n' % directory svn.run_add(directory) svn.run_checkin(directory, '%s' % action) # add test file test_file = os.path.join(src_dir, 'repo_test_file') test_file2 = os.path.join(branch_dir_2, 'repo_test_file') for tf in [test_file2, test_file]: action = 'adding %s\n' % tf with open(tf, 'wt') as f: f.write(action) svn.run_add(tf) svn.run_checkin(tf, '%s' % action) if edits_in_other_folder_before_copy: for idx in range(3): # edit test file action = 'editing %s Num. %d\n' % (test_file2, idx) with open(test_file2, 'a') as f: f.write(action) svn.run_checkin(test_file2, '%s' % action) # add branch branch1 = os.path.join(branch_dir_1, generate_random_str()) svn.run_copy(trunk_dir, branch1) svn.run_checkin(branch1, '1st branch') # edit test file in branch test_file = os.path.join(branch1, '/'.join(test_file.split('/')[-2:])) action = 'editing %s\n' % test_file with open(test_file, 'a') as f: f.write(action) svn.run_checkin(test_file, '%s' % action) return trunk_dir[len(svn_root):], branch1[len(svn_root):]
def svn_test_externals_8(self, docker_cli, depot_dir): external_cfg0 = '../bigtop/branches/hadoop-0.23/docs docs' external_cfgs = [external_cfg0] self.common_svn_test_externals(docker_cli, depot_dir, external_cfgs) src_svn = self.docker_svn_clients['svn_0'] with get_svn_from_docker(docker_cli) as (svn, svn_root): bigtop_repos = os.path.join(svn_root, 'bigtop/branches/hadoop-0.23') svn.run_update(bigtop_repos, update_arg='--set-depth infinity') testdir = os.path.join(bigtop_repos, 'docs') action = 'delete %s' % testdir svn.run_remove(testdir) svn.run_checkin(testdir, action)
def svn_test_action_symbol_in_commitmsg(self, docker_cli, depot_dir, commit_msg): with get_svn_from_docker(docker_cli) as (svn, svn_root): testdir = os.path.join(svn_root, depot_dir[1:]) testfile = os.path.join(testdir, 'repo_test_file') os.mkdir(testdir) act_str = 'adding %s\n' % testdir with open(testfile, 'wt') as f: f.write(act_str) svn.run_add(testdir) svn.run_checkin(testdir, '%s' % act_str) with open(testfile, 'a') as f: f.write('something more') svn.run_checkin(testfile, commit_msg)
def svn_test_add_empty_dir(self, docker_cli, project_dir): with get_svn_from_docker(docker_cli) as (svn, svn_root): # add project directory project_dir = os.path.join(svn_root, project_dir[1:]) os.mkdir(project_dir) test_dir = os.path.join(project_dir, 'test_dir') os.mkdir(test_dir) action = 'add %s' % project_dir svn.run_add(project_dir) svn.run_checkin(project_dir, action) test_file = os.path.join(test_dir, 'repo_test_file') action = 'add %s' % test_file with open(test_file, 'wt') as f: f.write(action) svn.run_add(test_file) svn.run_checkin(test_file, action)
def svn_test_action_deletefile(self, docker_cli, depot_dir): with get_svn_from_docker(docker_cli) as (svn, svn_root): testdir = os.path.join(svn_root, depot_dir[1:]) testfile = os.path.join(testdir, 'repo_test_file') os.mkdir(testdir) action = 'add %s' % testdir with open(testfile, 'wt') as f: f.write(action) svn.run_add(testdir) svn.run_checkin(testdir, action) action = 'edit %s' % testfile with open(testfile, 'a') as f: f.write(action) svn.run_checkin(testfile, action) action = 'delete %s' % testfile svn.run_remove(testfile) svn.run_checkin(testfile, action)
def common_svn_test_externals(self, docker_cli, depot_dir, external_cfgs): src_svn = self.docker_svn_clients['svn_0'] with get_svn_from_docker(docker_cli) as (svn, svn_root): testdir = os.path.join(svn_root, depot_dir[1:]) testfile = os.path.join(testdir, 'repo_test_file') os.mkdir(testdir) action = 'adding %s\n' % testdir with open(testfile, 'wt') as f: f.write(action) svn.run_add(testdir) svn.run_checkin(testdir, '%s' % action) # set external for external_cfg in external_cfgs: svn.run_update(testdir) if not external_cfg: svn.propdel('svn:externals', testdir) else: svn.propset('svn:externals', external_cfg, testdir) svn.run_checkin(testdir, 'added external %s' % external_cfg) action = 'editing %s\n' % testfile with open(testfile, 'a') as f: f.write(action) svn.run_checkin(testfile, '%s' % action) # delete external svn.run_update(testdir) svn.propdel('svn:externals', testdir) svn.run_checkin(testdir, 'del external') action = 'editing %s\n' % testfile with open(testfile, 'a') as f: f.write(action) svn.run_checkin(testfile, '%s' % action)
def svn_exclusion_construct_source_repos(self, src_depot_dir): logger.info('testing %s' % src_depot_dir) # create svn repo tree actions = [ 'edit', 'rename', 'delete_file', 'add_exec', 'add_dir', 'edit', 'add_exec', 'add_dir', 'edit', 'add_exec', 'add_dir', 'edit', ] src_docker_cli = self.docker_svn_clients['svn_0'] dst_docker_cli = self.docker_p4d_clients['p4d_0'] init_external_cfg = [ '^/bigtop/branches/hadoop-0.23/bigtop-deploy deploy', '^/bigtop/branches/hadoop-0.23/bigtop-tests tests', '^/bigtop/branches/hadoop-0.23/src/site hadoop_src', ] mod_external_cfgs = [ [ # remove tests '^/bigtop/branches/hadoop-0.23/bigtop-deploy deploy', '^/bigtop/branches/hadoop-0.23/src/site hadoop_src', ], [ # add tests back '^/bigtop/branches/hadoop-0.23/bigtop-deploy deploy', '^/bigtop/branches/hadoop-0.23/bigtop-tests tests', '^/bigtop/branches/hadoop-0.23/src/site hadoop_src', ], [ # relocate hadoop_src '^/bigtop/branches/hadoop-0.23/src/site hadoop/hadoop_src', ], [ # relocate hadoop_src '^/bigtop/branches/hadoop-0.23/src/site hadoop_src', '^/bigtop/branches/hadoop-0.23/bigtop-tests tests', ], ] svn_test_action_actions(src_docker_cli, src_depot_dir, actions=actions) with get_svn_from_docker(src_docker_cli) as (svn, svn_root): # add project directory project_abs_dir = os.path.join(svn_root, src_depot_dir[1:]) svn.run_update(project_abs_dir, update_arg='--depth infinity') trunk_dir = os.path.join(project_abs_dir, 'trunk') for idx, dir_name in enumerate([ 'test_dir_parent', 'test_dir_parent_1', ]): trunk_parent = os.path.join(trunk_dir, dir_name) os.mkdir(trunk_parent) if idx == 0: exclude_path = trunk_parent[len(svn_root):] ''' add test_dir_parent/c.exe test_dir_parent/c.exe/{a.json, a.txt, b.txt} ''' exec_subdir = os.path.join(trunk_parent, 'c.exe') os.mkdir(exec_subdir) for fn in ['a.json', 'a.txt', 'b.txt']: file_path = os.path.join(exec_subdir, fn) with open(file_path, 'wt') as f: f.write('my name is %s' % fn) normal_subdir = os.path.join(trunk_parent, 'some_dir') os.mkdir(normal_subdir) for fn in ['a.json', 'a.txt', 'b.txt', 'c.exe']: file_path = os.path.join(normal_subdir, fn) with open(file_path, 'wt') as f: f.write('my name is %s' % fn) '''add test_dir_parent/{a.exe, b.exe, a.json, b.json, a.txt, b.txt} ''' for fn in [ 'a.exe', 'b.exe', 'a.json', 'b.json', 'a.txt', 'b.txt' ]: file_path = os.path.join(trunk_parent, fn) with open(file_path, 'wt') as f: f.write('my name is %s' % fn) svn.run_add(trunk_parent) # add svn:externals # test_dir_parent/bigtop-deploy if idx == 0: svn.propset('svn:externals', '\n'.join(init_external_cfg), trunk_parent) svn.run_checkin(trunk_parent, 'adding %s' % trunk_parent) # edit test_dir_parent/a.exe testfile = os.path.join(trunk_parent, 'a.exe') action = 'editing %s\n' % testfile with open(testfile, 'a') as f: f.write(action) svn.run_checkin(testfile, '%s' % action) # add svn:externals # test_dir_parent/bigtop-deploy if idx == 1: svn.run_update(trunk_parent, update_arg='--depth infinity') svn.propset('svn:externals', '\n'.join(init_external_cfg), trunk_parent) svn.run_checkin(trunk_parent, 'adding externals') # edit test_dir_parent/b.json testfile = os.path.join(trunk_parent, 'b.json') action = 'editing %s\n' % testfile with open(testfile, 'a') as f: f.write(action) svn.run_checkin(testfile, '%s' % action) for ext_cfg in mod_external_cfgs: svn.run_update(trunk_parent, update_arg='--depth infinity') svn.propset('svn:externals', '\n'.join(ext_cfg), trunk_parent) svn.run_checkin(trunk_parent, 'changing externals: %s' % str(ext_cfg)) testfile = os.path.join(trunk_parent, 'b.json') action = 'editing %s\n' % testfile with open(testfile, 'a') as f: f.write(action) svn.run_checkin(testfile, '%s' % action) testfile = os.path.join(trunk_dir, 'a.txt') action = 'editing %s\n' % testfile with open(testfile, 'a') as f: f.write(action) svn.run_add(testfile) svn.run_checkin(testfile, '%s' % action) return exclude_path