-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integration: add tests for hostname resolution
Two scenarios are tested: 1) when some hostnames are invalid, but there are some addresses resolved successfully, initialisation continues without an error, 2) when all hostnames are invalid, and there are no adresses given, then NewSessionError::FailedToResolveAnyHostname is returned.
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
mod execution_profiles; | ||
mod hygiene; | ||
mod lwt_optimisation; | ||
mod new_session; | ||
mod retries; | ||
pub(crate) mod utils; |
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,34 @@ | ||
use assert_matches::assert_matches; | ||
use scylla::SessionBuilder; | ||
use scylla_cql::errors::NewSessionError; | ||
|
||
#[cfg(not(scylla_cloud_tests))] | ||
#[tokio::test] | ||
async fn proceed_if_only_some_hostnames_are_invalid() { | ||
// on purpose left without port | ||
let uri1 = "scylladbisthefastest.db".to_owned(); | ||
// correctly provided port, but unknown domain | ||
let uri2 = "cassandrasuckssomu.ch:9042".to_owned(); | ||
let uri3 = std::env::var("SCYLLA_URI3").unwrap_or_else(|_| "127.0.0.3:9042".to_string()); | ||
|
||
let session = SessionBuilder::new() | ||
.known_nodes([uri1, uri2, uri3]) | ||
.build() | ||
.await | ||
.unwrap(); | ||
session | ||
.query("SELECT host_id FROM system.local", &[]) | ||
.await | ||
.unwrap(); | ||
} | ||
|
||
#[cfg(not(scylla_cloud_tests))] | ||
#[tokio::test] | ||
async fn all_hostnames_invalid() { | ||
let uri = "cassandrasuckssomu.ch:9042".to_owned(); | ||
|
||
assert_matches!( | ||
SessionBuilder::new().known_node(uri).build().await, | ||
Err(NewSessionError::FailedToResolveAnyHostname(_)) | ||
); | ||
} |