-
Notifications
You must be signed in to change notification settings - Fork 524
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
testsys: Refactor code base #2560
Conversation
abe13b1
to
0cae019
Compare
^ Convert error from |
9b684ca
to
497aecb
Compare
^ Add documentation |
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.
Refactor looks good to me. The testing looks good as well.
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.
Some recommendations. The biggest one is that I think we should stick with cluster
over orchestrator
, though I don't remember the reasoning behind the choice.
tools/testsys/src/sonobuoy.rs
Outdated
/// Create a Sonobuoy CRD for K8s conformance and quick testing. | ||
pub(crate) fn sonobuoy_crd(test_input: TestInput) -> Result<Test> { | ||
let cluster_resource_name = test_input | ||
.orchestrator_crd_name |
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'm leaning toward using the word cluster
instead of orchestrator since the word cluster is being used everywhere else already and introducing a new word is cognitively dissonant.
#[snafu(display("{} was missing from {}", item, what))] | ||
Missing { item: String, what: String }, | ||
|
||
#[snafu(context(false), display("{}", source))] |
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 context(false) because the Error type is not std::error::Error? I haven't used that feature before.
#[snafu(context(false), display("{}", source))]
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.
context(false)
makes it so you don't need to add the .context()
for error conversion.
#[serde(untagged)] | ||
pub(crate) enum TestType { | ||
Known(KnownTestType), | ||
Unknown(String), |
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.
It's not clear looking at this definition what the String
represents. As a doc comment for Unknown
.
use std::fs::File; | ||
|
||
/// Get the AMI for the given `region` from the `ami_input` file. | ||
pub(crate) fn ami(ami_input: &str, region: &str) -> Result<String> { |
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.
It feels like we should have a common struct for serializing/deserializing this
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.
There is but it is private in Pubsys
let config = aws_config::from_env() | ||
.region(Region::new(region.into())) | ||
.load() | ||
.await; | ||
let ec2_client = aws_sdk_ec2::Client::new(&config); | ||
// Find all images named `name` on `arch` in the `region`. |
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.
The owners 'self' default assumes that this is being used against developer-built images, right? we can pass in the AMI-ID for other use cases?
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.
Correct.
} | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
pub(crate) struct AmiImage { |
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 was the purpose of this type? Validation?
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.
Easy deserialization. That was not added in the refactor.
tools/testsys/src/aws_ecs.rs
Outdated
get_ami_id( | ||
format!( | ||
"bottlerocket-{}-{}-{}-{}", | ||
crd_input.variant, crd_input.arch, crd_input.starting_version.as_ref().context(error::InvalidSnafu{what: "The starting version must be provided for migration testing"})?, self.migrate_starting_commit.as_ref().context(error::InvalidSnafu{what: "The commit for the starting version must be provided if the starting image id is not"})? |
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.
Can you wrap this? Sadly rustfmt can't seem to handle things inside of macro calls.
tools/testsys/src/aws_k8s.rs
Outdated
get_ami_id( | ||
format!( | ||
"bottlerocket-{}-{}-{}-{}", | ||
crd_input.variant, crd_input.arch, crd_input.starting_version.as_ref().context(error::InvalidSnafu{what: "The starting version must be provided for migration testing"})?, self.migrate_starting_commit.as_ref().context(error::InvalidSnafu{what: "The commit for the starting version must be provided if the starting image id is not"})? |
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'm seeing repeated code here. Maybe put this in an ami_name function.
.crd_input | ||
.existing_crds( | ||
&labels, | ||
&["testsys/cluster", "testsys/type", "testsys/region"], |
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 we should think about constants for these. Technically even the array could be a constant but maybe that's not necessary.
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 think in this case, it's not necessary.
&self.repo_config.metadata_base_url, | ||
&self.repo_config.targets_url, | ||
) { | ||
debug!( |
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.
Can we enable debug log level through cargo make
currently? Aside: it might be nice to have a globally respected log level for Bottlerocket build and test processes that is respected throughout Makefile.toml
.
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.
-e RUST_LOG=debug
can be used to see those logs.
^
|
Changes the way TestSys crd's are created while keeping the same interface.
Changes the way TestSys crd's are created while keeping the same interface.
Issue number:
Closes #2533
Description of changes:
CrdCreator
. TheCrdCreator
is responsible for creating all CRDs for a given variant family (aws-k8s
,aws-ecs
). TheCrdCreator
has a few functions that need to be implemented that enables support for the standard testing types. To add a new testing family, only aCrdCreator
needs to be created.OrchestratorInput
,BottlerocketInput
, etc).CrdInput::existing_resources()
.aws-k8s
andaws-ecs
Testing done:
Created ECS and EKS testing with:
After testing was complete the following status was left:
Note: The instance providers are not in the status because
DestructionPolicy::OnTestSuccess
was used.Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.