def init_rabbitMQ_msg_processors(): """The main bootstrap for sspl automated tests""" # Initialize logging try: init_logging("SSPL-Tests", "DEBUG") except Exception as err: # We don't have logger since it threw an exception, use generic 'print' print("[ Error ] when initializing logging :") print(err) print("Exiting ...") exit(os.EX_USAGE) # Modules to be used for testing conf_modules = Conf.get(SSPL_TEST_CONF, f"{SSPL_SETTING}>{MODULES}") # Create a map of references to all the module's message queues. Each module # is passed this mapping so that it can send messages to other modules. msgQlist = {} # Create a mapping of all the instantiated modules to their names world.sspl_modules = {} # Read in product value from configuration file product = Conf.get(GLOBAL_CONF, f"release>{PRODUCT_NAME}") logger.info("sspl-ll Bootstrap: product name supported: %s" % product) # Use reflection to instantiate the class based upon its class name in config file for conf_thread in conf_modules: klass = globals()[conf_thread] # Create mappings of modules and their message queues world.sspl_modules[klass.name()] = klass() msgQlist[klass.name()] = queue.Queue() # Convert to a dict # TODO: Check use of this world.diskmonitor_file = json.loads("{}") try: # Loop through the list of instanced modules and start them on threads threads = [] for name, curr_module in list(world.sspl_modules.items()): logger.info("SSPL-Tests Starting %s" % curr_module.name()) curr_module._set_debug(True) thread = Thread(target=_run_thread_capture_errors, args=(curr_module, msgQlist, conf_reader, product)) thread.start() threads.append(thread) # Allow threads to startup before running tests time.sleep(2) # Clear the message queue buffer out from msgs sent at startup while not world.sspl_modules[ RabbitMQingressProcessorTests.name()]._is_my_msgQ_empty(): world.sspl_modules[ RabbitMQingressProcessorTests.name()]._read_my_msgQ() except Exception as ex: logger.exception(ex)
def __init__(self, module, start_threads=True): ''' @param module: the module to load in /etc/sspl_ll/conf @type string ''' # Initialize logging try: init_logging("sspl-ll-cli", "DEBUG") except Exception as err: # We don't have logger since it threw an exception, use generic 'print' print("[ Error ] when initializing logging :") print(err) print("Exiting ...") sys.exit(os.EX_USAGE) self.module_name = module.upper() self.confReader() # Read in the actuator schema for validating messages schema_file = os.path.join(RESOURCE_PATH + '/actuators', self.JSON_ACTUATOR_SCHEMA) self._actuator_schema = self._load_schema(schema_file) # Read in the sensor schema for validating messages schema_file = os.path.join(RESOURCE_PATH + '/sensors', self.JSON_SENSOR_SCHEMA) self._sensor_schema = self._load_schema(schema_file) self._durable = True if start_threads: # Start up threads to receive responses self._basic_consume_ackt = threading.Thread( target=self.basicConsumeAck) self._basic_consume_ackt.setDaemon(True) self._basic_consume_ackt.start() self._basic_consumet = threading.Thread(target=self.basicConsume) self._basic_consumet.setDaemon(True) self._basic_consumet.start() self._alldata = True self._indent = True self._request_uuid = None self._msg_received = False self._total_msg_received = 0 self._total_ack_msg_received = 0 self._print_data = ""
def init_rabbitMQ_msg_processors(): """The main bootstrap for sspl automated tests""" # Retrieve configuration file for sspl-ll service conf_directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) path_to_conf_file = os.path.join(conf_directory, "sspl_tests.conf") try: conf_reader = ConfigReader(is_test=True, test_config_path=path_to_conf_file) except (IOError, ConfigReader.Error) as err: # We don't have logger yet, need to find log_level from conf file first print("[ Error ] when validating the configuration file %s :" % \ path_to_conf_file) print(err) print("Exiting ...") exit(os.EX_USAGE) # Initialize logging try: init_logging("SSPL-Tests", "DEBUG") except Exception as err: # We don't have logger since it threw an exception, use generic 'print' print("[ Error ] when initializing logging :") print(err) print("Exiting ...") exit(os.EX_USAGE) # Modules to be used for testing conf_modules = conf_reader._get_value_list(SSPL_SETTING, MODULES) # Create a map of references to all the module's message queues. Each module # is passed this mapping so that it can send messages to other modules. msgQlist = {} # Create a mapping of all the instantiated modules to their names world.sspl_modules = {} # Read in product value from configuration file product = conf_reader._get_value(SYS_INFORMATION, PRODUCT_NAME) logger.info("SSPL Bootstrap: product name supported: %s" % product) # Use reflection to instantiate the class based upon its class name in config file for conf_thread in conf_modules: klass = globals()[conf_thread] # Create mappings of modules and their message queues world.sspl_modules[klass.name()] = klass() msgQlist[klass.name()] = queue.Queue() # Convert to a dict # TODO: Check use of this world.diskmonitor_file = json.loads("{}") try: # Loop through the list of instanced modules and start them on threads threads=[] for name, curr_module in list(world.sspl_modules.items()): logger.info("SSPL Tests Starting %s" % curr_module.name()) curr_module._set_debug(True) thread = Thread(target=_run_thread_capture_errors, args=(curr_module, msgQlist, conf_reader, product)) thread.start() threads.append(thread) # Allow threads to startup before running tests time.sleep(2) # Clear the message queue buffer out from msgs sent at startup while not world.sspl_modules[RabbitMQingressProcessorTests.name()]._is_my_msgQ_empty(): world.sspl_modules[RabbitMQingressProcessorTests.name()]._read_my_msgQ() except Exception as ex: logger.exception(ex)
def __init__(self): """Initialize server.""" super().__init__() logging_level = Conf.get(SSPL_CONF, f"{SYSTEM_INFORMATION}>{LOG_LEVEL}", "INFO") init_logging('resource', logging_level)
def __init__(self): super(WebServices, self).__init__() init_logging("sspl", SSPL_LOG_PATH) self.http_methods = [self.HTTP_GET, self.HTTP_POST]
def __init__(self): super(FileStore, self).__init__() self.config_parser = ConfigParser() init_logging("sspl", SSPL_LOG_PATH)
def __init__(self): """Initialize resource.""" logging_level = Conf.get(SSPL_CONF, f"{SYSTEM_INFORMATION}>{LOG_LEVEL}", "INFO") init_logging('node-health', logging_level)