|
1 | | -// Copyright (c) 2023, Oracle and/or its affiliates. |
| 1 | +// Copyright (c) 2023, 2024, Oracle and/or its affiliates. |
2 | 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. |
3 | 3 |
|
4 | 4 | package oracle.weblogic.kubernetes; |
|
7 | 7 | import java.util.Collections; |
8 | 8 | import java.util.List; |
9 | 9 |
|
| 10 | +import oracle.weblogic.kubernetes.actions.impl.primitive.Command; |
| 11 | +import oracle.weblogic.kubernetes.actions.impl.primitive.CommandParams; |
10 | 12 | import oracle.weblogic.kubernetes.annotations.IntegrationTest; |
11 | 13 | import oracle.weblogic.kubernetes.annotations.Namespaces; |
12 | 14 | import oracle.weblogic.kubernetes.logging.LoggingFacade; |
|
16 | 18 | import org.junit.jupiter.api.Tag; |
17 | 19 | import org.junit.jupiter.api.Test; |
18 | 20 |
|
| 21 | +import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT; |
| 22 | +import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT; |
| 23 | +import static oracle.weblogic.kubernetes.TestConstants.KIND_CLUSTER; |
| 24 | +import static oracle.weblogic.kubernetes.TestConstants.KUBERNETES_CLI; |
19 | 25 | import static oracle.weblogic.kubernetes.TestConstants.MANAGED_SERVER_NAME_BASE; |
20 | 26 | import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_APP_NAME; |
21 | 27 | import static oracle.weblogic.kubernetes.TestConstants.OPERATOR_RELEASE_NAME; |
| 28 | +import static oracle.weblogic.kubernetes.TestConstants.WLSIMG_BUILDER; |
| 29 | +import static oracle.weblogic.kubernetes.TestConstants.WLSIMG_BUILDER_DEFAULT; |
22 | 30 | import static oracle.weblogic.kubernetes.actions.TestActions.deleteClusterCustomResource; |
23 | 31 | import static oracle.weblogic.kubernetes.actions.TestActions.getOperatorPodName; |
24 | 32 | import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort; |
@@ -69,6 +77,7 @@ class ItWDTModelNoServer { |
69 | 77 | private static final String MII_IMAGE_NAME = "wdtmodelnoserver-mii"; |
70 | 78 | private static final int replicaCount = 2; |
71 | 79 | private static final String internalPort = "8001"; |
| 80 | + private static final int ADMIN_SERVER_PORT = 7001; |
72 | 81 | private static final String appPath = "sample-war/index.jsp"; |
73 | 82 | private static final String clusterName = "cluster-1"; |
74 | 83 |
|
@@ -532,9 +541,37 @@ private void checkAdminServerName(String adminServerPodName, String expectedAdmi |
532 | 541 | int adminServiceNodePort |
533 | 542 | = getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default"); |
534 | 543 | assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid"); |
535 | | - assertTrue(checkSystemResourceDomainConfig(adminSvcExtHost, adminServiceNodePort, |
536 | | - "\"adminServerName\": \"" + expectedAdminServerName + "\""), |
537 | | - "Admin server name is not '" + expectedAdminServerName + "'"); |
| 544 | + if (KIND_CLUSTER && !WLSIMG_BUILDER.equals(WLSIMG_BUILDER_DEFAULT)) { |
| 545 | + assertTrue(checkSystemResourceConfigViaAdminPod(adminServerPodName, |
| 546 | + "\"adminServerName\": \"" + expectedAdminServerName + "\""), |
| 547 | + "Admin server name is not '" + expectedAdminServerName + "'"); |
| 548 | + } else { |
| 549 | + assertTrue(checkSystemResourceDomainConfig(adminSvcExtHost, adminServiceNodePort, |
| 550 | + "\"adminServerName\": \"" + expectedAdminServerName + "\""), |
| 551 | + "Admin server name is not '" + expectedAdminServerName + "'"); |
| 552 | + } |
538 | 553 | logger.info("AdminServerName is {0}", expectedAdminServerName); |
539 | 554 | } |
| 555 | + |
| 556 | + private boolean checkSystemResourceConfigViaAdminPod(String adminServerPodName, |
| 557 | + String expectedValue) { |
| 558 | + final LoggingFacade logger = getLogger(); |
| 559 | + |
| 560 | + StringBuffer curlString = new StringBuffer(KUBERNETES_CLI + " exec -n " |
| 561 | + + domainNamespace + " " + adminServerPodName) |
| 562 | + .append(" -- /bin/bash -c \"") |
| 563 | + .append("curl -g --user ") |
| 564 | + .append(ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT) |
| 565 | + .append(" http://" + adminServerPodName + ":" + ADMIN_SERVER_PORT) |
| 566 | + .append("/management/weblogic/latest/domainConfig") |
| 567 | + .append("/") |
| 568 | + .append(" \""); |
| 569 | + |
| 570 | + logger.info("checkSystemResource: curl command {0}", new String(curlString)); |
| 571 | + return Command |
| 572 | + .withParams(new CommandParams() |
| 573 | + .command(curlString.toString())) |
| 574 | + .executeAndVerify(expectedValue); |
| 575 | + } |
| 576 | + |
540 | 577 | } |
0 commit comments