Skip to content

Commit 187725e

Browse files
committed
Merge branch 'owls116014' into 'main'
podman changes in ItMiiUpdateDomainConfig See merge request weblogic-cloud/weblogic-kubernetes-operator!4587
2 parents de27a3f + c042bfe commit 187725e

File tree

2 files changed

+75
-23
lines changed

2 files changed

+75
-23
lines changed

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

Lines changed: 55 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG;
5757
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER;
5858
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_SECRET_NAME;
59+
import static oracle.weblogic.kubernetes.TestConstants.TRAEFIK_INGRESS_HTTP_HOSTPORT;
5960
import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
6061
import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR;
6162
import static oracle.weblogic.kubernetes.actions.TestActions.createConfigMap;
@@ -72,6 +73,7 @@
7273
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.verifyUpdateWebLogicCredential;
7374
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
7475
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
76+
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.createIngressHostRouting;
7577
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.exeAppInServerPod;
7678
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getHostAndPort;
7779
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
@@ -128,19 +130,21 @@ class ItMiiUpdateDomainConfig {
128130
private static final String pvcName = getUniqueName(domainUid + "-pvc-");
129131
private StringBuffer curlString = null;
130132
private V1Patch patch = null;
131-
private final String adminServerPodName = domainUid + "-admin-server";
133+
private static final String adminServerPodName = domainUid + "-admin-server";
132134
private final String managedServerPrefix = domainUid + "-managed-server";
133-
private final String adminServerName = "admin-server";
135+
private static final String adminServerName = "admin-server";
134136
private final String clusterName = "cluster-1";
135137
private String adminSvcExtHost = null;
138+
private static String hostHeader = null;
136139

137140
private static LoggingFacade logger = null;
138141

139142
/**
140143
* Install Operator.
141144
* Create domain resource defintion.
145+
*
142146
* @param namespaces list of namespaces created by the IntegrationTestWatcher by the
143-
JUnit engine parameter resolution mechanism
147+
* JUnit engine parameter resolution mechanism
144148
*/
145149
@BeforeAll
146150
public static void initAll(@Namespaces(2) List<String> namespaces) {
@@ -167,20 +171,20 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
167171
String adminSecretName = "weblogic-credentials";
168172
assertDoesNotThrow(() -> createDomainSecret(adminSecretName,
169173
ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT, domainNamespace),
170-
String.format("createSecret failed for %s", adminSecretName));
174+
String.format("createSecret failed for %s", adminSecretName));
171175

172176
// create encryption secret
173177
logger.info("Create encryption secret");
174178
String encryptionSecretName = "encryptionsecret";
175179
assertDoesNotThrow(() -> createDomainSecret(encryptionSecretName, "weblogicenc",
176180
"weblogicenc", domainNamespace),
177-
String.format("createSecret failed for %s", encryptionSecretName));
181+
String.format("createSecret failed for %s", encryptionSecretName));
178182

179183
logger.info("Create database secret");
180-
final String dbSecretName = domainUid + "-db-secret";
184+
final String dbSecretName = domainUid + "-db-secret";
181185
assertDoesNotThrow(() -> createDatabaseSecret(dbSecretName, "scott",
182186
"##W%*}!\"'\"`']\\\\//1$$~x", "jdbc:oracle:thin:localhost:/ORCLCDB", domainNamespace),
183-
String.format("createSecret failed for %s", dbSecretName));
187+
String.format("createSecret failed for %s", dbSecretName));
184188
String configMapName = "jdbc-jms-wldf-configmap";
185189

186190
createConfigMapAndVerify(
@@ -212,8 +216,17 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
212216
clusterName, domainNamespace, domain, replicaCount);
213217

214218
createDomainAndVerify(domain, domainNamespace);
219+
// verify the admin server service and pod created
220+
checkPodReadyAndServiceExists(adminServerPodName, domainUid, domainNamespace);
221+
222+
// create ingress for admin service
223+
if (TestConstants.KIND_CLUSTER
224+
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
225+
hostHeader = createIngressHostRouting(domainNamespace, domainUid, adminServerName, 7001);
226+
}
215227
}
216228

