Beispiel #1
0
    def test_controller_none_msg(self):
        log = test_utils.create_capture_log()

        # test subject
        core = EventCore(log=log)
        self.assertIsNotNone(core)

        # start test subject
        the_spawn = spawn(core.run)
        sleep(.005)  # give the spawn a chance to initialize
        self.assertFalse(core.is_stopped)

        # test controller shutdown
        controller = core.controller
        controller.signal_message({})
        sleep(0.01)  # allow for processing of the message

        self.assertFalse(core.is_stopped)

        # ensure that the core is shutdown
        core.kill()
        sleep(0.005)
        the_spawn.join(timeout=5)
        self.assertTrue(core.is_stopped)

        self.assertListEqual(['Empty command message delivered.'],
                             log.capture_handle.read_messages())
    def test_controller_none_msg(self):
        log = test_utils.create_capture_log()

        # test subject
        core = EventCore(log=log)
        self.assertIsNotNone(core)

        # start test subject
        the_spawn = spawn(core.run)
        sleep(.005)  # give the spawn a chance to initialize
        self.assertFalse(core.is_stopped)

        # test controller shutdown
        controller = core.controller
        controller.signal_message({})
        sleep(0.01)  # allow for processing of the message

        self.assertFalse(core.is_stopped)

        # ensure that the core is shutdown
        core.kill()
        sleep(0.005)
        the_spawn.join(timeout=5)
        self.assertTrue(core.is_stopped)

        self.assertListEqual(['Empty command message delivered.'],
                             log.capture_handle.read_messages())
Beispiel #3
0
    def test_simple_event_core(self):
        # test subject
        core = EventCore()
        self.assertIsNotNone(core)

        # test initial state
        self.assertTrue(core._stopped)

        # text run state
        the_spawn = spawn(core.run)
        sleep(0.005)  # give the spawn a chance to initialize
        self.assertFalse(core.is_stopped)

        # test shutdown state
        core.kill()
        the_spawn.join(timeout=5)
        self.assertTrue(core.is_stopped)
    def test_register_default_responder(self):
        core = EventCore(command_port=63353)
        responder = core.connection_manager.register_responder()

        # validate responder
        self.assertIsNotNone(responder)
        self.assertEqual('*', responder.address)
        self.assertIs(long, type(responder.id))
        self.assertEqual(60053, responder.port)
        self.assertEqual('tcp', responder.protocol)
        self.assertEqual('reply', responder.type)
    def test_register_default_sink(self):
        # test subjects
        core = EventCore(command_port=63353)
        sink = core.connection_manager.register_sink()

        # validate sink
        self.assertIsNotNone(sink)
        self.assertEqual('*', sink.address)
        self.assertIs(long, type(sink.id))
        self.assertEqual(60053, sink.port)
        self.assertEqual('tcp', sink.protocol)
        self.assertEqual('push', sink.type)
Beispiel #6
0
    def test_controller_kill_msg(self):
        # test subject
        core = EventCore(command_port=9002)
        self.assertIsNotNone(core)

        # start test subject
        the_spawn = spawn(core.run)
        sleep(.005)  # give the spawn a chance to initialize
        self.assertFalse(core.is_stopped)

        # test controller shutdown
        controller = core.controller
        kill_cmd = CommandMessage(cmd=CommandMessage.CMD_KILL)
        controller.signal_message(kill_cmd)
        the_spawn.join(timeout=5)

        # ensure that the core is shutdown
        self.assertTrue(core.is_stopped)
    def test_register_default_listener(self):
        # test subjects
        core = EventCore(command_port=63353)
        listener = core.connection_manager.register_listener()

        # validate listener
        self.assertIsNotNone(listener)
        self.assertEqual('localhost', listener.address)
        self.assertIs(long, type(listener.id))
        self.assertEqual(60053, listener.port)
        self.assertEqual('tcp', listener.protocol)
        self.assertEqual('pull', listener.type)

        # validate core state
        con_mgr_listener_configs = core.connection_manager.listener_configs
        self.assertEqual(1, len(con_mgr_listener_configs))
        self.assertIsNot(con_mgr_listener_configs[listener.id], listener,
                         'Listeners should be copies, and not equivalent.')
        self.assertIsNot(
            con_mgr_listener_configs[listener.id],
            core.connection_manager._listener_configs[listener.id],
            'Only listener copies should be exposed.')
Beispiel #8
0
    def test_event_core_restart(self):
        # test subject
        core = EventCore(command_port=9901)
        self.assertIsNotNone(core)

        # start and shutdown in prep for restart
        the_spawn = spawn(core.run)
        sleep(0.005)
        core.kill()
        the_spawn.join(timeout=5)
        self.assertTrue(core.is_stopped)

        # restart
        the_spawn = spawn(core.run)
        sleep(0.005)
        self.assertFalse(core.is_stopped)
        core.kill()
        the_spawn.join(timeout=5)
        self.assertTrue(core.is_stopped)