fixup: massage imports for tests

This commit is contained in:
Vlad Lazar
2025-07-25 19:09:06 +01:00
parent d5cd2de3cf
commit 07396d3fc7
3 changed files with 29 additions and 14 deletions

10
Cargo.lock generated
View File

@@ -1915,6 +1915,7 @@ dependencies = [
"chrono",
"diesel_derives",
"itoa",
"pq-sys",
"serde_json",
"uuid",
]
@@ -5467,6 +5468,15 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "pq-sys"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6cc05d7ea95200187117196eee9edd0644424911821aeb28a18ce60ea0b8793"
dependencies = [
"vcpkg",
]
[[package]]
name = "pq_proto"
version = "0.1.0"

View File

@@ -79,3 +79,9 @@ workspace_hack = { version = "0.1", path = "../workspace_hack" }
[dev-dependencies]
postgresql_archive = "0.19.0"
postgresql_embedded = { version = "0.19.0", features = ["blocking"] }
diesel = { version = "2.2.6", features = [
"postgres",
"serde_json",
"chrono",
"uuid",
] }

View File

@@ -394,8 +394,7 @@ async fn get_pageserver_connection_info(
None => {
// This is never supposed to happen because `SELECT min()` should always return one row.
return Err(DatabaseError::Logical(format!(
"Unexpected empty query result for min(shard_count) query. Tenant ID {}",
tenant_id
"Unexpected empty query result for min(shard_count) query. Tenant ID {tenant_id}"
)));
}
};
@@ -487,9 +486,9 @@ mod test {
fn get_test_sk_node(id: u64) -> SafeKeeperNode {
SafeKeeperNode::new(
NodeId(id),
format!("safekeeper-{}", id),
format!("safekeeper-{id}"),
123,
format!("safekeeper-{}", id),
format!("safekeeper-{id}"),
456,
)
}
@@ -501,13 +500,13 @@ mod test {
let connection_string = pg.settings().url("test");
{
let mut conn = PgConnection::establish(&connection_string)
.unwrap_or_else(|_| panic!("Error connecting to {}", connection_string));
.unwrap_or_else(|_| panic!("Error connecting to {connection_string}"));
run_migrations(&mut conn).unwrap();
}
let mut connection = AsyncPgConnection::establish(&connection_string)
.await
.unwrap_or_else(|_| panic!("Error connecting to {}", connection_string));
.unwrap_or_else(|_| panic!("Error connecting to {connection_string}"));
execute_sk_upsert(&mut connection, get_test_sk_node(0).to_database_row())
.await
@@ -565,13 +564,13 @@ mod test {
let connection_string = pg.settings().url("test");
{
let mut conn = PgConnection::establish(&connection_string)
.unwrap_or_else(|_| panic!("Error connecting to {}", connection_string));
.unwrap_or_else(|_| panic!("Error connecting to {connection_string}"));
run_migrations(&mut conn).unwrap();
}
let mut connection = AsyncPgConnection::establish(&connection_string)
.await
.unwrap_or_else(|_| panic!("Error connecting to {}", connection_string));
.unwrap_or_else(|_| panic!("Error connecting to {connection_string}"));
// An initial call should insert the timeline safekeepers and return the inserted values.
let timeline1_id = TimelineId::generate();
@@ -629,13 +628,13 @@ mod test {
let connection_string = pg.settings().url("test");
{
let mut conn = PgConnection::establish(&connection_string)
.unwrap_or_else(|_| panic!("Error connecting to {}", connection_string));
.unwrap_or_else(|_| panic!("Error connecting to {connection_string}"));
run_migrations(&mut conn).unwrap();
}
let mut connection = AsyncPgConnection::establish(&connection_string)
.await
.unwrap_or_else(|_| panic!("Error connecting to {}", connection_string));
.unwrap_or_else(|_| panic!("Error connecting to {connection_string}"));
// Insert some values
let timeline1_id = TimelineId::generate();
@@ -718,12 +717,12 @@ mod test {
let connection_string = pg.settings().url("test");
{
let mut conn = PgConnection::establish(&connection_string)
.unwrap_or_else(|_| panic!("Error connecting to {}", connection_string));
.unwrap_or_else(|_| panic!("Error connecting to {connection_string}"));
run_migrations(&mut conn).unwrap();
}
let mut connection = AsyncPgConnection::establish(&connection_string)
.await
.unwrap_or_else(|_| panic!("Error connecting to {}", connection_string));
.unwrap_or_else(|_| panic!("Error connecting to {connection_string}"));
// Insert some values
let safekeeper_ids = vec![
@@ -809,7 +808,7 @@ mod test {
.safekeeper_peers
.push(TimelineSafekeeperPeer {
node_id: NodeId(i),
listen_http_addr: format!("safekeeper-{}", i),
listen_http_addr: format!("safekeeper-{i}"),
http_port: 123,
});
if i < 3 {
@@ -817,7 +816,7 @@ mod test {
.safekeeper_peers
.push(TimelineSafekeeperPeer {
node_id: NodeId(i),
listen_http_addr: format!("safekeeper-{}", i),
listen_http_addr: format!("safekeeper-{i}"),
http_port: 123,
});
expected_responses[3]