Skip to content

Commit

Permalink
CI: Add some randomness to the ports used in VReplication e2e tests (#…
Browse files Browse the repository at this point in the history
…17712)

Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord authored Feb 10, 2025
1 parent 4c9de0b commit b567098
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 8 additions & 2 deletions go/test/endtoend/vreplication/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
5 changes: 3 additions & 2 deletions go/test/endtoend/vreplication/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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())
})

Expand Down

0 comments on commit b567098

Please sign in to comment.