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

policy: Add e2e egress tests #13390

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 22 additions & 1 deletion policy-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ pub mod grpc;
pub mod outbound_api;
pub mod web;

use kube::runtime::wait::Condition;
use linkerd_policy_controller_k8s_api::{
self as k8s,
policy::{httproute::ParentReference, EgressNetwork},
policy::{httproute::ParentReference, EgressNetwork, TrafficPolicy},
ResourceExt,
};
use maplit::{btreemap, convert_args};
Expand Down Expand Up @@ -349,6 +350,26 @@ pub fn endpoints_ready(obj: Option<&k8s::Endpoints>) -> bool {
false
}

pub fn egress_network_traffic_policy_is(
policy: TrafficPolicy,
) -> impl Condition<EgressNetwork> + 'static {
move |egress_net: Option<&EgressNetwork>| {
if let Some(egress_net) = &egress_net {
let status = egress_net.status.clone();
assert_status_accepted(status.map(|s| s.conditions).unwrap_or_default());

return egress_net.spec.traffic_policy == policy;
}
false
}
}

pub fn assert_status_accepted(conditions: Vec<k8s::Condition>) {
conditions
.iter()
.any(|c| c.type_ == "Accepted" && c.status == "True");
}

#[tracing::instrument(skip_all, fields(%pod, %container))]
pub async fn logs(client: &kube::Client, ns: &str, pod: &str, container: &str) {
let params = kube::api::LogParams {
Expand Down
Loading
Loading