@@ -96,14 +96,18 @@ func GetPodName(oc *CLI, namespace, podLabel, node string) (string, error) {
96
96
97
97
// AssertAllPodsToBeReadyWithPollerParams assert all pods in NS are in ready state until timeout in a given namespace
98
98
// Pros: allow user to customize poller parameters
99
- func AssertAllPodsToBeReadyWithPollerParams (oc * CLI , namespace string , interval , timeout time.Duration ) {
99
+ func AssertAllPodsToBeReadyWithPollerParams (oc * CLI , namespace string , interval , timeout time.Duration , selector string ) {
100
100
err := wait .PollUntilContextTimeout (context .Background (), interval , timeout , false , func (_ context.Context ) (bool , error ) {
101
101
102
102
// get the status flag for all pods
103
103
// except the ones which are in Complete Status.
104
104
// it use 'ne' operator which is only compatible with 4.10+ oc versions
105
105
template := "'{{- range .items -}}{{- range .status.conditions -}}{{- if ne .reason \" PodCompleted\" -}}{{- if eq .type \" Ready\" -}}{{- .status}} {{\" \" }}{{- end -}}{{- end -}}{{- end -}}{{- end -}}'"
106
- stdout , err := oc .AsAdmin ().Run ("get" ).Args ("pods" , "-n" , namespace ).Template (template ).Output ()
106
+ baseArgs := []string {"pods" , "-n" , namespace }
107
+ if selector != "" {
108
+ baseArgs = append (baseArgs , "-l" , selector )
109
+ }
110
+ stdout , err := oc .AsAdmin ().Run ("get" ).Args (baseArgs ... ).Template (template ).Output ()
107
111
if err != nil {
108
112
e2e .Logf ("the err:%v, and try next round" , err )
109
113
return false , nil
@@ -118,5 +122,11 @@ func AssertAllPodsToBeReadyWithPollerParams(oc *CLI, namespace string, interval,
118
122
119
123
// AssertAllPodsToBeReady assert all pods in NS are in ready state until timeout in a given namespace
120
124
func AssertAllPodsToBeReady (oc * CLI , namespace string ) {
121
- AssertAllPodsToBeReadyWithPollerParams (oc , namespace , 10 * time .Second , 4 * time .Minute )
125
+ AssertAllPodsToBeReadyWithPollerParams (oc , namespace , 10 * time .Second , 4 * time .Minute , "" )
126
+ }
127
+
128
+ // AssertAllPodsToBeReadyWithSelector assert all pods in NS are in ready state until timeout in a given namespace
129
+ // The selector parameter follows the regular oc/kubectl format for the --selector option.
130
+ func AssertAllPodsToBeReadyWithSelector (oc * CLI , namespace , selector string ) {
131
+ AssertAllPodsToBeReadyWithPollerParams (oc , namespace , 10 * time .Second , 4 * time .Minute , selector )
122
132
}
0 commit comments