Пример #1
0
    def test_RetryAccept_NotSuccessful_AndExit(self, exitmock, inputmock,
                                               shellmock):
        component1 = "uuid1"
        component2 = "uuid2"
        changeentry1 = testhelper.createchangeentry(revision="anyRevId",
                                                    component=component1)
        changeentry2 = testhelper.createchangeentry(revision="component2RevId",
                                                    component=component2)
        changeentry3 = testhelper.createchangeentry(revision="anyOtherRevId",
                                                    component=component1)
        changeentry3.setAccepted()
        changeentries = [changeentry1, changeentry2, changeentry3]

        self.configBuilder.setrepourl(
            "anyurl").setuseautomaticconflictresolution(
                "True").setmaxchangesetstoaccepttogether(10).setworkspace(
                    "anyWs")
        config = self.configBuilder.build()
        configuration.config = config

        handler = ImportHandler()
        handler.retryacceptincludingnextchangesets(changeentry1, changeentries)
        inputmock.assert_called_once_with(
            'Do you want to continue? Y for continue, any key for abort')
        exitmock.assert_called_once_with(
            "Please check the output/log and rerun program with resume")
Пример #2
0
    def test_RetryAccept_AssertThatOnlyChangesFromSameComponentGetAcceptedTogether(
            self, inputmock, shellmock):
        component1 = "uuid1"
        component2 = "uuid2"
        changeentry1 = testhelper.createchangeentry(revision="anyRevId",
                                                    component=component1)
        changeentry2 = testhelper.createchangeentry(revision="component2RevId",
                                                    component=component2)
        changeentry3 = testhelper.createchangeentry(revision="anyOtherRevId",
                                                    component=component1)
        changeentries = [changeentry1, changeentry2, changeentry3]

        shellmock.execute.return_value = 0
        self.configBuilder.setrepourl(
            "anyurl").setuseautomaticconflictresolution(
                "True").setmaxchangesetstoaccepttogether(10).setworkspace(
                    "anyWs")
        config = self.configBuilder.build()
        configuration.config = config

        handler = ImportHandler()
        handler.retryacceptincludingnextchangesets(changeentry1, changeentries)

        expectedshellcommand = 'lscm accept --verbose --overwrite-uncommitted --accept-missing-changesets --no-merge --repository-uri anyurl --target anyWs --changes anyRevId anyOtherRevId'
        shellmock.execute.assert_called_once_with(
            expectedshellcommand, handler.config.getlogpath("accept.txt"), "a")
Пример #3
0
 def test_useragreeing_answeris_n_expectfalseandexception(self, inputmock):
     handler = ImportHandler(self.configBuilder.build())
     try:
         handler.is_user_agreeing_to_accept_next_change(
             self.createChangeEntry())
         self.fail("Should have exit the program")
     except SystemExit as e:
         self.assertEqual(
             "Please check the output/log and rerun program with resume",
             e.code)
Пример #4
0
def prepare():
    config = configuration.get()
    rtc = ImportHandler()
    rtcworkspace = WorkspaceHandler()
    # git checkout branchpoint
    Commiter.checkout(config.previousstreamname + "_branchpoint")
    # list baselines of current workspace
    componentbaselineentries = rtc.getcomponentbaselineentriesfromstream(config.previousstreamuuid)
    # set components to that baselines
    rtcworkspace.setcomponentstobaseline(componentbaselineentries, config.previousstreamuuid)
    rtcworkspace.load()
Пример #5
0
    def test_getnextchangeset_fromsamecomponent_expectsamecomponent(self):
        component1 = "uuid_1"
        component2 = "uuid_2"
        # entries for component 1 (2nd entry being already accepted)
        entry1_1 = testhelper.createchangeentry(revision="1.1",
                                                component=component1)
        entry1_2 = testhelper.createchangeentry(revision="1.2",
                                                component=component1)
        entry1_2.setAccepted()
        entry1_3 = testhelper.createchangeentry(revision="1.3",
                                                component=component1)
        # entries for component 2 (2nd entry being already accepted)
        entry2_1 = testhelper.createchangeentry(revision="2.1",
                                                component=component2)
        entry2_2 = testhelper.createchangeentry(revision="2.2",
                                                component=component2)
        entry2_2.setAccepted()
        entry2_3 = testhelper.createchangeentry(revision="2.3",
                                                component=component2)
        changeentries = []
        changeentries.append(entry1_1)
        changeentries.append(entry2_1)
        changeentries.append(entry1_2)
        changeentries.append(entry2_2)
        changeentries.append(entry1_3)
        changeentries.append(entry2_3)

        nextentry = ImportHandler.getnextchangeset_fromsamecomponent(
            currentchangeentry=entry2_1, changeentries=changeentries)
        self.assertIsNotNone(nextentry)
        self.assertFalse(nextentry.isAccepted())
        self.assertEqual(component2, nextentry.component)
        self.assertEqual("2.3", nextentry.revision)
