Skip to content

Commit

Permalink
add smoke test for omdb (#4101)
Browse files Browse the repository at this point in the history
  • Loading branch information
davepacheco authored Sep 20, 2023
1 parent 47cbc6f commit 69a5b18
Show file tree
Hide file tree
Showing 10 changed files with 792 additions and 21 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ chacha20poly1305 = "0.10.1"
ciborium = "0.2.1"
cfg-if = "1.0"
chrono = { version = "0.4", features = [ "serde" ] }
clap = { version = "4.4", features = ["derive", "env"] }
clap = { version = "4.4", features = ["derive", "env", "wrap_help"] }
cookie = "0.16"
criterion = { version = "0.5.1", features = [ "async_tokio" ] }
crossbeam = "0.8"
Expand Down
9 changes: 9 additions & 0 deletions omdb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ textwrap.workspace = true
tokio = { workspace = true, features = [ "full" ] }
uuid.workspace = true

[dev-dependencies]
expectorate.workspace = true
nexus-test-utils.workspace = true
nexus-test-utils-macros.workspace = true
omicron-nexus.workspace = true
omicron-test-utils.workspace = true
regex.workspace = true
subprocess.workspace = true

# Disable doc builds by default for our binaries to work around issue
# rust-lang/cargo#8373. These docs would not be very useful anyway.
[[bin]]
Expand Down
2 changes: 1 addition & 1 deletion omdb/src/bin/omdb/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ async fn check_schema_version(datastore: &DataStore) {
Ok(found_version) => {
if found_version == expected_version {
eprintln!(
"note: databaase schema version matches expected ({})",
"note: database schema version matches expected ({})",
expected_version
);
return;
Expand Down
39 changes: 20 additions & 19 deletions omdb/src/bin/omdb/nexus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ pub struct NexusArgs {
#[derive(Debug, Subcommand)]
enum NexusCommands {
/// print information about background tasks
BackgroundTask(BackgroundTaskArgs),
BackgroundTasks(BackgroundTasksArgs),
}

#[derive(Debug, Args)]
struct BackgroundTaskArgs {
struct BackgroundTasksArgs {
#[command(subcommand)]
command: BackgroundTaskCommands,
command: BackgroundTasksCommands,
}

#[derive(Debug, Subcommand)]
enum BackgroundTaskCommands {
enum BackgroundTasksCommands {
/// Show documentation about background tasks
Doc,
/// Print a summary of the status of all background tasks
Expand All @@ -70,26 +70,27 @@ impl NexusArgs {
let client = nexus_client::Client::new(nexus_url, log.clone());

match &self.command {
NexusCommands::BackgroundTask(BackgroundTaskArgs {
command: BackgroundTaskCommands::Doc,
}) => cmd_nexus_background_task_doc(&client).await,
NexusCommands::BackgroundTask(BackgroundTaskArgs {
command: BackgroundTaskCommands::List,
}) => cmd_nexus_background_task_list(&client).await,
NexusCommands::BackgroundTask(BackgroundTaskArgs {
command: BackgroundTaskCommands::Show,
}) => cmd_nexus_background_task_show(&client).await,
NexusCommands::BackgroundTasks(BackgroundTasksArgs {
command: BackgroundTasksCommands::Doc,
}) => cmd_nexus_background_tasks_doc(&client).await,
NexusCommands::BackgroundTasks(BackgroundTasksArgs {
command: BackgroundTasksCommands::List,
}) => cmd_nexus_background_tasks_list(&client).await,
NexusCommands::BackgroundTasks(BackgroundTasksArgs {
command: BackgroundTasksCommands::Show,
}) => cmd_nexus_background_tasks_show(&client).await,
}
}
}

/// Runs `omdb nexus background-task doc`
async fn cmd_nexus_background_task_doc(
/// Runs `omdb nexus background-tasks doc`
async fn cmd_nexus_background_tasks_doc(
client: &nexus_client::Client,
) -> Result<(), anyhow::Error> {
let response =
client.bgtask_list().await.context("listing background tasks")?;
let tasks = response.into_inner();
let tasks: BTreeMap<_, _> = tasks.into_iter().collect();
for (_, bgtask) in &tasks {
println!("task: {:?}", bgtask.name);
println!(
Expand All @@ -108,8 +109,8 @@ async fn cmd_nexus_background_task_doc(
Ok(())
}

/// Runs `omdb nexus background-task list`
async fn cmd_nexus_background_task_list(
/// Runs `omdb nexus background-tasks list`
async fn cmd_nexus_background_tasks_list(
client: &nexus_client::Client,
) -> Result<(), anyhow::Error> {
let response =
Expand All @@ -124,8 +125,8 @@ async fn cmd_nexus_background_task_list(
Ok(())
}

/// Runs `omdb nexus background-task show`
async fn cmd_nexus_background_task_show(
/// Runs `omdb nexus background-tasks show`
async fn cmd_nexus_background_tasks_show(
client: &nexus_client::Client,
) -> Result<(), anyhow::Error> {
let response =
Expand Down
1 change: 1 addition & 0 deletions omdb/tests/config.test.toml
74 changes: 74 additions & 0 deletions omdb/tests/env.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
EXECUTING COMMAND: omdb ["db", "--db-url", "postgresql://root@[::1]:REDACTED_PORT/omicron?sslmode=disable", "sleds"]
termination: Exited(0)
---------------------------------------------
stdout:
SERIAL IP ROLE ID
sim-b6d65341 [::1]:REDACTED_PORT - REDACTED_UUID_REDACTED_UUID_REDACTED
---------------------------------------------
stderr:
note: database schema version matches expected (4.0.0)
=============================================
EXECUTING COMMAND: omdb ["db", "--db-url", "junk", "sleds"]
termination: Exited(2)
---------------------------------------------
stdout:
---------------------------------------------
stderr:
error: invalid value 'junk' for '--db-url <DB_URL>': invalid connection string: unexpected EOF

For more information, try '--help'.
=============================================
EXECUTING COMMAND: omdb ["nexus", "--nexus-internal-url", "http://127.0.0.1:REDACTED_PORT", "background-tasks", "doc"]
termination: Exited(0)
---------------------------------------------
stdout:
task: "dns_config_external"
watches external DNS data stored in CockroachDB


task: "dns_config_internal"
watches internal DNS data stored in CockroachDB


task: "dns_propagation_external"
propagates latest external DNS configuration (from "dns_config_external"
background task) to the latest list of DNS servers (from
"dns_servers_external" background task)


task: "dns_propagation_internal"
propagates latest internal DNS configuration (from "dns_config_internal"
background task) to the latest list of DNS servers (from
"dns_servers_internal" background task)


task: "dns_servers_external"
watches list of external DNS servers stored in CockroachDB


task: "dns_servers_internal"
watches list of internal DNS servers stored in CockroachDB


task: "external_endpoints"
reads config for silos and TLS certificates to determine the right set of
HTTP endpoints, their HTTP server names, and which TLS certificates to use
on each one


---------------------------------------------
stderr:
=============================================
EXECUTING COMMAND: omdb ["nexus", "--nexus-internal-url", "junk", "background-tasks", "doc"]
termination: Exited(1)
---------------------------------------------
stdout:
---------------------------------------------
stderr:
Error: listing background tasks

Caused by:
0: Communication Error: builder error: relative URL without a base
1: builder error: relative URL without a base
2: relative URL without a base
=============================================
Loading

0 comments on commit 69a5b18

Please sign in to comment.