def testBuildMissingOneOutput(self): mgr = DAQPool() compList = [] comp = MockComponent('fooHub', 0) comp.addOutput('aaa') comp.addInput('xxx', 123) compList.append(comp) comp = MockComponent('bar', 0) comp.addInput('aaa', 456) compList.append(comp) self.assertEqual(len(mgr.pool), 0) nameList = [] for c in compList: mgr.add(c) nameList.append(c.name) self.assertEqual(len(mgr.pool), len(compList)) logger = MockLogger('main') self.assertRaises(ValueError, mgr.makeRunset, nameList, logger) self.assertEqual(len(mgr.pool), len(compList)) for c in compList: mgr.remove(c) self.assertEqual(len(mgr.pool), 0) logger.checkStatus(10)
def testBuildMultiInput(self): self.__runConfigDir = tempfile.mkdtemp() mgr = MyDAQPool() compList = [] comp = MockComponent('fooHub', 0) comp.addOutput('conn') compList.append(comp) comp = MockComponent('bar', 0) comp.addInput('conn', 123) compList.append(comp) comp = MockComponent('baz', 0) comp.addInput('conn', 456) compList.append(comp) self.assertEqual(mgr.numComponents(), 0) for c in compList: mgr.add(c) self.assertEqual(mgr.numComponents(), len(compList)) runConfig = self.__createRunConfigFile(compList) logger = MockLogger('main') logger.addExpectedExact("Loading run configuration \"%s\"" % runConfig) logger.addExpectedExact("Loaded run configuration \"%s\"" % runConfig) logger.addExpectedRegexp("Built runset #\d+: .*") runset = mgr.makeRunset(self.__runConfigDir, runConfig, 0, logger, forceRestart=False, strict=False) self.assertEqual(mgr.numComponents(), 0) found = mgr.findRunset(runset.id()) self.failIf(found is None, "Couldn't find runset #%d" % runset.id()) mgr.returnRunset(runset, logger) self.assertEqual(mgr.numComponents(), len(compList)) for c in compList: mgr.remove(c) self.assertEqual(mgr.numComponents(), 0) logger.checkStatus(10)
def testBuildMultiMissing(self): self.__runConfigDir = tempfile.mkdtemp() mgr = MyDAQPool() compList = [] outputName = "xxx" comp = MockComponent('fooHub', 0) comp.addInput(outputName, 123) compList.append(comp) comp = MockComponent('bar', 0) comp.addOutput(outputName) compList.append(comp) comp = MockComponent('feeHub', 0) comp.addInput(outputName, 456) compList.append(comp) comp = MockComponent('baz', 0) comp.addOutput(outputName) compList.append(comp) self.assertEqual(mgr.numComponents(), 0) for c in compList: mgr.add(c) self.assertEqual(mgr.numComponents(), len(compList)) runConfig = self.__createRunConfigFile(compList) logger = MockLogger('main') logger.addExpectedExact("Loading run configuration \"%s\"" % runConfig) logger.addExpectedExact("Loaded run configuration \"%s\"" % runConfig) try: mgr.makeRunset(self.__runConfigDir, runConfig, 0, logger, forceRestart=False, strict=False) self.fail("makeRunset should not succeed") except ConnectionException, ce: if str(ce).find( "Found 2 %s inputs for 2 outputs" % outputName) < 0: raise ce
def testBuildMultiMissing(self): mgr = DAQPool() compList = [] comp = MockComponent('fooHub', 0) comp.addInput('xxx', 123) compList.append(comp) comp = MockComponent('bar', 0) comp.addOutput('xxx') compList.append(comp) comp = MockComponent('feeHub', 0) comp.addInput('xxx', 456) compList.append(comp) comp = MockComponent('baz', 0) comp.addOutput('xxx') compList.append(comp) self.assertEqual(len(mgr.pool), 0) nameList = [] for c in compList: mgr.add(c) nameList.append(c.name) self.assertEqual(len(mgr.pool), len(compList)) logger = MockLogger('main') try: mgr.makeRunset(nameList, logger) self.fail('Unexpected success') except ValueError: pass except: self.fail('Unexpected exception') self.assertEqual(len(mgr.pool), len(compList)) for c in compList: mgr.remove(c) self.assertEqual(len(mgr.pool), 0) logger.checkStatus(10)
def testBuildMultiInput(self): mgr = DAQPool() compList = [] comp = MockComponent('fooHub', 0) comp.addOutput('conn') compList.append(comp) comp = MockComponent('bar', 0) comp.addInput('conn', 123) compList.append(comp) comp = MockComponent('baz', 0) comp.addInput('conn', 456) compList.append(comp) self.assertEqual(len(mgr.pool), 0) nameList = [] for c in compList: mgr.add(c) nameList.append(c.name) self.assertEqual(len(mgr.pool), len(compList)) logger = MockLogger('main') runset = mgr.makeRunset(nameList, logger) self.assertEqual(len(mgr.pool), 0) found = mgr.findRunset(runset.id) self.failIf(found is None, "Couldn't find runset #" + str(runset.id)) mgr.returnRunset(runset) self.assertEqual(len(mgr.pool), len(compList)) for c in compList: mgr.remove(c) self.assertEqual(len(mgr.pool), 0) logger.checkStatus(10)
def testMonitorClients(self): self.__runConfigDir = tempfile.mkdtemp() mgr = MyDAQPool() compList = [] fooHub = MockComponent('fooHub', 0) fooHub.addOutput('conn') compList.append(fooHub) barComp = MockComponent('bar', 0) barComp.addInput('conn', 123) compList.append(barComp) bazComp = MockComponent('baz', 0) bazComp.addInput('conn', 456) compList.append(bazComp) self.assertEqual(mgr.numComponents(), 0) for c in compList: mgr.add(c) self.assertEqual(mgr.numComponents(), len(compList)) cnt = mgr.monitorClients() self.assertEqual(cnt, len(compList)) for c in compList: self.assertEqual(c.monitorCount(), 1) fooHub.setMonitorState(DAQClient.STATE_DEAD) bazComp.setMonitorState(DAQClient.STATE_MISSING) self.assertEqual(mgr.numComponents(), len(compList)) cnt = mgr.monitorClients() self.assertEqual(cnt, 1) self.assertEqual(mgr.numComponents(), 2) for c in compList: self.assertEqual(c.monitorCount(), 2)
def testStartRun(self): mgr = DAQPool() a = MockComponent('aHub', 0) a.addOutput('ab') b = MockComponent('b', 0) b.addInput('ab', 123) b.addOutput('bc') c = MockComponent('c', 0) c.addInput('bc', 456) compList = [c, a, b] self.assertEqual(len(mgr.pool), 0) nameList = [] for c in compList: mgr.add(c) nameList.append(c.name) self.assertEqual(len(mgr.pool), len(compList)) logger = MockLogger('main') runset = mgr.makeRunset(nameList, logger) self.assertEqual(len(mgr.pool), 0) self.assertEqual(len(runset.set), len(compList)) runset.configure('abc') ordered = True prevName = None for s in runset.set: if not prevName: prevName = s.name elif prevName > s.name: ordered = False self.failIf(ordered, 'Runset sorted before startRun()') runset.startRun(1) ordered = True prevName = None for s in runset.set: if not prevName: prevName = s.name elif prevName < s.name: ordered = False self.failUnless(ordered, 'Runset was not sorted by startRun()') runset.stopRun() ordered = True prevName = None for s in runset.set: if not prevName: prevName = s.name elif prevName > s.name: ordered = False self.failUnless(ordered, 'Runset was not reversed by stopRun()') mgr.returnRunset(runset) self.assertEqual(runset.id, None) self.assertEqual(runset.configured, False) self.assertEqual(runset.runNumber, None) self.assertEqual(len(mgr.pool), len(compList)) self.assertEqual(len(runset.set), 0) logger.checkStatus(10)
def testStartRun(self): self.__runConfigDir = tempfile.mkdtemp() mgr = MyDAQPool() a = MockComponent('aHub', 0) a.addOutput('ab') b = MockComponent('b', 0) b.addInput('ab', 123) b.addOutput('bc') c = MockComponent('c', 0) c.addInput('bc', 456) compList = [c, a, b] self.assertEqual(mgr.numComponents(), 0) for c in compList: mgr.add(c) self.assertEqual(mgr.numComponents(), len(compList)) runConfig = self.__createRunConfigFile(compList) logger = MockLogger('main') logger.addExpectedExact("Loading run configuration \"%s\"" % runConfig) logger.addExpectedExact("Loaded run configuration \"%s\"" % runConfig) logger.addExpectedRegexp("Built runset #\d+: .*") runset = mgr.makeRunset(self.__runConfigDir, runConfig, 0, logger, forceRestart=False, strict=False) self.assertEqual(mgr.numComponents(), 0) self.assertEqual(runset.size(), len(compList)) self.__checkRunsetState(runset, 'ready') clusterName = "cluster-foo" dashLog = runset.getLog("dashLog") dashLog.addExpectedRegexp(r"Version info: \S+ \d+ \S+ \S+ \S+ \S+" + r" \d+\S*") dashLog.addExpectedExact("Run configuration: %s" % runConfig) dashLog.addExpectedExact("Cluster configuration: %s" % clusterName) self.__checkRunsetState(runset, 'ready') runNum = 1 moniType = RunOption.MONI_TO_NONE logger.addExpectedExact("Starting run #%d with \"%s\"" % (runNum, clusterName)) dashLog.addExpectedExact("Starting run %d..." % runNum) global ACTIVE_WARNING if not LIVE_IMPORT and not ACTIVE_WARNING: ACTIVE_WARNING = True dashLog.addExpectedExact("Cannot import IceCube Live code, so" + " per-string active DOM stats wil not" + " be reported") versionInfo = { "filename": "fName", "revision": "1234", "date": "date", "time": "time", "author": "author", "release": "rel", "repo_rev": "1repoRev", } spadeDir = "/tmp" copyDir = None runset.startRun(runNum, clusterName, moniType, versionInfo, spadeDir, copyDir) self.__checkRunsetState(runset, 'running') numEvts = 0 numSecs = 0 numMoni = 0 numSN = 0 numTcals = 0 dashLog.addExpectedExact("%d physics events collected in %d seconds" % (numEvts, numSecs)) dashLog.addExpectedExact("%d moni events, %d SN events, %d tcals" % (numMoni, numSN, numTcals)) dashLog.addExpectedExact("Run terminated SUCCESSFULLY.") self.failIf(runset.stopRun(), "stopRun() encountered error") self.__checkRunsetState(runset, 'ready') mgr.returnRunset(runset, logger) self.assertEqual(runset.id(), None) self.assertEqual(runset.configured(), False) self.assertEqual(runset.runNumber(), None) self.assertEqual(mgr.numComponents(), len(compList)) self.assertEqual(runset.size(), 0) logger.checkStatus(10)