def build_test_revision_move(self, docker_cli, depot_dir):
        '''Create revision history of a file which has 9 "edit" revisions and
        one "move" revision.
        '''
        src_from_file_path = None

        with get_p4d_from_docker(docker_cli, depot_dir) as src_p4:
            # create integ_src submits
            src_from_file_path = os.path.join(src_p4.cwd, 'move_from')
            # add 1st revision
            with open(src_from_file_path, 'wt') as f:
                f.write('1\n')
            src_p4.run_add(src_from_file_path)
            src_p4.run_submit('-d', '1')
            # add 2nd ... 9th revisions
            revs = map(str, range(2, 10))
            for rev in revs:
                src_p4.run_edit(src_from_file_path)
                with open(src_from_file_path, 'at') as f:
                    f.write(rev + '\n')
                src_p4.run_submit('-d', rev)
    
            # move last rev to new file
            src_to_file_path = os.path.join(src_p4.cwd, 'move_to')
            #move_src_rev = '%s' % (src_from_file_path, revs[-1])
            src_p4.run_edit(src_from_file_path)
            src_p4.run_move(src_from_file_path, src_to_file_path)
            src_p4.run_submit('-d', 'moving %s to %s' % (src_from_file_path,
                                                         src_to_file_path))

        return src_from_file_path
Exemplo n.º 2
0
    def test_replicate_sample_depot_copy_deleted_rev(self):
        '''verify that branch generated by "p4 populate -f" could be replicated.
        '''
        test_case = 'replicate_sample_depot_copy_deleted_rev'

        src_docker_cli = self.docker_clients[0]
        #dst_docker_cli = self.docker_clients[1]

        # run populate -f
        src_dir = '//depot/Jam/...'
        dst_dir = '//depot/RBG_%s/...' % test_case
        populate_rev = '326'
        with get_p4d_from_docker(src_docker_cli, '/depot') as p4:
            # changelist 326 has "delete" action
            p4.run_populate('-f', '%s@%s' % (src_dir, populate_rev), dst_dir)
        import lib.P4ReleaseBranchGenerate as p4rbg
        # use Release Branch Generation script to copy the rest changelists.
        p4_user = BUILD_TEST_P4D_USER
        ip = src_docker_cli.get_container_ip_addr()
        p4_port = '%s:1666' % ip
        p4_passwd = ''
        p4rbg.release_branch_generate(p4_port, p4_user, p4_passwd, src_dir,
                                      dst_dir)

        # replicate
        depot_dir = dst_dir[1:-4]
        self.replicate_sample_dir_withdocker(depot_dir,
                                             src_docker_cli=src_docker_cli,
                                             do_change_desc_verification=False,
                                             do_integration_verification=False)

        logger.passed(test_case)
