-
Notifications
You must be signed in to change notification settings - Fork 4k
testcluster: assign unique ClusterName #157868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import ( | |
| "context" | ||
| gosql "database/sql" | ||
| "fmt" | ||
| "math/rand/v2" | ||
| "net" | ||
| "os" | ||
| "reflect" | ||
|
|
@@ -86,6 +87,11 @@ type TestCluster struct { | |
|
|
||
| var _ serverutils.TestClusterInterface = &TestCluster{} | ||
|
|
||
| // ClusterName returns the configured or auto-generated cluster name. | ||
| func (tc *TestCluster) ClusterName() string { | ||
| return tc.clusterArgs.ServerArgs.ClusterName | ||
| } | ||
|
|
||
| // NumServers is part of TestClusterInterface. | ||
| func (tc *TestCluster) NumServers() int { | ||
| return len(tc.Servers) | ||
|
|
@@ -317,6 +323,11 @@ func NewTestCluster( | |
| if clusterArgs.StartSingleNode && nodes > 1 { | ||
| t.Fatal("StartSingleNode implies 1 node only, but asked to create", nodes) | ||
| } | ||
| if clusterArgs.ServerArgs.ClusterName == "" { | ||
| // Use a cluster name that is sufficiently unique (within the CI env) but is | ||
| // concise and recognizable. | ||
| clusterArgs.ServerArgs.ClusterName = fmt.Sprintf("TestCluster-%d", rand.Uint32()) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is recent evidence to suggest
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. I'll fix up. |
||
| } | ||
|
|
||
| if err := checkServerArgsForCluster( | ||
| clusterArgs.ServerArgs, clusterArgs.ReplicationMode, disallowJoinAddr, | ||
|
|
@@ -634,6 +645,9 @@ func (tc *TestCluster) AddServer( | |
| if serverArgs.JoinAddr != "" { | ||
| serverArgs.NoAutoInitializeCluster = true | ||
| } | ||
| if serverArgs.ClusterName == "" { | ||
| serverArgs.ClusterName = tc.clusterArgs.ServerArgs.ClusterName | ||
| } | ||
|
|
||
| // Check args even though we have called checkServerArgsForCluster() | ||
| // already in NewTestCluster(). AddServer might be called for servers | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.