Skip to content

Commit 3dffa8d

Browse files
anpanigrANTARYAMI.PANIGRAHI@ORACLE.COMANTARYAMI.PANIGRAHI@ORACLE.COM
authored
Integration Test : Default ListenPort assignment in sever template (#2309)
* Integration Test : Default ListenPort assignment in sever template Co-authored-by: [email protected] <[email protected]> Co-authored-by: [email protected] <[email protected]>
1 parent 835d6ac commit 3dffa8d

15 files changed

+97
-30
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public void testDomainIntrospectVersionNotRolling() {
227227

228228
final String managedServerNameBase = "managed-server";
229229
String managedServerPodNamePrefix = domainUid + "-" + managedServerNameBase;
230-
final int managedServerPort = 8001;
230+
final int managedServerPort = 7100;
231231

232232
int replicaCount = 2;
233233

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
* This test class verifies usage of CustomIdentityCustomTrust on PV.
5656
* Create a MII domain with an attached persistent volume.
5757
* Configure custom identity and custom trust on server template
58-
* Enable SSL on server template with port 8002 (default 7002 does not work)
58+
* Donot set the SSL port on server template. The default will be set to 8100.
5959
* Put the IdentityKeyStore.jks and TrustKeyStore.jks on /shared directory
6060
* after administration server pod is started so that it can be accessible
6161
* from all managed server pods
@@ -224,6 +224,6 @@ private void runClientOnAdminPod() {
224224
condition.getElapsedTimeInMS(),
225225
condition.getRemainingTimeInMS()))
226226
.until(runClientInsidePod(adminServerPodName, domainNamespace,
227-
"/u01", extOpts.toString() + " SslTestClient", "t3s://" + domainUid + "-cluster-cluster-1:8002"));
227+
"/u01", extOpts.toString() + " SslTestClient", "t3s://" + domainUid + "-cluster-cluster-1:8100"));
228228
}
229229
}

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

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import static oracle.weblogic.kubernetes.actions.ActionConstants.WORK_DIR;
5454
import static oracle.weblogic.kubernetes.actions.TestActions.createDomainCustomResource;
5555
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
56+
import static oracle.weblogic.kubernetes.actions.TestActions.getServicePort;
5657
import static oracle.weblogic.kubernetes.actions.TestActions.patchDomainResourceWithNewIntrospectVersion;
5758
import static oracle.weblogic.kubernetes.assertions.TestAssertions.domainExists;
5859
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.checkWeblogicMBean;
@@ -72,6 +73,7 @@
7273
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
7374
import static org.awaitility.Awaitility.with;
7475
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
76+
import static org.junit.jupiter.api.Assertions.assertEquals;
7577
import static org.junit.jupiter.api.Assertions.assertNotNull;
7678
import static org.junit.jupiter.api.Assertions.assertTrue;
7779

@@ -151,9 +153,10 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
151153
+ " SecureModeEnabled: true \n"
152154
+ " ServerTemplate: \n"
153155
+ " \"cluster-1-template\": \n"
156+
+ " ListenPort: '7001' \n"
154157
+ " SSL: \n"
155158
+ " Enabled: true \n"
156-
+ " ListenPort: '7003' \n";
159+
+ " ListenPort: '7002' \n";
157160

