Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add "live tests" #6427

Merged
merged 28 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0cd7235
first cut
davepacheco Aug 21, 2024
ec5fadb
add CI that builds it
davepacheco Aug 21, 2024
4544934
avoid trying to run tests by default (does not seem like a great way)
davepacheco Aug 21, 2024
8f1cc51
bail out faster on non-illumos
davepacheco Aug 21, 2024
340fc22
Bundle up working directory instead of using git archive (much smalle…
davepacheco Aug 21, 2024
7c2c50c
check TMPDIR
davepacheco Aug 21, 2024
210e4f6
these tests need to run serially
davepacheco Aug 23, 2024
365d13e
commonize some code
davepacheco Aug 23, 2024
4712076
DataStore::new_failfast
davepacheco Aug 23, 2024
a27d14d
commonize run_subcmd in xtask
davepacheco Aug 23, 2024
c4f9ee7
write some docs
davepacheco Aug 23, 2024
826b278
make it a macro
davepacheco Aug 23, 2024
aed5ea2
fix bugs, clean up
davepacheco Aug 23, 2024
9d959db
test that the zone goes away
davepacheco Aug 23, 2024
f051594
live-test -> live-tests
davepacheco Aug 23, 2024
6dbf1ff
add some docs
davepacheco Aug 23, 2024
cf8fb0e
fix clippy
davepacheco Aug 23, 2024
a9d0a32
fix workspace dep check
davepacheco Aug 23, 2024
80922f6
fix hakari
davepacheco Aug 23, 2024
502d229
Merge branch 'main' into dap/drafts/reconfigurator-tests
davepacheco Aug 23, 2024
9288eb0
fix live-tests check (move this into the existing check that already …
davepacheco Aug 23, 2024
9bbb273
cannot build that on non-illumos
davepacheco Aug 24, 2024
c7cd0ed
review feedback
davepacheco Aug 26, 2024
78f99db
Merge branch 'main' into dap/drafts/reconfigurator-tests
davepacheco Aug 26, 2024
e85d012
Merge branch 'main' into dap/drafts/reconfigurator-tests
davepacheco Aug 27, 2024
251e665
Merge branch 'main' into dap/drafts/reconfigurator-tests
davepacheco Aug 27, 2024
ab5448b
fix semantic mismerge
davepacheco Aug 27, 2024
665bcc1
rustfmt
davepacheco Aug 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ experimental = ["setup-scripts"]
[[profile.default.scripts]]
# Exclude omicron-dev tests from crdb-seed as we explicitly want to simulate an
# environment where the seed file doesn't exist.
davepacheco marked this conversation as resolved.
Show resolved Hide resolved
filter = 'rdeps(nexus-test-utils) - package(omicron-dev)'
filter = 'rdeps(nexus-test-utils) - package(omicron-dev) - package(omicron-live-tests)'
setup = 'crdb-seed'

[profile.ci]
Expand All @@ -21,18 +21,26 @@ fail-fast = false
# invocations of nextest happen.
command = 'cargo run -p crdb-seed --profile test'

[test-groups]
# The ClickHouse cluster tests currently rely on a hard-coded set of ports for
# the nodes in the cluster. We would like to relax this in the future, at which
# point this test-group configuration can be removed or at least loosened to
# support testing in parallel. For now, enforce strict serialization for all
# tests with `replicated` in the name.
[test-groups]
clickhouse-cluster = { max-threads = 1 }
# While most Omicron tests operate with their own simulated control plane, the
# live-tests operate on a more realistic, shared control plane and test
# behaviors that conflict with each other. They need to be run serially.
live-tests = { max-threads = 1 }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Makes sense!
  2. As mentioned in the DM, you can now filter out omicron-live-tests from the default set. (You'll want to bump the required and recommended versions in this file, as well as the version used in CI, to 0.9.76)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool. I'd prefer we do that in a separate PR.


[[profile.default.overrides]]
filter = 'package(oximeter-db) and test(replicated)'
test-group = 'clickhouse-cluster'

[[profile.default.overrides]]
filter = 'package(omicron-live-tests)'
test-group = 'live-tests'

[[profile.default.overrides]]
# These tests can time out under heavy contention.
filter = 'binary_id(omicron-nexus::test_all) and test(::schema::)'
Expand Down
6 changes: 6 additions & 0 deletions .github/buildomat/build-and-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ ptime -m timeout 2h cargo nextest run --profile ci --locked --verbose
banner doctest
ptime -m timeout 1h cargo test --doc --locked --verbose --no-fail-fast

# Build the live-tests. This is only supported on illumos.
# We also can't actually run them here. See the README for more details.
if [[ $target_os == "illumos" ]]; then
ptime -m cargo xtask live-tests
fi

# We expect the seed CRDB to be placed here, so we explicitly remove it so the
# rmdir check below doesn't get triggered. Nextest doesn't have support for
# teardown scripts so this is the best we've got.
Expand Down
43 changes: 43 additions & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ members = [
"internal-dns",
"ipcc",
"key-manager",
"live-tests",
"live-tests/macros",
"nexus",
"nexus-config",
"nexus-sled-agent-shared",
Expand Down Expand Up @@ -170,6 +172,9 @@ default-members = [
"internal-dns",
"ipcc",
"key-manager",
# Do not include live-tests in the list of default members because its tests
# only work in a deployed system. The macros can be here, though.
"live-tests/macros",
"nexus",
"nexus-config",
"nexus-sled-agent-shared",
Expand Down Expand Up @@ -404,6 +409,7 @@ libc = "0.2.156"
libfalcon = { git = "https://github.com/oxidecomputer/falcon", rev = "e69694a1f7cc9fe31fab27f321017280531fb5f7" }
libnvme = { git = "https://github.com/oxidecomputer/libnvme", rev = "dd5bb221d327a1bc9287961718c3c10d6bd37da0" }
linear-map = "1.2.0"
live-tests-macros = { path = "live-tests/macros" }
macaddr = { version = "1.0.1", features = ["serde_std"] }
maplit = "1.0.2"
mockall = "0.13"
Expand Down
2 changes: 2 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ Nextest https://github.com/nextest-rs/nextest/issues/16[does not support doctest

Similarly, you can run tests inside a https://github.com/oxidecomputer/falcon[Falcon] based VM. This is described in the `test-utils` https://github.com/oxidecomputer/omicron/tree/main/test-utils[README].

There's also a xref:./live-tests/README.adoc[`live-tests`] test suite that can be run by hand in a _deployed_ Omicron system.

=== rustfmt and clippy

You can **format the code** using `cargo fmt`. Make sure to run this before pushing changes. The CI checks that the code is correctly formatted.
Expand Down
2 changes: 2 additions & 0 deletions dev-tools/xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ workspace = true
# downstream binaries do depend on it.)
anyhow.workspace = true
camino.workspace = true
camino-tempfile.workspace = true
cargo_toml = "0.20"
cargo_metadata.workspace = true
clap.workspace = true
Expand All @@ -32,5 +33,6 @@ macaddr.workspace = true
serde.workspace = true
swrite.workspace = true
tabled.workspace = true
textwrap.workspace = true
toml.workspace = true
usdt.workspace = true
1 change: 1 addition & 0 deletions dev-tools/xtask/src/check_workspace_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ pub fn run_cmd() -> Result<()> {
// The tests here should not be run by default, as they require
// a running control plane.
"end-to-end-tests",
"omicron-live-tests",
]
.contains(&package.name.as_str())
.then_some(&package.id)
Expand Down
25 changes: 3 additions & 22 deletions dev-tools/xtask/src/clippy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

//! Subcommand: cargo xtask clippy

use anyhow::{bail, Context, Result};
use crate::common::run_subcmd;
use anyhow::Result;
use clap::Parser;
use std::process::Command;

Expand Down Expand Up @@ -51,25 +52,5 @@ pub fn run_cmd(args: ClippyArgs) -> Result<()> {
.arg("--deny")
.arg("warnings");

eprintln!(
"running: {:?} {}",
&cargo,
command
.get_args()
.map(|arg| format!("{:?}", arg.to_str().unwrap()))
.collect::<Vec<_>>()
.join(" ")
);

let exit_status = command
.spawn()
.context("failed to spawn child process")?
.wait()
.context("failed to wait for child process")?;

if !exit_status.success() {
bail!("clippy failed: {}", exit_status);
}

Ok(())
run_subcmd(command)
}
34 changes: 34 additions & 0 deletions dev-tools/xtask/src/common.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! Common xtask command helpers

use anyhow::{bail, Context, Result};
use std::process::Command;

/// Runs the given command, printing some basic debug information around it, and
/// failing with an error message if the command does not exit successfully
pub fn run_subcmd(mut command: Command) -> Result<()> {
eprintln!(
"running: {} {}",
command.get_program().to_str().unwrap(),
command
.get_args()
.map(|arg| format!("{:?}", arg.to_str().unwrap()))
.collect::<Vec<_>>()
.join(" ")
);

let exit_status = command
.spawn()
.context("failed to spawn child process")?
.wait()
.context("failed to wait for child process")?;

if !exit_status.success() {
bail!("failed: {}", exit_status);
}

Ok(())
}
Loading
Loading