mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 10:43:56 +00:00
use sub test in gc_controller_test.go
This commit is contained in:
parent
961a5ed144
commit
7d45e12523
@ -18,6 +18,7 @@ package podgc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
@ -72,6 +73,7 @@ func TestGCTerminated(t *testing.T) {
|
||||
deletedPodNames sets.String
|
||||
}{
|
||||
{
|
||||
// case 1
|
||||
pods: []nameToPhase{
|
||||
{name: "a", phase: v1.PodFailed},
|
||||
{name: "b", phase: v1.PodSucceeded},
|
||||
@ -81,6 +83,7 @@ func TestGCTerminated(t *testing.T) {
|
||||
deletedPodNames: sets.NewString(),
|
||||
},
|
||||
{
|
||||
// case 2
|
||||
pods: []nameToPhase{
|
||||
{name: "a", phase: v1.PodFailed},
|
||||
{name: "b", phase: v1.PodSucceeded},
|
||||
@ -90,6 +93,7 @@ func TestGCTerminated(t *testing.T) {
|
||||
deletedPodNames: sets.NewString("a", "b"),
|
||||
},
|
||||
{
|
||||
// case 3
|
||||
pods: []nameToPhase{
|
||||
{name: "a", phase: v1.PodRunning},
|
||||
{name: "b", phase: v1.PodSucceeded},
|
||||
@ -99,6 +103,7 @@ func TestGCTerminated(t *testing.T) {
|
||||
deletedPodNames: sets.NewString("b"),
|
||||
},
|
||||
{
|
||||
// case 4
|
||||
pods: []nameToPhase{
|
||||
{name: "a", phase: v1.PodFailed},
|
||||
{name: "b", phase: v1.PodSucceeded},
|
||||
@ -107,6 +112,7 @@ func TestGCTerminated(t *testing.T) {
|
||||
deletedPodNames: sets.NewString("a"),
|
||||
},
|
||||
{
|
||||
// case 5
|
||||
pods: []nameToPhase{
|
||||
{name: "a", phase: v1.PodFailed},
|
||||
{name: "b", phase: v1.PodSucceeded},
|
||||
@ -117,6 +123,7 @@ func TestGCTerminated(t *testing.T) {
|
||||
}
|
||||
|
||||
for i, test := range testCases {
|
||||
t.Run(fmt.Sprintf("case: %v", i), func(t *testing.T) {
|
||||
client := fake.NewSimpleClientset(&v1.NodeList{Items: []v1.Node{*testutil.NewNode("node")}})
|
||||
gcc, podInformer, _ := NewFromClient(client, test.threshold)
|
||||
deletedPodNames := make([]string, 0)
|
||||
@ -144,6 +151,7 @@ func TestGCTerminated(t *testing.T) {
|
||||
t.Errorf("[%v]pod's deleted expected and actual did not match.\n\texpected: %v\n\tactual: %v",
|
||||
i, test.deletedPodNames.List(), deletedPodNames)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -403,6 +411,7 @@ func TestGCUnscheduledTerminating(t *testing.T) {
|
||||
}
|
||||
|
||||
for i, test := range testCases {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
client := fake.NewSimpleClientset()
|
||||
gcc, podInformer, _ := NewFromClient(client, -1)
|
||||
deletedPodNames := make([]string, 0)
|
||||
@ -436,5 +445,6 @@ func TestGCUnscheduledTerminating(t *testing.T) {
|
||||
t.Errorf("[%v]pod's deleted expected and actual did not match.\n\texpected: %v\n\tactual: %v, test: %v",
|
||||
i, test.deletedPodNames.List(), deletedPodNames, test.name)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user