|
73 | 73 | import static oracle.weblogic.kubernetes.actions.TestActions.createConfigMap;
|
74 | 74 | import static oracle.weblogic.kubernetes.actions.TestActions.createDomainCustomResource;
|
75 | 75 | import static oracle.weblogic.kubernetes.actions.TestActions.createSecret;
|
| 76 | +import static oracle.weblogic.kubernetes.actions.TestActions.execCommand; |
76 | 77 | import static oracle.weblogic.kubernetes.actions.TestActions.getJob;
|
77 | 78 | import static oracle.weblogic.kubernetes.actions.TestActions.getPodLog;
|
78 | 79 | import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
|
|
107 | 108 | import static oracle.weblogic.kubernetes.utils.FileUtils.copyFileToPod;
|
108 | 109 | import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
|
109 | 110 | import static org.awaitility.Awaitility.with;
|
| 111 | +import static org.junit.jupiter.api.Assertions.assertAll; |
110 | 112 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
111 | 113 | import static org.junit.jupiter.api.Assertions.assertFalse;
|
112 | 114 | import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
@@ -261,15 +263,47 @@ public void testMiiServerLogsAreOnPV() {
|
261 | 263 | }
|
262 | 264 |
|
263 | 265 | /**
|
264 |
| - * Create a WebLogic domain with a defined configmap in configuration/model |
| 266 | + * Check HTTP server logs are written on logHome. |
| 267 | + * The test looks for the string sample-war/index.jsp in HTTP access |
| 268 | + * logs |
| 269 | + */ |
| 270 | + @Test |
| 271 | + @Order(2) |
| 272 | + @DisplayName("Check the HTTP server logs are written to PersistentVolume") |
| 273 | + public void testMiiHttpServerLogsAreOnPV() { |
| 274 | + String[] podNames = {managedServerPrefix + "1", managedServerPrefix + "2"}; |
| 275 | + for (String pod : podNames) { |
| 276 | + String curlCmd = "for i in {1..100}; do curl -v " |
| 277 | + + "http://" + pod + ":8001/sample-war/index.jsp; done"; |
| 278 | + logger.info("Command to send HTTP request and get HTTP response {0} ", curlCmd); |
| 279 | + ExecResult execResult = assertDoesNotThrow(() -> execCommand(domainNamespace, pod, null, true, |
| 280 | + "/bin/sh", "-c", curlCmd)); |
| 281 | + if (execResult.exitValue() == 0) { |
| 282 | + logger.info("\n HTTP response is \n " + execResult.toString()); |
| 283 | + assertAll("Check that the HTTP response is 200", |
| 284 | + () -> assertTrue(execResult.toString().contains("HTTP/1.1 200 OK")) |
| 285 | + ); |
| 286 | + } else { |
| 287 | + fail("Failed to access sample application " + execResult.stderr()); |
| 288 | + } |
| 289 | + } |
| 290 | + String[] servers = {"managed-server1", "managed-server2"}; |
| 291 | + for (String server : servers) { |
| 292 | + logger.info("Checking HTTP server logs are written on PV and look for string sample-war/index.jsp in log"); |
| 293 | + checkLogsOnPV("grep sample-war/index.jsp /shared/logs/" + server + "_access.log", adminServerPodName); |
| 294 | + } |
| 295 | + } |
| 296 | + |
| 297 | + /** |
| 298 | + * Create a WebLogic domain with a defined configmap in configuration/model |
265 | 299 | * section of the domain resource.
|
266 |
| - * The configmap has multiple sparse WDT model files that define |
| 300 | + * The configmap has multiple sparse WDT model files that define |
267 | 301 | * a JDBCSystemResource, a JMSSystemResource and a WLDFSystemResource.
|
268 |
| - * Verify all the SystemResource configurations using the rest API call |
| 302 | + * Verify all the SystemResource configurations using the rest API call |
269 | 303 | * using the public nodeport of the administration server.
|
270 | 304 | */
|
271 | 305 | @Test
|
272 |
| - @Order(2) |
| 306 | + @Order(3) |
273 | 307 | @DisplayName("Verify the pre-configured SystemResources in the domain")
|
274 | 308 | public void testMiiCheckSystemResources() {
|
275 | 309 |
|
@@ -309,7 +343,7 @@ public void testMiiCheckSystemResources() {
|
309 | 343 | * Verify SystemResources are deleted from the domain.
|
310 | 344 | */
|
311 | 345 | @Test
|
312 |
| - @Order(3) |
| 346 | + @Order(4) |
313 | 347 | @DisplayName("Delete SystemResources from the domain")
|
314 | 348 | public void testMiiDeleteSystemResources() {
|
315 | 349 |
|
@@ -343,7 +377,7 @@ public void testMiiDeleteSystemResources() {
|
343 | 377 |
|
344 | 378 | String newRestartVersion = patchDomainResourceWithNewRestartVersion(domainUid, domainNamespace);
|
345 | 379 | logger.log(Level.INFO, "New restart version is {0}", newRestartVersion);
|
346 |
| - |
| 380 | + |
347 | 381 | assertTrue(verifyRollingRestartOccurred(pods, 1, domainNamespace),
|
348 | 382 | "Rolling restart failed");
|
349 | 383 |
|
@@ -374,7 +408,7 @@ public void testMiiDeleteSystemResources() {
|
374 | 408 | * Verify JMS Server logs are written on PV.
|
375 | 409 | */
|
376 | 410 | @Test
|
377 |
| - @Order(4) |
| 411 | + @Order(5) |
378 | 412 | @DisplayName("Add new JDBC/JMS SystemResources to the domain")
|
379 | 413 | public void testMiiAddSystemResources() {
|
380 | 414 |
|
@@ -409,7 +443,7 @@ public void testMiiAddSystemResources() {
|
409 | 443 |
|
410 | 444 | String newRestartVersion = patchDomainResourceWithNewRestartVersion(domainUid, domainNamespace);
|
411 | 445 | logger.log(Level.INFO, "New restart version is {0}", newRestartVersion);
|
412 |
| - |
| 446 | + |
413 | 447 | assertTrue(verifyRollingRestartOccurred(pods, 1, domainNamespace),
|
414 | 448 | "Rolling restart failed");
|
415 | 449 |
|
@@ -440,11 +474,11 @@ public void testMiiAddSystemResources() {
|
440 | 474 | * Update the restart version of the domain resource.
|
441 | 475 | * Verify rolling restart of the domain by comparing PodCreationTimestamp
|
442 | 476 | * before and after rolling restart.
|
443 |
| - * Verify servers from new cluster are not in running state, because |
| 477 | + * Verify servers from new cluster are not in running state, because |
444 | 478 | * the spec level replica count to zero(default).
|
445 | 479 | */
|
446 | 480 | @Test
|
447 |
| - @Order(5) |
| 481 | + @Order(6) |
448 | 482 | @DisplayName("Add a dynamic cluster to the domain with default replica count")
|
449 | 483 | public void testMiiAddDynmicClusteriWithNoReplica() {
|
450 | 484 |
|
@@ -504,7 +538,7 @@ public void testMiiAddDynmicClusteriWithNoReplica() {
|
504 | 538 | * Verify servers from new cluster are in running state.
|
505 | 539 | */
|
506 | 540 | @Test
|
507 |
| - @Order(6) |
| 541 | + @Order(7) |
508 | 542 | @DisplayName("Add a dynamic cluster to domain with non-zero replica count")
|
509 | 543 | public void testMiiAddDynamicCluster() {
|
510 | 544 |
|
@@ -581,7 +615,7 @@ public void testMiiAddDynamicCluster() {
|
581 | 615 | * Verify servers from new cluster are in running state.
|
582 | 616 | */
|
583 | 617 | @Test
|
584 |
| - @Order(7) |
| 618 | + @Order(8) |
585 | 619 | @DisplayName("Add a configured cluster to the domain")
|
586 | 620 | public void testMiiAddConfiguredCluster() {
|
587 | 621 |
|
@@ -649,11 +683,11 @@ public void testMiiAddConfiguredCluster() {
|
649 | 683 | * Start a WebLogic domain with model-in-imge.
|
650 | 684 | * Patch the domain CRD with a new credentials secret.
|
651 | 685 | * Update domainRestartVersion to trigger a rolling restart of server pods.
|
652 |
| - * Make sure all the server pods are re-started in a rolling fashion. |
| 686 | + * Make sure all the server pods are re-started in a rolling fashion. |
653 | 687 | * Check the validity of new credentials by accessing WebLogic RESTful Service
|
654 | 688 | */
|
655 | 689 | @Test
|
656 |
| - @Order(8) |
| 690 | + @Order(9) |
657 | 691 | @DisplayName("Change the WebLogic Admin credential of the domain")
|
658 | 692 | public void testMiiUpdateWebLogicCredential() {
|
659 | 693 | final boolean VALID = true;
|
@@ -709,23 +743,23 @@ public void testMiiUpdateWebLogicCredential() {
|
709 | 743 | }
|
710 | 744 |
|
711 | 745 | /**
|
712 |
| - * Start a WebLogic domain with a dynamic cluster with the following |
| 746 | + * Start a WebLogic domain with a dynamic cluster with the following |
713 | 747 | * attributes MaxDynamicClusterSize(5) and MinDynamicClusterSize(1)
|
714 | 748 | * Set allowReplicasBelowMinDynClusterSize to false.
|
715 | 749 | * Make sure that the cluster can be scaled up to 5 servers and
|
716 |
| - * scaled down to 1 server. |
717 |
| - * Create a configmap with a sparse model file with following attributes for |
| 750 | + * scaled down to 1 server. |
| 751 | + * Create a configmap with a sparse model file with following attributes for |
718 | 752 | * Cluster/cluster-1/DynamicServers
|
719 | 753 | * MaxDynamicClusterSize(4) and MinDynamicClusterSize(2)
|
720 | 754 | * Patch the domain resource with the configmap and update restartVersion.
|
721 |
| - * Make sure a rolling restart is triggered. |
| 755 | + * Make sure a rolling restart is triggered. |
722 | 756 | * Now with the modified value
|
723 | 757 | * Make sure that the cluster can be scaled up to 4 servers.
|
724 | 758 | * Make sure JMS Connections and messages are distributed across 4 servers.
|
725 | 759 | * Make sure that the cluster can be scaled down below 2 servers.
|
726 | 760 | */
|
727 | 761 | @Test
|
728 |
| - @Order(9) |
| 762 | + @Order(10) |
729 | 763 | @DisplayName("Test modification to Dynamic cluster size parameters")
|
730 | 764 | public void testMiiUpdateDynamicClusterSize() {
|
731 | 765 |
|
@@ -774,8 +808,8 @@ public void testMiiUpdateDynamicClusterSize() {
|
774 | 808 | pods.put(managedServerPrefix + i, getPodCreationTime(domainNamespace, managedServerPrefix + i));
|
775 | 809 | }
|
776 | 810 |
|
777 |
| - // Update the Dynamic ClusterSize and add distributed destination |
778 |
| - // to verify JMS connection and message distribution after the |
| 811 | + // Update the Dynamic ClusterSize and add distributed destination |
| 812 | + // to verify JMS connection and message distribution after the |
779 | 813 | // WebLogic cluster is scaled.
|
780 | 814 | String configMapName = "dynamic-cluster-size-cm";
|
781 | 815 | createClusterConfigMap(configMapName, "model.cluster.size.yaml");
|
@@ -810,7 +844,7 @@ public void testMiiUpdateDynamicClusterSize() {
|
810 | 844 | String.format("Scaling the cluster cluster-1 of domain %s in namespace %s failed", domainUid, domainNamespace));
|
811 | 845 | assertTrue(p1Success,
|
812 | 846 | String.format("replica patching to 3 failed for domain %s in namespace %s", domainUid, domainNamespace));
|
813 |
| - |
| 847 | + |
814 | 848 | // Make sure the 3rd Managed server comes up
|
815 | 849 | checkServiceExists(managedServerPrefix + "3", domainNamespace);
|
816 | 850 | checkServiceExists(managedServerPrefix + "4", domainNamespace);
|
@@ -842,11 +876,11 @@ public void testMiiUpdateDynamicClusterSize() {
|
842 | 876 | condition.getElapsedTimeInMS(),
|
843 | 877 | condition.getRemainingTimeInMS()))
|
844 | 878 | .until(runJmsClient(new String(javapCmd)));
|
845 |
| - |
846 |
| - // Since the MinDynamicClusterSize is set to 2 in the configmap |
| 879 | + |
| 880 | + // Since the MinDynamicClusterSize is set to 2 in the configmap |
847 | 881 | // and allowReplicasBelowMinDynClusterSize is set false, the replica
|
848 |
| - // count can not go below 2. So during the following scale down operation |
849 |
| - // only managed-server3 and managed-server4 pod should be removed. |
| 882 | + // count can not go below 2. So during the following scale down operation |
| 883 | + // only managed-server3 and managed-server4 pod should be removed. |
850 | 884 | logger.info("[After Patching] updating the replica count to 1");
|
851 | 885 | boolean p4Success = assertDoesNotThrow(() ->
|
852 | 886 | scaleCluster(domainUid, domainNamespace, "cluster-1", 1),
|
@@ -907,7 +941,7 @@ private static Callable<Boolean> runJmsClient(String javaCmd) {
|
907 | 941 |
|
908 | 942 |
|
909 | 943 | private static void createDatabaseSecret(
|
910 |
| - String secretName, String username, String password, |
| 944 | + String secretName, String username, String password, |
911 | 945 | String dburl, String domNamespace) throws ApiException {
|
912 | 946 | Map<String, String> secretMap = new HashMap();
|
913 | 947 | secretMap.put("username", username);
|
@@ -937,7 +971,7 @@ private static void createDomainSecret(String secretName, String username, Strin
|
937 | 971 |
|
938 | 972 | private static void createDomainResource(
|
939 | 973 | String domainUid, String domNamespace, String adminSecretName,
|
940 |
| - String repoSecretName, String encryptionSecretName, |
| 974 | + String repoSecretName, String encryptionSecretName, |
941 | 975 | int replicaCount, String configmapName, String dbSecretName) {
|
942 | 976 | List<String> securityList = new ArrayList<>();
|
943 | 977 | securityList.add(dbSecretName);
|
|
0 commit comments