Пример #6
0
    def test_getnextchangeset_fromsamecomponent_expectnonefound(self):
        component1 = "uuid_1"
        component2 = "uuid_2"
        # entries for component 1
        entry1_1 = testhelper.createchangeentry(revision="1.1",
                                                component=component1)
        entry1_1.setAccepted()
        entry1_2 = testhelper.createchangeentry(revision="1.2",
                                                component=component1)
        entry1_2.setAccepted()
        # entries for component 2 (2nd entry being already accepted)
        entry2_1 = testhelper.createchangeentry(revision="2.1",
                                                component=component2)
        entry2_1.setAccepted()
        entry2_2 = testhelper.createchangeentry(revision="2.2",
                                                component=component2)
        entry2_2.setAccepted()
        changeentries = []
        changeentries.append(entry1_1)
        changeentries.append(entry2_1)
        changeentries.append(entry1_2)
        changeentries.append(entry2_2)

        nextentry = ImportHandler.getnextchangeset_fromsamecomponent(
            currentchangeentry=entry2_1, changeentries=changeentries)
        self.assertIsNone(nextentry)
Пример #7
0
    def test_RetryAccept_AssertThatTwoChangesGetAcceptedTogether(
            self, inputmock, shellmock):
        changeentry1 = self.createChangeEntry("anyRevId")
        changeentry2 = self.createChangeEntry("anyOtherRevId")
        changeentries = [changeentry1, changeentry2]

        shellmock.execute.return_value = 0
        self.configBuilder.setrepourl(
            "anyurl").setuseautomaticconflictresolution("True").setworkspace(
                "anyWs")
        config = self.configBuilder.build()

        handler = ImportHandler(config)
        handler.retryacceptincludingnextchangesets(changeentry1, changeentries)

        expectedshellcommand = 'lscm accept -v -o -r anyurl -t anyWs --changes anyRevId anyOtherRevId'
        shellmock.execute.assert_called_once_with(
            expectedshellcommand, handler.config.getlogpath("accept.txt"), "a")
Пример #8
0
 def test_ReadChangesetInformationFromFile_InUtf8_ShouldBeSuccesful(self):
     shell.setencoding("UTF-8")
     sample_file_path = self.get_Sample_File_Path(
         "SampleCompareOutputInUtf8.txt")
     changeentries = ImportHandler.getchangeentriesfromfile(
         sample_file_path)
     self.assertEqual(1, len(changeentries))
     author = "John ÆØÅ"
     mail = "*****@*****.**"
     self.assert_Change_Entry(changeentries[0], author, mail, "Comment",
                              "2015-05-26 10:40:00")
Пример #9
0
    def test_collectChangeSetsToAcceptToAvoidMergeConflict_ShouldAcceptLargeAmountOfChangeSets(
            self):
        changeentries = [
            testhelper.createchangeentry(str(i)) for i in range(1, 500)
        ]
        change1 = changeentries[0]

        configuration.config = self.configBuilder.build()
        collectedchanges = ImportHandler(
        ).collect_changes_to_accept_to_avoid_conflicts(change1, changeentries,
                                                       500)
        self.assertEqual(499, len(collectedchanges))
Пример #10
0
    def test_collectChangeSetsToAcceptToAvoidMergeConflict_ShouldCollectThreeChangesets(
            self):
        mychange1 = self.createChangeEntry("doSomethingOnOldRev")
        mychange2 = self.createChangeEntry("doSomethingElseOnOldRev")
        mymergechange = self.createChangeEntry("anyRev",
                                               comment="merge change")
        changefromsomeoneelse = self.createChangeEntry(author="anyOtherAuthor",
                                                       revision="2",
                                                       comment="anotherCommit")

        changeentries = [
            mychange1, mychange2, mymergechange, changefromsomeoneelse
        ]

        handler = ImportHandler(self.configBuilder.build())
        collectedchanges = handler.collect_changes_to_accept_to_avoid_conflicts(
            mychange1, changeentries)
        self.assertTrue(mychange1 in collectedchanges)
        self.assertTrue(mychange2 in collectedchanges)
        self.assertTrue(mymergechange in collectedchanges)
        self.assertFalse(changefromsomeoneelse in collectedchanges)
        self.assertEqual(3, len(collectedchanges))
Пример #11
0
 def test_ReadChangesetInformationFromFile_WithLineBreakInComment_ShouldBeSuccesful(
         self):
     sample_file_path = self.get_Sample_File_Path(
         "SampleCompareOutputWithLineBreaks.txt")
     changeentries = ImportHandler.getchangeentriesfromfile(
         sample_file_path)
     self.assertEqual(2, len(changeentries))
     author = "Jon Doe"
     mail = "*****@*****.**"
     self.assert_Change_Entry(changeentries[0], author, mail,
                              "My first commit in rtc! :D",
                              "2015-05-26 10:40:00")
     expectedcomment = "I want to commit on my flight to Riga :(" + os.linesep + "This is a new line"
     self.assert_Change_Entry(changeentries[1], author, mail,
                              expectedcomment, "2015-05-26 10:42:00")
Пример #12
0
    def test_collectChangeSetsToAcceptToAvoidMergeConflict_ShouldAdhereToMaxChangeSetCount(
            self):
        change1 = testhelper.createchangeentry("1")
        change2 = testhelper.createchangeentry("2")
        change3 = testhelper.createchangeentry("3")

        changeentries = [change1, change2, change3]

        configuration.config = self.configBuilder.build()
        collectedchanges = ImportHandler(
        ).collect_changes_to_accept_to_avoid_conflicts(change1, changeentries,
                                                       2)
        self.assertTrue(change1 in collectedchanges)
        self.assertTrue(change2 in collectedchanges)
        self.assertFalse(change3 in collectedchanges)
        self.assertEqual(2, len(collectedchanges))
Пример #13
0
    def test_collectChangeSetsToAcceptToAvoidMergeConflict_ShouldCollectOnlyUnacceptedChangesets(
            self):
        change1 = testhelper.createchangeentry(revision="1")
        change2 = testhelper.createchangeentry(revision="2")
        change2.setAccepted()
        change3 = testhelper.createchangeentry(revision="3")

        changeentries = [change1, change2, change3]

        configuration.config = self.configBuilder.build()
        collectedchanges = ImportHandler(
        ).collect_changes_to_accept_to_avoid_conflicts(change1, changeentries,
                                                       10)
        self.assertTrue(change1 in collectedchanges)
        self.assertFalse(change2 in collectedchanges)
        self.assertTrue(change3 in collectedchanges)
        self.assertEqual(2, len(collectedchanges))
Пример #14
0
 def test_getchangeentriesbytypeandvalue_type_stream(self, shellmock):
     anyurl = "anyUrl"
     config = self.configBuilder.setrepourl(anyurl).setworkspace(
         self.workspace).build()
     configuration.config = config
     stream = "myStreamUUID"
     comparetype = CompareType.stream
     comparetypename = comparetype.name
     filename = "Compare_%s_%s.txt" % (comparetypename, stream)
     outputfilename = config.getlogpath(filename)
     try:
         shellmock.encoding = 'UTF-8'
         ImportHandler().getchangeentriesbytypeandvalue(comparetype, stream)
     except FileNotFoundError:
         pass  # do not bother creating the output file here
     expected_compare_command = "lscm --show-alias n --show-uuid y compare ws %s %s %s -r %s -I swc -C @@{name}@@{email}@@ --flow-directions i -D @@\"yyyy-MM-dd HH:mm:ss\"@@" \
                                % (self.workspace, comparetypename, stream, anyurl)
     shellmock.execute.assert_called_once_with(expected_compare_command,
                                               outputfilename)
