Skip to content

Commit

Permalink
Tidy up new verifyNoInternalTables e2e helper function
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord committed Jan 30, 2022
1 parent 8b15f51 commit a5638eb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion go/test/endtoend/vreplication/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package vreplication
// 1. Mixed case identifiers
// 2. Column and table names with special characters in them, namely a dash
// 3. Identifiers using reserved words, as lead is a reserved word in MySQL 8.0+ (https://dev.mysql.com/doc/refman/8.0/en/keywords.html)
// The internal table _vt_PURGE_4f9194b43b2011eb8a0104ed332e05c2_20221210194431 should be ignored by vreplciation
// The internal table _vt_PURGE_4f9194b43b2011eb8a0104ed332e05c2_20221210194431 should be ignored by vreplication
var (
initialProductSchema = `
create table product(pid int, description varbinary(128), date1 datetime not null default '0000-00-00 00:00:00', date2 datetime not null default '2021-00-01 00:00:00', primary key(pid));
Expand Down
17 changes: 7 additions & 10 deletions go/test/endtoend/vreplication/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"time"

"github.com/buger/jsonparser"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"vitess.io/vitess/go/test/endtoend/cluster"
Expand Down Expand Up @@ -93,20 +94,16 @@ func waitForQueryToExecute(t *testing.T, conn *mysql.Conn, database string, quer
}
}

func verifyNoInternalTables(t *testing.T, conn *mysql.Conn, database string) {
t.Logf("Checking that no internal tables exist in keyspace: %s", database)
qr := execVtgateQuery(t, conn, database, "show tables")
// verifyNoInternalTables can e.g. be used to confirm that no internal tables were
// copied from a source to a target during a MoveTables or Reshard operation.
func verifyNoInternalTables(t *testing.T, conn *mysql.Conn, keyspaceShard string) {
qr := execVtgateQuery(t, conn, keyspaceShard, "show tables")
require.NotNil(t, qr)
require.NotNil(t, qr.Rows)
found := false
for _, row := range qr.Rows {
if schema.IsInternalOperationTableName(row[0].ToString()) {
t.Logf("Found internal table in keyspace: %s! Table name: %s", database, row[0].ToString())
found = true
}
tableName := row[0].ToString()
assert.False(t, schema.IsInternalOperationTableName(tableName), "found internal table %s in shard %s", tableName, keyspaceShard)
}
require.Equal(t, false, found)
t.Logf("Found no internal tables in keyspace: %s!", database)
}

func validateCount(t *testing.T, conn *mysql.Conn, database string, table string, want int) {
Expand Down
2 changes: 1 addition & 1 deletion go/vt/wrangler/materializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func shouldInclude(table string, excludes []string) bool {
// structures built from the GetSchema database related API calls. In this
// case, however, the table list comes from the user via the -tables flag
// so we need to filter out internal table names here in case a user has
// explcility specified some.
// explicitly specified some.
// This could happen if there's some automated tooling that creates the list of
// tables to explicitly specify.
// But given that this should never be done in practice, we ignore the request.
Expand Down

0 comments on commit a5638eb

Please sign in to comment.