Move db_perf check to unit test (#5781)
* Move db_perf check to unit test * remove ci step
This commit is contained in:
parent
42bd941f35
commit
a2ef488528
@ -224,18 +224,6 @@ steps:
|
|||||||
- diff tmp.schema crates/db_schema_file/src/schema.rs
|
- diff tmp.schema crates/db_schema_file/src/schema.rs
|
||||||
when: *slow_check_paths
|
when: *slow_check_paths
|
||||||
|
|
||||||
check_db_perf_tool:
|
|
||||||
image: *rust_image
|
|
||||||
environment:
|
|
||||||
LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
|
|
||||||
RUST_BACKTRACE: "1"
|
|
||||||
CARGO_HOME: .cargo_home
|
|
||||||
RUSTUP_HOME: .rustup_home
|
|
||||||
commands:
|
|
||||||
# same as scripts/db_perf.sh but without creating a new database server
|
|
||||||
- cargo run --package lemmy_db_perf -- --posts 10 --read-post-pages 1
|
|
||||||
when: *slow_check_paths
|
|
||||||
|
|
||||||
run_federation_tests:
|
run_federation_tests:
|
||||||
image: node:22-bookworm-slim
|
image: node:22-bookworm-slim
|
||||||
environment:
|
environment:
|
||||||
|
16
Cargo.lock
generated
16
Cargo.lock
generated
@ -3336,22 +3336,6 @@ dependencies = [
|
|||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lemmy_db_perf"
|
|
||||||
version = "1.0.0-alpha.5"
|
|
||||||
dependencies = [
|
|
||||||
"anyhow",
|
|
||||||
"clap",
|
|
||||||
"diesel",
|
|
||||||
"diesel-async",
|
|
||||||
"lemmy_db_schema",
|
|
||||||
"lemmy_db_schema_file",
|
|
||||||
"lemmy_db_views_post",
|
|
||||||
"lemmy_utils",
|
|
||||||
"tokio",
|
|
||||||
"url",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lemmy_db_schema"
|
name = "lemmy_db_schema"
|
||||||
version = "1.0.0-alpha.5"
|
version = "1.0.0-alpha.5"
|
||||||
|
@ -49,7 +49,6 @@ members = [
|
|||||||
"crates/apub",
|
"crates/apub",
|
||||||
"crates/apub_objects",
|
"crates/apub_objects",
|
||||||
"crates/utils",
|
"crates/utils",
|
||||||
"crates/db_perf",
|
|
||||||
"crates/db_schema",
|
"crates/db_schema",
|
||||||
"crates/db_schema_file",
|
"crates/db_schema_file",
|
||||||
"crates/db_views/api_misc",
|
"crates/db_views/api_misc",
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "lemmy_db_perf"
|
|
||||||
publish = false
|
|
||||||
version.workspace = true
|
|
||||||
edition.workspace = true
|
|
||||||
description.workspace = true
|
|
||||||
license.workspace = true
|
|
||||||
homepage.workspace = true
|
|
||||||
documentation.workspace = true
|
|
||||||
repository.workspace = true
|
|
||||||
rust-version.workspace = true
|
|
||||||
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
anyhow = { workspace = true }
|
|
||||||
clap = { workspace = true }
|
|
||||||
diesel = { workspace = true }
|
|
||||||
diesel-async = { workspace = true }
|
|
||||||
lemmy_db_schema = { workspace = true }
|
|
||||||
lemmy_db_views_post = { workspace = true, features = ["full"] }
|
|
||||||
lemmy_utils = { workspace = true, features = ["full"] }
|
|
||||||
lemmy_db_schema_file = { workspace = true }
|
|
||||||
tokio = { workspace = true }
|
|
||||||
url = { workspace = true }
|
|
@ -1,8 +1,6 @@
|
|||||||
mod series;
|
mod series;
|
||||||
|
|
||||||
use crate::series::ValuesFromSeries;
|
use crate::{db_perf::series::ValuesFromSeries, impls::PostQuery, PostView};
|
||||||
use anyhow::Context;
|
|
||||||
use clap::Parser;
|
|
||||||
use diesel::{
|
use diesel::{
|
||||||
dsl::{self, sql},
|
dsl::{self, sql},
|
||||||
sql_types,
|
sql_types,
|
||||||
@ -21,38 +19,30 @@ use lemmy_db_schema::{
|
|||||||
utils::{build_db_pool, get_conn, now},
|
utils::{build_db_pool, get_conn, now},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema_file::{enums::PostSortType, schema::post};
|
use lemmy_db_schema_file::{enums::PostSortType, schema::post};
|
||||||
use lemmy_db_views_post::{impls::PostQuery, PostView};
|
use lemmy_utils::error::LemmyResult;
|
||||||
use lemmy_utils::error::{LemmyErrorExt2, LemmyResult};
|
use serial_test::serial;
|
||||||
use std::num::NonZeroU32;
|
use std::num::NonZeroU32;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Debug)]
|
||||||
struct CmdArgs {
|
struct CmdArgs {
|
||||||
#[arg(long, default_value_t = 3.try_into().unwrap())]
|
|
||||||
communities: NonZeroU32,
|
communities: NonZeroU32,
|
||||||
#[arg(long, default_value_t = 3.try_into().unwrap())]
|
|
||||||
people: NonZeroU32,
|
people: NonZeroU32,
|
||||||
#[arg(long, default_value_t = 100000.try_into().unwrap())]
|
|
||||||
posts: NonZeroU32,
|
posts: NonZeroU32,
|
||||||
#[arg(long, default_value_t = 0)]
|
|
||||||
read_post_pages: u32,
|
read_post_pages: u32,
|
||||||
#[arg(long)]
|
|
||||||
explain_insertions: bool,
|
explain_insertions: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::test]
|
||||||
async fn main() -> anyhow::Result<()> {
|
#[serial]
|
||||||
let mut result = try_main().await.into_anyhow();
|
async fn db_perf() -> LemmyResult<()> {
|
||||||
if let Ok(path) = std::env::var("PGDATA") {
|
let args = CmdArgs {
|
||||||
result = result.with_context(|| {
|
communities: 3.try_into()?,
|
||||||
format!("Failed to run lemmy_db_perf (more details might be available in {path}/log)")
|
people: 3.try_into()?,
|
||||||
});
|
posts: 100000.try_into()?,
|
||||||
}
|
read_post_pages: 0,
|
||||||
result
|
explain_insertions: false,
|
||||||
}
|
};
|
||||||
|
|
||||||
async fn try_main() -> LemmyResult<()> {
|
|
||||||
let args = CmdArgs::parse();
|
|
||||||
let pool = &build_db_pool()?;
|
let pool = &build_db_pool()?;
|
||||||
let pool = &mut pool.into();
|
let pool = &mut pool.into();
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
@ -7,6 +7,8 @@ use lemmy_db_schema::source::{
|
|||||||
tag::TagsView,
|
tag::TagsView,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod db_perf;
|
||||||
use serde_with::skip_serializing_none;
|
use serde_with::skip_serializing_none;
|
||||||
#[cfg(feature = "full")]
|
#[cfg(feature = "full")]
|
||||||
use {
|
use {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user