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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run endtoend tests on Cluster (vtgate_concurrentdml)
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Check if workflow needs to be skipped
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cluster_endtoend_vtgate_gen4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run endtoend tests on Cluster (vtgate_gen4)
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Check if workflow needs to be skipped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run endtoend tests on Cluster (vtgate_general_heavy)
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Check if workflow needs to be skipped
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cluster_endtoend_vtgate_godriver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run endtoend tests on Cluster (vtgate_godriver)
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Check if workflow needs to be skipped
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cluster_endtoend_vtgate_queries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run endtoend tests on Cluster (vtgate_queries)
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Check if workflow needs to be skipped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run endtoend tests on Cluster (vtgate_readafterwrite)
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Check if workflow needs to be skipped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run endtoend tests on Cluster (vtgate_reservedconn)
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Check if workflow needs to be skipped
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cluster_endtoend_vtgate_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run endtoend tests on Cluster (vtgate_schema)
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Check if workflow needs to be skipped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run endtoend tests on Cluster (vtgate_schema_tracker)
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Check if workflow needs to be skipped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run endtoend tests on Cluster (vtgate_tablet_healthcheck_cache)
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Check if workflow needs to be skipped
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cluster_endtoend_vtgate_topo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run endtoend tests on Cluster (vtgate_topo)
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Check if workflow needs to be skipped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run endtoend tests on Cluster (vtgate_topo_consul)
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Check if workflow needs to be skipped
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cluster_endtoend_vtgate_topo_etcd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run endtoend tests on Cluster (vtgate_topo_etcd)
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Check if workflow needs to be skipped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run endtoend tests on Cluster (vtgate_transaction)
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Check if workflow needs to be skipped
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cluster_endtoend_vtgate_unsharded.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run endtoend tests on Cluster (vtgate_unsharded)
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Check if workflow needs to be skipped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run endtoend tests on Cluster (vtgate_vindex_heavy)
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Check if workflow needs to be skipped
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cluster_endtoend_vtgate_vschema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run endtoend tests on Cluster (vtgate_vschema)
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: Check if workflow needs to be skipped
Expand Down
14 changes: 14 additions & 0 deletions go/test/endtoend/utils/cmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ func (mcmp *MySQLCompare) AssertMatches(query, expected string) {
}
}

// AssertMatchesAny ensures the given query produces any one of the expected results.
func (mcmp *MySQLCompare) AssertMatchesAny(query string, expected ...string) {
mcmp.t.Helper()
qr := mcmp.Exec(query)
got := fmt.Sprintf("%v", qr.Rows)
for _, e := range expected {
diff := cmp.Diff(e, got)
if diff == "" {
return
}
}
mcmp.t.Errorf("Query: %s (-want +got):\n%v\nGot:%s", query, expected, got)
}

