Skip to content

Commit 956481c

Browse files
authored
[1/n] [reconfigurator-cli] use datatest-stable for tests (#8121)
With this change, new scripts can be added and will be automatically picked up. ![image](https://github.com/user-attachments/assets/501989dd-9fbe-4c5f-9efc-c40a2c6fb84f)
1 parent 9303cf8 commit 956481c

22 files changed

+150
-135
lines changed

Cargo.lock

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ curve25519-dalek = "4"
403403
daft = { version = "0.1.3", features = ["derive", "newtype-uuid1", "oxnet01", "uuid1"] }
404404
display-error-chain = "0.2.2"
405405
omicron-ddm-admin-client = { path = "clients/ddm-admin-client" }
406+
datatest-stable = "0.3.2"
406407
db-macros = { path = "nexus/db-macros" }
407408
debug-ignore = "1.0.5"
408409
derive_more = "0.99.20"

dev-tools/reconfigurator-cli/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ omicron-workspace-hack.workspace = true
4848
# its database code here. Instead, put those tests inside
4949
# nexus/reconfigurator/cli-integration-tests.
5050
camino-tempfile.workspace = true
51+
datatest-stable.workspace = true
5152
expectorate.workspace = true
5253
omicron-test-utils.workspace = true
5354
serde.workspace = true
@@ -59,3 +60,7 @@ tokio.workspace = true
5960
[[bin]]
6061
name = "reconfigurator-cli"
6162
doc = false
63+
64+
[[test]]
65+
name = "test-scripts"
66+
harness = false

dev-tools/reconfigurator-cli/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ struct BlueprintDiffArgs {
488488

489489
#[derive(Debug, Subcommand)]
490490
enum SetArgs {
491+
/// RNG seed for future commands
492+
Seed { seed: String },
491493
/// target number of Nexus instances (for planning)
492494
NumNexus { num_nexus: u16 },
493495
/// system's external DNS zone name (suffix)
@@ -1286,6 +1288,12 @@ fn cmd_set(
12861288
) -> anyhow::Result<Option<String>> {
12871289
let mut state = sim.current_state().to_mut();
12881290
let rv = match args {
1291+
SetArgs::Seed { seed } => {
1292+
// In this case, reset the RNG state to the provided seed.
1293+
let rv = format!("new RNG seed: {seed}");
1294+
state.rng_mut().set_seed(seed);
1295+
rv
1296+
}
12891297
SetArgs::NumNexus { num_nexus } => {
12901298
let rv = format!(
12911299
"target number of Nexus zones: {:?} -> {}",

dev-tools/reconfigurator-cli/tests/input/cmds-example.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# This is a legacy test; new tests shouldn't need to set a seed
12
load-example --seed test-basic
23
load-example --seed test-basic
34

dev-tools/reconfigurator-cli/tests/input/cmds-expunge-newly-added.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
load-example
1+
# This is a legacy test; new tests shouldn't need to set a seed
2+
load-example --seed test_expunge_newly_added_external_dns
23

34
blueprint-show 3f00b694-1b16-4aaa-8f78-e6b3a527b434
45
blueprint-edit 3f00b694-1b16-4aaa-8f78-e6b3a527b434 expunge-zone 9995de32-dd52-4eb1-b0eb-141eb84bc739

dev-tools/reconfigurator-cli/tests/input/cmds-set-mgs-updates.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Load example system
2-
load-example --nsleds 3 --ndisks-per-sled 3
2+
# This is a legacy test; new tests shouldn't need to set a seed
3+
load-example --nsleds 3 --ndisks-per-sled 3 --seed test_set_mgs_updates
34
blueprint-show ad97e762-7bf1-45a6-a98f-60afb7e491c0
45

56
# Configure an MGS-managed update to one of the SPs.

dev-tools/reconfigurator-cli/tests/input/cmds-set-zone-images.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Load example system
2-
load-example --nsleds 1 --ndisks-per-sled 3
2+
# This is a legacy test; new tests shouldn't need to set a seed
3+
load-example --nsleds 1 --ndisks-per-sled 3 --seed test_set_zone_images
34
blueprint-show 971eeb12-1830-4fa0-a699-98ea0164505c
45

56
# Set a couple zones' image sources to specific artifacts.

dev-tools/reconfigurator-cli/tests/input/cmds.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This is a legacy test; new tests shouldn't need to set a seed
2+
set seed test_basic
13
sled-list
24
inventory-list
35
blueprint-list

0 commit comments

Comments
 (0)