mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Added test where both policies are set
This commit is contained in:
parent
ba4f5c4e7b
commit
198367a486
@ -6087,6 +6087,16 @@ func TestNoEndpointsMetric(t *testing.T) {
|
|||||||
{"10.0.1.3", "host2"},
|
{"10.0.1.3", "host2"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "both policies are set and there is non-zero local endpoints",
|
||||||
|
internalTrafficPolicy: &internalTrafficPolicyLocal,
|
||||||
|
externalTrafficPolicy: externalTrafficPolicyLocal,
|
||||||
|
endpoints: []endpoint{
|
||||||
|
{"10.0.1.1", testHostname},
|
||||||
|
{"10.0.1.2", "host1"},
|
||||||
|
{"10.0.1.3", "host2"},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "internalTrafficPolicy is set and there is zero local endpoint",
|
name: "internalTrafficPolicy is set and there is zero local endpoint",
|
||||||
internalTrafficPolicy: &internalTrafficPolicyLocal,
|
internalTrafficPolicy: &internalTrafficPolicyLocal,
|
||||||
@ -6107,6 +6117,18 @@ func TestNoEndpointsMetric(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedSyncProxyRulesNoLocalEndpointsTotalExternal: 1,
|
expectedSyncProxyRulesNoLocalEndpointsTotalExternal: 1,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "both policies are set and there is zero local endpoint",
|
||||||
|
internalTrafficPolicy: &internalTrafficPolicyLocal,
|
||||||
|
externalTrafficPolicy: externalTrafficPolicyLocal,
|
||||||
|
endpoints: []endpoint{
|
||||||
|
{"10.0.1.1", "host0"},
|
||||||
|
{"10.0.1.2", "host1"},
|
||||||
|
{"10.0.1.3", "host2"},
|
||||||
|
},
|
||||||
|
expectedSyncProxyRulesNoLocalEndpointsTotalInternal: 1,
|
||||||
|
expectedSyncProxyRulesNoLocalEndpointsTotalExternal: 1,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
|
@ -278,14 +278,14 @@ type Proxier struct {
|
|||||||
// It is used to publish the sync_proxy_rules_no_endpoints_total
|
// It is used to publish the sync_proxy_rules_no_endpoints_total
|
||||||
// metric with the traffic_policy label set to "internal".
|
// metric with the traffic_policy label set to "internal".
|
||||||
// sets.String is used here since we end up calculating endpoint topology multiple times for the same Service
|
// sets.String is used here since we end up calculating endpoint topology multiple times for the same Service
|
||||||
// if it has mulitple ports but each Service should only be counted once.
|
// if it has multiple ports but each Service should only be counted once.
|
||||||
serviceNoLocalEndpointsInternal sets.String
|
serviceNoLocalEndpointsInternal sets.String
|
||||||
// serviceNoLocalEndpointsExternal irepresents the set of services that couldn't be applied
|
// serviceNoLocalEndpointsExternal irepresents the set of services that couldn't be applied
|
||||||
// due to the absence of any endpoints when the external traffic policy is "Local".
|
// due to the absence of any endpoints when the external traffic policy is "Local".
|
||||||
// It is used to publish the sync_proxy_rules_no_endpoints_total
|
// It is used to publish the sync_proxy_rules_no_endpoints_total
|
||||||
// metric with the traffic_policy label set to "external".
|
// metric with the traffic_policy label set to "external".
|
||||||
// sets.String is used here since we end up calculating endpoint topology multiple times for the same Service
|
// sets.String is used here since we end up calculating endpoint topology multiple times for the same Service
|
||||||
// if it has mulitple ports but each Service should only be counted once.
|
// if it has multiple ports but each Service should only be counted once.
|
||||||
serviceNoLocalEndpointsExternal sets.String
|
serviceNoLocalEndpointsExternal sets.String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5838,6 +5838,16 @@ func TestNoEndpointsMetric(t *testing.T) {
|
|||||||
{"10.0.1.3", "host2"},
|
{"10.0.1.3", "host2"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "both policies are set and there is non-zero local endpoints",
|
||||||
|
internalTrafficPolicy: &internalTrafficPolicyLocal,
|
||||||
|
externalTrafficPolicy: externalTrafficPolicyLocal,
|
||||||
|
endpoints: []endpoint{
|
||||||
|
{"10.0.1.1", testHostname},
|
||||||
|
{"10.0.1.2", "host1"},
|
||||||
|
{"10.0.1.3", "host2"},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "internalTrafficPolicy is set and there is zero local endpoint",
|
name: "internalTrafficPolicy is set and there is zero local endpoint",
|
||||||
internalTrafficPolicy: &internalTrafficPolicyLocal,
|
internalTrafficPolicy: &internalTrafficPolicyLocal,
|
||||||
@ -5858,6 +5868,18 @@ func TestNoEndpointsMetric(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedSyncProxyRulesNoLocalEndpointsTotalExternal: 1,
|
expectedSyncProxyRulesNoLocalEndpointsTotalExternal: 1,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Both policies are set and there is zero local endpoint",
|
||||||
|
internalTrafficPolicy: &internalTrafficPolicyLocal,
|
||||||
|
externalTrafficPolicy: externalTrafficPolicyLocal,
|
||||||
|
endpoints: []endpoint{
|
||||||
|
{"10.0.1.1", "host0"},
|
||||||
|
{"10.0.1.2", "host1"},
|
||||||
|
{"10.0.1.3", "host2"},
|
||||||
|
},
|
||||||
|
expectedSyncProxyRulesNoLocalEndpointsTotalInternal: 1,
|
||||||
|
expectedSyncProxyRulesNoLocalEndpointsTotalExternal: 1,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ServiceInternalTrafficPolicy, true)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ServiceInternalTrafficPolicy, true)()
|
||||||
|
Loading…
Reference in New Issue
Block a user