// AssertContainsError executes the query on both Vitess and MySQL.
// Both clients need to return an error. The error of Vitess must be matching the given expectation.
func (mcmp *MySQLCompare) AssertContainsError(query, expected string) {
Expand Down
4 changes: 3 additions & 1 deletion go/test/endtoend/vtgate/gen4/system_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ func TestFKConstraintUsingInformationSchema(t *testing.T) {
defer utils.Exec(t, conn, "drop table ks.t7_fk, ks.t7_xxhash")

query := "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as name, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk on fk.constraint_schema = rc.constraint_schema and fk.constraint_name = rc.constraint_name where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = 't7_fk' and rc.constraint_schema = database() and rc.table_name = 't7_fk'"
utils.AssertMatches(t, conn, query, `[[VARCHAR("t7_xxhash") VARCHAR("uid") VARCHAR("t7_uid") VARCHAR("t7_fk_ibfk_1") VARCHAR("CASCADE") VARCHAR("SET NULL")]]`)
utils.AssertMatchesAny(t, conn, query,
`[[VARCHAR("t7_xxhash") VARCHAR("uid") VARCHAR("t7_uid") VARCHAR("t7_fk_ibfk_1") VARCHAR("CASCADE") VARCHAR("SET NULL")]]`,
`[[VARBINARY("t7_xxhash") VARCHAR("uid") VARCHAR("t7_uid") VARCHAR("t7_fk_ibfk_1") BINARY("CASCADE") BINARY("SET NULL")]]`)
}

func TestConnectWithSystemSchema(t *testing.T) {
Expand Down
31 changes: 16 additions & 15 deletions go/test/endtoend/vtgate/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ func TestShowColumns(t *testing.T) {
conn, closer := start(t)
defer closer()

expected := `[[VARCHAR("id") TEXT("bigint(20)") VARCHAR("NO") VARCHAR("PRI") NULL VARCHAR("")] [VARCHAR("idx") TEXT("varchar(50)") VARCHAR("YES") VARCHAR("") NULL VARCHAR("")]]`
utils.AssertMatches(t, conn, "show columns from `t5_null_vindex` in `ks`", expected)
utils.AssertMatches(t, conn, "SHOW COLUMNS from `t5_null_vindex` in `ks`", expected)
utils.AssertMatches(t, conn, "SHOW columns FROM `t5_null_vindex` in `ks`", expected)
utils.AssertMatches(t, conn, "SHOW columns FROM `t5_null_vindex` where Field = 'id'", `[[VARCHAR("id") TEXT("bigint(20)") VARCHAR("NO") VARCHAR("PRI") NULL VARCHAR("")]]`)
expected80 := `[[VARCHAR("id") BLOB("bigint") VARCHAR("NO") BINARY("PRI") NULL VARCHAR("")] [VARCHAR("idx") BLOB("varchar(50)") VARCHAR("YES") BINARY("") NULL VARCHAR("")]]`
expected57 := `[[VARCHAR("id") TEXT("bigint(20)") VARCHAR("NO") VARCHAR("PRI") NULL VARCHAR("")] [VARCHAR("idx") TEXT("varchar(50)") VARCHAR("YES") VARCHAR("") NULL VARCHAR("")]]`
utils.AssertMatchesAny(t, conn, "show columns from `t5_null_vindex` in `ks`", expected80, expected57)
utils.AssertMatchesAny(t, conn, "SHOW COLUMNS from `t5_null_vindex` in `ks`", expected80, expected57)
utils.AssertMatchesAny(t, conn, "SHOW columns FROM `t5_null_vindex` in `ks`", expected80, expected57)
utils.AssertMatchesAny(t, conn, "SHOW columns FROM `t5_null_vindex` where Field = 'id'",
`[[VARCHAR("id") BLOB("bigint") VARCHAR("NO") BINARY("PRI") NULL VARCHAR("")]]`,
`[[VARCHAR("id") TEXT("bigint(20)") VARCHAR("NO") VARCHAR("PRI") NULL VARCHAR("")]]`)
}

func TestShowTables(t *testing.T) {
Expand All @@ -72,7 +75,6 @@ func TestShowTables(t *testing.T) {
query := "show tables;"
qr := utils.Exec(t, conn, query)

assert.Equal(t, "information_schema", qr.Fields[0].Database)
assert.Equal(t, "Tables_in_ks", qr.Fields[0].Name)
}

Expand Down Expand Up @@ -228,9 +230,9 @@ func TestShowTablesWithWhereClause(t *testing.T) {
conn, closer := start(t)
defer closer()

utils.AssertMatches(t, conn, "show tables from ks where Tables_in_ks='t6'", `[[VARCHAR("t6")]]`)
utils.AssertMatchesAny(t, conn, "show tables from ks where Tables_in_ks='t6'", `[[VARBINARY("t6")]]`, `[[VARCHAR("t6")]]`)
utils.Exec(t, conn, "begin")
utils.AssertMatches(t, conn, "show tables from ks where Tables_in_ks='t3'", `[[VARCHAR("t3")]]`)
utils.AssertMatchesAny(t, conn, "show tables from ks where Tables_in_ks='t3'", `[[VARBINARY("t3")]]`, `[[VARCHAR("t3")]]`)
}

func TestOffsetAndLimitWithOLAP(t *testing.T) {
Expand Down Expand Up @@ -399,11 +401,11 @@ func TestFunctionInDefault(t *testing.T) {
// set the sql mode ALLOW_INVALID_DATES
utils.Exec(t, conn, `SET sql_mode = 'ALLOW_INVALID_DATES'`)

_, err := utils.ExecAllowError(t, conn, `create table function_default (x varchar(25) DEFAULT (TRIM(" check ")))`)
// this query fails because mysql57 does not support functions in default clause
require.Error(t, err)
// test that default expression works for columns.
utils.Exec(t, conn, `create table function_default (x varchar(25) DEFAULT (TRIM(" check ")))`)
utils.Exec(t, conn, "drop table function_default")

// verify that currenet_timestamp and it's aliases work as default values
// verify that current_timestamp and it's aliases work as default values
utils.Exec(t, conn, `create table function_default (
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
dt DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
Expand All @@ -426,9 +428,8 @@ ts12 TIMESTAMP DEFAULT LOCALTIME()
)`)
utils.Exec(t, conn, "drop table function_default")

_, err = utils.ExecAllowError(t, conn, `create table function_default (ts TIMESTAMP DEFAULT UTC_TIMESTAMP)`)
// this query fails because utc_timestamp is not supported in default clause
require.Error(t, err)
utils.Exec(t, conn, `create table function_default (ts TIMESTAMP DEFAULT UTC_TIMESTAMP)`)
utils.Exec(t, conn, "drop table function_default")

utils.Exec(t, conn, `create table function_default (x varchar(25) DEFAULT "check")`)
utils.Exec(t, conn, "drop table function_default")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ func TestFKConstraintUsingInformationSchema(t *testing.T) {
defer closer()

query := "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as name, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk on fk.constraint_schema = rc.constraint_schema and fk.constraint_name = rc.constraint_name where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = 't7_fk' and rc.constraint_schema = database() and rc.table_name = 't7_fk'"
mcmp.AssertMatches(query, `[[VARCHAR("t7_xxhash") VARCHAR("uid") VARCHAR("t7_uid") VARCHAR("t7_fk_ibfk_1") VARCHAR("CASCADE") VARCHAR("SET NULL")]]`)
mcmp.AssertMatchesAny(query,
`[[VARBINARY("t7_xxhash") VARCHAR("uid") VARCHAR("t7_uid") VARCHAR("t7_fk_ibfk_1") BINARY("CASCADE") BINARY("SET NULL")]]`,
`[[VARCHAR("t7_xxhash") VARCHAR("uid") VARCHAR("t7_uid") VARCHAR("t7_fk_ibfk_1") VARCHAR("CASCADE") VARCHAR("SET NULL")]]`)
}

func TestConnectWithSystemSchema(t *testing.T) {
Expand Down
6 changes: 4 additions & 2 deletions go/test/endtoend/vtgate/unsharded/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func TestDDLUnsharded(t *testing.T) {
utils.AssertMatches(t, conn, "select * from v1", `[[INT64(3) INT64(0) INT64(3) VARCHAR("a")] [INT64(30) INT64(10) INT64(30) VARCHAR("ac")] [INT64(300) INT64(100) INT64(300) VARCHAR("abc")]]`)
utils.Exec(t, conn, `drop view v1`)
utils.Exec(t, conn, `drop table tempt1`)
utils.AssertMatches(t, conn, "show tables", `[[VARCHAR("allDefaults")] [VARCHAR("t1")]]`)
utils.AssertMatchesAny(t, conn, "show tables", `[[VARBINARY("allDefaults")] [VARBINARY("t1")]]`, `[[VARCHAR("allDefaults")] [VARCHAR("t1")]]`)
}

func TestCallProcedure(t *testing.T) {
Expand Down Expand Up @@ -460,7 +460,9 @@ func TestFloatValueDefault(t *testing.T) {

utils.Exec(t, conn, `create table test_float_default (pos_f float default 2.1, neg_f float default -2.1);`)
defer utils.Exec(t, conn, `drop table test_float_default`)
utils.AssertMatches(t, conn, "select table_name, column_name, column_default from information_schema.columns where table_name = 'test_float_default' order by column_default desc", `[[VARCHAR("test_float_default") VARCHAR("pos_f") TEXT("2.1")] [VARCHAR("test_float_default") VARCHAR("neg_f") TEXT("-2.1")]]`)
utils.AssertMatchesAny(t, conn, "select table_name, column_name, column_default from information_schema.columns where table_name = 'test_float_default' order by column_default desc",
`[[VARBINARY("test_float_default") VARCHAR("pos_f") BLOB("2.1")] [VARBINARY("test_float_default") VARCHAR("neg_f") BLOB("-2.1")]]`,
`[[VARCHAR("test_float_default") VARCHAR("pos_f") TEXT("2.1")] [VARCHAR("test_float_default") VARCHAR("neg_f") TEXT("-2.1")]]`)
}

func execMulti(t *testing.T, conn *mysql.Conn, query string) []*sqltypes.Result {
Expand Down