Skip to content

Commit

Permalink
Merge pull request open-telemetry#97 from IshwarKanse/rebase-bot-main
Browse files Browse the repository at this point in the history
  • Loading branch information
openshift-merge-bot[bot] authored Oct 16, 2024
2 parents 442f582 + b9780e4 commit 020f0b4
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions cmd/otel-allocator/watcher/promOperator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ func TestRateLimit(t *testing.T) {
},
}
events := make(chan Event, 1)
eventInterval := 5 * time.Millisecond
eventInterval := 500 * time.Millisecond
cfg := allocatorconfig.Config{}

w, _ := getTestPrometheusCRWatcher(t, nil, nil, cfg)
Expand Down Expand Up @@ -1006,10 +1006,10 @@ func TestRateLimit(t *testing.T) {
default:
return false
}
}, eventInterval*2, time.Millisecond)
}, time.Second*5, eventInterval/10)

// it's difficult to measure the rate precisely
// what we do, is send two updates, and then assert that the elapsed time is between eventInterval and 3*eventInterval
// what we do, is send two updates, and then assert that the elapsed time is at least eventInterval
startTime := time.Now()
_, err = w.kubeMonitoringClient.MonitoringV1().ServiceMonitors("test").Update(context.Background(), serviceMonitor, metav1.UpdateOptions{})
require.NoError(t, err)
Expand All @@ -1020,7 +1020,7 @@ func TestRateLimit(t *testing.T) {
default:
return false
}
}, eventInterval*2, time.Millisecond)
}, time.Second*5, eventInterval/10)
_, err = w.kubeMonitoringClient.MonitoringV1().ServiceMonitors("test").Update(context.Background(), serviceMonitor, metav1.UpdateOptions{})
require.NoError(t, err)
require.Eventually(t, func() bool {
Expand All @@ -1030,11 +1030,9 @@ func TestRateLimit(t *testing.T) {
default:
return false
}
}, eventInterval*2, time.Millisecond)
}, time.Second*5, eventInterval/10)
elapsedTime := time.Since(startTime)
assert.Less(t, eventInterval, elapsedTime)
assert.GreaterOrEqual(t, eventInterval*3, elapsedTime)

}

// getTestPrometheusCRWatcher creates a test instance of PrometheusCRWatcher with fake clients
Expand Down

0 comments on commit 020f0b4

Please sign in to comment.