From 409f70a767f921a9d13c79086375fa8e6067bc55 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Thu, 16 Feb 2023 19:42:07 +0200 Subject: [PATCH 1/2] Fix SHOW VSCHEMA TABLES tests using v17 vtgate Signed-off-by: Florent Poinsard --- .../schematracker/sharded/st_sharded_test.go | 35 ++++++++++++++++--- .../unsharded/st_unsharded_test.go | 22 ++++++++++-- .../endtoend/vtgate/vschema/vschema_test.go | 17 ++++++--- 3 files changed, 62 insertions(+), 12 deletions(-) diff --git a/go/test/endtoend/vtgate/schematracker/sharded/st_sharded_test.go b/go/test/endtoend/vtgate/schematracker/sharded/st_sharded_test.go index cf12d40194c..a9fa29f92ca 100644 --- a/go/test/endtoend/vtgate/schematracker/sharded/st_sharded_test.go +++ b/go/test/endtoend/vtgate/schematracker/sharded/st_sharded_test.go @@ -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") @@ -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") diff --git a/go/test/endtoend/vtgate/schematracker/unsharded/st_unsharded_test.go b/go/test/endtoend/vtgate/schematracker/unsharded/st_unsharded_test.go index 930f288b831..d858d1d4c66 100644 --- a/go/test/endtoend/vtgate/schematracker/unsharded/st_unsharded_test.go +++ b/go/test/endtoend/vtgate/schematracker/unsharded/st_unsharded_test.go @@ -95,10 +95,17 @@ 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") @@ -106,10 +113,15 @@ func TestNewUnshardedTable(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`) + 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") @@ -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") diff --git a/go/test/endtoend/vtgate/vschema/vschema_test.go b/go/test/endtoend/vtgate/vschema/vschema_test.go index 80a29c6aff4..92863ff7dc8 100644 --- a/go/test/endtoend/vtgate/vschema/vschema_test.go +++ b/go/test/endtoend/vtgate/vschema/vschema_test.go @@ -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 @@ -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", `[]`) From 2fe3982c5ed1318054da046e8c50fb07cf12fbdc Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Fri, 17 Feb 2023 10:52:34 +0200 Subject: [PATCH 2/2] Fix tests expectations Signed-off-by: Florent Poinsard --- .../endtoend/vtgate/schematracker/sharded/st_sharded_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go/test/endtoend/vtgate/schematracker/sharded/st_sharded_test.go b/go/test/endtoend/vtgate/schematracker/sharded/st_sharded_test.go index a9fa29f92ca..532e5edae90 100644 --- a/go/test/endtoend/vtgate/schematracker/sharded/st_sharded_test.go +++ b/go/test/endtoend/vtgate/schematracker/sharded/st_sharded_test.go @@ -191,7 +191,7 @@ func TestInitAndUpdate(t *testing.T) { _ = 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")]]` + expected = `[[VARCHAR("t2")] [VARCHAR("t2_id4_idx")] [VARCHAR("t8")] [VARCHAR("test_sc")] [VARCHAR("test_sc1")]]` } utils.AssertMatchesWithTimeout(t, conn, "SHOW VSCHEMA TABLES", @@ -227,7 +227,7 @@ func TestDMLOnNewTable(t *testing.T) { 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")]]` + 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,