Beispiel #1
0
async def test_wait_for_status(api_client: APISessionClient,
                               api_test_config: APITestSessionConfig):
    async def is_deployed(resp: ClientResponse):
        if resp.status != 200:
            return False
        body = await resp.json()

        if body.get("commitId") != api_test_config.commit_id:
            return False

        backend = dict_path(body,
                            ["checks", "healthcheck", "outcome", "version"])
        if not backend:
            return True

        return backend.get("commitId") == api_test_config.commit_id

    deploy_timeout = 120 if api_test_config.api_environment.endswith(
        "sandbox") else 30

    await poll_until(
        make_request=lambda: api_client.get(
            "_status", headers={"apikey": env.status_endpoint_api_key()}),
        until=is_deployed,
        timeout=deploy_timeout,
    )
Beispiel #2
0
async def test_wait_for_status(api_client: APISessionClient,
                               api_test_config: APITestSessionConfig):
    """
        test for _status ..  this uses poll_until to wait until the correct SOURCE_COMMIT_ID ( from env var )
        is available
    """

    is_deployed = partial(_is_status_deployed, api_test_config=api_test_config)

    await poll_until(make_request=lambda: api_client.get(
        '_status', headers={'apikey': env.status_endpoint_api_key()}),
                     until=is_deployed,
                     timeout=120)
Beispiel #3
0
async def test_api_status_with_service_header(api_client: APISessionClient):

    r = await api_client.get("_status",
                             allow_retries=True,
                             max_retries=5,
                             headers={
                                 'x-apim-service': 'sync-wrap',
                                 'apikey': env.status_endpoint_api_key()
                             })
    assert r.status == 200, (r.status, r.reason, (await r.text())[:2000])
    body = await r.json()

    service = dict_path(body, ["checks", "healthcheck", "outcome", "service"])

    assert service == 'async-slowapp'
Beispiel #4
0
async def test_wait_for_status(api_client: APISessionClient, api_test_config: APITestSessionConfig):

    async def _is_complete(resp: ClientResponse):
        if resp.status != 200:
            return False
        body = await resp.json()
        version_info = body.get('_version')
        if not version_info:
            return False

        return version_info.get("commitId") == api_test_config.commit_id

    await poll_until(
        make_request=lambda: api_client.get('_status', headers={"apikey": env.status_endpoint_api_key()}),
        until=_is_complete,
        timeout=60
    )
Beispiel #5
0
async def test_api_status_with_service_header_another_service(api_client: APISessionClient):

    resp = await api_client.get("_status", allow_retries=True, max_retries=5, headers={'x-apim-service': 'another-service', "apikey": env.status_endpoint_api_key()})
    assert resp.status == 200
    body = await resp.json()

    assert body.get('service') == 'canary'