1
1
mod common;
2
2
3
- use std:: io :: BufReader ;
3
+ use std:: path :: PathBuf ;
4
4
use std:: {
5
5
collections:: { BTreeSet , HashMap } ,
6
- fs:: { set_permissions, File , Permissions } ,
7
- io:: BufRead ,
8
- os:: unix:: fs:: PermissionsExt ,
9
- path:: PathBuf ,
10
6
time:: Duration ,
11
7
} ;
8
+ #[ cfg( feature = "otel_tests" ) ]
9
+ use std:: { fs:: File , io:: BufRead } ;
12
10
13
11
use common:: { app, setup} ;
14
12
@@ -26,18 +24,9 @@ use policy_evaluator::{
26
24
use policy_server:: {
27
25
api:: admission_review:: AdmissionReviewResponse ,
28
26
config:: { PolicyMode , PolicyOrPolicyGroup } ,
29
- metrics:: setup_metrics,
30
- tracing:: setup_tracing,
31
27
} ;
32
- use rcgen:: { BasicConstraints , CertificateParams , DnType , IsCa , KeyPair } ;
33
28
use regex:: Regex ;
34
29
use rstest:: * ;
35
- use tempfile:: NamedTempFile ;
36
- use testcontainers:: {
37
- core:: { Mount , WaitFor } ,
38
- runners:: AsyncRunner ,
39
- GenericImage , ImageExt ,
40
- } ;
41
30
use tokio:: fs;
42
31
use tower:: ServiceExt ;
43
32
@@ -804,10 +793,23 @@ async fn test_detect_certificate_rotation() {
804
793
}
805
794
}
806
795
807
- // This test is flaky, needs fix. Ignoring for release.
808
- # [ ignore ]
796
+ // The OTEL test is behind a feature flag because it needs to ensure that the
797
+ // global OTEL configuration is not overwritten by other concurrent tests.
809
798
#[ tokio:: test]
799
+ #[ cfg( feature = "otel_tests" ) ]
810
800
async fn test_otel ( ) {
801
+ use policy_server:: { metrics:: setup_metrics, tracing:: setup_tracing} ;
802
+ use std:: {
803
+ fs:: { set_permissions, Permissions } ,
804
+ os:: unix:: fs:: PermissionsExt ,
805
+ } ;
806
+ use tempfile:: NamedTempFile ;
807
+ use testcontainers:: {
808
+ core:: { Mount , WaitFor } ,
809
+ runners:: AsyncRunner ,
810
+ GenericImage , ImageExt ,
811
+ } ;
812
+
811
813
setup ( ) ;
812
814
813
815
let otelc_config_path =
@@ -970,9 +972,12 @@ async fn test_otel() {
970
972
otelc. stop ( ) . await . unwrap ( ) ;
971
973
}
972
974
975
+ #[ cfg( feature = "otel_tests" ) ]
973
976
async fn parse_exporter_output (
974
977
exporter_output_file : & File ,
975
978
) -> serde_json:: Result < serde_json:: Value > {
979
+ use std:: io:: BufReader ;
980
+
976
981
let mut reader = BufReader :: new ( exporter_output_file) ;
977
982
978
983
// read only the first entry in the output file
@@ -984,7 +989,10 @@ async fn parse_exporter_output(
984
989
serde_json:: from_str ( & exporter_output)
985
990
}
986
991
992
+ #[ cfg( feature = "otel_tests" ) ]
987
993
fn generate_tls_certs ( ) -> ( String , String , String ) {
994
+ use rcgen:: { BasicConstraints , CertificateParams , DnType , IsCa , KeyPair } ;
995
+
988
996
let ca_key = KeyPair :: generate ( ) . unwrap ( ) ;
989
997
let mut params = CertificateParams :: new ( vec ! [ "My Test CA" . to_string( ) ] ) . unwrap ( ) ;
990
998
params. is_ca = IsCa :: Ca ( BasicConstraints :: Unconstrained ) ;
0 commit comments