Exemplo n.º 3
0
    def test_replicate_sample_depot_specialsymbols_1(self):
        '''verify that file(dir) name including special symbols '% * # @'
        could also be replicated properly
        '''
        test_case = 'replicate_sample_depot_specialsymbols'

        depot_dir = '/depot/test_special_name'
        src_docker_cli = self.docker_p4d_clients['p4d_0']

        with get_p4d_from_docker(src_docker_cli, depot_dir) as p4:
            clientspec = p4.fetch_client(p4.client)
            ws_root = clientspec._root
            # add a file with special symbols in a directory with special symbols
            special_dir_name = 'a_dir_with_%_*_#_@_in_its_name'
            test_dir = tempfile.mkdtemp(prefix=special_dir_name, dir=ws_root)
            special_file_names = [
                'a_file_with_%_*_#_@_in_its_name.txt',
                'another file with whitespaces.txt'
            ]
            for fn in special_file_names:
                special_file_path = os.path.join(test_dir, fn)
                description = 'test a file with file name %s' % fn
                with open(special_file_path, 'wt') as f:
                    f.write('My name is %s!\n' % fn)
                p4.run_add('-f', special_file_path)
                p4.run_submit('-d', description)

        self.replicate_sample_dir_withdocker(depot_dir)
        logger.passed(test_case)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    def test_replicate_sample_depot_specialsymbols(self):
        '''verify that file(dir) name including special symbols '% * # @'
        could also be replicated properly
        '''
        test_case = 'replicate_sample_depot_specialsymbols'

        src_docker_cli = self.docker_clients[0]
        dst_docker_cli = self.docker_clients[1]

        # create workspace
        depot_dir = '/depot/test_special_name_%s' % test_case

        with get_p4d_from_docker(src_docker_cli, depot_dir) as src_p4:
            clientspec = src_p4.fetch_client(src_p4.client)
            ws_root = clientspec._root

            # add a file with special symbols in a directory with special symbols
            special_dir_name = 'a_dir_with_%_*_#_@_in_its_name'
            special_depot_dir_name = 'a_dir_with_%25_%2A_%23_%40_in_its_name'
            test_dir = os.path.join(ws_root, special_dir_name)
            os.mkdir(test_dir)

            fn_depots = [
                ('a_file_with_%_*_#_@_in_its_name.txt',
                 'a_file_with_%25_%2A_%23_%40_in_its_name.txt'),
                ('another file with whitespaces.txt',
                 'another file with whitespaces.txt'),
            ]
            for special_file_name, special_depot_file_name in fn_depots:
                test_depot_dir = os.path.join(ws_root, special_depot_dir_name)
                special_file_path = os.path.join(test_dir, special_file_name)
                special_depot_file_path = os.path.join(
                    test_depot_dir, special_depot_file_name)
                description = 'test a file with file name %s' % special_file_name
                with open(special_file_path, 'wt') as f:
                    f.write('My name is %s!\n' % special_file_name)
                src_p4.run_add('-f', special_file_path)
                src_p4.run_submit('-d', description)

                for idx in range(2):
                    src_p4.run_edit(special_depot_file_path)
                    with open(special_file_path, 'a') as f:
                        f.write('edited %s!\n' % special_file_path)
                    desc = 'edit %s(%s) #%d' % (special_file_path,
                                                special_depot_file_path, idx)
                    src_p4.run_submit('-d', desc)

            src_p4.run_delete(special_depot_file_path)
            src_p4.run_submit('-d', 'delete special file')

        # replicate
        self.replicate_sample_dir_withdocker(depot_dir,
                                             src_docker_cli=src_docker_cli)

        logger.passed(test_case)
Exemplo n.º 6
0
    def test_replicate_sample_integration_ignored(self):
        test_case = 'replicate_sample_integration_ignored'

        src_docker_cli = self.docker_clients['ignored-src']
        dst_docker_cli = self.docker_clients['ignored-dst']

        src_dir = '/depot/Talkhouse/main-dev'
        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)
            p4.run_submit('-d', 'add test file')

            #  src should not be in //depot/Talkhouse/main-dev'
            integ_src = '//depot/Talkhouse/rel1.0/system/ide.log'

            # case 1
            p4.run_edit(test_file)
            with open(test_file, 'at') as fo:
                fo.write('editing %s!\n' % test_file)
            p4.run_integrate('-f', '-Rb', '-Rd', '%s#1' % integ_src, test_file)
            p4.run_resolve('-ay')
            p4.run_submit('-d', 'ignored integration, edit and changed')

            # case 2
            p4.run_edit(test_file)
            p4.run_integrate('-f', '-Rb', '-Rd', '%s#1' % integ_src, test_file)
            p4.run_resolve('-ay')
            p4.run_submit('-d', 'ignored integration, edit but no change')

            # case 3
            test_file1 = '%s_1' % test_file
            with open(test_file1, 'wt') as fo:
                fo.write('My name is %s!\n' % test_file1)
            p4.run_add('-f', test_file1)
            p4.run_integrate('-f', '-Rb', '-Rd', '%s#1' % integ_src, test_file)
            p4.run_resolve('-ay')
            p4.run_submit('-d', 'add another file and ignored integrate')

            #  case 4
            p4.run_integrate('-f', '-Rb', '-Rd', '%s#1' % integ_src, test_file)
            p4.run_resolve('-ay')
            p4.run_submit('-d', 'ignored integration, just integrate')

        try:
            self.replicate_sample_dir_withdocker(src_dir,
                                                 src_docker_cli=src_docker_cli,
                                                 dst_docker_cli=dst_docker_cli)
        except RepP4Exception, e:
            if '--target-empty-file' not in str(e):
                raise
Exemplo n.º 7
0
    def test_replicate_sample_depot_ignored_files(self):
        '''verify replication of .so, .a and others that could be ignored by
        SCMs by default
        '''
        test_case = 'replicate_sample_depot_ignored_files'

        depot_dir = '/depot/Misc/Artwork'
        src_docker_cli = self.docker_clients[0]
        with get_p4d_from_docker(src_docker_cli, depot_dir) as src_p4:
            clientspec = src_p4.fetch_client(src_p4.client)
            ws_root = clientspec._root

            src_p4.run_sync('...')
            ignored_suffixes = [
                'so', 'a', 'o', 'lo', 'la', 'al', 'libs', 'so.0', 'so.1',
                'so.9', 'pyc', 'pyo', 'rej', '~', 'swp', 'DS_Store'
            ]
            test_suffixes = ignored_suffixes + ['txt']

            # add them in separate folders
            for suffix in test_suffixes:
                test_dir = os.path.join(ws_root, 'suffix_%s' % suffix)
                os.mkdir(test_dir)
                fn = os.path.join(test_dir, 'a.%s' % suffix)
                with open(fn, 'wt') as f:
                    f.write('%s' % fn)
                src_p4.run_add('-ft', 'xbinary', fn)
                src_p4.run_submit('-d', 'submit %s' % fn)

            # add them all to one folder in one change
            test_dir = os.path.join(ws_root, 'suffix_all_in_one')
            os.mkdir(test_dir)
            for suffix in test_suffixes:
                fn = os.path.join(test_dir, 'a.%s' % suffix)
                with open(fn, 'wt') as f:
                    f.write('%s' % fn)
                src_p4.run_add('-ft', 'xbinary', fn)
            src_p4.run_submit('-d', 'submit files in one change')

            txt_file = os.path.join(test_dir, 'a.txt')
            src_p4.run_edit(txt_file)
            with open(fn, 'wt') as f:
                f.write('edited %s' % fn)
            src_p4.run_submit('-d', 'submit %s' % txt_file)

        # replicaten
        self.replicate_sample_dir_withdocker(depot_dir,
                                             src_docker_cli=src_docker_cli)

        logger.passed(test_case)
Exemplo n.º 8
0
    def test_replicate_sample_depot_Jam_ingroups(self):
        '''replicate the whole /repos/bigtop/trunk
        '''
        test_case = 'replicate_sample_depot_Jam_ingroup'

        depot_dir = '/depot/Jam'

        src_docker_cli = self.docker_p4d_clients['p4d_0']
        dst_docker_cli = self.docker_svn_clients['svn_0']
        with get_p4d_from_docker(src_docker_cli, depot_dir) as p4:
            src_revs = p4.run_changes('-l', '...@0,#head')
            src_revs.reverse()
            src_revs = [c['change'] for c in src_revs]
        src_revs.insert(0, 0)
        num_replicate = 1
        max_replicate = 20

        src_depot = '/%s/...' % depot_dir
        svn_test_dir_name = 'buildtest%s_group' % '_'.join(
            depot_dir.split('/'))
        dst_depot = '/%s' % svn_test_dir_name

        src_view = ((src_depot, './...'), )
        dst_view = ((dst_depot, ''), )

        for src_counter in src_revs[:max_replicate:num_replicate]:
            replicate_P4SvnReplicate(src_view,
                                     dst_view,
                                     src_docker_cli,
                                     dst_docker_cli,
                                     src_counter=0,
                                     replicate_change_num=num_replicate)
            verify_replication(src_view,
                               dst_view,
                               src_docker_cli,
                               dst_docker_cli,
                               src_counter=src_counter,
                               replicate_change_num=num_replicate)

        verify_replication(src_view,
                           dst_view,
                           src_docker_cli,
                           dst_docker_cli,
                           replicate_change_num=max_replicate)

        logger.passed(test_case)
