From 3f9e02c19771a6ed50dc13b41083b256021fb1f8 Mon Sep 17 00:00:00 2001 From: Or Ozeri Date: Sun, 19 May 2024 10:53:40 +0300 Subject: [PATCH] tests/e2e/k8s: Fix race in peer status check (#585) This commit fixes a race where a peer status is updated after being fetched for comparison. Signed-off-by: Or Ozeri --- tests/e2e/k8s/test_basic.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/e2e/k8s/test_basic.go b/tests/e2e/k8s/test_basic.go index e49dee97..30d6a579 100644 --- a/tests/e2e/k8s/test_basic.go +++ b/tests/e2e/k8s/test_basic.go @@ -16,6 +16,7 @@ package k8s import ( "fmt" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -161,6 +162,11 @@ func (s *TestSuite) TestControlplaneCRUD() { // list peers objects, err = client0.Peers.List() require.Nil(s.T(), err) + if !assert.ElementsMatch(s.T(), *objects.(*[]v1alpha1.Peer), []v1alpha1.Peer{peerFromServer}) { + objects, err = client0.Peers.Get(peer.Name) + require.Nil(s.T(), err) + peerFromServer = *objects.(*v1alpha1.Peer) + } require.ElementsMatch(s.T(), *objects.(*[]v1alpha1.Peer), []v1alpha1.Peer{peerFromServer}) // add another peer (for upcoming load-balancing test)