def testC_DashboardReporterPollerAlertSending_algorithm(self): """ Cause exception (alert-worthy situation) in the algorithm() method. """ myThread = threading.currentThread() config = self.getConfig() handler, self.alertsReceiver = \ utils.setUpReceiver(config.Alert.address, config.Alert.controlAddr) # emulate exception behaviour def raiseException(): raise Exception("My test exception.") dashboardReporter = DashboardReporterPoller(config = config) dashboardReporter.pollCouch = raiseException self.assertRaises(Exception, dashboardReporter.algorithm) # wait for the generated alert to arrive while len(handler.queue) == 0: time.sleep(0.3) print "%s waiting for alert to arrive ..." % inspect.stack()[0][3] self.alertsReceiver.shutdown() self.alertsReceiver = None # now check if the alert was properly sent self.assertEqual(len(handler.queue), 1) alert = handler.queue[0] self.assertEqual(alert["Source"], dashboardReporter.__class__.__name__) self.assertEqual(alert["Component"], "DashboardReporter") return
def testA_testSubmit(self): """ _testSubmit_ Test whether we pick up submitted jobs """ #workload = self.createWorkload() jobGroup = self.createTestJobGroup() config = self.getConfig() xmlPath = os.path.join(WMCore.WMBase.getTestBase(), "WMCore_t/FwkJobReport_t/PerformanceReport.xml") myReport = Report("cmsRun1") myReport.parse(xmlPath) changer = ChangeState(config) for job in jobGroup.jobs: job['fwjr'] = myReport changer.propagate(jobGroup.jobs, "complete", "executing") changer.propagate(jobGroup.jobs, "success", "complete") dashboardReporter = DashboardReporterPoller(config = config) dashboardReporter.algorithm() # What the hell am I supposed to check? changer.propagate(jobGroup.jobs, 'jobfailed', 'executing') dashboardReporter.algorithm() return