Skip to content

Commit 51d8a05

Browse files
test: disable direct connections for a deterministic reachable peers metric (#19458)
closes coder/internal#921 Not sure what I was thinking when I wrote this test case, but it was relying on the connection being p2p on every ping, which is technically and evidently not always the case. Instead we'll require a DERP peer, and block direct connections.
1 parent bfd392b commit 51d8a05

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

agent/agent_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3470,7 +3470,11 @@ func TestAgent_Metrics_SSH(t *testing.T) {
34703470
registry := prometheus.NewRegistry()
34713471

34723472
//nolint:dogsled
3473-
conn, _, _, _, _ := setupAgent(t, agentsdk.Manifest{}, 0, func(_ *agenttest.Client, o *agent.Options) {
3473+
conn, _, _, _, _ := setupAgent(t, agentsdk.Manifest{
3474+
// Make sure we always get a DERP connection for
3475+
// currently_reachable_peers.
3476+
DisableDirectConnections: true,
3477+
}, 0, func(_ *agenttest.Client, o *agent.Options) {
34743478
o.PrometheusRegistry = registry
34753479
})
34763480

@@ -3524,7 +3528,7 @@ func TestAgent_Metrics_SSH(t *testing.T) {
35243528
{
35253529
Name: "coderd_agentstats_currently_reachable_peers",
35263530
Type: proto.Stats_Metric_GAUGE,
3527-
Value: 0,
3531+
Value: 1,
35283532
Labels: []*proto.Stats_Metric_Label{
35293533
{
35303534
Name: "connection_type",
@@ -3535,7 +3539,7 @@ func TestAgent_Metrics_SSH(t *testing.T) {
35353539
{
35363540
Name: "coderd_agentstats_currently_reachable_peers",
35373541
Type: proto.Stats_Metric_GAUGE,
3538-
Value: 1,
3542+
Value: 0,
35393543
Labels: []*proto.Stats_Metric_Label{
35403544
{
35413545
Name: "connection_type",

0 commit comments

Comments
 (0)