mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
test: e2e: fix race in pods test
This commit is contained in:
parent
112dbd5586
commit
b7c74338e8
@ -263,6 +263,7 @@ var _ = SIGDescribe("Pods Extended", func() {
|
||||
start := time.Now()
|
||||
created := podClient.Create(pod)
|
||||
ch := make(chan []watch.Event)
|
||||
waitForWatch := make(chan struct{})
|
||||
go func() {
|
||||
defer ginkgo.GinkgoRecover()
|
||||
defer close(ch)
|
||||
@ -275,6 +276,7 @@ var _ = SIGDescribe("Pods Extended", func() {
|
||||
return
|
||||
}
|
||||
defer w.Stop()
|
||||
close(waitForWatch)
|
||||
events := []watch.Event{
|
||||
{Type: watch.Added, Object: created},
|
||||
}
|
||||
@ -291,6 +293,10 @@ var _ = SIGDescribe("Pods Extended", func() {
|
||||
ch <- events
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-ch: // in case the goroutine above exits before establishing the watch
|
||||
case <-waitForWatch: // when the watch is established
|
||||
}
|
||||
t := time.Duration(rand.Intn(delay)) * time.Millisecond
|
||||
time.Sleep(t)
|
||||
err := podClient.Delete(context.TODO(), pod.Name, metav1.DeleteOptions{})
|
||||
|
Loading…
Reference in New Issue
Block a user