예제 #1
0
def test_this_sender():
    from test_bl.test_bl_tools import logging_tools
    """
    send_receive class basic usage
    """
    lt = logging_tools.LoggingTools(
        default_path=
        "C:\\data\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\FW_28_08_2018\\test_bl\\test_bl_configs\\logging_conf.json"
    )
    logger = lt.get_logger(__name__)
    sr = SendReceive(logging_tools=lt, q_based=True)

    messages = [
        "msg01 \n", "msg02 \n", "msg03 \n", "msg04 \n", "msg05 \n", "msg06 \n"
    ]
    udp_snd_01_name = sr.set_udp_sender(ip_to="10.11.10.12", port_to="55555")
    sr.udp_send_to(messages_list=messages, sender_id=udp_snd_01_name)

    udp_snd_02_name = sr.set_udp_sender(ip_to="10.11.10.12", port_to="55556")
    sr.udp_send_to(messages_list=messages, sender_id=udp_snd_02_name)

    sr.stop_sender(udp_snd_01_name)

    udp_snd_03_name = sr.set_udp_sender(ip_to="10.11.10.12", port_to="55557")
    sr.udp_send_to(messages_list=messages, sender_id=udp_snd_03_name)

    return
예제 #2
0
def test_this():
    import os
    from test_bl.test_sonata_plugin.structs_sonata import sonata_msg
    from test_bl.test_bl_tools import logging_tools
    """
    BASIC TEST BASIC CONFIG
    """
    '''
    Read test data from json
    '''
    '''And where we are'''
    module_abs_path = os.path.abspath(os.path.dirname(__file__))
    path_to_data = "..\\test_sonata_plugin\\resources_sonata\\sonata_test_data.json"
    def_mgs_location = os.path.join(module_abs_path, path_to_data)
    path_to_log_conf = "..\\test_bl_configs\\logging_conf.json"

    lt = logging_tools.LoggingTools(path_to_json=path_to_log_conf)
    logger = lt.get_logger(__name__)

    rd = ReadData(def_mgs_location, test_data_type=test_data_type.json)

    sonata_msg_struct = sonata_msg.SonataMsg(logging_tools=lt)
    rd.read_json_to_map()
    testsuite_data = rd.get_testsuite_data(msg_struct=sonata_msg_struct)
    test_ids = [
        "test_sonata_messages01", "test_sonata_messages05",
        "test_sonata_messages02", "test_sonata_messages07",
        "test_sonata_messages05"
    ]
    for id in test_ids:
        test_messages = rd.get_testcase_messages(id)
        test_data = rd.get_testcase_data(id)
    logger.info("test messages collected: " + str(test_messages) + "\n")
    logger.info("test data collected: " + str(test_data) + "\n")
    logger.info("End of test read data_from")
예제 #3
0
 def _config_loggers(self, path_to_logging_conf):
     """
     :param path_to_logging_conf:
     :return:
     """
     '''
     setup all loggers for all modules at once
     '''
     logging_tools.LoggingTools(path_to_json=path_to_logging_conf)
예제 #4
0
def config_loggers():
    import os
    '''here we are'''
    module_abs_path = os.path.abspath(os.path.dirname(__file__))
    '''config logging'''
    path_to_logging_conf = "..\\test_bl_configs\\logging_conf.json"
    path_to_logging_conf = os.path.join(module_abs_path, path_to_logging_conf)
    '''setup all loggers for all modules at once'''
    logging_tools.LoggingTools(path_to_json=path_to_logging_conf)
예제 #5
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
예제 #6
0
def test_this_server():
    from test_bl.test_bl_tools import logging_tools
    """
    send_receive class basic usage
    """
    lt = logging_tools.LoggingTools(
        default_path=
        "C:\\data\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\FW_28_08_2018\\test_bl\\test_bl_configs\\logging_conf.json"
    )
    logger = lt.get_logger(__name__)
    sr = SendReceive(logging_tools=lt, q_based=True)
    sr.set_udp_server(ip_address="10.11.10.12", port=55556)
    sr.stop_udp_server()
    return
예제 #7
0
 def config_loggers(path_to_json):
     """
     This function just sets up all
     loggers for all modules at ones
     based on logging_conf.json
     :return: nothing
     """
     import os
     '''current location of the project'''
     module_abs_path = os.path.abspath(os.path.dirname(__file__))
     '''config logging'''
     path_to_logging_conf = path_to_json
     path_to_logging_conf = os.path.join(module_abs_path,
                                         path_to_logging_conf)
     '''setup all loggers for all modules at once'''
     logging_tools.LoggingTools(path_to_json=path_to_logging_conf)
