Skip to content

Commit

Permalink
move tso to pkg
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Feb 2, 2023
1 parent 6ca9a33 commit c5203c4
Show file tree
Hide file tree
Showing 18 changed files with 27 additions and 27 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion server/grpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ import (
"github.com/tikv/pd/pkg/errs"
"github.com/tikv/pd/pkg/storage/endpoint"
"github.com/tikv/pd/pkg/storage/kv"
"github.com/tikv/pd/pkg/tso"
"github.com/tikv/pd/pkg/utils/grpcutil"
"github.com/tikv/pd/pkg/utils/logutil"
"github.com/tikv/pd/pkg/utils/tsoutil"
"github.com/tikv/pd/pkg/versioninfo"
"github.com/tikv/pd/server/cluster"
"github.com/tikv/pd/server/tso"
"go.etcd.io/etcd/clientv3"
"go.uber.org/zap"
"google.golang.org/grpc"
Expand Down
2 changes: 1 addition & 1 deletion server/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/tikv/pd/pkg/core/storelimit"
"github.com/tikv/pd/pkg/encryption"
"github.com/tikv/pd/pkg/errs"
"github.com/tikv/pd/pkg/tso"
"github.com/tikv/pd/pkg/utils/apiutil"
"github.com/tikv/pd/pkg/utils/syncutil"
"github.com/tikv/pd/server/cluster"
Expand All @@ -44,7 +45,6 @@ import (
"github.com/tikv/pd/server/schedulers"
"github.com/tikv/pd/server/statistics"
"github.com/tikv/pd/server/storage"
"github.com/tikv/pd/server/tso"
"go.uber.org/zap"
)

Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"github.com/tikv/pd/pkg/storage/endpoint"
"github.com/tikv/pd/pkg/storage/kv"
"github.com/tikv/pd/pkg/systimemon"
"github.com/tikv/pd/pkg/tso"
"github.com/tikv/pd/pkg/utils/apiutil"
"github.com/tikv/pd/pkg/utils/etcdutil"
"github.com/tikv/pd/pkg/utils/grpcutil"
Expand All @@ -66,7 +67,6 @@ import (
"github.com/tikv/pd/server/schedule/hbstream"
"github.com/tikv/pd/server/schedule/placement"
"github.com/tikv/pd/server/storage"
"github.com/tikv/pd/server/tso"
"go.etcd.io/etcd/clientv3"
"go.etcd.io/etcd/embed"
"go.etcd.io/etcd/pkg/types"
Expand Down
6 changes: 3 additions & 3 deletions tests/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ import (
"github.com/tikv/pd/pkg/core"
"github.com/tikv/pd/pkg/mock/mockid"
"github.com/tikv/pd/pkg/storage/endpoint"
"github.com/tikv/pd/pkg/tso"
"github.com/tikv/pd/pkg/utils/assertutil"
"github.com/tikv/pd/pkg/utils/testutil"
"github.com/tikv/pd/pkg/utils/tsoutil"
"github.com/tikv/pd/pkg/utils/typeutil"
"github.com/tikv/pd/server"
"github.com/tikv/pd/server/config"
"github.com/tikv/pd/server/tso"
"github.com/tikv/pd/tests"
"go.uber.org/goleak"
)
Expand Down Expand Up @@ -238,15 +238,15 @@ func TestUpdateAfterResetTSO(t *testing.T) {
return err == nil
})
// Transfer leader back.
re.NoError(failpoint.Enable("github.com/tikv/pd/server/tso/delaySyncTimestamp", `return(true)`))
re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/tso/delaySyncTimestamp", `return(true)`))
err = cluster.GetServer(newLeaderName).ResignLeader()
re.NoError(err)
// Should NOT panic here.
testutil.Eventually(re, func() bool {
_, _, err := cli.GetTS(context.TODO())
return err == nil
})
re.NoError(failpoint.Disable("github.com/tikv/pd/server/tso/delaySyncTimestamp"))
re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/tso/delaySyncTimestamp"))
}

