Skip to content

Commit

Permalink
Try a few times
Browse files Browse the repository at this point in the history
  • Loading branch information
enocom committed Oct 8, 2024
1 parent 2ab767e commit 545ff59
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,27 @@ func dump[T any](t *testing.T, data T) string {
func wantLastValueMetric(t *testing.T, wantName string, ms []metric, wantValue int) {
t.Helper()
gotNames := make(map[string]view.AggregationData)
for _, m := range ms {
if strings.Contains(m.name, "open_connections") {
fmt.Printf("RISHABH DEBUG calling wantLastValueMetric() => name: %v, value: %v\n", m.name, m.data)
for i := 0; i < 10; i++ {
for _, m := range ms {
if strings.Contains(m.name, "open_connections") {
fmt.Printf("RISHABH DEBUG calling wantLastValueMetric() => name: %v, value: %v\n", m.name, m.data)
}
gotNames[m.name] = m.data
}
ad, ok := gotNames[wantName]
if !ok {
time.Sleep(10 * time.Millisecond)
continue
}
gotNames[m.name] = m.data
}
ad, ok := gotNames[wantName]
if ok {
lvd, ok := ad.(*view.LastValueData)
if ok {
if lvd.Value == float64(wantValue) {
return
}
if !ok {
time.Sleep(10 * time.Millisecond)
continue
}
if lvd.Value == float64(wantValue) {
return
}
time.Sleep(10 * time.Millisecond)
}
t.Fatalf(
"want metric LastValueData{name = %q, value = %v}, got metrics = %v",
Expand Down

0 comments on commit 545ff59

Please sign in to comment.