Skip to content

Commit

Permalink
Make statistics check eventuallly
Browse files Browse the repository at this point in the history
  • Loading branch information
zolia committed Feb 27, 2020
1 parent 70f2ece commit 66cbefe
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion e2e/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ func consumerConnectFlow(t *testing.T, tequilapi *tequilapi_client.Client, consu
assert.Equal(t, "New", se.Status)

// Wait some time for session to collect stats.
time.Sleep(4 * time.Second)
if serviceType != "noop" {
assert.Eventually(t, sessionStatsReceived(tequilapi), 10*time.Second, 1*time.Second)
}

err = tequilapi.ConnectionDestroy()
assert.NoError(t, err)
Expand All @@ -181,6 +183,17 @@ func consumerConnectFlow(t *testing.T, tequilapi *tequilapi_client.Client, consu
serviceTypeAssertionMap[serviceType](t, se)
}

func sessionStatsReceived(tequilapi *tequilapi_client.Client) func() bool {
return func() bool {
stats, err := tequilapi.ConnectionStatistics()
if err != nil {
return false
}
log.Info().Msgf("sessions stats: %v", stats)
return stats.BytesReceived > 0 && stats.BytesSent > 0
}
}

type sessionAsserter func(t *testing.T, session tequilapi_client.ConnectionSessionDTO)

var serviceTypeAssertionMap = map[string]sessionAsserter{
Expand Down

0 comments on commit 66cbefe

Please sign in to comment.