@@ -972,6 +972,38 @@ public static String callShellScriptByExecToPod(
972
972
return result .stdout ().trim ();
973
973
}
974
974
975
+ /**
976
+ * exec into the pod and call the shell script with given arguments.
977
+ *
978
+ * @param podName pod name
979
+ * @param domainNS namespace
980
+ * @param scriptsLocInPod script location
981
+ * @param shScriptName script name
982
+ * @param args script arguments
983
+ * @throws Exception exception
984
+ */
985
+ public static void callShellScriptByExecToPod (
986
+ String podName , String domainNS , String scriptsLocInPod , String shScriptName , String [] args )
987
+ throws Exception {
988
+ StringBuffer cmdKubectlSh = new StringBuffer ("kubectl -n " );
989
+ cmdKubectlSh
990
+ .append (domainNS )
991
+ .append (" exec -it " )
992
+ .append (podName )
993
+ .append (" -- bash -c 'chmod +x -R " )
994
+ .append (scriptsLocInPod )
995
+ .append (" && " )
996
+ .append (scriptsLocInPod )
997
+ .append ("/" )
998
+ .append (shScriptName )
999
+ .append (" " )
1000
+ .append (String .join (" " , args ).toString ())
1001
+ .append ("'" );
1002
+
1003
+ logger .info ("Command to call kubectl sh file " + cmdKubectlSh );
1004
+ TestUtils .exec (cmdKubectlSh .toString ());
1005
+ }
1006
+
975
1007
public static void createDirUnderDomainPV (String dirPath ) throws Exception {
976
1008
977
1009
String crdCmd =
@@ -1434,35 +1466,4 @@ public static ExecResult kubectlpatch(String domainUid, String domainNS, String
1434
1466
+ " --type merge" ;
1435
1467
return exec (cmd , true );
1436
1468
}
1437
- /**
1438
- * exec into the pod and call the shell script with given arguments
1439
- *
1440
- * @param podName
1441
- * @param domainNS
1442
- * @param scriptsLocInPod
1443
- * @param shScriptName
1444
- * @param args
1445
- * @throws Exception
1446
- */
1447
- public static void callShellScriptByExecToPod (
1448
- String podName , String domainNS , String scriptsLocInPod , String shScriptName , String [] args )
1449
- throws Exception {
1450
- StringBuffer cmdKubectlSh = new StringBuffer ("kubectl -n " );
1451
- cmdKubectlSh
1452
- .append (domainNS )
1453
- .append (" exec -it " )
1454
- .append (podName )
1455
- .append (" -- bash -c 'chmod +x -R " )
1456
- .append (scriptsLocInPod )
1457
- .append (" && " )
1458
- .append (scriptsLocInPod )
1459
- .append ("/" )
1460
- .append (shScriptName )
1461
- .append (" " )
1462
- .append (String .join (" " , args ).toString ())
1463
- .append ("'" );
1464
-
1465
- logger .info ("Command to call kubectl sh file " + cmdKubectlSh );
1466
- TestUtils .exec (cmdKubectlSh .toString ());
1467
- }
1468
1469
}
0 commit comments