Skip to content

Commit 22cc722

Browse files
anpanigrrjeberhard
authored andcommitted
Modify wdt model and py scriprt to verify WLS 14.1.2.0 Image
1 parent a1cd703 commit 22cc722

19 files changed

+97
-154
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItProductionSecureMode.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2024, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes;
@@ -88,7 +88,7 @@
8888
/**
8989
* The test verifies the enablement of ProductionSecureMode in WebLogic Operator
9090
* environment. Make sure all the servers in the domain comes up and WebLogic
91-
* console is accessible thru default-admin NodePort service
91+
* readyapp is accessible thru default-admin NodePort service
9292
* In order to enable ProductionSecureMode in WebLogic Operator environment
9393
* (a) add channel called `default-admin` to domain resource
9494
* (b) JAVA_OPTIONS to -Dweblogic.security.SSL.ignoreHostnameVerification=true
@@ -208,7 +208,7 @@ public void beforeEach() {
208208
* Create a WebLogic domain with ProductionModeEnabled.
209209
* Create a domain resource with a channel with the name `default-admin`.
210210
* Verify a NodePort service is available thru default-admin channel.
211-
* Verify WebLogic console is accessible through the `default-admin` service.
211+
* Verify WebLogic readyapp is accessible through the `default-admin` service.
212212
* Verify no NodePort service is available thru default channel since
213213
* clear text default port (7001) is disabled.
214214
* Check the `default-secure` and `default-admin` port on cluster service.
@@ -241,7 +241,7 @@ void testVerifyProductionSecureMode() {
241241
"Getting Default Admin Cluster Service port failed");
242242
assertEquals(9002, defaultAdminSecurePort, "Default Admin Cluster port is not set to 9002");
243243

244-
//expose the admin server external service to access the console in OKD cluster
244+
//expose the admin server external service to access the readyapp in OKD cluster
245245
//set the sslPort as the target port
246246
adminSvcSslPortExtHost = createRouteForOKD(getExternalServicePodName(adminServerPodName),
247247
domainNamespace, "admin-server-sslport-ext");
@@ -250,33 +250,33 @@ void testVerifyProductionSecureMode() {
250250
String hostAndPort = getHostAndPort(adminSvcSslPortExtHost, defaultAdminPort);
251251
logger.info("The hostAndPort is {0}", hostAndPort);
252252

253-
String resourcePath = "/console/login/LoginForm.jsp";
253+
String resourcePath = "/weblogic/ready";
254254
if (!WEBLOGIC_SLIM) {
255255
if (OKE_CLUSTER) {
256256
ExecResult result = exeAppInServerPod(domainNamespace, adminServerPodName,7002, resourcePath);
257257
logger.info("result in OKE_CLUSTER is {0}", result.toString());
258-
assertEquals(0, result.exitValue(), "Failed to access WebLogic console");
258+
assertEquals(0, result.exitValue(), "Failed to access WebLogic readyapp");
259259
} else {
260260
String curlCmd = "curl -g -sk --show-error --noproxy '*' "
261261
+ " https://" + hostAndPort
262-
+ "/console/login/LoginForm.jsp --write-out %{http_code} "
262+
+ "/weblogic/ready --write-out %{http_code} "
263263
+ " -o /dev/null";
264264
logger.info("Executing default-admin nodeport curl command {0}", curlCmd);
265265
assertTrue(callWebAppAndWaitTillReady(curlCmd, 10));
266266
}
267-
logger.info("WebLogic console is accessible thru default-admin service");
267+
logger.info("WebLogic readyapp is accessible thru default-admin service");
268268

269269
String localhost = "localhost";
270270
String forwardPort = startPortForwardProcess(localhost, domainNamespace, domainUid, 9002);
271271
assertNotNull(forwardPort, "port-forward fails to assign local port");
272272
logger.info("Forwarded admin-port is {0}", forwardPort);
273273
String curlCmd = "curl -sk --show-error --noproxy '*' "
274274
+ " https://" + localhost + ":" + forwardPort
275-
+ "/console/login/LoginForm.jsp --write-out %{http_code} "
275+
+ "/weblogic/ready --write-out %{http_code} "
276276
+ " -o /dev/null";
277277
logger.info("Executing default-admin port-fwd curl command {0}", curlCmd);
278278
assertTrue(callWebAppAndWaitTillReady(curlCmd, 10));
279-
logger.info("WebLogic console is accessible thru admin port forwarding");
279+
logger.info("WebLogic readyapp is accessible thru admin port forwarding");
280280

281281
// When port-forwarding is happening on admin-port, port-forwarding will
282282
// not work for SSL port i.e. 7002
@@ -285,14 +285,14 @@ void testVerifyProductionSecureMode() {
285285
logger.info("Forwarded ssl port is {0}", forwardPort);
286286
curlCmd = "curl -g -sk --show-error --noproxy '*' "
287287
+ " https://" + localhost + ":" + forwardPort
288-
+ "/console/login/LoginForm.jsp --write-out %{http_code} "
288+
+ "/weblogic/ready --write-out %{http_code} "
289289
+ " -o /dev/null";
290290
logger.info("Executing default-admin port-fwd curl command {0}", curlCmd);
291291
assertFalse(callWebAppAndWaitTillReady(curlCmd, 10));
292-
logger.info("WebLogic console should not be accessible thru ssl port forwarding");
292+
logger.info("WebLogic readyapp should not be accessible thru ssl port forwarding");
293293
stopPortForwardProcess(domainNamespace);
294294
} else {
295-
logger.info("Skipping WebLogic console in WebLogic slim image");
295+
logger.info("Skipping WebLogic reeadyapp check in WebLogic slim image");
296296
}
297297

298298
int nodePort = getServiceNodePort(
@@ -345,7 +345,7 @@ void testMiiDynamicChangeWithSSLEnabled() {
345345
if (OKE_CLUSTER) {
346346
ExecResult result = exeAppInServerPod(domainNamespace, managedServerPrefix + "1",9002, resourcePath);
347347
logger.info("result in OKE_CLUSTER is {0}", result.toString());
348-
assertEquals(0, result.exitValue(), "Failed to access WebLogic console");
348+
assertEquals(0, result.exitValue(), "Failed to access WebLogic rest endpoint");
349349
} else {
350350
testUntil(
351351
() -> checkWeblogicMBean(

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/CommonLBTestUtils.java

Lines changed: 31 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
import java.util.Properties;
1818
import java.util.concurrent.TimeUnit;
1919

20-
import com.gargoylesoftware.htmlunit.WebClient;
21-
import com.gargoylesoftware.htmlunit.html.HtmlElement;
22-
import com.gargoylesoftware.htmlunit.html.HtmlForm;
23-
import com.gargoylesoftware.htmlunit.html.HtmlPage;
2420
import io.kubernetes.client.custom.Quantity;
2521
import io.kubernetes.client.openapi.models.V1ConfigMapVolumeSource;
2622
import io.kubernetes.client.openapi.models.V1Container;
@@ -50,8 +46,6 @@
5046
import oracle.weblogic.domain.DomainSpec;
5147
import oracle.weblogic.domain.ServerPod;
5248
import oracle.weblogic.kubernetes.TestConstants;
53-
import oracle.weblogic.kubernetes.actions.impl.primitive.Command;
54-
import oracle.weblogic.kubernetes.actions.impl.primitive.CommandParams;
5549
import oracle.weblogic.kubernetes.logging.LoggingFacade;
5650

5751
import static java.nio.file.Files.copy;
@@ -73,7 +67,6 @@
7367
import static oracle.weblogic.kubernetes.TestConstants.RESULTS_ROOT;
7468
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_INGRESS_HTTP_HOSTPORT;
7569
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TO_USE_IN_SPEC;
76-
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_SLIM;
7770
import static oracle.weblogic.kubernetes.actions.ActionConstants.APP_DIR;
7871
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
7972
import static oracle.weblogic.kubernetes.actions.TestActions.getPodLog;
@@ -445,14 +438,13 @@ private static DomainResource createDomainCustomResource(String domainUid,
445438
*/
446439
private static boolean adminNodePortAccessible(int nodePort)
447440
throws IOException {
448-
if (WEBLOGIC_SLIM) {
449-
getLogger().info("Check REST Console for WebLogic slim image");
450-
StringBuffer curlCmd = new StringBuffer("status=$(curl -g --user ");
451-
String host = K8S_NODEPORT_HOST;
452-
if (host.contains(":")) {
453-
host = "[" + host + "]";
454-
}
455-
curlCmd.append(ADMIN_USERNAME_DEFAULT)
441+
getLogger().info("Check REST Console for WebLogic Image");
442+
StringBuffer curlCmd = new StringBuffer("status=$(curl -g --user ");
443+
String host = K8S_NODEPORT_HOST;
444+
if (host.contains(":")) {
445+
host = "[" + host + "]";
446+
}
447+
curlCmd.append(ADMIN_USERNAME_DEFAULT)
456448
.append(":")
457449
.append(ADMIN_PASSWORD_DEFAULT)
458450
.append(" http://")
@@ -461,72 +453,36 @@ private static boolean adminNodePortAccessible(int nodePort)
461453
.append(nodePort)
462454
.append("/management/tenant-monitoring/servers/ --silent --show-error -o /dev/null -w %{http_code}); ")
463455
.append("echo ${status}");
464-
getLogger().info("checkRestConsole : curl command {0}", new String(curlCmd));
465-
try {
466-
ExecResult result = ExecCommand.exec(new String(curlCmd), true);
467-
String response = result.stdout().trim();
468-
getLogger().info("exitCode: {0}, \nstdout: {1}, \nstderr: {2}",
456+
getLogger().info("checkRestConsole : curl command {0}", new String(curlCmd));
457+
try {
458+
ExecResult result = ExecCommand.exec(new String(curlCmd), true);
459+
String response = result.stdout().trim();
460+
getLogger().info("exitCode: {0}, \nstdout: {1}, \nstderr: {2}",
469461
result.exitValue(), response, result.stderr());
470-
return response.contains("200");
471-
} catch (IOException | InterruptedException ex) {
472-
getLogger().info("Exception in checkRestConsole {0}", ex);
473-
return false;
474-
}
475-
} else {
476-
// generic/dev Image
477-
String host = K8S_NODEPORT_HOST;
478-
if (host.contains(":")) {
479-
host = "[" + host + "]";
480-
}
481-
getLogger().info("Check administration Console for generic/dev image");
482-
String consoleUrl = new StringBuffer()
483-
.append("http://")
484-
.append(host)
485-
.append(":")
486-
.append(nodePort)
487-
.append("/console/login/LoginForm.jsp").toString();
488-
489-
boolean adminAccessible = false;
490-
for (int i = 1; i <= 10; i++) {
491-
getLogger().info("Iteration {0} out of 10: Accessing WebLogic console with url {1}", i, consoleUrl);
492-
final WebClient webClient = new WebClient();
493-
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
494-
final HtmlPage loginPage = assertDoesNotThrow(() -> webClient.getPage(consoleUrl),
495-
"connection to the WebLogic admin console failed");
496-
HtmlForm form = loginPage.getFormByName("loginData");
497-
form.getInputByName("j_username").type(ADMIN_USERNAME_DEFAULT);
498-
form.getInputByName("j_password").type(ADMIN_PASSWORD_DEFAULT);
499-
HtmlElement submit = form.getOneHtmlElementByAttribute("input", "type", "submit");
500-
getLogger().info("Clicking login button");
501-
HtmlPage home = submit.click();
502-
if (home.asNormalizedText().contains("Persistent Stores")) {
503-
getLogger().info("Console login passed");
504-
adminAccessible = true;
505-
break;
506-
}
507-
}
508-
return adminAccessible;
462+
return response.contains("200");
463+
} catch (IOException | InterruptedException ex) {
464+
getLogger().info("Exception in checkRestConsole {0}", ex);
465+
return false;
509466
}
510467
}
511468

512469
/**
513-
* Verify admin console is accessible by login to WebLogic console.
470+
* Verify REST console is accessible by login to WebLogic Server.
514471
*
515472
* @param adminServerPodName admin server pod
516473
* @param adminPort admin port
517474
* @param namespace admin server pod namespace
518475
* @param userName WebLogic administration server user name
519476
* @param password WebLogic administration server password
520-
* @return true if login to WebLogic administration console is successful
477+
* @return true if login to WebLogic REST console is successful
521478
* @throws IOException when connection to console fails
522479
*/
523480
public static boolean adminLoginPageAccessible(String adminServerPodName, String adminPort, String namespace,
524481
String userName, String password)
525482
throws IOException {
526483
LoggingFacade logger = getLogger();
527-
if (WEBLOGIC_SLIM) {
528-
logger.info("Check REST Console for WebLogic slim image");
529-
StringBuffer curlCmd = new StringBuffer(KUBERNETES_CLI + " exec -n "
484+
logger.info("Check REST Console for WebLogic Image");
485+
StringBuffer curlCmd = new StringBuffer(KUBERNETES_CLI + " exec -n "
530486
+ namespace + " " + adminServerPodName)
531487
.append(" -- /bin/bash -c \"")
532488
.append("curl -g --user ")
@@ -535,48 +491,17 @@ public static boolean adminLoginPageAccessible(String adminServerPodName, String
535491
.append(password)
536492
.append(" http://" + adminServerPodName + ":" + adminPort)
537493
.append("/management/tenant-monitoring/servers/ --silent --show-error -o /dev/null -w %{http_code} && ")
538-
.append("echo ${status}");
539-
logger.info("checkRestConsole : curl command {0}", new String(curlCmd));
540-
try {
541-
ExecResult result = ExecCommand.exec(new String(curlCmd), true);
542-
String response = result.stdout().trim();
543-
logger.info("exitCode: {0}, \nstdout: {1}, \nstderr: {2}",
494+
.append("echo ${status}\"");
495+
logger.info("checkRestConsole : k8s exec command {0}", new String(curlCmd));
496+
try {
497+
ExecResult result = ExecCommand.exec(new String(curlCmd), true);
498+
String response = result.stdout().trim();
499+
logger.info("exitCode: {0}, \nstdout: {1}, \nstderr: {2}",
544500
result.exitValue(), response, result.stderr());
545-
return response.contains("200");
546-
} catch (IOException | InterruptedException ex) {
547-
logger.info("Exception in checkRestConsole {0}", ex);
548-
return false;
549-
}
550-
} else {
551-
// generic/dev Image
552-
logger.info("Check administration Console for generic/dev image");
553-
String curlCmd = new StringBuffer(KUBERNETES_CLI + " exec -n "
554-
+ namespace + " " + adminServerPodName)
555-
.append(" -- /bin/bash -c \"")
556-
.append("curl --user ")
557-
.append(userName)
558-
.append(":")
559-
.append(password)
560-
.append(" http://" + adminServerPodName + ":" + adminPort)
561-
.append("/console/login/LoginForm.jsp")
562-
.append("\"").toString();
563-
564-
boolean adminAccessible = false;
565-
String expectedValue = "Oracle WebLogic Server Administration Console";
566-
for (int i = 1; i <= 10; i++) {
567-
logger.info("Iteration {0} out of 10: Accessing WebLogic console ", i);
568-
logger.info("check administration console: curl command {0} expectedValue {1}", curlCmd, expectedValue);
569-
adminAccessible = Command
570-
.withParams(new CommandParams()
571-
.command(curlCmd))
572-
.executeAndVerify(expectedValue);
573-
574-
if (adminAccessible) {
575-
getLogger().info("Console login passed");
576-
break;
577-
}
578-
}
579-
return adminAccessible;
501+
return response.contains("200");
502+
} catch (IOException | InterruptedException ex) {
503+
logger.info("Exception in checkRestConsole {0}", ex);
504+
return false;
580505
}
581506
}
582507

@@ -923,7 +848,7 @@ public static void verifyAdminServerAccess(boolean isTLS,
923848
consoleUrl.append(pathLocation);
924849
}
925850

926-
consoleUrl.append("/console/login/LoginForm.jsp");
851+
consoleUrl.append("/weblogic/ready");
927852
String curlCmd;
928853
if (isHostRouting) {
929854
curlCmd = String.format("curl -g -ks --show-error --noproxy '*' -H 'host: %s' %s",

integration-tests/src/test/resources/python-scripts/sit-config-create-domain.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020, 2021, Oracle and/or its affiliates.
1+
# Copyright (c) 2020, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
import sys
@@ -207,6 +207,11 @@ def create_domain():
207207
cd('/')
208208
if production_mode_enabled == "true":
209209
cmo.setProductionModeEnabled(true)
210+
cd('/SecurityConfiguration/'+domain_name)
211+
secm=create('mySecureMode','SecureMode')
212+
cd('SecureMode/mySecureMode')
213+
set('SecureModeEnabled','false')
214+
#setOption('ServerStartMode', 'prod')
210215
else:
211216
cmo.setProductionModeEnabled(false)
212217
updateDomain()

integration-tests/src/test/resources/python-scripts/wlst-create-domain-onpv.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020, 2021, Oracle and/or its affiliates.
1+
# Copyright (c) 2020, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
import sys
@@ -89,6 +89,11 @@ def create_domain():
8989
cd('/')
9090
if production_mode_enabled == "true":
9191
cmo.setProductionModeEnabled(true)
92+
cd('/SecurityConfiguration/'+domain_name)
93+
secm=create('mySecureMode','SecureMode')
94+
cd('SecureMode/mySecureMode')
95+
set('SecureModeEnabled','false')
96+
#setOption('ServerStartMode', 'prod')
9297
else:
9398
cmo.setProductionModeEnabled(false)
9499
updateDomain()

integration-tests/src/test/resources/python-scripts/wlst-create-istio-domain-onpv.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020, 2021, Oracle and/or its affiliates.
1+
# Copyright (c) 2020, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
import sys
@@ -90,6 +90,11 @@ def create_domain():
9090
cd('/')
9191
if production_mode_enabled == "true":
9292
cmo.setProductionModeEnabled(true)
93+
cd('/SecurityConfiguration/'+domain_name)
94+
secm=create('mySecureMode','SecureMode')
95+
cd('SecureMode/mySecureMode')
96+
set('SecureModeEnabled','false')
97+
#setOption('ServerStartMode', 'prod')
9398
else:
9499
cmo.setProductionModeEnabled(false)
95100
updateDomain()

integration-tests/src/test/resources/wdt-models/coherence-managed-wdt-config.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
# Copyright (c) 2020, 2021, Oracle and/or its affiliates.
1+
# Copyright (c) 2020, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
domainInfo:
55
AdminUserName: '@@PROP:AdminUserName@@'
66
AdminPassword: '@@PROP:AdminPassword@@'
7-
ServerStartMode: 'prod'
87
topology:
98
AdminServerName: 'admin-server'
109
ProductionModeEnabled: true
10+
SecurityConfiguration:
11+
SecureMode:
12+
SecureModeEnabled: false
1113
Log:
1214
FileName: domain1.log
1315
Cluster:

integration-tests/src/test/resources/wdt-models/coherence-wdt-config.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
# Copyright (c) 2020, 2021, Oracle and/or its affiliates.
1+
# Copyright (c) 2020, 2024, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
domainInfo:
55
AdminUserName: '@@PROP:AdminUserName@@'
66
AdminPassword: '@@PROP:AdminPassword@@'
7-
ServerStartMode: 'prod'
87
topology:
98
AdminServerName: 'admin-server'
109
ProductionModeEnabled: true
10+
SecurityConfiguration:
11+
SecureMode:
12+
SecureModeEnabled: false
1113
Log:
1214
FileName: domain1.log
1315
Cluster:

0 commit comments

Comments
 (0)