예제 #8
0
def test_this_read_data():
    from test_bl.test_bl_tools import logging_tools
    """
    send_receive class basic usage
    """
    lt = logging_tools.LoggingTools(
        default_path=
        "C:\\data\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\bl_git_branching\\test_bl\\test_bl_configs\\logging_conf.json"
    )
    logger = lt.get_logger(__name__)
    sr = SendReceive(logging_tools=lt, q_based=True)

    udp_snd_01_name = sr.set_udp_sender(ip_to="10.11.10.11", port_to="55555")
    udp_srv_name = sr.set_udp_server(ip_address="10.11.10.12", port=55556)

    received_q = sr.get_received_queue(udp_srv_name)
    test_ids = [
        "test_sonata_messages05", "test_sonata_messages06",
        "test_sonata_messages07"
    ]
    for index in test_ids:
        messages_file = get_test_messages(test_case_id=index)
        sr.udp_send_to(messages_list=messages_file, sender_id=udp_snd_01_name)
        sr.check_all_messages_received(messages_list=messages_file,
                                       server_id=udp_srv_name)
        result = sr.get_received_queue(server_id=udp_srv_name)
        logging.debug("DATA RECEIVED: ==>" + str(result) + "\n")
    '''
    result = []
    while not received_q.empty():

        result.append(received_q.get())
    logging.debug("==>>>" + str(result))
    result.clear()
    '''

    sr.stop_sender(udp_snd_01_name)
    sr.stop_udp_server(udp_srv_name)
    return
