Skip to content

Commit

Permalink
fix cdrs list/set eq
Browse files Browse the repository at this point in the history
  • Loading branch information
conorbros committed Nov 22, 2022
1 parent ee4321b commit 6e37c7f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 45 deletions.
84 changes: 46 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions shotover-proxy/Cargo.toml
Expand Up @@ -64,7 +64,7 @@ halfbrown = "0.1.11"

# Transform dependencies
redis-protocol = { version = "4.0.1", features = ["decode-mut"] }
cassandra-protocol = { git = "https://github.com/conorbros/cdrs-tokio", branch = "8.0-dev" }
cassandra-protocol = { git = "https://github.com/krojew/cdrs-tokio", branch = "8.0-dev" }
crc16 = "0.4.0"
ordered-float = { version = "3.0.0", features = ["serde"] }

Expand All @@ -91,7 +91,7 @@ hex-literal = "0.3.3"
nix = "0.25.0"
reqwest = "0.11.6"
metrics-util = "0.14.0"
cdrs-tokio = { git = "https://github.com/conorbros/cdrs-tokio", branch = "8.0-dev" }
cdrs-tokio = { git = "https://github.com/krojew/cdrs-tokio", branch = "8.0-dev" }
scylla = { git = "https://github.com/scylladb/scylla-rust-driver", features = ["ssl"] }
rstest = "0.15.0"

Expand Down
Expand Up @@ -63,7 +63,7 @@ async fn test_rewrite_system_peers_dummy_peers(connection: &CassandraConnection)
ResultValue::Any,
// Unfortunately token generation appears to be non-deterministic but we can at least assert that
// there are 128 tokens per node
ResultValue::Set(std::iter::repeat(ResultValue::Any).take(3 * 128).collect()),
ResultValue::AnyList(std::iter::repeat(ResultValue::Any).take(3 * 128).collect()),
];
let star_results2 = [
ResultValue::Inet("127.0.0.1".parse().unwrap()),
Expand All @@ -78,7 +78,7 @@ async fn test_rewrite_system_peers_dummy_peers(connection: &CassandraConnection)
ResultValue::Any,
// Unfortunately token generation appears to be non-deterministic but we can at least assert that
// there are 128 tokens per node
ResultValue::Set(std::iter::repeat(ResultValue::Any).take(3 * 128).collect()),
ResultValue::AnyList(std::iter::repeat(ResultValue::Any).take(3 * 128).collect()),
];

let all_columns = "peer, data_center, host_id, preferred_ip, rack, release_version, rpc_address, schema_version, tokens";
Expand Down Expand Up @@ -121,7 +121,7 @@ async fn test_rewrite_system_peers_v2_dummy_peers(connection: &CassandraConnecti
ResultValue::Any,
// Unfortunately token generation appears to be non-deterministic but we can at least assert that
// there are 128 tokens per node
ResultValue::Set(std::iter::repeat(ResultValue::Any).take(3 * 128).collect()),
ResultValue::AnyList(std::iter::repeat(ResultValue::Any).take(3 * 128).collect()),
];
let star_results2 = [
ResultValue::Inet("127.0.0.1".parse().unwrap()),
Expand All @@ -138,7 +138,7 @@ async fn test_rewrite_system_peers_v2_dummy_peers(connection: &CassandraConnecti
ResultValue::Any,
// Unfortunately token generation appears to be non-deterministic but we can at least assert that
// there are 128 tokens per node
ResultValue::Set(std::iter::repeat(ResultValue::Any).take(3 * 128).collect()),
ResultValue::AnyList(std::iter::repeat(ResultValue::Any).take(3 * 128).collect()),
];

let all_columns = "peer, peer_port, data_center, host_id, native_address, native_port, preferred_ip, preferred_port, rack, release_version, schema_version, tokens";
Expand Down Expand Up @@ -190,7 +190,7 @@ async fn test_rewrite_system_local(connection: &CassandraConnection) {
ResultValue::Any,
// Unfortunately token generation appears to be non-deterministic but we can at least assert that
// there are 128 tokens per node
ResultValue::Set(std::iter::repeat(ResultValue::Any).take(3 * 128).collect()),
ResultValue::AnyList(std::iter::repeat(ResultValue::Any).take(3 * 128).collect()),
// truncated_at is non deterministic so we cant assert on it.
ResultValue::Any,
];
Expand Down
7 changes: 7 additions & 0 deletions shotover-proxy/tests/helpers/cassandra.rs
Expand Up @@ -753,6 +753,8 @@ pub enum ResultValue {
/// Can be used by the user in assertions to allow any value.
#[allow(dead_code)]
Any,
#[allow(dead_code)]
AnyList(Vec<ResultValue>),
}

impl PartialEq for ResultValue {
Expand Down Expand Up @@ -785,6 +787,11 @@ impl PartialEq for ResultValue {
(Self::Null, Self::Null) => true,
(Self::Any, _) => true,
(_, Self::Any) => true,
(Self::AnyList(l0), Self::AnyList(r0)) => l0 == r0,
(Self::AnyList(l0), Self::Set(r0)) => l0 == r0,
(Self::AnyList(l0), Self::List(r0)) => l0 == r0,
(Self::Set(l0), Self::AnyList(r0)) => l0 == r0,
(Self::List(l0), Self::AnyList(r0)) => l0 == r0,
_ => false,
}
}
Expand Down

0 comments on commit 6e37c7f

Please sign in to comment.