Пример #15
0
 def test_ReadChangesetInformationFromFile_WithMultipleComponents(self):
     sample_file_path = self.get_Sample_File_Path(
         "SampleCompareOutputWithComponents.txt")
     changeentries = ImportHandler.getchangeentriesfromfile(
         sample_file_path)
     self.assertEqual(4, len(changeentries))
     author = "Bubba Gump"
     mail = "*****@*****.**"
     self.assert_Change_Entry(changeentries[0], author, mail,
                              "1234: work item - commit 1",
                              "2015-06-07 16:34:22",
                              "_2mytestcomponent2-UUID")
     self.assert_Change_Entry(changeentries[1], author, mail,
                              "1234: work item - commit 3",
                              "2015-08-25 16:15:50",
                              "_2mytestcomponent2-UUID")
     self.assert_Change_Entry(changeentries[2], author, mail,
                              "1234: work item - commit 2",
                              "2015-06-08 16:34:22",
                              "_3mytestcomponent3-UUID")
     self.assert_Change_Entry(changeentries[3], author, mail,
                              "1234: work item - commit 4",
                              "2015-08-26 16:15:50",
                              "_3mytestcomponent3-UUID")
Пример #16
0
def migrate():
    rtc = ImportHandler()
    rtcworkspace = WorkspaceHandler()
    git = Commiter

    if existsrepo():
        resume()
    else:
        initialize()

    config = configuration.get()
    streamuuid = config.streamuuid
    streamname = config.streamname
    branchname = streamname + "_branchpoint"

    componentbaselineentries = rtc.getcomponentbaselineentriesfromstream(streamuuid)
    rtcworkspace.setnewflowtargets(streamuuid)

    history = rtc.readhistory(componentbaselineentries, streamname)
    changeentries = rtc.getchangeentriesofstreamcomponents(componentbaselineentries)

    if len(changeentries) > 0:
        git.branch(branchname)
        rtc.acceptchangesintoworkspace(rtc.getchangeentriestoaccept(changeentries, history))
        shouter.shout("All changes until creation of stream '%s' accepted" % streamname)
        git.pushbranch(branchname)

        rtcworkspace.setcomponentstobaseline(componentbaselineentries, streamuuid)
        rtcworkspace.load()

    git.branch(streamname)
    changeentries = rtc.getchangeentriesofstream(streamuuid)
    amountofacceptedchanges = rtc.acceptchangesintoworkspace(rtc.getchangeentriestoaccept(changeentries, history))
    if amountofacceptedchanges > 0:
        git.pushbranch(streamname)
        git.promotebranchtomaster(streamname)

    RTCLogin.logout()
    summary(streamname)
Пример #17
0
def migrate():
    config = configuration.read()
    rtc = ImportHandler(config)
    rtcworkspace = WorkspaceHandler(config)
    git = Commiter

    initialize(config)
    streamuuids = config.streamuuids
    for streamuuid in streamuuids:
        componentbaselineentries = rtc.getcomponentbaselineentriesfromstream(
            streamuuid)
        streamname = config.streamnames[streamuuids.index(streamuuid)]
        rtcworkspace.setnewflowtargets(streamuuid)
        git.branch(streamname)

        history = rtc.readhistory(componentbaselineentries, streamname)
        changeentries = rtc.getchangeentriesofstreamcomponents(
            componentbaselineentries)

        rtc.acceptchangesintoworkspace(
            rtc.getchangeentriestoaccept(changeentries, history))
        shouter.shout("All changes of components of stream '%s' accepted" %
                      streamname)
        git.pushbranch(streamname)

        rtcworkspace.setcomponentstobaseline(componentbaselineentries,
                                             streamuuid)
        rtcworkspace.load()

        changeentries = rtc.getchangeentriesofstream(streamuuid)
        rtc.acceptchangesintoworkspace(
            rtc.getchangeentriestoaccept(changeentries, history))
        git.pushbranch(streamname)
        shouter.shout(
            "All changes of stream '%s' accepted - Migration of stream completed"
            % streamname)

        morestreamstomigrate = streamuuids.index(streamuuid) + 1 is not len(
            streamuuids)
        if morestreamstomigrate:
            git.checkout("master")
            rtcworkspace.recreateoldestworkspace()
