Hey fauna community,
we’re currently trying to figure out how we can develop E2E tests for our app that uses a fauna database. For the tests to run in a github CI process we need a database with some basic data seeded. I’d like to know if there is someone in the community who could give us some guidance what the best approach could be. Basically he have two options:
- Create custom image with data already seeded (doesn’t seem to work)
- Use the base image fauna/faunadb and seed data on every test run (slow)
Approach 1: Create a custom image with data already seeded
This approach would be nice but does not seem to work. These were the (Dockerfile) steps for building a custom image, seed.sh would wait for fauna to be started, create the database, upload the schema and create indexes, functions and documents.
Problem here: The build never stops because there is no way to shut the faunadb down.
FROM fauna/faunadb:latest
RUN faunadb
COPY ./schema.gql schema.gql
COPY ./seed.sh seed.sh
RUN chmod +x seed.shRUN /bin/bash ./seed.sh
Approach 2: Seed the base container on every Test run
The steps on a build agent would be:
- start fauna/faunadb container with ports mapped to 8443 & 8084
- install fauna-cli
- create endpoint
- run seeding script on build agent (custom fauna cli installation)
- Question: which secret do use? ‘secret’ ?
- run E2E tests
The image would only differ in the way that we would run the seed script together with the fauna startup command:
FROM fauna/faunadb:latest
RUN faunadb
COPY ./schema.gql schema.gql
COPY ./seed.sh seed.sh
RUN chmod +x seed.shCMD /bin/bash ./seed.sh & faunadb
Problem here is that the container is always seeded for each test run. That makes the runs unnecessarily slow.
Problems with Approach 2
If you’ve read this far, then thank you!
We’re currently working on Approach 2 which does not work either (schema upload not working, but we just wanted to double-check with the community if we missed something.
This is the error
443
UPLOADING SCHEMA (mode=override): ./schema.gql
RESPONSE:
Invalid database secret.
Expected behaviour
schema can be uploaded.
This is what we did:
docker run -d --rm --name faunadb -p 8443:8443 -p 8084:8084 fauna/faunadb
fauna add-endpoint http://localhost:8443/ --alias localhost-e2e --key secret
fauna create-database MY_DATA --endpoint=localhost
fauna upload-graphql-schema ./schema.gql --mode override --secret=secret --graphqlHost localhost --graphqlPort=8084 --scheme=http --timeout 5 --domain localhost --port 8443