@@ -16,11 +16,15 @@ const ingressDaemonSample = `{"apiVersion":"apps/v1","kind":"DaemonSet","metadat
1616// Unexpected containers, observer failures and identity changes must prevent a
1717// usable result, even after the observer has returned plausible flow bytes.
1818func TestIngressObserverBindsExecutionAndRefusesPartialEvidence (t * testing.T ) {
19- for _ , mode := range []string {"matching" , "named-cluster" , "cluster-churn" , "unready-agent" , "agent-churn" , "daemon-churn" , "probe-failure" , "observer-failure" , "empty-flow" , "truncated-flow" } {
19+ for _ , mode := range []string {"matching" , "named-cluster" , "active-proxy" , "native-port-while-proxied" , " cluster-churn" , "unready-agent" , "agent-churn" , "daemon-churn" , "probe-failure" , "observer-failure" , "empty-flow" , "truncated-flow" } {
2020 t .Run (mode , func (t * testing.T ) {
2121 podReads , daemonReads , executions , probes , clockReads := 0 , 0 , 0 , 0 , 0
2222 clusterReads := 0
2323 start := time .Date (2026 , 10 , 28 , 16 , 0 , 0 , 0 , time .UTC )
24+ app := binding {UID : "44444444-4444-4444-4444-444444444444" , Node : "worker-1" }
25+ if mode == "active-proxy" || mode == "native-port-while-proxied" {
26+ app .ProxyConfig = approvedProxyMap
27+ }
2428 run := func (_ context.Context , args ... string ) ([]byte , error ) {
2529 switch strings .Join (args , " " ) {
2630 case "--context admin@prod --request-timeout=10s get configmap cilium-config -n kube-system -o json" :
@@ -56,8 +60,12 @@ func TestIngressObserverBindsExecutionAndRefusesPartialEvidence(t *testing.T) {
5660 if len (args ) != 24 || ! reflect .DeepEqual (args [:16 ], prefix ) || args [16 ] != "--since" || args [17 ] != "2026-10-28T16:00:00Z" || args [18 ] != "--until" || args [19 ] != "2026-10-28T16:00:10Z" || args [20 ] != "--allowlist" || args [22 ] != "--output" || args [23 ] != "jsonpb" {
5761 return nil , errors .New ("unexpected native operation" )
5862 }
63+ expectedFilter := `{"destination_ip":["10.244.2.2"],"destination_pod":["private-mail/private-mail-0"],"destination_port":["8080"],"protocol":["tcp"],"source_identity":[8],"tcp_flags":[{"SYN":true}],"reply":[false],"verdict":["FORWARDED"],"traffic_direction":["INGRESS","EGRESS"],"event_type":[{"type":4,"match_sub_type":true,"sub_type":0}]}`
64+ if app .ProxyConfig != "" {
65+ expectedFilter = strings .Replace (expectedFilter , `["8080"]` , `["8081"]` , 1 )
66+ }
5967 var actual , expected any
60- if json .Unmarshal ([]byte (args [21 ]), & actual ) != nil || json .Unmarshal ([]byte (`{"destination_ip":["10.244.2.2"],"destination_pod":["private-mail/private-mail-0"],"destination_port":["8080"],"protocol":["tcp"],"source_identity":[8],"tcp_flags":[{"SYN":true}],"reply":[false],"verdict":["FORWARDED"],"traffic_direction":["INGRESS","EGRESS"],"event_type":[{"type":4,"match_sub_type":true,"sub_type":0}]}` ), & expected ) != nil || ! reflect .DeepEqual (actual , expected ) {
68+ if json .Unmarshal ([]byte (args [21 ]), & actual ) != nil || json .Unmarshal ([]byte (expectedFilter ), & expected ) != nil || ! reflect .DeepEqual (actual , expected ) {
6169 return nil , errors .New ("unexpected filter" )
6270 }
6371 executions ++
@@ -68,6 +76,9 @@ func TestIngressObserverBindsExecutionAndRefusesPartialEvidence(t *testing.T) {
6876 return []byte (" \n \t " ), nil
6977 }
7078 raw := ingressFlowSample
79+ if mode == "active-proxy" {
80+ raw = strings .Replace (raw , `"destination_port":8080` , `"destination_port":8081` , 1 )
81+ }
7182 if mode != "named-cluster" {
7283 raw = strings .Replace (raw , `"prod/worker-1"` , `"worker-1"` , 1 )
7384 }
@@ -90,11 +101,12 @@ func TestIngressObserverBindsExecutionAndRefusesPartialEvidence(t *testing.T) {
90101 }
91102 return start .Add (10 * time .Second )
92103 }
93- result , err := observeIngressSources (context .Background (), run , binding {UID : "44444444-4444-4444-4444-444444444444" , Node : "worker-1" }, accessAddresses {Pod : netip .MustParseAddr ("10.244.2.2" )}, probe , func (context.Context ) error { return nil }, now )
94- if (err == nil ) != (mode == "matching" || mode == "named-cluster" ) {
95- t .Fatal ("partial observation accepted or bound observation refused" )
104+ result , err := observeIngressSources (context .Background (), run , app , accessAddresses {Pod : netip .MustParseAddr ("10.244.2.2" )}, probe , func (context.Context ) error { return nil }, now )
105+ wantSuccess := mode == "matching" || mode == "named-cluster" || mode == "active-proxy"
106+ if (err == nil ) != wantSuccess {
107+ t .Fatalf ("partial observation accepted or bound observation refused at %s" , ingressFailureStage (err ))
96108 }
97- if ( mode == "matching" || mode == "named-cluster" ) && (len (result .Sources ) != 1 || result .Sources [0 ] != netip .MustParseAddr ("10.244.1.1" ) || result .Public503 != 2 || result .Public200 != 0 || clusterReads != 2 ) {
109+ if wantSuccess && (len (result .Sources ) != 1 || result .Sources [0 ] != netip .MustParseAddr ("10.244.1.1" ) || result .Public503 != 2 || result .Public200 != 0 || clusterReads != 2 ) {
98110 t .Fatal ("observed peer or public response was lost" )
99111 }
100112 if err != nil && (len (result .Sources ) != 0 || strings .Contains (err .Error (), "private-" )) {
@@ -104,7 +116,7 @@ func TestIngressObserverBindsExecutionAndRefusesPartialEvidence(t *testing.T) {
104116 want := map [string ]string {
105117 "cluster-churn" : "cluster_after" , "unready-agent" : "agent_before" , "agent-churn" : "agent_after" ,
106118 "daemon-churn" : "daemon_after" , "probe-failure" : "public_probes" , "observer-failure" : "flow_read" ,
107- "empty-flow" : "flow_empty" , "truncated-flow" : "flow_decode" ,
119+ "empty-flow" : "flow_empty" , "truncated-flow" : "flow_decode" , "native-port-while-proxied" : "flow_decode" ,
108120 }[mode ]
109121 if ingressFailureStage (err ) != want {
110122 t .Fatal ("failed observation lost its closed failure stage" )
0 commit comments