Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into use-poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamalama committed Apr 6, 2023
2 parents 6108cf3 + 0950d62 commit e20df57
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 74 deletions.
4 changes: 2 additions & 2 deletions IntegrationTests.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11.2-slim as build
FROM python:3.11.3-slim as build

ENV PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
Expand All @@ -17,7 +17,7 @@ WORKDIR /opt
COPY pyproject.toml poetry.lock ./
RUN $POETRY_HOME/bin/poetry install --only integration-tests --no-root

FROM python:3.11.2-slim
FROM python:3.11.3-slim
ENV PATH="/opt/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
VIRTUAL_ENV=/opt/.venv \
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ Note that the tests assume that the server has the ``attachments``,
have the ``email`` plugin installed.

To have the tests bootstrap themselves (i.e. when ``SKIP_SERVER_SETUP=false``),
the credentials passed in ``SETUP_AUTH`` should have the permission to create
the credentials passed in ``SETUP_AUTH`` should have the permission to create
users, buckets, and collections. These credentials will be in the form
``SETUP_AUTH=username:password`` or ``SETUP_AUTH="Bearer some_token"``

If the tests should not bootstrap themselves and instead use resources already
available on the server (i.e. when ``SKIP_SERVER_SETUP=true``):

- There should be a bucket and collection available

- the bucket, if not specified by the ``BUCKET`` config option, should be named ``main-workspace``
- the collection, if not specified by the ``COLLECTION`` config option, should be named ``product-integrity``

Expand All @@ -138,7 +138,7 @@ Running integration tests on the Remote Settings DEV server should look somethin
.. code-block:: shell
docker run --rm \
--env SERVER=https://settings.dev.mozaws.net/v1 \
--env SERVER=https://remote-settings-dev.allizom.org/v1 \
--env MAIL_DIR="" `#disables test cases related to emails` \
--env SKIP_SERVER_SETUP=true \
--env TO_REVIEW_ENABLED=false \
Expand Down
4 changes: 2 additions & 2 deletions RemoteSettings.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11.2 as compile
FROM python:3.11.3 as compile

ENV PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
Expand Down Expand Up @@ -27,7 +27,7 @@ COPY ./kinto-remote-settings ./kinto-remote-settings
COPY VERSION .
RUN pip install ./kinto-remote-settings

FROM python:3.11.2-slim as production
FROM python:3.11.3-slim as production

ENV KINTO_INI=config/local.ini \
PATH="/opt/.venv/bin:$PATH" \
Expand Down
28 changes: 14 additions & 14 deletions docs/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ Check out the :ref:`screencast to create, request review and approve changes <sc
Environments
------------

+--------------+---------------------------------------+----------------------------------------------+---------------------------------------------+
| | DEV | STAGE | PROD |
+==============+=======================================+==============================================+=============================================+
| Base URL | https://settings.dev.mozaws.net/v1/ | https://settings-writer.stage.mozaws.net/v1/ | https://settings-writer.prod.mozaws.net/v1/ |
+--------------+---------------------------------------+----------------------------------------------+---------------------------------------------+
| Main purpose | Try out API and new use-cases | QA data changes | Deliver data within minutes |
+--------------+---------------------------------------+----------------------------------------------+---------------------------------------------+
| Deployed on | pull-request merges | tagged versions | approvals |
+--------------+---------------------------------------+----------------------------------------------+---------------------------------------------+
| Access | Public via LDAP Auth | VPN via LDAP groups | VPN via LDAP groups |
+--------------+---------------------------------------+----------------------------------------------+---------------------------------------------+
| Permissions | - Create collections, groups, records | - CRUD records | - CRUD records |
| | - Approve own changes | - Approve other's changes | - Approve other's changes |
+--------------+---------------------------------------+----------------------------------------------+---------------------------------------------+
+--------------+---------------------------------------------+----------------------------------------------+---------------------------------------------+
| | DEV | STAGE | PROD |
+==============+=============================================+==============================================+=============================================+
| Base URL | https://remote-settings-dev.allizom.org/v1/ | https://settings-writer.stage.mozaws.net/v1/ | https://settings-writer.prod.mozaws.net/v1/ |
+--------------+---------------------------------------------+----------------------------------------------+---------------------------------------------+
| Main purpose | Try out API and new use-cases | QA data changes | Deliver data within minutes |
+--------------+---------------------------------------------+----------------------------------------------+---------------------------------------------+
| Deployed on | pull-request merges | tagged versions | approvals |
+--------------+---------------------------------------------+----------------------------------------------+---------------------------------------------+
| Access | Public via LDAP Auth | VPN via LDAP groups | VPN via LDAP groups |
+--------------+---------------------------------------------+----------------------------------------------+---------------------------------------------+
| Permissions | - Create collections, groups, records | - CRUD records | - CRUD records |
| | - Approve own changes | - Approve other's changes | - Approve other's changes |
+--------------+---------------------------------------------+----------------------------------------------+---------------------------------------------+


.. note::
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorial-dev-server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Until `Bug 1630651 <https://bugzilla.mozilla.org/show_bug.cgi?id=1630651>`_ happ

