forked from apache/cassandra-gocql-driver
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from sylwiaszunejko/dc_name_validation
Add the datacenter name validation if provided
- Loading branch information
Showing
4 changed files
with
106 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