Skip to content

Commit

Permalink
[release-16.0]: Fix upgrade-downgrade test setup and fix the `init_…
Browse files Browse the repository at this point in the history
…db.sql` (vitessio#13525)

Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 authored and tanjinx committed Oct 14, 2024
1 parent 37b690c commit 5cb0cfe
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ jobs:
source build.env
rm -f $PWD/bin/vtbackup $PWD/bin/vttablet
cp /tmp/vitess-build-current/bin/vtbackup $PWD/bin/vtbackup
cp /tmp/vitess-build-other/bin/vttablet $PWD/bin/vttablet
cp /tmp/vitess-build-other/bin/vtbackup $PWD/bin/vtbackup
cp /tmp/vitess-build-current/bin/vttablet $PWD/bin/vttablet
vtbackup --version
vttablet --version
Expand Down
12 changes: 12 additions & 0 deletions config/init_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
###############################################################################
# Equivalent of mysql_secure_installation
###############################################################################
# We need to ensure that super_read_only is disabled so that we can execute
# these commands. Note that disabling it does NOT disable read_only.
# We save the current value so that we only re-enable it at the end if it was
# enabled before.
SET @original_super_read_only=IF(@@global.super_read_only=1, 'ON', 'OFF');
SET GLOBAL super_read_only='OFF';

# Changes during the init db should not make it to the binlog.
# They could potentially create errant transactions on replicas.
Expand Down Expand Up @@ -101,3 +107,9 @@ FLUSH PRIVILEGES;

RESET SLAVE ALL;
RESET MASTER;

# custom sql is used to add custom scripts like creating users/passwords. We use it in our tests
# {{custom_sql}}

# We need to set super_read_only back to what it was before
SET GLOBAL super_read_only=IFNULL(@original_super_read_only, 'ON');
7 changes: 6 additions & 1 deletion go/test/endtoend/backup/vtbackup/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"testing"

"vitess.io/vitess/go/test/endtoend/cluster"
"vitess.io/vitess/go/test/endtoend/utils"
"vitess.io/vitess/go/vt/log"
)

