33
44package oracle .weblogic .kubernetes ;
55
6+
7+ import java .net .InetAddress ;
8+ import java .net .UnknownHostException ;
69import java .nio .file .Path ;
710import java .nio .file .Paths ;
811import java .util .ArrayList ;
2427
2528import static oracle .weblogic .kubernetes .TestConstants .ADMIN_PASSWORD_DEFAULT ;
2629import static oracle .weblogic .kubernetes .TestConstants .ADMIN_USERNAME_DEFAULT ;
30+ import static oracle .weblogic .kubernetes .TestConstants .ISTIO_HTTP_HOSTPORT ;
31+ import static oracle .weblogic .kubernetes .TestConstants .IT_ISTIOMONITORINGEXPORTER_PROM_HTTP_CONAINERPORT ;
32+ import static oracle .weblogic .kubernetes .TestConstants .IT_ISTIOMONITORINGEXPORTER_PROM_HTTP_HOSTPORT ;
2733import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOST ;
34+ import static oracle .weblogic .kubernetes .TestConstants .OCNE ;
2835import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER ;
2936import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER_PRIVATEIP ;
3037import static oracle .weblogic .kubernetes .TestConstants .RESULTS_ROOT ;
3845import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createTestWebAppWarFile ;
3946import static oracle .weblogic .kubernetes .utils .CommonTestUtils .formatIPv6Host ;
4047import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getImageBuilderExtraArgs ;
41- import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getNextFreePort ;
4248import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getServiceExtIPAddrtOke ;
4349import static oracle .weblogic .kubernetes .utils .CommonTestUtils .startPortForwardProcess ;
4450import static oracle .weblogic .kubernetes .utils .CommonTestUtils .stopPortForwardProcess ;
@@ -140,7 +146,7 @@ public static void initAll(@Namespaces(3) List<String> namespaces) {
140146
141147 // install and verify operator
142148 installAndVerifyOperator (opNamespace , domain1Namespace , domain2Namespace );
143- prometheusPort = getNextFreePort () ;
149+ prometheusPort = IT_ISTIOMONITORINGEXPORTER_PROM_HTTP_CONAINERPORT ;
144150 }
145151
146152 /**
@@ -223,6 +229,14 @@ private void deployPrometheusAndVerify(String domainNamespace, String domainUid,
223229 // In internal OKE env, use Istio EXTERNAL-IP; in non-OKE env, use K8S_NODEPORT_HOST + ":" + istioIngressPort
224230 hostPortPrometheus = getServiceExtIPAddrtOke (istioIngressServiceName , istioNamespace ) != null
225231 ? getServiceExtIPAddrtOke (istioIngressServiceName , istioNamespace ) : host + ":" + prometheusPort ;
232+ if (!TestConstants .WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT ) && !OCNE ) {
233+ try {
234+ hostPortPrometheus = InetAddress .getLocalHost ().getHostAddress ()
235+ + ":" + IT_ISTIOMONITORINGEXPORTER_PROM_HTTP_HOSTPORT ;
236+ } catch (UnknownHostException ex ) {
237+ logger .severe (ex .getLocalizedMessage ());
238+ }
239+ }
226240
227241 if (OKE_CLUSTER_PRIVATEIP ) {
228242 String localhost = "localhost" ;
@@ -233,7 +247,6 @@ private void deployPrometheusAndVerify(String domainNamespace, String domainUid,
233247 logger .info ("Forwarded local port is {0}" , forwardPort );
234248 hostPortPrometheus = localhost + ":" + forwardPort ;
235249 isPrometheusPortForward = true ;
236-
237250 }
238251 } else {
239252 String newRegex = String .format ("regex: %s;%s" , domainNamespace , domainUid );
@@ -394,7 +407,17 @@ private void setupIstioModelInImageDomain(String miiImage, String domainNamespac
394407 // In internal OKE env, use Istio EXTERNAL-IP; in non-OKE env, use K8S_NODEPORT_HOST + ":" + istioIngressPort
395408 String hostAndPort = getServiceExtIPAddrtOke (istioIngressServiceName , istioNamespace ) != null
396409 ? getServiceExtIPAddrtOke (istioIngressServiceName , istioNamespace ) : host + ":" + istioIngressPort ;
397-
410+ String deployHost = K8S_NODEPORT_HOST ;
411+
412+ if (!TestConstants .WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT ) && !OCNE ) {
413+ istioIngressPort = ISTIO_HTTP_HOSTPORT ;
414+ try {
415+ hostAndPort = InetAddress .getLocalHost ().getHostAddress () + ":" + istioIngressPort ;
416+ deployHost = InetAddress .getLocalHost ().getHostAddress ();
417+ } catch (UnknownHostException ex ) {
418+ logger .severe (ex .getLocalizedMessage ());
419+ }
420+ }
398421 String readyAppUrl = "http://" + hostAndPort + "/weblogic/ready" ;
399422 boolean checlReadyApp =
400423 checkAppUsingHostHeader (readyAppUrl , domainNamespace + ".org" );
@@ -406,7 +429,7 @@ private void setupIstioModelInImageDomain(String miiImage, String domainNamespac
406429 ExecResult result = OKE_CLUSTER
407430 ? deployUsingRest (hostAndPort , ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT ,
408431 target , archivePath , domainNamespace + ".org" , "testwebapp" )
409- : deployToClusterUsingRest (K8S_NODEPORT_HOST ,
432+ : deployToClusterUsingRest (deployHost ,
410433 String .valueOf (istioIngressPort ),
411434 ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT ,
412435 clusterName , archivePath , domainNamespace + ".org" , "testwebapp" );
0 commit comments