mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-09 20:50:20 +08:00
fix(gateway): complete worker registration cleanup
This commit is contained in:
@@ -7,7 +7,7 @@ use tracing::info;
|
||||
// Generated by build.rs from schema/bootstrap/postgres.
|
||||
pub(crate) static EMPTY_DATABASE_SNAPSHOT_SQL: &str =
|
||||
include_str!(concat!(env!("OUT_DIR"), "/empty_database_snapshot.sql"));
|
||||
pub(crate) const EMPTY_DATABASE_SNAPSHOT_CUTOFF_VERSION: i64 = 20260727000000;
|
||||
pub(crate) const EMPTY_DATABASE_SNAPSHOT_CUTOFF_VERSION: i64 = 20260731000000;
|
||||
|
||||
const PUBLIC_BASE_TABLE_COUNT_SQL: &str = r#"
|
||||
SELECT COUNT(*)::BIGINT
|
||||
|
||||
@@ -410,6 +410,7 @@ fn empty_database_snapshot_covers_current_cutoff_versions() {
|
||||
20260718010000,
|
||||
20260720000000,
|
||||
20260727000000,
|
||||
20260731000000,
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -983,6 +984,43 @@ fn mysql_and_sqlite_migrations_do_not_use_postgres_jsonb() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn worker_boot_cleanup_migration_is_enabled_for_every_driver() {
|
||||
const VERSION: i64 = 20260731000000;
|
||||
|
||||
for (driver, migrator) in [
|
||||
("postgres", &POSTGRES_MIGRATOR),
|
||||
("mysql", &super::mysql::MIGRATOR),
|
||||
("sqlite", &super::sqlite::MIGRATOR),
|
||||
] {
|
||||
let migration = migrator
|
||||
.iter()
|
||||
.find(|migration| migration.version == VERSION)
|
||||
.unwrap_or_else(|| panic!("{driver} worker boot cleanup migration should be embedded"));
|
||||
let sql = migration.sql.as_ref();
|
||||
|
||||
for required in [
|
||||
"DELETE FROM background_task_events",
|
||||
"DELETE FROM background_task_runs",
|
||||
"id LIKE 'boot:%'",
|
||||
"owner_instance IS NOT NULL",
|
||||
"created_by = 'system'",
|
||||
"progress_message = 'worker booted'",
|
||||
] {
|
||||
assert!(
|
||||
sql.contains(required),
|
||||
"{driver} worker boot cleanup migration is missing {required}"
|
||||
);
|
||||
}
|
||||
|
||||
assert!(
|
||||
sql.find("DELETE FROM background_task_events")
|
||||
< sql.find("DELETE FROM background_task_runs"),
|
||||
"{driver} must delete child events before worker boot runs"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mysql_and_sqlite_migrations_include_enabled_incrementals() {
|
||||
let mysql_versions = super::mysql::MIGRATOR
|
||||
@@ -1025,6 +1063,7 @@ fn mysql_and_sqlite_migrations_include_enabled_incrementals() {
|
||||
20260725020000,
|
||||
20260725030000,
|
||||
20260727000000,
|
||||
20260731000000,
|
||||
]
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -1058,6 +1097,7 @@ fn mysql_and_sqlite_migrations_include_enabled_incrementals() {
|
||||
20260725030000,
|
||||
20260725040000,
|
||||
20260727000000,
|
||||
20260731000000,
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -2162,6 +2202,8 @@ fn pending_migrations_from_applied_skips_versions_already_applied() {
|
||||
20260718000000,
|
||||
20260718010000,
|
||||
20260720000000,
|
||||
20260727000000,
|
||||
20260731000000,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user