test(functests): migration/MUC/timestamp tests, group rebalancing
All checks were successful
CI Code / Check spelling (pull_request) Successful in 24s
CI Code / Check coding style (pull_request) Successful in 41s
CI Code / Linux (ubuntu) (pull_request) Successful in 6m56s
CI Code / Linux (debian) (pull_request) Successful in 7m0s
CI Code / Code Coverage (pull_request) Successful in 7m5s
CI Code / Linux (arch) (pull_request) Successful in 9m29s

Add 11 new export/import tests (24 → 35): 4 MUC database, 3 timestamp
verification, 3 migration stress, 1 LMC correction with negative assert.

Add delay-stamp timestamp checks to 5 base tests via /time chat set
iso8601 and /history on (previously passed by accident from PTY buffer).

Replace magic numbers: NEGATIVE_ASSERT_TIMEOUT, MIN_ELAPSED_INIT.
Add per-test slow/fast thresholds and TZ override (prof_test_tz).

Rebalance groups by whole logical blocks (spread 46s → 3s):
G1=52s G2=50s G3=53s G4=53s. All 129 tests pass.
This commit is contained in:
2026-03-19 19:05:36 +03:00
parent 2b1b70665b
commit 58002409ff
5 changed files with 1211 additions and 61 deletions

View File

