def __init__( self, conf_path, channel_conf_path, server_address, datasource, conf_override=None, channel_conf_override=None, ): """format of args should match what you set in conf_mamanger""" super().__init__(name="DETestWorker") self.server_address = server_address self.conf_path = conf_path self.channel_conf_path = channel_conf_path self.global_config, self.channel_config_loader = _get_de_conf_manager( conf_path, channel_conf_path, parse_program_options([])) # Override global configuration for testing self.global_config["shutdown_timeout"] = 1 self.global_config["server_address"] = self.server_address self.global_config["dataspace"]["datasource"] = datasource self.global_config["no_webserver"] = True self.de_server = _create_de_server(self.global_config, self.channel_config_loader) self.stdout_at_setup = None
def deserver_mock_data_block(mock_data_block): # noqa: F811 global_config, channel_config_handler = _get_de_conf_manager(_CONFIG_PATH, _CHANNEL_CONFIG_PATH, parse_program_options([f'--port={_port}'])) server = _create_de_server(global_config, channel_config_handler) server.start_channels() server.block_while(State.BOOT) yield server server.stop_channels()
def __init__( self, conf_path, channel_conf_path, server_address, datasource, conf_override=None, channel_conf_override=None, ): """format of args should match what you set in conf_mamanger""" super().__init__(name="DETestWorker") self.server_address = server_address self.conf_path = conf_path self.channel_conf_path = channel_conf_path self.global_config, self.channel_config_loader = _get_de_conf_manager( conf_path, channel_conf_path, parse_program_options([]) ) # Because multiple DETestWorkers can be in use concurrently, # we assign different database numbers (from 0 through 15 by # redis default) where possible to avoid kombu messaging # collisions whenever routing keys are the same. # If pytest-xdist is being used, and 16 or fewer xdist workers # are being used, we can use the number in the worker ID as # the database ID. Otherwise, we assign a random number # between 0 and 15 (inclusive). db_number = 0 xdist_worker_count = os.environ.get("PYTEST_XDIST_WORKER_COUNT") if xdist_worker_count and int(xdist_worker_count) <= 16: worker_id = os.environ["PYTEST_XDIST_WORKER"] db_number = re.sub(r"^gw(\d{1,2})", r"\1", worker_id) # Remove the gw prefix assert int(db_number) < 16 else: db_number = random.randrange(0, 16) # Override global configuration for testing self.global_config["broker_url"] = f"redis://localhost:6379/{db_number}" self.global_config["shutdown_timeout"] = 1 self.global_config["server_address"] = self.server_address self.global_config["dataspace"]["datasource"] = datasource self.global_config["no_webserver"] = False self.global_config["webserver"] = {} self.global_config["webserver"]["port"] = get_random_port() self.de_server = _create_de_server(self.global_config, self.channel_config_loader) self.stdout_at_setup = None
def __init__( self, conf_path, channel_conf_path, server_address, datasource, conf_override=None, channel_conf_override=None, ): '''format of args should match what you set in conf_mamanger''' super().__init__(name='DETestWorker') self.server_address = server_address self.global_config, self.channel_config_loader = _get_de_conf_manager( conf_path, channel_conf_path, parse_program_options([])) # Override global configuration for testing self.global_config['shutdown_timeout'] = 1 self.global_config['server_address'] = self.server_address self.global_config['dataspace']['datasource'] = datasource self.de_server = _create_de_server(self.global_config, self.channel_config_loader)
def __init__(self, conf_path, channel_conf_path, server_address, db_info, conf_override=None, channel_conf_override=None): '''format of args should match what you set in conf_mamanger''' super().__init__() self.server_address = server_address global_config, channel_config_loader = _get_de_conf_manager( conf_path, channel_conf_path, parse_program_options([])) # Override global configuration for testing global_config['shutdown_timeout'] = 1 global_config['server_address'] = self.server_address global_config['dataspace']['datasource']['config'] = db_info self.de_server = _create_de_server(global_config, channel_config_loader) self.reaper_start_delay_seconds = global_config['dataspace'].get( 'reaper_start_delay_seconds', 1818)