Пример #18
0
def migrate():
    config = configuration.read()
    rtc = ImportHandler(config)
    rtcworkspace = WorkspaceHandler(config)
    git = Commiter
    initialize(config)
    streamuuid = config.streamuuid
    streamname = config.streamname
    branchname = streamname + "_branchpoint"

    componentbaselineentries = rtc.getcomponentbaselineentriesfromstream(streamuuid)
    rtcworkspace.setnewflowtargets(streamuuid)
    git.branch(branchname)

    history = rtc.readhistory(componentbaselineentries, streamname)
    changeentries = rtc.getchangeentriesofstreamcomponents(componentbaselineentries)

    rtc.acceptchangesintoworkspace(rtc.getchangeentriestoaccept(changeentries, history))
    shouter.shout("All changes until creation of stream '%s' accepted" % streamname)
    git.pushbranch(branchname)
    git.branch(streamname)

    rtcworkspace.setcomponentstobaseline(componentbaselineentries, streamuuid)
    rtcworkspace.load()

    changeentries = rtc.getchangeentriesofstream(streamuuid)
    rtc.acceptchangesintoworkspace(rtc.getchangeentriestoaccept(changeentries, history))
    git.pushbranch(streamname)
    shouter.shout("All changes of stream '%s' accepted - Migration of stream completed" % streamname)
Пример #19
0
 def test_useragreeing_answeris_y_expecttrue(self, inputmock):
     configuration.config = self.configBuilder.build()
     self.assertTrue(ImportHandler().is_user_agreeing_to_accept_next_change(
         testhelper.createchangeentry()))
Пример #20
0
def migrate():
    config = configuration.read()
    rtc = ImportHandler(config)
    rtcworkspace = WorkspaceHandler(config)
    git = Commiter
    initialize(config)
    streamuuid = config.streamuuid
    streamname = config.streamname
    branchname = streamname + "_branchpoint"

    componentbaselineentries = rtc.getcomponentbaselineentriesfromstream(
        streamuuid)
    rtcworkspace.setnewflowtargets(streamuuid)
    git.branch(branchname)

    history = rtc.readhistory(componentbaselineentries, streamname)
    changeentries = rtc.getchangeentriesofstreamcomponents(
        componentbaselineentries)

    rtc.acceptchangesintoworkspace(
        rtc.getchangeentriestoaccept(changeentries, history))
    shouter.shout("All changes until creation of stream '%s' accepted" %
                  streamname)
    git.pushbranch(branchname)
    git.branch(streamname)

    rtcworkspace.setcomponentstobaseline(componentbaselineentries, streamuuid)
    rtcworkspace.load()

    changeentries = rtc.getchangeentriesofstream(streamuuid)
    rtc.acceptchangesintoworkspace(
        rtc.getchangeentriestoaccept(changeentries, history))
    git.pushbranch(streamname)
    shouter.shout(
        "All changes of stream '%s' accepted - Migration of stream completed" %
        streamname)
Пример #21
0
def migrate():
    config = configuration.read()
    rtc = ImportHandler(config)
    rtcworkspace = WorkspaceHandler(config)
    git = Commiter

    initialize(config)
    streamuuids = config.streamuuids
    for streamuuid in streamuuids:
        componentbaselineentries = rtc.getcomponentbaselineentriesfromstream(streamuuid)
        streamname = config.streamnames[streamuuids.index(streamuuid)]
        rtcworkspace.setnewflowtargets(streamuuid)
        git.branch(streamname)

        history = rtc.readhistory(componentbaselineentries, streamname)
        changeentries = rtc.getchangeentriesofstreamcomponents(componentbaselineentries)

        rtc.acceptchangesintoworkspace(rtc.getchangeentriestoaccept(changeentries, history))
        shouter.shout("All changes of components of stream '%s' accepted" % streamname)
        git.pushbranch(streamname)

        rtcworkspace.setcomponentstobaseline(componentbaselineentries, streamuuid)
        rtcworkspace.load()

        changeentries = rtc.getchangeentriesofstream(streamuuid)
        rtc.acceptchangesintoworkspace(rtc.getchangeentriestoaccept(changeentries, history))
        git.pushbranch(streamname)
        shouter.shout("All changes of stream '%s' accepted - Migration of stream completed" % streamname)

        morestreamstomigrate = streamuuids.index(streamuuid) + 1 is not len(streamuuids)
        if morestreamstomigrate:
            git.checkout("master")
            rtcworkspace.recreateoldestworkspace()
Пример #22
0
 def test_useragreeing_answeris_y_expecttrue(self, inputmock):
     handler = ImportHandler(self.configBuilder.build())
     self.assertTrue(
         handler.is_user_agreeing_to_accept_next_change(
             self.createChangeEntry()))