@@ -14,11 +14,11 @@
* flaky tests caused by leftover state. The overhead is acceptable since
* functional tests run less frequently than unit tests.
*
* Tests are organized into groups for better maintainability and parallel execution:
* Group 1: Connect, Ping, Rooms, Software, Last Activity, Autoping, Disco
* Group 2: Message, Receipts, Roster, Export/Import (+SQLite)
* Group 3: Presence, Disconnect, DB History
* Group 4: Chat Session, MUC, Carbons
* Tests are organized into groups balanced for parallel execution:
* Group 1: Connect, Ping, Rooms, Software, Last Activity, Autoping, Disco, Roster
* Group 2: Export/Import (core + bidirectional), Receipts
* Group 3: Presence, Disconnect, DB History, Message, MUC Database
* Group 4: Chat Session, MUC, Carbons, Migration Stress
*
* Parallel execution:
* ./functionaltests - run all tests sequentially
@@ -61,7 +61,19 @@
#endif
/* Macro to wrap each test with setup/teardown functions */
#define PROF_FUNC_TEST(test) cmocka_unit_test_setup_teardown(test, init_prof_test, close_prof_test)
#define PROF_FUNC_TEST(test) { #test, test, init_prof_test, close_prof_test, #test }
#ifdef HAVE_SQLITE
/* Custom init that sets a non-UTC timezone (POSIX TST-3 = UTC+3) */
static int
init_tz_plus3_test(void** state)
{
prof_test_tz = "TST-3";
int ret = init_prof_test(state);
prof_test_tz = "UTC";
return ret;
}
#endif
int
main(int argc, char* argv[])
@@ -83,8 +95,8 @@ main(int argc, char* argv[])
fprintf(stderr, "[PROF_TEST] Starting functional tests, group=%d\n", group);
/* ============================================================
* GROUP 1: Connect, Ping, Rooms, Software, Last Activity, Disco
* Basic XMPP session establishment and server queries
* GROUP 1: Connect, Ping, Rooms, Software, Last Activity, Disco, Roster
* Basic XMPP session establishment, server queries, contact mgmt
* ============================================================ */
const struct CMUnitTest group1_tests[] = {
/* Connection tests - verify login, roster, bookmarks */
@@ -141,11 +153,18 @@ main(int argc, char* argv[])
PROF_FUNC_TEST(disco_info_without_name),
PROF_FUNC_TEST(disco_items_without_name),
PROF_FUNC_TEST(disco_info_service_unavailable),
/* Roster management - add/remove/rename contacts */
PROF_FUNC_TEST(sends_new_item),
PROF_FUNC_TEST(sends_new_item_nick),
PROF_FUNC_TEST(sends_remove_item),
PROF_FUNC_TEST(sends_remove_item_nick),
PROF_FUNC_TEST(sends_nick_change),
};
/* ============================================================
* GROUP 2: Message, Receipts, Roster, Export/Import
* Core messaging and contact management
* GROUP 2: Export/Import (core + bidirectional), Receipts
* Cross-backend migration, message timestamp round-trip
* ============================================================ */
const struct CMUnitTest group2_tests[] = {
#ifdef HAVE_SQLITE
@@ -160,29 +179,26 @@ main(int argc, char* argv[])
PROF_FUNC_TEST(verify_after_export),
PROF_FUNC_TEST(switch_backends_independent_messages),
PROF_FUNC_TEST(export_empty_contact),
#endif
/* Basic message send/receive */
PROF_FUNC_TEST(message_send),
PROF_FUNC_TEST(message_receive_console),
PROF_FUNC_TEST(message_receive_chatwin),
/* Bidirectional migration — split timelines merged across backends */
PROF_FUNC_TEST(bidirectional_merge_to_flatfile),
PROF_FUNC_TEST(bidirectional_merge_to_sqlite),
PROF_FUNC_TEST(migration_incremental_accumulation),
PROF_FUNC_TEST(roundtrip_full_cycle),
PROF_FUNC_TEST(export_timestamps_preserved),
PROF_FUNC_TEST(import_timestamps_preserved),
{ "export_timestamps_non_utc", export_timestamps_non_utc, init_tz_plus3_test, close_prof_test, "export_timestamps_non_utc" },
#endif
/* Message receipts - XEP-0184 */
PROF_FUNC_TEST(does_not_send_receipt_request_to_barejid),
PROF_FUNC_TEST(send_receipt_request),
PROF_FUNC_TEST(send_receipt_on_request),
/* Roster management - add/remove/rename contacts */
PROF_FUNC_TEST(sends_new_item),
PROF_FUNC_TEST(sends_new_item_nick),
PROF_FUNC_TEST(sends_remove_item),
PROF_FUNC_TEST(sends_remove_item_nick),
PROF_FUNC_TEST(sends_nick_change),
};
/* ============================================================
* GROUP 3: Presence, Disconnect, DB History
* Status management, clean teardown, message persistence
* GROUP 3: Presence, Disconnect, DB History, Message, MUC Database
* Status management, message persistence, MUC storage
* ============================================================ */
const struct CMUnitTest group3_tests[] = {
/* Presence - online/away/xa/dnd/chat status management */
@@ -218,11 +234,24 @@ main(int argc, char* argv[])
PROF_FUNC_TEST(message_db_history_service_chars),
PROF_FUNC_TEST(message_db_history_verify),
PROF_FUNC_TEST(message_db_history_lmc),
/* Basic message send/receive */
PROF_FUNC_TEST(message_send),
PROF_FUNC_TEST(message_receive_console),
PROF_FUNC_TEST(message_receive_chatwin),
#ifdef HAVE_SQLITE
/* MUC (groupchat) database — export/import of type="muc" messages */
PROF_FUNC_TEST(muc_export_sqlite_to_flatfile),
PROF_FUNC_TEST(muc_import_flatfile_to_sqlite),
PROF_FUNC_TEST(muc_export_timestamps_preserved),
PROF_FUNC_TEST(muc_export_multiple_rooms),
#endif
};
/* ============================================================
* GROUP 4: Chat Session, MUC, Carbons
* Session routing, multi-user chat, message synchronization
* GROUP 4: Chat Session, MUC, Carbons, Migration Stress
* Session routing, multi-user chat, message sync, stress tests
* ============================================================ */
const struct CMUnitTest group4_tests[] = {
/* Chat session management - bare/full JID routing */
@@ -265,6 +294,13 @@ main(int argc, char* argv[])
PROF_FUNC_TEST(receive_carbon),
PROF_FUNC_TEST(receive_self_carbon),
PROF_FUNC_TEST(receive_private_carbon),
#ifdef HAVE_SQLITE
/* Migration stress — pool accumulation, LMC chains, large bodies */
PROF_FUNC_TEST(export_message_pool_dated),
PROF_FUNC_TEST(export_lmc_pool_multiple),
PROF_FUNC_TEST(export_large_body_survives),
#endif
};
/* Test group registry for easy extension */
@@ -274,10 +310,10 @@ main(int argc, char* argv[])
const struct CMUnitTest* tests;
size_t count;
} groups[] = {
{ "Group 1: Connect/Ping/Rooms/Software/LastActivity/Autoping/Disco", group1_tests, ARRAY_SIZE(group1_tests) },
{ "Group 2: Message/Receipts/Roster/ExportImport", group2_tests, ARRAY_SIZE(group2_tests) },
{ "Group 3: Presence/Disconnect/DBHistory", group3_tests, ARRAY_SIZE(group3_tests) },
{ "Group 4: Session/MUC/Carbons", group4_tests, ARRAY_SIZE(group4_tests) },
{ "Group 1: Connect/Ping/Disco/Roster", group1_tests, ARRAY_SIZE(group1_tests) },
{ "Group 2: ExportImport/Receipts", group2_tests, ARRAY_SIZE(group2_tests) },
{ "Group 3: Presence/Disconnect/DBHistory/Message/MUC-DB", group3_tests, ARRAY_SIZE(group3_tests) },
{ "Group 4: Session/MUC/Carbons/MigrationStress", group4_tests, ARRAY_SIZE(group4_tests) },
};
const int num_groups = ARRAY_SIZE(groups);