4444import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_NAME ;
4545import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
4646import static oracle .weblogic .kubernetes .TestConstants .OCNE ;
47+ import static oracle .weblogic .kubernetes .TestConstants .OKD ;
4748import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER ;
4849import static oracle .weblogic .kubernetes .TestConstants .TEST_IMAGES_REPO_SECRET_NAME ;
4950import static oracle .weblogic .kubernetes .actions .ActionConstants .MODEL_DIR ;
6465import static oracle .weblogic .kubernetes .utils .CommonTestUtils .withStandardRetryPolicy ;
6566import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .createConfigMapAndVerify ;
6667import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
68+ import static oracle .weblogic .kubernetes .utils .ExecCommand .exec ;
6769import static oracle .weblogic .kubernetes .utils .FileUtils .generateFileFromTemplate ;
6870import static oracle .weblogic .kubernetes .utils .FileUtils .replaceStringInFile ;
6971import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
8890@ Tag ("kind-parallel" )
8991@ Tag ("olcne-srg" )
9092@ Tag ("oke-parallel" )
93+ @ Tag ("okd-wls-mrg" )
9194class ItIstioMiiDomain {
9295
9396 private static String opNamespace = null ;
@@ -125,8 +128,19 @@ static void initAll(@Namespaces(2) List<String> namespaces) {
125128 // Label the domain/operator namespace with istio-injection=enabled
126129 Map <String , String > labelMap = new HashMap <>();
127130 labelMap .put ("istio-injection" , "enabled" );
128- assertDoesNotThrow (() -> addLabelsToNamespace (domainNamespace ,labelMap ));
129- assertDoesNotThrow (() -> addLabelsToNamespace (opNamespace ,labelMap ));
131+ labelMap .put ("istio-discovery" , "enabled" );
132+ testUntil (
133+ withStandardRetryPolicy ,
134+ addLabelsToNamespace (domainNamespace , labelMap , true ),
135+ logger ,
136+ "adding istio labels to domain namespace {0}" ,
137+ domainNamespace );
138+ testUntil (
139+ withStandardRetryPolicy ,
140+ addLabelsToNamespace (opNamespace , labelMap , true ),
141+ logger ,
142+ "adding istio labels to operator namespace {0}" ,
143+ opNamespace );
130144
131145 // install and verify operator
132146 installAndVerifyOperator (opNamespace , domainNamespace );
@@ -153,7 +167,7 @@ static void initAll(@Namespaces(2) List<String> namespaces) {
153167 @ Test
154168 @ DisplayName ("Create WebLogic Domain with mii model with istio" )
155169 @ Tag ("gate" )
156- void testIstioModelInImageDomain () throws IOException {
170+ void testIstioModelInImageDomain () throws IOException , InterruptedException {
157171
158172 // Create the repo secret to pull the image
159173 // this secret is used only for non-kind cluster
@@ -219,34 +233,60 @@ void testIstioModelInImageDomain() throws IOException {
219233 Path srcHttpFile = Paths .get (RESOURCE_DIR , "istio" , "istio-http-template.yaml" );
220234 Path targetHttpFile = assertDoesNotThrow (
221235 () -> generateFileFromTemplate (srcHttpFile .toString (), "istio-http.yaml" , templateMap ));
222- logger .info ("Generated Http VS/Gateway file path is {0}" , targetHttpFile );
236+ logger .info ("Generated Http VS/Gateway file path is {0}" , targetHttpFile );
237+ if (OKD ) {
238+ replaceStringInFile (targetHttpFile .toString (), domainNamespace + ".org" , "*" );
239+ }
223240
224241 boolean deployRes = assertDoesNotThrow (
225242 () -> deployHttpIstioGatewayAndVirtualservice (targetHttpFile ));
226243 assertTrue (deployRes , "Failed to deploy Http Istio Gateway/VirtualService" );
227244
228- Path srcDrFile = Paths .get (RESOURCE_DIR , "istio" , "istio-dr-template.yaml" );
229- Path targetDrFile = assertDoesNotThrow (
230- () -> generateFileFromTemplate (srcDrFile .toString (), "istio-dr.yaml" , templateMap ));
231- logger .info ("Generated DestinationRule file path is {0}" , targetDrFile );
232-
233- deployRes = assertDoesNotThrow (() -> deployIstioDestinationRule (targetDrFile ));
234- assertTrue (deployRes , "Failed to deploy Istio DestinationRule" );
235-
236- int istioIngressPort = getIstioHttpIngressPort ();
237- String host = formatIPv6Host (K8S_NODEPORT_HOST );
238- logger .info ("Istio Ingress Port is {0}" , istioIngressPort );
239- logger .info ("host {0}" , host );
240-
241- // In internal OKE env, use Istio EXTERNAL-IP; in non-OKE env, use K8S_NODEPORT_HOST + ":" + istioIngressPort
242- String hostAndPort = getServiceExtIPAddrtOke (istioIngressServiceName , istioNamespace ) != null
243- ? getServiceExtIPAddrtOke (istioIngressServiceName , istioNamespace ) : host + ":" + istioIngressPort ;
245+ Path targetDrFile ;
246+ if (!OKD ) {
247+ Path srcDrFile = Paths .get (RESOURCE_DIR , "istio" , "istio-dr-template.yaml" );
248+ targetDrFile = assertDoesNotThrow (
249+ () -> generateFileFromTemplate (srcDrFile .toString (), "istio-dr.yaml" , templateMap ));
250+ logger .info ("Generated DestinationRule file path is {0}" , targetDrFile );
251+
252+ deployRes = assertDoesNotThrow (() -> deployIstioDestinationRule (targetDrFile ));
253+ assertTrue (deployRes , "Failed to deploy Istio DestinationRule" );
254+ } else {
255+ Path srcDrFile = Paths .get (RESOURCE_DIR , "istio" , "openshift-istio-roles-template.yaml" );
256+ targetDrFile = assertDoesNotThrow (
257+ () -> generateFileFromTemplate (srcDrFile .toString (), "openshift-istio-roles.yaml" , templateMap ));
258+ logger .info ("Generated Gateway roles and service file path is {0}" , targetDrFile );
259+
260+ deployRes = assertDoesNotThrow (() -> deployIstioDestinationRule (targetDrFile ));
261+ //assertTrue(deployRes, "Failed to deploy Istio DestinationRule");
262+
263+ String command = "oc expose service istio-ingressgateway -n " + domainNamespace ;
264+ result = exec (command , true );
265+ assertEquals (0 , result .exitValue (), "Failed to expose istio-ingressgateway service" );
266+ }
244267
268+ String hostAndPort = "" ;
245269 String workManagers = "/management/weblogic/latest/domainConfig/selfTuning/workManagers/" ;
246270 String newWM = workManagers + "newWM/" ;
247- if (!TestConstants .WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT ) && !OCNE ) {
248- istioIngressPort = ISTIO_HTTP_HOSTPORT ;
249- hostAndPort = InetAddress .getLocalHost ().getHostAddress () + ":" + istioIngressPort ;
271+
272+ if (!OKD ) {
273+ int istioIngressPort = getIstioHttpIngressPort ();
274+ String host = formatIPv6Host (K8S_NODEPORT_HOST );
275+ logger .info ("Istio Ingress Port is {0}" , istioIngressPort );
276+ logger .info ("host {0}" , host );
277+
278+ // In internal OKE env, use Istio EXTERNAL-IP; in non-OKE env, use K8S_NODEPORT_HOST + ":" + istioIngressPort
279+ hostAndPort = getServiceExtIPAddrtOke (istioIngressServiceName , istioNamespace ) != null
280+ ? getServiceExtIPAddrtOke (istioIngressServiceName , istioNamespace ) : host + ":" + istioIngressPort ;
281+
282+ if (!TestConstants .WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT ) && !OCNE ) {
283+ istioIngressPort = ISTIO_HTTP_HOSTPORT ;
284+ hostAndPort = InetAddress .getLocalHost ().getHostAddress () + ":" + istioIngressPort ;
285+ }
286+ } else {
287+ result = exec ("oc get route istio-ingressgateway -n " + domainNamespace + " -o jsonpath='{.spec.host}'" , true );
288+ assertEquals (0 , result .exitValue (), "Failed to get route" );
289+ hostAndPort = result .stdout ();
250290 }
251291
252292 String url = "http://" + hostAndPort + "/management/tenant-monitoring/servers/" ;
@@ -350,7 +390,15 @@ private static void enableStrictMode(String namespace) {
350390
351391 private void checkApp (String url ) {
352392 testUntil (
353- () -> checkAppUsingHostHeader (url , domainNamespace + ".org" ),
393+ () -> {
394+ if (!OKD ) {
395+ checkAppUsingHostHeader (url , domainNamespace + ".org" );
396+ return true ;
397+ } else {
398+ checkAppUsingHostHeader (url , null );
399+ return true ;
400+ }
401+ },
354402 logger ,
355403 "application to be ready {0}" ,
356404 url );
0 commit comments