Graduate EndpointSliceNodeName feature gate to GA

- Feature gate can be removed when EndpointSlice v1beta1 is removed
  - Remove test cases where feature gate is disabled
This commit is contained in:
Swetha Repakula
2021-03-03 17:05:57 -08:00
parent afb1ee3c9a
commit be2ef551d1
6 changed files with 68 additions and 167 deletions

View File

@@ -252,7 +252,6 @@ func TestPodToEndpoint(t *testing.T) {
expectedEndpoint discovery.Endpoint
publishNotReadyAddresses bool
terminatingGateEnabled bool
nodeNameGateEnabled bool
}{
{
name: "Ready pod",
@@ -262,6 +261,7 @@ func TestPodToEndpoint(t *testing.T) {
Addresses: []string{"1.2.3.5"},
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
Topology: map[string]string{"kubernetes.io/hostname": "node-1"},
NodeName: utilpointer.StringPtr("node-1"),
TargetRef: &v1.ObjectReference{
Kind: "Pod",
Namespace: ns,
@@ -279,6 +279,7 @@ func TestPodToEndpoint(t *testing.T) {
Addresses: []string{"1.2.3.5"},
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
Topology: map[string]string{"kubernetes.io/hostname": "node-1"},
NodeName: utilpointer.StringPtr("node-1"),
TargetRef: &v1.ObjectReference{
Kind: "Pod",
Namespace: ns,
@@ -296,6 +297,7 @@ func TestPodToEndpoint(t *testing.T) {
Addresses: []string{"1.2.3.5"},
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(false)},
Topology: map[string]string{"kubernetes.io/hostname": "node-1"},
NodeName: utilpointer.StringPtr("node-1"),
TargetRef: &v1.ObjectReference{
Kind: "Pod",
Namespace: ns,
@@ -309,24 +311,6 @@ func TestPodToEndpoint(t *testing.T) {
name: "Unready pod + publishNotReadyAddresses",
pod: unreadyPod,
svc: &svcPublishNotReady,
expectedEndpoint: discovery.Endpoint{
Addresses: []string{"1.2.3.5"},
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
Topology: map[string]string{"kubernetes.io/hostname": "node-1"},
TargetRef: &v1.ObjectReference{
Kind: "Pod",
Namespace: ns,
Name: readyPod.Name,
UID: readyPod.UID,
ResourceVersion: readyPod.ResourceVersion,
},
},
},
{
name: "Ready pod + node name gate enabled",
pod: readyPod,
svc: &svc,
nodeNameGateEnabled: true,
expectedEndpoint: discovery.Endpoint{
Addresses: []string{"1.2.3.5"},
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
@@ -354,6 +338,7 @@ func TestPodToEndpoint(t *testing.T) {
"topology.kubernetes.io/zone": "us-central1-a",
"topology.kubernetes.io/region": "us-central1",
},
NodeName: utilpointer.StringPtr("node-1"),
TargetRef: &v1.ObjectReference{
Kind: "Pod",
Namespace: ns,
@@ -376,6 +361,7 @@ func TestPodToEndpoint(t *testing.T) {
"topology.kubernetes.io/zone": "us-central1-a",
"topology.kubernetes.io/region": "us-central1",
},
NodeName: utilpointer.StringPtr("node-1"),
TargetRef: &v1.ObjectReference{
Kind: "Pod",
Namespace: ns,
@@ -399,6 +385,7 @@ func TestPodToEndpoint(t *testing.T) {
"topology.kubernetes.io/zone": "us-central1-a",
"topology.kubernetes.io/region": "us-central1",
},
NodeName: utilpointer.StringPtr("node-1"),
TargetRef: &v1.ObjectReference{
Kind: "Pod",
Namespace: ns,
@@ -420,6 +407,7 @@ func TestPodToEndpoint(t *testing.T) {
Terminating: utilpointer.BoolPtr(false),
},
Topology: map[string]string{"kubernetes.io/hostname": "node-1"},
NodeName: utilpointer.StringPtr("node-1"),
TargetRef: &v1.ObjectReference{
Kind: "Pod",
Namespace: ns,
@@ -440,6 +428,7 @@ func TestPodToEndpoint(t *testing.T) {
Ready: utilpointer.BoolPtr(false),
},
Topology: map[string]string{"kubernetes.io/hostname": "node-1"},
NodeName: utilpointer.StringPtr("node-1"),
TargetRef: &v1.ObjectReference{
Kind: "Pod",
Namespace: ns,
@@ -462,6 +451,7 @@ func TestPodToEndpoint(t *testing.T) {
Terminating: utilpointer.BoolPtr(true),
},
Topology: map[string]string{"kubernetes.io/hostname": "node-1"},
NodeName: utilpointer.StringPtr("node-1"),
TargetRef: &v1.ObjectReference{
Kind: "Pod",
Namespace: ns,
@@ -482,6 +472,7 @@ func TestPodToEndpoint(t *testing.T) {
Ready: utilpointer.BoolPtr(false),
},
Topology: map[string]string{"kubernetes.io/hostname": "node-1"},
NodeName: utilpointer.StringPtr("node-1"),
TargetRef: &v1.ObjectReference{
Kind: "Pod",
Namespace: ns,
@@ -504,6 +495,7 @@ func TestPodToEndpoint(t *testing.T) {
Terminating: utilpointer.BoolPtr(true),
},
Topology: map[string]string{"kubernetes.io/hostname": "node-1"},
NodeName: utilpointer.StringPtr("node-1"),
TargetRef: &v1.ObjectReference{
Kind: "Pod",
Namespace: ns,
@@ -519,7 +511,6 @@ func TestPodToEndpoint(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.EndpointSliceTerminatingCondition, testCase.terminatingGateEnabled)()
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.EndpointSliceNodeName, testCase.nodeNameGateEnabled)()
endpoint := podToEndpoint(testCase.pod, testCase.node, testCase.svc, discovery.AddressTypeIPv4)
if !reflect.DeepEqual(testCase.expectedEndpoint, endpoint) {