-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize CockroachDB setup for tests (96% reduction) (#493)
Optimizes setup time for CRDB-based tests by seeding + copying a seeded database, rather than populating the database anew during each test. This significantly cuts down on the setup time for any test which wants to use even a simple, single-node Cockroach instance.
- Loading branch information
Showing
9 changed files
with
186 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// 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/. | ||
|
||
use dropshot::{test_util::LogContext, ConfigLogging, ConfigLoggingLevel}; | ||
use omicron_test_utils::dev::test_setup_database_seed; | ||
|
||
// Creates a "pre-populated" CockroachDB storage directory, which | ||
// subsequent tests can copy instead of creating themselves. | ||
// | ||
// Is it critical this happens at build-time? No. However, it | ||
// makes it more convenient for tests to assume this seeded | ||
// directory exists, rather than all attempting to create it | ||
// concurrently. | ||
// | ||
// Refer to the documentation of [`test_setup_database_seed`] for | ||
// more context. | ||
#[tokio::main] | ||
async fn main() { | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
println!("cargo:rerun-if-changed=../../common/src/sql/dbinit.sql"); | ||
println!("cargo:rerun-if-changed=../../tools/cockroachdb_checksums"); | ||
println!("cargo:rerun-if-changed=../../tools/cockroachdb_version"); | ||
|
||
let logctx = LogContext::new( | ||
"crdb_seeding", | ||
&ConfigLogging::StderrTerminal { level: ConfigLoggingLevel::Info }, | ||
); | ||
|
||
test_setup_database_seed(&logctx.log).await; | ||
} |
Oops, something went wrong.