def setup_module(module): global DICTIONARIES global cluster global node global dict_configs_path cluster = ClickHouseCluster(__file__) if os.path.exists(dict_configs_path): shutil.rmtree(dict_configs_path) os.mkdir(dict_configs_path) for i, field in enumerate(FIELDS): DICTIONARIES.append([]) sources = [] sources.append(SourceRedis("RedisSimple", "localhost", cluster.redis_port, cluster.redis_host, "6379", "", "clickhouse", i * 2, storage_type="simple")) sources.append(SourceRedis("RedisHash", "localhost", cluster.redis_port, cluster.redis_host, "6379", "", "clickhouse", i * 2 + 1, storage_type="hash_map")) for source in sources: for layout in LAYOUTS: if not source.compatible_with_layout(layout): print("Source", source.name, "incompatible with layout", layout.name) continue fields = KEY_FIELDS[layout.layout_type] + [field] DICTIONARIES[i].append(get_dict(source, layout, fields, field.name)) main_configs = [] dictionaries = [] for fname in os.listdir(dict_configs_path): dictionaries.append(os.path.join(dict_configs_path, fname)) node = cluster.add_instance('node', main_configs=main_configs, dictionaries=dictionaries, with_redis=True)
def generate_dict_configs(): global DICTIONARIES global cluster if os.path.exists(dict_configs_path): shutil.rmtree(dict_configs_path) os.mkdir(dict_configs_path) for i, field in enumerate(FIELDS): DICTIONARIES.append([]) sources = [] sources.append( SourceRedis( "RedisSimple", "localhost", cluster.redis_port, cluster.redis_host, "6379", "", "clickhouse", i * 2, storage_type="simple", ) ) sources.append( SourceRedis( "RedisHash", "localhost", cluster.redis_port, cluster.redis_host, "6379", "", "clickhouse", i * 2 + 1, storage_type="hash_map", ) ) for source in sources: for layout in LAYOUTS: if not source.compatible_with_layout(layout): logging.debug( f"Source {source.name} incompatible with layout {layout.name}" ) continue fields = KEY_FIELDS[layout.layout_type] + [field] DICTIONARIES[i].append(get_dict(source, layout, fields, field.name)) main_configs = [] dictionaries = [] for fname in os.listdir(dict_configs_path): path = os.path.join(dict_configs_path, fname) logging.debug(f"Found dictionary {path}") dictionaries.append(path) node = cluster.add_instance( "node", main_configs=main_configs, dictionaries=dictionaries, with_redis=True )