Skip to content

Commit

Permalink
Better parallel testing (#503)
Browse files Browse the repository at this point in the history
* remove serial tests, connect to random databases and buckets

* fix redis

* remove unused deps

* share postgres and redis

* sleep between lock attempts

* rename examples
  • Loading branch information
aumetra authored Mar 17, 2024
1 parent b837e3b commit 7c9e7ac
Show file tree
Hide file tree
Showing 23 changed files with 155 additions and 121 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,37 @@ jobs:
test:
name: Test
runs-on: ubuntu-latest
services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v4
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: Swatinem/rust-cache@v2
- uses: rui314/setup-mold@v1
- uses: taiki-e/install-action@nextest
- run: nix develop --impure --command bash -c "unset DATABASE_URL LD_LIBRARY_PATH REDIS_URL && cargo nextest run --all-features"
- run: nix develop --impure --command bash -c "unset LD_LIBRARY_PATH && cargo nextest run --all-features"
env:
DATABASE_URL: "postgres://postgres:postgres@localhost/test_db"
REDIS_URL: "redis://localhost"
49 changes: 4 additions & 45 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion crates/kitsune-activitypub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ kitsune-config = { path = "../kitsune-config" }
kitsune-test = { path = "../kitsune-test" }
kitsune-webfinger = { path = "../kitsune-webfinger" }
pretty_assertions = "1.4.0"
serial_test = "3.0.0"
tokio = { version = "1.36.0", features = ["macros"] }
tower = { version = "0.4.13", default-features = false, features = ["util"] }

Expand Down
3 changes: 0 additions & 3 deletions crates/kitsune-activitypub/tests/fetcher/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use std::sync::Arc;
use tower::service_fn;

#[tokio::test]
#[serial_test::serial]
async fn fetch_actor() {
database_test(|db_pool| async move {
let client = Client::builder().service(service_fn(handle));
Expand Down Expand Up @@ -63,7 +62,6 @@ async fn fetch_actor() {
}

#[tokio::test]
#[serial_test::serial]
async fn fetch_emoji() {
database_test(|db_pool| async move {
let client = Client::builder().service(service_fn(handle));
Expand Down Expand Up @@ -116,7 +114,6 @@ async fn fetch_emoji() {
}

#[tokio::test]
#[serial_test::serial]
async fn fetch_note() {
database_test(|db_pool| async move {
let client = Client::builder().service(service_fn(handle));
Expand Down
2 changes: 0 additions & 2 deletions crates/kitsune-activitypub/tests/fetcher/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use std::{convert::Infallible, sync::Arc};
use tower::service_fn;

#[tokio::test]
#[serial_test::serial]
async fn federation_allow() {
database_test(|db_pool| async move {
let builder = Fetcher::builder()
Expand Down Expand Up @@ -89,7 +88,6 @@ async fn federation_allow() {
}

#[tokio::test]
#[serial_test::serial]
async fn federation_deny() {
database_test(|db_pool| async move {
let client = service_fn(
Expand Down
1 change: 0 additions & 1 deletion crates/kitsune-activitypub/tests/fetcher/infinite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use std::{
use tower::service_fn;

#[tokio::test]
#[serial_test::serial]
async fn fetch_infinitely_long_reply_chain() {
database_test(|db_pool| async move {
let request_counter = Arc::new(AtomicU32::new(0));
Expand Down
2 changes: 0 additions & 2 deletions crates/kitsune-activitypub/tests/fetcher/origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use std::{convert::Infallible, sync::Arc};
use tower::service_fn;

#[tokio::test]
#[serial_test::serial]
async fn check_ap_id_authority() {
database_test(|db_pool| async move {
let builder = Fetcher::builder()
Expand Down Expand Up @@ -80,7 +79,6 @@ async fn check_ap_id_authority() {
}

#[tokio::test]
#[serial_test::serial]
async fn check_ap_content_type() {
database_test(|db_pool| async move {
let client = service_fn(|req: Request<_>| async {
Expand Down
2 changes: 0 additions & 2 deletions crates/kitsune-activitypub/tests/fetcher/webfinger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use std::{convert::Infallible, sync::Arc};
use tower::service_fn;

#[tokio::test]
#[serial_test::serial]
async fn fetch_actor_with_custom_acct() {
database_test(|db_pool| async move {
let mut jrd_base = include_bytes!("../../../../test-fixtures/0x0_jrd.json").to_owned();
Expand Down Expand Up @@ -80,7 +79,6 @@ async fn fetch_actor_with_custom_acct() {
}

#[tokio::test]
#[serial_test::serial]
async fn ignore_fake_webfinger_acct() {
database_test(|db_pool| async move {
let link = Link {
Expand Down
1 change: 0 additions & 1 deletion crates/kitsune-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ typed-builder = "0.18.1"

[dev-dependencies]
kitsune-test = { path = "../kitsune-test" }
serial_test = "3.0.0"
tokio = { version = "1.36.0", features = ["macros"] }

[lints]
Expand Down
2 changes: 0 additions & 2 deletions crates/kitsune-db/tests/unicode_collation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ async fn create_user(conn: &mut AsyncPgConnection, username: &str) -> Result<Use
}

#[tokio::test]
#[serial_test::serial]
async fn accounts_username() {
database_test(|db_pool| async move {
db_pool
Expand Down Expand Up @@ -95,7 +94,6 @@ async fn accounts_username() {
}

#[tokio::test]
#[serial_test::serial]
async fn users_username() {
database_test(|db_pool| async move {
db_pool
Expand Down
1 change: 0 additions & 1 deletion crates/kitsune-s3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ typed-builder = "0.18.1"

[dev-dependencies]
kitsune-test = { path = "../kitsune-test" }
serial_test = "3.0.0"
tokio = { version = "1.36.0", features = ["macros", "rt"] }

[lints]
Expand Down
2 changes: 0 additions & 2 deletions crates/kitsune-s3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ mod test {
}

#[tokio::test]
#[serial_test::serial]
async fn full_test() {
minio_test(|client| async move {
client
Expand Down Expand Up @@ -283,7 +282,6 @@ mod test {
}

#[tokio::test]
#[serial_test::serial]
async fn abort_request_works() {
minio_test(|client| async move {
let result = client
Expand Down
1 change: 0 additions & 1 deletion crates/kitsune-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ kitsune-jobs = { path = "../kitsune-jobs" }
kitsune-test = { path = "../kitsune-test" }
kitsune-webfinger = { path = "../kitsune-webfinger" }
pretty_assertions = "1.4.0"
serial_test = "3.0.0"
tempfile = "3.10.1"
tower = { version = "0.4.13", default-features = false, features = ["util"] }

Expand Down
1 change: 0 additions & 1 deletion crates/kitsune-service/src/attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ mod test {
use tower::service_fn;

#[tokio::test]
#[serial_test::serial]
async fn upload_jpeg() {
database_test(|db_pool| async move {
let client = Client::builder().service(service_fn(handle));
Expand Down
2 changes: 1 addition & 1 deletion crates/kitsune-service/src/post/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ mod test {
use tower::service_fn;

#[tokio::test]
#[serial_test::serial]
#[allow(clippy::too_many_lines)]
async fn parse_post() {
redis_test(|redis_pool| async move {
database_test(|db_pool| async move {
Expand Down
6 changes: 4 additions & 2 deletions crates/kitsune-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ license.workspace = true

[dependencies]
bytes = "1.5.0"
diesel = "2.1.5"
diesel-async = "0.4.1"
futures-util = "0.3.30"
http = "1.1.0"
Expand All @@ -18,18 +17,21 @@ kitsune-db = { path = "../kitsune-db" }
kitsune-s3 = { path = "../kitsune-s3" }
multiplex-pool = { path = "../../lib/multiplex-pool" }
pin-project-lite = "0.2.13"
rand = "0.8.5"
redis = { version = "0.25.2", default-features = false, features = [
"connection-manager",
"tokio-rustls-comp",
] }
rusty-s3 = { version = "0.5.0", default-features = false }
scoped-futures = "0.1.3"
testcontainers = { version = "0.15.0", features = ["watchdog"] }
testcontainers-modules = { version = "0.3.5", features = [
"minio",
"postgres",
"redis",
] }
tokio = { version = "1.36.0", features = ["time"] }
url = "2.5.0"
uuid = { version = "1.7.0", features = ["v4", "fast-rng"] }

[lints]
workspace = true
Loading

0 comments on commit 7c9e7ac

Please sign in to comment.