@@ -1163,6 +1163,49 @@ private static KeyStore createKeyStore(Operator operator) throws Exception {
1163
1163
return myKeyStore ;
1164
1164
}
1165
1165
1166
+ /**
1167
+ *
1168
+ * @param cmd command to run in the loop
1169
+ * @param matchStr expected string to match in the output
1170
+ * @return ExecResult object containing command output info
1171
+ * @throws Exception exception if fails to execute
1172
+ */
1173
+ public static ExecResult checkAnyCmdInLoop (String cmd , String matchStr )
1174
+ throws Exception {
1175
+ int i = 0 ;
1176
+ ExecResult result = null ;
1177
+ while (i < BaseTest .getMaxIterationsPod ()) {
1178
+ result = ExecCommand .exec (cmd );
1179
+
1180
+ if (result .exitValue () != 0
1181
+ || (result .exitValue () == 0 && !result .stdout ().contains (matchStr ))) {
1182
+ logger .info ("Output for " + cmd + "\n " + result .stdout () + "\n " + result .stderr ());
1183
+ // check for last iteration
1184
+ if (i == (BaseTest .getMaxIterationsPod () - 1 )) {
1185
+ throw new RuntimeException (
1186
+ "FAILURE: expected output " + matchStr + " from command " + cmd + " is not receieved, exiting!" );
1187
+ }
1188
+ logger .info (
1189
+ "did not receive the expected output "
1190
+ + matchStr
1191
+ + "from command " + cmd + " Ite ["
1192
+ + i
1193
+ + "/"
1194
+ + BaseTest .getMaxIterationsPod ()
1195
+ + "], sleeping "
1196
+ + BaseTest .getWaitTimePod ()
1197
+ + " seconds more" );
1198
+
1199
+ Thread .sleep (BaseTest .getWaitTimePod () * 1000 );
1200
+ i ++;
1201
+ } else {
1202
+ logger .info ("Command " + cmd + " is successful" );
1203
+ break ;
1204
+ }
1205
+ }
1206
+ return result ;
1207
+ }
1208
+
1166
1209
public static void checkCmdInLoop (String cmd , String matchStr , String k8sObjName )
1167
1210
throws Exception {
1168
1211
int i = 0 ;
0 commit comments