Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    def testBuildMatchPlusMissingMultiOutput(self):
        self.__runConfigDir = tempfile.mkdtemp()

        mgr = MyDAQPool()

        compList = []

        inputName = "yyy"

        comp = MockComponent('fooHub', 0)
        comp.addInput('xxx', 123)
        comp.addInput(inputName, 456)
        comp.addOutput('aaa')
        compList.append(comp)

        comp = MockComponent('bar', 0)
        comp.addInput('aaa', 789)
        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("No outputs found for %s inputs" % inputName) < 0:
                raise ce
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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)