56
56
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
57
57
import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER ;
58
58
import static oracle .weblogic .kubernetes .TestConstants .TEST_IMAGES_REPO_SECRET_NAME ;
59
+ import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_INGRESS_HTTP_HOSTPORT ;
59
60
import static oracle .weblogic .kubernetes .actions .ActionConstants .MODEL_DIR ;
60
61
import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
61
62
import static oracle .weblogic .kubernetes .actions .TestActions .createConfigMap ;
72
73
import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .verifyUpdateWebLogicCredential ;
73
74
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodReadyAndServiceExists ;
74
75
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkServiceExists ;
76
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createIngressHostRouting ;
75
77
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .exeAppInServerPod ;
76
78
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getHostAndPort ;
77
79
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getNextFreePort ;
@@ -128,19 +130,21 @@ class ItMiiUpdateDomainConfig {
128
130
private static final String pvcName = getUniqueName (domainUid + "-pvc-" );
129
131
private StringBuffer curlString = null ;
130
132
private V1Patch patch = null ;
131
- private final String adminServerPodName = domainUid + "-admin-server" ;
133
+ private static final String adminServerPodName = domainUid + "-admin-server" ;
132
134
private final String managedServerPrefix = domainUid + "-managed-server" ;
133
- private final String adminServerName = "admin-server" ;
135
+ private static final String adminServerName = "admin-server" ;
134
136
private final String clusterName = "cluster-1" ;
135
137
private String adminSvcExtHost = null ;
138
+ private static String hostHeader = null ;
136
139
137
140
private static LoggingFacade logger = null ;
138
141
139
142
/**
140
143
* Install Operator.
141
144
* Create domain resource defintion.
145
+ *
142
146
* @param namespaces list of namespaces created by the IntegrationTestWatcher by the
143
- JUnit engine parameter resolution mechanism
147
+ * JUnit engine parameter resolution mechanism
144
148
*/
145
149
@ BeforeAll
146
150
public static void initAll (@ Namespaces (2 ) List <String > namespaces ) {
@@ -167,20 +171,20 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
167
171
String adminSecretName = "weblogic-credentials" ;
168
172
assertDoesNotThrow (() -> createDomainSecret (adminSecretName ,
169
173
ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT , domainNamespace ),
170
- String .format ("createSecret failed for %s" , adminSecretName ));
174
+ String .format ("createSecret failed for %s" , adminSecretName ));
171
175
172
176
// create encryption secret
173
177
logger .info ("Create encryption secret" );
174
178
String encryptionSecretName = "encryptionsecret" ;
175
179
assertDoesNotThrow (() -> createDomainSecret (encryptionSecretName , "weblogicenc" ,
176
180
"weblogicenc" , domainNamespace ),
177
- String .format ("createSecret failed for %s" , encryptionSecretName ));
181
+ String .format ("createSecret failed for %s" , encryptionSecretName ));
178
182
179
183
logger .info ("Create database secret" );
180
- final String dbSecretName = domainUid + "-db-secret" ;
184
+ final String dbSecretName = domainUid + "-db-secret" ;
181
185
assertDoesNotThrow (() -> createDatabaseSecret (dbSecretName , "scott" ,
182
186
"##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 ));
184
188
String configMapName = "jdbc-jms-wldf-configmap" ;
185
189
186
190
createConfigMapAndVerify (
@@ -212,8 +216,17 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
212
216
clusterName , domainNamespace , domain , replicaCount );
213
217
214
218
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
+ }
215
227
}
216
228
229
+
217
230
/**
218
231
* Verify all server pods are running.
219
232
* Verify all k8s services for all servers are created.
@@ -269,12 +282,20 @@ void testMiiCustomEnv() {
269
282
String hostAndPort =
270
283
OKE_CLUSTER ? adminServerPodName + ":7001" : getHostAndPort (adminSvcExtHost , adminServiceNodePort );
271
284
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
+ }
272
292
String curlString = new StringBuffer ()
273
293
.append ("curl -g --user " )
274
294
.append (ADMIN_USERNAME_DEFAULT )
275
295
.append (":" )
276
296
.append (ADMIN_PASSWORD_DEFAULT )
277
297
.append (" " )
298
+ .append (headers )
278
299
.append ("\" http://" + hostAndPort )
279
300
.append ("/management/weblogic/latest/domainConfig" )
280
301
.append ("/JMSServers/TestClusterJmsServer" )
@@ -381,15 +402,15 @@ void testMiiCheckSystemResources() {
381
402
logger .info ("Found the JDBCSystemResource configuration" );
382
403
} else {
383
404
verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
384
- "JDBCSystemResources" , "TestDataSource" , "200" );
405
+ "JDBCSystemResources" , "TestDataSource" , "200" , hostHeader );
385
406
logger .info ("Found the JDBCSystemResource configuration" );
386
407
387
408
verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
388
- "JMSSystemResources" , "TestClusterJmsModule" , "200" );
409
+ "JMSSystemResources" , "TestClusterJmsModule" , "200" , hostHeader );
389
410
logger .info ("Found the JMSSystemResource configuration" );
390
411
391
412
verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
392
- "WLDFSystemResources" , "TestWldfModule" , "200" );
413
+ "WLDFSystemResources" , "TestWldfModule" , "200" , hostHeader );
393
414
logger .info ("Found the WLDFSystemResource configuration" );
394
415
395
416
verifyJdbcRuntime ("TestDataSource" , "jdbc:oracle:thin:localhost" );
@@ -473,9 +494,9 @@ void testMiiDeleteSystemResources() {
473
494
= getServiceNodePort (domainNamespace , getExternalServicePodName (adminServerPodName ), "default" );
474
495
assertNotEquals (-1 , adminServiceNodePort , "admin server default node port is not valid" );
475
496
verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
476
- "JDBCSystemResources" , "TestDataSource" , "404" );
497
+ "JDBCSystemResources" , "TestDataSource" , "404" , hostHeader );
477
498
verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
478
- "JMSSystemResources" , "TestClusterJmsModule" , "404" );
499
+ "JMSSystemResources" , "TestClusterJmsModule" , "404" , hostHeader );
479
500
}
480
501
}
481
502
@@ -556,11 +577,11 @@ void testMiiAddSystemResources() {
556
577
assertNotEquals (-1 , adminServiceNodePort , "admin server default node port is not valid" );
557
578
558
579
verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
559
- "JDBCSystemResources" , "TestDataSource2" , "200" );
580
+ "JDBCSystemResources" , "TestDataSource2" , "200" , hostHeader );
560
581
logger .info ("Found the JDBCSystemResource configuration" );
561
582
562
583
verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
563
- "JMSSystemResources" , "TestClusterJmsModule2" , "200" );
584
+ "JMSSystemResources" , "TestClusterJmsModule2" , "200" , hostHeader );
564
585
logger .info ("Found the JMSSystemResource configuration" );
565
586
}
566
587
@@ -888,9 +909,9 @@ void testMiiDeleteSystemResourcesByEmptyConfigMap() {
888
909
= getServiceNodePort (domainNamespace , getExternalServicePodName (adminServerPodName ), "default" );
889
910
assertNotEquals (-1 , adminServiceNodePort , "admin server default node port is not valid" );
890
911
verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
891
- "JDBCSystemResources" , "TestDataSource" , "404" );
912
+ "JDBCSystemResources" , "TestDataSource" , "404" , hostHeader );
892
913
verifySystemResourceConfiguration (adminSvcExtHost , adminServiceNodePort ,
893
- "JMSSystemResources" , "TestClusterJmsModule" , "404" );
914
+ "JMSSystemResources" , "TestClusterJmsModule" , "404" , hostHeader );
894
915
}
895
916
}
896
917
@@ -1004,11 +1025,20 @@ private void verifyManagedServerConfiguration(String managedServer) {
1004
1025
= getServiceNodePort (domainNamespace , getExternalServicePodName (adminServerPodName ), "default" );
1005
1026
String hostAndPort =
1006
1027
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
+ }
1007
1036
StringBuffer checkClusterBaseCmd = new StringBuffer ("curl -g --user " )
1008
1037
.append (ADMIN_USERNAME_DEFAULT )
1009
1038
.append (":" )
1010
1039
.append (ADMIN_PASSWORD_DEFAULT )
1011
1040
.append (" " )
1041
+ .append (headers )
1012
1042
.append ("http://" + hostAndPort )
1013
1043
.append ("/management/tenant-monitoring/servers/" )
1014
1044
.append (managedServer )
@@ -1064,14 +1094,22 @@ private void createClusterConfigMap(String configMapName, String modelFile) {
1064
1094
private void verifyJdbcRuntime (String resourcesName , String expectedOutput ) {
1065
1095
int adminServiceNodePort
1066
1096
= 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
+ }
1067
1104
1068
1105
ExecResult result = null ;
1069
1106
curlString = new StringBuffer ("curl -g --user " )
1070
1107
.append (ADMIN_USERNAME_DEFAULT )
1071
1108
.append (":" )
1072
1109
.append (ADMIN_PASSWORD_DEFAULT )
1073
1110
.append (" " )
1074
- .append ("http://" + getHostAndPort (adminSvcExtHost , adminServiceNodePort ))
1111
+ .append (headers )
1112
+ .append ("http://" + hostAndPort )
1075
1113
.append ("/management/wls/latest/datasources/id/" )
1076
1114
.append (resourcesName )
1077
1115
.append ("/" )
0 commit comments