Verify outgoing request persistence and document commit boundary
This commit is contained in:
1 parent
93e81841ba
commit
ceedf828ed
3 files changed
+76
-1
No files matched your search
@@ -482,11 +482,36 @@ static void test_outgoing_rollback_failure(void) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_MEDIA, "PASS outgoing requests: rollback failure stops core without event/send or rearming timer");
|
||||
}
|
||||
|
||||
static void test_outgoing_restart(void) {
|
||||
struct fixture f; setup(&f);
|
||||
for (int unavailable = 0; unavailable < 3; unavailable++) {
|
||||
outgoing_reset(&f, 0);
|
||||
if (!unavailable) f.route_up = 0;
|
||||
else if (unavailable == 1) f.room = 0;
|
||||
else f.send_rc = -1;
|
||||
outgoing_tick(&f, 1, unavailable == 2);
|
||||
struct snapshot saved = snapshot(&f);
|
||||
chat_event_set_handler(f.inst, NULL); active = NULL; utun_instance_destroy(f.inst);
|
||||
char config[1024];
|
||||
snprintf(config, sizeof(config), "[global]\ndb_path=%s\n[ntp]\nenabled=no\n"
|
||||
"[chatserver]\ngroup_autoconnect=0\nstorage_autoload=0\n", f.directory);
|
||||
f.inst = utun_instance_create_from_str(f.ua, config);
|
||||
assert(f.inst && !utun_core_start(f.inst) && !chat_service_start(f.inst));
|
||||
f.route.inst = f.inst; f.route_up = f.room = 1; f.send_rc = 0; active = &f;
|
||||
chat_event_set_handler(f.inst, event);
|
||||
struct snapshot restored = snapshot(&f);
|
||||
assert(restored.exists && restored.incoming == 0 && restored.state == 0 && restored.command == 1 && restored.retry == 0);
|
||||
assert(restored.created == saved.created); outgoing_tick(&f, 0, 1);
|
||||
}
|
||||
cleanup(&f);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_MEDIA, "PASS outgoing requests: no route/backpressure/send error preserve queue and date across real instance restart");
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
debug_config_init(); debug_set_level(DEBUG_LEVEL_ERROR); debug_set_category_level(DEBUG_CATEGORY_MEDIA, DEBUG_LEVEL_INFO);
|
||||
utun_instance_set_tun_init_enabled(0); size_t baseline = u_get_allocated_count();
|
||||
if (argc != 2 || strcmp(argv[1], "--outgoing")) { test_faults(); test_controls(); test_ack_retry(); test_rollback_failure(); }
|
||||
test_outgoing_controls(); test_outgoing_faults(); test_outgoing_rollback_failure();
|
||||
test_outgoing_controls(); test_outgoing_faults(); test_outgoing_restart(); test_outgoing_rollback_failure();
|
||||
assert(!fault && !fail_rollback && u_get_allocated_count() == baseline);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_MEDIA, "PASS attachment requests: reader before ACK/events, stable duplicate date, neighboring key and allocations preserved");
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user