Skip to content

Commit a427796

Browse files
authored
test: deflake TestRerank_RecordRequestCompletion (#1505)
**Description** Resolves #1478 Signed-off-by: Takeshi Yoneda <[email protected]>
1 parent 8d406a1 commit a427796

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/metrics/rerank_metrics_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package metrics
77

88
import (
99
"testing"
10+
"testing/synctest"
1011
"time"
1112

1213
"github.com/stretchr/testify/assert"
@@ -145,6 +146,11 @@ func TestRerank_Labels_SetModel_RequestAndResponseDiffer(t *testing.T) {
145146
}
146147

147148
func TestRerank_RecordRequestCompletion(t *testing.T) {
149+
// Virtualize time.Sleep to avoid any flaky test behavior.
150+
synctest.Test(t, testRerankRecordRequestCompletion)
151+
}
152+
153+
func testRerankRecordRequestCompletion(t *testing.T) {
148154
mr := sdkmetric.NewManualReader()
149155
meter := sdkmetric.NewMeterProvider(sdkmetric.WithReader(mr)).Meter("test")
150156
rr := NewRerankFactory(meter, nil)().(*rerank)

0 commit comments

Comments
 (0)