Add ruleguard and open ruleguard check

Signed-off-by: cai.zhang <cai.zhang@zilliz.com>
pull/4973/head^2
cai.zhang 2020-11-13 10:00:32 +08:00 committed by yefu.chen
parent b68322d469
commit cfee642a11
5 changed files with 7 additions and 7 deletions

View File

@ -42,9 +42,9 @@ lint:
ruleguard:
@echo "Running $@ check"
@${GOPATH}/bin/ruleguard -rules ruleguard.rules.go ./internal/... || true
@${GOPATH}/bin/ruleguard -rules ruleguard.rules.go ./cmd/... || true
@${GOPATH}/bin/ruleguard -rules ruleguard.rules.go ./test/... || true
@${GOPATH}/bin/ruleguard -rules ruleguard.rules.go ./internal/...
@${GOPATH}/bin/ruleguard -rules ruleguard.rules.go ./cmd/...
@${GOPATH}/bin/ruleguard -rules ruleguard.rules.go ./test/...
verifiers: get-check-deps fmt lint ruleguard

View File

@ -87,7 +87,7 @@ func (gta *GlobalTSOAllocator) GenerateTSO(count uint32) (uint64, error) {
for i := 0; i < maxRetryCount; i++ {
current := (*atomicObject)(atomic.LoadPointer(&gta.tso.TSO))
if current == nil || current.physical == typeutil.ZeroTime {
if current == nil || current.physical.Equal(typeutil.ZeroTime) {
// If it's leader, maybe SyncTimestamp hasn't completed yet
log.Println("sync hasn't completed yet, wait for a while")
time.Sleep(200 * time.Millisecond)

View File

@ -35,7 +35,7 @@ func TestGlobalTSOAllocator_GenerateTSO(t *testing.T) {
for i := 0; i < count; i++ {
ts, _ := GTsoAllocator.GenerateTSO(perCount)
physical, logical := tsoutil.ParseTS(ts)
if lastPhysical == physical {
if lastPhysical.Equal(physical) {
diff := logical - lastLogical
assert.Equal(t, uint64(perCount), diff)
}

View File

@ -76,7 +76,7 @@ func TestTimeTick(t *testing.T) {
return
}
if tsm.Timestamp <= lastTimestamp {
t.Fatalf("current = %d, last = %d", uint64(tsm.Timestamp), uint64(lastTimestamp))
t.Fatalf("current = %d, last = %d", tsm.Timestamp, lastTimestamp)
}
t.Log("current = ", tsm.Timestamp)
lastTimestamp = tsm.Timestamp

View File

@ -137,7 +137,7 @@ func sendMsgFromCmd(ctx context.Context, fg *TimeTickedFlowGraph) {
return
}
// assert result
if res != math.Pow(num, 2)+math.Sqrt(num) {
if res-(math.Pow(num, 2)+math.Sqrt(num)) > 0.000001 {
fmt.Println(res)
fmt.Println(math.Pow(num, 2) + math.Sqrt(num))
panic("wrong answer")