Skip to content

Commit

Permalink
Add no_scatter flag to vttestserver
Browse files Browse the repository at this point in the history
Signed-off-by: Armand Parajon <[email protected]>
  • Loading branch information
aparajon committed Apr 5, 2024
1 parent 795c678 commit 4ac36dc
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
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")
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

0 comments on commit 4ac36dc

Please sign in to comment.