Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix metric checking tests #87

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ var (
// search for any request metrics between startTime and time.Now() for particular request methods
// if testedmethods is empty, all metrics in timeframe are returned.
func findMetricsInWindowForMethods(db database.PostgresClient, startTime time.Time, testedmethods []string) []database.ProxiedRequestMetric {
endTime := time.Now()
// add small buffer into future in case metrics are still being created
endTime := time.Now().Add(100 * time.Millisecond)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could source from an environment variable and set to higher values in ci if tests are being flaky


var nextCursor int64
var proxiedRequestMetrics []database.ProxiedRequestMetric
Expand Down Expand Up @@ -151,7 +152,7 @@ func waitForMetricsInWindow(

// besides verification, waiting for the metrics ensures future tests don't fail b/c metrics are being processed
require.Eventually(t, func() bool {
metrics = findMetricsInWindowForMethods(db, startTime, []string{})
metrics = findMetricsInWindowForMethods(db, startTime, testedmethods)
return len(metrics) >= expected
}, timeout, time.Millisecond,
fmt.Sprintf("failed to find %d metrics in %f seconds from start %s", expected, timeout.Seconds(), startTime))
Expand Down
Loading