From f326808d15a7e73fe09b102ffaeea61dd1903139 Mon Sep 17 00:00:00 2001 From: graham Date: Sat, 28 Mar 2026 15:57:19 -0500 Subject: [PATCH] fix: increase timeout in flaky debounce test (#210) The test was using 75ms timeout which was too tight: - 5 broadcasts with 5ms delays = 25ms - Debounce delay = 50ms - Processing overhead = variable Increased to 200ms to match other similar tests in the file and provide adequate buffer for debouncing + processing. Also reformatted proto erlang_compat files to fix line length issues. Reviewed-on: https://git.mcintire.me/graham/towerops-web/pulls/210 --- lib/towerops/proto/erlang_compat_decode.ex | 22 +++++++++++++++---- lib/towerops/proto/erlang_compat_encode.ex | 9 +++++--- .../channels/agent_channel_test.exs | 5 +++-- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/lib/towerops/proto/erlang_compat_decode.ex b/lib/towerops/proto/erlang_compat_decode.ex index becbbffa..09b8598b 100644 --- a/lib/towerops/proto/erlang_compat_decode.ex +++ b/lib/towerops/proto/erlang_compat_decode.ex @@ -141,10 +141,24 @@ defmodule :towerops@proto@decode do end defp metric_to_gleam({:neighbor_discovery, %Types.NeighborDiscovery{} = nd}) do - {:neighbor_discovery_metric, - {:neighbor_discovery, nd.interface_id, nd.protocol, nd.remote_chassis_id, nd.remote_system_name, - nd.remote_system_description, nd.remote_platform, nd.remote_port_id, nd.remote_port_description, nd.remote_address, - nd.remote_capabilities, nd.timestamp}} + { + :neighbor_discovery_metric, + { + :neighbor_discovery, + nd.interface_id, + nd.protocol, + nd.remote_chassis_id, + nd.remote_system_name, + # credo:disable-for-next-line Credo.Check.Readability.MaxLineLength + nd.remote_system_description, + nd.remote_platform, + nd.remote_port_id, + nd.remote_port_description, + nd.remote_address, + nd.remote_capabilities, + nd.timestamp + } + } end # Stub implementations for less critical functions diff --git a/lib/towerops/proto/erlang_compat_encode.ex b/lib/towerops/proto/erlang_compat_encode.ex index 7716d52c..8bd5dc0d 100644 --- a/lib/towerops/proto/erlang_compat_encode.ex +++ b/lib/towerops/proto/erlang_compat_encode.ex @@ -447,9 +447,12 @@ defmodule :towerops@proto@encode do :none -> nil - {:some, - {:snmp_device, ip, community, version, port, v3_security_level, v3_username, v3_auth_protocol, v3_auth_password, - v3_priv_protocol, v3_priv_password, transport}} -> + { + :some, + # credo:disable-for-next-line Credo.Check.Readability.MaxLineLength + {:snmp_device, ip, community, version, port, v3_security_level, v3_username, v3_auth_protocol, v3_auth_password, + v3_priv_protocol, v3_priv_password, transport} + } -> %Types.SnmpDevice{ ip: ip, community: community, diff --git a/test/towerops_web/channels/agent_channel_test.exs b/test/towerops_web/channels/agent_channel_test.exs index e4f0102e..55a5d276 100644 --- a/test/towerops_web/channels/agent_channel_test.exs +++ b/test/towerops_web/channels/agent_channel_test.exs @@ -1538,10 +1538,11 @@ defmodule ToweropsWeb.AgentChannelTest do end # Should only receive ONE jobs message (debounced) - 50ms debounce in test - assert_push "jobs", %{binary: _jobs_binary}, 75 + # Use 200ms timeout to account for debounce delay + processing time + assert_push "jobs", %{binary: _jobs_binary}, 200 # Should NOT receive additional jobs messages - refute_push "jobs", _, 50 + refute_push "jobs", _, 100 end end end