milvus/proxy-go/proxy_node/timestamporacle_test.go
neza2017 b0189c2450 Update time sync
Signed-off-by: neza2017 <yefu.chen@zilliz.com>
2020-10-09 15:37:24 +08:00

36 lines
720 B
Go

package proxy_node
import (
"context"
"go.etcd.io/etcd/clientv3"
"testing"
"time"
)
func TestTimestampOracle(t *testing.T) {
cli, err := clientv3.New(clientv3.Config{Endpoints: []string{"127.0.0.1:2379"}})
if err != nil {
t.Fatal(err)
}
defer cli.Close()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
tso := timestampOracle{
client: cli,
ctx: ctx,
rootPath: "/proxy/tso",
saveInterval: 200,
}
tso.Restart(0)
time.Sleep(time.Second)
tso.loadTimestamp()
tso.mux.Lock()
if tso.tso.physical < 100 {
t.Fatalf("physical error")
}
t.Log("physical = ", tso.tso.physical)
tso.mux.Unlock()
ts, _ := tso.GetTimestamp(1)
t.Log("Timestamp = ", ts[0])
}