Skip to content

Commit

Permalink
make test happy
Browse files Browse the repository at this point in the history
Signed-off-by: husharp <[email protected]>
  • Loading branch information
HuSharp committed May 13, 2024
1 parent a39300e commit 51708b5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/mcs/resourcemanager/server/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,18 @@ func NewTestServer(ctx context.Context, re *require.Assertions, cfg *Config) (*S
// GenerateConfig generates a new config with the given options.
func GenerateConfig(c *Config) (*Config, error) {
arguments := []string{
"--name=" + c.Name,
"--listen-addr=" + c.ListenAddr,
"--advertise-listen-addr=" + c.AdvertiseListenAddr,
"--backend-endpoints=" + c.BackendEndpoints,
}

flagSet := pflag.NewFlagSet("test", pflag.ContinueOnError)
flagSet.StringP("name", "", "", "human-readable name for this resource manager member")
flagSet.BoolP("version", "V", false, "print version information and exit")
flagSet.StringP("config", "", "", "config file")
flagSet.StringP("backend-endpoints", "", "", "url for etcd client")
flagSet.StringP("listen-addr", "", "", "listen address for tso service")
flagSet.StringP("listen-addr", "", "", "listen address for resource manager service")
flagSet.StringP("advertise-listen-addr", "", "", "advertise urls for listen address (default '${listen-addr}')")
flagSet.StringP("cacert", "", "", "path of file that contains list of trusted TLS CAs")
flagSet.StringP("cert", "", "", "path of file that contains X509 certificate in PEM format")
Expand Down
2 changes: 2 additions & 0 deletions pkg/mcs/scheduling/server/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ func NewTestServer(ctx context.Context, re *require.Assertions, cfg *config.Conf
// GenerateConfig generates a new config with the given options.
func GenerateConfig(c *config.Config) (*config.Config, error) {
arguments := []string{
"--name=" + c.Name,
"--listen-addr=" + c.ListenAddr,
"--advertise-listen-addr=" + c.AdvertiseListenAddr,
"--backend-endpoints=" + c.BackendEndpoints,
}

flagSet := pflag.NewFlagSet("test", pflag.ContinueOnError)
flagSet.StringP("name", "", "", "human-readable name for this scheduling member")
flagSet.BoolP("version", "V", false, "print version information and exit")
flagSet.StringP("config", "", "", "config file")
flagSet.StringP("backend-endpoints", "", "", "url for etcd client")
Expand Down
2 changes: 2 additions & 0 deletions pkg/mcs/tso/server/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ func MustNewGrpcClient(re *require.Assertions, addr string) (*grpc.ClientConn, t
// GenerateConfig generates a new config with the given options.
func GenerateConfig(c *Config) (*Config, error) {
arguments := []string{
"--name=" + c.Name,
"--listen-addr=" + c.ListenAddr,
"--advertise-listen-addr=" + c.AdvertiseListenAddr,
"--backend-endpoints=" + c.BackendEndpoints,
}

flagSet := pflag.NewFlagSet("test", pflag.ContinueOnError)
flagSet.StringP("name", "", "", "human-readable name for this tso member")
flagSet.BoolP("version", "V", false, "print version information and exit")
flagSet.StringP("config", "", "", "config file")
flagSet.StringP("backend-endpoints", "", "", "url for etcd client")
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/mcs/members/member_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (suite *memberTestSuite) TestTransferPrimary() {
var newPrimary string
for _, member := range nodes {
if member.GetAddr() != primary {
newPrimary = member.GetAddr()
newPrimary = member.Name()
break
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func StartSingleTSOTestServerWithoutCheck(ctx context.Context, re *require.Asser
cfg := tso.NewConfig()
cfg.BackendEndpoints = backendEndpoints
cfg.ListenAddr = listenAddrs
cfg.Name = cfg.ListenAddr
cfg, err := tso.GenerateConfig(cfg)
re.NoError(err)
// Setup the logger.
Expand Down Expand Up @@ -121,6 +122,7 @@ func StartSingleSchedulingTestServer(ctx context.Context, re *require.Assertions
cfg := sc.NewConfig()
cfg.BackendEndpoints = backendEndpoints
cfg.ListenAddr = listenAddrs
cfg.Name = cfg.ListenAddr
cfg, err := scheduling.GenerateConfig(cfg)
re.NoError(err)

Expand Down

0 comments on commit 51708b5

Please sign in to comment.