Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
1443731
draft: using db-pool form a 2021 branch
momentary-lapse Jul 4, 2025
55d010d
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Jul 11, 2025
91613fb
fix
momentary-lapse Jul 11, 2025
618f635
some renaming
momentary-lapse Jul 11, 2025
ef155c5
reusable pool integrated except everywhere, some tests adapted
momentary-lapse Jul 14, 2025
f949aea
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Jul 14, 2025
6b13d21
generic pool in context and stat modules, now it compiles
momentary-lapse Jul 15, 2025
8528a7f
Merge branch 'main' into parallel-db-tests
momentary-lapse Jul 15, 2025
e90c8be
fix taplo
momentary-lapse Jul 16, 2025
5d6fe0c
clippy fix
momentary-lapse Jul 16, 2025
906c36a
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Jul 19, 2025
418e91b
clippy fix
momentary-lapse Jul 19, 2025
fe3305b
fmt fix
momentary-lapse Jul 20, 2025
a95ad45
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Jul 23, 2025
4377da8
shear fix
momentary-lapse Jul 23, 2025
e18c7f7
clippy + shear fixes
momentary-lapse Jul 23, 2025
5264ab1
fmt fix
momentary-lapse Jul 23, 2025
9db404d
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Jul 27, 2025
6e795ea
fix merge issues
momentary-lapse Jul 27, 2025
603efb3
config forrunning new tests locally
momentary-lapse Jul 27, 2025
0d59fcf
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Aug 7, 2025
1fbe5f4
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Aug 11, 2025
64bc9e6
removing the rest of serial tests
momentary-lapse Aug 12, 2025
6534cbc
fmt
momentary-lapse Aug 12, 2025
12037df
excluding serial_test dep
momentary-lapse Aug 12, 2025
b8c2836
fix
momentary-lapse Aug 13, 2025
aadfcca
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Aug 15, 2025
99f4f03
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Aug 24, 2025
2b1776b
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Sep 13, 2025
3abdada
add tokio-shared-rt library
momentary-lapse Oct 13, 2025
7457486
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Oct 13, 2025
355e6fe
updated lock
momentary-lapse Oct 13, 2025
f936ec3
removing serial
momentary-lapse Oct 14, 2025
9ab549a
post crate changes partial
momentary-lapse Oct 14, 2025
5f00b50
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Nov 3, 2025
5ba2328
merge fixes
momentary-lapse Nov 3, 2025
8f9d819
full access to r schema in tests
momentary-lapse Nov 3, 2025
738c71c
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Nov 15, 2025
1d3c3d8
made it compile
momentary-lapse Nov 15, 2025
35ac090
using db-pool version with superuser test user
momentary-lapse Nov 16, 2025
7e92da6
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Dec 6, 2025
5d52b36
PrivilegedPostgresConfig adapted to conn string containing options
momentary-lapse Dec 9, 2025
59dbc62
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Dec 15, 2025
3d469ef
tests are compiling
momentary-lapse Dec 15, 2025
7984f6d
shared runtime in tests
momentary-lapse Dec 15, 2025
f912ecf
prettier fix
momentary-lapse Dec 15, 2025
20e9b46
linter fixes
momentary-lapse Dec 15, 2025
c4ad852
removing empty file
momentary-lapse Dec 15, 2025
c7f9151
fixing tests
momentary-lapse Dec 15, 2025
90c6152
ignoring tokio to satisfy shear
momentary-lapse Dec 15, 2025
a847d44
taplo fix
momentary-lapse Dec 15, 2025
4be9c32
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Jan 1, 2026
75d5671
fixing tests and tomls
momentary-lapse Jan 1, 2026
ec18a6b
fixing lemmy_db_views_post tests
momentary-lapse Jan 2, 2026
d5b3fd5
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Jan 12, 2026
ae6ac4b
fix test
momentary-lapse Jan 12, 2026
c26ab70
some more fixes
momentary-lapse Jan 12, 2026
b9d1b18
Merge branch 'main' of github.com:LemmyNet/lemmy into parallel-db-tests
momentary-lapse Jan 24, 2026
4abcc9d
using improved db-pool config accepting a connection string
momentary-lapse Jan 24, 2026
d977c4e
Merge branch 'main' of https://github.com/LemmyNet/lemmy into paralle…
momentary-lapse Feb 11, 2026
1c1433a
Cargo lock changed
momentary-lapse Mar 1, 2026
290f64f
Merge branch 'main' of https://github.com/LemmyNet/lemmy into paralle…
momentary-lapse Mar 1, 2026
bc61f54
fixes for submodule
Mar 1, 2026
7824a91
test fix
Mar 1, 2026
9006d18
fmt fix
Mar 1, 2026
a011e9f
fix compilation
Mar 8, 2026
909c7b9
failed tests ignored
Mar 8, 2026
bfd799a
Merge branch 'main' of https://github.com/LemmyNet/lemmy into paralle…
Mar 8, 2026
21156df
removing serial in new tests
Mar 8, 2026
94ed7b2
removing empty file
Mar 8, 2026
0b4676f
removing empty file
Mar 8, 2026
b172cdb
adding multi-thread flavor
Mar 8, 2026
eba169d
db-pool upd
Mar 8, 2026
9fd3d24
Revert "db-pool upd"
Mar 8, 2026
e037df5
fix pool sizes
Mar 9, 2026
a5d4d96
Merge branch 'main' of https://github.com/LemmyNet/lemmy into paralle…
Mar 9, 2026
923177b
db-pool doesn't throw errors on cleanup
Mar 9, 2026
0230818
use serial for workers which share the same port
Mar 10, 2026
73aad3e
removing ignore
Mar 10, 2026
3b187a8
removing ignore
Mar 10, 2026
dc3c087
clippy and fmt fixes
Mar 10, 2026
9c00d0a
Merge branch 'main' of https://github.com/LemmyNet/lemmy into paralle…
Mar 31, 2026
5dfa1df
db-pool dependency library supports diesel-async 0.8.0
Mar 31, 2026
1bcd4ff
test fixes
Mar 31, 2026
28d869e
Merge branch 'main' of https://github.com/LemmyNet/lemmy into paralle…
Apr 6, 2026
46f2d66
fmt fix
Apr 6, 2026
fabeac1
Merge branch 'main' of https://github.com/LemmyNet/lemmy into paralle…
Apr 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ lemmy_db_views_vote = { version = "=1.0.0-alpha.5", path = "./crates/db_views/vo
activitypub_federation = { version = "0.7.0-beta.5", default-features = false, features = [
"actix-web",
] }
diesel = { version = "2.2.10", features = [
diesel = { version = "2.2.11", features = [
"chrono",
"postgres",
"serde_json",
Expand Down
22 changes: 16 additions & 6 deletions crates/api/api_utils/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ use lemmy_utils::{
};
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
use std::sync::Arc;
use lemmy_db_schema::utils::ReusableDbPool;

#[derive(Clone)]
pub enum ContextPool {
Actual(ActualDbPool),
Reusable(ReusableDbPool), // TODO it's not cloneable
}

#[derive(Clone)]
pub struct LemmyContext {
pool: ActualDbPool,
pool: ContextPool,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the moment which currently blocks me, and i think it's better to consult with you again. LemmyContext structure must be cloneable, therefore all the fields, therefore the pool. But unfortunately, reusable pool from db-pool crate is not, and i don't have access to its fields to implement the trait here.
But before asking db-pool developer, i'd like to be sure we really need this pool cloning stuff, especially for the tests. Cloning the pool seems a bit strange to me, but i may miss something. I'm looking at the code now, but maybe you folks already have some insights on this

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap it in Arc for now.

client: Arc<ClientWithMiddleware>,
/// Pictrs requests must bypass proxy. Unfortunately no_proxy can only be set on ClientBuilder
/// and not on RequestBuilder, so we need a separate client here.
Expand All @@ -24,7 +31,7 @@ pub struct LemmyContext {

impl LemmyContext {
pub fn create(
pool: ActualDbPool,
pool: ContextPool,
client: ClientWithMiddleware,
pictrs_client: ClientWithMiddleware,
secret: Secret,
Expand All @@ -39,9 +46,12 @@ impl LemmyContext {
}
}
pub fn pool(&self) -> DbPool<'_> {
DbPool::Pool(&self.pool)
match &self.pool {
ContextPool::Actual(pool) => DbPool::Pool(pool),
ContextPool::Reusable(pool) => DbPool::ReusablePool(pool),
}
}
pub fn inner_pool(&self) -> &ActualDbPool {
pub fn inner_pool(&self) -> &ContextPool {
&self.pool
}
pub fn client(&self) -> &ClientWithMiddleware {
Expand All @@ -66,7 +76,7 @@ impl LemmyContext {
#[allow(clippy::expect_used)]
pub async fn init_test_federation_config() -> FederationConfig<LemmyContext> {
// call this to run migrations
let pool = build_db_pool_for_tests();
let pool = build_db_pool_for_tests().await;

let client = client_builder(&SETTINGS).build().expect("build client");

Expand All @@ -79,7 +89,7 @@ impl LemmyContext {
let rate_limit_cell = RateLimit::with_test_config();

let context = LemmyContext::create(
pool,
ContextPool::Reusable(pool),
client.clone(),
client,
secret,
Expand Down
2 changes: 2 additions & 0 deletions crates/db_schema/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ diesel-derive-newtype = { workspace = true, optional = true }
diesel-async = { workspace = true, features = [
"deadpool",
"postgres",
"async-connection-wrapper",
], optional = true }
regex = { workspace = true, optional = true }
diesel_ltree = { workspace = true, optional = true }
Expand All @@ -75,6 +76,7 @@ i-love-jesus = { workspace = true, optional = true }
derive-new.workspace = true
tuplex = { workspace = true, optional = true }
moka = { workspace = true, optional = true }
db-pool = { git = "https://github.com/momentary-lapse/db-pool.git", branch = "edition2021-test", features = ["diesel-async-postgres", "diesel-async-deadpool"] }


[dev-dependencies]
Expand Down
6 changes: 2 additions & 4 deletions crates/db_schema/src/impls/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ mod tests {
use url::Url;

#[tokio::test]
#[serial]
async fn receive_activity_duplicate() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();
let ap_id: DbUrl = Url::parse("http://example.com/activity/531")?.into();

Expand All @@ -86,9 +85,8 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn sent_activity_write_read() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();
let ap_id: DbUrl = Url::parse("http://example.com/activity/412")?.into();
let data = json!({
Expand Down
18 changes: 6 additions & 12 deletions crates/db_schema/src/impls/actor_language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,8 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn test_convert_update_languages() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();

// call with empty vec, returns all languages
Expand All @@ -445,10 +444,9 @@ mod tests {
Ok(())
}
#[tokio::test]
#[serial]
async fn test_convert_read_languages() -> LemmyResult<()> {
use lemmy_db_schema_file::schema::language::dsl::{id, language};
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();

// call with all languages, returns empty vec
Expand All @@ -466,9 +464,8 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn test_site_languages() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();

let data = TestData::create(pool).await?;
Expand All @@ -489,9 +486,8 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn test_user_languages() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();

let data = TestData::create(pool).await?;
Expand Down Expand Up @@ -521,9 +517,8 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn test_community_languages() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();
let data = TestData::create(pool).await?;
let test_langs = test_langs1(pool).await?;
Expand Down Expand Up @@ -576,9 +571,8 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn test_validate_post_language() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();
let data = TestData::create(pool).await?;
let test_langs = test_langs1(pool).await?;
Expand Down
6 changes: 2 additions & 4 deletions crates/db_schema/src/impls/captcha_answer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ mod tests {
use serial_test::serial;

#[tokio::test]
#[serial]
async fn test_captcha_happy_path() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();

let inserted = CaptchaAnswer::insert(
Expand All @@ -81,9 +80,8 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn test_captcha_repeat_answer_fails() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();

let inserted = CaptchaAnswer::insert(
Expand Down
6 changes: 2 additions & 4 deletions crates/db_schema/src/impls/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,8 @@ mod tests {
use url::Url;

#[tokio::test]
#[serial]
async fn test_crud() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();

let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?;
Expand Down Expand Up @@ -507,9 +506,8 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn test_aggregates() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();

let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?;
Expand Down
6 changes: 2 additions & 4 deletions crates/db_schema/src/impls/community.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,9 +703,8 @@ mod tests {
use serial_test::serial;

#[tokio::test]
#[serial]
async fn test_crud() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();

let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?;
Expand Down Expand Up @@ -864,9 +863,8 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn test_aggregates() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();

let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?;
Expand Down
3 changes: 1 addition & 2 deletions crates/db_schema/src/impls/federation_allowlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ mod tests {
use serial_test::serial;

#[tokio::test]
#[serial]
async fn test_allowlist_insert_and_clear() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();
let instances = vec![
Instance::read_or_create(pool, "tld1.xyz".to_string()).await?,
Expand Down
3 changes: 1 addition & 2 deletions crates/db_schema/src/impls/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ mod tests {
use serial_test::serial;

#[tokio::test]
#[serial]
async fn test_languages() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();

let all = Language::read_all(pool).await?;
Expand Down
6 changes: 2 additions & 4 deletions crates/db_schema/src/impls/local_site.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn test_aggregates() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();

let (data, inserted_person, inserted_community) = prepare_site_with_community(pool).await?;
Expand Down Expand Up @@ -155,9 +154,8 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn test_soft_delete() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();

let (data, inserted_person, inserted_community) = prepare_site_with_community(pool).await?;
Expand Down
6 changes: 2 additions & 4 deletions crates/db_schema/src/impls/local_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,8 @@ mod tests {
use serial_test::serial;

#[tokio::test]
#[serial]
async fn test_admin_higher_check() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();

let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?;
Expand Down Expand Up @@ -439,9 +438,8 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn test_email_taken() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();

let darwin_email = "charles.darwin@gmail.com";
Expand Down
3 changes: 1 addition & 2 deletions crates/db_schema/src/impls/mod_log/moderator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,8 @@ mod tests {
use serial_test::serial;

#[tokio::test]
#[serial]
async fn test_crud() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();

let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()).await?;
Expand Down
3 changes: 1 addition & 2 deletions crates/db_schema/src/impls/multi_community.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,8 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn test_multi_community_apub() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();
let data = setup(pool).await?;

Expand Down
3 changes: 1 addition & 2 deletions crates/db_schema/src/impls/password_reset_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ mod tests {
use serial_test::serial;

#[tokio::test]
#[serial]
async fn test_password_reset() -> LemmyResult<()> {
let pool = &build_db_pool_for_tests();
let pool = &build_db_pool_for_tests().await;
let pool = &mut pool.into();

// Setup
Expand Down
Loading