Skip to content
Merged
Changes from all commits
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
22 changes: 11 additions & 11 deletions pkg/autoscaler/metrics/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestMetricCollectorScraper(t *testing.T) {
mtp.Channel <- now
var gotRPS, gotConcurrency, panicRPS, panicConcurrency float64
// Poll to see that the async loop completed.
wait.PollImmediate(10*time.Millisecond, 1*time.Second, func() (bool, error) {
wait.PollImmediate(10*time.Millisecond, 2*time.Second, func() (bool, error) {
gotConcurrency, panicConcurrency, _ = coll.StableAndPanicConcurrency(metricKey, now)
gotRPS, panicRPS, _ = coll.StableAndPanicRPS(metricKey, now)
return gotConcurrency == wantConcurrency &&
Expand All @@ -164,10 +164,10 @@ func TestMetricCollectorScraper(t *testing.T) {
})

if _, _, err := coll.StableAndPanicConcurrency(metricKey, now); err != nil {
t.Errorf("StableAndPanicConcurrency = %v", err)
t.Errorf("StableAndPanicConcurrency() = %v", err)
}
if _, _, err := coll.StableAndPanicRPS(metricKey, now); err != nil {
t.Errorf("StableAndPanicRPS = %v", err)
t.Errorf("StableAndPanicRPS() = %v", err)
}
if panicConcurrency != wantPConcurrency {
t.Errorf("PanicConcurrency() = %v, want %v", panicConcurrency, wantPConcurrency)
Expand All @@ -187,16 +187,16 @@ func TestMetricCollectorScraper(t *testing.T) {
mtp.Channel <- now

// Wait for async loop to finish.
wait.PollImmediate(10*time.Millisecond, 1*time.Second, func() (bool, error) {
wait.PollImmediate(10*time.Millisecond, 2*time.Second, func() (bool, error) {
gotConcurrency, _, _ = coll.StableAndPanicConcurrency(metricKey, now.Add(defaultMetric.Spec.StableWindow).Add(-5*time.Second))
gotRPS, _, _ = coll.StableAndPanicRPS(metricKey, now.Add(defaultMetric.Spec.StableWindow).Add(-5*time.Second))
return gotConcurrency == reportConcurrency*5 && gotRPS == reportRPS*5, nil
})
if gotConcurrency != reportConcurrency*5 {
t.Errorf("StableAndPanicConcurrency() = %v, want %v", gotConcurrency, wantConcurrency)
t.Errorf("StableAndPanicConcurrency() = %v, want %v", gotConcurrency, reportConcurrency*5)
}
if gotRPS != reportRPS*5 {
t.Errorf("StableAndPanicRPS() = %v, want %v", gotRPS, wantRPS)
t.Errorf("StableAndPanicRPS() = %v, want %v", gotRPS, reportRPS*5)
}

// Deleting the metric should cause a calculation error.
Expand Down Expand Up @@ -239,10 +239,10 @@ func TestMetricCollectorNoScraper(t *testing.T) {
gotConcurrency, panicConcurrency, errCon := coll.StableAndPanicConcurrency(metricKey, now)
gotRPS, panicRPS, errRPS := coll.StableAndPanicRPS(metricKey, now)
if errCon != nil {
t.Errorf("StableAndPanicConcurrency = %v", errCon)
t.Errorf("StableAndPanicConcurrency() = %v", errCon)
}
if errRPS != nil {
t.Errorf("StableAndPanicRPS = %v", errRPS)
t.Errorf("StableAndPanicRPS() = %v", errRPS)
}
if panicConcurrency != wantStat {
t.Errorf("PanicConcurrency() = %v, want %v", panicConcurrency, wantStat)
Expand Down Expand Up @@ -270,7 +270,7 @@ func TestMetricCollectorNoScraper(t *testing.T) {
gotConcurrency, _, _ = coll.StableAndPanicConcurrency(metricKey, now)
gotRPS, _, err := coll.StableAndPanicRPS(metricKey, now)
if err != nil {
t.Errorf("StableAndPanicRPS = %v", err)
t.Errorf("StableAndPanicRPS() = %v", err)
}
if gotRPS != wantRC {
t.Errorf("StableRPS() = %v, want %v", gotRPS, wantRC)
Expand Down Expand Up @@ -304,10 +304,10 @@ func TestMetricCollectorNoDataError(t *testing.T) {
_, _, errCon := coll.StableAndPanicConcurrency(metricKey, now)
_, _, errRPS := coll.StableAndPanicRPS(metricKey, now)
if errCon != ErrNoData {
t.Errorf("StableAndPanicConcurrency = %v", errCon)
t.Errorf("StableAndPanicConcurrency() = %v", errCon)
}
if errRPS != ErrNoData {
t.Errorf("StableAndPanicRPS = %v", errRPS)
t.Errorf("StableAndPanicRPS() = %v", errRPS)
}
}

Expand Down