Skip to content

Commit

Permalink
include successful metric emission in TestProxyProtocols
Browse files Browse the repository at this point in the history
  • Loading branch information
ransford-stripe committed Nov 30, 2022
1 parent 1b14b4e commit f98f253
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion pkg/smokescreen/smokescreen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,22 @@ func TestProxyProtocols(t *testing.T) {
client.Do(req)
clientCh <- true
}()

<-clientCh

// Metrics should show one successful connection and a corresponding successful
// DNS request along with its timing metric.
tmc, ok := cfg.MetricsClient.(*metrics.MockMetricsClient)
r.True(ok)
i, err := tmc.GetCount("cn.atpt.total", "success:true")
r.NoError(err)
r.Equal(i, uint64(1))
lookups, err := tmc.GetCount("resolver.attempts_total")
r.NoError(err)
r.Equal(lookups, uint64(1))
ltime, err := tmc.GetCount("resolver.lookup_time")
r.NoError(err)
r.Equal(ltime, uint64(1))

entry := findCanonicalProxyDecision(logHook.AllEntries())
r.NotNil(entry)

Expand Down Expand Up @@ -611,6 +625,20 @@ func TestProxyProtocols(t *testing.T) {
serverCh <- true
<-clientCh

// Metrics should show one successful connection and a corresponding successful
// DNS request along with its timing metric.
tmc, ok := cfg.MetricsClient.(*metrics.MockMetricsClient)
r.True(ok)
i, err := tmc.GetCount("cn.atpt.total", "success:true")
r.NoError(err)
r.Equal(i, uint64(1))
lookups, err := tmc.GetCount("resolver.attempts_total")
r.NoError(err)
r.Equal(lookups, uint64(1))
ltime, err := tmc.GetCount("resolver.lookup_time")
r.NoError(err)
r.Equal(ltime, uint64(1))

entry := findCanonicalProxyDecision(logHook.AllEntries())
r.NotNil(entry)
r.Contains(entry.Data, "proxy_type")
Expand Down

0 comments on commit f98f253

Please sign in to comment.