diff --git a/go/test/endtoend/vreplication/cluster_test.go b/go/test/endtoend/vreplication/cluster_test.go index 1cf44e1d4c7..e6181cad31b 100644 --- a/go/test/endtoend/vreplication/cluster_test.go +++ b/go/test/endtoend/vreplication/cluster_test.go @@ -297,11 +297,17 @@ func downloadDBTypeVersion(dbType string, majorVersion string, path string) erro } func getClusterConfig(idx int, dataRootDir string) *ClusterConfig { + offset := 0 + if !debugMode { + // Add some randomness to the ports so that multiple tests can run in + // parallel on the same host. + offset = (idx + 1) * rand.IntN(1000) + } basePort := 15000 etcdPort := 2379 - basePort += idx * 10000 - etcdPort += idx * 10000 + basePort += (idx * 10000) + offset + etcdPort += (idx * 10000) + offset if _, err := os.Stat(dataRootDir); os.IsNotExist(err) { os.Mkdir(dataRootDir, 0700) } diff --git a/go/test/endtoend/vreplication/migrate_test.go b/go/test/endtoend/vreplication/migrate_test.go index ef20d953781..676ce128fa0 100644 --- a/go/test/endtoend/vreplication/migrate_test.go +++ b/go/test/endtoend/vreplication/migrate_test.go @@ -96,8 +96,9 @@ func TestMigrateUnsharded(t *testing.T) { var output, expected string t.Run("mount external cluster", func(t *testing.T) { + etcdHostPort := fmt.Sprintf("localhost:%d", extVc.ClusterConfig.topoPort) output, err := vc.VtctldClient.ExecuteCommandWithOutput("Mount", "register", "--name=ext1", "--topo-type=etcd2", - fmt.Sprintf("--topo-server=localhost:%d", extVc.ClusterConfig.topoPort), "--topo-root=/vitess/global") + "--topo-server", etcdHostPort, "--topo-root=/vitess/global") require.NoError(t, err, "Mount Register command failed with %s", output) output, err = vc.VtctldClient.ExecuteCommandWithOutput("Mount", "list") @@ -110,7 +111,7 @@ func TestMigrateUnsharded(t *testing.T) { require.NoError(t, err, "Mount command failed with %s\n", output) require.Equal(t, "etcd2", gjson.Get(output, "topo_type").String()) - require.Equal(t, "localhost:12379", gjson.Get(output, "topo_server").String()) + require.Equal(t, etcdHostPort, gjson.Get(output, "topo_server").String()) require.Equal(t, "/vitess/global", gjson.Get(output, "topo_root").String()) })