Skip to content

Commit 0e775db

Browse files
authored
Merge pull request opendatahub-io#737 from hbelmiro/fix-its
Added retry for integration test
2 parents 5afca07 + c4c8bc0 commit 0e775db

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

tests/dspa_v2_test.go

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ package integration
2121
import (
2222
"fmt"
2323
"testing"
24+
"time"
2425

2526
testUtil "github.com/opendatahub-io/data-science-pipelines-operator/tests/util"
26-
"github.com/stretchr/testify/assert"
2727
"github.com/stretchr/testify/require"
2828
corev1 "k8s.io/api/core/v1"
2929
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -51,30 +51,38 @@ func (suite *IntegrationTestSuite) TestDSPADeployment() {
5151
}
5252
suite.T().Run("with default MariaDB and Minio", func(t *testing.T) {
5353
t.Run(fmt.Sprintf("should have %d pods", podCount), func(t *testing.T) {
54-
podList := &corev1.PodList{}
55-
// retrieve the running pods only, to allow for multiple reruns of the test suite
56-
listOpts := []client.ListOption{
57-
client.InNamespace(suite.DSPANamespace),
58-
client.MatchingFields{"status.phase": string(corev1.PodRunning)},
59-
}
60-
err := suite.Clientmgr.k8sClient.List(suite.Ctx, podList, listOpts...)
61-
require.NoError(t, err)
62-
actualPodCount := len(podList.Items)
63-
assert.Equal(t, podCount, actualPodCount)
54+
timeout := time.Second * 10
55+
interval := time.Millisecond * 2
56+
actualPodCount := 0
6457

65-
// Print out pod statuses for troubleshooting
66-
if podCount != actualPodCount {
67-
t.Log(fmt.Sprintf("expected %d pods to successfully deploy, got %d instead. Pods in the namespace:", podCount, actualPodCount))
68-
totalPodList := &corev1.PodList{}
69-
listOpts1 := []client.ListOption{
58+
require.Eventually(t, func() bool {
59+
podList := &corev1.PodList{}
60+
// retrieve the running pods only, to allow for multiple reruns of the test suite
61+
listOpts := []client.ListOption{
7062
client.InNamespace(suite.DSPANamespace),
63+
client.MatchingFields{"status.phase": string(corev1.PodRunning)},
7164
}
72-
err1 := suite.Clientmgr.k8sClient.List(suite.Ctx, totalPodList, listOpts1...)
73-
require.NoError(t, err1)
74-
for _, pod := range totalPodList.Items {
75-
t.Log(fmt.Sprintf("Pod Name: %s, Status: %s", pod.Name, pod.Status.Phase))
65+
err := suite.Clientmgr.k8sClient.List(suite.Ctx, podList, listOpts...)
66+
require.NoError(suite.T(), err)
67+
actualPodCount = len(podList.Items)
68+
69+
// Print out pod statuses for troubleshooting
70+
if podCount != actualPodCount {
71+
t.Log(fmt.Sprintf("expected %d pods to successfully deploy, got %d instead. Pods in the namespace:", podCount, actualPodCount))
72+
totalPodList := &corev1.PodList{}
73+
listOpts1 := []client.ListOption{
74+
client.InNamespace(suite.DSPANamespace),
75+
}
76+
err1 := suite.Clientmgr.k8sClient.List(suite.Ctx, totalPodList, listOpts1...)
77+
require.NoError(t, err1)
78+
for _, pod := range totalPodList.Items {
79+
t.Log(fmt.Sprintf("Pod Name: %s, Status: %s", pod.Name, pod.Status.Phase))
80+
}
81+
return false
82+
} else {
83+
return true
7684
}
77-
}
85+
}, timeout, interval)
7886
})
7987
for _, deployment := range deployments {
8088
t.Run(fmt.Sprintf("should have a ready %s deployment", deployment), func(t *testing.T) {

0 commit comments

Comments
 (0)