mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00

lease uses monotimer to calculate its expiration. In this way, changing system time won't affect in lease expiration. FIX #6700
23 lines
523 B
Go
23 lines
523 B
Go
// Copyright (C) 2016 Arista Networks, Inc.
|
|
// Use of this source code is governed by the Apache License 2.0
|
|
|
|
// Package monotime provides a fast monotonic clock source.
|
|
|
|
package monotime
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestNow(t *testing.T) {
|
|
for i := 0; i < 100; i++ {
|
|
t1 := Now()
|
|
t2 := Now()
|
|
// I honestly thought that we needed >= here, but in some environments
|
|
// two consecutive calls can return the same value!
|
|
if t1 > t2 {
|
|
t.Fatalf("t1=%d should have been less than or equal to t2=%d", t1, t2)
|
|
}
|
|
}
|
|
}
|