Exemplo n.º 9
0
    def test_replicate_sample_depot_special_strings(self):
        test_case = 'replicate_sample_depot_special_strings'

        special_strings = {
            'utf-8':
            u"мыслю, следовательно существую., it's a smilling face, \u263A",
            'cp1251':
            u"мыслю, следовательно существую., it's a smilling face'",
            'latin1': u'La Santé',
        }
        depot_dir = '/depot/Misc'
        src_docker_cli = self.docker_clients[0]
        with get_p4d_from_docker(src_docker_cli, depot_dir) as src_p4:
            clientspec = src_p4.fetch_client(src_p4.client)
            ws_root = clientspec._root

            src_p4.run_sync('...')
            logger.info('src_p4.charset: %s' % src_p4.charset)

            test_dir = os.path.join(ws_root, test_case)
            os.mkdir(test_dir)

            import locale
            _, locale_encoding = locale.getlocale()
            special_string = special_strings.get(locale_encoding.lower())
            special_string = special_string.encode(locale_encoding)
            fn = os.path.join(test_dir, special_string + '.txt')
            with open(fn, 'wt') as f:
                f.write('added %s' % fn)
            src_p4.run_add(fn)
            src_p4.run_submit('-d', 'submit %s' % fn)

            fn = os.path.join(test_dir, 'exec_file')
            with open(fn, 'wt') as f:
                f.write('added %s' % special_string)
            src_p4.run_add('-t', '+x', fn)
            src_p4.run_submit('-d', 'submit %s' % fn)

        # replicaten
        depot_dir = os.path.join(depot_dir, test_case)
        self.replicate_sample_dir_withdocker(depot_dir,
                                             src_docker_cli=src_docker_cli)

        logger.passed(test_case)
    def test_replicate_with_additional_target_rev(self):
        '''replication integrations with additional revision in target depot.

        This test is designed for BENG-1447
        '''
        test_case = 'replicate_with_additional_target_rev'

        src_docker_cli = self.docker_clients['move_non_last_rev_src']
        dst_docker_cli = self.docker_clients['move_non_last_rev_dst']

        # create source revision graph
        depot_dir = '/depot/src_move_graph'
        from_file_path = self.build_test_revision_move(src_docker_cli, depot_dir)

        # replicate all changelists but the last one
        src_depot = '/%s/...' % depot_dir
        src_changes = get_changelist_in_sample_depot(src_docker_cli, src_depot)
        num_change = len(src_changes)

        replicate_sample_dir(depot_dir,
                             src_docker_cli=src_docker_cli,
                             dst_docker_cli=dst_docker_cli,
                             obliterate=False,
                             replicate_change_num=num_change-1)

        # add one revision in target "move from" file
        dst_depot_dir = '/depot/buildtest%s' % depot_dir
        from_file_name = os.path.basename(from_file_path)
        with get_p4d_from_docker(dst_docker_cli, dst_depot_dir) as dst_p4:
            dst_from_file_path = os.path.join(dst_p4.cwd, from_file_name)
            dst_p4.run_sync('-f')
            dst_p4.run_edit(dst_from_file_path)
            with open(dst_from_file_path, 'at') as f:
                f.write('target additional rev')
            dst_p4.run_submit('-d', 'target additional rev')

        # replicate the last changelist
        replicate_sample_dir(depot_dir,
                             src_docker_cli=src_docker_cli,
                             dst_docker_cli=dst_docker_cli,
                             src_counter=int(src_changes[-2]),
                             skip_verification=True)

        logger.passed(test_case)
Exemplo n.º 11
0
    def test_replicate_sample_depot_copy_samefile(self):
        '''verify that "p4 copy //depot/file.c#3 //depot/file.c" could be
        replicated
        '''
        test_case = 'replicate_sample_depot_copy_samefile'

        depot_dir = '/depot/Misc/Artwork'
        depot_file = '//depot/Misc/Artwork/HQ.psd'
        copy_rev = 3
        src_docker_cli = self.docker_clients[0]
        dst_docker_cli = self.docker_clients[1]
        with get_p4d_from_docker(src_docker_cli, depot_dir) as src_p4:
            src_p4.run_copy('%s#%d' % (depot_file, copy_rev), depot_file)
            src_p4.run_submit(
                '-d', 'copy %s#%d %s' % (depot_file, copy_rev, depot_file))

        # replicate
        self.replicate_sample_dir_withdocker(depot_dir,
                                             src_docker_cli=src_docker_cli)

        logger.passed(test_case)