229+
217230
/**
218231
* Verify all server pods are running.
219232
* Verify all k8s services for all servers are created.
@@ -269,12 +282,20 @@ void testMiiCustomEnv() {
269282
String hostAndPort =
270283
OKE_CLUSTER ? adminServerPodName + ":7001" : getHostAndPort(adminSvcExtHost, adminServiceNodePort);
271284

285+
// use traefik LB for kind cluster with ingress host header in url
286+
String headers = "";
287+
if (TestConstants.KIND_CLUSTER
288+
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
289+
hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT;
290+
headers = " -H 'host: " + hostHeader + "' ";
291+
}
272292
String curlString = new StringBuffer()
273293
.append("curl -g --user ")
274294
.append(ADMIN_USERNAME_DEFAULT)
275295
.append(":")
276296
.append(ADMIN_PASSWORD_DEFAULT)
277297
.append(" ")
298+
.append(headers)
278299
.append("\"http://" + hostAndPort)
279300
.append("/management/weblogic/latest/domainConfig")
280301
.append("/JMSServers/TestClusterJmsServer")
@@ -381,15 +402,15 @@ void testMiiCheckSystemResources() {
381402
logger.info("Found the JDBCSystemResource configuration");
382403
} else {
383404
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
384-
"JDBCSystemResources", "TestDataSource", "200");
405+
"JDBCSystemResources", "TestDataSource", "200", hostHeader);
385406
logger.info("Found the JDBCSystemResource configuration");
386407

387408
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
388-
"JMSSystemResources", "TestClusterJmsModule", "200");
409+
"JMSSystemResources", "TestClusterJmsModule", "200", hostHeader);
389410
logger.info("Found the JMSSystemResource configuration");
390411

391412
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
392-
"WLDFSystemResources", "TestWldfModule", "200");
413+
"WLDFSystemResources", "TestWldfModule", "200", hostHeader);
393414
logger.info("Found the WLDFSystemResource configuration");
394415

395416
verifyJdbcRuntime("TestDataSource", "jdbc:oracle:thin:localhost");
@@ -473,9 +494,9 @@ void testMiiDeleteSystemResources() {
473494
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
474495
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
475496
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
476-
"JDBCSystemResources", "TestDataSource", "404");
497+
"JDBCSystemResources", "TestDataSource", "404", hostHeader);
477498
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
478-
"JMSSystemResources", "TestClusterJmsModule", "404");
499+
"JMSSystemResources", "TestClusterJmsModule", "404", hostHeader);
479500
}
480501
}
481502

@@ -556,11 +577,11 @@ void testMiiAddSystemResources() {
556577
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
557578

558579
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
559-
"JDBCSystemResources", "TestDataSource2", "200");
580+
"JDBCSystemResources", "TestDataSource2", "200", hostHeader);
560581
logger.info("Found the JDBCSystemResource configuration");
561582

562583
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
563-
"JMSSystemResources", "TestClusterJmsModule2", "200");
584+
"JMSSystemResources", "TestClusterJmsModule2", "200", hostHeader);
564585
logger.info("Found the JMSSystemResource configuration");
565586
}
566587

@@ -888,9 +909,9 @@ void testMiiDeleteSystemResourcesByEmptyConfigMap() {
888909
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
889910
assertNotEquals(-1, adminServiceNodePort, "admin server default node port is not valid");
890911
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
891-
"JDBCSystemResources", "TestDataSource", "404");
912+
"JDBCSystemResources", "TestDataSource", "404", hostHeader);
892913
verifySystemResourceConfiguration(adminSvcExtHost, adminServiceNodePort,
893-
"JMSSystemResources", "TestClusterJmsModule", "404");
914+
"JMSSystemResources", "TestClusterJmsModule", "404", hostHeader);
894915
}
895916
}
896917

@@ -1004,11 +1025,20 @@ private void verifyManagedServerConfiguration(String managedServer) {
10041025
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
10051026
String hostAndPort =
10061027
OKE_CLUSTER ? adminServerPodName + ":7001" : getHostAndPort(adminSvcExtHost, adminServiceNodePort);
1028+
1029+
// use traefik LB for kind cluster with ingress host header in url
1030+
String headers = "";
1031+
if (TestConstants.KIND_CLUSTER
1032+
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
1033+
hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT;
1034+
headers = " -H 'host: " + hostHeader + "' ";
1035+
}
10071036
StringBuffer checkClusterBaseCmd = new StringBuffer("curl -g --user ")
10081037
.append(ADMIN_USERNAME_DEFAULT)
10091038
.append(":")
10101039
.append(ADMIN_PASSWORD_DEFAULT)
10111040
.append(" ")
1041+
.append(headers)
10121042
.append("http://" + hostAndPort)
10131043
.append("/management/tenant-monitoring/servers/")
10141044
.append(managedServer)
@@ -1064,14 +1094,22 @@ private void createClusterConfigMap(String configMapName, String modelFile) {
10641094
private void verifyJdbcRuntime(String resourcesName, String expectedOutput) {
10651095
int adminServiceNodePort
10661096
= getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default");
1097+
String hostAndPort = getHostAndPort(adminSvcExtHost, adminServiceNodePort);
1098+
String headers = "";
1099+
if (TestConstants.KIND_CLUSTER
1100+
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
1101+
hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT;
1102+
headers = " -H 'host: " + hostHeader + "' ";
1103+
}
10671104

10681105
ExecResult result = null;
10691106
curlString = new StringBuffer("curl -g --user ")
10701107
.append(ADMIN_USERNAME_DEFAULT)
10711108
.append(":")
10721109
.append(ADMIN_PASSWORD_DEFAULT)
10731110
.append(" ")
1074-
.append("http://" + getHostAndPort(adminSvcExtHost, adminServiceNodePort))
1111+
.append(headers)
1112+
.append("http://" + hostAndPort)
10751113
.append("/management/wls/latest/datasources/id/")
10761114
.append(resourcesName)
10771115
.append("/")

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

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -759,18 +759,32 @@ public static boolean checkSystemResourceConfiguration(String adminServerPodName
759759

760760
/**
761761
* verify the system resource configuration using REST API.
762-
* @param adminRouteHost only required for OKD env. null otherwise
763-
* @param nodePort admin node port
764-
* @param resourcesType type of the resource
765-
* @param resourcesName name of the resource
762+
*
763+
* @param adminRouteHost only required for OKD env. null otherwise
764+
* @param nodePort admin node port
765+
* @param resourcesType type of the resource
766+
* @param resourcesName name of the resource
766767
* @param expectedStatusCode expected status code
768+
* @param hostHeader ingress host name to pass as header, only for kind cluster
767769
*/
768770
public static void verifySystemResourceConfiguration(String adminRouteHost, int nodePort, String resourcesType,
769-
String resourcesName, String expectedStatusCode) {
771+
String resourcesName, String expectedStatusCode, String hostHeader) {
770772
final LoggingFacade logger = getLogger();
773+
774+
String hostAndPort = getHostAndPort(adminRouteHost, nodePort);
775+
776+
// use traefik LB for kind cluster with ingress host header in url
777+
String headers = "";
778+
if (TestConstants.KIND_CLUSTER
779+
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
780+
hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT;
781+
headers = " -H 'host: " + hostHeader + "' ";
782+
}
771783
StringBuffer curlString = new StringBuffer("status=$(curl --user ");
772784
curlString.append(ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT)
773-
.append(" http://" + getHostAndPort(adminRouteHost, nodePort))
785+
.append(" ")
786+
.append(headers)
787+
.append(" http://" + hostAndPort)
774788
.append("/management/weblogic/latest/domainConfig")
775789
.append("/")
776790
.append(resourcesType)

0 commit comments

Comments
 (0)