Merge pull request #82498 from liggitt/race-flake

Avoid encoding from competing goroutines
This commit is contained in:
Kubernetes Prow Robot 2019-09-11 21:23:50 -07:00 committed by GitHub
commit 50b8b42c1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -154,7 +154,8 @@ func TestWebhookLoadBalance(t *testing.T) {
t.Fatal(err)
}
pod := &corev1.Pod{
pod := func() *corev1.Pod {
return &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Namespace: ns,
GenerateName: "loadbalance-",
@ -166,6 +167,7 @@ func TestWebhookLoadBalance(t *testing.T) {
}},
},
}
}
// Submit 10 parallel requests
wg := &sync.WaitGroup{}
@ -173,7 +175,7 @@ func TestWebhookLoadBalance(t *testing.T) {
wg.Add(1)
go func() {
defer wg.Done()
_, err := client.CoreV1().Pods(ns).Create(pod)
_, err := client.CoreV1().Pods(ns).Create(pod())
if err != nil {
t.Error(err)
}
@ -192,7 +194,7 @@ func TestWebhookLoadBalance(t *testing.T) {
wg.Add(1)
go func() {
defer wg.Done()
_, err := client.CoreV1().Pods(ns).Create(pod)
_, err := client.CoreV1().Pods(ns).Create(pod())
if err != nil {
t.Error(err)
}