Skip to content

Commit

Permalink
Run tests against PostgreSQL, fix compatibility (#170)
Browse files Browse the repository at this point in the history
* Make database url configurable for tests

* Add github action for postgres, probably this is the beginning of a longer try-and-error phase

* Add --command

* Add MySQL, try using services

* Enable logging

* Try different logging

* Remove that fancy fluff

* Fix comment

* Do not reset

* Who did that typo?

* Reset databases again

* Correct database env var for postgres container

* What was that

* Reduce parallelization

* Do not use BLOB

* Make sure to disconnect when migration failed

* Set mysql database again

* Correctly run tests serially

* WIP

* Fix column type

* Clean up

* Add missing trait again

* Bring back failing UNIQUE constraint

* Make previous_operations in OperationRow an Option

* Fix COALESCE type from int to text

* Make previous_operation an Option in OperationFieldsJoinedRow

* Update parse_operation_rows to account for None value previous_operations

* Don't check for exact db error strings

* Missing await

* Typo

* WIP massive test refactor making sure they get unwinded

* Enable all features for the testing runtime

* Fix ownership for tests with many cases and borrowed values

* Don't use rstest shoul_panic macro

* Make list_index INTEGER(255)

* Revert list_index type change

* Make columns Option in OperationFieldRow

* Don't check for specific error message strings

* Cast strings to numerics in get_paginated_log_entries()

* Use ON CONFLICT to avoid task duplicates

* Use COALESCE to compare nullable strings

* Use test runner in all mutation tests

* Revert removal of empty store in publish_entry test

* Refactor test which used two dbs

* Use test runner in query tests

* Use test runner for http service test

* Try different env var names for mariadb container

* Try changing port configuration for mariadb container

* Try using container label as hostname

* Roll back port changes

* Expose port properly

* Remove MySQL support, fix async runtime of sqlx

* Add entry to CHANGELOG.md

* Give null values the same representation as index

* Make fields in other rows also optional

* Last tests using old database utilities

* Clean up

* Remove unnecessary comments, just unwrap test result

* Make linters happy

* Improve formatting of long case tests

* Edit comments

* Add some more comments

Co-authored-by: Sam Andreae <contact@samandreae.com>
Co-authored-by: Vincent Ahrend <mail@vincentahrend.com>
  • Loading branch information
3 people committed Jun 27, 2022
1 parent 5a1a845 commit ab8d186
Show file tree
Hide file tree
Showing 27 changed files with 2,295 additions and 2,323 deletions.
57 changes: 54 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,58 @@ jobs:
with:
command: test
args: --manifest-path ${{ env.cargo_manifest }}
# Ensure debug output is also tested
env:
# Ensure debug output is also tested
RUST_LOG: debug

rust-test-postgres:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: aquadoggo-development
ports:
# Maps TCP port 5432 on service container to the host
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Restore from cargo cache
uses: actions/cache@v3
with:
path: ${{ env.cache_path }}
key: ${{ runner.os }}-test-${{ hashFiles('**/Cargo.lock') }}

- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
# Make sure the tests run consecutively to avoid accessing the same
# database by multiple test threads
args: >-
--manifest-path ${{ env.cargo_manifest }}
-- --test-threads 1
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/aquadoggo-development

rust-check:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -151,9 +199,12 @@ jobs:
uses: actions-rs/tarpaulin@v0.1
with:
# Force cleaning via `--force-clean` flag to prevent buggy code coverage
args: --manifest-path ${{ env.cargo_manifest }} --locked --force-clean
# Ensure debug output is also tested
args: >-
--manifest-path ${{ env.cargo_manifest }}
--locked
--force-clean
env:
# Ensure debug output is also tested
RUST_LOG: debug

- name: Upload to codecov.io
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fix high CPU usage of idle workers [#136](https://github.com/p2panda/aquadoggo/pull/136)
- Improve CI, track test coverage [#139](https://github.com/p2panda/aquadoggo/pull/139)
- Fix compatibility with PostgreSQL, change sqlx runtime to `tokio` [#170](https://github.com/p2panda/aquadoggo/pull/170)

## [0.2.0]

Expand Down
Loading

0 comments on commit ab8d186

Please sign in to comment.