Add back the default database path.

Allow default server_name when testing.

Default to smoke test vector when testing.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-09-27 15:49:46 +00:00
parent 292b601755
commit ae52676e33
6 changed files with 57 additions and 11 deletions

View File

@@ -272,7 +272,10 @@ features = ["std"]
[workspace.dependencies.nix] [workspace.dependencies.nix]
version = "0.30" version = "0.30"
default-features = false default-features = false
features = ["resource"] features = [
"resource",
"user",
]
[workspace.dependencies.num-traits] [workspace.dependencies.num-traits]
version = "0.2" version = "0.2"

View File

@@ -26,6 +26,7 @@ ARG sys_target
WORKDIR /usr/src/tuwunel WORKDIR /usr/src/tuwunel
COPY --link --from=source /usr/src/tuwunel . COPY --link --from=source /usr/src/tuwunel .
ENV TUWUNEL_DATABASE_PATH="/tmp/buildtest.db"
RUN \ RUN \
--mount=type=cache,dst=/nix,sharing=shared \ --mount=type=cache,dst=/nix,sharing=shared \
--mount=type=cache,dst=/root/.cache/nix,sharing=shared \ --mount=type=cache,dst=/root/.cache/nix,sharing=shared \

View File

@@ -149,6 +149,18 @@ pub struct Args {
pub gc_muzzy: Option<bool>, pub gc_muzzy: Option<bool>,
} }
impl Args {
#[must_use]
pub fn default_test(name: &str) -> Self {
let mut args = Self::default();
args.test.push(name.into());
args.option
.push("server_name=\"localhost\"".into());
args
}
}
impl Default for Args { impl Default for Args {
fn default() -> Self { Self::parse() } fn default() -> Self { Self::parse() }
} }

View File

@@ -76,14 +76,14 @@ pub struct Config {
/// WIPE. /// WIPE.
/// ///
/// example: "girlboss.ceo" /// example: "girlboss.ceo"
#[cfg_attr(test, serde(default = "default_server_name"))]
pub server_name: OwnedServerName, pub server_name: OwnedServerName,
/// This is the only directory where tuwunel will save its data, including /// This is the only directory where tuwunel will save its data, including
/// media. Note: this was previously "/var/lib/matrix-conduit". /// media. Note: this was previously "/var/lib/matrix-conduit".
/// ///
/// YOU NEED TO EDIT THIS. /// default: "/var/lib/tuwunel"
/// #[serde(default = "default_database_path")]
/// example: "/var/lib/tuwunel"
pub database_path: PathBuf, pub database_path: PathBuf,
/// Text which will be added to the end of the user's displayname upon /// Text which will be added to the end of the user's displayname upon
@@ -1870,6 +1870,12 @@ pub struct Config {
#[serde(default)] #[serde(default)]
pub tokio_console: bool, pub tokio_console: bool,
/// Arbitrary argument vector for integration testing. Functionality in the
/// server is altered or informed for the requirements of integration tests.
/// - "smoke" performs a shutdown after startup admin commands rather than
/// hanging on client handling.
///
/// default: []
#[serde(default)] #[serde(default)]
pub test: BTreeSet<String>, pub test: BTreeSet<String>,
@@ -2571,6 +2577,11 @@ impl Config {
fn true_fn() -> bool { true } fn true_fn() -> bool { true }
#[cfg(test)]
fn default_server_name() -> OwnedServerName { ruma::owned_server_name!("localhost") }
fn default_database_path() -> PathBuf { "/var/lib/tuwunel".to_owned().into() }
fn default_address() -> ListeningAddr { fn default_address() -> ListeningAddr {
ListeningAddr { ListeningAddr {
addrs: Right(vec![Ipv4Addr::LOCALHOST.into(), Ipv6Addr::LOCALHOST.into()]), addrs: Right(vec![Ipv4Addr::LOCALHOST.into(), Ipv6Addr::LOCALHOST.into()]),

20
src/main/tests/smoke.rs Normal file
View File

@@ -0,0 +1,20 @@
#![cfg(test)]
use tuwunel::Server;
use tuwunel_core::{Args, Result, runtime};
#[test]
fn dummy() {}
#[test]
#[should_panic = "dummy"]
fn panic_dummy() { panic!("dummy") }
#[test]
fn smoke() -> Result {
let args = Args::default_test("smoke");
let runtime = runtime::new(Some(&args))?;
let server = Server::new(Some(&args), Some(runtime.handle()))?;
tuwunel::exec(&server, runtime)
}

View File

@@ -39,11 +39,7 @@
# This is the only directory where tuwunel will save its data, including # This is the only directory where tuwunel will save its data, including
# media. Note: this was previously "/var/lib/matrix-conduit". # media. Note: this was previously "/var/lib/matrix-conduit".
# #
# YOU NEED TO EDIT THIS. #database_path = "/var/lib/tuwunel"
#
# example: "/var/lib/tuwunel"
#
#database_path =
# Text which will be added to the end of the user's displayname upon # Text which will be added to the end of the user's displayname upon
# registration with a space before the text. In Conduit, this was the # registration with a space before the text. In Conduit, this was the
@@ -1613,9 +1609,12 @@
# #
#tokio_console = false #tokio_console = false
# This item is undocumented. Please contribute documentation for it. # Arbitrary argument vector for integration testing. Functionality in the
# server is altered or informed for the requirements of integration tests.
# - "smoke" performs a shutdown after startup admin commands rather than
# hanging on client handling.
# #
#test = false #test = []
# Controls whether admin room notices like account registrations, password # Controls whether admin room notices like account registrations, password
# changes, account deactivations, room directory publications, etc will be # changes, account deactivations, room directory publications, etc will be