Changeset 67 for mergebot/trunk/utils/test.py
- Timestamp:
- Feb 24, 2010 12:27:23 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mergebot/trunk/utils/test.py
r65 r67 11 11 # - verify inter-ticket dependency checking 12 12 # - verify failure cascades through inter-ticket dependencies 13 # - change the version of a ticket, rebranch, and merge 13 14 14 15 import os … … 92 93 tc.notfind('No handler matched request to /mergebot') 93 94 94 def branch(self, ticket_id, component, timeout=1): 95 """timeout is in seconds.""" 95 def queue_branch(self, ticket_id): 96 96 self.go_to_mergebot() 97 97 tc.formvalue('ops-%s' % ticket_id, 'ticket', ticket_id) # Essentially a noop to select the right form 98 98 tc.submit('Branch') 99 100 def branch(self, ticket_id, component, timeout=1): 101 """timeout is in seconds.""" 102 self.queue_branch(ticket_id) 99 103 self.wait_until_find('Nothing in the queue', timeout) 100 104 tc.find('Rebranch') … … 108 112 raise Exception('svn ls failed with exit code %s' % retval) 109 113 110 def _rebranch(self, ticket_id, component, search, timeout=15): 111 """timeout is in seconds.""" 114 def queue_rebranch(self, ticket_id): 112 115 self.go_to_mergebot() 113 116 tc.formvalue('ops-%s' % ticket_id, 'ticket', ticket_id) # Essentially a noop to select the right form 114 117 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) 115 122 self.wait_until_find('Nothing in the queue', timeout) 116 123 tc.find('Rebranch') … … 130 137 self._rebranch(ticket_id, component, 'There were conflicts on rebranching', timeout) 131 138 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): 140 140 self.go_to_mergebot() 141 141 tc.formvalue('ops-%s' % ticket_id, 'ticket', ticket_id) # Essentially a noop to select the right form 142 142 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) 143 153 self.wait_until_find('Nothing in the queue', timeout) 144 154 tc.find('Branch') … … 151 161 raise Exception('svn ls failed with exit code %s' % retval) 152 162 153 def checkmerge(self, ticket_id, component, timeout=5): 154 """timeout is in seconds.""" 163 def queue_checkmerge(self, ticket_id): 155 164 self.go_to_mergebot() 156 165 tc.formvalue('ops-%s' % ticket_id, 'ticket', ticket_id) # Essentially a noop to select the right form 157 166 tc.submit('CheckMerge') 167 168 def checkmerge(self, ticket_id, component, timeout=5): 169 """timeout is in seconds.""" 170 self.queue_checkmerge(ticket_id) 158 171 self.wait_until_find('Nothing in the queue', timeout) 159 172 tc.find('Rebranch') … … 166 179 if retval: 167 180 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) 168 185 169 186 … … 232 249 self.assertEqual(retval, 0, "svn checkout failed with error %s" % (retval)) 233 250 234 def add_new_file(self, filename=None ):251 def add_new_file(self, filename=None, file_size=None): 235 252 workdir = self.get_workdir() 236 253 if filename is None: … … 238 255 else: 239 256 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) 241 265 retval = call(['svn', 'add', newfile], 242 266 cwd=workdir, … … 337 361 self.cleanup() 338 362 363 339 364 class MergeBotTestMergeWithChangeAndTrunkChange(FunctionalSvnTestCaseSetup): 340 365 def runTest(self): … … 795 820 self.commit('Make a second modification') 796 821 self._tester.merge(ticket_id, 'stuff') 822 self.cleanup() 823 824 825 class 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 797 855 self.cleanup() 798 856 … … 824 882 suite.addTest(MergeBotTestSingleUseCase()) 825 883 suite.addTest(MergeBotTestBranchReuse()) 884 suite.addTest(MergeBotTestMergeDependency()) 826 885 return suite 827 886
Note: See TracChangeset
for help on using the changeset viewer.