Skip to content

Commit

Permalink
fix races
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com>
  • Loading branch information
denis-tingaikin committed May 12, 2022
1 parent 90abf5e commit 5e39a48
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pkg/networkservice/common/createpod/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,19 +299,21 @@ objectmeta:

cancel()

require.Never(t, func() bool {
newPodList, fetchListErr := clientSet.CoreV1().Pods(testNamespace).List(ctx, metav1.ListOptions{})
return fetchListErr != nil || len(newPodList.Items) == 0
}, time.Millisecond*150, time.Millisecond*15)
for end := time.Now().Add(time.Millisecond * 150); time.Until(end) > 0; time.Sleep(time.Millisecond * 15) {
podList, err := clientSet.CoreV1().Pods(testNamespace).List(ctx, metav1.ListOptions{})
require.NoError(t, err)
require.Len(t, podList.Items, 1)
}

podList.Items[0].Status.Phase = "Succeeded"
_, err = clientSet.CoreV1().Pods(testNamespace).UpdateStatus(ctx, &podList.Items[0], metav1.UpdateOptions{})
require.NoError(t, err)

require.Never(t, func() bool {
for end := time.Now().Add(time.Millisecond * 100); time.Until(end) > 0; time.Sleep(time.Millisecond * 10) {
podList, err := clientSet.CoreV1().Pods(testNamespace).List(ctx, metav1.ListOptions{})
return err != nil || len(podList.Items) == 0
}, time.Millisecond*100, time.Millisecond*10)
require.NoError(t, err)
require.Len(t, podList.Items, 1)
}

ctx, cancel = context.WithTimeout(context.Background(), time.Second)
defer cancel()
Expand Down

0 comments on commit 5e39a48

Please sign in to comment.