Skip to content
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
17 changes: 17 additions & 0 deletions go/test/endtoend/tabletgateway/vtgate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ func TestVtgateHealthCheck(t *testing.T) {
assert.Equal(t, 3, len(qr.Rows), "wrong number of results from show")
}

func TestVtgateReplicationStatusCheck(t *testing.T) {
defer cluster.PanicHandler(t)
// Healthcheck interval on tablet is set to 1s, so sleep for 2s
time.Sleep(2 * time.Second)
verifyVtgateVariables(t, clusterInstance.VtgateProcess.VerifyURL)
ctx := context.Background()
conn, err := mysql.Connect(ctx, &vtParams)
require.Nil(t, err)
defer conn.Close()

// Only returns rows for REPLICA and RDONLY tablets -- so should be 2 of them
qr := exec(t, conn, "show vitess_replication_status like '%'", "")
expectNumRows := 2
numRows := len(qr.Rows)
assert.Equal(t, expectNumRows, numRows, fmt.Sprintf("wrong number of results from show vitess_replication_status. Expected %d, got %d", expectNumRows, numRows))
}

func verifyVtgateVariables(t *testing.T, url string) {
resp, err := http.Get(url)
require.NoError(t, err)
Expand Down
3 changes: 2 additions & 1 deletion go/vt/sqlparser/ast_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,8 @@ func (node *Show) Format(buf *TrackedBuffer) {
func (node *ShowLegacy) Format(buf *TrackedBuffer) {
nodeType := strings.ToLower(node.Type)
if (nodeType == "tables" || nodeType == "columns" || nodeType == "fields" || nodeType == "index" || nodeType == "keys" || nodeType == "indexes" ||
nodeType == "databases" || nodeType == "schemas" || nodeType == "keyspaces" || nodeType == "vitess_keyspaces" || nodeType == "vitess_shards" || nodeType == "vitess_tablets") && node.ShowTablesOpt != nil {
nodeType == "databases" || nodeType == "schemas" || nodeType == "keyspaces" || nodeType == "vitess_keyspaces" || nodeType == "vitess_replication_status" ||
nodeType == "vitess_shards" || nodeType == "vitess_tablets") && node.ShowTablesOpt != nil {
opt := node.ShowTablesOpt
if node.Extended != "" {
buf.astPrintf(node, "show %s%s", node.Extended, nodeType)
Expand Down
3 changes: 2 additions & 1 deletion go/vt/sqlparser/ast_format_fast.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions go/vt/sqlparser/keywords.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,11 @@ var keywords = []keyword{
{"vitess", VITESS},
{"vitess_keyspaces", VITESS_KEYSPACES},
{"vitess_metadata", VITESS_METADATA},
{"vitess_shards", VITESS_SHARDS},
{"vitess_tablets", VITESS_TABLETS},
{"vitess_migration", VITESS_MIGRATION},
{"vitess_migrations", VITESS_MIGRATIONS},
{"vitess_replication_status", VITESS_REPLICATION_STATUS},
{"vitess_shards", VITESS_SHARDS},
{"vitess_tablets", VITESS_TABLETS},
{"vschema", VSCHEMA},
{"warnings", WARNINGS},
{"when", WHEN},
Expand Down
4 changes: 4 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1639,6 +1639,10 @@ var (
}, {
input: "show vitess_keyspaces like '%'",
output: "show keyspaces like '%'",
}, {
input: "show vitess_replication_status",
}, {
input: "show vitess_replication_status like '%'",
}, {
input: "show vitess_shards",
}, {
Expand Down
Loading