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

Fix SHOW VSCHEMA TABLES tests using v17 vtgate that expected dual #12381

Merged
merged 2 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -160,35 +160,54 @@ func TestInitAndUpdate(t *testing.T) {
require.NoError(t, err)
defer conn.Close()

vtgateVersion, err := cluster.GetMajorVersion("vtgate")
require.NoError(t, err)

expected := `[[VARCHAR("dual")] [VARCHAR("t2")] [VARCHAR("t2_id4_idx")] [VARCHAR("t8")]]`
if vtgateVersion >= 17 {
expected = `[[VARCHAR("t2")] [VARCHAR("t2_id4_idx")] [VARCHAR("t8")]]`
}
utils.AssertMatchesWithTimeout(t, conn,
"SHOW VSCHEMA TABLES",
`[[VARCHAR("dual")] [VARCHAR("t2")] [VARCHAR("t2_id4_idx")] [VARCHAR("t8")]]`,
expected,
100*time.Millisecond,
3*time.Second,
"initial table list not complete")

// Init
_ = utils.Exec(t, conn, "create table test_sc (id bigint primary key)")
expected = `[[VARCHAR("dual")] [VARCHAR("t2")] [VARCHAR("t2_id4_idx")] [VARCHAR("t8")] [VARCHAR("test_sc")]]`
if vtgateVersion >= 17 {
expected = `[[VARCHAR("t2")] [VARCHAR("t2_id4_idx")] [VARCHAR("t8")] [VARCHAR("test_sc")]]`
}
utils.AssertMatchesWithTimeout(t, conn,
"SHOW VSCHEMA TABLES",
`[[VARCHAR("dual")] [VARCHAR("t2")] [VARCHAR("t2_id4_idx")] [VARCHAR("t8")] [VARCHAR("test_sc")]]`,
expected,
100*time.Millisecond,
3*time.Second,
"test_sc not in vschema tables")

// Tables Update via health check.
_ = utils.Exec(t, conn, "create table test_sc1 (id bigint primary key)")
expected = `[[VARCHAR("dual")] [VARCHAR("t2")] [VARCHAR("t2_id4_idx")] [VARCHAR("t8")] [VARCHAR("test_sc")] [VARCHAR("test_sc1")]]`
if vtgateVersion >= 17 {
expected = `[VARCHAR("t2")] [VARCHAR("t2_id4_idx")] [VARCHAR("t8")] [VARCHAR("test_sc")] [VARCHAR("test_sc1")]]`
}
utils.AssertMatchesWithTimeout(t, conn,
"SHOW VSCHEMA TABLES",
`[[VARCHAR("dual")] [VARCHAR("t2")] [VARCHAR("t2_id4_idx")] [VARCHAR("t8")] [VARCHAR("test_sc")] [VARCHAR("test_sc1")]]`,
expected,
100*time.Millisecond,
3*time.Second,
"test_sc1 not in vschema tables")

_ = utils.Exec(t, conn, "drop table test_sc, test_sc1")
expected = `[[VARCHAR("dual")] [VARCHAR("t2")] [VARCHAR("t2_id4_idx")] [VARCHAR("t8")]]`
if vtgateVersion >= 17 {
expected = `[[VARCHAR("t2")] [VARCHAR("t2_id4_idx")] [VARCHAR("t8")]]`
}
utils.AssertMatchesWithTimeout(t, conn,
"SHOW VSCHEMA TABLES",
`[[VARCHAR("dual")] [VARCHAR("t2")] [VARCHAR("t2_id4_idx")] [VARCHAR("t8")]]`,
expected,
100*time.Millisecond,
3*time.Second,
"test_sc and test_sc_1 should not be in vschema tables")
Expand All @@ -204,10 +223,16 @@ func TestDMLOnNewTable(t *testing.T) {
// create a new table which is not part of the VSchema
utils.Exec(t, conn, `create table new_table_tracked(id bigint, name varchar(100), primary key(id)) Engine=InnoDB`)

vtgateVersion, err := cluster.GetMajorVersion("vtgate")
require.NoError(t, err)
expected := `[[VARCHAR("dual")] [VARCHAR("new_table_tracked")] [VARCHAR("t2")] [VARCHAR("t2_id4_idx")] [VARCHAR("t8")]]`
if vtgateVersion >= 17 {
expected = `[VARCHAR("new_table_tracked")] [VARCHAR("t2")] [VARCHAR("t2_id4_idx")] [VARCHAR("t8")]]`
}
// wait for vttablet's schema reload interval to pass
utils.AssertMatchesWithTimeout(t, conn,
"SHOW VSCHEMA TABLES",
`[[VARCHAR("dual")] [VARCHAR("new_table_tracked")] [VARCHAR("t2")] [VARCHAR("t2_id4_idx")] [VARCHAR("t8")]]`,
expected,
100*time.Millisecond,
3*time.Second,
"test_sc not in vschema tables")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,33 @@ func TestNewUnshardedTable(t *testing.T) {
require.NoError(t, err)
defer conn.Close()

vtgateVersion, err := cluster.GetMajorVersion("vtgate")
require.NoError(t, err)
expected := `[[VARCHAR("dual")] [VARCHAR("main")]]`
if vtgateVersion >= 17 {
expected = `[[VARCHAR("main")]]`
}

// ensuring our initial table "main" is in the schema
utils.AssertMatchesWithTimeout(t, conn,
"SHOW VSCHEMA TABLES",
`[[VARCHAR("dual")] [VARCHAR("main")]]`,
expected,
100*time.Millisecond,
3*time.Second,
"initial table list not complete")

// create a new table which is not part of the VSchema
utils.Exec(t, conn, `create table new_table_tracked(id bigint, name varchar(100), primary key(id)) Engine=InnoDB`)

expected = `[[VARCHAR("dual")] [VARCHAR("main")] [VARCHAR("new_table_tracked")]]`
if vtgateVersion >= 17 {
expected = `[[VARCHAR("main")] [VARCHAR("new_table_tracked")]]`
}

// waiting for the vttablet's schema_reload interval to kick in
utils.AssertMatchesWithTimeout(t, conn,
"SHOW VSCHEMA TABLES",
`[[VARCHAR("dual")] [VARCHAR("main")] [VARCHAR("new_table_tracked")]]`,
expected,
100*time.Millisecond,
3*time.Second,
"new_table_tracked not in vschema tables")
Expand All @@ -126,9 +138,13 @@ func TestNewUnshardedTable(t *testing.T) {
utils.Exec(t, conn, `drop table new_table_tracked`)

// waiting for the vttablet's schema_reload interval to kick in
expected = `[[VARCHAR("dual")] [VARCHAR("main")]]`
if vtgateVersion >= 17 {
expected = `[[VARCHAR("main")]]`
}
utils.AssertMatchesWithTimeout(t, conn,
"SHOW VSCHEMA TABLES",
`[[VARCHAR("dual")] [VARCHAR("main")]]`,
expected,
100*time.Millisecond,
3*time.Second,
"new_table_tracked not in vschema tables")
Expand Down
17 changes: 13 additions & 4 deletions go/test/endtoend/vtgate/vschema/vschema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,15 @@ func TestVSchema(t *testing.T) {

utils.AssertMatches(t, conn, "delete from vt_user", `[]`)

vtgateVersion, err := cluster.GetMajorVersion("vtgate")
require.NoError(t, err)

// Test empty vschema
utils.AssertMatches(t, conn, "SHOW VSCHEMA TABLES", `[[VARCHAR("dual")]]`)
if vtgateVersion >= 17 {
utils.AssertMatches(t, conn, "SHOW VSCHEMA TABLES", `[]`)
} else {
utils.AssertMatches(t, conn, "SHOW VSCHEMA TABLES", `[[VARCHAR("dual")]]`)
}

// Use the DDL to create an unsharded vschema and test again

Expand All @@ -128,9 +135,11 @@ func TestVSchema(t *testing.T) {
utils.Exec(t, conn, "commit")

// Test Showing Tables
utils.AssertMatches(t, conn,
"SHOW VSCHEMA TABLES",
`[[VARCHAR("dual")] [VARCHAR("main")] [VARCHAR("vt_user")]]`)
if vtgateVersion >= 17 {
utils.AssertMatches(t, conn, "SHOW VSCHEMA TABLES", `[[VARCHAR("main")] [VARCHAR("vt_user")]]`)
} else {
utils.AssertMatches(t, conn, "SHOW VSCHEMA TABLES", `[[VARCHAR("dual")] [VARCHAR("main")] [VARCHAR("vt_user")]]`)
}

// Test Showing Vindexes
utils.AssertMatches(t, conn, "SHOW VSCHEMA VINDEXES", `[]`)
Expand Down