Expand Down Expand Up @@ -89,8 +90,12 @@ func TestMain(m *testing.M) {
dbCredentialFile = cluster.WriteDbCredentialToTmp(localCluster.TmpDirectory)
initDb, _ := os.ReadFile(path.Join(os.Getenv("VTROOT"), "/config/init_db.sql"))
sql := string(initDb)
// The original init_db.sql does not have any passwords. Here we update the init file with passwords
sql, err = utils.GetInitDBSQL(sql, cluster.GetPasswordUpdateSQL(localCluster), "")
if err != nil {
return 1, err
}
newInitDBFile = path.Join(localCluster.TmpDirectory, "init_db_with_passwords.sql")
sql = sql + cluster.GetPasswordUpdateSQL(localCluster)
err = os.WriteFile(newInitDBFile, []byte(sql), 0666)
if err != nil {
return 1, err
Expand Down
24 changes: 23 additions & 1 deletion go/test/endtoend/cluster/mysqlctl_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/mysqlctl"
"vitess.io/vitess/go/vt/tlstest"
)

Expand Down Expand Up @@ -211,11 +212,15 @@ func (mysqlctl *MysqlctlProcess) CleanupFiles(tabletUID int) {
// MysqlCtlProcessInstanceOptionalInit returns a Mysqlctl handle for mysqlctl process
// configured with the given Config.
func MysqlCtlProcessInstanceOptionalInit(tabletUID int, mySQLPort int, tmpDirectory string, initMySQL bool) *MysqlctlProcess {
initFile, err := getInitDBFileUsed()
if err != nil {
log.Errorf("Couldn't find init db file - %v", err)
}
mysqlctl := &MysqlctlProcess{
Name: "mysqlctl",
Binary: "mysqlctl",
LogDirectory: tmpDirectory,
InitDBFile: path.Join(os.Getenv("VTROOT"), "/config/init_db.sql"),
InitDBFile: initFile,
}
mysqlctl.MySQLPort = mySQLPort
mysqlctl.TabletUID = tabletUID
Expand All @@ -224,6 +229,23 @@ func MysqlCtlProcessInstanceOptionalInit(tabletUID int, mySQLPort int, tmpDirect
return mysqlctl
}

func getInitDBFileUsed() (string, error) {
versionStr, err := mysqlctl.GetVersionString()
if err != nil {
return "", err
}
flavor, _, err := mysqlctl.ParseVersionString(versionStr)
if err != nil {
return "", err
}
if flavor == mysqlctl.FlavorMySQL || flavor == mysqlctl.FlavorPercona {
return path.Join(os.Getenv("VTROOT"), "/config/init_db.sql"), nil
}
// Non-MySQL instances for example MariaDB, will use init_testserver_db.sql which does not contain super_read_only global variable.
// Even though MariaDB support is deprecated (https://github.com/vitessio/vitess/issues/9518) but we still support migration scenario.
return path.Join(os.Getenv("VTROOT"), "go/test/endtoend/vreplication/testdata/config/init_testserver_db.sql"), nil
}

// MysqlCtlProcessInstance returns a Mysqlctl handle for mysqlctl process
// configured with the given Config.
func MysqlCtlProcessInstance(tabletUID int, mySQLPort int, tmpDirectory string) *MysqlctlProcess {
Expand Down
20 changes: 20 additions & 0 deletions go/test/endtoend/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,23 @@ func TimeoutAction(t *testing.T, timeout time.Duration, errMsg string, action fu
}
}
}

func GetInitDBSQL(initDBSQL string, updatedPasswords string, oldAlterTableMode string) (string, error) {
// Since password update is DML we need to insert it before we disable
// super_read_only therefore doing the split below.
splitString := strings.Split(initDBSQL, "# {{custom_sql}}")

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_transaction)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_transaction)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_transaction)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_transaction)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_transaction)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo_etcd)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo_etcd)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo_etcd)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_concurrentdml)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_concurrentdml)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_concurrentdml)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_readafterwrite)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_readafterwrite)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_readafterwrite)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vindex_heavy)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vindex_heavy)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vindex_heavy)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vindex_heavy)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vindex_heavy)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_unsharded)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_unsharded)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_unsharded)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vttablet_prscomplex)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vttablet_prscomplex)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vttablet_prscomplex)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vttablet_prscomplex)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vttablet_prscomplex)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_reservedconn)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_reservedconn)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_reservedconn)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_reservedconn)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_reservedconn)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_consul)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_consul)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_consul)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (13)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (13)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (13)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (13)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (13)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test (Race)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test (Race)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test (Race)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (12)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (12)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (12)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test (Race)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test (Race)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test (Race)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old VTTablet

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old VTTablet

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old VTTablet

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old Vtctl

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old Vtctl

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old Vtctl

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old Vtctl

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old Vtctl

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old Vtctl

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old VTTablet

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old VTTablet

undefined: strings

Check failure on line 246 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old VTTablet

undefined: strings
if len(splitString) != 2 {
return "", fmt.Errorf("missing `# {{custom_sql}}` in init_db.sql file")
}
var builder strings.Builder

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_transaction)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_transaction)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_transaction)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_transaction)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_transaction)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo_etcd)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo_etcd)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo_etcd)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_concurrentdml)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_concurrentdml)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_concurrentdml)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_readafterwrite)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_readafterwrite)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_readafterwrite)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vindex_heavy)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vindex_heavy)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vindex_heavy)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vindex_heavy)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vindex_heavy)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_unsharded)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_unsharded)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_unsharded)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vttablet_prscomplex)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vttablet_prscomplex)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vttablet_prscomplex)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vttablet_prscomplex)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vttablet_prscomplex)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_reservedconn)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_reservedconn)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_reservedconn)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_reservedconn)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_reservedconn)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_consul)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_consul)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_consul)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (13)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (13)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (13)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (13)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (13)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test (Race)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test (Race)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test (Race)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (12)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (12)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (12)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test (Race)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test (Race)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test (Race)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / End-to-End Test

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old VTTablet

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old VTTablet

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old VTTablet

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old Vtctl

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old Vtctl

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old Vtctl

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old Vtctl

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old Vtctl

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old Vtctl

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old VTTablet

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old VTTablet

