Beispiel #1
0
def cli(ctx: Context, verbose: bool, mongo_uri: str) -> None:
    """Entry point for the cli interface. It sets up the evg api instance and logging."""
    ctx.ensure_object(dict)
    ctx.obj["mongo"] = MongoWrapper.connect(mongo_uri)

    verbosity = Verbosity.DEBUG if verbose else Verbosity.INFO
    config_logging(verbosity, human_readable=False)
def cli(ctx: Context, verbose: bool, log_format: str) -> None:
    """Suite of test mapping related commands, see the commands help for more details."""
    ctx.ensure_object(dict)
    ctx.obj["evg_api"] = get_evg_api()

    verbosity = Verbosity.DEBUG if verbose else Verbosity.INFO
    config_logging(verbosity, human_readable=log_format == "text")
Beispiel #3
0
def cli(ctx: Context, verbose: bool, log_format: str) -> None:
    """Entry point for the cli interface. It sets up the evg api instance and logging."""
    ctx.ensure_object(dict)
    ctx.obj["evg_api"] = get_evg_api()

    verbosity = Verbosity.DEBUG if verbose else Verbosity.INFO
    config_logging(verbosity, human_readable=log_format == "text")
def cli(ctx: Context, verbose: bool, mongo_uri: str) -> None:
    """Suite of MongoDB related commands, see the commands help for more details."""
    ctx.ensure_object(dict)
    ctx.obj["mongo"] = MongoWrapper.connect(mongo_uri)

    verbosity = Verbosity.DEBUG if verbose else Verbosity.INFO
    config_logging(verbosity, human_readable=False)
def cli(ctx: Context, verbose: str, log_format: str, mongo_uri: str) -> None:
    """Suite of selected-tests commands, see the commands help for more details."""
    ctx.ensure_object(dict)
    ctx.obj["mongo"] = MongoWrapper.connect(mongo_uri)
    ctx.obj["evg_api"] = get_evg_api()

    verbosity = Verbosity.DEBUG if verbose else Verbosity.INFO
    config_logging(verbosity, human_readable=log_format == "text")
Beispiel #6
0
def create_app(mongo_wrapper: MongoWrapper, evg_api: EvergreenApi) -> FastAPI:
    """
    Create a selected-tests REST API.

    :param mongo_wrapper: MongoDB wrapper.
    :param evg_api: Evergreen Api.
    :return: The application.
    """
    config_logging(verbosity=Verbosity.INFO, human_readable=False)

    app = FastAPI(
        version="1.0",
        title="Selected Tests Service",
        description=
        "This service is used to predict which tests and tasks need to run based on"
        " code changes.",
        docs_url="/swagger",
        openapi_url="/swagger.json",
    )
    app.include_router(health_controller.router,
                       prefix="/health",
                       tags=["health"])
    app.include_router(
        project_task_mappings_controller.router,
        prefix="/projects/{project}/task-mappings",
        tags=["projects"],
    )
    app.include_router(
        project_test_mappings_controller.router,
        prefix="/projects/{project}/test-mappings",
        tags=["projects"],
    )
    app.state.db = mongo_wrapper
    app.state.evg_api = evg_api

    @app.exception_handler(Exception)
    async def uncaught_exception_handler(request: Request,
                                         exc: Exception) -> JSONResponse:
        """Handle all uncaught exceptions."""
        log_exception(exc)
        return JSONResponse(
            status_code=500,
            content={
                "message":
                "An unexpected exception occurred during this request"
            },
        )

    return app