Ignore:
Timestamp:
Feb 24, 2010 12:27:23 AM (15 years ago)
Author:
retracile
Message:

Mergebot: add test for merge task dependencies

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mergebot/trunk/utils/test.py

    r65 r67  
    1111# - verify inter-ticket dependency checking
    1212# - verify failure cascades through inter-ticket dependencies
     13# - change the version of a ticket, rebranch, and merge
    1314
    1415import os
     
    9293        tc.notfind('No handler matched request to /mergebot')
    9394
    94     def branch(self, ticket_id, component, timeout=1):
    95         """timeout is in seconds."""
     95    def queue_branch(self, ticket_id):
    9696        self.go_to_mergebot()
    9797        tc.formvalue('ops-%s' % ticket_id, 'ticket', ticket_id) # Essentially a noop to select the right form
    9898        tc.submit('Branch')
     99
     100    def branch(self, ticket_id, component, timeout=1):
     101        """timeout is in seconds."""
     102        self.queue_branch(ticket_id)
    99103        self.wait_until_find('Nothing in the queue', timeout)
    100104        tc.find('Rebranch')
     
    108112            raise Exception('svn ls failed with exit code %s' % retval)
    109113
    110     def _rebranch(self, ticket_id, component, search, timeout=15):
    111         """timeout is in seconds."""
     114    def queue_rebranch(self, ticket_id):
    112115        self.go_to_mergebot()
    113116        tc.formvalue('ops-%s' % ticket_id, 'ticket', ticket_id) # Essentially a noop to select the right form
    114117        tc.submit('Rebranch')
     118
     119    def _rebranch(self, ticket_id, component, search, timeout=15):
     120        """timeout is in seconds."""
     121        self.queue_rebranch(ticket_id)
    115122        self.wait_until_find('Nothing in the queue', timeout)
    116123        tc.find('Rebranch')
     
    130137        self._rebranch(ticket_id, component, 'There were conflicts on rebranching', timeout)
    131138
    132     def merge(self, ticket_id, component, timeout=5):
    133         self._merge(ticket_id, component, 'Merged .* to .* for', timeout)
    134 
    135     def merge_conflict(self, ticket_id, component, timeout=5):
    136         self._merge(ticket_id, component, 'Found [0-9]+ conflicts? in attempt to merge ', timeout)
    137 
    138     def _merge(self, ticket_id, component, search, timeout=5):
    139         """timeout is in seconds."""
     139    def queue_merge(self, ticket_id):
    140140        self.go_to_mergebot()
    141141        tc.formvalue('ops-%s' % ticket_id, 'ticket', ticket_id) # Essentially a noop to select the right form
    142142        tc.submit('Merge')
     143
     144    def merge(self, ticket_id, component, timeout=5):
     145        self._merge(ticket_id, component, 'Merged .* to .* for', timeout)
     146
     147    def merge_conflict(self, ticket_id, component, timeout=5):
     148        self._merge(ticket_id, component, 'Found [0-9]+ conflicts? in attempt to merge ', timeout)
     149
     150    def _merge(self, ticket_id, component, search, timeout=5):
     151        """timeout is in seconds."""
     152        self.queue_merge(ticket_id)
    143153        self.wait_until_find('Nothing in the queue', timeout)
    144154        tc.find('Branch')
     
    151161            raise Exception('svn ls failed with exit code %s' % retval)
    152162
    153     def checkmerge(self, ticket_id, component, timeout=5):
    154         """timeout is in seconds."""
     163    def queue_checkmerge(self, ticket_id):
    155164        self.go_to_mergebot()
    156165        tc.formvalue('ops-%s' % ticket_id, 'ticket', ticket_id) # Essentially a noop to select the right form
    157166        tc.submit('CheckMerge')
     167
     168    def checkmerge(self, ticket_id, component, timeout=5):
     169        """timeout is in seconds."""
     170        self.queue_checkmerge(ticket_id)
    158171        self.wait_until_find('Nothing in the queue', timeout)
    159172        tc.find('Rebranch')
     
    166179        if retval:
    167180            raise Exception('svn ls failed with exit code %s' % retval)
     181
     182    def wait_for_empty_queue(self, timeout=10):
     183        self.go_to_mergebot()
     184        self.wait_until_find('Nothing in the queue', timeout)
    168185
    169186
     
    232249        self.assertEqual(retval, 0, "svn checkout failed with error %s" % (retval))
    233250
    234     def add_new_file(self, filename=None):
     251    def add_new_file(self, filename=None, file_size=None):
    235252        workdir = self.get_workdir()
    236253        if filename is None:
     
    238255        else:
    239256            newfile = os.path.join(workdir, filename)
    240         open(newfile, 'w').write(random_page())
     257        if file_size is None:
     258            data = random_page()
     259        else:
     260            data = ''
     261            while len(data) < file_size:
     262                data += random_page()
     263            data = data[:file_size]
     264        open(newfile, 'w').write(data)
    241265        retval = call(['svn', 'add', newfile],
    242266            cwd=workdir,
     
    337361        self.cleanup()
    338362
     363
    339364class MergeBotTestMergeWithChangeAndTrunkChange(FunctionalSvnTestCaseSetup):
    340365    def runTest(self):
     
    795820        self.commit('Make a second modification')
    796821        self._tester.merge(ticket_id, 'stuff')
     822        self.cleanup()
     823
     824
     825class MergeBotTestMergeDependency(FunctionalSvnTestCaseSetup):
     826    def runTest(self):
     827        """Merge two branches to trunk; make sure the second one shows as waiting"""
     828        # This test is fundamentally racy.  The size of the files has been
     829        # chosen to slow down the test long enough to get a view of the
     830        # mergebot page with one of them waiting for the other to complete.
     831        ticket_one = self._tester.create_ticket(summary=self.__class__.__name__ + " one",
     832            info={'component':'stuff', 'version':'trunk'})
     833        ticket_two = self._tester.create_ticket(summary=self.__class__.__name__ + " two",
     834            info={'component':'stuff', 'version':'trunk'})
     835        basename = self.__class__.__name__
     836
     837        self._tester.branch(ticket_one, 'stuff')
     838        self._tester.branch(ticket_two, 'stuff')
     839
     840        self.checkout(ticket_one)
     841        self.add_new_file(basename + '-one', 30*1024**2)
     842        self.commit('Add a new file')
     843
     844        self.switch(ticket_two)
     845        self.add_new_file(basename + '-two', 30*1024**2)
     846        self.commit('Add a new file')
     847
     848        self._tester.queue_merge(ticket_two)
     849        self._tester.queue_merge(ticket_one)
     850
     851        #self._tester.go_to_mergebot()
     852        tc.find('Waiting')
     853        self._tester.wait_for_empty_queue()
     854       
    797855        self.cleanup()
    798856
     
    824882    suite.addTest(MergeBotTestSingleUseCase())
    825883    suite.addTest(MergeBotTestBranchReuse())
     884    suite.addTest(MergeBotTestMergeDependency())
    826885    return suite
    827886
Note: See TracChangeset for help on using the changeset viewer.