mirror of https://github.com/linkerd/linkerd2.git
feat(policy-test): conditionally compile experimental type tests (#13891)
Our policy controller tests execute tests for resources that are not part of the stable gateway-api distribution. To support testing only the stable API, this change introduces a new `gateway-api-experimental` feature that enables compilation of TCPRoute and TLSRoute tests and utilities. This features is enabled by default, as that is the current behavior. This will be consumed by CI in followup changes.
This commit is contained in:
parent
9316c2b3fb
commit
9110660fe0
|
|
@ -5,6 +5,10 @@ edition = "2021"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["gateway-api-experimental"]
|
||||||
|
gateway-api-experimental = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
|
|
|
||||||
|
|
@ -293,6 +293,7 @@ pub async fn await_grpc_route_status(
|
||||||
route_status
|
route_status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "gateway-api-experimental")]
|
||||||
// Waits until an TlsRoute with the given namespace and name has a status set
|
// Waits until an TlsRoute with the given namespace and name has a status set
|
||||||
// on it, then returns the generic route status representation.
|
// on it, then returns the generic route status representation.
|
||||||
pub async fn await_tls_route_status(
|
pub async fn await_tls_route_status(
|
||||||
|
|
@ -316,6 +317,7 @@ pub async fn await_tls_route_status(
|
||||||
route_status
|
route_status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "gateway-api-experimental")]
|
||||||
// Waits until an TcpRoute with the given namespace and name has a status set
|
// Waits until an TcpRoute with the given namespace and name has a status set
|
||||||
// on it, then returns the generic route status representation.
|
// on it, then returns the generic route status representation.
|
||||||
pub async fn await_tcp_route_status(
|
pub async fn await_tcp_route_status(
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ pub fn grpc_routes(config: &grpc::outbound::OutboundPolicy) -> &[grpc::outbound:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "gateway-api-experimental")]
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn tls_routes(config: &grpc::outbound::OutboundPolicy) -> &[grpc::outbound::TlsRoute] {
|
pub fn tls_routes(config: &grpc::outbound::OutboundPolicy) -> &[grpc::outbound::TlsRoute] {
|
||||||
let kind = config
|
let kind = config
|
||||||
|
|
@ -137,6 +138,7 @@ pub fn tls_routes(config: &grpc::outbound::OutboundPolicy) -> &[grpc::outbound::
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "gateway-api-experimental")]
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn tcp_routes(config: &grpc::outbound::OutboundPolicy) -> &[grpc::outbound::OpaqueRoute] {
|
pub fn tcp_routes(config: &grpc::outbound::OutboundPolicy) -> &[grpc::outbound::OpaqueRoute] {
|
||||||
let kind = config
|
let kind = config
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@ use linkerd_policy_controller_k8s_api::{
|
||||||
self as k8s, gateway, policy, Condition, Resource as _, ResourceExt,
|
self as k8s, gateway, policy, Condition, Resource as _, ResourceExt,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::outbound_api::{detect_http_routes, grpc_routes, tcp_routes, tls_routes};
|
use crate::outbound_api::{detect_http_routes, grpc_routes};
|
||||||
|
#[cfg(feature = "gateway-api-experimental")]
|
||||||
|
use crate::outbound_api::{tcp_routes, tls_routes};
|
||||||
|
|
||||||
pub trait TestRoute:
|
pub trait TestRoute:
|
||||||
kube::Resource<Scope = kube::core::NamespaceResourceScope, DynamicType: Default>
|
kube::Resource<Scope = kube::core::NamespaceResourceScope, DynamicType: Default>
|
||||||
|
|
@ -482,6 +484,7 @@ impl TestRoute for gateway::GRPCRoute {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "gateway-api-experimental")]
|
||||||
impl TestRoute for gateway::TLSRoute {
|
impl TestRoute for gateway::TLSRoute {
|
||||||
type Route = outbound::TlsRoute;
|
type Route = outbound::TlsRoute;
|
||||||
type Backend = outbound::tls_route::RouteBackend;
|
type Backend = outbound::tls_route::RouteBackend;
|
||||||
|
|
@ -626,6 +629,7 @@ impl TestRoute for gateway::TLSRoute {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "gateway-api-experimental")]
|
||||||
impl TestRoute for gateway::TCPRoute {
|
impl TestRoute for gateway::TCPRoute {
|
||||||
type Route = outbound::OpaqueRoute;
|
type Route = outbound::OpaqueRoute;
|
||||||
type Backend = outbound::opaque_route::RouteBackend;
|
type Backend = outbound::opaque_route::RouteBackend;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![cfg(feature = "gateway-api-experimental")]
|
||||||
|
|
||||||
use linkerd_policy_controller_k8s_api::{self as api, gateway};
|
use linkerd_policy_controller_k8s_api::{self as api, gateway};
|
||||||
use linkerd_policy_test::admission;
|
use linkerd_policy_test::admission;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![cfg(feature = "gateway-api-experimental")]
|
||||||
|
|
||||||
use linkerd_policy_controller_k8s_api::{self as api, gateway};
|
use linkerd_policy_controller_k8s_api::{self as api, gateway};
|
||||||
use linkerd_policy_test::admission;
|
use linkerd_policy_test::admission;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue