@@ -92,11 +92,7 @@ public Domain(Map<String, Object> inputDomainMap) throws Exception {
92
92
public void verifyDomainCreated () throws Exception {
93
93
StringBuffer command = new StringBuffer ();
94
94
command .append ("kubectl get domain " ).append (domainUid ).append (" -n " ).append (domainNS );
95
- ExecResult result = ExecCommand .exec (command .toString ());
96
- if (result .exitValue () != 0 ) {
97
- throw new RuntimeException (
98
- "FAILED: command to get domain " + command + " failed with " + result .stderr ());
99
- }
95
+ ExecResult result = TestUtils .exec (command .toString ());
100
96
if (!result .stdout ().contains (domainUid ))
101
97
throw new RuntimeException ("FAILURE: domain not found, exiting!" );
102
98
@@ -262,11 +258,7 @@ public void verifyAdminServerExternalService(String username, String password) t
262
258
.append (password )
263
259
.append (" -H X-Requested-By:Integration-Test --write-out %{http_code} -o /dev/null" );
264
260
logger .info ("cmd for curl " + cmd );
265
- ExecResult result = ExecCommand .exec (cmd .toString ());
266
- if (result .exitValue () != 0 ) {
267
- throw new RuntimeException (
268
- "FAILURE: command " + cmd + " failed, returned " + result .stderr ());
269
- }
261
+ ExecResult result = TestUtils .exec (cmd .toString ());
270
262
String output = result .stdout ().trim ();
271
263
logger .info ("output " + output );
272
264
if (!output .equals ("200" )) {
@@ -372,11 +364,7 @@ public void deployWebAppViaREST(
372
364
.append ("/management/weblogic/latest/edit/appDeployments" )
373
365
.append (" --write-out %{http_code} -o /dev/null" );
374
366
logger .fine ("Command to deploy webapp " + cmd );
375
- ExecResult result = ExecCommand .exec (cmd .toString ());
376
- if (result .exitValue () != 0 ) {
377
- throw new RuntimeException (
378
- "FAILURE: command " + cmd + " failed, returned " + result .stderr ());
379
- }
367
+ ExecResult result = TestUtils .exec (cmd .toString ());
380
368
String output = result .stdout ().trim ();
381
369
if (!output .contains ("202" )) {
382
370
throw new RuntimeException ("FAILURE: Webapp deployment failed with response code " + output );
@@ -506,16 +494,7 @@ public void create() throws Exception {
506
494
.append (domainUid )
507
495
.append ("/domain.yaml" );
508
496
logger .info ("Running " + cmd );
509
- ExecResult result = ExecCommand .exec (cmd .toString ());
510
- if (result .exitValue () != 0 ) {
511
- throw new RuntimeException (
512
- "FAILURE: command "
513
- + cmd
514
- + " failed, returned "
515
- + result .stdout ()
516
- + "\n "
517
- + result .stderr ());
518
- }
497
+ ExecResult result = TestUtils .exec (cmd .toString ());
519
498
String outputStr = result .stdout ().trim ();
520
499
logger .info ("Command returned " + outputStr );
521
500
@@ -534,11 +513,7 @@ public void destroy() throws Exception {
534
513
.append ("/weblogic-domains/" )
535
514
.append (domainUid )
536
515
.append ("/domain.yaml" );
537
- ExecResult result = ExecCommand .exec (cmd .toString ());
538
- if (result .exitValue () != 0 ) {
539
- throw new RuntimeException (
540
- "FAILURE: command " + cmd + " failed, returned " + result .stderr ());
541
- }
516
+ ExecResult result = TestUtils .exec (cmd .toString ());
542
517
String output = result .stdout ().trim ();
543
518
logger .info ("command to delete domain " + cmd + " \n returned " + output );
544
519
verifyDomainDeleted (replicas );
@@ -552,11 +527,7 @@ public void destroy() throws Exception {
552
527
public void shutdown () throws Exception {
553
528
int replicas = TestUtils .getClusterReplicas (domainUid , clusterName , domainNS );
554
529
String cmd = "kubectl delete domain " + domainUid + " -n " + domainNS ;
555
- ExecResult result = ExecCommand .exec (cmd );
556
- if (result .exitValue () != 0 ) {
557
- throw new RuntimeException (
558
- "FAILURE: command " + cmd + " failed, returned " + result .stderr ());
559
- }
530
+ ExecResult result = TestUtils .exec (cmd .toString ());
560
531
String output = result .stdout ().trim ();
561
532
logger .info ("command to delete domain " + cmd + " \n returned " + output );
562
533
verifyDomainDeleted (replicas );
@@ -575,11 +546,7 @@ public void shutdownUsingServerStartPolicy() throws Exception {
575
546
+ " -n "
576
547
+ domainNS
577
548
+ " -p '{\" spec\" :{\" serverStartPolicy\" :\" NEVER\" }}' --type merge" ;
578
- ExecResult result = ExecCommand .exec (cmd );
579
- if (result .exitValue () != 0 ) {
580
- throw new RuntimeException (
581
- "FAILURE: command " + cmd + " failed, returned " + result .stderr ());
582
- }
549
+ ExecResult result = TestUtils .exec (cmd );
583
550
String output = result .stdout ().trim ();
584
551
logger .info ("command to shutdown domain " + cmd + " \n returned " + output );
585
552
verifyServerPodsDeleted (replicas );
@@ -597,11 +564,7 @@ public void restartUsingServerStartPolicy() throws Exception {
597
564
+ " -n "
598
565
+ domainNS
599
566
+ " -p '{\" spec\" :{\" serverStartPolicy\" :\" IF_NEEDED\" }}' --type merge" ;
600
- ExecResult result = ExecCommand .exec (cmd );
601
- if (result .exitValue () != 0 ) {
602
- throw new RuntimeException (
603
- "FAILURE: command " + cmd + " failed, returned " + result .stderr ());
604
- }
567
+ ExecResult result = TestUtils .exec (cmd );
605
568
String output = result .stdout ().trim ();
606
569
logger .info ("command to restart domain " + cmd + " \n returned " + output );
607
570
verifyPodsCreated ();
@@ -715,16 +678,7 @@ public void verifyAdminConsoleViaLB() throws Exception {
715
678
.append (responseBodyFile );
716
679
logger .info ("cmd for curl " + cmd );
717
680
718
- ExecResult result = ExecCommand .exec (cmd .toString ());
719
- if (result .exitValue () != 0 ) {
720
- throw new RuntimeException (
721
- "FAILURE: command "
722
- + cmd
723
- + " failed, returned "
724
- + result .stderr ()
725
- + "\n "
726
- + result .stdout ());
727
- }
681
+ ExecResult result = TestUtils .exec (cmd .toString ());
728
682
729
683
String output = result .stdout ().trim ();
730
684
logger .info ("output " + output );
@@ -785,11 +739,7 @@ public int getNumberOfServersInClusterServiceEndpoint(String clusterName) throws
785
739
.append (domainNS )
786
740
.append (" | grep Endpoints | awk '{print $2}'" );
787
741
788
- ExecResult result = ExecCommand .exec (cmd .toString ());
789
- if (result .exitValue () != 0 ) {
790
- throw new RuntimeException (
791
- "FAILURE: Commmand " + cmd + " failed, cluster service is not ready." );
792
- }
742
+ ExecResult result = TestUtils .exec (cmd .toString ());
793
743
logger .info ("Cluster service Endpoint " + result .stdout ());
794
744
return new StringTokenizer (result .stdout (), "," ).countTokens ();
795
745
}
@@ -806,12 +756,8 @@ private int getAdminSericeLBNodePort() throws Exception {
806
756
807
757
logger .info ("Cmd to get the admins service node port " + cmd );
808
758
809
- ExecResult result = ExecCommand .exec (cmd .toString ());
810
- if (result .exitValue () == 0 ) {
811
- return new Integer (result .stdout ().trim ()).intValue ();
812
- } else {
813
- throw new RuntimeException ("Cmd failed " + result .stderr () + " \n " + result .stdout ());
814
- }
759
+ ExecResult result = TestUtils .exec (cmd .toString ());
760
+ return new Integer (result .stdout ().trim ()).intValue ();
815
761
}
816
762
817
763
/**
@@ -979,16 +925,7 @@ private void createSecret() throws Exception {
979
925
String .format (
980
926
"kubectl label secret %s weblogic.domainUID=%s -n %s" ,
981
927
secret .getSecretName (), domainUid , domainNS );
982
- ExecResult result = ExecCommand .exec (labelCmd );
983
- if (result .exitValue () != 0 ) {
984
- throw new RuntimeException (
985
- "FAILURE: command to label secret \" "
986
- + labelCmd
987
- + "\" failed, returned "
988
- + result .stdout ()
989
- + "\n "
990
- + result .stderr ());
991
- }
928
+ TestUtils .exec (labelCmd );
992
929
}
993
930
994
931
/**
@@ -1161,11 +1098,7 @@ private void callShellScriptByExecToPod(
1161
1098
1162
1099
private void callWebAppAndWaitTillReady (String curlCmd ) throws Exception {
1163
1100
for (int i = 0 ; i < maxIterations ; i ++) {
1164
- ExecResult result = ExecCommand .exec (curlCmd .toString ());
1165
- if (result .exitValue () != 0 ) {
1166
- throw new RuntimeException (
1167
- "FAILURE: command " + curlCmd + " failed, returned " + result .stderr ());
1168
- }
1101
+ ExecResult result = TestUtils .exec (curlCmd );
1169
1102
String responseCode = result .stdout ().trim ();
1170
1103
if (!responseCode .equals ("200" )) {
1171
1104
logger .info (
@@ -1200,18 +1133,9 @@ private void callWebAppAndCheckForServerNameInResponse(
1200
1133
logger .info ("Calling webapp 20 times " + curlCmd );
1201
1134
// number of times to call webapp
1202
1135
for (int i = 0 ; i < 20 ; i ++) {
1203
- ExecResult result = ExecCommand .exec (curlCmd .toString ());
1204
- if (result .exitValue () != 0 ) {
1205
- throw new RuntimeException (
1206
- "FAILURE: command "
1207
- + curlCmd
1208
- + " failed, returned "
1209
- + result .stderr ()
1210
- + " \n "
1211
- + result .stdout ());
1212
- } else {
1213
- logger .info ("webapp invoked successfully for curlCmd:" + curlCmd );
1214
- }
1136
+ ExecResult result = TestUtils .exec (curlCmd );
1137
+
1138
+ logger .info ("webapp invoked successfully for curlCmd:" + curlCmd );
1215
1139
if (verifyLoadBalancing ) {
1216
1140
String response = result .stdout ().trim ();
1217
1141
// logger.info("response: " + response);
@@ -1356,11 +1280,7 @@ private String getNodeHost() throws Exception {
1356
1280
+ domainNS
1357
1281
+ " | grep Node:" ;
1358
1282
1359
- ExecResult result = ExecCommand .exec (cmd );
1360
- if (result .exitValue () != 0 ) {
1361
- throw new RuntimeException (
1362
- "FAILURE: command " + cmd + " failed, returned " + result .stderr ());
1363
- }
1283
+ ExecResult result = TestUtils .exec (cmd );
1364
1284
String nodePortHost = result .stdout ();
1365
1285
// logger.info("nodePortHost "+nodePortHost);
1366
1286
if (nodePortHost .contains (":" ) && nodePortHost .contains ("/" )) {
@@ -1379,11 +1299,7 @@ private String getNodePort() throws Exception {
1379
1299
.append (" -n " )
1380
1300
.append (domainNS )
1381
1301
.append (" | grep \" Node Port:\" " );
1382
- ExecResult result = ExecCommand .exec (cmd .toString ());
1383
- if (result .exitValue () != 0 ) {
1384
- throw new RuntimeException (
1385
- "FAILURE: command " + cmd + " failed, returned " + result .stderr ());
1386
- }
1302
+ ExecResult result = TestUtils .exec (cmd .toString ());
1387
1303
String output = result .stdout ();
1388
1304
if (output .contains ("Node Port" )) {
1389
1305
return output .substring (output .indexOf (":" ) + 1 ).trim ();
@@ -1421,16 +1337,7 @@ private void gitCloneDockerImagesSample() throws Exception {
1421
1337
.append (BaseTest .getResultDir ())
1422
1338
.append ("/docker-images" );
1423
1339
logger .info ("Executing cmd " + removeAndClone );
1424
- ExecResult result = ExecCommand .exec (removeAndClone .toString ());
1425
- if (result .exitValue () != 0 ) {
1426
- throw new RuntimeException (
1427
- "FAILURE: command "
1428
- + removeAndClone
1429
- + " failed "
1430
- + result .stderr ()
1431
- + " "
1432
- + result .stdout ());
1433
- }
1340
+ ExecResult result = TestUtils .exec (removeAndClone .toString ());
1434
1341
}
1435
1342
}
1436
1343
0 commit comments