Skip to content

Commit

Permalink
Merge pull request kubernetes#93619 from liggitt/node-flake
Browse files Browse the repository at this point in the history
Deflake node controller unit tests
  • Loading branch information
k8s-ci-robot authored Aug 2, 2020
2 parents 78ab6d8 + 82aa6d9 commit 09d6512
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions staging/src/k8s.io/cloud-provider/controllers/node/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ go_test(
"//staging/src/k8s.io/cloud-provider/fake:go_default_library",
"//vendor/github.com/google/go-cmp/cmp:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/k8s.io/klog/v2:go_default_library",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ import (
"testing"
"time"

"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/klog/v2"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/informers"
"k8s.io/client-go/tools/record"
"k8s.io/cloud-provider"
cloudprovider "k8s.io/cloud-provider"
cloudproviderapi "k8s.io/cloud-provider/api"
fakecloud "k8s.io/cloud-provider/fake"

Expand Down Expand Up @@ -1293,7 +1294,8 @@ func Test_AddCloudNode(t *testing.T) {
recorder: eventBroadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: "cloud-node-controller"}),
nodeStatusUpdateFrequency: 1 * time.Second,
}
eventBroadcaster.StartLogging(t.Logf)
w := eventBroadcaster.StartLogging(klog.Infof)
defer w.Stop()

cloudNodeController.AddCloudNode(context.TODO(), test.existingNode)

Expand Down Expand Up @@ -1371,7 +1373,8 @@ func TestGCEConditionV2(t *testing.T) {
recorder: eventBroadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: "cloud-node-controller"}),
nodeStatusUpdateFrequency: 1 * time.Second,
}
eventBroadcaster.StartLogging(t.Logf)
w := eventBroadcaster.StartLogging(klog.Infof)
defer w.Stop()

cloudNodeController.AddCloudNode(context.TODO(), existingNode)

Expand Down Expand Up @@ -1453,7 +1456,8 @@ func TestGCECondition(t *testing.T) {
recorder: eventBroadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: "cloud-node-controller"}),
nodeStatusUpdateFrequency: 1 * time.Second,
}
eventBroadcaster.StartLogging(t.Logf)
w := eventBroadcaster.StartLogging(klog.Infof)
defer w.Stop()

cloudNodeController.AddCloudNode(context.TODO(), existingNode)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ func Test_NodesDeleted(t *testing.T) {
nodeMonitorPeriod: 1 * time.Second,
}

eventBroadcaster.StartLogging(t.Logf)
w := eventBroadcaster.StartLogging(klog.Infof)
defer w.Stop()
cloudNodeLifecycleController.MonitorNodes()

updatedNode, err := clientset.CoreV1().Nodes().Get(context.TODO(), testcase.existingNode.Name, metav1.GetOptions{})
Expand Down Expand Up @@ -498,7 +499,8 @@ func Test_NodesShutdown(t *testing.T) {
nodeMonitorPeriod: 1 * time.Second,
}

eventBroadcaster.StartLogging(klog.Infof)
w := eventBroadcaster.StartLogging(klog.Infof)
defer w.Stop()
cloudNodeLifecycleController.MonitorNodes()

updatedNode, err := clientset.CoreV1().Nodes().Get(context.TODO(), testcase.existingNode.Name, metav1.GetOptions{})
Expand Down

0 comments on commit 09d6512

Please sign in to comment.