forked from apache/cassandra-gocql-driver
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the datacenter name validation if provided
Fail to connect if DC name is different in the topology than the one the user entered.
- Loading branch information
1 parent
e6d9bec
commit bde593a
Showing
4 changed files
with
96 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//go:build integration && scylla | ||
// +build integration,scylla | ||
|
||
package gocql | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
// Check if session fail to start if DC name provided in the policy is wrong | ||
func TestDCValidationTokenAware(t *testing.T) { | ||
cluster := createCluster() | ||
|
||
fallback := DCAwareRoundRobinPolicy("WRONG_DC") | ||
cluster.PoolConfig.HostSelectionPolicy = TokenAwareHostPolicy(fallback) | ||
|
||
_, err := cluster.CreateSession() | ||
if err == nil { | ||
t.Fatal("createSession was expected to fail with wrong DC name provided.") | ||
} | ||
} | ||
|
||
func TestDCValidationDCAware(t *testing.T) { | ||
cluster := createCluster() | ||
cluster.PoolConfig.HostSelectionPolicy = DCAwareRoundRobinPolicy("WRONG_DC") | ||
|
||
_, err := cluster.CreateSession() | ||
if err == nil { | ||
t.Fatal("createSession was expected to fail with wrong DC name provided.") | ||
} | ||
} | ||
|
||
func TestDCValidationRackAware(t *testing.T) { | ||
cluster := createCluster() | ||
cluster.PoolConfig.HostSelectionPolicy = RackAwareRoundRobinPolicy("WRONG_DC", "RACK") | ||
|
||
_, err := cluster.CreateSession() | ||
if err == nil { | ||
t.Fatal("createSession was expected to fail with wrong DC name provided.") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters