|
84 | 84 | import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.verifyUpdateWebLogicCredential;
|
85 | 85 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
|
86 | 86 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
|
87 |
| -import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkSystemResourceConfiguration; |
| 87 | +import static oracle.weblogic.kubernetes.utils.CommonTestUtils.verifyCommandResultContainsMsg; |
| 88 | +import static oracle.weblogic.kubernetes.utils.CommonTestUtils.verifySystemResourceConfiguration; |
88 | 89 | import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.createConfigMapAndVerify;
|
89 | 90 | import static oracle.weblogic.kubernetes.utils.ExecCommand.exec;
|
90 | 91 | import static oracle.weblogic.kubernetes.utils.FileUtils.copyFileToPod;
|
@@ -276,19 +277,7 @@ void testMiiCustomEnv() {
|
276 | 277 | .append("?fields=notes&links=none\"")
|
277 | 278 | .append(" --silent ");
|
278 | 279 | logger.info("checkJmsServerConfig: curl command {0}", new String(curlString));
|
279 |
| - ExecResult result = null; |
280 |
| - try { |
281 |
| - result = exec(new String(curlString), true); |
282 |
| - getLogger().info("The command returned exit value: " |
283 |
| - + result.exitValue() + " command output: " |
284 |
| - + result.stderr() + "\n" + result.stdout()); |
285 |
| - assertTrue((result.exitValue() == 0), |
286 |
| - "curl command returned non zero value"); |
287 |
| - assertTrue((result.stdout().contains("${DOMAIN_UID}~##!'%*$(ls)")), |
288 |
| - "Custom environment variable is not reflected in domin config"); |
289 |
| - } catch (Exception e) { |
290 |
| - getLogger().info("Got exception, command failed with errors " + e.getMessage()); |
291 |
| - } |
| 280 | + verifyCommandResultContainsMsg(new String(curlString), "${DOMAIN_UID}~##!'%*$(ls)"); |
292 | 281 | }
|
293 | 282 |
|
294 | 283 | /**
|
@@ -324,7 +313,7 @@ void testMiiHttpServerLogsAreOnPV() {
|
324 | 313 | + "(elapsed time {0} ms, remaining time {1} ms)",
|
325 | 314 | condition.getElapsedTimeInMS(),
|
326 | 315 | condition.getRemainingTimeInMS()))
|
327 |
| - .until((Callable<Boolean>) () -> { |
| 316 | + .until(() -> { |
328 | 317 | ExecResult execResult = assertDoesNotThrow(() -> execCommand(domainNamespace, pod, null, true,
|
329 | 318 | "/bin/sh", "-c", curlCmd));
|
330 | 319 | return execResult.toString().contains("HTTP/1.1 200 OK");
|
@@ -353,27 +342,19 @@ void testMiiCheckSystemResources() {
|
353 | 342 | int adminServiceNodePort
|
354 | 343 | = getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
|
355 | 344 | assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
|
356 |
| - assertTrue(checkSystemResourceConfiguration(adminServiceNodePort, "JDBCSystemResources", |
357 |
| - "TestDataSource", "200"), "JDBCSystemResource not found"); |
| 345 | + |
| 346 | + verifySystemResourceConfiguration(adminServiceNodePort, "JDBCSystemResources", "TestDataSource", "200"); |
358 | 347 | logger.info("Found the JDBCSystemResource configuration");
|
359 | 348 |
|
360 |
| - assertTrue(checkSystemResourceConfiguration(adminServiceNodePort,"JMSSystemResources", |
361 |
| - "TestClusterJmsModule", "200"), "JMSSystemResources not found"); |
| 349 | + verifySystemResourceConfiguration(adminServiceNodePort,"JMSSystemResources", "TestClusterJmsModule", "200"); |
362 | 350 | logger.info("Found the JMSSystemResource configuration");
|
363 | 351 |
|
364 |
| - assertTrue(checkSystemResourceConfiguration(adminServiceNodePort,"WLDFSystemResources", |
365 |
| - "TestWldfModule", "200"), "WLDFSystemResources not found"); |
| 352 | + verifySystemResourceConfiguration(adminServiceNodePort,"WLDFSystemResources", "TestWldfModule", "200"); |
366 | 353 | logger.info("Found the WLDFSystemResource configuration");
|
367 | 354 |
|
368 |
| - ExecResult result = null; |
369 |
| - result = checkJdbcRuntime("TestDataSource"); |
370 |
| - logger.info("checkJdbcRuntime: returned {0}", result.toString()); |
371 |
| - assertTrue(result.stdout().contains("jdbc:oracle:thin:localhost"), |
372 |
| - String.format("DB URL does not match with RuntimeMBean Info")); |
373 |
| - assertTrue(result.stdout().contains("scott"), |
374 |
| - String.format("DB user name does not match with RuntimeMBean Info")); |
| 355 | + verifyJdbcRuntime("TestDataSource", "jdbc:oracle:thin:localhost"); |
| 356 | + verifyJdbcRuntime("TestDataSource", "scott"); |
375 | 357 | logger.info("Found the JDBCSystemResource configuration");
|
376 |
| - |
377 | 358 | }
|
378 | 359 |
|
379 | 360 | /**
|
@@ -434,10 +415,8 @@ void testMiiDeleteSystemResources() {
|
434 | 415 | int adminServiceNodePort
|
435 | 416 | = getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
|
436 | 417 | assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
|
437 |
| - assertTrue(checkSystemResourceConfiguration(adminServiceNodePort, "JDBCSystemResources", |
438 |
| - "TestDataSource", "404"), "JDBCSystemResource should be deleted"); |
439 |
| - assertTrue(checkSystemResourceConfiguration(adminServiceNodePort, "JMSSystemResources", |
440 |
| - "TestClusterJmsModule", "404"), "JMSSystemResources should be deleted"); |
| 418 | + verifySystemResourceConfiguration(adminServiceNodePort, "JDBCSystemResources", "TestDataSource", "404"); |
| 419 | + verifySystemResourceConfiguration(adminServiceNodePort, "JMSSystemResources", "TestClusterJmsModule", "404"); |
441 | 420 | }
|
442 | 421 |
|
443 | 422 | /**
|
@@ -500,12 +479,11 @@ void testMiiAddSystemResources() {
|
500 | 479 | int adminServiceNodePort
|
501 | 480 | = getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
|
502 | 481 | assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
|
503 |
| - assertTrue(checkSystemResourceConfiguration(adminServiceNodePort,"JDBCSystemResources", |
504 |
| - "TestDataSource2", "200"), "JDBCSystemResource not found"); |
| 482 | + |
| 483 | + verifySystemResourceConfiguration(adminServiceNodePort,"JDBCSystemResources", "TestDataSource2", "200"); |
505 | 484 | logger.info("Found the JDBCSystemResource configuration");
|
506 | 485 |
|
507 |
| - assertTrue(checkSystemResourceConfiguration(adminServiceNodePort, "JMSSystemResources", |
508 |
| - "TestClusterJmsModule2", "200"), "JMSSystemResources not found"); |
| 486 | + verifySystemResourceConfiguration(adminServiceNodePort, "JMSSystemResources", "TestClusterJmsModule2", "200"); |
509 | 487 | logger.info("Found the JMSSystemResource configuration");
|
510 | 488 |
|
511 | 489 | // check JMS logs are written on PV
|
@@ -566,8 +544,7 @@ void testMiiAddDynmicClusteriWithNoReplica() {
|
566 | 544 | String newServerPodName = domainUid + "-config-server1";
|
567 | 545 | checkPodNotCreated(newServerPodName, domainUid, domainNamespace);
|
568 | 546 |
|
569 |
| - boolean isServerConfigured = checkManagedServerConfiguration("config-server1"); |
570 |
| - assertTrue(isServerConfigured, "Could not find new managed server configuration"); |
| 547 | + verifyManagedServerConfiguration("config-server1"); |
571 | 548 | logger.info("Found new managed server configuration");
|
572 | 549 | }
|
573 | 550 |
|
@@ -643,8 +620,7 @@ void testMiiAddDynamicCluster() {
|
643 | 620 | checkPodReady(newServerPodName, domainUid, domainNamespace);
|
644 | 621 | checkServiceExists(newServerPodName, domainNamespace);
|
645 | 622 |
|
646 |
| - boolean isServerConfigured = checkManagedServerConfiguration("dynamic-server1"); |
647 |
| - assertTrue(isServerConfigured, "Could not find new managed server configuration"); |
| 623 | + verifyManagedServerConfiguration("dynamic-server1"); |
648 | 624 | logger.info("Found new managed server configuration");
|
649 | 625 | }
|
650 | 626 |
|
@@ -717,8 +693,7 @@ void testMiiAddConfiguredCluster() {
|
717 | 693 | checkPodReady(newServerPodName, domainUid, domainNamespace);
|
718 | 694 | checkServiceExists(newServerPodName, domainNamespace);
|
719 | 695 |
|
720 |
| - boolean isServerConfigured = checkManagedServerConfiguration("config-server1"); |
721 |
| - assertTrue(isServerConfigured, "Could not find new managed server configuration"); |
| 696 | + verifyManagedServerConfiguration("config-server1"); |
722 | 697 | logger.info("Found new managed server configuration");
|
723 | 698 | }
|
724 | 699 |
|
@@ -1051,36 +1026,23 @@ private void checkPodNotCreated(String podName, String domainUid, String domName
|
1051 | 1026 | podName, domNamespace)));
|
1052 | 1027 | }
|
1053 | 1028 |
|
1054 |
| - /* |
1055 |
| - * Verify the server MBEAN configuration through rest API. |
1056 |
| - * @param managedServer name of the managed server |
1057 |
| - * @returns true if MBEAN is found otherwise false |
1058 |
| - **/ |
1059 |
| - private boolean checkManagedServerConfiguration(String managedServer) { |
1060 |
| - ExecResult result = null; |
| 1029 | + private void verifyManagedServerConfiguration(String managedServer) { |
| 1030 | + |
1061 | 1031 | int adminServiceNodePort
|
1062 | 1032 | = getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
|
| 1033 | + |
1063 | 1034 | checkCluster = new StringBuffer("status=$(curl --user weblogic:welcome1 ");
|
1064 | 1035 | checkCluster.append("http://" + K8S_NODEPORT_HOST + ":" + adminServiceNodePort)
|
1065 |
| - .append("/management/tenant-monitoring/servers/") |
1066 |
| - .append(managedServer) |
1067 |
| - .append(" --silent --show-error ") |
1068 |
| - .append(" -o /dev/null") |
1069 |
| - .append(" -w %{http_code});") |
1070 |
| - .append("echo ${status}"); |
| 1036 | + .append("/management/tenant-monitoring/servers/") |
| 1037 | + .append(managedServer) |
| 1038 | + .append(" --silent --show-error ") |
| 1039 | + .append(" -o /dev/null") |
| 1040 | + .append(" -w %{http_code});") |
| 1041 | + .append("echo ${status}"); |
1071 | 1042 | logger.info("checkManagedServerConfiguration: curl command {0}", new String(checkCluster));
|
1072 |
| - try { |
1073 |
| - result = exec(new String(checkCluster), true); |
1074 |
| - } catch (Exception ex) { |
1075 |
| - logger.info("Exception in checkManagedServerConfiguration() {0}", ex); |
1076 |
| - return false; |
1077 |
| - } |
1078 |
| - logger.info("checkManagedServerConfiguration: curl command returned {0}", result.toString()); |
1079 |
| - if (result.stdout().equals("200")) { |
1080 |
| - return true; |
1081 |
| - } else { |
1082 |
| - return false; |
1083 |
| - } |
| 1043 | + |
| 1044 | + verifyCommandResultContainsMsg(new String(checkCluster), "200"); |
| 1045 | + |
1084 | 1046 | }
|
1085 | 1047 |
|
1086 | 1048 | // Crate a ConfigMap with a model file to add a new WebLogic cluster
|
@@ -1108,25 +1070,20 @@ private void createClusterConfigMap(String configMapName, String modelFile) {
|
1108 | 1070 | assertTrue(cmCreated, String.format("createConfigMap failed while creating ConfigMap %s", configMapName));
|
1109 | 1071 | }
|
1110 | 1072 |
|
1111 |
| - private ExecResult checkJdbcRuntime(String resourcesName) { |
| 1073 | + private void verifyJdbcRuntime(String resourcesName, String expectedOutput) { |
1112 | 1074 | int adminServiceNodePort
|
1113 | 1075 | = getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
|
1114 | 1076 | ExecResult result = null;
|
1115 | 1077 |
|
1116 | 1078 | curlString = new StringBuffer("curl --user weblogic:welcome1 ");
|
1117 | 1079 | curlString.append("http://" + K8S_NODEPORT_HOST + ":" + adminServiceNodePort)
|
1118 |
| - .append("/management/wls/latest/datasources/id/") |
1119 |
| - .append(resourcesName) |
1120 |
| - .append("/") |
1121 |
| - .append(" --silent --show-error "); |
| 1080 | + .append("/management/wls/latest/datasources/id/") |
| 1081 | + .append(resourcesName) |
| 1082 | + .append("/") |
| 1083 | + .append(" --silent --show-error "); |
1122 | 1084 | logger.info("checkJdbcRuntime: curl command {0}", new String(curlString));
|
1123 |
| - try { |
1124 |
| - result = exec(new String(curlString), true); |
1125 |
| - } catch (Exception ex) { |
1126 |
| - logger.info("checkJdbcRuntime: caught unexpected exception {0}", ex); |
1127 |
| - return null; |
1128 |
| - } |
1129 |
| - return result; |
| 1085 | + |
| 1086 | + verifyCommandResultContainsMsg(new String(curlString), expectedOutput); |
1130 | 1087 | }
|
1131 | 1088 |
|
1132 | 1089 | private static void createJobToChangePermissionsOnPvHostPath(String pvName, String pvcName, String namespace) {
|
|
0 commit comments