endpointslice controller: set new conditions 'accepting' and 'terminating'

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
This commit is contained in:
Andrew Sy Kim
2020-10-29 23:24:01 -04:00
parent 9a7c3c4c34
commit 1c603e90ef
8 changed files with 229 additions and 52 deletions

View File

@@ -100,12 +100,12 @@ func TestDetermineNeededServiceUpdates(t *testing.T) {
// There are 3*5 possibilities(3 types of RestartPolicy by 5 types of PodPhase).
// Not listing them all here. Just listing all of the 3 false cases and 3 of the
// 12 true cases.
func TestShouldPodBeInEndpoints(t *testing.T) {
func TestShouldPodBeInEndpointSlice(t *testing.T) {
testCases := []struct {
name string
pod *v1.Pod
publishNotReady bool
expected bool
name string
pod *v1.Pod
expected bool
includeTerminating bool
}{
// Pod should not be in endpoints:
{
@@ -162,7 +162,7 @@ func TestShouldPodBeInEndpoints(t *testing.T) {
expected: false,
},
{
name: "Terminating Pod",
name: "Terminating Pod with includeTerminating=false",
pod: &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
DeletionTimestamp: &metav1.Time{
@@ -175,8 +175,7 @@ func TestShouldPodBeInEndpoints(t *testing.T) {
PodIP: "1.2.3.4",
},
},
publishNotReady: false,
expected: false,
expected: false,
},
// Pod should be in endpoints:
{
@@ -245,7 +244,7 @@ func TestShouldPodBeInEndpoints(t *testing.T) {
expected: true,
},
{
name: "Terminating Pod with publish not ready",
name: "Terminating Pod with includeTerminating=true",
pod: &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
DeletionTimestamp: &metav1.Time{
@@ -258,14 +257,14 @@ func TestShouldPodBeInEndpoints(t *testing.T) {
PodIP: "1.2.3.4",
},
},
publishNotReady: true,
expected: true,
expected: true,
includeTerminating: true,
},
}
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
result := ShouldPodBeInEndpoints(test.pod, test.publishNotReady)
result := ShouldPodBeInEndpointSlice(test.pod, test.includeTerminating)
if result != test.expected {
t.Errorf("expected: %t, got: %t", test.expected, result)
}