Exemplo n.º 12
0
    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)
Exemplo n.º 13
0
    def test_replicate_sample_depot_changing_symlink(self):
        '''verify replication of changing symlink
        '''
        test_case = 'replicate_sample_depot_changing_symlink'

        depot_dir = '/depot/Misc/Artwork'
        depot_file = '//depot/Misc/Artwork/HQ.psd'
        src_docker_cli = self.docker_clients[0]
        with get_p4d_from_docker(src_docker_cli, depot_dir) as src_p4:
            clientspec = src_p4.fetch_client(src_p4.client)
            ws_root = clientspec._root

            file_path = os.path.join(ws_root, 'HQ.psd')
            link_path = os.path.join(ws_root, 'HQ.psd_link')
            src_p4.run_sync('...')

            with open(link_path, 'wt') as f:
                f.write('text file')
            src_p4.run_add(link_path)
            src_p4.run_submit('-d', 'submit text file %s' % link_path)

            for i in range(6):
                if i & 1:
                    src_p4.run_edit('-t', 'text', link_path)
                    os.remove(link_path)
                    with open(link_path, 'wt') as f:
                        f.write('text file')
                    src_p4.run_submit('-d', 'now text file')
                else:
                    src_p4.run_edit('-t', 'symlink', link_path)
                    os.remove(link_path)
                    os.symlink(file_path, link_path)
                    src_p4.run_submit('-d', 'now symlink')

        # replicate
        self.replicate_sample_dir_withdocker(depot_dir,
                                             src_docker_cli=src_docker_cli)

        logger.passed(test_case)
Exemplo n.º 14
0
    def test_replicate_sample_depot_resume_from_manual_change(self):
        test_case = 'replicate_sample_depot_resume_from_manual_change'

        depot_dir = '/depot/Jam'
        src_docker_cli = self.docker_clients[0]
        dst_docker_cli = self.docker_clients[1]
        dst_depot = self.replicate_sample_dir_withdocker(
            depot_dir,
            src_docker_cli=src_docker_cli,
            dst_docker_cli=dst_docker_cli,
            replicate_change_num=10,
            obliterate=False)

        dst_dir = dst_depot[1:-4]
        # manual commit to mess up replication script
        with get_p4d_from_docker(dst_docker_cli, dst_dir) as dst_p4:
            clientspec = dst_p4.fetch_client(dst_p4.client)
            ws_root = clientspec._root

            test_file_path = os.path.join(ws_root, 'test_file_')
            with open(test_file_path, 'wt') as f:
                f.write('My name is %s!\n' % test_file_path)
            dst_p4.run_add('-f', test_file_path)
            desc = 'manual change to fool replication script'
            dst_p4.run_submit('-d', desc)

        try:
            self.replicate_sample_dir_withdocker(depot_dir,
                                                 src_docker_cli=src_docker_cli,
                                                 dst_docker_cli=dst_docker_cli,
                                                 replicate_change_num=10)
        except ReplicationException, e:
            if 'src counter is 0(default) while last replicated rev is 10' in str(
                    e):
                logger.info('Expected exception: %s' % str(e))
            else:
                raise
Exemplo n.º 15
0
    def test_replicate_sample_depot_changing_exec_binary(self):
        '''verify replication of changing executable bit
        '''
        test_case = 'replicate_sample_depot_changing_exec_binary'

        depot_dir = '/depot/Misc/Artwork'
        depot_file = '//depot/Misc/Artwork/HQ.psd'
        src_docker_cli = self.docker_clients[0]
        with get_p4d_from_docker(src_docker_cli, depot_dir) as src_p4:
            clientspec = src_p4.fetch_client(src_p4.client)
            ws_root = clientspec._root
            file_path = os.path.join(ws_root, 'HQ.psd')

            src_p4.run_sync('...')
            for i in range(4):
                sign = 'binary' if i & 1 else '+x'
                src_p4.run_edit('-t', '%s' % sign, file_path)
                src_p4.run_submit('-d', '%s executable bit' % sign)

        # replicate
        self.replicate_sample_dir_withdocker(depot_dir,
                                             src_docker_cli=src_docker_cli)

        logger.passed(test_case)
