Skip to content

Commit

Permalink
Use a more clear package naming
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <[email protected]>
  • Loading branch information
JmPotato committed Nov 21, 2024
1 parent 7d2220f commit 4f5462e
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"github.com/tikv/pd/client/clients/metastorage"
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/sd"
sd "github.com/tikv/pd/client/servicediscovery"
"github.com/tikv/pd/client/utils"
"github.com/tikv/pd/client/utils/tlsutil"
"go.uber.org/zap"
Expand Down
2 changes: 1 addition & 1 deletion client/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/retry"
"github.com/tikv/pd/client/sd"
sd "github.com/tikv/pd/client/servicediscovery"
"go.uber.org/zap"
)

Expand Down
2 changes: 1 addition & 1 deletion client/inner_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/pingcap/log"
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/sd"
sd "github.com/tikv/pd/client/servicediscovery"
"go.uber.org/zap"
"google.golang.org/grpc"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package sd
package servicediscovery

import (
"crypto/tls"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package sd
package servicediscovery

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package sd
package servicediscovery

import (
"context"
Expand Down Expand Up @@ -190,12 +190,12 @@ func (suite *serviceClientTestSuite) TestServiceClient() {
re.False(follower.IsConnectedToLeader())
re.True(leader.IsConnectedToLeader())

re.NoError(failpoint.Enable("github.com/tikv/pd/client/sd/unreachableNetwork1", "return(true)"))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/servicediscovery/unreachableNetwork1", "return(true)"))
follower.(*pdServiceClient).checkNetworkAvailable(suite.ctx)
leader.(*pdServiceClient).checkNetworkAvailable(suite.ctx)
re.False(follower.Available())
re.False(leader.Available())
re.NoError(failpoint.Disable("github.com/tikv/pd/client/sd/unreachableNetwork1"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/servicediscovery/unreachableNetwork1"))

follower.(*pdServiceClient).checkNetworkAvailable(suite.ctx)
leader.(*pdServiceClient).checkNetworkAvailable(suite.ctx)
Expand Down Expand Up @@ -237,7 +237,7 @@ func (suite *serviceClientTestSuite) TestServiceClient() {
followerAPIClient := newPDServiceAPIClient(follower, regionAPIErrorFn)
leaderAPIClient := newPDServiceAPIClient(leader, regionAPIErrorFn)

re.NoError(failpoint.Enable("github.com/tikv/pd/client/sd/fastCheckAvailable", "return(true)"))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/servicediscovery/fastCheckAvailable", "return(true)"))

re.True(followerAPIClient.Available())
re.True(leaderAPIClient.Available())
Expand Down Expand Up @@ -269,7 +269,7 @@ func (suite *serviceClientTestSuite) TestServiceClient() {
re.True(followerAPIClient.Available())
re.True(leaderAPIClient.Available())

re.NoError(failpoint.Disable("github.com/tikv/pd/client/sd/fastCheckAvailable"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/servicediscovery/fastCheckAvailable"))
}

func (suite *serviceClientTestSuite) TestServiceClientBalancer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package sd
package servicediscovery

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion client/tso_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/pingcap/log"
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/sd"
sd "github.com/tikv/pd/client/servicediscovery"
"github.com/tikv/pd/client/utils/grpcutil"
"github.com/tikv/pd/client/utils/tlsutil"
"go.uber.org/zap"
Expand Down
2 changes: 1 addition & 1 deletion client/tso_dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/retry"
"github.com/tikv/pd/client/sd"
sd "github.com/tikv/pd/client/servicediscovery"
"github.com/tikv/pd/client/utils/timerutil"
"github.com/tikv/pd/client/utils/tsoutil"
"go.uber.org/zap"
Expand Down
2 changes: 1 addition & 1 deletion client/tso_dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/sd"
sd "github.com/tikv/pd/client/servicediscovery"
"go.uber.org/zap/zapcore"
)

Expand Down
26 changes: 13 additions & 13 deletions tests/integrations/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
"github.com/tikv/pd/client/caller"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/retry"
"github.com/tikv/pd/client/sd"
sd "github.com/tikv/pd/client/servicediscovery"
"github.com/tikv/pd/pkg/core"
"github.com/tikv/pd/pkg/mcs/utils/constant"
"github.com/tikv/pd/pkg/mock/mockid"
Expand Down Expand Up @@ -325,7 +325,7 @@ func TestTSOFollowerProxy(t *testing.T) {

func TestTSOFollowerProxyWithTSOService(t *testing.T) {
re := require.New(t)
re.NoError(failpoint.Enable("github.com/tikv/pd/client/sd/fastUpdateServiceMode", `return(true)`))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/servicediscovery/fastUpdateServiceMode", `return(true)`))
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
cluster, err := tests.NewTestAPICluster(ctx, 1)
Expand All @@ -347,7 +347,7 @@ func TestTSOFollowerProxyWithTSOService(t *testing.T) {
// TSO service does not support the follower proxy, so enabling it should fail.
err = cli.UpdateOption(opt.EnableTSOFollowerProxy, true)
re.Error(err)
re.NoError(failpoint.Disable("github.com/tikv/pd/client/sd/fastUpdateServiceMode"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/servicediscovery/fastUpdateServiceMode"))
}

// TestUnavailableTimeAfterLeaderIsReady is used to test https://github.com/tikv/pd/issues/5207
Expand Down Expand Up @@ -498,13 +498,13 @@ func (suite *followerForwardAndHandleTestSuite) TestGetRegionByFollowerForwardin

cli := setupCli(ctx, re, suite.endpoints, opt.WithForwardingOption(true))
defer cli.Close()
re.NoError(failpoint.Enable("github.com/tikv/pd/client/sd/unreachableNetwork1", "return(true)"))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/servicediscovery/unreachableNetwork1", "return(true)"))
time.Sleep(200 * time.Millisecond)
r, err := cli.GetRegion(context.Background(), []byte("a"))
re.NoError(err)
re.NotNil(r)

re.NoError(failpoint.Disable("github.com/tikv/pd/client/sd/unreachableNetwork1"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/servicediscovery/unreachableNetwork1"))
time.Sleep(200 * time.Millisecond)
r, err = cli.GetRegion(context.Background(), []byte("a"))
re.NoError(err)
Expand Down Expand Up @@ -720,7 +720,7 @@ func (suite *followerForwardAndHandleTestSuite) TestGetRegionFromFollower() {

// because we can't check whether this request is processed by followers from response,
// we can disable forward and make network problem for leader.
re.NoError(failpoint.Enable("github.com/tikv/pd/client/sd/unreachableNetwork1", fmt.Sprintf("return(\"%s\")", leader.GetAddr())))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/servicediscovery/unreachableNetwork1", fmt.Sprintf("return(\"%s\")", leader.GetAddr())))
time.Sleep(150 * time.Millisecond)
cnt = 0
for range 100 {
Expand All @@ -731,11 +731,11 @@ func (suite *followerForwardAndHandleTestSuite) TestGetRegionFromFollower() {
re.Equal(resp.Meta.Id, suite.regionID)
}
re.Equal(100, cnt)
re.NoError(failpoint.Disable("github.com/tikv/pd/client/sd/unreachableNetwork1"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/servicediscovery/unreachableNetwork1"))

// make network problem for follower.
follower := cluster.GetServer(cluster.GetFollower())
re.NoError(failpoint.Enable("github.com/tikv/pd/client/sd/unreachableNetwork1", fmt.Sprintf("return(\"%s\")", follower.GetAddr())))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/servicediscovery/unreachableNetwork1", fmt.Sprintf("return(\"%s\")", follower.GetAddr())))
time.Sleep(100 * time.Millisecond)
cnt = 0
for range 100 {
Expand All @@ -746,7 +746,7 @@ func (suite *followerForwardAndHandleTestSuite) TestGetRegionFromFollower() {
re.Equal(resp.Meta.Id, suite.regionID)
}
re.Equal(100, cnt)
re.NoError(failpoint.Disable("github.com/tikv/pd/client/sd/unreachableNetwork1"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/servicediscovery/unreachableNetwork1"))

// follower client failed will retry by leader service client.
re.NoError(failpoint.Enable("github.com/tikv/pd/server/followerHandleError", "return(true)"))
Expand All @@ -762,8 +762,8 @@ func (suite *followerForwardAndHandleTestSuite) TestGetRegionFromFollower() {
re.NoError(failpoint.Disable("github.com/tikv/pd/server/followerHandleError"))

// test after being healthy
re.NoError(failpoint.Enable("github.com/tikv/pd/client/sd/unreachableNetwork1", fmt.Sprintf("return(\"%s\")", leader.GetAddr())))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/sd/fastCheckAvailable", "return(true)"))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/servicediscovery/unreachableNetwork1", fmt.Sprintf("return(\"%s\")", leader.GetAddr())))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/servicediscovery/fastCheckAvailable", "return(true)"))
time.Sleep(100 * time.Millisecond)
cnt = 0
for range 100 {
Expand All @@ -774,8 +774,8 @@ func (suite *followerForwardAndHandleTestSuite) TestGetRegionFromFollower() {
re.Equal(resp.Meta.Id, suite.regionID)
}
re.Equal(100, cnt)
re.NoError(failpoint.Disable("github.com/tikv/pd/client/sd/unreachableNetwork1"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/sd/fastCheckAvailable"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/servicediscovery/unreachableNetwork1"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/servicediscovery/fastCheckAvailable"))
}

func (suite *followerForwardAndHandleTestSuite) TestGetTSFuture() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
pd "github.com/tikv/pd/client"
"github.com/tikv/pd/client/caller"
"github.com/tikv/pd/client/resource_group/controller"
"github.com/tikv/pd/client/sd"
sd "github.com/tikv/pd/client/servicediscovery"
"github.com/tikv/pd/pkg/mcs/resourcemanager/server"
"github.com/tikv/pd/pkg/utils/testutil"
"github.com/tikv/pd/pkg/utils/typeutil"
Expand Down
8 changes: 4 additions & 4 deletions tests/integrations/mcs/tso/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func NewAPIServerForward(re *require.Assertions) APIServerForward {
re.NoError(suite.pdLeader.BootstrapCluster())
suite.addRegions()

re.NoError(failpoint.Enable("github.com/tikv/pd/client/sd/usePDServiceMode", "return(true)"))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/servicediscovery/usePDServiceMode", "return(true)"))
suite.pdClient, err = pd.NewClientWithContext(context.Background(),
caller.TestComponent,
[]string{suite.backendEndpoints}, pd.SecurityOption{}, opt.WithMaxErrorRetry(1))
Expand All @@ -267,7 +267,7 @@ func (suite *APIServerForward) ShutDown() {
}
suite.cluster.Destroy()
suite.cancel()
re.NoError(failpoint.Disable("github.com/tikv/pd/client/sd/usePDServiceMode"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/servicediscovery/usePDServiceMode"))
}

func TestForwardTSORelated(t *testing.T) {
Expand Down Expand Up @@ -593,7 +593,7 @@ func (suite *CommonTestSuite) TestBootstrapDefaultKeyspaceGroup() {
// If `EnableTSODynamicSwitching` is disabled, the PD should not provide TSO service after the TSO server is stopped.
func TestTSOServiceSwitch(t *testing.T) {
re := require.New(t)
re.NoError(failpoint.Enable("github.com/tikv/pd/client/sd/fastUpdateServiceMode", `return(true)`))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/servicediscovery/fastUpdateServiceMode", `return(true)`))
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Expand Down Expand Up @@ -666,7 +666,7 @@ func TestTSOServiceSwitch(t *testing.T) {

// Verify PD is now providing TSO service and timestamps are monotonically increasing
re.NoError(checkTSOMonotonic(ctx, pdClient, &globalLastTS, 10))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/sd/fastUpdateServiceMode"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/servicediscovery/fastUpdateServiceMode"))
}

func checkTSOMonotonic(ctx context.Context, pdClient pd.Client, globalLastTS *uint64, count int) error {
Expand Down
22 changes: 11 additions & 11 deletions tests/integrations/tso/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
pd "github.com/tikv/pd/client"
"github.com/tikv/pd/client/caller"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/sd"
sd "github.com/tikv/pd/client/servicediscovery"
"github.com/tikv/pd/client/utils/testutil"
bs "github.com/tikv/pd/pkg/basicserver"
"github.com/tikv/pd/pkg/mcs/utils/constant"
Expand Down Expand Up @@ -267,11 +267,11 @@ func (suite *tsoClientTestSuite) TestDiscoverTSOServiceWithLegacyPath() {
failpointValue := fmt.Sprintf(`return(%d)`, keyspaceID)
// Simulate the case that the server has lower version than the client and returns no tso addrs
// in the GetClusterInfo RPC.
re.NoError(failpoint.Enable("github.com/tikv/pd/client/sd/serverReturnsNoTSOAddrs", `return(true)`))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/sd/unexpectedCallOfFindGroupByKeyspaceID", failpointValue))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/servicediscovery/serverReturnsNoTSOAddrs", `return(true)`))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/servicediscovery/unexpectedCallOfFindGroupByKeyspaceID", failpointValue))
defer func() {
re.NoError(failpoint.Disable("github.com/tikv/pd/client/sd/serverReturnsNoTSOAddrs"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/sd/unexpectedCallOfFindGroupByKeyspaceID"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/servicediscovery/serverReturnsNoTSOAddrs"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/servicediscovery/unexpectedCallOfFindGroupByKeyspaceID"))
}()

ctx, cancel := context.WithCancel(suite.ctx)
Expand Down Expand Up @@ -321,14 +321,14 @@ func (suite *tsoClientTestSuite) TestGetMinTS() {
}
wg.Wait()

re.NoError(failpoint.Enable("github.com/tikv/pd/client/sd/unreachableNetwork1", "return(true)"))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/servicediscovery/unreachableNetwork1", "return(true)"))
time.Sleep(time.Second)
testutil.Eventually(re, func() bool {
var err error
_, _, err = suite.clients[0].GetMinTS(suite.ctx)
return err == nil
})
re.NoError(failpoint.Disable("github.com/tikv/pd/client/sd/unreachableNetwork1"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/servicediscovery/unreachableNetwork1"))
}

// More details can be found in this issue: https://github.com/tikv/pd/issues/4884
Expand Down Expand Up @@ -488,10 +488,10 @@ func TestMixedTSODeployment(t *testing.T) {
re := require.New(t)

re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/tso/fastUpdatePhysicalInterval", "return(true)"))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/sd/skipUpdateServiceMode", "return(true)"))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/servicediscovery/skipUpdateServiceMode", "return(true)"))
defer func() {
re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/tso/fastUpdatePhysicalInterval"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/sd/skipUpdateServiceMode"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/servicediscovery/skipUpdateServiceMode"))
}()

ctx, cancel := context.WithCancel(context.Background())
Expand Down Expand Up @@ -551,7 +551,7 @@ func TestUpgradingAPIandTSOClusters(t *testing.T) {
backendEndpoints := pdLeader.GetAddr()

// Create a pd client in PD mode to let the API leader to forward requests to the TSO cluster.
re.NoError(failpoint.Enable("github.com/tikv/pd/client/sd/usePDServiceMode", "return(true)"))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/servicediscovery/usePDServiceMode", "return(true)"))
pdClient, err := pd.NewClientWithContext(context.Background(),
caller.TestComponent,
[]string{backendEndpoints}, pd.SecurityOption{}, opt.WithMaxErrorRetry(1))
Expand Down Expand Up @@ -580,7 +580,7 @@ func TestUpgradingAPIandTSOClusters(t *testing.T) {
tsoCluster.Destroy()
apiCluster.Destroy()
cancel()
re.NoError(failpoint.Disable("github.com/tikv/pd/client/sd/usePDServiceMode"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/servicediscovery/usePDServiceMode"))
}

func checkTSO(
Expand Down
2 changes: 1 addition & 1 deletion tools/pd-simulator/simulator/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/kvproto/pkg/pdpb"
pdHttp "github.com/tikv/pd/client/http"
"github.com/tikv/pd/client/sd"
sd "github.com/tikv/pd/client/servicediscovery"
"github.com/tikv/pd/pkg/core"
"github.com/tikv/pd/pkg/utils/typeutil"
sc "github.com/tikv/pd/tools/pd-simulator/simulator/config"
Expand Down
2 changes: 1 addition & 1 deletion tools/pd-simulator/simulator/drive.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/prometheus/client_golang/prometheus/promhttp"
pdHttp "github.com/tikv/pd/client/http"
"github.com/tikv/pd/client/sd"
sd "github.com/tikv/pd/client/servicediscovery"
"github.com/tikv/pd/pkg/core"
"github.com/tikv/pd/pkg/utils/typeutil"
"github.com/tikv/pd/tools/pd-simulator/simulator/cases"
Expand Down

0 comments on commit 4f5462e

Please sign in to comment.