Skip to content

Commit

Permalink
Add regression test for #4369
Browse files Browse the repository at this point in the history
  • Loading branch information
bnaecker committed Oct 31, 2023
1 parent 336475a commit 355ce6c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
41 changes: 40 additions & 1 deletion oximeter/db/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3484,7 +3484,7 @@ mod tests {
) -> Result<(), Error> {
use strum::IntoEnumIterator;
usdt::register_probes().unwrap();
let logctx = test_setup_log("test_update_schema_cache_on_new_sample");
let logctx = test_setup_log("test_select_all_datum_types");
let log = &logctx.log;

let client = Client::new(address, &log);
Expand Down Expand Up @@ -4007,4 +4007,43 @@ mod tests {
);
assert!(Client::verify_schema_upgrades(&map).is_err());
}

// Regression test for https://github.com/oxidecomputer/omicron/issues/4369.
//
// This tests that we can successfully query all extant field types from the
// schema table. There may be no such values, but the query itself should
// succeed.
#[tokio::test]
async fn test_select_all_field_types() {
use strum::IntoEnumIterator;
usdt::register_probes().unwrap();
let logctx = test_setup_log("test_select_all_field_types");
let log = &logctx.log;

let mut db = ClickHouseInstance::new_single_node(0)
.await
.expect("Failed to start ClickHouse");
let address = SocketAddr::new(Ipv6Addr::LOCALHOST.into(), db.port());
let client = Client::new(address, &log);
client
.init_single_node_db()
.await
.expect("Failed to initialize timeseries database");

// Attempt to select all schema with each field type.
for ty in oximeter::FieldType::iter() {
let sql = format!(
"SELECT COUNT() \
FROM {}.timeseries_schema \
WHERE arrayFirstIndex(x -> x = '{:?}', fields.type) > 0;",
crate::DATABASE_NAME,
crate::model::DbFieldType::from(ty),
);
let res = client.execute_with_body(sql).await.unwrap();
let count = res.trim().parse::<usize>().unwrap();
assert_eq!(count, 0);
}
db.cleanup().await.expect("Failed to cleanup ClickHouse server");
logctx.cleanup_successful();
}
}
1 change: 1 addition & 0 deletions oximeter/oximeter/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use uuid::Uuid;
JsonSchema,
Serialize,
Deserialize,
strum::EnumIter,
)]
#[serde(rename_all = "snake_case")]
pub enum FieldType {
Expand Down

0 comments on commit 355ce6c

Please sign in to comment.