From 351f38a39d1a5e013dfa5c21613d5f6006de5471 Mon Sep 17 00:00:00 2001 From: Deepthi Sigireddi Date: Thu, 17 Sep 2020 12:22:31 -0700 Subject: [PATCH] Revert "Make use of environment variables easier to troubleshoot" Signed-off-by: deepthi --- Makefile | 25 +++--- .../transform/backup_transform_utils.go | 5 +- .../backup/vtbackup/backup_only_test.go | 4 +- go/test/endtoend/backup/vtbackup/main_test.go | 12 +-- .../backup/vtctlbackup/backup_utils.go | 6 +- go/test/endtoend/cellalias/cell_alias_test.go | 3 +- go/test/endtoend/cluster/cluster_process.go | 18 ++--- go/test/endtoend/cluster/mysqlctl_process.go | 80 ++++++------------- go/test/endtoend/cluster/mysqlctld_process.go | 6 +- go/test/endtoend/cluster/topo_process.go | 6 +- go/test/endtoend/cluster/vtbackup_process.go | 4 +- go/test/endtoend/cluster/vtctld_process.go | 4 +- go/test/endtoend/cluster/vtgate_process.go | 2 +- go/test/endtoend/cluster/vttablet_process.go | 4 +- go/test/endtoend/cluster/vtworker_process.go | 3 +- .../encrypted_replication_test.go | 3 +- .../encrypted_transport_test.go | 2 +- go/test/endtoend/mysqlctl/mysqlctl_test.go | 9 +-- .../endtoend/recovery/pitr/binlog_server.go | 6 +- .../recovery/pitr/shardedpitr_test.go | 2 +- .../shardedrecovery/sharded_recovery_test.go | 2 +- .../recovery/unshardedrecovery/recovery.go | 4 +- go/test/endtoend/reparent/main_test.go | 12 +-- .../endtoend/sharded/sharded_keyspace_test.go | 9 ++- .../sharding/initialsharding/sharding_util.go | 4 +- .../mergesharding/mergesharding_base.go | 3 +- .../sharding/resharding/resharding_base.go | 3 +- .../verticalsplit/vertical_split_test.go | 3 +- .../cellalias/cell_alias_test.go | 3 +- go/test/endtoend/tabletmanager/main_test.go | 4 +- go/test/endtoend/vreplication/cluster.go | 7 +- .../endtoend/vtcombo/vttest_sample_test.go | 4 +- .../vtctldweb/vtctld_web_main_test.go | 4 +- go/test/endtoend/worker/worker_test.go | 4 +- 34 files changed, 116 insertions(+), 154 deletions(-) diff --git a/Makefile b/Makefile index 322d26824ee..a4562845ecc 100644 --- a/Makefile +++ b/Makefile @@ -62,25 +62,16 @@ endif bash ./build.env go install $(EXTRA_BUILD_FLAGS) $(VT_GO_PARALLEL) -ldflags "$(shell tools/build_version_flags.sh)" -gcflags -'N -l' ./go/... -check-prefix: - if [ -z ${PREFIX+x} ]; then echo "set the PREFIX environment with the install target"; false; fi - -check-vtroot: - if [ -z ${VTROOT+x} ]; then echo "need VTROOT environment variable set"; false; fi - -check-version: - if [ -z ${VERSION+x} ]; then echo "Set the env var VERSION with the release version"; false; fi - # install copies the files needed to run Vitess into the given directory tree. # Usage: make install PREFIX=/path/to/install/root -install: check-prefix build +install: build # binaries mkdir -p "$${PREFIX}/bin" cp "$${VTROOT}/bin/"{mysqlctld,vtctld,vtctlclient,vtgate,vttablet,vtworker,vtbackup} "$${PREFIX}/bin/" # install copies the files needed to run test Vitess using vtcombo into the given directory tree. # Usage: make install PREFIX=/path/to/install/root -install-testing: check-vtroot check-prefix build +install-testing: build # binaries mkdir -p "$${PREFIX}/bin" cp "$${VTROOT}/bin/"{mysqlctld,mysqlctl,vtcombo,vttestserver} "$${PREFIX}/bin/" @@ -170,7 +161,7 @@ ifndef NOBANNER echo $$(date): Compiling proto definitions endif -$(PROTO_GO_OUTS): check-vtroot install_protoc-gen-go proto/*.proto +$(PROTO_GO_OUTS): install_protoc-gen-go proto/*.proto for name in $(PROTO_SRC_NAMES); do \ $(VTROOT)/bin/protoc --go_out=plugins=grpc:. -Iproto proto/$${name}.proto && \ goimports -w vitess.io/vitess/go/vt/proto/$${name}/$${name}.pb.go; \ @@ -309,7 +300,10 @@ docker_unit_test: # Release a version. # This will generate a tar.gz file into the releases folder with the current source -release: check-version docker_base +release: docker_base + @if [ -z "$VERSION" ]; then \ + echo "Set the env var VERSION with the release version"; exit 1;\ + fi mkdir -p releases docker build -f docker/Dockerfile.release -t vitess/release . docker run -v ${PWD}/releases:/vt/releases --env VERSION=$(VERSION) vitess/release @@ -318,7 +312,10 @@ release: check-version docker_base echo "git push origin v$(VERSION)" echo "Also, don't forget the upload releases/v$(VERSION).tar.gz file to GitHub releases" -packages: check-version docker_base +packages: docker_base + @if [ -z "$VERSION" ]; then \ + echo "Set the env var VERSION with the release version"; exit 1;\ + fi mkdir -p releases docker build -f docker/packaging/Dockerfile -t vitess/packaging . docker run --rm -v ${PWD}/releases:/vt/releases --env VERSION=$(VERSION) vitess/packaging --package /vt/releases -t deb --deb-no-default-config-files diff --git a/go/test/endtoend/backup/transform/backup_transform_utils.go b/go/test/endtoend/backup/transform/backup_transform_utils.go index c43698ff17a..e54fdf047b9 100644 --- a/go/test/endtoend/backup/transform/backup_transform_utils.go +++ b/go/test/endtoend/backup/transform/backup_transform_utils.go @@ -22,6 +22,7 @@ import ( "fmt" "io/ioutil" "os" + "os/exec" "path" "testing" "time" @@ -87,7 +88,7 @@ func TestMainSetup(m *testing.M, useMysqlctld bool) { shard := &localCluster.Keyspaces[0].Shards[0] // changing password for mysql user dbCredentialFile = initialsharding.WriteDbCredentialToTmp(localCluster.TmpDirectory) - initDb, _ := ioutil.ReadFile(path.Join(cluster.GetEnvOrPanic("VTROOT"), "/config/init_db.sql")) + initDb, _ := ioutil.ReadFile(path.Join(os.Getenv("VTROOT"), "/config/init_db.sql")) sql := string(initDb) newInitDBFile = path.Join(localCluster.TmpDirectory, "init_db_with_passwords.sql") sql = sql + initialsharding.GetPasswordUpdateSQL(localCluster) @@ -97,7 +98,7 @@ func TestMainSetup(m *testing.M, useMysqlctld bool) { commonTabletArg = append(commonTabletArg, "-db-credentials-file", dbCredentialFile) // start mysql process for all replicas and master - var mysqlProcs []*cluster.MySQLCmd + var mysqlProcs []*exec.Cmd for i := 0; i < 3; i++ { tabletType := "replica" tablet := localCluster.NewVttabletInstance(tabletType, 0, cell) diff --git a/go/test/endtoend/backup/vtbackup/backup_only_test.go b/go/test/endtoend/backup/vtbackup/backup_only_test.go index 35eb43c1efc..0a128f47a50 100644 --- a/go/test/endtoend/backup/vtbackup/backup_only_test.go +++ b/go/test/endtoend/backup/vtbackup/backup_only_test.go @@ -182,7 +182,7 @@ func listBackups(shardKsName string) ([]string, error) { backups, err := localCluster.VtctlProcess.ExecuteCommandWithOutput( "-backup_storage_implementation", "file", "-file_backup_storage_root", - path.Join(cluster.GetEnvOrPanic("VTDATAROOT"), "tmp", "backupstorage"), + path.Join(os.Getenv("VTDATAROOT"), "tmp", "backupstorage"), "ListBackups", shardKsName, ) if err != nil { @@ -206,7 +206,7 @@ func removeBackups(t *testing.T) { _, err := localCluster.VtctlProcess.ExecuteCommandWithOutput( "-backup_storage_implementation", "file", "-file_backup_storage_root", - path.Join(cluster.GetEnvOrPanic("VTDATAROOT"), "tmp", "backupstorage"), + path.Join(os.Getenv("VTDATAROOT"), "tmp", "backupstorage"), "RemoveBackup", shardKsName, backup, ) require.Nil(t, err) diff --git a/go/test/endtoend/backup/vtbackup/main_test.go b/go/test/endtoend/backup/vtbackup/main_test.go index f23be2111e6..70c84e556d3 100644 --- a/go/test/endtoend/backup/vtbackup/main_test.go +++ b/go/test/endtoend/backup/vtbackup/main_test.go @@ -21,6 +21,7 @@ import ( "fmt" "io/ioutil" "os" + "os/exec" "path" "testing" @@ -83,7 +84,7 @@ func TestMain(m *testing.M) { // Create a new init_db.sql file that sets up passwords for all users. // Then we use a db-credentials-file with the passwords. dbCredentialFile = initialsharding.WriteDbCredentialToTmp(localCluster.TmpDirectory) - initDb, _ := ioutil.ReadFile(path.Join(cluster.GetEnvOrPanic("VTROOT"), "/config/init_db.sql")) + initDb, _ := ioutil.ReadFile(path.Join(os.Getenv("VTROOT"), "/config/init_db.sql")) sql := string(initDb) newInitDBFile = path.Join(localCluster.TmpDirectory, "init_db_with_passwords.sql") sql = sql + initialsharding.GetPasswordUpdateSQL(localCluster) @@ -101,7 +102,7 @@ func TestMain(m *testing.M) { shard.Vttablets = []*cluster.Vttablet{master, replica1, replica2} // Start MySql processes - var mysqlProcs []*cluster.MySQLCmd + var mysqlProcs []*exec.Cmd for _, tablet := range shard.Vttablets { tablet.VttabletProcess = localCluster.VtprocessInstanceFromVttablet(tablet, shard.Name, keyspaceName) tablet.VttabletProcess.DbPassword = dbPassword @@ -112,11 +113,12 @@ func TestMain(m *testing.M) { tablet.MysqlctlProcess = *cluster.MysqlCtlProcessInstance(tablet.TabletUID, tablet.MySQLPort, localCluster.TmpDirectory) tablet.MysqlctlProcess.InitDBFile = newInitDBFile tablet.MysqlctlProcess.ExtraArgs = extraArgs - proc, err := tablet.MysqlctlProcess.StartProcess() - if err != nil { + if proc, err := tablet.MysqlctlProcess.StartProcess(); err != nil { return 1, err + } else { + // ignore golint warning, we need the else block to use proc + mysqlProcs = append(mysqlProcs, proc) } - mysqlProcs = append(mysqlProcs, proc) } for _, proc := range mysqlProcs { if err := proc.Wait(); err != nil { diff --git a/go/test/endtoend/backup/vtctlbackup/backup_utils.go b/go/test/endtoend/backup/vtctlbackup/backup_utils.go index f131dbf81c8..0d0acceafda 100644 --- a/go/test/endtoend/backup/vtctlbackup/backup_utils.go +++ b/go/test/endtoend/backup/vtctlbackup/backup_utils.go @@ -103,7 +103,7 @@ func LaunchCluster(setupType int, streamMode string, stripes int) (int, error) { shard := &localCluster.Keyspaces[0].Shards[0] dbCredentialFile = initialsharding.WriteDbCredentialToTmp(localCluster.TmpDirectory) - initDb, _ := ioutil.ReadFile(path.Join(cluster.GetEnvOrPanic("VTROOT"), "/config/init_db.sql")) + initDb, _ := ioutil.ReadFile(path.Join(os.Getenv("VTROOT"), "/config/init_db.sql")) sql := string(initDb) newInitDBFile = path.Join(localCluster.TmpDirectory, "init_db_with_passwords.sql") sql = sql + initialsharding.GetPasswordUpdateSQL(localCluster) @@ -135,7 +135,7 @@ func LaunchCluster(setupType int, streamMode string, stripes int) (int, error) { commonTabletArg = append(commonTabletArg, xtrabackupArgs...) } - var mysqlProcs []*cluster.MySQLCmd + var mysqlProcs []*exec.Cmd for i := 0; i < 3; i++ { tabletType := "replica" if i == 0 { @@ -437,7 +437,7 @@ func restartMasterReplica(t *testing.T) { // remove all backups localCluster.RemoveAllBackups(t, shardKsName) // start all tablet and mysql instances - var mysqlProcs []*cluster.MySQLCmd + var mysqlProcs []*exec.Cmd for _, tablet := range []*cluster.Vttablet{master, replica1, replica2} { if tablet.MysqlctldProcess.TabletUID > 0 { err := tablet.MysqlctldProcess.Start() diff --git a/go/test/endtoend/cellalias/cell_alias_test.go b/go/test/endtoend/cellalias/cell_alias_test.go index 0aa97a80f72..84792547675 100644 --- a/go/test/endtoend/cellalias/cell_alias_test.go +++ b/go/test/endtoend/cellalias/cell_alias_test.go @@ -26,6 +26,7 @@ import ( "flag" "fmt" "os" + "os/exec" "testing" "github.com/stretchr/testify/assert" @@ -125,7 +126,7 @@ func TestMain(m *testing.M) { shard2Replica = localCluster.NewVttabletInstance("replica", 0, cell2) shard2Rdonly = localCluster.NewVttabletInstance("rdonly", 0, cell2) - var mysqlProcs []*cluster.MySQLCmd + var mysqlProcs []*exec.Cmd for _, tablet := range []*cluster.Vttablet{shard1Master, shard1Replica, shard1Rdonly, shard2Master, shard2Replica, shard2Rdonly} { tablet.MysqlctlProcess = *cluster.MysqlCtlProcessInstance(tablet.TabletUID, tablet.MySQLPort, localCluster.TmpDirectory) tablet.VttabletProcess = cluster.VttabletProcessInstance(tablet.HTTPPort, diff --git a/go/test/endtoend/cluster/cluster_process.go b/go/test/endtoend/cluster/cluster_process.go index b9a4611533e..e56a0171f81 100644 --- a/go/test/endtoend/cluster/cluster_process.go +++ b/go/test/endtoend/cluster/cluster_process.go @@ -169,7 +169,7 @@ func (cluster *LocalProcessCluster) StartTopo() (err error) { cluster.Cell = DefaultCell } cluster.TopoPort = cluster.GetAndReservePort() - cluster.TmpDirectory = path.Join(GetEnvOrPanic("VTDATAROOT"), fmt.Sprintf("/tmp_%d", cluster.GetAndReservePort())) + cluster.TmpDirectory = path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/tmp_%d", cluster.GetAndReservePort())) cluster.TopoProcess = *TopoProcessInstance(cluster.TopoPort, cluster.GetAndReservePort(), cluster.Hostname, *topoFlavor, "global") log.Infof("Starting topo server %v on port: %d", *topoFlavor, cluster.TopoPort) @@ -210,15 +210,6 @@ func (cluster *LocalProcessCluster) StartTopo() (err error) { return } -//GetEnvOrPanic panics is an environment variable is missing -func GetEnvOrPanic(name string) string { - getenv, found := os.LookupEnv(name) - if !found { - panic(fmt.Sprintf("need %s to be set", name)) - } - return getenv -} - // StartUnshardedKeyspace starts unshared keyspace with shard name as "0" func (cluster *LocalProcessCluster) StartUnshardedKeyspace(keyspace Keyspace, replicaCount int, rdonly bool) error { return cluster.StartKeyspace(keyspace, []string{"0"}, replicaCount, rdonly) @@ -239,12 +230,13 @@ func (cluster *LocalProcessCluster) StartKeyspace(keyspace Keyspace, shardNames log.Infof("Starting keyspace: %v", keyspace.Name) _ = cluster.VtctlProcess.CreateKeyspace(keyspace.Name) - var mysqlctlProcessList []*MySQLCmd + var mysqlctlProcessList []*exec.Cmd for _, shardName := range shardNames { shard := &Shard{ Name: shardName, } log.Infof("Starting shard: %v", shardName) + mysqlctlProcessList = []*exec.Cmd{} for i := 0; i < totalTabletsRequired; i++ { // instantiate vttablet object with reserved ports tabletUID := cluster.GetAndReserveTabletUID() @@ -446,8 +438,8 @@ func (cluster *LocalProcessCluster) NewVtgateInstance() *VtgateProcess { func NewCluster(cell string, hostname string) *LocalProcessCluster { cluster := &LocalProcessCluster{Cell: cell, Hostname: hostname, mx: new(sync.Mutex)} go cluster.CtrlCHandler() - cluster.OriginalVTDATAROOT = GetEnvOrPanic("VTDATAROOT") - cluster.CurrentVTDATAROOT = path.Join(cluster.OriginalVTDATAROOT, fmt.Sprintf("vtroot_%d", cluster.GetAndReservePort())) + cluster.OriginalVTDATAROOT = os.Getenv("VTDATAROOT") + cluster.CurrentVTDATAROOT = path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("vtroot_%d", cluster.GetAndReservePort())) _ = createDirectory(cluster.CurrentVTDATAROOT, 0700) _ = os.Setenv("VTDATAROOT", cluster.CurrentVTDATAROOT) rand.Seed(time.Now().UTC().UnixNano()) diff --git a/go/test/endtoend/cluster/mysqlctl_process.go b/go/test/endtoend/cluster/mysqlctl_process.go index 320d24261c2..34e290f8af3 100644 --- a/go/test/endtoend/cluster/mysqlctl_process.go +++ b/go/test/endtoend/cluster/mysqlctl_process.go @@ -66,62 +66,28 @@ func (mysqlctl *MysqlctlProcess) Start() (err error) { return tmpProcess.Wait() } -// MySQLCmd wraps a exec.Cmd and restarts it with verbose settings if it would fail -type MySQLCmd struct { - mysqlctl *MysqlctlProcess - cmd *exec.Cmd -} - -//Wait waits for the underlying process to finish. If it fails, it's restarted with more log output -func (m *MySQLCmd) Wait() error { - err := m.cmd.Wait() - if err != nil { - err = m.startProcess(true) - if err != nil { - return err - } - return m.cmd.Wait() - } - return nil -} - -func (m *MySQLCmd) startProcess(verbose bool) error { - proc := exec.Command( - m.mysqlctl.Binary, - "-log_dir", m.mysqlctl.LogDirectory, - "-tablet_uid", fmt.Sprintf("%d", m.mysqlctl.TabletUID), - "-mysql_port", fmt.Sprintf("%d", m.mysqlctl.MySQLPort), +// StartProcess starts the mysqlctl and returns the process reference +func (mysqlctl *MysqlctlProcess) StartProcess() (*exec.Cmd, error) { + tmpProcess := exec.Command( + mysqlctl.Binary, + "-log_dir", mysqlctl.LogDirectory, + "-tablet_uid", fmt.Sprintf("%d", mysqlctl.TabletUID), + "-mysql_port", fmt.Sprintf("%d", mysqlctl.MySQLPort), ) if *isCoverage { - proc.Args = append(proc.Args, []string{"-test.coverprofile=" + getCoveragePath("mysql-start.out")}...) + tmpProcess.Args = append(tmpProcess.Args, []string{"-test.coverprofile=" + getCoveragePath("mysql-start.out")}...) } - if len(m.mysqlctl.ExtraArgs) > 0 { - proc.Args = append(proc.Args, m.mysqlctl.ExtraArgs...) - } - if m.mysqlctl.InitMysql { - proc.Args = append(proc.Args, "init", - "-init_db_sql_file", m.mysqlctl.InitDBFile) + if len(mysqlctl.ExtraArgs) > 0 { + tmpProcess.Args = append(tmpProcess.Args, mysqlctl.ExtraArgs...) } - proc.Args = append(proc.Args, "start") - log.Infof("Starting mysqlctl with command: %v", proc.Args) - if verbose { - proc.Stdout = os.Stdout - proc.Stderr = os.Stderr + if mysqlctl.InitMysql { + tmpProcess.Args = append(tmpProcess.Args, "init", + "-init_db_sql_file", mysqlctl.InitDBFile) } - - m.cmd = proc - - return proc.Start() -} - -// StartProcess starts the mysqlctl and returns the process reference -func (mysqlctl *MysqlctlProcess) StartProcess() (*MySQLCmd, error) { - cmd := &MySQLCmd{ - mysqlctl: mysqlctl, - } - - return cmd, cmd.startProcess(false) + tmpProcess.Args = append(tmpProcess.Args, "start") + log.Infof("Starting mysqlctl with command: %v", tmpProcess.Args) + return tmpProcess, tmpProcess.Start() } // Stop executes mysqlctl command to stop mysql instance @@ -153,11 +119,11 @@ func (mysqlctl *MysqlctlProcess) StopProcess() (*exec.Cmd, error) { // CleanupFiles clean the mysql files to make sure we can start the same process again func (mysqlctl *MysqlctlProcess) CleanupFiles(tabletUID int) { - os.RemoveAll(path.Join(GetEnvOrPanic("VTDATAROOT"), fmt.Sprintf("/vt_%010d/data", tabletUID))) - os.RemoveAll(path.Join(GetEnvOrPanic("VTDATAROOT"), fmt.Sprintf("/vt_%010d/relay-logs", tabletUID))) - os.RemoveAll(path.Join(GetEnvOrPanic("VTDATAROOT"), fmt.Sprintf("/vt_%010d/tmp", tabletUID))) - os.RemoveAll(path.Join(GetEnvOrPanic("VTDATAROOT"), fmt.Sprintf("/vt_%010d/bin-logs", tabletUID))) - os.RemoveAll(path.Join(GetEnvOrPanic("VTDATAROOT"), fmt.Sprintf("/vt_%010d/innodb", tabletUID))) + os.RemoveAll(path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d/data", tabletUID))) + os.RemoveAll(path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d/relay-logs", tabletUID))) + os.RemoveAll(path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d/tmp", tabletUID))) + os.RemoveAll(path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d/bin-logs", tabletUID))) + os.RemoveAll(path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d/innodb", tabletUID))) } // MysqlCtlProcessInstance returns a Mysqlctl handle for mysqlctl process @@ -167,7 +133,7 @@ func MysqlCtlProcessInstance(tabletUID int, mySQLPort int, tmpDirectory string) Name: "mysqlctl", Binary: "mysqlctl", LogDirectory: tmpDirectory, - InitDBFile: path.Join(GetEnvOrPanic("VTROOT"), "/config/init_db.sql"), + InitDBFile: path.Join(os.Getenv("VTROOT"), "/config/init_db.sql"), } mysqlctl.MySQLPort = mySQLPort mysqlctl.TabletUID = tabletUID @@ -190,7 +156,7 @@ func StartMySQLAndGetConnection(ctx context.Context, tablet *Vttablet, username } params := mysql.ConnParams{ Uname: username, - UnixSocket: path.Join(GetEnvOrPanic("VTDATAROOT"), fmt.Sprintf("/vt_%010d", tablet.TabletUID), "/mysql.sock"), + UnixSocket: path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d", tablet.TabletUID), "/mysql.sock"), } return mysql.Connect(ctx, ¶ms) diff --git a/go/test/endtoend/cluster/mysqlctld_process.go b/go/test/endtoend/cluster/mysqlctld_process.go index 9de98e55399..08abb7027d3 100644 --- a/go/test/endtoend/cluster/mysqlctld_process.go +++ b/go/test/endtoend/cluster/mysqlctld_process.go @@ -139,7 +139,7 @@ func (mysqlctld *MysqlctldProcess) Stop() error { // CleanupFiles clean the mysql files to make sure we can start the same process again func (mysqlctld *MysqlctldProcess) CleanupFiles(tabletUID int) { - os.RemoveAll(path.Join(GetEnvOrPanic("VTDATAROOT"), fmt.Sprintf("/vt_%010d", tabletUID))) + os.RemoveAll(path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d", tabletUID))) } // MysqlCtldProcessInstance returns a Mysqlctld handle for mysqlctld process @@ -149,7 +149,7 @@ func MysqlCtldProcessInstance(tabletUID int, mySQLPort int, tmpDirectory string) Name: "mysqlctld", Binary: "mysqlctld", LogDirectory: tmpDirectory, - InitDBFile: path.Join(GetEnvOrPanic("VTROOT"), "/config/init_db.sql"), + InitDBFile: path.Join(os.Getenv("VTROOT"), "/config/init_db.sql"), } mysqlctld.MySQLPort = mySQLPort mysqlctld.TabletUID = tabletUID @@ -159,7 +159,7 @@ func MysqlCtldProcessInstance(tabletUID int, mySQLPort int, tmpDirectory string) // IsHealthy gives the health status of mysql. func (mysqlctld *MysqlctldProcess) IsHealthy() bool { - socketFile := path.Join(GetEnvOrPanic("VTDATAROOT"), fmt.Sprintf("/vt_%010d", mysqlctld.TabletUID), "/mysql.sock") + socketFile := path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d", mysqlctld.TabletUID), "/mysql.sock") params := NewConnParams(0, mysqlctld.Password, socketFile, "") _, err := mysql.Connect(context.Background(), ¶ms) return err == nil diff --git a/go/test/endtoend/cluster/topo_process.go b/go/test/endtoend/cluster/topo_process.go index 6cc8cdb4d02..de60c79e791 100644 --- a/go/test/endtoend/cluster/topo_process.go +++ b/go/test/endtoend/cluster/topo_process.go @@ -151,7 +151,7 @@ func (topo *TopoProcess) SetupConsul(cluster *LocalProcessCluster) (err error) { topo.VerifyURL = fmt.Sprintf("http://%s:%d/v1/kv/?keys", topo.Host, topo.Port) - configFile := path.Join(GetEnvOrPanic("VTDATAROOT"), "consul.json") + configFile := path.Join(os.Getenv("VTDATAROOT"), "consul.json") config := fmt.Sprintf(`{"ports":{"dns":%d,"http":%d,"serf_lan":%d,"serf_wan":%d}}`, cluster.GetAndReservePort(), topo.Port, cluster.GetAndReservePort(), cluster.GetAndReservePort()) @@ -305,8 +305,8 @@ func TopoProcessInstance(port int, peerPort int, hostname string, flavor string, topo.AdvertiseClientURL = fmt.Sprintf("http://%s:%d", topo.Host, topo.Port) topo.ListenClientURL = fmt.Sprintf("http://%s:%d", topo.Host, topo.Port) - topo.DataDirectory = path.Join(GetEnvOrPanic("VTDATAROOT"), fmt.Sprintf("%s_%d", "topo", port)) - topo.LogDirectory = path.Join(GetEnvOrPanic("VTDATAROOT"), fmt.Sprintf("%s_%d", "topo", port), "logs") + topo.DataDirectory = path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("%s_%d", "topo", port)) + topo.LogDirectory = path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("%s_%d", "topo", port), "logs") topo.VerifyURL = fmt.Sprintf("http://%s:%d/v2/keys", topo.Host, topo.Port) topo.PeerURL = fmt.Sprintf("http://%s:%d", hostname, peerPort) return topo diff --git a/go/test/endtoend/cluster/vtbackup_process.go b/go/test/endtoend/cluster/vtbackup_process.go index ee45ab2f268..d211aa35862 100644 --- a/go/test/endtoend/cluster/vtbackup_process.go +++ b/go/test/endtoend/cluster/vtbackup_process.go @@ -71,7 +71,7 @@ func (vtbackup *VtbackupProcess) Setup() (err error) { //Backup Arguments are not optional "-backup_storage_implementation", "file", "-file_backup_storage_root", - path.Join(GetEnvOrPanic("VTDATAROOT"), "tmp", "backupstorage"), + path.Join(os.Getenv("VTDATAROOT"), "tmp", "backupstorage"), ) if vtbackup.initialBackup { @@ -127,7 +127,7 @@ func VtbackupProcessInstance(tabletUID int, mysqlPort int, newInitDBFile string, Binary: "vtbackup", CommonArg: *vtctl, LogDir: tmpDirectory, - Directory: GetEnvOrPanic("VTDATAROOT"), + Directory: os.Getenv("VTDATAROOT"), TabletAlias: fmt.Sprintf("%s-%010d", cell, tabletUID), initDBfile: newInitDBFile, Keyspace: keyspace, diff --git a/go/test/endtoend/cluster/vtctld_process.go b/go/test/endtoend/cluster/vtctld_process.go index 008d27de6fc..89bd7544496 100644 --- a/go/test/endtoend/cluster/vtctld_process.go +++ b/go/test/endtoend/cluster/vtctld_process.go @@ -160,11 +160,11 @@ func VtctldProcessInstance(httpPort int, grpcPort int, topoPort int, hostname st CommonArg: *vtctl, ServiceMap: "grpc-vtctl", BackupStorageImplementation: "file", - FileBackupStorageRoot: path.Join(GetEnvOrPanic("VTDATAROOT"), "/backups"), + FileBackupStorageRoot: path.Join(os.Getenv("VTDATAROOT"), "/backups"), LogDir: tmpDirectory, Port: httpPort, GrpcPort: grpcPort, - Directory: GetEnvOrPanic("VTDATAROOT"), + Directory: os.Getenv("VTDATAROOT"), } vtctld.VerifyURL = fmt.Sprintf("http://%s:%d/debug/vars", hostname, vtctld.Port) return vtctld diff --git a/go/test/endtoend/cluster/vtgate_process.go b/go/test/endtoend/cluster/vtgate_process.go index bb3d4cbd297..ed2c287304d 100644 --- a/go/test/endtoend/cluster/vtgate_process.go +++ b/go/test/endtoend/cluster/vtgate_process.go @@ -219,7 +219,7 @@ func VtgateProcessInstance(port int, grpcPort int, mySQLServerPort int, cell str Name: "vtgate", Binary: "vtgate", FileToLogQueries: path.Join(tmpDirectory, "/vtgate_querylog.txt"), - Directory: GetEnvOrPanic("VTDATAROOT"), + Directory: os.Getenv("VTDATAROOT"), ServiceMap: "grpc-tabletmanager,grpc-throttler,grpc-queryservice,grpc-updatestream,grpc-vtctl,grpc-vtworker,grpc-vtgateservice", LogDir: tmpDirectory, Port: port, diff --git a/go/test/endtoend/cluster/vttablet_process.go b/go/test/endtoend/cluster/vttablet_process.go index 1a8c0d335d9..b6335d97762 100644 --- a/go/test/endtoend/cluster/vttablet_process.go +++ b/go/test/endtoend/cluster/vttablet_process.go @@ -371,7 +371,7 @@ func VttabletProcessInstance(port int, grpcPort int, tabletUID int, cell string, Name: "vttablet", Binary: "vttablet", FileToLogQueries: path.Join(tmpDirectory, fmt.Sprintf("/vt_%010d_querylog.txt", tabletUID)), - Directory: path.Join(GetEnvOrPanic("VTDATAROOT"), fmt.Sprintf("/vt_%010d", tabletUID)), + Directory: path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d", tabletUID)), TabletPath: fmt.Sprintf("%s-%010d", cell, tabletUID), ServiceMap: "grpc-queryservice,grpc-tabletmanager,grpc-updatestream,grpc-throttler", LogDir: tmpDirectory, @@ -389,7 +389,7 @@ func VttabletProcessInstance(port int, grpcPort int, tabletUID int, cell string, SupportsBackup: true, ServingStatus: "NOT_SERVING", BackupStorageImplementation: "file", - FileBackupStorageRoot: path.Join(GetEnvOrPanic("VTDATAROOT"), "/backups"), + FileBackupStorageRoot: path.Join(os.Getenv("VTDATAROOT"), "/backups"), VreplicationTabletType: "replica", TabletUID: tabletUID, } diff --git a/go/test/endtoend/cluster/vtworker_process.go b/go/test/endtoend/cluster/vtworker_process.go index d0780b9fccc..ab14eaab5ef 100644 --- a/go/test/endtoend/cluster/vtworker_process.go +++ b/go/test/endtoend/cluster/vtworker_process.go @@ -156,7 +156,6 @@ func (vtworker *VtworkerProcess) ExecuteCommand(args ...string) (err error) { return tmpProcess.Run() } -// ExecuteCommandInBg executes command in the background func (vtworker *VtworkerProcess) ExecuteCommandInBg(args ...string) (*exec.Cmd, error) { args = append([]string{"-vtworker_client_protocol", "grpc", "-server", vtworker.Server, "-log_dir", vtworker.LogDir, "-stderrthreshold", "info"}, args...) @@ -208,7 +207,7 @@ func VtworkerProcessInstance(httpPort int, grpcPort int, topoPort int, hostname GrpcPort: grpcPort, ExecuteRetryTime: "1s", CommandDisplayInterval: "10ms", - Directory: GetEnvOrPanic("VTDATAROOT"), + Directory: os.Getenv("VTDATAROOT"), Server: fmt.Sprintf("%s:%d", hostname, grpcPort), } vtworker.VerifyURL = fmt.Sprintf("http://%s:%d/debug/vars", hostname, vtworker.Port) diff --git a/go/test/endtoend/encryption/encryptedreplication/encrypted_replication_test.go b/go/test/endtoend/encryption/encryptedreplication/encrypted_replication_test.go index d08d3e01537..469aff3f74d 100644 --- a/go/test/endtoend/encryption/encryptedreplication/encrypted_replication_test.go +++ b/go/test/endtoend/encryption/encryptedreplication/encrypted_replication_test.go @@ -19,6 +19,7 @@ package encryptedreplication import ( "flag" "os" + "os/exec" "path" "testing" @@ -80,7 +81,7 @@ func testReplicationBase(t *testing.T, isClientCertPassed bool) { } func initializeCluster(t *testing.T) (int, error) { - var mysqlProcesses []*cluster.MySQLCmd + var mysqlProcesses []*exec.Cmd clusterInstance = cluster.NewCluster(cell, hostname) // Start topo server diff --git a/go/test/endtoend/encryption/encryptedtransport/encrypted_transport_test.go b/go/test/endtoend/encryption/encryptedtransport/encrypted_transport_test.go index 1594018f060..00bee425eed 100644 --- a/go/test/endtoend/encryption/encryptedtransport/encrypted_transport_test.go +++ b/go/test/endtoend/encryption/encryptedtransport/encrypted_transport_test.go @@ -241,7 +241,7 @@ func TestSecureTransport(t *testing.T) { } func clusterSetUp(t *testing.T) (int, error) { - var mysqlProcesses []*cluster.MySQLCmd + var mysqlProcesses []*exec.Cmd clusterInstance = cluster.NewCluster(cell, hostname) // Start topo server diff --git a/go/test/endtoend/mysqlctl/mysqlctl_test.go b/go/test/endtoend/mysqlctl/mysqlctl_test.go index 6f9a241ddda..986e4ef1e24 100644 --- a/go/test/endtoend/mysqlctl/mysqlctl_test.go +++ b/go/test/endtoend/mysqlctl/mysqlctl_test.go @@ -20,6 +20,7 @@ import ( "flag" "fmt" "os" + "os/exec" "testing" "github.com/stretchr/testify/require" @@ -81,7 +82,7 @@ func initCluster(shardNames []string, totalTabletsRequired int) { shard := &cluster.Shard{ Name: shardName, } - var mysqlCtlProcessList []*cluster.MySQLCmd + var mysqlCtlProcessList []*exec.Cmd for i := 0; i < totalTabletsRequired; i++ { // instantiate vttablet object with reserved ports tabletUID := clusterInstance.GetAndReserveTabletUID() @@ -152,7 +153,7 @@ func TestAutoDetect(t *testing.T) { defer cluster.PanicHandler(t) // Start up tablets with an empty MYSQL_FLAVOR, which means auto-detect - sqlFlavor, found := os.LookupEnv("MYSQL_FLAVOR") + sqlFlavor := os.Getenv("MYSQL_FLAVOR") os.Setenv("MYSQL_FLAVOR", "") err := clusterInstance.Keyspaces[0].Shards[0].Vttablets[0].VttabletProcess.Setup() @@ -165,8 +166,6 @@ func TestAutoDetect(t *testing.T) { require.Nil(t, err, "error should be nil") //Reset flavor - if found { - os.Setenv("MYSQL_FLAVOR", sqlFlavor) - } + os.Setenv("MYSQL_FLAVOR", sqlFlavor) } diff --git a/go/test/endtoend/recovery/pitr/binlog_server.go b/go/test/endtoend/recovery/pitr/binlog_server.go index f80bfe02722..b753d0faf8f 100644 --- a/go/test/endtoend/recovery/pitr/binlog_server.go +++ b/go/test/endtoend/recovery/pitr/binlog_server.go @@ -25,8 +25,6 @@ import ( "syscall" "time" - "vitess.io/vitess/go/test/endtoend/cluster" - "vitess.io/vitess/go/vt/log" ) @@ -56,7 +54,7 @@ type mysqlMaster struct { // newBinlogServer returns an instance of binlog server func newBinlogServer(hostname string, port int) (*binLogServer, error) { - dataDir := path.Join(cluster.GetEnvOrPanic("VTDATAROOT"), fmt.Sprintf("%s_%d", binlogDataDir, port)) + dataDir := path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("%s_%d", binlogDataDir, port)) fmt.Println(dataDir) if _, err := os.Stat(dataDir); os.IsNotExist(err) { err := os.Mkdir(dataDir, 0700) @@ -66,7 +64,7 @@ func newBinlogServer(hostname string, port int) (*binLogServer, error) { } } return &binLogServer{ - executablePath: path.Join(cluster.GetEnvOrPanic("EXTRA_BIN"), binlogExecutableName), + executablePath: path.Join(os.Getenv("EXTRA_BIN"), binlogExecutableName), dataDirectory: dataDir, username: binlogUser, hostname: hostname, diff --git a/go/test/endtoend/recovery/pitr/shardedpitr_test.go b/go/test/endtoend/recovery/pitr/shardedpitr_test.go index e27d4b073b3..16a9be2fed8 100644 --- a/go/test/endtoend/recovery/pitr/shardedpitr_test.go +++ b/go/test/endtoend/recovery/pitr/shardedpitr_test.go @@ -408,7 +408,7 @@ func initializeCluster(t *testing.T) { err = clusterInstance.LaunchCluster(keyspace, []cluster.Shard{*shard, *shard0, *shard1}) require.NoError(t, err) // Start MySql - var mysqlCtlProcessList []*cluster.MySQLCmd + var mysqlCtlProcessList []*exec.Cmd for _, shard := range clusterInstance.Keyspaces[0].Shards { for _, tablet := range shard.Vttablets { proc, err := tablet.MysqlctlProcess.StartProcess() diff --git a/go/test/endtoend/recovery/shardedrecovery/sharded_recovery_test.go b/go/test/endtoend/recovery/shardedrecovery/sharded_recovery_test.go index 4e14dd4d70f..80c968288d2 100644 --- a/go/test/endtoend/recovery/shardedrecovery/sharded_recovery_test.go +++ b/go/test/endtoend/recovery/shardedrecovery/sharded_recovery_test.go @@ -511,7 +511,7 @@ func initializeCluster(t *testing.T) (int, error) { err = localCluster.LaunchCluster(keyspace, []cluster.Shard{*shard, *shard0, *shard1}) require.NoError(t, err) // Start MySql - var mysqlCtlProcessList []*cluster.MySQLCmd + var mysqlCtlProcessList []*exec.Cmd for _, shard := range localCluster.Keyspaces[0].Shards { for _, tablet := range shard.Vttablets { if proc, err := tablet.MysqlctlProcess.StartProcess(); err != nil { diff --git a/go/test/endtoend/recovery/unshardedrecovery/recovery.go b/go/test/endtoend/recovery/unshardedrecovery/recovery.go index f014c3a27d5..a1df0be9c92 100644 --- a/go/test/endtoend/recovery/unshardedrecovery/recovery.go +++ b/go/test/endtoend/recovery/unshardedrecovery/recovery.go @@ -95,7 +95,7 @@ func TestMainImpl(m *testing.M) { localCluster.Keyspaces = append(localCluster.Keyspaces, *keyspace) dbCredentialFile = initialsharding.WriteDbCredentialToTmp(localCluster.TmpDirectory) - initDb, _ := ioutil.ReadFile(path.Join(cluster.GetEnvOrPanic("VTROOT"), "/config/init_db.sql")) + initDb, _ := ioutil.ReadFile(path.Join(os.Getenv("VTROOT"), "/config/init_db.sql")) sql := string(initDb) newInitDBFile = path.Join(localCluster.TmpDirectory, "init_db_with_passwords.sql") sql = sql + initialsharding.GetPasswordUpdateSQL(localCluster) @@ -108,7 +108,7 @@ func TestMainImpl(m *testing.M) { Name: shardName, } - var mysqlProcs []*cluster.MySQLCmd + var mysqlProcs []*exec.Cmd for i := 0; i < 4; i++ { tabletType := "replica" if i == 0 { diff --git a/go/test/endtoend/reparent/main_test.go b/go/test/endtoend/reparent/main_test.go index f02e4958a2c..87a8a95abae 100644 --- a/go/test/endtoend/reparent/main_test.go +++ b/go/test/endtoend/reparent/main_test.go @@ -21,6 +21,7 @@ import ( "flag" "fmt" "os" + "os/exec" "path" "testing" @@ -120,15 +121,16 @@ func TestMain(m *testing.M) { } //Start MySql - var mysqlCtlProcessList []*cluster.MySQLCmd + var mysqlCtlProcessList []*exec.Cmd for _, shard := range clusterInstance.Keyspaces[0].Shards { for _, tablet := range shard.Vttablets { log.Infof("Starting MySql for tablet %v", tablet.Alias) - proc, err := tablet.MysqlctlProcess.StartProcess() - if err != nil { + if proc, err := tablet.MysqlctlProcess.StartProcess(); err != nil { return 1 + } else { + // ignore golint warning, we need the else block to use proc + mysqlCtlProcessList = append(mysqlCtlProcessList, proc) } - mysqlCtlProcessList = append(mysqlCtlProcessList, proc) } } @@ -154,7 +156,7 @@ func getMysqlConnParam(tablet *cluster.Vttablet) mysql.ConnParams { connParams := mysql.ConnParams{ Uname: username, DbName: dbName, - UnixSocket: path.Join(cluster.GetEnvOrPanic("VTDATAROOT"), fmt.Sprintf("/vt_%010d/mysql.sock", tablet.TabletUID)), + UnixSocket: path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d/mysql.sock", tablet.TabletUID)), } return connParams } diff --git a/go/test/endtoend/sharded/sharded_keyspace_test.go b/go/test/endtoend/sharded/sharded_keyspace_test.go index 01820f160da..a5cf249dccb 100644 --- a/go/test/endtoend/sharded/sharded_keyspace_test.go +++ b/go/test/endtoend/sharded/sharded_keyspace_test.go @@ -20,6 +20,7 @@ import ( "flag" "fmt" "os" + "os/exec" "strings" "testing" @@ -197,7 +198,7 @@ func initCluster(shardNames []string, totalTabletsRequired int) { Name: shardName, } - var mysqlCtlProcessList []*cluster.MySQLCmd + var mysqlCtlProcessList []*exec.Cmd for i := 0; i < totalTabletsRequired; i++ { // instantiate vttablet object with reserved ports @@ -214,11 +215,11 @@ func initCluster(shardNames []string, totalTabletsRequired int) { } // Start Mysqlctl process tablet.MysqlctlProcess = *cluster.MysqlCtlProcessInstance(tablet.TabletUID, tablet.MySQLPort, clusterInstance.TmpDirectory) - proc, err := tablet.MysqlctlProcess.StartProcess() - if err != nil { + if proc, err := tablet.MysqlctlProcess.StartProcess(); err != nil { return + } else { + mysqlCtlProcessList = append(mysqlCtlProcessList, proc) } - mysqlCtlProcessList = append(mysqlCtlProcessList, proc) // start vttablet process tablet.VttabletProcess = cluster.VttabletProcessInstance(tablet.HTTPPort, diff --git a/go/test/endtoend/sharding/initialsharding/sharding_util.go b/go/test/endtoend/sharding/initialsharding/sharding_util.go index 83ca691f976..d72ec0000a0 100644 --- a/go/test/endtoend/sharding/initialsharding/sharding_util.go +++ b/go/test/endtoend/sharding/initialsharding/sharding_util.go @@ -130,7 +130,7 @@ func ClusterWrapper(isMulti bool) (int, error) { } func initClusterForInitialSharding(keyspaceName string, shardNames []string, totalTabletsRequired int, rdonly bool, isMulti bool) { - var mysqlProcesses []*cluster.MySQLCmd + var mysqlProcesses []*exec.Cmd var extraArgs []string if isMulti { extraArgs = []string{"-db-credentials-file", dbCredentialFile} @@ -629,7 +629,7 @@ func checkSrvKeyspaceForSharding(t *testing.T, ksName string, expectedPartitions // Create a new init_db.sql file that sets up passwords for all users. // Then we use a db-credentials-file with the passwords. func writeInitDBFile() { - initDb, _ := ioutil.ReadFile(path.Join(cluster.GetEnvOrPanic("VTROOT"), "/config/init_db.sql")) + initDb, _ := ioutil.ReadFile(path.Join(os.Getenv("VTROOT"), "/config/init_db.sql")) sql := string(initDb) newInitDbFile = path.Join(ClusterInstance.TmpDirectory, "init_db_with_passwords.sql") sql = sql + GetPasswordUpdateSQL(ClusterInstance) + ` diff --git a/go/test/endtoend/sharding/mergesharding/mergesharding_base.go b/go/test/endtoend/sharding/mergesharding/mergesharding_base.go index 62448317456..43b1ffc1065 100644 --- a/go/test/endtoend/sharding/mergesharding/mergesharding_base.go +++ b/go/test/endtoend/sharding/mergesharding/mergesharding_base.go @@ -20,6 +20,7 @@ import ( "context" "encoding/json" "fmt" + "os/exec" "path" "strings" "sync" @@ -163,7 +164,7 @@ func TestMergesharding(t *testing.T, useVarbinaryShardingKeyType bool) { assert.Equal(t, len(clusterInstance.Keyspaces[0].Shards), 4) //Start MySql - var mysqlCtlProcessList []*cluster.MySQLCmd + var mysqlCtlProcessList []*exec.Cmd for _, shard := range clusterInstance.Keyspaces[0].Shards { for _, tablet := range shard.Vttablets { log.Infof("Starting MySql for tablet %v", tablet.Alias) diff --git a/go/test/endtoend/sharding/resharding/resharding_base.go b/go/test/endtoend/sharding/resharding/resharding_base.go index b8e2a88fb4b..bca8b420f4f 100644 --- a/go/test/endtoend/sharding/resharding/resharding_base.go +++ b/go/test/endtoend/sharding/resharding/resharding_base.go @@ -20,6 +20,7 @@ import ( "context" "encoding/json" "fmt" + "os/exec" "path" "strings" "sync" @@ -252,7 +253,7 @@ func TestResharding(t *testing.T, useVarbinaryShardingKeyType bool) { assert.Equal(t, len(clusterInstance.Keyspaces[0].Shards), 4) //Start MySql - var mysqlCtlProcessList []*cluster.MySQLCmd + var mysqlCtlProcessList []*exec.Cmd for _, shard := range clusterInstance.Keyspaces[0].Shards { for _, tablet := range shard.Vttablets { log.Infof("Starting mysql for tablet %v", tablet.Alias) diff --git a/go/test/endtoend/sharding/verticalsplit/vertical_split_test.go b/go/test/endtoend/sharding/verticalsplit/vertical_split_test.go index 102514f8328..c0df6967ac6 100644 --- a/go/test/endtoend/sharding/verticalsplit/vertical_split_test.go +++ b/go/test/endtoend/sharding/verticalsplit/vertical_split_test.go @@ -20,6 +20,7 @@ import ( "context" "flag" "fmt" + "os/exec" "path" "reflect" "strings" @@ -621,7 +622,7 @@ func checkSrvKeyspaceServedFrom(t *testing.T, cell string, ksname string, expect } func initializeCluster() (int, error) { - var mysqlProcesses []*cluster.MySQLCmd + var mysqlProcesses []*exec.Cmd clusterInstance = cluster.NewCluster(cellj, hostname) // Start topo server diff --git a/go/test/endtoend/tabletgateway/cellalias/cell_alias_test.go b/go/test/endtoend/tabletgateway/cellalias/cell_alias_test.go index 6fb33dc1c04..afaf9f35f9d 100644 --- a/go/test/endtoend/tabletgateway/cellalias/cell_alias_test.go +++ b/go/test/endtoend/tabletgateway/cellalias/cell_alias_test.go @@ -26,6 +26,7 @@ import ( "flag" "fmt" "os" + "os/exec" "testing" "github.com/stretchr/testify/assert" @@ -125,7 +126,7 @@ func TestMain(m *testing.M) { shard2Replica = localCluster.NewVttabletInstance("replica", 0, cell2) shard2Rdonly = localCluster.NewVttabletInstance("rdonly", 0, cell2) - var mysqlProcs []*cluster.MySQLCmd + var mysqlProcs []*exec.Cmd for _, tablet := range []*cluster.Vttablet{shard1Master, shard1Replica, shard1Rdonly, shard2Master, shard2Replica, shard2Rdonly} { tablet.MysqlctlProcess = *cluster.MysqlCtlProcessInstance(tablet.TabletUID, tablet.MySQLPort, localCluster.TmpDirectory) tablet.VttabletProcess = cluster.VttabletProcessInstance(tablet.HTTPPort, diff --git a/go/test/endtoend/tabletmanager/main_test.go b/go/test/endtoend/tabletmanager/main_test.go index bae322342ad..476331263d7 100644 --- a/go/test/endtoend/tabletmanager/main_test.go +++ b/go/test/endtoend/tabletmanager/main_test.go @@ -135,12 +135,12 @@ func TestMain(m *testing.M) { masterTabletParams = mysql.ConnParams{ Uname: username, DbName: dbName, - UnixSocket: path.Join(cluster.GetEnvOrPanic("VTDATAROOT"), fmt.Sprintf("/vt_%010d/mysql.sock", masterTablet.TabletUID)), + UnixSocket: path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d/mysql.sock", masterTablet.TabletUID)), } replicaTabletParams = mysql.ConnParams{ Uname: username, DbName: dbName, - UnixSocket: path.Join(cluster.GetEnvOrPanic("VTDATAROOT"), fmt.Sprintf("/vt_%010d/mysql.sock", replicaTablet.TabletUID)), + UnixSocket: path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/vt_%010d/mysql.sock", replicaTablet.TabletUID)), } // create tablet manager client diff --git a/go/test/endtoend/vreplication/cluster.go b/go/test/endtoend/vreplication/cluster.go index cd17f37f9fb..34a90cd5640 100644 --- a/go/test/endtoend/vreplication/cluster.go +++ b/go/test/endtoend/vreplication/cluster.go @@ -6,6 +6,7 @@ import ( "fmt" "math/rand" "os" + "os/exec" "path" "strings" "testing" @@ -84,7 +85,7 @@ type Tablet struct { } func init() { - originalVtdataroot = cluster.GetEnvOrPanic("VTDATAROOT") + originalVtdataroot = os.Getenv("VTDATAROOT") } func initGlobals() { @@ -184,7 +185,7 @@ func (vc *VitessCluster) AddKeyspace(t *testing.T, cells []*Cell, ksName string, } // AddTablet creates new tablet with specified attributes -func (vc *VitessCluster) AddTablet(t *testing.T, cell *Cell, keyspace *Keyspace, shard *Shard, tabletType string, tabletID int) (*Tablet, *cluster.MySQLCmd, error) { +func (vc *VitessCluster) AddTablet(t *testing.T, cell *Cell, keyspace *Keyspace, shard *Shard, tabletType string, tabletID int) (*Tablet, *exec.Cmd, error) { tablet := &Tablet{} vttablet := cluster.VttabletProcessInstance( @@ -240,7 +241,7 @@ func (vc *VitessCluster) AddShards(t *testing.T, cells []*Cell, keyspace *Keyspa keyspace.Shards[shardName] = shard } for i, cell := range cells { - dbProcesses := make([]*cluster.MySQLCmd, 0) + dbProcesses := make([]*exec.Cmd, 0) tablets := make([]*Tablet, 0) if i == 0 { // only add master tablet for first cell, so first time CreateShard is called diff --git a/go/test/endtoend/vtcombo/vttest_sample_test.go b/go/test/endtoend/vtcombo/vttest_sample_test.go index da7a1c63e46..d3688a01043 100644 --- a/go/test/endtoend/vtcombo/vttest_sample_test.go +++ b/go/test/endtoend/vtcombo/vttest_sample_test.go @@ -28,8 +28,6 @@ import ( "strings" "testing" - "vitess.io/vitess/go/test/endtoend/cluster" - "vitess.io/vitess/go/vt/log" "github.com/stretchr/testify/assert" @@ -72,7 +70,7 @@ func TestMain(m *testing.M) { var cfg vttest.Config cfg.Topology = topology - cfg.SchemaDir = cluster.GetEnvOrPanic("VTROOT") + "/test/vttest_schema" + cfg.SchemaDir = os.Getenv("VTROOT") + "/test/vttest_schema" cfg.DefaultSchemaDir = os.Getenv("VTROOT") + "/test/vttest_schema/default" localCluster = &vttest.LocalCluster{ diff --git a/go/test/endtoend/vtctldweb/vtctld_web_main_test.go b/go/test/endtoend/vtctldweb/vtctld_web_main_test.go index 895c429da7a..72c2fcd031c 100644 --- a/go/test/endtoend/vtctldweb/vtctld_web_main_test.go +++ b/go/test/endtoend/vtctldweb/vtctld_web_main_test.go @@ -98,7 +98,7 @@ func TestMain(m *testing.M) { var cfg vttest.Config cfg.Topology = topology - cfg.SchemaDir = cluster.GetEnvOrPanic("VTROOT") + "/test/vttest_schema" + cfg.SchemaDir = os.Getenv("VTROOT") + "/test/vttest_schema" cfg.DefaultSchemaDir = os.Getenv("VTROOT") + "/test/vttest_schema/default" localCluster = &vttest.LocalCluster{ @@ -159,7 +159,7 @@ func CreateWebDriver(port int) error { // selenium.SetDebug(true) // Set common Options - options := selenium.ChromeDriver(cluster.GetEnvOrPanic("VTROOT") + "/dist") + options := selenium.ChromeDriver(os.Getenv("VTROOT") + "/dist") if os.Getenv("CI") == "true" && os.Getenv("TRAVIS") == "true" { diff --git a/go/test/endtoend/worker/worker_test.go b/go/test/endtoend/worker/worker_test.go index 4c19960a98c..520f3d6ba44 100644 --- a/go/test/endtoend/worker/worker_test.go +++ b/go/test/endtoend/worker/worker_test.go @@ -269,7 +269,7 @@ func verifySuccessfulWorkerCopyWithReparent(t *testing.T, isMysqlDown bool) { // third replica up the whole time. // start mysql - var mysqlCtlProcessStartList []*cluster.MySQLCmd + var mysqlCtlProcessStartList []*exec.Cmd for _, tablet := range []*cluster.Vttablet{shard0Master, shard1Master} { tablet.MysqlctlProcess.InitMysql = false @@ -580,7 +580,7 @@ func initializeCluster(t *testing.T, onlyTopo bool) (int, error) { assert.Nil(t, err) // Start MySql - var mysqlCtlProcessList []*cluster.MySQLCmd + var mysqlCtlProcessList []*exec.Cmd for _, shard := range localCluster.Keyspaces[0].Shards { for _, tablet := range shard.Vttablets { if proc, err := tablet.MysqlctlProcess.StartProcess(); err != nil {