Skip to content

Commit

Permalink
Fix mirrord ls test (#3050)
Browse files Browse the repository at this point in the history
* Test fixed

* Changelog

* Updated CONTRIBUTING guide

* Fixed changelog

* Added service to expected types

* Removed useless iter
  • Loading branch information
Razz4780 authored Jan 31, 2025
1 parent 2c4bf38 commit d5c9170
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -570,3 +570,13 @@ cargo-zigbuild clippy --lib --bins --all-features --target x86_64-unknown-linux-
If it doesn't work, try updating `cargo-zigbuild`
(`cargo install cargo-zigbuild` or maybe `cargo install cargo-zigbuild --force`)
or via `homebrew` if it was installed via homebrew.
# Adding new target types
Adding a new target type for mirrord requires changes in:
1. `mirrord-config` crate - parsing the target from the user config;
2. `mirrord-cli` crate - verifying the user config;
3. `mirrord-kube` crate - resolving the target to the Kubernetes resource;
4. `mirrord-operator` crate - defining operator's `ClusterRole`;
5. `test` crate - testing `mirrord ls` command
1 change: 1 addition & 0 deletions changelog.d/+ls-test.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated `tests::operator::sanity::mirrord_ls` test after adding ReplicaSet support.
19 changes: 17 additions & 2 deletions tests/src/operator/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,30 @@ pub async fn mirrord_ls(#[future] service_for_mirrord_ls: KubeService) {
assert!(res.success());
let stdout = process.get_stdout().await;
let targets: Vec<String> = serde_json::from_str(&stdout).unwrap();
let re = Regex::new(r"^(pod|deployment|statefulset|cronjob|job)/.+(/container/.+)?$").unwrap();

let expected_target_types = [
"pod",
"deployment",
"statefulset",
"cronjob",
"job",
"replicaset",
"service",
];

let re = Regex::new(&format!(
r"^({})/.+(/container/.+)?$",
expected_target_types.join("|")
))
.unwrap();
targets.iter().for_each(|output| {
assert!(
re.is_match(output),
"output line {output} does not match regex {re}"
);
});

for target_type in ["pod", "deployment", "statefulset", "cronjob", "job"] {
for target_type in expected_target_types {
assert!(
targets
.iter()
Expand Down

0 comments on commit d5c9170

Please sign in to comment.