def testAddComponent(self): """ Test if the component is added to DB. """ config = self.config self.tempDir = self.testInit.generateWorkDir(config) config.component_("TestComponent") config.TestComponent.logLevel = 'INFO' config.section_("General") config.TestComponent.componentDir = os.path.join( \ self.tempDir, "Components/TestComponent1") config.General.workDir = config.TestComponent.componentDir os.makedirs( config.TestComponent.componentDir ) testComponent = TestComponent(config) testComponent.prepareToStart() query = {'key':"TestComponent"} workers = self.agent_db.loadView('Agent', 'existWorkers', query)['rows'] assert len(workers) == 1
def testAddComponent(self): """ Test if the component is added to DB. """ config = self.config self.tempDir = self.testInit.generateWorkDir(config) config.component_("TestComponent") config.TestComponent.logLevel = 'INFO' config.section_("General") config.TestComponent.componentDir = os.path.join( \ self.tempDir, "Components/TestComponent1") config.General.workDir = config.TestComponent.componentDir os.makedirs(config.TestComponent.componentDir) testComponent = TestComponent(config) testComponent.prepareToStart() query = {'key': "TestComponent"} workers = self.agent_db.loadView('Agent', 'existWorkers', query)['rows'] assert len(workers) == 1
def testB(self): raise nose.SkipTest config = self.testInit.getConfiguration() self.tempDir = self.testInit.generateWorkDir(config) config.component_("TestComponent") config.TestComponent.logLevel = 'INFO' config.section_("General") config.TestComponent.componentDir = os.path.join( \ self.tempDir, "Components/TestComponent1") config.General.workDir = config.TestComponent.componentDir os.makedirs(config.TestComponent.componentDir) # as this is a test we build the string from our global environment # parameters normally you put this straight into the DefaultConfig.py file: # testInit.getConfiguration returns from the environment variable by default testComponent = TestComponent(config) testComponent.prepareToStart() testComponent.handleMessage('LogState', '') testComponent.handleMessage('TestMessage1', 'TestMessag1Payload') testComponent.handleMessage('TestMessage2', 'TestMessag2Payload') testComponent.handleMessage('TestMessage3', 'TestMessag3Payload') testComponent.handleMessage('TestMessage4', 'TestMessag4Payload') testComponent.handleMessage('Logging.DEBUG', '') testComponent.handleMessage('Logging.WARNING', '') testComponent.handleMessage('Logging.CRITICAL', '') testComponent.handleMessage('Logging.ERROR', '') testComponent.handleMessage('Logging.INFO', '') testComponent.handleMessage('Logging.SQLDEBUG', '') testComponent.handleMessage('TestComponent:Logging.DEBUG', '') testComponent.handleMessage('TestComponent:Logging.WARNING', '') testComponent.handleMessage('TestComponent:Logging.CRITICAL', '') testComponent.handleMessage('TestComponent:Logging.ERROR', '') testComponent.handleMessage('TestComponent:Logging.INFO', '') testComponent.handleMessage('TestComponent:Logging.SQLDEBUG', '') # test a non existing message (to generate an error) errorMsg = '' try: testComponent.handleMessage('NonExistingMessageType', '') except Exception as ex: errorMsg = str(ex) self.assertTrue( errorMsg.startswith('Message NonExistingMessageType with payload'))
def testB(self): raise nose.SkipTest config = self.testInit.getConfiguration() self.tempDir = self.testInit.generateWorkDir(config) config.component_("TestComponent") config.TestComponent.logLevel = 'INFO' config.section_("General") config.TestComponent.componentDir = os.path.join( \ self.tempDir, "Components/TestComponent1") config.General.workDir = config.TestComponent.componentDir os.makedirs(config.TestComponent.componentDir) # as this is a test we build the string from our global environment # parameters normally you put this straight into the DefaultConfig.py file: # testInit.getConfiguration returns from the environment variable by default testComponent = TestComponent(config) testComponent.prepareToStart() testComponent.handleMessage('LogState', '') testComponent.handleMessage('TestMessage1', 'TestMessag1Payload') testComponent.handleMessage('TestMessage2', 'TestMessag2Payload') testComponent.handleMessage('TestMessage3', 'TestMessag3Payload') testComponent.handleMessage('TestMessage4', 'TestMessag4Payload') testComponent.handleMessage('Logging.DEBUG', '') testComponent.handleMessage('Logging.WARNING', '') testComponent.handleMessage('Logging.CRITICAL', '') testComponent.handleMessage('Logging.ERROR', '') testComponent.handleMessage('Logging.INFO', '') testComponent.handleMessage('Logging.SQLDEBUG', '') testComponent.handleMessage('TestComponent:Logging.DEBUG', '') testComponent.handleMessage('TestComponent:Logging.WARNING', '') testComponent.handleMessage('TestComponent:Logging.CRITICAL', '') testComponent.handleMessage('TestComponent:Logging.ERROR', '') testComponent.handleMessage('TestComponent:Logging.INFO', '') testComponent.handleMessage('TestComponent:Logging.SQLDEBUG', '') # test a non existing message (to generate an error) errorMsg = '' try: testComponent.handleMessage('NonExistingMessageType', '') except Exception as ex: errorMsg = str(ex) self.assertTrue(errorMsg.startswith('Message NonExistingMessageType with payload'))
def testAddWorker(self): """ Test if the a component worked is added to DB. """ config = self.config self.tempDir = self.testInit.generateWorkDir(config) config.component_("TestComponent") config.TestComponent.logLevel = 'INFO' config.section_("General") config.TestComponent.componentDir = os.path.join( \ self.tempDir, "Components/TestComponent1") config.General.workDir = config.TestComponent.componentDir os.makedirs( config.TestComponent.componentDir ) testComponent = TestComponent(config) testComponent.prepareToStart() myThread = threading.currentThread() myThread.workerThreadManager.addWorker(TestComponentPoller(config), 10) myThread.workerThreadManager.terminateWorkers() query = {'key':"TestComponent"} workers = self.agent_db.loadView('Agent', 'existWorkers', query)['rows'] assert workers[0]['value'].has_key('TestComponentPoller') == True
def testAddWorker(self): """ Test if the a component worked is added to DB. """ config = self.config self.tempDir = self.testInit.generateWorkDir(config) config.component_("TestComponent") config.TestComponent.logLevel = 'INFO' config.section_("General") config.TestComponent.componentDir = os.path.join( \ self.tempDir, "Components/TestComponent1") config.General.workDir = config.TestComponent.componentDir os.makedirs(config.TestComponent.componentDir) testComponent = TestComponent(config) testComponent.prepareToStart() myThread = threading.currentThread() myThread.workerThreadManager.addWorker(TestComponentPoller(config), 10) myThread.workerThreadManager.terminateWorkers() query = {'key': "TestComponent"} workers = self.agent_db.loadView('Agent', 'existWorkers', query)['rows'] assert workers[0]['value'].has_key('TestComponentPoller') == True