mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #82498 from liggitt/race-flake
Avoid encoding from competing goroutines
This commit is contained in:
commit
50b8b42c1b
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user