From 09901dabc580882cbcbea90c66a574d71fe039dc Mon Sep 17 00:00:00 2001 From: Rohit Nayak Date: Sun, 15 Dec 2024 20:56:51 +0100 Subject: [PATCH] Try explicitly killing processes started during the tests to see if it fixes the flakiness seen by some residual processes, especially in the migrate tests Signed-off-by: Rohit Nayak --- go/test/endtoend/vreplication/cluster_test.go | 13 +++++++++++++ go/test/endtoend/vreplication/migrate_test.go | 3 +++ 2 files changed, 16 insertions(+) diff --git a/go/test/endtoend/vreplication/cluster_test.go b/go/test/endtoend/vreplication/cluster_test.go index dc5a72e5e88..f9a143983ab 100644 --- a/go/test/endtoend/vreplication/cluster_test.go +++ b/go/test/endtoend/vreplication/cluster_test.go @@ -933,6 +933,19 @@ func (vc *VitessCluster) startQuery(t *testing.T, query string) (func(t *testing return commit, rollback } +func killBinaries() { + binaries := []string{"mysqld_safe", "mysqld", "etcd", "mysqlctl", "mysqlctld", "vtgate", "vttablet", "vtctld", "vtctl", "vtorc"} + for _, bin := range binaries { + cmd := exec.Command("pkill", fmt.Sprintf(".*%s.*", bin)) + err := cmd.Run() + if err != nil { + log.Infof("Error killing %s: %v", bin, err) + } else { + log.Infof("Killed %s", bin) + } + } +} + // setupDBTypeVersion will perform any work needed to enable a specific // database type and version if not already installed. It returns a // function to reset any environment changes made. diff --git a/go/test/endtoend/vreplication/migrate_test.go b/go/test/endtoend/vreplication/migrate_test.go index 2ccb3158fd9..7911cee6ae2 100644 --- a/go/test/endtoend/vreplication/migrate_test.go +++ b/go/test/endtoend/vreplication/migrate_test.go @@ -48,6 +48,7 @@ func insertInitialDataIntoExternalCluster(t *testing.T, conn *mysql.Conn) { // hence the VTDATAROOT env variable gets overwritten. // Each time we need to create vt processes in the "other" cluster we need to set the appropriate VTDATAROOT func TestVtctlMigrate(t *testing.T) { + killBinaries() vc = NewVitessCluster(t, nil) oldDefaultReplicas := defaultReplicas @@ -175,6 +176,7 @@ func TestVtctlMigrate(t *testing.T) { // hence the VTDATAROOT env variable gets overwritten. // Each time we need to create vt processes in the "other" cluster we need to set the appropriate VTDATAROOT func TestVtctldMigrateUnsharded(t *testing.T) { + killBinaries() vc = NewVitessCluster(t, nil) oldDefaultReplicas := defaultReplicas @@ -320,6 +322,7 @@ func TestVtctldMigrateUnsharded(t *testing.T) { // doesn't match that of the source cluster. The test migrates from a cluster with keyspace customer to an "external" // cluster with keyspace rating. func TestVtctldMigrateSharded(t *testing.T) { + killBinaries() setSidecarDBName("_vt") currentWorkflowType = binlogdatapb.VReplicationWorkflowType_MoveTables oldDefaultReplicas := defaultReplicas