3
3
4
4
package oracle .weblogic .kubernetes ;
5
5
6
+ import java .net .InetAddress ;
7
+ import java .net .UnknownHostException ;
6
8
import java .nio .file .Path ;
7
9
import java .nio .file .Paths ;
8
10
import java .util .ArrayList ;
45
47
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_API_VERSION ;
46
48
import static oracle .weblogic .kubernetes .TestConstants .DOMAIN_VERSION ;
47
49
import static oracle .weblogic .kubernetes .TestConstants .IMAGE_PULL_POLICY ;
50
+ import static oracle .weblogic .kubernetes .TestConstants .IT_EXTERNALLB_TUNNELING_HTTPS_CONAINERPORT ;
51
+ import static oracle .weblogic .kubernetes .TestConstants .IT_EXTERNALLB_TUNNELING_HTTPS_HOSTPORT ;
52
+ import static oracle .weblogic .kubernetes .TestConstants .IT_EXTERNALLB_TUNNELING_HTTP_CONAINERPORT ;
53
+ import static oracle .weblogic .kubernetes .TestConstants .IT_EXTERNALLB_TUNNELING_HTTP_HOSTPORT ;
48
54
import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOST ;
49
55
import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOSTNAME ;
50
56
import static oracle .weblogic .kubernetes .TestConstants .KUBERNETES_CLI ;
57
63
import static oracle .weblogic .kubernetes .TestConstants .TRAEFIK_RELEASE_NAME ;
58
64
import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
59
65
import static oracle .weblogic .kubernetes .actions .TestActions .createDomainCustomResource ;
60
- import static oracle .weblogic .kubernetes .actions .TestActions .getServiceNodePort ;
61
66
import static oracle .weblogic .kubernetes .actions .TestActions .getServicePort ;
62
67
import static oracle .weblogic .kubernetes .actions .TestActions .uninstallTraefik ;
63
68
import static oracle .weblogic .kubernetes .assertions .TestAssertions .domainExists ;
64
69
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodReadyAndServiceExists ;
70
+ import static oracle .weblogic .kubernetes .utils .CommonTestUtils .formatIPv6Host ;
65
71
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getHostAndPort ;
66
72
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getNextFreePort ;
67
73
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
@@ -130,6 +136,7 @@ class ItExternalLbTunneling {
130
136
private static Path jksTrustFile ;
131
137
private static String tlsSecretName = domainUid + "-test-tls-secret" ;
132
138
private String clusterSvcRouteHost = null ;
139
+ private static String hostAddress = K8S_NODEPORT_HOST ;
133
140
134
141
/**
135
142
* Install Operator.
@@ -138,9 +145,13 @@ class ItExternalLbTunneling {
138
145
JUnit engine parameter resolution mechanism
139
146
*/
140
147
@ BeforeAll
141
- public static void initAll (@ Namespaces (3 ) List <String > namespaces ) {
148
+ public static void initAll (@ Namespaces (3 ) List <String > namespaces ) throws UnknownHostException {
142
149
logger = getLogger ();
143
150
logger .info ("K8S_NODEPORT_HOSTNAME {0} K8S_NODEPORT_HOST {1}" , K8S_NODEPORT_HOSTNAME , K8S_NODEPORT_HOST );
151
+ if (TestConstants .KIND_CLUSTER
152
+ && !TestConstants .WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
153
+ hostAddress = formatIPv6Host (InetAddress .getLocalHost ().getHostAddress ());
154
+ }
144
155
145
156
// get a new unique opNamespace
146
157
logger .info ("Assigning unique namespace for Operator" );
@@ -177,7 +188,7 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
177
188
// Prepare the config map sparse model file from the template by replacing
178
189
// Public Address of the custom channel with K8S_NODEPORT_HOST
179
190
Map <String , String > configTemplateMap = new HashMap <>();
180
- configTemplateMap .put ("INGRESS_HOST" , K8S_NODEPORT_HOST );
191
+ configTemplateMap .put ("INGRESS_HOST" , hostAddress );
181
192
182
193
Path srcFile = Paths .get (RESOURCE_DIR ,
183
194
"wdt-models" , "tunneling.model.template.yaml" );
@@ -207,11 +218,12 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
207
218
208
219
if (!OKD ) {
209
220
logger .info ("Installing Traefik controller using helm" );
210
- traefikHelmParams = installAndVerifyTraefik (traefikNamespace , 0 , 0 ).getHelmParams ();
221
+ traefikHelmParams = installAndVerifyTraefik (traefikNamespace ,
222
+ IT_EXTERNALLB_TUNNELING_HTTP_CONAINERPORT , IT_EXTERNALLB_TUNNELING_HTTPS_CONAINERPORT ).getHelmParams ();
211
223
}
212
224
213
225
// Create SSL certificate and key using openSSL with SAN extension
214
- createCertKeyFiles (K8S_NODEPORT_HOST );
226
+ createCertKeyFiles (hostAddress );
215
227
// Create kubernates secret using genereated certificate and key
216
228
createSecretWithTLSCertKey (tlsSecretName );
217
229
// Import the tls certificate into a JKS truststote to be used while
@@ -262,7 +274,7 @@ void testExternalRmiAccessThruTraefik() {
262
274
templateMap .put ("DOMAIN_NS" , domainNamespace );
263
275
templateMap .put ("DOMAIN_UID" , domainUid );
264
276
templateMap .put ("CLUSTER" , clusterName );
265
- templateMap .put ("INGRESS_HOST" , K8S_NODEPORT_HOST );
277
+ templateMap .put ("INGRESS_HOST" , hostAddress );
266
278
267
279
Path srcTraefikHttpFile = Paths .get (RESOURCE_DIR ,
268
280
"tunneling" , "traefik.tunneling.template.yaml" );
@@ -281,11 +293,14 @@ void testExternalRmiAccessThruTraefik() {
281
293
282
294
// Get the ingress service nodeport corresponding to non-tls service
283
295
// Get the Traefik Service Name traefik-release-{ns}
284
- String service =
285
- TRAEFIK_RELEASE_NAME + "-" + traefikNamespace .substring (3 );
296
+ String service
297
+ = TRAEFIK_RELEASE_NAME + "-" + traefikNamespace .substring (3 );
286
298
logger .info ("TRAEFIK_SERVICE {0} in {1}" , service , traefikNamespace );
287
- int httpTunnelingPort =
288
- getServiceNodePort (traefikNamespace , service , "web" );
299
+ int httpTunnelingPort = IT_EXTERNALLB_TUNNELING_HTTP_CONAINERPORT ;
300
+ if (TestConstants .KIND_CLUSTER
301
+ && !TestConstants .WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
302
+ httpTunnelingPort = IT_EXTERNALLB_TUNNELING_HTTP_HOSTPORT ;
303
+ }
289
304
assertNotEquals (-1 , httpTunnelingPort ,
290
305
"Could not get the Traefik HttpTunnelingPort service node port" );
291
306
logger .info ("HttpTunnelingPort for Traefik {0}" , httpTunnelingPort );
@@ -320,7 +335,7 @@ void testExternalRmiAccessThruTraefikHttpsTunneling() {
320
335
templateMap .put ("DOMAIN_UID" , domainUid );
321
336
templateMap .put ("CLUSTER" , clusterName );
322
337
templateMap .put ("TLS_CERT" , tlsSecretName );
323
- templateMap .put ("INGRESS_HOST" , K8S_NODEPORT_HOST );
338
+ templateMap .put ("INGRESS_HOST" , hostAddress );
324
339
325
340
Path srcTraefikHttpsFile = Paths .get (RESOURCE_DIR ,
326
341
"tunneling" , "traefik.tls.tunneling.template.yaml" );
@@ -339,11 +354,14 @@ void testExternalRmiAccessThruTraefikHttpsTunneling() {
339
354
340
355
// Get the ingress service nodeport corresponding to tls service
341
356
// Get the Traefik Service Name traefik-release-{ns}
342
- String service =
343
- TRAEFIK_RELEASE_NAME + "-" + traefikNamespace .substring (3 );
357
+ String service
358
+ = TRAEFIK_RELEASE_NAME + "-" + traefikNamespace .substring (3 );
344
359
logger .info ("TRAEFIK_SERVICE {0} in {1}" , service , traefikNamespace );
345
- int httpsTunnelingPort =
346
- getServiceNodePort (traefikNamespace , service , "websecure" );
360
+ int httpsTunnelingPort = IT_EXTERNALLB_TUNNELING_HTTPS_CONAINERPORT ;
361
+ if (TestConstants .KIND_CLUSTER
362
+ && !TestConstants .WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
363
+ httpsTunnelingPort = IT_EXTERNALLB_TUNNELING_HTTPS_HOSTPORT ;
364
+ }
347
365
assertNotEquals (-1 , httpsTunnelingPort ,
348
366
"Could not get the Traefik HttpsTunnelingPort service node port" );
349
367
logger .info ("HttpsTunnelingPort for Traefik {0}" , httpsTunnelingPort );
@@ -441,8 +459,7 @@ private void runExtHttpsClient(String routeHost, int httpsTunnelingPort, int ser
441
459
logger .info ("java command to be run {0}" , javasCmd .toString ());
442
460
443
461
// Note it takes a couples of iterations before the client success
444
- testUntil (
445
- runJmsClient (new String (javasCmd )),
462
+ testUntil (runJmsClient (new String (javasCmd )),
446
463
logger ,
447
464
"Wait for Https JMS Client to access WLS" );
448
465
}
@@ -503,7 +520,7 @@ private void runExtClient(String routeHost, int httpTunnelingPort, int serverCou
503
520
javaCmd .append (String .valueOf (checkConnection ));
504
521
logger .info ("java command to be run {0}" , javaCmd .toString ());
505
522
506
- // Note it takes a couples of iterations before the client success
523
+ // Note it takes a couples of iterations before the client success
507
524
testUntil (runJmsClient (new String (javaCmd )), logger , "Wait for Http JMS Client to access WLS" );
508
525
}
509
526
@@ -604,7 +621,7 @@ public void tearDownAll() {
604
621
private static void createCertKeyFiles (String cn ) {
605
622
606
623
Map <String , String > sanConfigTemplateMap = new HashMap <>();
607
- sanConfigTemplateMap .put ("INGRESS_HOST" , K8S_NODEPORT_HOST );
624
+ sanConfigTemplateMap .put ("INGRESS_HOST" , hostAddress );
608
625
609
626
Path srcFile = Paths .get (RESOURCE_DIR ,
610
627
"tunneling" , "san.config.template.txt" );
0 commit comments