.. code-block:: bash
SERVER=https://settings.dev.mozaws.net/v1
SERVER=https://remote-settings-dev.allizom.org/v1
BEARER_TOKEN="Bearer uLdb-Yafefe....2Hyl5_w"
curl -s ${SERVER}/ -H "Authorization:${BEARER_TOKEN}" | jq .user
Expand Down Expand Up @@ -124,7 +124,7 @@ Until `support for the DEV environment <https://github.com/mozilla-extensions/re
.. code-block:: javascript
Services.prefs.setCharPref("services.settings.loglevel", "debug");
Services.prefs.setCharPref("services.settings.server", "https://settings.dev.mozaws.net/v1");
Services.prefs.setCharPref("services.settings.server", "https://remote-settings-dev.allizom.org/v1");
// Dev collections are signed with the STAGE infrastructure, use STAGE's hash:
Services.prefs.setCharPref("security.content.signature.root_hash", "3C:01:44:6A:BE:90:36:CE:A9:A0:9A:CA:A3:A5:20:AC:62:8F:20:A7:AE:32:CE:86:1C:B2:EF:B7:0F:A0:C7:45");
// Prevent packaged dumps to interfere.
Expand Down Expand Up @@ -186,4 +186,4 @@ Delete your collection
curl -X DELETE ${SERVER}/buckets/main/collections/${CID} -H "Authorization:${BEARER_TOKEN}"
.. _Admin UI: https://settings.dev.mozaws.net/v1/admin/
.. _Admin UI: https://remote-settings-dev.allizom.org/v1/admin/
60 changes: 30 additions & 30 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ uwsgi = "2.0.21"
kinto-remote-settings = {path = "./kinto-remote-settings", develop = true}

[tool.poetry.group.dev.dependencies]
black = "23.1.0"
black = "23.3.0"
flake8 = "6.0.0"
isort = "5.12.0"
pytest = "6.2.5"
Expand All @@ -76,7 +76,7 @@ aiohttp = "3.8.4"
autograph-utils = "0.1.1"
canonicaljson-rs = "0.5.0"
httpie = "3.2.1"
kinto-http = "11.0.0"
kinto-http = "11.0.1"
pytest = "6.2.5"
pytest-asyncio = "0.20.3"
pytest-selenium = "4.0.0"
Expand Down
28 changes: 23 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import asyncio
import os
import random
from typing import Callable, Tuple

import pytest
Expand All @@ -12,6 +14,22 @@
from urllib3.util.retry import Retry


class RemoteSettingsAsyncClient(AsyncClient):
async def fetch_changeset(self, **kwargs) -> list[dict]:
"""
Fetch from `/changeset` endpoint introduced by the kinto-remote-settings plugin.
"""
bucket = self.bucket_name
collection = self.collection_name
endpoint = f"/buckets/{bucket}/collections/{collection}/changeset"
kwargs.setdefault("_expected", random.randint(999999000000, 999999999999))
loop = asyncio.get_event_loop()
body, _ = await loop.run_in_executor(
None, lambda: self._client.session.request("get", endpoint, params=kwargs)
)
return body


def asbool(s):
return s.strip().lower() in ("true", "yes", "on", "1")

Expand All @@ -28,7 +46,7 @@ def asbool(s):
DEFAULT_TO_REVIEW_ENABLED = asbool(os.getenv("TO_REVIEW_ENABLED", "true"))

Auth = Tuple[str, str]
ClientFactory = Callable[[Auth], AsyncClient]
ClientFactory = Callable[[Auth], RemoteSettingsAsyncClient]


def pytest_addoption(parser):
Expand Down Expand Up @@ -154,18 +172,18 @@ def to_review_enabled(request) -> bool:
def make_client(
server: str, source_bucket: str, source_collection: str, skip_server_setup: bool
) -> ClientFactory:
"""Factory as fixture for creating a Kinto AsyncClient used for tests.
"""Factory as fixture for creating a RemoteSettings AsyncClient used for tests.
Args:
server (str): Kinto server (in form 'http(s)://<host>:<port>/v1')
source_bucket (str): Source bucket
source_collection (str): Source collection
Returns:
AsyncClient: AsyncClient
RemoteSettingsAsyncClient: RemoteSettingsAsyncClient
"""

def _make_client(auth: Auth) -> AsyncClient:
def _make_client(auth: Auth) -> RemoteSettingsAsyncClient:
request_session = requests.Session()
retries = Retry(
total=5, backoff_factor=0.1, status_forcelist=[500, 502, 503, 504]
Expand All @@ -177,7 +195,7 @@ def _make_client(auth: Auth) -> AsyncClient:
if not skip_server_setup and auth:
create_user(request_session, server, auth)

return AsyncClient(
return RemoteSettingsAsyncClient(
server_url=server,
auth=auth,
bucket=source_bucket,
Expand Down
Loading

0 comments on commit e20df57

Please sign in to comment.