Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add no_scatter flag to vttestserver #15670

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go/cmd/vttestserver/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ func New() (cmd *cobra.Command) {
cmd.Flags().DurationVar(&config.VtgateTabletRefreshInterval, "tablet_refresh_interval", 10*time.Second, "Interval at which vtgate refreshes tablet information from topology server.")

cmd.Flags().BoolVar(&doCreateTCPUser, "initialize-with-vt-dba-tcp", false, "If this flag is enabled, MySQL will be initialized with an additional user named vt_dba_tcp, who will have access via TCP/IP connection.")

cmd.Flags().BoolVar(&config.NoScatter, "no_scatter", false, "when set to true, the planner will fail instead of producing a plan that includes scatter queries")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are supposed to use dashes instead of underscores for new flags but this isn't really a new flag but rather we're adding it to another binary and having uniformity is better/nicer for it IMO. So I think this is fine. 🙂

acl.RegisterFlags(cmd.Flags())

return cmd
Expand Down
15 changes: 15 additions & 0 deletions go/cmd/vttestserver/cli/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,21 @@ func TestForeignKeysAndDDLModes(t *testing.T) {
assert.NoError(t, err)
}

func TestNoScatter(t *testing.T) {
conf := config
defer resetConfig(conf)

cluster, err := startCluster("--no_scatter")
assert.NoError(t, err)
defer cluster.TearDown()

_ = execOnCluster(cluster, "app_customer", func(conn *mysql.Conn) error {
_, err = conn.ExecuteFetch("SELECT * FROM customers", 100, false)
require.ErrorContains(t, err, "plan includes scatter, which is disallowed")
return nil
})
}

// TestCreateDbaTCPUser tests that the vt_dba_tcp user is created and can connect through TCP/IP connection
// when --initialize-with-vt-dba-tcp is set to true.
func TestCreateDbaTCPUser(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions go/flags/endtoend/vttestserver.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Flags:
--mysql_server_version string MySQL server version to advertise. (default "8.0.30-Vitess")
--mysqlctl_mycnf_template string template file to use for generating the my.cnf file during server init
--mysqlctl_socket string socket file to use for remote mysqlctl actions (empty for local actions)
--no_scatter when set to true, the planner will fail instead of producing a plan that includes scatter queries
--null_probability float The probability to initialize a field with 'NULL' if --initialize_with_random_data is true. Only applies to fields that can contain NULL values. (default 0.1)
--num_shards strings Comma separated shard count (one per keyspace) (default [2])
--onclose_timeout duration wait no more than this for OnClose handlers before stopping (default 10s)
Expand Down
3 changes: 3 additions & 0 deletions go/vt/vttest/local_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ type Config struct {
ExternalTopoGlobalRoot string

VtgateTabletRefreshInterval time.Duration

// Set the planner to fail on scatter queries
NoScatter bool
}

// InitSchemas is a shortcut for tests that just want to setup a single
Expand Down
1 change: 1 addition & 0 deletions go/vt/vttest/vtprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ func VtcomboProcess(environment Environment, args *Config, mysql MySQLManager) (
fmt.Sprintf("--enable_online_ddl=%t", args.EnableOnlineDDL),
fmt.Sprintf("--enable_direct_ddl=%t", args.EnableDirectDDL),
fmt.Sprintf("--enable_system_settings=%t", args.EnableSystemSettings),
fmt.Sprintf("--no_scatter=%t", args.NoScatter),
}...)

// If topo tablet refresh interval is not defined then we will give it value of 10s. Please note
Expand Down
Loading