def monitorTests(self): timer = 5 # self.batch_time = datetime.datetime.now() self.completedTests = {} while timer > 0 and len(self.testItemIdList) > 0: print '-- %d tests remaining' % len(self.testItemIdList) params = urllib.urlencode({'q': "select Id, ApexClassId, SystemModstamp from ApexTestQueueItem where Status = 'Completed'"}) data = self.invokeGetREST("query/?%s" % params) if not data == None: records = data['records'] print 'fetched %d records' % len(records) while data.has_key('nextRecordsUrl'): nextRecordsUrl = data['nextRecordsUrl'] print 'nextRecordsUrl=%s' % nextRecordsUrl data = self._invokeGetREST(nextRecordsUrl) if data.has_key('records'): morerecords = data['records'] records.extend(morerecords) print 'fetched %d more records' % len(morerecords) for record in records: if not self.isPendingTest(record): continue # make sure only looking at OUR tests timer = 5 # print 'record:' # print record if not self.completedTests.has_key(record['Id']): self.processCompletedQueueItem(record) print '%d: sleeping...' % timer time.sleep(60) timer -= 1 UnitTestRunUtil.process_run(self.utb.id)
def monitorTests(self): timer = 5 # self.batch_time = datetime.datetime.now() self.completedTests = {} while timer > 0 and len(self.testItemIdList) > 0: print '-- %d tests remaining' % len(self.testItemIdList) params = urllib.urlencode({ 'q': "select Id, ApexClassId, SystemModstamp from ApexTestQueueItem where Status = 'Completed'" }) data = self.invokeGetREST("query/?%s" % params) if not data == None: records = data['records'] print 'fetched %d records' % len(records) while data.has_key('nextRecordsUrl'): nextRecordsUrl = data['nextRecordsUrl'] print 'nextRecordsUrl=%s' % nextRecordsUrl data = self._invokeGetREST(nextRecordsUrl) if data.has_key('records'): morerecords = data['records'] records.extend(morerecords) print 'fetched %d more records' % len(morerecords) for record in records: if not self.isPendingTest(record): continue # make sure only looking at OUR tests timer = 5 # print 'record:' # print record if not self.completedTests.has_key(record['Id']): self.processCompletedQueueItem(record) print '%d: sleeping...' % timer time.sleep(60) timer -= 1 UnitTestRunUtil.process_run(self.utb.id)
def results(request): if request.method == 'GET' and request.GET.__contains__('sendReport'): batch_id = request.GET['sendReport'] UnitTestRunUtil.process_run(batch_id) if request.method == 'GET' and request.GET.__contains__('delete'): batch_id = request.GET['delete'] UnitTestRunUtil.delete_batch(batch_id) batches = UnitTestBatch.objects.all().order_by('-batch_time')[:50] data = {'batches': batches} return render(request, 'unit_testing_results.html', data)