def client( loop, aiohttp_client, app_config, ## waits until swarm with *_services are up ): assert app_config["rest"]["version"] == API_VERSION app_config["storage"]["enabled"] = False app_config["main"]["testing"] = True app_config["db"]["init_tables"] = True # inits postgres_service pprint(app_config) # fake config app = create_safe_application() app[APP_CONFIG_KEY] = app_config pprint(app_config) setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_login(app) setup_projects(app) setup_computation(app) yield loop.run_until_complete( aiohttp_client( app, server_kwargs={ "port": app_config["main"]["port"], "host": app_config["main"]["host"], }, ))
def client( loop, aiohttp_client, app_config, ## waits until swarm with *_services are up rabbit_service: RabbitConfig, ## waits until rabbit is responsive postgres_db: sa.engine.Engine, ): assert app_config["rest"]["version"] == API_VERSION app_config["storage"]["enabled"] = False # fake config app = create_safe_application() app[APP_CONFIG_KEY] = app_config setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_login(app) setup_projects(app) setup_computation(app) setup_director_v2(app) setup_socketio(app) setup_resource_manager(app) yield loop.run_until_complete( aiohttp_client( app, server_kwargs={ "port": app_config["main"]["port"], "host": app_config["main"]["host"], }, ))
def client(loop, aiohttp_client, app_cfg, postgres_service, qx_client_outdir, monkeypatch): # def client(loop, aiohttp_client, app_cfg, qx_client_outdir, monkeypatch): # <<<< FOR DEVELOPMENT. DO NOT REMOVE. cfg = deepcopy(app_cfg) cfg["db"][ "init_tables"] = True # inits tables of postgres_service upon startup cfg["projects"]["enabled"] = True cfg["storage"]["enabled"] = False cfg["rabbit"]["enabled"] = False app = create_safe_application(cfg) setup_statics(app) setup_db(app) setup_session(app) setup_security(app) setup_rest(app) # TODO: why should we need this?? setup_login(app) setup_users(app) assert setup_projects(app), "Shall not skip this setup" assert setup_studies_access(app), "Shall not skip this setup" # server and client yield loop.run_until_complete( aiohttp_client( app, server_kwargs={ "port": cfg["main"]["port"], "host": cfg["main"]["host"] }, ))
def client(loop, aiohttp_client, aiohttp_unused_port, api_specs_dir, fake_db): app = web.Application() server_kwargs = {'port': aiohttp_unused_port(), 'host': 'localhost'} # fake config app[APP_CONFIG_KEY] = { "main": server_kwargs, "rest": { "version": "v0", "location": str(api_specs_dir / API_VERSION / "openapi.yaml") }, "db": { "enabled": False }, # inits postgres_service, "projects": { "location": str(api_specs_dir / API_VERSION / "components/schemas/project-v0.0.1.json") } } setup_db(app) setup_session(app) setup_rest(app, debug=True) setup_projects( app, enable_fake_data=False, # no fake data disable_login=True) yield loop.run_until_complete( aiohttp_client(app, server_kwargs=server_kwargs))
def client(loop, aiohttp_client, app_cfg, postgres_db, qx_client_outdir, mocks_on_projects_api): cfg = deepcopy(app_cfg) cfg["projects"]["enabled"] = True cfg["storage"]["enabled"] = False cfg["rabbit"]["enabled"] = False cfg["main"]["client_outdir"] = qx_client_outdir app = create_safe_application(cfg) setup_settings(app) setup_statics(app) setup_db(app) setup_session(app) setup_security(app) setup_rest(app) # TODO: why should we need this?? setup_login(app) setup_users(app) setup_products(app) assert setup_projects(app), "Shall not skip this setup" assert setup_studies_access(app), "Shall not skip this setup" # server and client yield loop.run_until_complete( aiohttp_client( app, server_kwargs={ "port": cfg["main"]["port"], "host": cfg["main"]["host"] }, ))
def client(loop, aiohttp_client, app_cfg, postgres_service, mock_orphaned_services): cfg = deepcopy(app_cfg) assert cfg["rest"]["version"] == API_VERSION assert cfg["rest"]["enabled"] cfg["db"]["init_tables"] = True # inits postgres_service cfg["projects"]["enabled"] = True cfg["director"]["enabled"] = True cfg[config.CONFIG_SECTION_NAME][ "garbage_collection_interval_seconds"] = GARBAGE_COLLECTOR_INTERVAL # increase speed of garbage collection # fake config app = create_safe_application(cfg) # activates only security+restAPI sub-modules setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_login(app) setup_users(app) setup_sockets(app) setup_projects(app) setup_director(app) assert setup_resource_manager(app) yield loop.run_until_complete( aiohttp_client( app, server_kwargs={ "port": cfg["main"]["port"], "host": cfg["main"]["host"] }, ))
def client( event_loop, aiohttp_client, app_cfg, postgres_db, monkeypatch_setenv_from_app_config: Callable, ): cfg = deepcopy(app_cfg) port = cfg["main"]["port"] assert cfg["rest"]["version"] == API_VERSION monkeypatch_setenv_from_app_config(cfg) # fake config app = create_safe_application(cfg) assert setup_settings(app) setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_login(app) setup_users(app) setup_groups(app) client = event_loop.run_until_complete( aiohttp_client(app, server_kwargs={ "port": port, "host": "localhost" })) return client
def client( loop, mock_orphaned_services, aiohttp_client, app_config, ## waits until swarm with *_services are up ): assert app_config["rest"]["version"] == API_VERSION app_config["main"]["testing"] = True app_config["db"]["init_tables"] = True app_config["storage"]["enabled"] = False app_config["rabbit"]["enabled"] = False pprint(app_config) app = create_safe_application(app_config) setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_login(app) setup_resource_manager(app) assert setup_projects(app) yield loop.run_until_complete( aiohttp_client( app, server_kwargs={ "port": app_config["main"]["port"], "host": app_config["main"]["host"], }, ))
def client(loop, aiohttp_client, aiohttp_unused_port, app_cfg, postgres_service): app = web.Application() port = app_cfg["main"]["port"] = aiohttp_unused_port() assert app_cfg["rest"]["version"] == API_VERSION assert API_VERSION in app_cfg["rest"]["location"] app_cfg["db"]["init_tables"] = True # inits postgres_service # fake config app[APP_CONFIG_KEY] = app_cfg setup_db(app) setup_session(app) setup_security(app) setup_rest(app, debug=True) setup_login(app) setup_users(app) client = loop.run_until_complete( aiohttp_client(app, server_kwargs={ 'port': port, 'host': 'localhost' })) return client
def client( loop, aiohttp_client, app_config, ## waits until swarm with *_services are up ): assert app_config["rest"]["version"] == API_VERSION app_config["storage"]["enabled"] = False app_config["main"]["testing"] = True # fake config app = create_safe_application(app_config) setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_login(app) setup_users(app) setup_socketio(app) setup_projects(app) setup_computation(app) setup_director_v2(app) setup_resource_manager(app) yield loop.run_until_complete( aiohttp_client( app, server_kwargs={ "port": app_config["main"]["port"], "host": app_config["main"]["host"], }, ))
def client(loop, aiohttp_client, app_config, mock_orphaned_services): app = create_safe_application(app_config) setup_session(app) setup_security(app) setup_rest(app) setup_activity(app) cli = loop.run_until_complete(aiohttp_client(app)) return cli
def client( loop: asyncio.AbstractEventLoop, aiohttp_client: Callable, app_cfg: Dict[str, Any], postgres_db: sa.engine.Engine, mock_orphaned_services, redis_client: Redis, monkeypatch_setenv_from_app_config: Callable, ) -> TestClient: cfg = deepcopy(app_cfg) assert cfg["rest"]["version"] == API_VTAG assert cfg["rest"]["enabled"] cfg["projects"]["enabled"] = True cfg["director"]["enabled"] = True # sets TTL of a resource after logout cfg["resource_manager"][ "resource_deletion_timeout_seconds"] = SERVICE_DELETION_DELAY monkeypatch_setenv_from_app_config(cfg) app = create_safe_application(cfg) # activates only security+restAPI sub-modules assert setup_settings(app) setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_login(app) setup_users(app) setup_socketio(app) setup_projects(app) setup_director(app) setup_director_v2(app) assert setup_resource_manager(app) assert is_setup_completed("simcore_service_webserver.resource_manager", app) # NOTE: garbage_collector is disabled and instead explicitly called using # garbage_collector_core.collect_garbage assert not is_setup_completed( "simcore_service_webserver.garbage_collector", app) return loop.run_until_complete( aiohttp_client( app, server_kwargs={ "port": cfg["main"]["port"], "host": cfg["main"]["host"] }, ))
def client( loop: asyncio.AbstractEventLoop, postgres_session: sa.orm.session.Session, rabbit_service: RabbitConfig, redis_service: RedisConfig, simcore_services_ready: None, aiohttp_client: Callable, app_config: Dict[str, Any], ## waits until swarm with *_services are up mocker: MockerFixture, monkeypatch_setenv_from_app_config: Callable, ) -> TestClient: cfg = deepcopy(app_config) assert cfg["rest"]["version"] == API_VTAG cfg["storage"]["enabled"] = False cfg["main"]["testing"] = True # fake config monkeypatch_setenv_from_app_config(cfg) app = create_safe_application(app_config) setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_diagnostics(app) setup_login(app) setup_users(app) setup_socketio(app) setup_projects(app) setup_computation(app) setup_director_v2(app) # GC not included in this test-suite, mocker.patch( "simcore_service_webserver.resource_manager.module_setup.setup_garbage_collector", side_effect=lambda app: print( f"PATCH @{__name__}:" "Garbage collector disabled." "Mock bypasses setup_garbage_collector to skip initializing the GC" ), ) setup_resource_manager(app) return loop.run_until_complete( aiohttp_client( app, server_kwargs={ "port": app_config["main"]["port"], "host": app_config["main"]["host"], }, ))
def client( loop, aiohttp_client, app_config, postgres_with_template_db, mock_orphaned_services, monkeypatch_setenv_from_app_config: Callable, ): cfg = deepcopy(app_config) assert cfg["rest"]["version"] == API_VERSION assert cfg["rest"]["enabled"] cfg["projects"]["enabled"] = True cfg["director"]["enabled"] = True cfg["resource_manager"].update({ "garbage_collection_interval_seconds": GARBAGE_COLLECTOR_INTERVAL, # increase speed of garbage collection "resource_deletion_timeout_seconds": SERVICE_DELETION_DELAY, # reduce deletion delay }) monkeypatch_setenv_from_app_config(cfg) app = create_safe_application(cfg) # activates only security+restAPI sub-modules assert setup_settings(app) setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_login(app) setup_users(app) setup_socketio(app) setup_projects(app) setup_director(app) setup_director_v2(app) assert setup_resource_manager(app) setup_garbage_collector(app) yield loop.run_until_complete( aiohttp_client( app, server_kwargs={ "port": cfg["main"]["port"], "host": cfg["main"]["host"] }, ))
def client( event_loop, aiohttp_client, app_cfg, postgres_db, mocked_director_v2_api, mock_orphaned_services, redis_client, monkeypatch_setenv_from_app_config: Callable, ): # config app cfg = deepcopy(app_cfg) port = cfg["main"]["port"] cfg["projects"]["enabled"] = True cfg["director"]["enabled"] = True cfg["resource_manager"][ "garbage_collection_interval_seconds" ] = DEFAULT_GARBAGE_COLLECTOR_INTERVAL_SECONDS # increase speed of garbage collection cfg["resource_manager"][ "resource_deletion_timeout_seconds" ] = DEFAULT_GARBAGE_COLLECTOR_DELETION_TIMEOUT_SECONDS # reduce deletion delay monkeypatch_setenv_from_app_config(cfg) app = create_safe_application(cfg) # setup app assert setup_settings(app) setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_login(app) # needed for login_utils fixtures setup_resource_manager(app) setup_garbage_collector(app) setup_socketio(app) setup_director(app) setup_director_v2(app) setup_tags(app) assert setup_projects(app) setup_products(app) # server and client yield event_loop.run_until_complete( aiohttp_client(app, server_kwargs={"port": port, "host": "localhost"}) )
def client( event_loop: asyncio.AbstractEventLoop, postgres_session: sa.orm.session.Session, rabbit_service: RabbitSettings, redis_settings: RedisSettings, simcore_services_ready: None, aiohttp_client: Callable, app_config: Dict[str, Any], ## waits until swarm with *_services are up mocker: MockerFixture, monkeypatch_setenv_from_app_config: Callable, ) -> TestClient: cfg = deepcopy(app_config) assert cfg["rest"]["version"] == API_VTAG cfg["storage"]["enabled"] = False cfg["main"]["testing"] = True # fake config monkeypatch_setenv_from_app_config(cfg) app = create_safe_application(app_config) assert setup_settings(app) setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_diagnostics(app) setup_login(app) setup_users(app) setup_socketio(app) setup_projects(app) setup_computation(app) setup_director_v2(app) setup_resource_manager(app) # no garbage collector return event_loop.run_until_complete( aiohttp_client( app, server_kwargs={ "port": app_config["main"]["port"], "host": app_config["main"]["host"], }, ))
def client( loop: asyncio.AbstractEventLoop, aiohttp_client: Callable, app_config: Dict[str, Any], ## waits until swarm with *_services are up rabbit_service: RabbitConfig, ## waits until rabbit is responsive and set env vars postgres_db: sa.engine.Engine, mocker: MockerFixture, monkeypatch_setenv_from_app_config: Callable, ): app_config["storage"]["enabled"] = False monkeypatch_setenv_from_app_config(app_config) app = create_safe_application(app_config) setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_diagnostics(app) setup_login(app) setup_projects(app) setup_computation(app) setup_director_v2(app) setup_socketio(app) # GC not relevant for these test-suite, mocker.patch( "simcore_service_webserver.resource_manager.module_setup.setup_garbage_collector", side_effect=lambda app: print( f"PATCH @{__name__}:" "Garbage collector disabled." "Mock bypasses setup_garbage_collector to skip initializing the GC" ), ) setup_resource_manager(app) return loop.run_until_complete( aiohttp_client( app, server_kwargs={ "port": app_config["main"]["port"], "host": app_config["main"]["host"], }, ))
def client( mock_garbage_collector_task, loop: asyncio.AbstractEventLoop, aiohttp_client: Callable, app_cfg: Dict[str, Any], postgres_db: sa.engine.Engine, mock_orphaned_services, redis_client: Redis, monkeypatch_setenv_from_app_config: Callable, ) -> TestClient: cfg = deepcopy(app_cfg) assert cfg["rest"]["version"] == API_VERSION assert cfg["rest"]["enabled"] cfg["projects"]["enabled"] = True cfg["director"]["enabled"] = True cfg[config.CONFIG_SECTION_NAME][ "garbage_collection_interval_seconds"] = GARBAGE_COLLECTOR_INTERVAL # increase speed of garbage collection # fake config monkeypatch_setenv_from_app_config(cfg) app = create_safe_application(cfg) # activates only security+restAPI sub-modules setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_login(app) setup_users(app) setup_socketio(app) setup_projects(app) setup_director(app) setup_director_v2(app) assert setup_resource_manager(app) return loop.run_until_complete( aiohttp_client( app, server_kwargs={ "port": cfg["main"]["port"], "host": cfg["main"]["host"] }, ))
def client( loop, aiohttp_client, app_config, mock_orphaned_services, monkeypatch_setenv_from_app_config: Callable, ): monkeypatch_setenv_from_app_config(app_config) app = create_safe_application(app_config) setup_session(app) setup_security(app) setup_rest(app) setup_activity(app) cli = loop.run_until_complete(aiohttp_client(app)) return cli
def client( loop, aiohttp_client, app_cfg, postgres_service, mocked_director_subsystem, mock_orphaned_services, ): # def client(loop, aiohttp_client, app_cfg): # <<<< FOR DEVELOPMENT. DO NOT REMOVE. # config app cfg = deepcopy(app_cfg) port = cfg["main"]["port"] cfg["db"]["init_tables"] = True # inits tables of postgres_service upon startup cfg["projects"]["enabled"] = True cfg["director"]["enabled"] = True cfg["resource_manager"][ "garbage_collection_interval_seconds" ] = 3 # increase speed of garbage collection cfg["resource_manager"][ "resource_deletion_timeout_seconds" ] = 3 # reduce deletion delay app = create_safe_application(cfg) # setup app setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_login(app) # needed for login_utils fixtures setup_resource_manager(app) setup_sockets(app) setup_director(app) setup_tags(app) assert setup_projects(app) # server and client yield loop.run_until_complete( aiohttp_client(app, server_kwargs={"port": port, "host": "localhost"}) )
def client( loop, mock_orphaned_services, aiohttp_client, app_config, # waits until swarm with *_services are up monkeypatch_setenv_from_app_config: Callable, ): assert app_config["rest"]["version"] == API_VERSION app_config["main"]["testing"] = True app_config["storage"]["enabled"] = False app_config["computation"]["enabled"] = False monkeypatch_setenv_from_app_config(app_config) app = create_safe_application(app_config) assert setup_settings(app) setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_login(app) setup_resource_manager(app) setup_garbage_collector(app) assert setup_projects(app) setup_catalog(app) setup_products(app) setup_director_v2(app) yield loop.run_until_complete( aiohttp_client( app, server_kwargs={ "port": app_config["main"]["port"], "host": app_config["main"]["host"], }, ) )
def client( event_loop: asyncio.AbstractEventLoop, aiohttp_client: Callable, app_config: Dict[str, Any], ## waits until swarm with *_services are up rabbit_service: RabbitSettings, ## waits until rabbit is responsive and set env vars postgres_db: sa.engine.Engine, mocker: MockerFixture, monkeypatch_setenv_from_app_config: Callable, ): app_config["storage"]["enabled"] = False monkeypatch_setenv_from_app_config(app_config) app = create_safe_application(app_config) assert setup_settings(app) assert app[APP_SETTINGS_KEY].WEBSERVER_COMPUTATION setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_diagnostics(app) setup_login(app) setup_projects(app) setup_computation(app) setup_director_v2(app) setup_socketio(app) setup_resource_manager(app) # GC not relevant for these test-suite, return event_loop.run_until_complete( aiohttp_client( app, server_kwargs={ "port": app_config["main"]["port"], "host": app_config["main"]["host"], }, ) )
def client(loop, aiohttp_client, app_cfg, postgres_service): cfg = deepcopy(app_cfg) port = cfg["main"]["port"] assert cfg["rest"]["version"] == API_VERSION cfg["db"]["init_tables"] = True # inits postgres_service # fake config app = create_safe_application(cfg) setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_login(app) setup_users(app) client = loop.run_until_complete( aiohttp_client(app, server_kwargs={"port": port, "host": "localhost"}) ) return client
def client( loop, aiohttp_client, app_config, ## waits until swarm with *_services are up rabbit_config: Config, rabbit_service, ## waits until rabbit is responsive ): assert app_config["rest"]["version"] == API_VERSION app_config["storage"]["enabled"] = False app_config["db"]["init_tables"] = True # inits postgres_service app_config[CONFIG_SECTION_NAME] = rabbit_config.dict() # fake config app = create_safe_application() app[APP_CONFIG_KEY] = app_config setup_db(app) setup_session(app) setup_security(app) setup_rest(app) setup_login(app) setup_projects(app) setup_computation(app) setup_sockets(app) setup_resource_manager(app) yield loop.run_until_complete( aiohttp_client( app, server_kwargs={ "port": app_config["main"]["port"], "host": app_config["main"]["host"], }, ) )
def webserver_service(loop, docker_stack, aiohttp_server, aiohttp_unused_port, api_specs_dir, app_config): port = app_config["main"]["port"] = aiohttp_unused_port() app_config['main']['host'] = '127.0.0.1' assert app_config["rest"]["version"] == API_VERSION assert API_VERSION in app_config["rest"]["location"] app_config['storage']['enabled'] = False app_config['rabbit']['enabled'] = False app = web.Application() app[APP_CONFIG_KEY] = app_config setup_db(app) setup_session(app) setup_security(app) setup_rest(app, debug=True) setup_login(app) setup_projects( app, enable_fake_data=False, # no fake data disable_login=False) yield loop.run_until_complete(aiohttp_server(app, port=port))