Example #1
0
def test_threaded_srv():
    import threading
    from test_bl.test_bl_tools import udp_server
    '''
    TO BECOME properly initialised
    Server needs logger
    '''
    # conf = sonata_send_recieve_properties.SonataSendReceiveProperties()
    conf = sonata_suite_config.SonataSuiteConfig()

    lt = conf.logging_tools
    '''
    Server needs iterable to store data_from in
    '''
    data_in = []
    '''
    Server needs listening prefs
    '''

    server02 = conf.sender_receiver.udp_server
    # ip, port = server.server_address  # find out what port we were given
    ip02, port02 = server02.server_address

    # server02.serve_forever()
    t01 = threading.Thread(target=server02.serve_forever)
    t01.setDaemon(True)  # don't hang on exit
    t01.start()
    t01.join

    server02.stop_serve_forever = False

    address = ('10.11.10.12', 55557)
    # address = ('localhost', 0)  # let the kernel give us a port
    server = udp_server.UdpServer(address, UdpPayloadHandler, data_in, lt,
                                  conf)

    t = threading.Thread(target=server.serve_forever)
    t.setDaemon(True)  # don't hang on exit
    t.start()
    t.join

    # server.RequestHandlerClass.srv_shutdown = True

    # server.serve_forever()
    '''
    Stop UDP server.
    NB! When attempt is made to use flag.
    It is not checked until the moment when the new service request comes in
    '''
    # server.stop_serve_forever = False  # don't hang on exit
    '''Regular procedure is a shutdown method call. It sets flag checked authomatically'''

    server02.stop_server()
    server.stop_server()

    return
Example #2
0
class NMEAConversionTests(unittest.TestCase):
    """Logging tools"""
    '''Logging'''

    lt = logging_tools.LoggingTools(
        default_level="DEBUG",
        logging_dir=
        "C:\\data\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\bl_frame_work",
        log_file="logging_conf.json",
        log_file_dir=
        "C:\\data\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\bl_frame_work",
        log_conf_full=
        "C:\data\kronshtadt\QA\BL\AutomationFrameworkDesign\bl_frame_work\test_bl\test_sonata_plugin\configs_sonata\logging_conf.json"
    )

    msg_q = deque()
    msg_l = []

    udp_sender = udp_sender.UdpSender(msg_iterator=msg_l.__iter__(),
                                      delay=1,
                                      logging_tools=lt,
                                      ip_to="10.11.10.12",
                                      port_to="55555",
                                      msg_queue=msg_q,
                                      msg_sent_evnt=None,
                                      msg_src_slctr=0)

    address = ('10.11.10.12', 55557)
    data_in = []
    udp_udp_server = udp_server.UdpServer(server_address=address,
                                          handler_class=UdpPayloadHandler,
                                          data_in=data_in,
                                          curr_log_tools=lt,
                                          conf_in=None,
                                          msg_res_event=None)

    @classmethod
    def tearDownClass(self):

        return

    def setUp(self):

        return

    def tearDown(self):

        return

    @unittest.skip("test_nmea01 is not needed now")
    def test_nmea01(self):

        return
Example #3
0
def test_this():
    import threading
    from test_bl.test_bl_tools import logging_tools, udp_server, udp_sender
    from test_bl.test_sonata_plugin.configs_sonata import sonata_suite_config
    '''
    TO BECOME properly initialised
    Server needs logger
    '''
    #conf = sonata_send_recieve_properties.SonataSendReceiveProperties()
    conf = sonata_suite_config.SonataSuiteConfig()

    lt = conf.logging_tools
    '''
    Server needs iterable to store data_from in
    '''
    data_in = []
    '''
    Server needs listening prefs
    '''
    address = ('10.11.10.12', 55556)
    #address = ('localhost', 0)  # let the kernel give us a port
    server = udp_server.UdpServer(address, UdpPayloadHandler, data_in, lt,
                                  conf)
    ip, port = server.server_address  # find out what port we were given

    t = threading.Thread(target=server.serve_forever)
    t.setDaemon(True)  # don't hang on exit
    t.start()
    t.join
    '''
    Pure debug 
    '''
    logger = logging.getLogger('External call to logger')
    logger.info('Server on %s:%s', ip, port)
    '''
    Stop UDP server
    '''
    t.stop_serve_forever = False  # don't hang on exit

    return