refactor(gateway): remove voice reconciliation v3 (#2601)

This commit is contained in:
Hampus
2026-09-08 19:17:48 +02:00
committed by GitHub
parent ef067f36c6
commit ce08f82a92
17 changed files with 79 additions and 792 deletions
+32 -50
View File
@@ -123,56 +123,6 @@ pending_connection_timeout_preserves_active_voice_state_test() ->
)
).
reconcile_absent_connections_removes_matching_voice_state_test() ->
UserId = 42,
OtherUserId = 84,
SessionId = <<"session-42">>,
OtherSessionId = <<"session-84">>,
ConnectionId = <<"conn-42">>,
OtherConnectionId = <<"conn-84">>,
Ref = monitor(process, self()),
OtherRef = monitor(process, self()),
VoiceState = #{
<<"user_id">> => <<"42">>,
<<"channel_id">> => <<"1">>,
<<"connection_id">> => ConnectionId
},
OtherVoiceState = #{
<<"user_id">> => <<"84">>,
<<"channel_id">> => <<"1">>,
<<"connection_id">> => OtherConnectionId
},
State = new_call_test_state(#{
voice_states => #{UserId => VoiceState, OtherUserId => OtherVoiceState},
sessions => #{
SessionId => {UserId, self(), Ref},
OtherSessionId => {OtherUserId, self(), OtherRef}
},
pending_connections => #{ConnectionId => #{user_id => UserId}},
initiator_ready => true
}),
Absent = [
#{
connection_id => ConnectionId,
user_id => UserId,
channel_id => 1,
guild_id => null,
region_id => <<"local">>,
server_id => <<"s1">>,
pending => false
}
],
{noreply, NewState} = call_voice:reconcile_absent_connections(Absent, State),
?assertNot(maps:is_key(UserId, maps:get(voice_states, NewState))),
?assert(maps:is_key(OtherUserId, maps:get(voice_states, NewState))),
?assertNot(maps:is_key(SessionId, maps:get(sessions, NewState))),
?assertNot(maps:is_key(ConnectionId, maps:get(pending_connections, NewState))),
receive
{'$gen_cast', {call_force_disconnect, 1, ConnectionId}} -> ok
after 1000 ->
?assert(false, force_disconnect_not_sent)
end.
leave_then_rejoin_keeps_voice_state_test() ->
UserId = 42,
OtherUserId = 84,
@@ -264,6 +214,38 @@ disconnect_user_if_in_channel_notifies_session_cleanup_test() ->
?assert(false)
end.
disconnect_user_if_in_channel_ignores_a_stale_connection_id_test() ->
UserId = 42,
SessionId = <<"session-42">>,
LiveConnectionId = <<"conn-live">>,
StaleConnectionId = <<"conn-stale">>,
VoiceState = #{
<<"user_id">> => <<"42">>,
<<"channel_id">> => <<"1">>,
<<"connection_id">> => LiveConnectionId
},
State = new_call_test_state(#{
voice_states => #{UserId => VoiceState},
sessions => #{SessionId => {UserId, self(), make_ref()}},
initiator_ready => true
}),
{reply, Reply, NewState} = call:handle_call(
{disconnect_user_if_in_channel, UserId, 1, StaleConnectionId},
{self(), make_ref()},
State
),
?assertMatch(#{ignored := true, reason := <<"not_in_call">>}, Reply),
?assertEqual(
VoiceState,
maps:get(UserId, maps:get(voice_states, NewState), undefined)
),
receive
{'$gen_cast', {call_force_disconnect, _, _}} ->
?assert(false, force_disconnected_a_live_connection)
after 200 ->
ok
end.
leave_removes_voice_state_count_without_full_rebuild_test() ->
UserId = 42,
SessionId = <<"session-count-leave">>,
@@ -16,9 +16,7 @@ default_config() ->
<<"max_concurrent_guild_starts">> => 256,
<<"gateway_dispatch_relay_shards">> => 32,
<<"gateway_dispatch_relay_max_queue">> => 50000,
<<"voice_e2ee_scope">> => <<"guild_feature_only">>,
<<"voice_reconciliation_v3_percentage">> => 100,
<<"voice_reconciliation_v3_interval_ms">> => 2000
<<"voice_e2ee_scope">> => <<"guild_feature_only">>
}.
default_config_has_expected_keys_test() ->
@@ -29,9 +27,7 @@ default_config_has_expected_keys_test() ->
?assertEqual(100, maps:get(<<"guild_rollout_percentage">>, Config)),
?assertEqual(10000, maps:get(<<"rpc_request_timeout_ms">>, Config)),
?assertEqual(512, maps:get(<<"max_concurrent_session_starts">>, Config)),
?assertEqual(256, maps:get(<<"max_concurrent_guild_starts">>, Config)),
?assertEqual(100, maps:get(<<"voice_reconciliation_v3_percentage">>, Config)),
?assertEqual(2000, maps:get(<<"voice_reconciliation_v3_interval_ms">>, Config)).
?assertEqual(256, maps:get(<<"max_concurrent_guild_starts">>, Config)).
is_session_eligible_full_rollout_test() ->
persistent_term:put(?PERSISTENT_TERM_KEY, default_config()),
@@ -234,24 +230,6 @@ validate_config_rejects_rpc_timeout_above_maximum_test() ->
)
).
validate_config_rejects_voice_reconciliation_v3_interval_below_minimum_test() ->
?assertMatch(
{error, {invalid_field, <<"voice_reconciliation_v3_interval_ms">>, 499}},
gateway_rollout_config_validate:validate(
#{<<"voice_reconciliation_v3_interval_ms">> => 499},
default_config()
)
).
validate_config_rejects_voice_reconciliation_v3_percentage_above_maximum_test() ->
?assertMatch(
{error, {invalid_field, <<"voice_reconciliation_v3_percentage">>, 101}},
gateway_rollout_config_validate:validate(
#{<<"voice_reconciliation_v3_percentage">> => 101},
default_config()
)
).
validate_config_rejects_relay_max_queue_zero_test() ->
?assertMatch(
{error, {invalid_field, <<"gateway_dispatch_relay_max_queue">>, 0}},