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
|
||||
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:
|
||||
image: node:22-bookworm-slim
|
||||
environment:
|
||||
|
16
Cargo.lock
generated
16
Cargo.lock
generated
@ -3336,22 +3336,6 @@ dependencies = [
|
||||
"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]]
|
||||
name = "lemmy_db_schema"
|
||||
version = "1.0.0-alpha.5"
|
||||
|
@ -49,7 +49,6 @@ members = [
|
||||
"crates/apub",
|
||||
"crates/apub_objects",
|
||||
"crates/utils",
|
||||
"crates/db_perf",
|
||||
"crates/db_schema",
|
||||
"crates/db_schema_file",
|
||||
"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;
|
||||
|
||||
use crate::series::ValuesFromSeries;
|
||||
use anyhow::Context;
|
||||
use clap::Parser;
|
||||
use crate::{db_perf::series::ValuesFromSeries, impls::PostQuery, PostView};
|
||||
use diesel::{
|
||||
dsl::{self, sql},
|
||||
sql_types,
|
||||
@ -21,38 +19,30 @@ use lemmy_db_schema::{
|
||||
utils::{build_db_pool, get_conn, now},
|
||||
};
|
||||
use lemmy_db_schema_file::{enums::PostSortType, schema::post};
|
||||
use lemmy_db_views_post::{impls::PostQuery, PostView};
|
||||
use lemmy_utils::error::{LemmyErrorExt2, LemmyResult};
|
||||
use lemmy_utils::error::LemmyResult;
|
||||
use serial_test::serial;
|
||||
use std::num::NonZeroU32;
|
||||
use url::Url;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[derive(Debug)]
|
||||
struct CmdArgs {
|
||||
#[arg(long, default_value_t = 3.try_into().unwrap())]
|
||||
communities: NonZeroU32,
|
||||
#[arg(long, default_value_t = 3.try_into().unwrap())]
|
||||
people: NonZeroU32,
|
||||
#[arg(long, default_value_t = 100000.try_into().unwrap())]
|
||||
posts: NonZeroU32,
|
||||
#[arg(long, default_value_t = 0)]
|
||||
read_post_pages: u32,
|
||||
#[arg(long)]
|
||||
explain_insertions: bool,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
let mut result = try_main().await.into_anyhow();
|
||||
if let Ok(path) = std::env::var("PGDATA") {
|
||||
result = result.with_context(|| {
|
||||
format!("Failed to run lemmy_db_perf (more details might be available in {path}/log)")
|
||||
});
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
async fn try_main() -> LemmyResult<()> {
|
||||
let args = CmdArgs::parse();
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
async fn db_perf() -> LemmyResult<()> {
|
||||
let args = CmdArgs {
|
||||
communities: 3.try_into()?,
|
||||
people: 3.try_into()?,
|
||||
posts: 100000.try_into()?,
|
||||
read_post_pages: 0,
|
||||
explain_insertions: false,
|
||||
};
|
||||
let pool = &build_db_pool()?;
|
||||
let pool = &mut pool.into();
|
||||
let conn = &mut get_conn(pool).await?;
|
@ -7,6 +7,8 @@ use lemmy_db_schema::source::{
|
||||
tag::TagsView,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(test)]
|
||||
pub mod db_perf;
|
||||
use serde_with::skip_serializing_none;
|
||||
#[cfg(feature = "full")]
|
||||
use {
|
||||
|
Loading…
x
Reference in New Issue
Block a user