undefined: strings

Check failure on line 250 in go/test/endtoend/utils/utils.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old VTTablet

undefined: strings
builder.WriteString(splitString[0])
builder.WriteString(updatedPasswords)

// https://github.com/vitessio/vitess/issues/8315
if oldAlterTableMode != "" {
builder.WriteString(oldAlterTableMode)
}
builder.WriteString(splitString[1])

return builder.String(), nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# This file is for testing purpose only.
# This file is executed immediately after initializing a fresh data directory.
# It is equivalent of init_db.sql. Given init_db.sql is for mysql which has super_read_only
# related stuff therefore for testing purpose we avoid setting `super_read_only` during initialization.

###############################################################################
# WARNING: Any change to init_db.sql should gets reflected in this file as well.
###############################################################################

###############################################################################
# WARNING: This sql is *NOT* safe for production use,
# as it contains default well-known users and passwords.
# Care should be taken to change these users and passwords
# for production.
###############################################################################

###############################################################################
# Equivalent of mysql_secure_installation
###############################################################################
# We need to ensure that read_only is disabled so that we can execute
# these commands.
SET GLOBAL read_only='OFF';

# Changes during the init db should not make it to the binlog.
# They could potentially create errant transactions on replicas.
SET sql_log_bin = 0;
# Remove anonymous users.
DELETE FROM mysql.user WHERE User = '';

# Disable remote root access (only allow UNIX socket).
DELETE FROM mysql.user WHERE User = 'root' AND Host != 'localhost';

# Remove test database.
DROP DATABASE IF EXISTS test;

###############################################################################
# Vitess defaults
###############################################################################

# Admin user with all privileges.
CREATE USER 'vt_dba'@'localhost';
GRANT ALL ON *.* TO 'vt_dba'@'localhost';
GRANT GRANT OPTION ON *.* TO 'vt_dba'@'localhost';

# User for app traffic, with global read-write access.
CREATE USER 'vt_app'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, FILE,
REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES,
LOCK TABLES, EXECUTE, REPLICATION CLIENT, CREATE VIEW,
SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER
ON *.* TO 'vt_app'@'localhost';

# User for app debug traffic, with global read access.
CREATE USER 'vt_appdebug'@'localhost';
GRANT SELECT, SHOW DATABASES, PROCESS ON *.* TO 'vt_appdebug'@'localhost';

# User for administrative operations that need to be executed as non-SUPER.
# Same permissions as vt_app here.
CREATE USER 'vt_allprivs'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, FILE,
REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES,
LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW,
SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER
ON *.* TO 'vt_allprivs'@'localhost';

# User for slave replication connections.
CREATE USER 'vt_repl'@'%';
GRANT REPLICATION SLAVE ON *.* TO 'vt_repl'@'%';

# User for Vitess VReplication (base vstreamers and vplayer).
CREATE USER 'vt_filtered'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, FILE,
REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES,
LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW,
SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER
ON *.* TO 'vt_filtered'@'localhost';

# User for general MySQL monitoring.
CREATE USER 'vt_monitoring'@'localhost';
GRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT, RELOAD
ON *.* TO 'vt_monitoring'@'localhost';
GRANT SELECT, UPDATE, DELETE, DROP
ON performance_schema.* TO 'vt_monitoring'@'localhost';

FLUSH PRIVILEGES;

RESET SLAVE ALL;
RESET MASTER;

# custom sql is used to add custom scripts like creating users/passwords. We use it in our tests
# {{custom_sql}}

0 comments on commit 5cb0cfe

Please sign in to comment.