fix(test): stub all migrations in migration_engine join-wait. Refs EventHub/EventHubBack#42
CI / test (push) Successful in 27m9s
CI / deploy-ift (push) Failing after 3m35s
CI / e2e-ift (push) Has been skipped
CI / deploy-stage (push) Has been skipped
CI / e2e-stage (push) Has been skipped

This commit is contained in:
2026-07-18 10:40:12 +03:00
parent dd754e28cc
commit 1cd7c2e402
+14 -9
View File
@@ -3,6 +3,14 @@
-include("records.hrl"). -include("records.hrl").
-define(LOCK_VERSION, "__migration_lock__"). -define(LOCK_VERSION, "__migration_lock__").
%% Keep in sync with migration_engine:?ALL_MIGRATIONS (atom → string version).
-define(ALL_VERSIONS, [
"20260501120000_base_schema",
"20260504150000_test_migration",
"20260716230000_ticket_source_and_hash_index",
"20260717180000_stats_counters",
"20260717190000_admin_stats_indexes"
]).
setup() -> setup() ->
mnesia:stop(), mnesia:stop(),
@@ -37,9 +45,9 @@ test_ensure_applied() ->
Status = migration_engine:status(), Status = migration_engine:status(),
?assertEqual([], maps:get(pending, Status)), ?assertEqual([], maps:get(pending, Status)),
Applied = maps:get(applied, Status), Applied = maps:get(applied, Status),
?assert(lists:member("20260501120000_base_schema", Applied)), lists:foreach(fun(V) ->
?assert(lists:member("20260504150000_test_migration", Applied)), ?assert(lists:member(V, Applied))
?assert(lists:member("20260716230000_ticket_source_and_hash_index", Applied)). end, ?ALL_VERSIONS).
test_ensure_applied_idempotent() -> test_ensure_applied_idempotent() ->
?assertEqual(ok, migration_engine:ensure_applied()), ?assertEqual(ok, migration_engine:ensure_applied()),
@@ -55,12 +63,9 @@ test_join_wait() ->
mnesia:dirty_write(#schema_migration{version = ?LOCK_VERSION, applied_at = Now}), mnesia:dirty_write(#schema_migration{version = ?LOCK_VERSION, applied_at = Now}),
spawn(fun() -> spawn(fun() ->
timer:sleep(100), timer:sleep(100),
mnesia:dirty_write(#schema_migration{ lists:foreach(fun(V) ->
version = "20260501120000_base_schema", applied_at = Now}), mnesia:dirty_write(#schema_migration{version = V, applied_at = Now})
mnesia:dirty_write(#schema_migration{ end, ?ALL_VERSIONS),
version = "20260504150000_test_migration", applied_at = Now}),
mnesia:dirty_write(#schema_migration{
version = "20260716230000_ticket_source_and_hash_index", applied_at = Now}),
mnesia:dirty_delete({schema_migration, ?LOCK_VERSION}) mnesia:dirty_delete({schema_migration, ?LOCK_VERSION})
end), end),
?assertEqual(ok, migration_engine:ensure_applied()). ?assertEqual(ok, migration_engine:ensure_applied()).