@@ -60,44 +60,48 @@ func ForStatefulSetToExist(stsName string, retryInterval, timeout time.Duration,
6060
6161// ForStatefulSetToHaveUpdateStrategy waits until all replicas of the StatefulSet with the given name
6262// have reached the ready status
63- func ForStatefulSetToHaveUpdateStrategy (t * testing.T , mdb * mdbv1.MongoDBCommunity , strategy appsv1.StatefulSetUpdateStrategyType , retryInterval , timeout time.Duration ) error {
64- return waitForStatefulSetCondition (t , mdb , retryInterval , timeout , func (sts appsv1.StatefulSet ) bool {
63+ func ForStatefulSetToHaveUpdateStrategy (t * testing.T , mdb * mdbv1.MongoDBCommunity , strategy appsv1.StatefulSetUpdateStrategyType , opts ... Configuration ) error {
64+ options := newOptions (opts ... )
65+ return waitForStatefulSetCondition (t , mdb , options , func (sts appsv1.StatefulSet ) bool {
6566 return sts .Spec .UpdateStrategy .Type == strategy
6667 })
6768}
6869
6970// ForStatefulSetToBeReady waits until all replicas of the StatefulSet with the given name
7071// have reached the ready status
71- func ForStatefulSetToBeReady (t * testing.T , mdb * mdbv1.MongoDBCommunity , retryInterval , timeout time.Duration ) error {
72- return waitForStatefulSetCondition (t , mdb , retryInterval , timeout , func (sts appsv1.StatefulSet ) bool {
72+ func ForStatefulSetToBeReady (t * testing.T , mdb * mdbv1.MongoDBCommunity , opts ... Configuration ) error {
73+ options := newOptions (opts ... )
74+ return waitForStatefulSetCondition (t , mdb , options , func (sts appsv1.StatefulSet ) bool {
7375 return statefulset .IsReady (sts , mdb .Spec .Members )
7476 })
7577}
7678
7779// ForStatefulSetToBeUnready waits until all replicas of the StatefulSet with the given name
7880// is not ready.
79- func ForStatefulSetToBeUnready (t * testing.T , mdb * mdbv1.MongoDBCommunity , retryInterval , timeout time.Duration ) error {
80- return waitForStatefulSetCondition (t , mdb , retryInterval , timeout , func (sts appsv1.StatefulSet ) bool {
81+ func ForStatefulSetToBeUnready (t * testing.T , mdb * mdbv1.MongoDBCommunity , opts ... Configuration ) error {
82+ options := newOptions (opts ... )
83+ return waitForStatefulSetCondition (t , mdb , options , func (sts appsv1.StatefulSet ) bool {
8184 return ! statefulset .IsReady (sts , mdb .Spec .Members )
8285 })
8386}
8487
8588// ForStatefulSetToBeReadyAfterScaleDown waits for just the ready replicas to be correct
8689// and does not account for the updated replicas
87- func ForStatefulSetToBeReadyAfterScaleDown (t * testing.T , mdb * mdbv1.MongoDBCommunity , retryInterval , timeout time.Duration ) error {
88- return waitForStatefulSetCondition (t , mdb , retryInterval , timeout , func (sts appsv1.StatefulSet ) bool {
90+ func ForStatefulSetToBeReadyAfterScaleDown (t * testing.T , mdb * mdbv1.MongoDBCommunity , opts ... Configuration ) error {
91+ options := newOptions (opts ... )
92+ return waitForStatefulSetCondition (t , mdb , options , func (sts appsv1.StatefulSet ) bool {
8993 return int32 (mdb .Spec .Members ) == sts .Status .ReadyReplicas
9094 })
9195}
9296
93- func waitForStatefulSetCondition (t * testing.T , mdb * mdbv1.MongoDBCommunity , retryInterval , timeout time. Duration , condition func (set appsv1.StatefulSet ) bool ) error {
94- _ , err := ForStatefulSetToExist (mdb .Name , retryInterval , timeout , mdb .Namespace )
97+ func waitForStatefulSetCondition (t * testing.T , mdb * mdbv1.MongoDBCommunity , waitOpts Options , condition func (set appsv1.StatefulSet ) bool ) error {
98+ _ , err := ForStatefulSetToExist (mdb .Name , waitOpts . RetryInterval , waitOpts . Timeout , mdb .Namespace )
9599 if err != nil {
96100 return errors .Errorf ("error waiting for stateful set to be created: %s" , err )
97101 }
98102
99103 sts := appsv1.StatefulSet {}
100- return wait .Poll (retryInterval , timeout , func () (done bool , err error ) {
104+ return wait .Poll (waitOpts . RetryInterval , waitOpts . Timeout , func () (done bool , err error ) {
101105 err = e2eutil .TestClient .Get (context .TODO (), mdb .NamespacedName (), & sts )
102106 if err != nil {
103107 return false , err
0 commit comments