示例#1
0
def test_openapi_specs():
    openapi_path = resources.get_path(resources.RESOURCE_OPEN_API)
    with resources.stream(resources.RESOURCE_OPEN_API) as fh:
        specs = yaml.safe_load(fh)
        try:
            validate_spec(specs, spec_url=openapi_path.as_uri())
        except OpenAPIValidationError as err:
            pytest.fail(err.message)
示例#2
0
def test_openapi_specs(version):
    name = "{root}/{version}/openapi.yaml".format(
        root=resources.RESOURCE_OPENAPI_ROOT, version=version)
    openapi_path = resources.get_path(name)
    with resources.stream(name) as fh:
        specs = yaml.safe_load(fh)
        try:
            validate_spec(specs, spec_url=openapi_path.as_uri())
        except OpenAPIValidationError as err:
            pytest.fail(err.message)
示例#3
0
def setup_app() -> web.Application:
    api_spec_path = resources.get_path(resources.RESOURCE_OPEN_API)
    app = routing.create_web_app(api_spec_path.parent, api_spec_path.name)

    # NOTE: ensure client session is context is run first, then any further get_client_sesions will be correctly closed
    app.cleanup_ctx.append(persistent_client_session)

    registry_cache_task.setup(app)

    setup_app_monitoring(app, "simcore_service_director")

    setup_app_tracing(app, "simcore_service_director")

    return app
示例#4
0
def _check_services(created_services, services, schema_version="v1"):
    assert len(created_services) == len(services)

    created_service_descriptions = [x["service_description"] for x in created_services]

    json_schema_path = resources.get_path(resources.RESOURCE_NODE_SCHEMA)
    assert json_schema_path.exists() == True
    with json_schema_path.open() as file_pt:
        service_schema = json.load(file_pt)

    for service in services:
        if schema_version == "v1":
            assert created_service_descriptions.count(service) == 1
        json_schema_validator.validate_instance_object(service, service_schema)
示例#5
0
def is_service_valid(service: Dict):
    with resources.stream(resources.RESOURCE_NODE_SCHEMA) as fp:
        schema = json.load(fp)
        try:
            validate(service, schema)
            log.debug("service [%s] validated", service["key"])
            return True
        except ValidationError as exc:
            log.debug("Node validation error: %s", exc.message)
            return False
        except SchemaError:
            log.exception("Schema error:")
            raise exceptions.DirectorException(
                "Incorrect json schema used from %s" %
                (resources.get_path(resources.RESOURCE_NODE_SCHEMA)))
示例#6
0
def setup_app() -> web.Application:
    api_spec_path = resources.get_path(resources.RESOURCE_OPEN_API)
    app = routing.create_web_app(api_spec_path.parent, api_spec_path.name)

    # NOTE: ensure client session is context is run first, then any further get_client_sesions will be correctly closed
    app.cleanup_ctx.append(persistent_client_session)
    app.cleanup_ctx.append(setup_registry)

    registry_cache_task.setup(app)

    setup_app_monitoring(app, "simcore_service_director")

    # NOTE: removed tracing from director. Users old version of servicelib and
    # in any case this service will be completely replaced

    return app
示例#7
0
def test_valid_individual_json_schemas_specs(version):
    name = "{root}/{version}/schemas".format(
        root=resources.RESOURCE_OPENAPI_ROOT, version=version)
    schemas_folder_path = resources.get_path(name)

    validate_individual_schemas(Path(schemas_folder_path).rglob("*.json"))
示例#8
0
def main():
    # create web app and serve
    api_spec_path = resources.get_path(resources.RESOURCE_OPEN_API)
    app = routing.create_web_app(api_spec_path.parent, api_spec_path.name)
    web.run_app(app, port=8080)