Skip to content

Commit 884aa5a

Browse files
Refactor vtcombo flags - Part 4 (#18422)
Signed-off-by: mounicasruthi <mounicasruthi30@gmail.com> Signed-off-by: Nick Van Wiggeren <nick@planetscale.com> Co-authored-by: Nick Van Wiggeren <nick@planetscale.com>
1 parent 093cf6a commit 884aa5a

File tree

74 files changed

+255
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+255
-212
lines changed

config/tablet/default.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ oltp:
7979
healthcheck:
8080
intervalSeconds: 20 # health-check-interval
8181
degradedThresholdSeconds: 30 # degraded-threshold
82-
unhealthyThresholdSeconds: 7200 # unhealthy_threshold
82+
unhealthyThresholdSeconds: 7200 # unhealthy-threshold
8383

8484
gracePeriods:
85-
shutdownSeconds: 0 # shutdown_grace_period
86-
transitionSeconds: 0 # serving_state_grace_period
85+
shutdownSeconds: 0 # shutdown-grace-period
86+
transitionSeconds: 0 # serving-state-grace-period
8787

8888
replicationTracker:
8989
mode: disable # enable-replication-reporter

go/cmd/vtcombo/cli/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ func init() {
105105

106106
acl.RegisterFlags(Main.Flags())
107107

108-
Main.Flags().StringVar(&schemaDir, "schema_dir", schemaDir, "Schema base directory. Should contain one directory per keyspace, with a vschema.json file if necessary.")
109-
Main.Flags().BoolVar(&startMysql, "start_mysql", startMysql, "Should vtcombo also start mysql")
108+
utils.SetFlagStringVar(Main.Flags(), &schemaDir, "schema-dir", schemaDir, "Schema base directory. Should contain one directory per keyspace, with a vschema.json file if necessary.")
109+
utils.SetFlagBoolVar(Main.Flags(), &startMysql, "start-mysql", startMysql, "Should vtcombo also start mysql")
110110
utils.SetFlagIntVar(Main.Flags(), &mysqlPort, "mysql-port", mysqlPort, "mysql port")
111111
utils.SetFlagBoolVar(Main.Flags(), &externalTopoServer, "external-topo-server", externalTopoServer, "Should vtcombo use an external topology server instead of starting its own in-memory topology server. "+
112112
"If true, vtcombo will use the flags defined in topo/server.go to open topo server")

go/cmd/vttablet/cli/cli_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
// TestRunFailsToStartTabletManager tests the code path in 'run' where we fail to start the TabletManager
3232
// this is done by starting vttablet without a cnf file but requesting it to restore from backup.
3333
// When starting, the TabletManager checks if it needs to restore, in tm.handleRestore but this step will
34-
// fail if we do not provide a cnf file and if the flag --restore_from_backup is provided.
34+
// fail if we do not provide a cnf file and if the flag --restore-from-backup is provided.
3535
func TestRunFailsToStartTabletManager(t *testing.T) {
3636
ts, factory := memorytopo.NewServerAndFactory(context.Background(), "cell")
3737
topo.RegisterFactory("test", factory)
@@ -59,7 +59,7 @@ func TestRunFailsToStartTabletManager(t *testing.T) {
5959
}
6060

6161
flagArgs = append(flagArgs,
62-
"--tablet-path", "cell-1", "--restore_from_backup",
62+
"--tablet-path", "cell-1", "--restore-from-backup",
6363
)
6464

6565
os.Args = append([]string{"vttablet"}, flagArgs...)
@@ -69,5 +69,5 @@ func TestRunFailsToStartTabletManager(t *testing.T) {
6969
defer cancel()
7070

7171
err := Main.ExecuteContext(ctx)
72-
require.ErrorContains(t, err, "you cannot enable --restore_from_backup without a my.cnf file")
72+
require.ErrorContains(t, err, "you cannot enable --restore-from-backup without a my.cnf file")
7373
}

go/cmd/vttestserver/cli/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func New() (cmd *cobra.Command) {
120120
"Define the fake cluster topology as a compact text format encoded"+
121121
" vttest proto. See vttest.proto for more information.")
122122

123-
cmd.Flags().StringVar(&config.SchemaDir, "schema_dir", "",
123+
utils.SetFlagStringVar(cmd.Flags(), &config.SchemaDir, "schema-dir", "",
124124
"Directory for initial schema files. Within this dir,"+
125125
" there should be a subdir for each keyspace. Within"+
126126
" each keyspace dir, each file is executed as SQL"+
@@ -130,7 +130,7 @@ func New() (cmd *cobra.Command) {
130130

131131
cmd.Flags().StringVar(&config.DefaultSchemaDir, "default_schema_dir", "",
132132
"Default directory for initial schema files. If no schema is found"+
133-
" in schema_dir, default to this location.")
133+
" in schema-dir, default to this location.")
134134

135135
cmd.Flags().StringVar(&config.DataDir, "data_dir", "",
136136
"Directory where the data files will be placed, defaults to a random "+
@@ -146,7 +146,7 @@ func New() (cmd *cobra.Command) {
146146
"If this flag is set, the MySQL data directory is not cleaned up"+
147147
" when LocalCluster.TearDown() is called. This is useful for running"+
148148
" vttestserver as a database container in local developer environments. Note"+
149-
" that db migration files (--schema_dir option) and seeding of"+
149+
" that db migration files (--schema-dir option) and seeding of"+
150150
" random data (--initialize-with-random-data option) will only run during"+
151151
" cluster startup if the data directory does not already exist. "+
152152
" Changes to VSchema are persisted across cluster restarts using a simple"+

go/cmd/vttestserver/cli/main_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func TestMtlsAuth(t *testing.T) {
300300
clientCert := path.Join(root, "client-cert.pem")
301301
clientKey := path.Join(root, "client-key.pem")
302302

303-
// When cluster starts it will apply SQL and VSchema migrations in the configured schema_dir folder
303+
// When cluster starts it will apply SQL and VSchema migrations in the configured schema-dir folder
304304
// With mtls authorization enabled, the authorized CN must match the certificate's CN
305305
cluster, err := startCluster(
306306
utils.GetFlagVariantForTests("--grpc-auth-mode")+"=mtls",
@@ -341,7 +341,7 @@ func TestMtlsAuthUnauthorizedFails(t *testing.T) {
341341
clientCert := path.Join(root, "client-cert.pem")
342342
clientKey := path.Join(root, "client-key.pem")
343343

344-
// When cluster starts it will apply SQL and VSchema migrations in the configured schema_dir folder
344+
// When cluster starts it will apply SQL and VSchema migrations in the configured schema-dir folder
345345
// For mtls authorization failure by providing a client certificate with different CN thant the
346346
// authorized in the configuration
347347
cluster, err := startCluster(
@@ -376,7 +376,7 @@ var clusterKeyspaces = []string{
376376

377377
func startCluster(flags ...string) (cluster vttest.LocalCluster, err error) {
378378
args := []string{"vttestserver"}
379-
schemaDirArg := "--schema_dir=data/schema"
379+
schemaDirArg := utils.GetFlagVariantForTests("--schema-dir") + "=data/schema"
380380
tabletHostname := fmt.Sprintf("%s=localhost", utils.GetFlagVariantForTests("--tablet-hostname"))
381381
keyspaceArg := "--keyspaces=" + strings.Join(clusterKeyspaces, ",")
382382
numShardsArg := "--num_shards=2,2"

0 commit comments

Comments
 (0)