44
44
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_NAME ;
45
45
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
46
46
import static oracle .weblogic .kubernetes .TestConstants .OCNE ;
47
+ import static oracle .weblogic .kubernetes .TestConstants .OKD ;
47
48
import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER ;
48
49
import static oracle .weblogic .kubernetes .TestConstants .TEST_IMAGES_REPO_SECRET_NAME ;
49
50
import static oracle .weblogic .kubernetes .actions .ActionConstants .MODEL_DIR ;
64
65
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .withStandardRetryPolicy ;
65
66
import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .createConfigMapAndVerify ;
66
67
import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
68
+ import static oracle .weblogic .kubernetes .utils .ExecCommand .exec ;
67
69
import static oracle .weblogic .kubernetes .utils .FileUtils .generateFileFromTemplate ;
68
70
import static oracle .weblogic .kubernetes .utils .FileUtils .replaceStringInFile ;
69
71
import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
88
90
@ Tag ("kind-parallel" )
89
91
@ Tag ("olcne-srg" )
90
92
@ Tag ("oke-parallel" )
93
+ @ Tag ("okd-wls-mrg" )
91
94
class ItIstioMiiDomain {
92
95
93
96
private static String opNamespace = null ;
@@ -125,8 +128,19 @@ static void initAll(@Namespaces(2) List<String> namespaces) {
125
128
// Label the domain/operator namespace with istio-injection=enabled
126
129
Map <String , String > labelMap = new HashMap <>();
127
130
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 );
130
144
131
145
// install and verify operator
132
146
installAndVerifyOperator (opNamespace , domainNamespace );
@@ -153,7 +167,7 @@ static void initAll(@Namespaces(2) List<String> namespaces) {
153
167
@ Test
154
168
@ DisplayName ("Create WebLogic Domain with mii model with istio" )
155
169
@ Tag ("gate" )
156
- void testIstioModelInImageDomain () throws IOException {
170
+ void testIstioModelInImageDomain () throws IOException , InterruptedException {
157
171
158
172
// Create the repo secret to pull the image
159
173
// this secret is used only for non-kind cluster
@@ -219,34 +233,60 @@ void testIstioModelInImageDomain() throws IOException {
219
233
Path srcHttpFile = Paths .get (RESOURCE_DIR , "istio" , "istio-http-template.yaml" );
220
234
Path targetHttpFile = assertDoesNotThrow (
221
235
() -> 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
+ }
223
240
224
241
boolean deployRes = assertDoesNotThrow (
225
242
() -> deployHttpIstioGatewayAndVirtualservice (targetHttpFile ));
226
243
assertTrue (deployRes , "Failed to deploy Http Istio Gateway/VirtualService" );
227
244
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
+ }
244
267
268
+ String hostAndPort = "" ;
245
269
String workManagers = "/management/weblogic/latest/domainConfig/selfTuning/workManagers/" ;
246
270
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 ();
250
290
}
251
291
252
292
String url = "http://" + hostAndPort + "/management/tenant-monitoring/servers/" ;
@@ -350,7 +390,15 @@ private static void enableStrictMode(String namespace) {
350
390
351
391
private void checkApp (String url ) {
352
392
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
+ },
354
402
logger ,
355
403
"application to be ready {0}" ,
356
404
url );
0 commit comments