Skip to content

Commit

Permalink
Initial work to support streams (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
marrony authored Mar 14, 2024
1 parent f6d5f23 commit 6d0d365
Show file tree
Hide file tree
Showing 19 changed files with 791 additions and 229 deletions.
31 changes: 5 additions & 26 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,27 @@ jobs:
- "3.11"
- "3.10"
- "3.9"
fauna-docker-service:
- name: "fauna/faunadb:latest"
host: "core"
port: "8443"
# if we had a nightly image, we could run the testsuite against it by uncommented this
# - name: "fauna/faunadb:nightly"
# host: "localhost"
# port: "8443"

timeout-minutes: 5
runs-on: ubuntu-latest

container:
image: python:${{ matrix.python-version}}

services:
core:
image: ${{ matrix.fauna-docker-service.name }}

steps:
- uses: actions/checkout@v3

- name: Show file descriptor limit
run: ulimit -a

- name: "Install ci dependencies"
run: pip install . .[test] .[lint] --use-pep517
- name: Build docker
run: docker-compose -f docker/docker-compose.yml build --build-arg BASE_IMG=python:${{ matrix.python-version }} --no-cache

- name: Run unit tests
run: pytest -v --cov=fauna --cov-context=test tests/unit
run: docker-compose -f docker/docker-compose.yml run --rm unit-test

- name: Run integration tests
run: pytest -v --cov=fauna --cov-context=test tests/integration
# To get more insight into tests which are only flaky when run in github actions -- use commands like below
# run: env HTTPX_LOG_LEVEL=trace pytest --capture=no -v --cov=fauna --cov-context=test -k test_stream_max_open_streams
env:
FAUNA_ENDPOINT: "http://${{ matrix.fauna-docker-service.host }}:${{ matrix.fauna-docker-service.port }}"
FAUNA_ROOT_KEY: secret
USE_GITHUB_ACTION_OVERRIDES: 1
run: docker-compose -f docker/docker-compose.yml run --rm integration-test

- name: Generate coverage html report with dynamic contexts
run: coverage html --show-contexts
run: docker-compose -f docker/docker-compose.yml run --rm coverage

- uses: actions/upload-artifact@v3
with:
Expand Down
10 changes: 10 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ARG BASE_IMG=?

FROM $BASE_IMG

WORKDIR /fauna-python
VOLUME /fauna-python

COPY . /fauna-python/

RUN cd /fauna-python && pip install . .[test] .[lint] --use-pep517
38 changes: 38 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: "3"

services:
db:
image: fauna/faunadb:latest
ports:
- "8443:8443"
volumes:
- ../docker/feature-flags.json:/etc/feature-flag-periodic.d/feature-flags.json
test:
image: fauna-python-test:latest
build:
context: ../
dockerfile: docker/Dockerfile
integration-test:
image: fauna-python-test:latest
volumes:
- ..:/fauna-python
command:
- /bin/bash
- -cx
- |
while ! curl -s --fail -m 1 http://db:8443/ping 2>&1; do sleep 3; done
pytest -v --cov=fauna --cov-context=test tests/integration
environment:
- FAUNA_ENDPOINT=http://db:8443
depends_on:
- db
unit-test:
image: fauna-python-test:latest
volumes:
- ..:/fauna-python
command: pytest -v --cov=fauna --cov-context=test tests/unit
coverage:
image: fauna-python-test:latest
volumes:
- ..:/fauna-python
command: coverage html --show-contexts
27 changes: 27 additions & 0 deletions docker/feature-flags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"version": 1,
"properties": [
{
"property_name": "cluster_name",
"property_value": "fauna",
"flags": {
"fql2_schema": true,
"fqlx_typecheck_default": true,
"persisted_fields": true,
"changes_by_collection_index": true,
"fql2_streams": true
}
},
{
"property_name": "account_id",
"property_value": 0,
"flags": {
"fql2_schema": true,
"fqlx_typecheck_default": true,
"persisted_fields": true,
"changes_by_collection_index": true,
"fql2_streams": true
}
}
]
}
2 changes: 1 addition & 1 deletion fauna/client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .client import Client, QueryOptions
from .client import Client, QueryOptions, StreamOptions
from .endpoints import Endpoints
from .headers import Header
Loading

0 comments on commit 6d0d365

Please sign in to comment.