Skip to content

Commit

Permalink
Plumb log
Browse files Browse the repository at this point in the history
  • Loading branch information
smklein committed Jun 17, 2024
1 parent 88f67aa commit 72369bb
Show file tree
Hide file tree
Showing 22 changed files with 118 additions and 68 deletions.
3 changes: 2 additions & 1 deletion dev-tools/omdb/src/bin/omdb/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ impl DbUrlOptions {
eprintln!("note: using database URL {}", &db_url);

let db_config = db::Config { url: db_url.clone() };
let pool = Arc::new(db::Pool::new_qorb_single_host(&db_config));
let pool =
Arc::new(db::Pool::new_qorb_single_host(&log.clone(), &db_config));

// Being a dev tool, we want to try this operation even if the schema
// doesn't match what we expect. So we use `DataStore::new_unchecked()`
Expand Down
20 changes: 10 additions & 10 deletions nexus/db-queries/src/db/collection_attach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ mod test {
dev::test_setup_log("test_attach_missing_collection_fails");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -886,7 +886,7 @@ mod test {
let logctx = dev::test_setup_log("test_attach_missing_resource_fails");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -923,7 +923,7 @@ mod test {
let logctx = dev::test_setup_log("test_attach_once");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -971,7 +971,7 @@ mod test {
let logctx = dev::test_setup_log("test_attach_once_synchronous");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -1020,7 +1020,7 @@ mod test {
let logctx = dev::test_setup_log("test_attach_multiple_times");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -1076,7 +1076,7 @@ mod test {
let logctx = dev::test_setup_log("test_attach_beyond_capacity_fails");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -1140,7 +1140,7 @@ mod test {
let logctx = dev::test_setup_log("test_attach_while_already_attached");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -1247,7 +1247,7 @@ mod test {
let logctx = dev::test_setup_log("test_attach_once");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -1302,7 +1302,7 @@ mod test {
let logctx = dev::test_setup_log("test_attach_deleted_resource_fails");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -1347,7 +1347,7 @@ mod test {
let logctx = dev::test_setup_log("test_attach_without_update_filter");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down
12 changes: 6 additions & 6 deletions nexus/db-queries/src/db/collection_detach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ mod test {
dev::test_setup_log("test_detach_missing_collection_fails");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -812,7 +812,7 @@ mod test {
let logctx = dev::test_setup_log("test_detach_missing_resource_fails");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -848,7 +848,7 @@ mod test {
let logctx = dev::test_setup_log("test_detach_once");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -888,7 +888,7 @@ mod test {
let logctx = dev::test_setup_log("test_detach_while_already_detached");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -952,7 +952,7 @@ mod test {
let logctx = dev::test_setup_log("test_detach_deleted_resource_fails");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -996,7 +996,7 @@ mod test {
let logctx = dev::test_setup_log("test_detach_without_update_filter");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down
16 changes: 8 additions & 8 deletions nexus/db-queries/src/db/collection_detach_many.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ mod test {
dev::test_setup_log("test_detach_missing_collection_fails");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -806,7 +806,7 @@ mod test {
dev::test_setup_log("test_detach_missing_resource_succeeds");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -847,7 +847,7 @@ mod test {
let logctx = dev::test_setup_log("test_detach_once");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -890,7 +890,7 @@ mod test {
let logctx = dev::test_setup_log("test_detach_once_synchronous");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -935,7 +935,7 @@ mod test {
let logctx = dev::test_setup_log("test_detach_while_already_detached");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -991,7 +991,7 @@ mod test {
let logctx = dev::test_setup_log("test_detach_filter_collection");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -1042,7 +1042,7 @@ mod test {
let logctx = dev::test_setup_log("test_detach_deleted_resource");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -1100,7 +1100,7 @@ mod test {
let logctx = dev::test_setup_log("test_detach_many");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down
4 changes: 2 additions & 2 deletions nexus/db-queries/src/db/collection_insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ mod test {
let logctx = dev::test_setup_log("test_collection_not_present");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down Expand Up @@ -588,7 +588,7 @@ mod test {
let logctx = dev::test_setup_log("test_collection_present");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

let conn = setup_db(&pool).await;

Expand Down
6 changes: 3 additions & 3 deletions nexus/db-queries/src/db/datastore/db_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ mod test {
let mut crdb = test_db::test_setup_database(&logctx.log).await;

let cfg = db::Config { url: crdb.pg_config().clone() };
let pool = Arc::new(db::Pool::new_qorb_single_host(&cfg));
let pool = Arc::new(db::Pool::new_qorb_single_host(&logctx.log, &cfg));
let datastore =
Arc::new(DataStore::new(&logctx.log, pool, None).await.unwrap());

Expand Down Expand Up @@ -559,7 +559,7 @@ mod test {
let mut crdb = test_db::test_setup_database(&logctx.log).await;

let cfg = db::Config { url: crdb.pg_config().clone() };
let pool = Arc::new(db::Pool::new_qorb_single_host(&cfg));
let pool = Arc::new(db::Pool::new_qorb_single_host(&logctx.log, &cfg));
let conn = pool.claim().await.unwrap();

// Mimic the layout of "schema/crdb".
Expand Down Expand Up @@ -671,7 +671,7 @@ mod test {
let mut crdb = test_db::test_setup_database(&logctx.log).await;

let cfg = db::Config { url: crdb.pg_config().clone() };
let pool = Arc::new(db::Pool::new_qorb_single_host(&cfg));
let pool = Arc::new(db::Pool::new_qorb_single_host(&logctx.log, &cfg));
let conn = pool.claim().await.unwrap();

// Mimic the layout of "schema/crdb".
Expand Down
4 changes: 2 additions & 2 deletions nexus/db-queries/src/db/datastore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ mod test {
dev::test_setup_log("test_queries_do_not_require_full_table_scan");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);
let datastore =
DataStore::new(&logctx.log, Arc::new(pool), None).await.unwrap();
let conn = datastore.pool_connection_for_tests().await.unwrap();
Expand Down Expand Up @@ -1622,7 +1622,7 @@ mod test {
let logctx = dev::test_setup_log("test_sled_ipv6_address_allocation");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = Arc::new(db::Pool::new_qorb_single_host(&cfg));
let pool = Arc::new(db::Pool::new_qorb_single_host(&logctx.log, &cfg));
let datastore =
Arc::new(DataStore::new(&logctx.log, pool, None).await.unwrap());
let opctx = OpContext::for_tests(
Expand Down
2 changes: 1 addition & 1 deletion nexus/db-queries/src/db/datastore/pub_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub async fn datastore_test(
use crate::authn;

let cfg = db::Config { url: db.pg_config().clone() };
let pool = Arc::new(db::Pool::new_qorb_single_host(&cfg));
let pool = Arc::new(db::Pool::new_qorb_single_host(&logctx.log, &cfg));
let datastore =
Arc::new(DataStore::new(&logctx.log, pool, None).await.unwrap());

Expand Down
4 changes: 2 additions & 2 deletions nexus/db-queries/src/db/explain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ mod test {
let logctx = dev::test_setup_log("test_explain_async");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);
let conn = pool.claim().await.unwrap();

create_schema(&pool).await;
Expand All @@ -169,7 +169,7 @@ mod test {
let logctx = dev::test_setup_log("test_explain_full_table_scan");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);
let conn = pool.claim().await.unwrap();

create_schema(&pool).await;
Expand Down
8 changes: 4 additions & 4 deletions nexus/db-queries/src/db/pagination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ mod test {
dev::test_setup_log("test_paginated_single_column_ascending");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

use schema::test_users::dsl;

Expand Down Expand Up @@ -437,7 +437,7 @@ mod test {
dev::test_setup_log("test_paginated_single_column_descending");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

use schema::test_users::dsl;

Expand Down Expand Up @@ -472,7 +472,7 @@ mod test {
dev::test_setup_log("test_paginated_multicolumn_ascending");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

use schema::test_users::dsl;

Expand Down Expand Up @@ -526,7 +526,7 @@ mod test {
dev::test_setup_log("test_paginated_multicolumn_descending");
let mut db = test_setup_database(&logctx.log).await;
let cfg = db::Config { url: db.pg_config().clone() };
let pool = db::Pool::new_qorb_single_host(&cfg);
let pool = db::Pool::new_qorb_single_host(&logctx.log, &cfg);

use schema::test_users::dsl;

Expand Down
Loading

0 comments on commit 72369bb

Please sign in to comment.