From 9845b67e92724ed0b5b172bc57c1795be3999b78 Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Mon, 8 Apr 2024 13:24:17 -0400 Subject: [PATCH 1/2] Add stratis-min tests Signed-off-by: Bryan Gurney --- tests/stratis_min.rs | 146 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) diff --git a/tests/stratis_min.rs b/tests/stratis_min.rs index 9bfbf49894..cb0d5307ce 100644 --- a/tests/stratis_min.rs +++ b/tests/stratis_min.rs @@ -144,6 +144,17 @@ fn test_stratis_min_create_no_blockdevs() { )); } +#[test] +// Test stopping a pool using an invalid name, that will fail with a +// "Uuid error". +fn test_stratis_min_pool_stop_invalid_name() { + let mut cmd = Command::cargo_bin("stratis-min").unwrap(); + cmd.arg("pool").arg("stop").arg("pn"); + cmd.assert() + .failure() + .stderr(predicate::str::contains("Uuid error")); +} + // stratis-min tests with sim engine fn stratis_min_create_pool_and_fs() { @@ -214,6 +225,141 @@ fn test_stratis_min_pool_rename() { test_with_stratisd_min_sim(stratis_min_pool_rename); } +fn stratis_min_fs_rename() { + stratis_min_create_pool_and_fs(); + let mut cmd = Command::cargo_bin("stratis-min").unwrap(); + cmd.arg("filesystem") + .arg("rename") + .arg("pn") + .arg("fn") + .arg("fm"); + cmd.assert().success(); + let mut cmd = Command::cargo_bin("stratis-min").unwrap(); + cmd.arg("filesystem") + .assert() + .success() + .stdout(predicate::str::contains("fm")); +} + +#[test] +// Test renaming a filesystem. +fn test_stratis_min_fs_rename() { + test_with_stratisd_min_sim(stratis_min_fs_rename); +} + +fn stratis_min_pool_stop_name() { + stratis_min_create_pool_and_fs(); + let mut cmd = Command::cargo_bin("stratis-min").unwrap(); + cmd.arg("pool").arg("stop").arg("--name").arg("pn"); + cmd.assert().success(); +} + +#[test] +// Test stopping a pool using a valid name. +fn test_stratis_min_pool_stop_name() { + test_with_stratisd_min_sim(stratis_min_pool_stop_name); +} + +fn stratis_min_pool_stop_start_name() { + stratis_min_create_pool_and_fs(); + let mut cmd = Command::cargo_bin("stratis-min").unwrap(); + cmd.arg("pool").arg("stop").arg("--name").arg("pn"); + cmd.assert().success(); + let mut cmd = Command::cargo_bin("stratis-min").unwrap(); + cmd.arg("pool").arg("start").arg("--name").arg("pn"); + cmd.assert().success(); +} + +#[test] +// Test stopping and starting a pool using a valid name. +fn test_stratis_min_pool_stop_start_name() { + test_with_stratisd_min_sim(stratis_min_pool_stop_start_name); +} + +fn stratis_min_pool_is_encrypted() { + stratis_min_create_pool_and_fs(); + let mut cmd = Command::cargo_bin("stratis-min").unwrap(); + cmd.arg("pool").arg("is-encrypted").arg("--name").arg("pn"); + cmd.assert().success(); +} + +#[test] +// Test if a pool is encrypted. +fn test_stratis_min_pool_is_encrypted() { + test_with_stratisd_min_sim(stratis_min_pool_is_encrypted); +} + +fn stratis_min_pool_is_stopped() { + stratis_min_create_pool_and_fs(); + let mut cmd = Command::cargo_bin("stratis-min").unwrap(); + cmd.arg("pool").arg("is-stopped").arg("--name").arg("pn"); + cmd.assert().success(); +} + +#[test] +// Test if a pool is stopped. +fn test_stratis_min_pool_is_stopped() { + test_with_stratisd_min_sim(stratis_min_pool_is_stopped); +} + +fn stratis_min_pool_is_bound() { + stratis_min_create_pool_and_fs(); + let mut cmd = Command::cargo_bin("stratis-min").unwrap(); + cmd.arg("pool").arg("is-bound").arg("--name").arg("pn"); + cmd.assert().success(); +} + +#[test] +// Test if a pool is bound. +fn test_stratis_min_pool_is_bound() { + test_with_stratisd_min_sim(stratis_min_pool_is_bound); +} + +fn stratis_min_pool_has_passphrase() { + stratis_min_create_pool_and_fs(); + let mut cmd = Command::cargo_bin("stratis-min").unwrap(); + cmd.arg("pool") + .arg("has-passphrase") + .arg("--name") + .arg("pn"); + cmd.assert().success(); +} + +#[test] +// Test if a pool has a passphrase. +fn test_stratis_min_pool_has_passphrase() { + test_with_stratisd_min_sim(stratis_min_pool_has_passphrase); +} + +fn stratis_min_pool_stop_nonexistent_uuid() { + stratis_min_create_pool_and_fs(); + let mut cmd = Command::cargo_bin("stratis-min").unwrap(); + cmd.arg("pool") + .arg("stop") + .arg("44444444444444444444444444444444"); + cmd.assert().failure().stderr(predicate::str::contains( + "was not found and cannot be stopped", + )); +} + +#[test] +// Test trying to stop a pool with a nonexistent UUID. +fn test_stratis_min_pool_stop_nonexistent_uuid() { + test_with_stratisd_min_sim(stratis_min_pool_stop_nonexistent_uuid); +} + +fn stratis_min_fs_origin() { + stratis_min_create_pool_and_fs(); + let mut cmd = Command::cargo_bin("stratis-min").unwrap(); + cmd.arg("filesystem").arg("origin").arg("pn").arg("fn"); + cmd.assert().success(); +} + +#[test] +fn test_stratis_min_fs_origin() { + test_with_stratisd_min_sim(stratis_min_fs_origin); +} + fn stratis_min_report() { let mut cmd = Command::cargo_bin("stratis-min").unwrap(); cmd.arg("report"); From ddce6ec0f7866d30f7d99fd2f33a980813450cdd Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Thu, 11 Apr 2024 10:58:42 -0400 Subject: [PATCH 2/2] github actions: ignore only pushes to tests/client-dbus dir Signed-off-by: Bryan Gurney --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7a383e6231..ccd05afea1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ on: - 'CHANGES.txt' - '**/README.md' - 'README_tests.md' - - 'tests/**' + - 'tests/client-dbus/**' - '.packit.yaml' - 'plans/**' - 'tests-fmf/**' @@ -21,7 +21,7 @@ on: - 'CHANGES.txt' - '**/README.md' - 'README_tests.md' - - 'tests/**' + - 'tests/client-dbus/**' - '.packit.yaml' - 'plans/**' - 'tests-fmf/**'