Skip to content
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

fix(test): ensure that the controller sets rate limit status #13377

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions policy-test/tests/inbound_api.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::time::Duration;

use futures::prelude::*;
use k8s_openapi::chrono;

Check warning on line 4 in policy-test/tests/inbound_api.rs

View workflow job for this annotation

GitHub Actions / check

warning: unused import: `k8s_openapi::chrono` --> policy-test/tests/inbound_api.rs:4:5 | 4 | use k8s_openapi::chrono; | ^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default

Check warning on line 4 in policy-test/tests/inbound_api.rs

View workflow job for this annotation

GitHub Actions / clippy

warning: unused import: `k8s_openapi::chrono` --> policy-test/tests/inbound_api.rs:4:5 | 4 | use k8s_openapi::chrono; | ^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
use kube::ResourceExt;
use linkerd_policy_controller_core::{Ipv4Net, Ipv6Net};
use linkerd_policy_controller_k8s_api as k8s;
use linkerd_policy_test::{
assert_default_all_unauthenticated_labels, assert_is_default_all_unauthenticated,
assert_protocol_detect, create, create_ready_pod, grpc, with_temp_ns,
assert_protocol_detect, await_condition, create, create_ready_pod, grpc, with_temp_ns,
};
use maplit::{btreemap, convert_args, hashmap};
use tokio::time;
Expand Down Expand Up @@ -332,7 +332,7 @@
.await;

// Create a rate-limit policy associated to the server
create(
let rate_limit = create(
&client,
k8s::policy::ratelimit_policy::HttpLocalRateLimitPolicy {
metadata: k8s::ObjectMeta {
Expand All @@ -356,25 +356,29 @@
}],
}]),
},
status: Some(k8s::policy::HttpLocalRateLimitPolicyStatus {
conditions: vec![k8s::Condition {
last_transition_time: k8s::Time(chrono::DateTime::<chrono::Utc>::MIN_UTC),
message: "".to_string(),
observed_generation: None,
reason: "".to_string(),
status: "True".to_string(),
type_: "Accepted".to_string(),
}],
target_ref: k8s::policy::LocalTargetRef {
group: Some("policy.linkerd.io".to_string()),
kind: "Server".to_string(),
name: "linkerd-admin".to_string(),
},
}),
status: None,
},
)
.await;

await_condition(
&client,
&ns,
&rate_limit.name_unchecked(),
|obj: Option<&k8s::policy::ratelimit_policy::HttpLocalRateLimitPolicy>| {
obj.as_ref().map_or(false, |obj| {
obj.status.as_ref().map_or(false, |status| {
status
.conditions
.iter()
.any(|c| c.type_ == "Accepted" && c.status == "True")
})
})
},
)
.await
.expect("rate limit must get a status");

let client_id = format!("sa-0.{}.serviceaccount.identity.linkerd.cluster.local", ns);
let ratelimit_overrides = vec![(200, vec![client_id])];
let ratelimit =
Expand Down
Loading