Skip to content

Commit b00b7e5

Browse files
Bootstrap rooted metadata fixtures through their actual database configuration (#95)
Use production rooted metadata provisioning for ordinary snapshot, view operations, and native push fixtures. Retain schema ownership, generic history behavior, native queue timing, and all existing test assertions. Validation is source-only: owned nightly format checks and Git whitespace checks; native builds, database tests, and performance runs are deferred.
1 parent 17790ae commit b00b7e5

3 files changed

Lines changed: 33 additions & 8 deletions

File tree

‎src/api/router/snapshot_content_tests.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ impl Fixture {
679679
config.mst2.auth_token = Some(TOKEN.to_string());
680680
let backend = build_object_storage(&config.object_storage).await.unwrap();
681681
let counts = Arc::new(ReadCounts::default());
682-
let (mut storage, schema) = if rebuildable {
682+
let (mut storage, schema) = if rebuildable || !generic_history {
683683
let (database, schema) = test_db_config(temp.path()).await;
684684
config.database = database;
685685
let assembly = async {

‎src/jupiter/service/native_publication_push_tests.rs‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,36 @@ use crate::jupiter::utils::converter::FromMegaModel;
88

99
const NATIVE_INSTANCE: &str = "6ab219b0-4275-45ba-9d7b-7b0b633018cd";
1010

11-
async fn native_fixture() -> (tempfile::TempDir, crate::jupiter::storage::Storage, git_internal::internal::object::commit::Commit, String) {
11+
async fn native_fixture() -> (
12+
tempfile::TempDir,
13+
crate::jupiter::storage::Storage,
14+
git_internal::internal::object::commit::Commit,
15+
String,
16+
) {
1217
let temp = tempfile::tempdir().unwrap();
1318
let mut config = crate::config::testing::isolated_config(temp.path().join("config"));
1419
config.monorepo.push_policy = PushPolicy::Trunk;
1520
config.mst2.enabled = true;
1621
config.mst2.publication_enabled = true;
1722
config.mst2.instance_uuid = Some(NATIVE_INSTANCE.to_owned());
18-
let storage = crate::jupiter::tests::test_storage_with_config(temp.path(), config).await;
23+
let (database, schema) = crate::jupiter::tests::test_db_config(temp.path()).await;
24+
config.database = database;
25+
let mut connection = crate::jupiter::storage::init::database_connection(&config.database)
26+
.await
27+
.unwrap();
28+
connection.set_metric_callback(move |_| {
29+
let _held_by_the_connection = &schema;
30+
});
31+
let mut storage = crate::jupiter::storage::Storage::new_with_connection(
32+
Arc::new(config),
33+
Arc::new(connection),
34+
crate::jupiter::storage::object_storage::mock_object_storage(),
35+
)
36+
.await
37+
.unwrap();
38+
storage.push_queue_service = storage
39+
.push_queue_service
40+
.with_timeouts(Duration::from_secs(30), Duration::from_millis(20));
1941
let storage = crate::jupiter::tests::with_test_vault(storage, temp.path()).await;
2042
let name = format!("native-{}", uuid::Uuid::new_v4().simple());
2143
use git_internal::internal::object::{

‎src/jupiter/storage/view_ops_tests.rs‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ use crate::{
1515
ceres::view::filter::parse_for_registration,
1616
config::testing::isolated_config,
1717
jupiter::{
18-
migration::apply_migrations,
1918
service::{
2019
view_metrics::ViewMetrics,
2120
view_projection_service::{CatchUpOutcome, ViewProjectionService},
2221
},
2322
storage::{
2423
Storage,
2524
git_db_storage::fu18_support::single_connection,
25+
init::database_connection,
2626
object_storage::mock_object_storage,
2727
view_root_chain::RootChainOutcome,
2828
view_storage::ViewLockMode,
@@ -31,7 +31,7 @@ use crate::{
3131
seed_unrelated_root_history,
3232
},
3333
},
34-
tests::test_db_connection,
34+
tests::{TestSchemaGuard, test_db_config},
3535
},
3636
};
3737

@@ -58,6 +58,7 @@ struct OpsFixture {
5858
filter_a: i64,
5959
filter_b: i64,
6060
filter_a_id: String,
61+
_schema: TestSchemaGuard,
6162
}
6263

6364
fn fixed_time() -> chrono::NaiveDateTime {
@@ -222,9 +223,10 @@ async fn insert_warming_filter(
222223

223224
async fn ops_fixture() -> OpsFixture {
224225
let temp = tempfile::tempdir().unwrap();
225-
let db = test_db_connection(temp.path()).await;
226-
apply_migrations(&db, true).await.unwrap();
227-
let config = isolated_config(temp.path().join("config"));
226+
let (database, schema) = test_db_config(temp.path()).await;
227+
let mut config = isolated_config(temp.path().join("config"));
228+
config.database = database;
229+
let db = database_connection(&config.database).await.unwrap();
228230
let storage = Storage::new_with_connection(
229231
Arc::new(config),
230232
Arc::new(db.clone()),
@@ -406,6 +408,7 @@ async fn ops_fixture() -> OpsFixture {
406408
filter_a: filter_a.id,
407409
filter_b: filter_b.id,
408410
filter_a_id: filter_a.filter_id,
411+
_schema: schema,
409412
}
410413
}
411414

0 commit comments

Comments
 (0)