示例#1
0
    def testD(self):
        raise nose.SkipTest
        config = self.testInit.getConfiguration()
        config.component_("TestComponent")
        config.TestComponent.logLevel = 'INFO'
        config.section_("General")
        self.tempDir = self.testInit.generateWorkDir(config)
        # try starting a component as a daemon:
        config.TestComponent.componentDir = os.path.join( \
            self.tempDir, "Components/TestComponent2")
        os.makedirs(config.TestComponent.componentDir)
        testComponent = TestComponent(config)
        # we set the parent to true as we are testing
        testComponent.startDaemon(keepParent=True)
        time.sleep(2)
        daemonFile = os.path.join(config.TestComponent.componentDir,
                                  "Daemon.xml")
        details = Details(daemonFile)
        print('Is component alive: ' + str(details.isAlive()))

        # create msgService to send stop message.
        myThread = threading.currentThread()
        factory = WMFactory("msgService", "WMCore.MsgService." + \
                            myThread.dialect)
        myThread.transaction = Transaction(myThread.dbi)
        msgService = factory.loadObject("MsgService")
        msgService.registerAs("HarnessTest")
        myThread.transaction.commit()

        print(
            'Publish a stop message to test if the component shutsdown gracefully'
        )
        myThread.transaction.begin()
        msg = {'name': 'Stop', 'payload': ''}
        msgService.publish(msg)
        myThread.transaction.commit()

        msgService.finish()

        while details.isAlive():
            print('Component has not received stop message')
            time.sleep(2)
        print('Daemon shutdown gracefully')
示例#2
0
    def testD(self):
        raise nose.SkipTest
        config = self.testInit.getConfiguration()
        config.component_("TestComponent")
        config.TestComponent.logLevel = 'INFO'
        config.section_("General")
        self.tempDir = self.testInit.generateWorkDir(config)
        # try starting a component as a daemon:
        config.TestComponent.componentDir = os.path.join( \
                    self.tempDir, "Components/TestComponent2")
        os.makedirs( config.TestComponent.componentDir )
        testComponent = TestComponent(config)
        # we set the parent to true as we are testing
        testComponent.startDaemon(keepParent = True)
        time.sleep(2)
        daemonFile = os.path.join(config.TestComponent.componentDir, "Daemon.xml")
        details = Details(daemonFile)
        print('Is component alive: '+str(details.isAlive()))

        #create msgService to send stop message.
        myThread = threading.currentThread()
        factory = WMFactory("msgService", "WMCore.MsgService."+ \
            myThread.dialect)
        myThread.transaction = Transaction(myThread.dbi)
        msgService = factory.loadObject("MsgService")
        msgService.registerAs("HarnessTest")
        myThread.transaction.commit()

        print('Publish a stop message to test if the component shutsdown gracefully')
        myThread.transaction.begin()
        msg = {'name' : 'Stop', 'payload' : ''}
        msgService.publish(msg)
        myThread.transaction.commit()


        msgService.finish()

        while details.isAlive():
            print('Component has not received stop message')
            time.sleep(2)
        print('Daemon shutdown gracefully')
示例#3
0
 def testC(self):
     raise nose.SkipTest
     config = self.testInit.getConfiguration()
     self.tempDir = self.testInit.generateWorkDir(config)
     config.component_("TestComponent")
     config.TestComponent.logLevel = 'INFO'
     config.section_("General")
     # try starting a component as a daemon:
     config.TestComponent.componentDir = os.path.join( \
         self.tempDir, "Components/TestComponent1")
     os.makedirs(config.TestComponent.componentDir)
     testComponent = TestComponent(config)
     # we set the parent to true as we are testing
     testComponent.startDaemon(keepParent=True)
     print('trying to kill the component')
     time.sleep(2)
     daemonFile = os.path.join(config.TestComponent.componentDir, "Daemon.xml")
     details = Details(daemonFile)
     print('Is component alive: ' + str(details.isAlive()))
     time.sleep(2)
     details.killWithPrejudice()
     print('Daemon killed')
示例#4
0
 def testC(self):
     raise nose.SkipTest
     config = self.testInit.getConfiguration()
     self.tempDir = self.testInit.generateWorkDir(config)
     config.component_("TestComponent")
     config.TestComponent.logLevel = 'INFO'
     config.section_("General")
     # try starting a component as a daemon:
     config.TestComponent.componentDir = os.path.join( \
                 self.tempDir, "Components/TestComponent1")
     os.makedirs( config.TestComponent.componentDir )
     testComponent = TestComponent(config)
     # we set the parent to true as we are testing
     testComponent.startDaemon(keepParent = True)
     print('trying to kill the component')
     time.sleep(2)
     daemonFile = os.path.join(config.TestComponent.componentDir, "Daemon.xml")
     details = Details(daemonFile)
     print('Is component alive: '+str(details.isAlive()))
     time.sleep(2)
     details.killWithPrejudice()
     print('Daemon killed')