func TestTSOAllocatorLeader(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion tests/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/tikv/pd/pkg/errs"
"github.com/tikv/pd/pkg/id"
"github.com/tikv/pd/pkg/swaggerserver"
"github.com/tikv/pd/pkg/tso"
"github.com/tikv/pd/pkg/utils/testutil"
"github.com/tikv/pd/server"
"github.com/tikv/pd/server/api"
Expand All @@ -41,7 +42,6 @@ import (
"github.com/tikv/pd/server/config"
"github.com/tikv/pd/server/join"
"github.com/tikv/pd/server/keyspace"
"github.com/tikv/pd/server/tso"
"go.etcd.io/etcd/clientv3"
)

Expand Down
2 changes: 1 addition & 1 deletion tests/server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/tikv/pd/pkg/dashboard"
"github.com/tikv/pd/pkg/id"
"github.com/tikv/pd/pkg/mock/mockid"
"github.com/tikv/pd/pkg/tso"
"github.com/tikv/pd/pkg/utils/testutil"
"github.com/tikv/pd/pkg/utils/tsoutil"
"github.com/tikv/pd/pkg/utils/typeutil"
Expand All @@ -44,7 +45,6 @@ import (
syncer "github.com/tikv/pd/server/region_syncer"
"github.com/tikv/pd/server/schedule/operator"
"github.com/tikv/pd/server/storage"
"github.com/tikv/pd/server/tso"
"github.com/tikv/pd/tests"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down
2 changes: 1 addition & 1 deletion tests/server/tso/allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import (
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/stretchr/testify/require"
"github.com/tikv/pd/pkg/slice"
"github.com/tikv/pd/pkg/tso"
"github.com/tikv/pd/pkg/utils/etcdutil"
"github.com/tikv/pd/pkg/utils/testutil"
"github.com/tikv/pd/server/config"
"github.com/tikv/pd/server/tso"
"github.com/tikv/pd/tests"
)

Expand Down
18 changes: 9 additions & 9 deletions tests/server/tso/consistency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import (
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/tikv/pd/pkg/tso"
"github.com/tikv/pd/pkg/utils/grpcutil"
"github.com/tikv/pd/pkg/utils/testutil"
"github.com/tikv/pd/pkg/utils/tsoutil"
"github.com/tikv/pd/server/config"
"github.com/tikv/pd/server/tso"
"github.com/tikv/pd/tests"
)

Expand Down Expand Up @@ -226,9 +226,9 @@ func (suite *tsoConsistencyTestSuite) TestSynchronizedGlobalTSOOverflow() {

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
suite.NoError(failpoint.Enable("github.com/tikv/pd/server/tso/globalTSOOverflow", `return(true)`))
suite.NoError(failpoint.Enable("github.com/tikv/pd/pkg/tso/globalTSOOverflow", `return(true)`))
suite.getTimestampByDC(ctx, cluster, tso.GlobalDCLocation)
suite.NoError(failpoint.Disable("github.com/tikv/pd/server/tso/globalTSOOverflow"))
suite.NoError(failpoint.Disable("github.com/tikv/pd/pkg/tso/globalTSOOverflow"))
}

func (suite *tsoConsistencyTestSuite) TestLocalAllocatorLeaderChange() {
Expand Down Expand Up @@ -326,7 +326,7 @@ func (suite *tsoConsistencyTestSuite) TestLocalTSOAfterMemberChanged() {
time.Sleep(time.Second * 5)

// Mock the situation that the system time of PD nodes in dc-4 is slower than others.
suite.NoError(failpoint.Enable("github.com/tikv/pd/server/tso/systemTimeSlow", `return(true)`))
suite.NoError(failpoint.Enable("github.com/tikv/pd/pkg/tso/systemTimeSlow", `return(true)`))

// Join a new dc-location
pd4, err := cluster.Join(suite.ctx, func(conf *config.Config, serverName string) {
Expand All @@ -343,7 +343,7 @@ func (suite *tsoConsistencyTestSuite) TestLocalTSOAfterMemberChanged() {
))
suite.testTSO(cluster, dcLocationConfig, previousTS)

suite.NoError(failpoint.Disable("github.com/tikv/pd/server/tso/systemTimeSlow"))
suite.NoError(failpoint.Disable("github.com/tikv/pd/pkg/tso/systemTimeSlow"))
}

func (suite *tsoConsistencyTestSuite) testTSO(cluster *tests.TestCluster, dcLocationConfig map[string]string, previousTS *pdpb.Timestamp) {
Expand Down Expand Up @@ -401,8 +401,8 @@ func TestFallbackTSOConsistency(t *testing.T) {
re := require.New(t)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
re.NoError(failpoint.Enable("github.com/tikv/pd/server/tso/fallBackSync", `return(true)`))
re.NoError(failpoint.Enable("github.com/tikv/pd/server/tso/fallBackUpdate", `return(true)`))
re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/tso/fallBackSync", `return(true)`))
re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/tso/fallBackUpdate", `return(true)`))
var err error
cluster, err := tests.NewTestCluster(ctx, 1)
re.NoError(err)
Expand All @@ -415,8 +415,8 @@ func TestFallbackTSOConsistency(t *testing.T) {
grpcPDClient := testutil.MustNewGrpcClient(re, server.GetAddr())
svr := server.GetServer()
svr.Close()
re.NoError(failpoint.Disable("github.com/tikv/pd/server/tso/fallBackSync"))
re.NoError(failpoint.Disable("github.com/tikv/pd/server/tso/fallBackUpdate"))
re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/tso/fallBackSync"))
re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/tso/fallBackUpdate"))
re.NoError(svr.Run())
cluster.WaitLeader()
var wg sync.WaitGroup
Expand Down
6 changes: 3 additions & 3 deletions tests/server/tso/global_tso_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import (
"github.com/pingcap/failpoint"
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/stretchr/testify/require"
"github.com/tikv/pd/pkg/tso"
"github.com/tikv/pd/pkg/utils/grpcutil"
"github.com/tikv/pd/pkg/utils/testutil"
"github.com/tikv/pd/pkg/utils/typeutil"
"github.com/tikv/pd/server/config"
"github.com/tikv/pd/server/tso"
"github.com/tikv/pd/tests"
)

Expand Down Expand Up @@ -171,7 +171,7 @@ func TestDelaySyncTimestamp(t *testing.T) {
DcLocation: tso.GlobalDCLocation,
}

re.NoError(failpoint.Enable("github.com/tikv/pd/server/tso/delaySyncTimestamp", `return(true)`))
re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/tso/delaySyncTimestamp", `return(true)`))

// Make the old leader resign and wait for the new leader to get a lease
leaderServer.ResignLeader()
Expand All @@ -185,7 +185,7 @@ func TestDelaySyncTimestamp(t *testing.T) {
resp, err := tsoClient.Recv()
re.NoError(err)
re.NotNil(checkAndReturnTimestampResponse(re, req, resp))
re.NoError(failpoint.Disable("github.com/tikv/pd/server/tso/delaySyncTimestamp"))
re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/tso/delaySyncTimestamp"))
}

func TestLogicalOverflow(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions tests/server/tso/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (

"github.com/pingcap/failpoint"
"github.com/stretchr/testify/require"
"github.com/tikv/pd/pkg/tso"
"github.com/tikv/pd/pkg/utils/etcdutil"
"github.com/tikv/pd/pkg/utils/testutil"
"github.com/tikv/pd/server/config"
"github.com/tikv/pd/server/tso"
"github.com/tikv/pd/tests"
"go.etcd.io/etcd/clientv3"
)
Expand Down Expand Up @@ -160,15 +160,15 @@ func TestNextLeaderKey(t *testing.T) {
})
defer cluster.Destroy()
re.NoError(err)
re.NoError(failpoint.Enable("github.com/tikv/pd/server/tso/injectNextLeaderKey", "return(true)"))
re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/tso/injectNextLeaderKey", "return(true)"))
re.NoError(cluster.RunInitialServers())

cluster.WaitLeader(tests.WithWaitInterval(5*time.Second), tests.WithRetryTimes(3))
// To speed up the test, we force to do the check
cluster.CheckClusterDCLocation()
originName := cluster.WaitAllocatorLeader("dc-1", tests.WithRetryTimes(5), tests.WithWaitInterval(5*time.Second))
re.Equal("", originName)
re.NoError(failpoint.Disable("github.com/tikv/pd/server/tso/injectNextLeaderKey"))
re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/tso/injectNextLeaderKey"))
cluster.CheckClusterDCLocation()
originName = cluster.WaitAllocatorLeader("dc-1")
re.NotEqual("", originName)
Expand Down
6 changes: 3 additions & 3 deletions tests/server/tso/tso_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (
"github.com/pingcap/failpoint"
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/stretchr/testify/require"
"github.com/tikv/pd/pkg/tso"
"github.com/tikv/pd/pkg/utils/grpcutil"
"github.com/tikv/pd/pkg/utils/testutil"
"github.com/tikv/pd/server/config"
"github.com/tikv/pd/server/tso"
"github.com/tikv/pd/tests"
)

Expand All @@ -53,7 +53,7 @@ func TestLoadTimestamp(t *testing.T) {

lastTSMap := requestLocalTSOs(re, cluster, dcLocationConfig)

re.NoError(failpoint.Enable("github.com/tikv/pd/server/tso/systemTimeSlow", `return(true)`))
re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/tso/systemTimeSlow", `return(true)`))

// Reboot the cluster.
re.NoError(cluster.StopAll())
Expand All @@ -70,7 +70,7 @@ func TestLoadTimestamp(t *testing.T) {
re.Greater(newTS.GetPhysical()-lastTS.GetPhysical(), int64(0))
}

failpoint.Disable("github.com/tikv/pd/server/tso/systemTimeSlow")
failpoint.Disable("github.com/tikv/pd/pkg/tso/systemTimeSlow")
}

func requestLocalTSOs(re *require.Assertions, cluster *tests.TestCluster, dcLocationConfig map[string]string) map[string]*pdpb.Timestamp {
Expand Down

0 comments on commit c5203c4

Please sign in to comment.