@@ -21,9 +21,9 @@ package integration
21
21
import (
22
22
"fmt"
23
23
"testing"
24
+ "time"
24
25
25
26
testUtil "github.com/opendatahub-io/data-science-pipelines-operator/tests/util"
26
- "github.com/stretchr/testify/assert"
27
27
"github.com/stretchr/testify/require"
28
28
corev1 "k8s.io/api/core/v1"
29
29
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -51,30 +51,38 @@ func (suite *IntegrationTestSuite) TestDSPADeployment() {
51
51
}
52
52
suite .T ().Run ("with default MariaDB and Minio" , func (t * testing.T ) {
53
53
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
64
57
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 {
70
62
client .InNamespace (suite .DSPANamespace ),
63
+ client.MatchingFields {"status.phase" : string (corev1 .PodRunning )},
71
64
}
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
76
84
}
77
- }
85
+ }, timeout , interval )
78
86
})
79
87
for _ , deployment := range deployments {
80
88
t .Run (fmt .Sprintf ("should have a ready %s deployment" , deployment ), func (t * testing.T ) {
0 commit comments