예제 #9
0
    def __init__(self):
        """
        Connection establishment and in/out data_from fields setup
        """
        '''
        Set env variables for all configs to use.
        TODO: Good idea would be to read variables that are needed for configuration
        to be read from the same .cmd or .bash script that sets
        them to 
        be checked and assigned into config values structure to be used during the course
        of tests execution         
        '''
        #cmd_path_commands = 'C:\\data_from\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\bl_frame_work\\env_setup.cmd',
        #cmd_path = 'C:\\data_from\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\bl_frame_work\\'
        '''
        Locations for the .cmd script setting ENV variables
        '''
        self.cmd_path_commands = 'C:\\data\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\bl_frame_work\\env_setup.cmd'
        self.cmd_path = 'C:\\data\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\bl_frame_work'

        self.vm_vbox_manage = ''
        self.vm_alt_img = ''
        self.vm_alt_img_snapshot = ''
        self.ssh_remote_commands_conf_start = ''
        self.ssh_remote_commands_conf_stop = ''
        self.logging_tools = None
        self.ssh_host = ''
        self.ssh_port = ''
        self.ssh_user = ''
        self.ssh_pwd = ''
        self.vm_log_srv_exec = ''
        self.vm_log_srv_dir = ''
        '''
        ----------------------------------------------------------------------------------------------------------------
        '''
        '''
        SET ENV VARIABLES
        '''
        self.ext_scripts = external_scripts.ExtScripts(self,
                                                       self.cmd_path_commands,
                                                       self.cmd_path)
        self.ext_scripts.load_env_vars()
        '''
        self.set_env_vars(self.curr_cmd_path_commands,
                          self.curr_cmd_path
                          )
        '''
        '''
        ----------------------------------------------------------------------------------------------------------------
        '''
        '''
        SET VARS TO DEFINE LOGGING FACILITIES FOR TEST MODULES
        BASED on ENV VARS
        '''

        self.default_path = 'C:\\data_from\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\bl_frame_work\\test_bl\\test_bl_configs\\logging_conf.json'

        self.env_key_default_level = 'BL_LOGGING_LEVEL'
        self.env_key_logging_dir = 'BL_LOGGING_DIR'
        self.env_key_log_file = 'BL_LOG_CONF_FNAME'
        self.env_key_log_file_dir = 'BL_LOG_CONF_PATH'
        self.env_key_log_conf_full = 'BL_LOG_CONF_PATH_TOF'

        self.logging_dir = os.getenv(self.env_key_logging_dir, None)
        self.log_file = os.getenv(self.env_key_log_file, None)
        self.log_file_dir = os.getenv(self.env_key_log_file_dir, None)
        self.log_conf_full = os.getenv(self.env_key_log_conf_full, None)
        self.default_level = os.getenv(self.env_key_default_level, None)

        self.logging_tools = logging_tools.LoggingTools(
            self.default_path, self.default_level, self.logging_dir,
            self.log_file, self.log_file_dir, self.log_conf_full)
        '''
        ----------------------------------------------------------------------------------------------------------------
        '''
        '''
        SET VARS TO DEFINE for TEST DATA RETRIVAL
        '''
        '''
        ----------------------------------------------------------------------------------------------------------------
        '''
        '''
        VARS TO DEFINE MESSAGES USED BY SENDING TOOLS AGAINST MODULES
        '''

        self.env_key_message_type = 'BL_MESSAGES_TYPE'
        self.env_key_message_src = 'BL_MESSAGES_SRC'
        self.env_key_msgs_dir_json = 'BL_MESSAGES_PATH_JSON'
        self.env_key_msgs_dir_txt = 'BL_MESSAGES_PATH_TXT'
        '''
        SET THE TYPE OF MESSAGES TO BE USED IN
        TESTS        
        '''
        self.messages_type = os.getenv(self.env_key_message_type, None)
        self.messages_src = os.getenv(self.env_key_message_src, None)
        self.messages_dir_json = os.getenv(self.env_key_msgs_dir_json, None)
        self.messages_dir_txt = os.getenv(self.env_key_msgs_dir_txt, None)
        '''
        Default not used.
        It is here just in case.
        '''
        self.def_mgs_location = "C:\\data_from\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\bl_frame_work\\resources\\messagesUDP.txt"
        '''
        VARS TO DEFINE TEST DATA  
        TODO: Think about it how to do it better
        req:
        1) messages should be test specific 
        2) facility for choosing specific set per test case should exist
        in load test method   
        Why bother? just use what is needed this time...
        '''
        '''
        Data structures for storing
        and
        retrieving test data_from (input/output)
        '''
        '''
        TODO: reset whatever         
        '''
        self.rd = received_data.RecievedData()
        self.data_received = self.rd.get_received_l_all()
        self.data_sent = self.rd.get_sent_m_all()
        '''
        Set the empty storing 
        structures in everything
        '''
        self.content_proc = sonata_nmea_msgs_content_process.SonataNmeaMsgsContentProcessing(
            self.data_received, self.data_sent)
        '''
        Actual constructed messages that are out 
        to be sent  in each test case
        '''
        self.msgs_to_send = None

        #self.load_test_messages()
        '''
        Test data_from transmission control fields
        '''
        self.env_key_pause_flag = "SENDER_PAUSE_FLAG"
        self.env_key_quit_flag = "SENDER_STOP_FLAG"
        self.env_key_num_msgs_to_send = "NUM_OF_MSGS"
        self.env_key_delay_btwn_msgs = "DEL_BTWN_MSGS"

        self.pause_flag = os.getenv(self.env_key_pause_flag, None)
        self.quit_flag = os.getenv(self.env_key_quit_flag, None)
        self.num_msgs_to_send = int(
            os.getenv(self.env_key_num_msgs_to_send, None))
        self.delay_btwn_msgs = int(
            os.getenv(self.env_key_delay_btwn_msgs, None))
        '''
        |---------------------------------------------------------------------------------------------------------------        
        '''
        '''
        VARS TO DEFINE Connections PREFERENCES
        for TEST DATA senders and RECEIVERS
        '''
        '''
        SENDING ENV KEYS
        '''
        self.env_key_ip_to = "BL_IP_TO"
        self.env_key_port_to = "BL_PORT_TO"
        self.env_key_protocol_to = "BL_PROT_TO"

        self.ip_to = os.getenv(self.env_key_ip_to, None)
        self.port_to = int(os.getenv(self.env_key_port_to, None))
        self.toInfo = ' '.join((self.ip_to, ':', str(self.port_to)))
        '''
        self.env_key_ip_to = "10.11.10.11" #int()
        self.env_key_port_to = 55555 #int()
        self.env_key_toInfo = ' '.join((self.ip_to, ':', str(self.port_to)))
        '''
        '''
        RECEIVEING ENV KEYS
        '''
        self.env_key_ip_on = "BL_IP_ON"
        self.env_key_port_on = "BL_PORT_ON"
        self.env_key_buff_size = "BL_BUFFSZ_ON"

        self.ip_on = os.getenv(self.env_key_ip_on, None)
        self.port_on = int(os.getenv(self.env_key_port_on, None))
        self.buff_size = os.getenv(self.env_key_buff_size, None)
        self.listen_on = (self.ip_on, self.port_on)
        '''
        self.ip_on = "10.11.10.12"
        self.port_on = 55556  # int()
        self.buff_size = 4096  # int()
        '''
        self.listen_on = (self.ip_on, self.port_on)
        #self.onInfo = ' '.join((self.ip_on, ':', str(self.port_on)))
        '''
        Setup for the test suite and current test which uses this configuration
        also
        used by setting up all that pertains to sending receiving data
        '''
        self.curr_test_suite = None
        self.curr_test = None
        def __init__(self):
            """
            Connection establishment and in/out data_from fields setup
            """
            '''
            Set all configs params to be used in ALL TESTS of THIS SUITE dealing with SONATA messages.
            TODO: Good idea would be to read variables that are needed for configuration
            from the same .cmd or .bash script that sets
            them to 
            be checked and assigned into config values structure to be used during the course
            of tests execution. How to do such dynamic assignment? And where static part of it would be?        
            '''
            self.__utils__=var_utils.Varutils()

            '''
            |---------------------------------------------------------------------------------------------------------------        
            '''
            '''
            SET VARIOUS Config files           
            '''
            '''SET PARAMS for LOCAL VM MANAGEMENT and start of LOG SERVER serving BL remotely'''
            self.vm_logsrv_cnf = configparser.ConfigParser()
            self.vm_logsrv_cnf_location = 'C:\\data\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\bl_frame_work\\test_bl\\test_bl_configs\\LocalVM_RemBL_LogSRVconf.ini'
            self.vm_logsrv_cnf.read(self.vm_logsrv_cnf_location)

            '''SET SONATA`S GENERAL CONFIG'''
            self.sonata_cnf = configparser.ConfigParser()
            self.sonata_cnf_location = 'C:\\data\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\bl_frame_work\\test_bl\\test_sonata_plugin\\configs_sonata\\sonata_conf.ini'
            self.sonata_cnf.read(self.sonata_cnf_location)

            '''SET SSH PREFS FOR BL CONFIG AND RESTART HANDLING'''
            self.bl_ssh_cnf = configparser.ConfigParser()
            self.bl_ssh_cnf_location = 'C:\\data\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\bl_frame_work\\test_bl\\test_bl_configs\\ssh_bl_conf_files.ini'
            self.bl_ssh_cnf.read(self.bl_ssh_cnf_location)


            '''
            |---------------------------------------------------------------------------------------------------------------        
            '''
            '''SET VM and LOG SERVER PREFS'''
            self.vm_vbox_manage         = self.vm_logsrv_cnf['LOCAL_VBOX_DIRS']['VBOXMANAGE_DIR']
            self.vm_alt_img             = self.vm_logsrv_cnf['CLEAN_IMAGES']['CLEAN_ALT']
            self.vm_alt_img_snapshot    = self.vm_logsrv_cnf['CLEAN_IMAGES']['CLEAN_ALT_SNAP']
            self.vm_log_srv_exec        = self.vm_logsrv_cnf['LOGGER_SRV']['LOGGER_SRV_EXEC']
            self.vm_log_srv_dir         = self.vm_logsrv_cnf['LOGGER_SRV']['LOGGER_SRV_DIR']

            '''SET SSH PREFS COMMON FOR ALL TEST SUITES'''
            self.ssh_host               = self.bl_ssh_cnf['SSH_PREFS']['SSH_HOST']
            self.ssh_port               = self.bl_ssh_cnf['SSH_PREFS']['SSH_PORT']
            self.ssh_user               = self.bl_ssh_cnf['SSH_PREFS']['SSH_USER_NAME']
            self.ssh_pwd                = self.bl_ssh_cnf['SSH_PREFS']['SSH_PASSWD']
            self.ssh_target_dir         = self.bl_ssh_cnf['SSH_PREFS']['SSH_TARGET_DIR']

            '''Here an assumption is made that all configs and all scripts for all modules are in the same archive
            with predetermined directoryes structure'''
            self.sut_all_confs  = self.bl_ssh_cnf['BL_CONFIG_FILES']['BL_CONF_FILES_ARCH']
            '''
            |---------------------------------------------------------------------------------------------------------------        
            '''
            '''SET REMOTE ACTIONS SPECIFIC FOR SONATA TESTS'''
            '''First we need to copy configs and bash scripts over over.
               Here an assumption is made that all configs and all '''
            self.sut_sonata_confs    = self.sonata_cnf['BL_SONATA_CONFIG_FILES']['SONATA_CONF_FILES_ARCH']

            '''ssh_content_to_copy VAR is known to external scripts that care only about source for files to be copied'''
            self.ssh_content_to_copy = self.sut_sonata_confs

            '''SET BL HANDLING PREFS'''
            '''Second we ought for fill up a map of connamds to be executed remotely'''


            '''These settings handle everything that pertains to BL restart and configuration changes'''

            '''SET COMMANDS to be executed on BL Snapshotrestore/Reboot/FirstStart of Tests'''
            #self.ssh_remote_commands_keys = [key for key in self.sonata_cnf['SUT_CONTROL_COMMANDS_START']]
            self.ssh_remote_commands_keys = self.__utils__.conf_key_to_arr(conf_parser=self.sonata_cnf,
                                                                           section_key='SUT_CONTROL_COMMANDS_START',
                                                                           switch='keys')
            #self.ssh_remote_commands_vals = [value for value in self.sonata_cnf['SUT_CONTROL_COMMANDS_START'].values()]
            self.ssh_remote_commands_vals = self.__utils__.conf_key_to_arr(conf_parser=self.sonata_cnf,
                                                                           section_key='SUT_CONTROL_COMMANDS_START',
                                                                           switch='values')

            '''Final MAP of commands for execution over SSH on tests start'''
            self.ssh_remote_commands_conf_start = self.__utils__.zip_to_map(to_zip01=self.ssh_remote_commands_keys,
                                                                                to_zip02=self.ssh_remote_commands_vals)


            self.ssh_remote_commands_keys = self.__utils__.conf_key_to_arr(conf_parser=self.sonata_cnf,
                                                                           section_key='SUT_CONTROL_COMMANDS_STOP',
                                                                           switch='keys')
            #temp03 = self.sonata_cnf['SUT_CONTROL_COMMANDS_START']
            #self.ssh_remote_commands_vals = [value for value in self.sonata_cnf['SUT_CONTROL_COMMANDS_START'].values()]
            self.ssh_remote_commands_vals = self.__utils__.conf_key_to_arr(conf_parser=self.sonata_cnf,
                                                                           section_key='SUT_CONTROL_COMMANDS_STOP',
                                                                           switch='values')

            '''Final MAP of commands for execution over SSH on tests start'''
            self.ssh_remote_commands_conf_stop = self.__utils__.zip_to_map(to_zip01=self.ssh_remote_commands_keys,
                                                                            to_zip02=self.ssh_remote_commands_vals)

            '''SET TEST NAMES FOR AUTO LOADING OF TEST DATA FOR SPECIFIC TEST'''


            '''Final MAP of commands for execution over SSH on tests start'''
            self.sonata_tests_names = self.__utils__.conf_key_to_arr(conf_parser=self.sonata_cnf,
                                                                           section_key='SONATA_TEST_NAMES',
                                                                           switch='values')

            '''
            self.ssh_remote_keys_vals_combined = zip(self.ssh_remote_commands_keys, self.ssh_remote_commands_vals)

            self.ssh_remote_commands_conf_start = {}
            #Final ARRAY of commands for execution over SSH
            for key, val in self.ssh_remote_keys_vals_combined:
                self.ssh_remote_commands_conf_start[key]=val
            '''
            '''
            |---------------------------------------------------------------------------------------------------------------        
            '''
            '''
            SET PREFS FOR LOGGING FACILITIES OF THE TEST MODULES            
            '''
            self.logging_dir = self.sonata_cnf['LOGGING_PREFS']['BL_LOGGING_DIR']
            self.log_file = self.sonata_cnf['LOGGING_PREFS']['BL_LOG_CONF_FNAME']
            self.log_file_dir = self.sonata_cnf['LOGGING_PREFS']['BL_LOG_CONF_PATH']
            self.log_conf_full = self.sonata_cnf['LOGGING_PREFS']['BL_LOG_CONF_PATH_TOF']
            self.default_level =  self.sonata_cnf['LOGGING_PREFS']['BL_LOGGING_LEVEL']

            self.default_path = 'C:\\data_from\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\bl_frame_work\\test_bl\\test_bl_configs\\logging_conf.json'


            self.logging_tools = logging_tools.LoggingTools(self.default_path,
                                                            self.default_level,
                                                            self.logging_dir,
                                                            self.log_file,
                                                            self.log_file_dir,
                                                            self.log_conf_full
                                                            )
            '''
            |---------------------------------------------------------------------------------------------------------------        
            |    SET VARS TO DEFINE for TEST DATA RETRIEVAL       
            |---------------------------------------------------------------------------------------------------------------
            '''
            '''VARS TO DEFINE MESSAGES USED BY SENDING TOOLS AGAINST MODULES
            '''
            '''SET THE TYPE OF MESSAGES TO BE USED IN
                TESTS        
            '''
            self.messages_type = self.sonata_cnf['TEST_DATA']['BL_MESSAGES_TYPE']
            self.messages_src =  self.sonata_cnf['TEST_DATA']['BL_MESSAGES_SRC']
            self.messages_dir_json =  self.sonata_cnf['TEST_DATA']['BL_MESSAGES_PATH_JSON']
            self.messages_dir_txt = self.sonata_cnf['TEST_DATA']['BL_MESSAGES_PATH_TXT']

            '''
            Default not used.
            It is here just in case.
            '''
            self.def_mgs_location = "C:\\data_from\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\bl_frame_work\\resources\\messages.json"

            '''======================================================================================================'''
            '''
            SET params for test data transmission. MOSTLY USELESS NOW.
            '''
            self.pause_flag = bool(self.sonata_cnf['TEST_DATA']['SENDER_PAUSE_FLAG'])
            self.quit_flag = bool(self.sonata_cnf['TEST_DATA']['SENDER_STOP_FLAG'])
            self.num_msgs_to_send = int(self.sonata_cnf['TEST_DATA']['NUM_OF_MSGS'])
            self.delay_btwn_msgs = int(self.sonata_cnf['TEST_DATA']['DEL_BTWN_MSGS'])
            '''======================================================================================================'''
            '''
            VARS TO DEFINE actual SENDING/RECEIVING 
            and 
            TEST DATA CHOICES PER TEST
            '''
            '''======================================================================================================'''

            '''SET Data structures
                for storing
                and
                retrieving
                test
                data_from(input / output)
            '''
            self.rd = received_data.RecievedData()
            self.data_received = self.rd.get_received_l_all()
            '''
            SET LOCK FOR RECEIVED DATA
            '''
            self.data_received_lock = threading.RLock()
            self.data_sent = self.rd.get_sent_m_all()
            '''
            |---------------------------------------------------------------------------------------------------------------        
            '''
            ''' Set the empty storing 
                structures in everything
            '''
            self.content_proc = sonata_nmea_msgs_content_process.SonataNmeaMsgsContentProcessing(self.data_received,
                                                                                                 self.data_sent)
            '''
            |---------------------------------------------------------------------------------------------------------------        
            '''

            ''' Setup for the test suite and current test which uses this configuration
                also
                used by setting up all that pertains to sending receiving data
            '''
            self.curr_test_suite = None
            self.curr_test = None
            ''' Actual constructed messages that are out 
                to be sent  in each test case
            '''
            self.msgs_to_send = None
            '''Initially plain list was used to put messages directly'''
            '''For both sending and receiving'''
            self.messages_use_events = self.sonata_cnf.getboolean('TEST_DATA','USE_EVENTS')
            self.messages_use_queue = self.sonata_cnf.getboolean('TEST_DATA','USE_QUEUE')

            if self.messages_use_events == True and self.messages_use_queue == True:
                    self.q_support = 1
                    self.msg_sent_evnt = threading.Event()
                    self.msg_received_evnt = threading.Event()
                    self.msg_to_send_q = queue.Queue()
                    self.msg_to_receive_q = queue.Queue()
            else:
                self.q_support = 0
                self.msg_sent_evnt = None
                self.msg_received_evnt = None
                self.msg_to_send_q = None
                self.msg_to_receive_q = None



            '''======================================================================================================'''
            '''
            VARS TO DEFINE Connections PREFERENCES
            for TEST DATA SENDERS and RECEIVERS
            '''
            '''SET SENDERS'''
            self.ip_to = self.sonata_cnf['CONNECTION_PREFS']['BL_IP_TO']
            self.port_to = int(self.sonata_cnf['CONNECTION_PREFS']['BL_PORT_TO'])
            self.protocol_to = self.sonata_cnf['CONNECTION_PREFS']['BL_PROT_TO']

            '''SET RECEIVERS'''
            self.ip_on = self.sonata_cnf['CONNECTION_PREFS']['BL_IP_ON']
            self.port_on = int(self.sonata_cnf['CONNECTION_PREFS']['BL_PORT_ON'])
            self.buff_size = self.sonata_cnf['CONNECTION_PREFS']['BL_BUFFSZ_ON']
            '''Combine prefs'''
            self.listen_on = (self.ip_on, self.port_on)
            '''======================================================================================================'''
            '''
            |---------------------------------------------------------------------------------------------------------------        
            '''
            '''SETUP SENDER/RECIVER class doing all the work before TESTS start
            '''
            ''' Actual, properly constructed messages that are out 
                to be sent in each test case are configured on the sender/receiver level
                and passed as iterator to UDP sender
            '''
            self.sender_receiver = send_receive_sonata.SendReceiveSonata(self)
            #self.sender_receiver =  send_receive_sonata_threads.SendReceiveSonataTreaded()

            '''
            |---------------------------------------------------------------------------------------------------------------        
            '''
            '''
            TODO: reset                   whatever NEEDED to be reset
            '''

            '''
예제 #11
0
def test_this():
    from test_bl.test_bl_tools import logging_tools
    """
    send_receive class basic usage
    """
    lt = logging_tools.LoggingTools(
        default_path=
        "C:\\data\\kronshtadt\\QA\\BL\\AutomationFrameworkDesign\\bl_git_branching\\test_bl\\test_bl_configs\\logging_conf.json"
    )
    logger = lt.get_logger(__name__)
    sr = SendReceive(logging_tools=lt, q_based=True)

    udp_snd_01_name = sr.set_udp_sender(ip_to="10.11.10.12", port_to="55556")
    udp_srv_name = sr.set_udp_server(ip_address="10.11.10.12", port=55556)

    messages = [
        "msg01 \n", "msg02 \n", "msg03 \n", "msg04 \n", "msg05 \n", "msg06 \n",
        "msg07  \n", "msg08 \n"
    ]
    sr.udp_send_to(messages_list=messages, sender_id=udp_snd_01_name)
    sr.check_all_messages_received(messages_list=messages,
                                   server_id=udp_srv_name)

    received_q = sr.get_received_queue(udp_srv_name)
    logger.debug("--->>>num of messages in received Q == " +
                 str(received_q.qsize()))
    result = []
    while not received_q.empty():
        result.append(received_q.get())
    logging.debug("==>>>" + str(result))
    result.clear()

    messages_file = get_test_messages()
    sr.udp_send_to(messages_list=messages_file, sender_id=udp_snd_01_name)
    sr.check_all_messages_received(messages_list=messages_file,
                                   server_id=udp_srv_name)
    while not received_q.empty():
        result.append(received_q.get())
    logging.debug("==>>>" + str(result))
    result.clear()
    ''''''
    messages = [
        "msg01 \n", "msg02 \n", "msg03 \n", "msg04 \n", "msg05 \n", "msg06 \n"
    ]
    '''Put messages in ONLY'''
    sr.udp_send_to_one(messages_list=messages, sender_id=udp_snd_01_name)
    '''Send one ONLY'''
    sr.udp_send_to_one(sender_id=udp_snd_01_name)

    sr.check_all_messages_received(messages_list=["msg01 \n"],
                                   server_id=udp_srv_name)

    sr.udp_send_to_one(sender_id=udp_snd_01_name)
    sr.check_all_messages_received(messages_list=["msg02 \n"],
                                   server_id=udp_srv_name)

    sr.udp_send_to_one(sender_id=udp_snd_01_name)
    sr.check_all_messages_received(messages_list=["msg03 \n"],
                                   server_id=udp_srv_name)

    sr.udp_send_to_one(sender_id=udp_snd_01_name)
    sr.check_all_messages_received(messages_list=["msg04 \n"],
                                   server_id=udp_srv_name)

    sr.udp_send_to(messages_list=messages, sender_id=udp_snd_01_name)
    sr.check_all_messages_received(messages_list=messages,
                                   server_id=udp_srv_name)

    return