Skip to content

Commit 74b7742

Browse files
authored
Optimizations to the Nexus schema tests (#8271)
This PR optimizes several of the Nexus schema tests: - It uses a "baseline" version of dbinit.sql to avoid scaling linearly with the number of schema changes. It adds the `cargo xtask schema generate-base` command to help pull down this baseline. - This PR also adds `cargo xtask schema old-migrations` to assist with cleaning up old migrations that are before the "baseline", and are no longer supported. - It changes a few of the schema tests to compare "baseline" -> "latest" versions, rather than applying all schema changes that have ever been created. ``` $ cargo nt -p omicron-nexus -- integration_tests::schema ... PASS [ 2.152s] omicron-nexus::test_all integration_tests::schema::dbinit_version_matches_version_known_to_nexus PASS [ 8.946s] omicron-nexus::test_all integration_tests::schema::nexus_applies_update_on_boot PASS [ 10.831s] omicron-nexus::test_all integration_tests::schema::compare_table_differing_constraint PASS [ 10.861s] omicron-nexus::test_all integration_tests::schema::compare_sequence_differing_increment PASS [ 10.997s] omicron-nexus::test_all integration_tests::schema::compare_index_creation_differing_columns PASS [ 11.043s] omicron-nexus::test_all integration_tests::schema::compare_view_differing_where_clause PASS [ 11.075s] omicron-nexus::test_all integration_tests::schema::compare_table_differing_not_null_order PASS [ 11.111s] omicron-nexus::test_all integration_tests::schema::compare_index_creation_differing_where_clause PASS [ 8.621s] omicron-nexus::test_all integration_tests::schema::update_since_base_has_idempotent_up PASS [ 8.008s] omicron-nexus::test_all integration_tests::schema::validate_data_migrations PASS [ 30.662s] omicron-nexus::test_all integration_tests::schema::nexus_cannot_apply_update_from_unknown_version PASS [ 23.131s] omicron-nexus::test_all integration_tests::schema::validate_migration_from_base_version ──────────── Summary [ 34.713s] 12 tests run: 12 passed, 604 skipped ``` Fixes #10005
1 parent 0028b4e commit 74b7742

781 files changed

Lines changed: 6689 additions & 9896 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/buildomat/build-and-test.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ fi
178178
banner doctest
179179
ptime -m timeout 1h cargo test --doc --locked --verbose --no-fail-fast
180180

181+
# Verify that old migrations have been removed.
182+
#
183+
# We do this after the main build, so the dependencies of "cargo xtask schema"
184+
# have already been built, which makes this cheap(er).
185+
banner "check schema migration cleanup"
186+
ptime -m cargo xtask schema old-migrations
187+
181188
# Build the live-tests. This is only supported on illumos.
182189
# We also can't actually run them here. See the README for more details.
183190
if [[ $target_os == "illumos" ]]; then

Cargo.lock

Lines changed: 14 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ members = [
5353
"dev-tools/releng",
5454
"dev-tools/repl-utils",
5555
"dev-tools/repo-depot-standalone",
56+
"dev-tools/schema",
5657
"dev-tools/xtask",
5758
"dns-server",
5859
"dns-server-api",
@@ -230,6 +231,7 @@ default-members = [
230231
"dev-tools/releng",
231232
"dev-tools/repl-utils",
232233
"dev-tools/repo-depot-standalone",
234+
"dev-tools/schema",
233235
# Do not include xtask in the list of default members, because this causes
234236
# hakari to not work as well and build times to be longer.
235237
# See omicron#4392.

dev-tools/schema/Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "schema"
3+
version = "0.1.0"
4+
edition = "2021"
5+
license = "MPL-2.0"
6+
7+
[lints]
8+
workspace = true
9+
10+
[build-dependencies]
11+
omicron-rpaths.workspace = true
12+
13+
[dependencies]
14+
anyhow.workspace = true
15+
camino.workspace = true
16+
clap.workspace = true
17+
nexus-db-model.workspace = true
18+
omicron-workspace-hack.workspace = true
19+
pq-sys = "*"
20+
semver.workspace = true

dev-tools/schema/build.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
// See omicron-rpaths for documentation.
6+
// NOTE: This file MUST be kept in sync with the other build.rs files in this
7+
// repository.
8+
fn main() {
9+
omicron_rpaths::configure_default_omicron_rpaths();
10+
}

0 commit comments

Comments
 (0)