158161
assertDoesNotThrow(() -> Files.write(pathToEnableSSLYaml, yamlString.getBytes()));
159162
createConfigMapAndVerify(configMapName, domainUid, domainNamespace, Arrays.asList(pathToEnableSSLYaml.toString()));
@@ -200,20 +203,37 @@ public void beforeEach() {
200203
* Verify WebLogic console is accessible through the `default-admin` service.
201204
* Verify no NodePort service is available thru default channel since
202205
* clear text default port (7001) is disabled.
206+
* Check the `default-secure` and `default-admin` port on cluster service.
203207
*/
204208
@Test
205209
@Order(1)
206210
@DisplayName("Verify the secure service through administration port")
207211
public void testVerifyProductionSecureMode() {
208-
int sslNodePort = getServiceNodePort(
212+
int defaultAdminPort = getServiceNodePort(
209213
domainNamespace, getExternalServicePodName(adminServerPodName), "default-admin");
210-
assertTrue(sslNodePort != -1,
214+
assertTrue(defaultAdminPort != -1,
211215
"Could not get the default-admin external service node port");
212-
logger.info("Found the administration service nodePort {0}", sslNodePort);
216+
logger.info("Found the administration service nodePort {0}", defaultAdminPort);
217+
218+
// Here the SSL port is explicitly set to 7002 (on-prem default) in
219+
// in ServerTemplate section on topology file. Here the generated
220+
// config.xml has no SSL port assigned, but the default-secure service i
221+
// must be active with port 7002
222+
int defaultClusterSecurePort = assertDoesNotThrow(()
223+
-> getServicePort(domainNamespace,
224+
domainUid + "-cluster-cluster-1", "default-secure"),
225+
"Getting Default Secure Cluster Service port failed");
226+
assertEquals(7002, defaultClusterSecurePort, "Default Secure Cluster port is not set to 7002");
227+
228+
int defaultAdminSecurePort = assertDoesNotThrow(()
229+
-> getServicePort(domainNamespace,
230+
domainUid + "-cluster-cluster-1", "default-admin"),
231+
"Getting Default Admin Cluster Service port failed");
232+
assertEquals(9002, defaultAdminSecurePort, "Default Admin Cluster port is not set to 9002");
213233

214234
if (!WEBLOGIC_SLIM) {
215235
String curlCmd = "curl -sk --show-error --noproxy '*' "
216-
+ " https://" + K8S_NODEPORT_HOST + ":" + sslNodePort
236+
+ " https://" + K8S_NODEPORT_HOST + ":" + defaultAdminPort
217237
+ "/console/login/LoginForm.jsp --write-out %{http_code} "
218238
+ " -o /dev/null";
219239
logger.info("Executing default-admin nodeport curl command {0}", curlCmd);

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ class ItSessionMigration {
9595
private static String adminServerPodName = domainUid + "-" + ADMIN_SERVER_NAME_BASE;
9696
private static String managedServerPrefix = domainUid + "-" + MANAGED_SERVER_NAME_BASE;
9797
private static String finalPrimaryServerName = null;
98-
private static int managedServerPort = 8001;
98+
// Since the ServerTemplate section of the model file model.sessmigr.yaml
99+
// does not explicitly specify ListenPort, the introspector/wdt generated
100+
// default ListenPort for each dynamic server is set to 7100
101+
private static int managedServerPort = 7100;
99102
private static int replicaCount = 2;
100103
private static String opNamespace = null;
101104
private static String domainNamespace = null;

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@
4545
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_SERVER_NAME_BASE;
4646
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
4747
import static oracle.weblogic.kubernetes.TestConstants.BASE_IMAGES_REPO_SECRET;
48+
import static oracle.weblogic.kubernetes.TestConstants.DEFAULT_LISTEN_PORT;
4849
import static oracle.weblogic.kubernetes.TestConstants.DOMAIN_API_VERSION;
4950
import static oracle.weblogic.kubernetes.TestConstants.K8S_NODEPORT_HOST;
5051
import static oracle.weblogic.kubernetes.TestConstants.MANAGED_SERVER_NAME_BASE;
5152
import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_IMAGE_TO_USE_IN_SPEC;
5253
import static oracle.weblogic.kubernetes.actions.ActionConstants.APP_DIR;
5354
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
5455
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
56+
import static oracle.weblogic.kubernetes.actions.TestActions.getServicePort;
5557
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
5658
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createConfigMapForDomainCreation;
5759
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createDomainAndVerify;
@@ -119,6 +121,8 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
119121
* Test t3 channel access by deploying a app using WLST.
120122
* Test Creates a domain in persistent volume using WLST.
121123
* Verifies that the pods comes up and sample application deployment works.
124+
* Verify the default service port is set to 7100 since ListenPort is not
125+
* explicitly set on WLST offline script to create the domain configuration.
122126
*/
123127
@Test
124128
@DisplayName("Test admin server t3 channel access by deploying a application")
@@ -290,6 +294,28 @@ public void testAdminServerT3Channel() {
290294

291295
//verify admin server accessibility and the health of cluster members
292296
verifyMemberHealth(adminServerPodName, managedServerNames, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT);
297+
298+
// Since the ListenPort is not set explicitly on ServerTemplate
299+
// in wlst offline script wlst-create-domain-onpv.py, the default
300+
// ListenPort on each manged server is set to 7100. This can be confirmed
301+
// by intorospecting the corresponding cluster service port (default)
302+
int servicePort = assertDoesNotThrow(()
303+
-> getServicePort(domainNamespace,
304+
domainUid + "-cluster-" + clusterName, "default"),
305+
"Getting Cluster Service default port failed");
306+
assertEquals(DEFAULT_LISTEN_PORT, servicePort, "Default Service Port is not set to 7100");
307+
int napPort = assertDoesNotThrow(()
308+
-> getServicePort(domainNamespace,
309+
domainUid + "-cluster-" + clusterName, "ms-nap"),
310+
"Getting Cluster Service nap port failed");
311+
assertEquals(8011, napPort, "Nap Service Port is not set to 8011");
312+
313+
servicePort = assertDoesNotThrow(()
314+
-> getServicePort(domainNamespace,
315+
domainUid + "-managed-server1", "default"),
316+
"Getting Managed Server Service default port failed");
317+
assertEquals(DEFAULT_LISTEN_PORT, servicePort, "Default Managed Service Port is not 7100");
318+
293319
}
294320

295321
private static void verifyMemberHealth(String adminServerPodName, List<String> managedServerNames,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public class ItTwoDomainsLoadBalancers {
212212
// domain constants
213213
private final String clusterName = "cluster-1";
214214
private final int replicaCount = 2;
215-
private static final int MANAGED_SERVER_PORT = 8001;
215+
private static final int MANAGED_SERVER_PORT = 7100;
216216
private static final int ADMIN_SERVER_PORT = 7001;
217217

218218
private int t3ChannelPort = 0;
@@ -425,7 +425,7 @@ public void testDeployAppAndInstallIngressControllers() {
425425

426426
// install and verify Apache for default sample
427427
apacheHelmParams1 = assertDoesNotThrow(
428-
() -> installAndVerifyApache(domain1Namespace, kindRepoApacheImage, 0, 0, domain1Uid));
428+
() -> installAndVerifyApache(domain1Namespace, kindRepoApacheImage, 0, 0, MANAGED_SERVER_PORT, domain1Uid));
429429

430430
// install and verify Apache for custom sample
431431
LinkedHashMap<String, String> clusterNamePortMap = new LinkedHashMap<>();
@@ -434,7 +434,7 @@ public void testDeployAppAndInstallIngressControllers() {
434434
}
435435
createPVPVCForApacheCustomConfiguration(defaultNamespace);
436436
apacheHelmParams2 = assertDoesNotThrow(
437-
() -> installAndVerifyApache(defaultNamespace, kindRepoApacheImage, 0, 0, domain1Uid,
437+
() -> installAndVerifyApache(defaultNamespace, kindRepoApacheImage, 0, 0, MANAGED_SERVER_PORT, domain1Uid,
438438
apachePvcName, "apache-sample-host", ADMIN_SERVER_PORT, clusterNamePortMap));
439439
}
440440

@@ -540,7 +540,7 @@ public void testTraefikHttpHostRoutingAcrossDomains() {
540540
@Order(9)
541541
@Test
542542
@DisplayName("Verify Traefik host routing with HTTPS protocol across two domains")
543-
public void testTraefikHostHttpsRoutingAcrossDomains() {
543+
public void testTraefikHttpsHostRoutingAcrossDomains() {
544544

545545
logger.info("Verifying Traefik host routing with HTTPS protocol across two domains");
546546
for (String domainUid : domainUids) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,10 @@ public interface TestConstants {
185185
.orElse("v1.3.3-debian-elasticsearch-1.3");
186186
public static final String ELASTICSEARCH_IMAGE = ELASTICSEARCH_NAME + ":" + ELK_STACK_VERSION;
187187
public static final String ELASTICSEARCH_HOST = "elasticsearch.default.svc.cluster.local";
188+
public static final int DEFAULT_LISTEN_PORT = 7100;
188189
public static final int ELASTICSEARCH_HTTP_PORT = 9200;
189190
public static final int ELASTICSEARCH_HTTPS_PORT = 9300;
191+
public static final int DEFAULT_SSL_LISTEN_PORT = 8100;
190192
public static final String ELKSTACK_NAMESPACE = "default";
191193
public static final String LOGSTASH_INDEX_KEY = "logstash";
192194
public static final String FLUENTD_INDEX_KEY = "fluentd";

integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/ApacheParams.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class ApacheParams {
2222
private static final String PVC_NAME = "persistentVolumeClaimName";
2323
private static final String HTTP_NODEPORT = "httpNodePort";
2424
private static final String HTTPS_NODEPORT = "httpsNodePort";
25+
private static final String MANAGED_SERVER_PORT = "managedServerPort";
2526
private static final String VIRTUAL_HOSTNAME = "virtualHostName";
2627
private static final String CUSTOM_CERT = "customCert";
2728
private static final String CUSTOM_KEY = "customKey";
@@ -33,6 +34,7 @@ public class ApacheParams {
3334
private String pvcName = null;
3435
private int httpNodePort = 0;
3536
private int httpsNodePort = 0;
37+
private int managedServerPort = 0;
3638
private String virtualHostName = null;
3739
private String customCert = null;
3840
private String customKey = null;
@@ -69,6 +71,11 @@ public ApacheParams httpsNodePort(int httpsNodePort) {
6971
return this;
7072
}
7173

74+
public ApacheParams managedServerPort(int managedServerPort) {
75+
this.managedServerPort = managedServerPort;
76+
return this;
77+
}
78+
7279
public ApacheParams virtualHostName(String virtualHostName) {
7380
this.virtualHostName = virtualHostName;
7481
return this;
@@ -117,6 +124,9 @@ public Map<String, Object> getValues() {
117124
if (httpsNodePort >= 0) {
118125
values.put(HTTPS_NODEPORT, httpsNodePort);
119126
}
127+
if (managedServerPort >= 0) {
128+
values.put(MANAGED_SERVER_PORT, managedServerPort);
129+
}
120130

121131
values.put(VIRTUAL_HOSTNAME, virtualHostName);
122132
values.put(CUSTOM_CERT, customCert);

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,15 +813,17 @@ public static HelmParams installAndVerifyVoyager(String voyagerNamespace,
813813
* @param image the image name of Apache webtier
814814
* @param httpNodePort the http nodeport of Apache
815815
* @param httpsNodePort the https nodeport of Apache
816+
* @param managedServerPort the listenport of each managed server in cluster
816817
* @param domainUid the uid of the domain to which Apache will route the services
817818
* @return the Apache Helm installation parameters
818819
*/
819820
public static HelmParams installAndVerifyApache(String apacheNamespace,
820821
String image,
821822
int httpNodePort,
822823
int httpsNodePort,
824+
int managedServerPort,
823825
String domainUid) throws IOException {
824-
return installAndVerifyApache(apacheNamespace, image, httpNodePort, httpsNodePort, domainUid,
826+
return installAndVerifyApache(apacheNamespace, image, httpNodePort, httpsNodePort, managedServerPort, domainUid,
825827
null, null, 0, null);
826828
}
827829

@@ -832,6 +834,7 @@ public static HelmParams installAndVerifyApache(String apacheNamespace,
832834
* @param image the image name of Apache webtier
833835
* @param httpNodePort the http nodeport of Apache
834836
* @param httpsNodePort the https nodeport of Apache
837+
* @param managedServerPort the listenport of each managed server in cluster
835838
* @param domainUid the uid of the domain to which Apache will route the services
836839
* @param pvcName name of the Persistent Volume Claim which contains your own custom_mod_wl_apache.conf file
837840
* @param virtualHostName the VirtualHostName of the Apache HTTP server which is used to enable custom SSL config
@@ -843,6 +846,7 @@ public static HelmParams installAndVerifyApache(String apacheNamespace,
843846
String image,
844847
int httpNodePort,
845848
int httpsNodePort,
849+
int managedServerPort,
846850
String domainUid,
847851
String pvcName,
848852
String virtualHostName,
@@ -882,6 +886,9 @@ public static HelmParams installAndVerifyApache(String apacheNamespace,
882886
.httpNodePort(httpNodePort)
883887
.httpsNodePort(httpsNodePort);
884888
}
889+
if (managedServerPort >= 0) {
890+
apacheParams.managedServerPort(managedServerPort);
891+
}
885892

886893
if (pvcName != null && clusterNamePortMap != null) {
887894
// create a custom Apache plugin configuration file named custom_mod_wl_apache.conf

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ private static V1Pod setupPVPod(String namespace, String pvcName, String pvName)
347347
.containers(Arrays.asList(
348348
new V1Container()
349349
.name("pv-container")
350-
.image("oraclelinux:7")
350+
.image("ghcr.io/oracle/oraclelinux:7")
351351
.imagePullPolicy("IfNotPresent")
352352
.volumeMounts(Arrays.asList(
353353
new V1VolumeMount()

0 commit comments

Comments
 (0)