@@ -586,8 +586,17 @@ func TestTrafficPolicy_ExternalLocal_NodePort_NoLocalEndpoints_SkipsService(t *t
586586 assert .Contains (t , actualServices , "10.100.2.3:6:8080:false:rr" ,
587587 "ClusterIP service should still be created" )
588588
589- // But NodePort should be skipped due to no local endpoints with Local policy
589+ // Verify remote endpoint IS added to ClusterIP (internalTrafficPolicy=Cluster allows remote)
590+ actualEndpoints := getEndpointsFromAddServerCalls (mock )
591+ assert .Contains (t , actualEndpoints , "10.100.2.3:8080->172.20.2.7:80" ,
592+ "remote endpoint should be added to ClusterIP (internal policy is Cluster)" )
593+
594+ // Verify NO NodePort endpoints were added (externalTrafficPolicy=Local with no local endpoints)
590595 // The syncNodePortIpvsServices function has early exit logic for this case
596+ for _ , endpoint := range actualEndpoints {
597+ assert .NotContains (t , endpoint , "30003" ,
598+ "NodePort should not have any endpoints when externalTrafficPolicy=Local and no local endpoints exist" )
599+ }
591600}
592601
593602// TestTrafficPolicy_ExternalCluster_ExternalIP_AllEndpoints verifies that with externalTrafficPolicy=Cluster,
@@ -708,11 +717,13 @@ func TestTrafficPolicy_ExternalLocal_ExternalIP_NoLocalEndpoints_SkipsService(t
708717 assert .Contains (t , actualServices , "10.100.3.3:6:8080:false:rr" ,
709718 "ClusterIP service should still be created" )
710719
711- // ExternalIP should be skipped due to no local endpoints with Local policy
712- // Check that ExternalIP was NOT created
713- // Note: The actual behavior depends on implementation - ExternalIP may still be
714- // created but with no endpoints, or may be skipped entirely
720+ // Verify remote endpoint IS added to ClusterIP (internalTrafficPolicy=Cluster allows remote)
715721 actualEndpoints := getEndpointsFromAddServerCalls (mock )
722+ assert .Contains (t , actualEndpoints , "10.100.3.3:8080->172.20.2.10:80" ,
723+ "remote endpoint should be added to ClusterIP (internal policy is Cluster)" )
724+
725+ // ExternalIP should be skipped due to no local endpoints with Local policy
726+ // Verify that the remote endpoint is NOT added to the ExternalIP
716727 assert .NotContains (t , actualEndpoints , "203.0.113.3:8080->172.20.2.10:80" ,
717728 "remote endpoint should NOT be added to ExternalIP with Local policy" )
718729}
@@ -1574,6 +1585,11 @@ func TestDSR_ExternalTrafficPolicyLocal_NoLocalEndpoints(t *testing.T) {
15741585 svcs := getServicesFromAddServiceCalls (mock )
15751586 assert .Contains (t , svcs , "10.100.1.1:6:8080:false:rr" ,
15761587 "ClusterIP service should still be created" )
1588+
1589+ // Verify remote endpoint IS added to ClusterIP (internalTrafficPolicy=Cluster allows remote)
1590+ allEndpoints := getEndpointsFromAddServerCalls (mock )
1591+ assert .Contains (t , allEndpoints , "10.100.1.1:8080->172.20.2.1:80" ,
1592+ "remote endpoint should be added to ClusterIP (internal policy is Cluster)" )
15771593}
15781594
15791595// TestDSR_ClusterIPUnaffectedByExternalTrafficPolicy verifies that DSR annotation only affects
0 commit comments