Skip to content
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
Expand Up @@ -7,7 +7,7 @@ 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 @@ async fn http_local_rate_limit_policy() {
.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 @@ async fn http_local_rate_limit_policy() {
}],
}]),
},
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