@@ -11,7 +11,6 @@ import (
1111 "time"
1212
1313 "github.com/pingcap/tiproxy/pkg/balance/metricsreader"
14- "github.com/pingcap/tiproxy/pkg/util/monotime"
1514 "github.com/prometheus/common/expfmt"
1615 "github.com/prometheus/common/model"
1716 "github.com/stretchr/testify/require"
@@ -85,7 +84,7 @@ func TestCPUBalanceOnce(t *testing.T) {
8584 mmr := & mockMetricsReader {
8685 qrs : map [string ]metricsreader.QueryResult {
8786 "cpu" : {
88- UpdateTime : monotime .Now (),
87+ UpdateTime : time .Now (),
8988 Value : model .Matrix (values ),
9089 },
9190 },
@@ -198,7 +197,7 @@ func TestCPUBalanceContinuously(t *testing.T) {
198197 }
199198 curTime = curTime .Add (time .Millisecond )
200199 mmr .qrs ["cpu" ] = metricsreader.QueryResult {
201- UpdateTime : monotime .Now (),
200+ UpdateTime : time .Now (),
202201 Value : model .Matrix (values ),
203202 }
204203 // Rebalance until it stops. The final scores should be newConnScores.
@@ -228,18 +227,18 @@ func TestCPUBalanceContinuously(t *testing.T) {
228227func TestNoCPUMetric (t * testing.T ) {
229228 tests := []struct {
230229 cpus [][]float64
231- updateTime monotime .Time
230+ updateTime time .Time
232231 }{
233232 {
234233 cpus : nil ,
235234 },
236235 {
237236 cpus : [][]float64 {{1.0 }, {0.0 }},
238- updateTime : monotime .Now ().Add (- cpuMetricExpDuration * 2 ),
237+ updateTime : time .Now ().Add (- cpuMetricExpDuration * 2 ),
239238 },
240239 {
241240 cpus : [][]float64 {{math .NaN ()}, {math .NaN ()}},
242- updateTime : monotime .Now (),
241+ updateTime : time .Now (),
243242 },
244243 }
245244 mmr := newMockMetricsReader ()
@@ -248,7 +247,7 @@ func TestNoCPUMetric(t *testing.T) {
248247 for i , test := range tests {
249248 values := make ([]* model.SampleStream , 0 , len (test .cpus ))
250249 for j := 0 ; j < len (test .cpus ); j ++ {
251- ss := createSampleStream (test .cpus [j ], j , model .Time (test .updateTime / monotime . Time ( time . Millisecond )))
250+ ss := createSampleStream (test .cpus [j ], j , model .TimeFromUnixNano (test .updateTime . UnixNano ( )))
252251 values = append (values , ss )
253252 }
254253 mmr .qrs ["cpu" ] = metricsreader.QueryResult {
@@ -291,7 +290,7 @@ func TestCPUResultNotUpdated(t *testing.T) {
291290 array := []float64 {test .cpu }
292291 values := []* model.SampleStream {createSampleStream (array , 0 , test .updateTime ), createSampleStream (array , 1 , test .updateTime )}
293292 mmr .qrs ["cpu" ] = metricsreader.QueryResult {
294- UpdateTime : monotime .Now (),
293+ UpdateTime : time .Now (),
295294 Value : model .Matrix (values ),
296295 }
297296 updateScore (fc , backends )
0 commit comments