-
Notifications
You must be signed in to change notification settings - Fork 129
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
Backport ccm main #1296
base: main
Are you sure you want to change the base?
Backport ccm main #1296
Conversation
Cleanup unused dependancies
|
2f94f52
to
394dcec
Compare
It was released over 6 months ago so it is ok to use it. It allows us to use LazyCell.
ccm module will contain tests that require ccm. It's lib submodule will contain the ccm integration. Why do it this way - which is different than what we did during a hackathon? - Old way required ugly hacks to share test utils between integration test targets, and those hacks did not work well with rust-analyzer. - One target means better compilation time CCM tests will be guardded by a cfg, so we will still be able to run the subset that we want: - All tests: run integration tests with the required cfg - Only CCM tests: as above, but filter by ccm folder - Only non-ccm test: run without the cfg
ad0c3aa
to
6e14276
Compare
Possible improvements / API changes after a brief glance at the code:
|
Notice that I implemented all of this when we had old certificates in the repository. We had to update them, because of the errors thrown by Why old certs worked for
|
Moving such workflows to CCM has 2 advantages:
If we move only part of it, we get neither. So I'll cherry pick commits that move auth, and skip TLS for now. We can do that in the future. Btw is it possible to use domain names instead of ip addresses with scylla? In other words, can we have domain names instead of ip addresses in system.peers in driver-relevant columns? |
scylla can use hostnames, but then you need a dns server to map them. I think generating certs as needed is the best approach, and also give the flexibility to try more variants as needed. |
Is there functionality in CCM to generate certs? Or do we have to do it other way? If Scylla can use hostnames, then we should test it too. @fruch one other question for you. Could you describe (or point to documentation if such exists) what exactly wait-related flags do in CCM, and how do they interact if I specify more than one? |
you are more then welcome to document it. |
I'd be happy to make a PR that improves descriptions, but I would have to first understand those options myself. |
6e14276
to
aeabc5e
Compare
I backported the commits that move auth to CCM. I also removed TLS support from CCM for now. |
Marking as ready. The way I see it the only improvement I can make here is better CCM API - which needs input from others, which is basically a review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We hold nodes in Arc<RwLock<>>, and methods that give user nodes return that. Maybe we could return refs / mut refs and get rid of Arc<RwLock<>>? I'm not sure.
As of now, there is no use case for Arc<RwLock<>>
- I think we can return refs/mutrefs for now. We could always revert this in the future. It also simplifies the API - I believe NodeList
is no longer necessary then. Instead, we can expose nodes_iter_[mut]()
and get_node_[mut]_by_id
methods on Cluster
.
Currently, append_node()
and add_node()
methods return Arc<RwLock<>>
. They could return node id instead.
Co-authored-by: Mikołaj Uzarski <[email protected]> Co-authored-by: Dmitry Kropachev <[email protected]>
|
aeabc5e
to
d546b53
Compare
I have one more idea: we can split off another file from cluster.rs, I would call it |
d546b53
to
f05e4dc
Compare
I did this for 2 commands as an experiment, in additional commit. I like the new version, so unless anyone has different opinion I'll convert the rest of the command to this. @dkropachev I see that both |
55fced0
to
b605f97
Compare
b605f97
to
a02254c
Compare
For now it will run on each PR. If at some point it becomes too slow we can switch it to running manually and before release.
Co-authored-by: Mikołaj Uzarski <[email protected]>
Auth tests are now run as a part of CCM test suite.
I love the idea. The code in |
|
Could you elaborate? What bad happens in such scenario? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ cluster.rs
contains a lot of functions which are not used and whose goal is not always clear to me. Are we going to merge them as-is, only later wondering about their intended use and possibly adding documentation?
.inspect_err(|_err| { | ||
warn!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Note that as #1298 has been merged, there is one more spot that should be updated in this commit.
@@ -13,7 +13,7 @@ env: | |||
CARGO_TERM_COLOR: always | |||
RUSTFLAGS: -Dwarnings | |||
RUST_BACKTRACE: full | |||
rust_min: 1.70.0 # <- Update this when bumping up MSRV | |||
rust_min: 1.80.0 # <- Update this when bumping up MSRV |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Not to forget about it, I suggest making a follow-up commit that replaces lazy_static
uses with LazyLock
. Let's remove deps providing functionality that is already present in the standard library.
@@ -84,12 +84,15 @@ num-bigint-04 = { package = "num-bigint", version = "0.4" } | |||
bigdecimal-04 = { package = "bigdecimal", version = "0.4" } | |||
scylla-proxy = { version = "0.0.3", path = "../scylla-proxy" } | |||
ntest = "0.9.3" | |||
criterion = "0.4" # Note: v0.5 needs at least rust 1.70.0 | |||
tokio = { version = "1.34", features = ["test-util"] } | |||
criterion = "0.4" # Note: v0.5 needs at least rust 1.70.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📌 maybe let's bump it, as now we can?
anyhow = "1" | ||
tempfile = "3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 As you mentioned elsewhere @Lorak-mmk, omitting minor number can result in build problems in some scenarios. Let's write minors explicitly.
#[tokio::test] | ||
#[cfg_attr(not(ccm_tests), ignore)] | ||
async fn test_cluster_lifecycle1() { | ||
setup_tracing(); | ||
async fn test(cluster: Arc<Mutex<Cluster>>) { | ||
let cluster = cluster.lock().await; | ||
let session = cluster.make_session_builder().await.build().await.unwrap(); | ||
|
||
let rows = session | ||
.query_unpaged("select data_center from system.local", &[]) | ||
.await | ||
.expect("failed to execute query") | ||
.into_rows_result() | ||
.expect("failed to get rows") | ||
.rows::<(String,)>() | ||
.expect("failed to deserialize rows") | ||
.map(|res| res.map(|row| row.0)) | ||
.collect::<Result<Vec<_>, _>>() | ||
.unwrap(); | ||
debug!("{:?}", rows); | ||
} | ||
run_ccm_test(cluster_1_node, test).await; | ||
} | ||
|
||
#[tokio::test] | ||
#[cfg_attr(not(ccm_tests), ignore)] | ||
async fn test_cluster_lifecycle2() { | ||
setup_tracing(); | ||
async fn test(cluster: Arc<Mutex<Cluster>>) { | ||
let cluster = cluster.lock().await; | ||
let session = cluster.make_session_builder().await.build().await.unwrap(); | ||
|
||
let rows = session | ||
.query_unpaged("select data_center from system.local", &[]) | ||
.await | ||
.expect("failed to execute query") | ||
.into_rows_result() | ||
.expect("failed to get rows") | ||
.rows::<(String,)>() | ||
.expect("failed to deserialize rows") | ||
.map(|res| res.map(|row| row.0)) | ||
.collect::<Result<Vec<_>, _>>() | ||
.unwrap(); | ||
debug!("{:?}", rows); | ||
} | ||
run_ccm_test(cluster_1_node, test).await; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Is there any difference between these two tests? I can't find any.
let nodes_string = nodes | ||
.iter() | ||
.map(|node| node.to_string()) | ||
.collect::<Vec<String>>() | ||
.join(":"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ Let's use Itertools::join
. Unnecessary collect()
pains my eyes even though I know these are just tests...
pub(crate) struct ClusterCreate<'ccm> { | ||
ccm: &'ccm mut Ccm, | ||
name: String, | ||
version: String, | ||
ip_prefix: String, | ||
db_type: DBType, | ||
} | ||
|
||
impl Ccm { | ||
pub(crate) fn cluster_create( | ||
&mut self, | ||
name: String, | ||
version: String, | ||
ip_prefix: NetPrefix, | ||
db_type: DBType, | ||
) -> ClusterCreate<'_> { | ||
ClusterCreate { | ||
ccm: self, | ||
name, | ||
version, | ||
ip_prefix: ip_prefix.to_string(), | ||
db_type, | ||
} | ||
} | ||
} | ||
|
||
impl ClusterCreate<'_> { | ||
pub(crate) async fn run(self) -> Result<ExitStatus, anyhow::Error> { | ||
let mut args: Vec<&str> = vec![ | ||
"create", | ||
self.name.as_str(), | ||
"--version", | ||
self.version.as_str(), | ||
"--ipprefix", | ||
self.ip_prefix.as_str(), | ||
"--config-dir", | ||
self.ccm.config_dir.as_str(), | ||
]; | ||
if self.db_type == DBType::Scylla { | ||
args.push("--scylla"); | ||
} | ||
self.ccm | ||
.cmd | ||
.run_command("ccm", &args, RunOptions::new()) | ||
.await | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 🤩 What a great, clean design! Congrats!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now all parameters are accepted in the constructor of the command. I'll switch it to builder pattern soon, and of course move other commands too.
pub(super) fn to_str(self) -> String { | ||
match self.0 { | ||
IpAddr::V4(v4) => { | ||
let octets = v4.octets(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 I doubted to_*
functions should accept self
by value, even in case of Copy
types.
However, a quick look at i64::to_be() convinced me. TIL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to change this name anyway, but not because of to_
part. The str
part is the problem imo, as the function returns String
, not &str
.
|
||
impl std::fmt::Display for NetPrefix { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "{}", self.to_str()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ Should have a bit lower overhead (at least compile-time):
write!(f, "{}", self.to_str()) | |
f.write_str(self.to_str()) |
let ip_port: Vec<&str> = ip_hex.split(':').collect(); | ||
if let Some(ip_hex) = ip_port.first() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let ip_port: Vec<&str> = ip_hex.split(':').collect(); | |
if let Some(ip_hex) = ip_port.first() { | |
let mut ip_port = ip_hex.split(':'); | |
if let Some(ip_hex) = ip_port.next() { |
@muzarski @wprzytula This is a draft of the CCM backport into main branch.
I mostly took the current state from branch-hackathon. One important change I made is to remove separate
ccm-integration
test target. Instead ccm tests are now a module inintegration
.This avoids the problem with sharing utils. It should also be quicker to compile - no need to link 2 separate binaries.
Apart from that I did not really modify CCM integration. Now the question is: what do we do with it.
Are we satisfied with the API? Probably not.
If not, what should the API be like?
This is fully internal to the crate, so we can change it freely, so there is no need to spend too much time on it - we can always improve later.
Still, we should retain some reasonable level of quality, so I'd like to discuss this a bit.
I did not yet pick up @muzarski 's changes that integrated auth and TLS workflows into CCM. I can do that after we agree to the rest of this PR.
On the above matter @muzarski : How should I adapt CCM given that we now support multiple TLS backends?
I see we have in mod.rs DB_TLS_CERT_PATH, DB_TLS_KEY_PATH and CA_TLS_CERT_PATH (which I removed for now because it was guarded by old feature name).
I also see that on branch-hackathon you wrote a TLS test. We should probably make a test per backend, right?
What about those vars? Do they make sense for all the tests? In that case we just need to change feature guard on CA_TLS_CERT_PATH to be activated when any backend is active - or to even make it always active because why not.
Pre-review checklist
./docs/source/
.Fixes:
annotations to PR description.