Exemplo n.º 16
0
    def p4svn_action_remove_setup_env(self, depot_dir, action, **kwargs):
        levels_of_dir = kwargs.get('levels_of_dir', 0)
        place_holder_file = kwargs.get('place_holder_file', -1)

        src_docker_cli = self.docker_p4d_clients['p4d_0']
        with get_p4d_from_docker(src_docker_cli, depot_dir) as p4:
            clientspec = p4.fetch_client(p4.client)
            ws_root = clientspec._root

            project_dir = 'a_dir'
            project_dir = tempfile.mkdtemp(prefix=project_dir, dir=ws_root)

            # add a file in project dir
            proj_file_path = os.path.join(project_dir, 'project_file')
            description = 'add a file with file name %s' % proj_file_path
            with open(proj_file_path, 'wt') as f:
                f.write('My name is %s!\n' % proj_file_path)
            p4.run_add('-f', proj_file_path)
            p4.run_submit('-d', description)

            # make a directory and add files in it
            file_names = [
                'a_file.txt', 'another_file.txt', 'yet_another_file.txt'
            ]

            test_dir = tempfile.mkdtemp(dir=project_dir)
            for i in range(levels_of_dir):
                test_dir = tempfile.mkdtemp(dir=test_dir, prefix='%s_' % i)
                if place_holder_file == i:
                    file_path = os.path.join(test_dir, 'place_holder')
                    with open(file_path, 'wt') as f:
                        f.write('prevent deletion of dir!\n')
                    p4.run_add('-f', file_path)
                    p4.run_submit('-d',
                                  'add a file to prevent deletion of dir')

            # add the files
            for fn in file_names:
                file_path = os.path.join(test_dir, fn)
                description = 'add a file with file name %s' % fn
                with open(file_path, 'wt') as f:
                    f.write('My name is %s!\n' % fn)
                p4.run_add('-f', file_path)
                p4.run_submit('-d', description)

            if action == 'remove_one_by_one':
                # remove all files one by one
                for fn in file_names:
                    file_path = os.path.join(test_dir, fn)
                    description = 'remove %s' % fn
                    p4.run_delete(file_path)
                    p4.run_submit('-d', description)
            elif action == 'remove_all_in_one_change':
                # remove all files all together
                description = ''
                for fn in file_names:
                    file_path = os.path.join(test_dir, fn)
                    description += 'remove %s\n' % fn
                    p4.run_delete(file_path)
                p4.run_submit('-d', description)
            elif action in [
                    'remove_all_add_one', 'remove_all_add_one_in_parent'
            ]:
                # 1) remove_all_add_one
                # remove all files all together but add a new file in
                # the same directory, no directory should be deleted
                # 2) remove_all_add_on_in_parent
                # remove all files all together and add a new file in
                # the parent directory, current directory should be deleted
                description = ''
                for fn in file_names:
                    file_path = os.path.join(test_dir, fn)
                    description += 'remove %s\n' % fn
                    p4.run_delete(file_path)

                file_path = os.path.join(test_dir, 'fantastic_additional')
                if action == 'remove_all_add_one_in_parent':
                    test_dir_parent = os.path.split(test_dir)[0]
                    file_path = os.path.join(test_dir_parent,
                                             'fantastic_additional')
                description = 'add a file with file name %s' % fn
                with open(file_path, 'wt') as f:
                    f.write('My name is %s!\n' % fn)
                p4.run_add('-f', file_path)
                p4.run_submit('-d', description)
            else:
                logger.error('"%s" not yet implemented' % action)

            p4.run_edit(proj_file_path)
            with open(proj_file_path, 'a') as f:
                f.write('My name is %s!\n' % proj_file_path)
            p4.run_submit('-d', 'editing %s' % proj_file_path)