|
1 |
| -// Copyright (c) 2020, 2024, Oracle and/or its affiliates. |
| 1 | +// Copyright (c) 2020, 2025, Oracle and/or its affiliates. |
2 | 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
3 | 3 |
|
4 | 4 | package oracle.weblogic.kubernetes;
|
|
45 | 45 | import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME;
|
46 | 46 | import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG;
|
47 | 47 | import static oracle.weblogic.kubernetes.TestConstants.OCNE;
|
| 48 | +import static oracle.weblogic.kubernetes.TestConstants.OKD; |
48 | 49 | import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER;
|
49 | 50 | import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_SECRET_NAME;
|
50 | 51 | import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
|
|
65 | 66 | import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withStandardRetryPolicy;
|
66 | 67 | import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.createConfigMapAndVerify;
|
67 | 68 | import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
|
| 69 | +import static oracle.weblogic.kubernetes.utils.ExecCommand.exec; |
68 | 70 | import static oracle.weblogic.kubernetes.utils.FileUtils.generateFileFromTemplate;
|
69 | 71 | import static oracle.weblogic.kubernetes.utils.FileUtils.replaceStringInFile;
|
70 | 72 | import static oracle.weblogic.kubernetes.utils.ImageUtils.createBaseRepoSecret;
|
@@ -126,8 +128,19 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
|
126 | 128 | // Label the domain/operator namespace with istio-injection=enabled
|
127 | 129 | Map<String, String> labelMap = new HashMap<>();
|
128 | 130 | labelMap.put("istio-injection", "enabled");
|
129 |
| - assertDoesNotThrow(() -> addLabelsToNamespace(domainNamespace,labelMap)); |
130 |
| - 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); |
131 | 144 |
|
132 | 145 | // install and verify operator
|
133 | 146 | installAndVerifyOperator(opNamespace, domainNamespace);
|
@@ -221,33 +234,59 @@ void testIstioModelInImageDomain() throws UnknownHostException, IOException, Int
|
221 | 234 | Path targetHttpFile = assertDoesNotThrow(
|
222 | 235 | () -> generateFileFromTemplate(srcHttpFile.toString(), "istio-http.yaml", templateMap));
|
223 | 236 | logger.info("Generated Http VS/Gateway file path is {0}", targetHttpFile);
|
| 237 | + if (OKD) { |
| 238 | + replaceStringInFile(targetHttpFile.toString(), domainNamespace + ".org", "*"); |
| 239 | + } |
224 | 240 |
|
225 | 241 | boolean deployRes = assertDoesNotThrow(
|
226 | 242 | () -> deployHttpIstioGatewayAndVirtualservice(targetHttpFile));
|
227 | 243 | assertTrue(deployRes, "Failed to deploy Http Istio Gateway/VirtualService");
|
228 | 244 |
|
229 |
| - Path srcDrFile = Paths.get(RESOURCE_DIR, "istio", "istio-dr-template.yaml"); |
230 |
| - Path targetDrFile = assertDoesNotThrow( |
231 |
| - () -> generateFileFromTemplate(srcDrFile.toString(), "istio-dr.yaml", templateMap)); |
232 |
| - logger.info("Generated DestinationRule file path is {0}", targetDrFile); |
233 |
| - |
234 |
| - deployRes = assertDoesNotThrow(() -> deployIstioDestinationRule(targetDrFile)); |
235 |
| - assertTrue(deployRes, "Failed to deploy Istio DestinationRule"); |
236 |
| - |
237 |
| - int istioIngressPort = getIstioHttpIngressPort(); |
238 |
| - String host = formatIPv6Host(K8S_NODEPORT_HOST); |
239 |
| - logger.info("Istio Ingress Port is {0}", istioIngressPort); |
240 |
| - logger.info("host {0}", host); |
241 |
| - |
242 |
| - // In internal OKE env, use Istio EXTERNAL-IP; in non-OKE env, use K8S_NODEPORT_HOST + ":" + istioIngressPort |
243 |
| - String hostAndPort = getServiceExtIPAddrtOke(istioIngressServiceName, istioNamespace) != null |
244 |
| - ? 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 | + } |
245 | 267 |
|
| 268 | + String hostAndPort = ""; |
246 | 269 | String workManagers = "/management/weblogic/latest/domainConfig/selfTuning/workManagers/";
|
247 | 270 | String newWM = workManagers + "newWM/";
|
248 |
| - if (!TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT) && !OCNE) { |
249 |
| - istioIngressPort = ISTIO_HTTP_HOSTPORT; |
250 |
| - 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(); |
251 | 290 | }
|
252 | 291 |
|
253 | 292 | String url = "http://" + hostAndPort + "/management/tenant-monitoring/servers/";
|
@@ -351,7 +390,15 @@ private static void enableStrictMode(String namespace) {
|
351 | 390 |
|
352 | 391 | private void checkApp(String url) {
|
353 | 392 | testUntil(
|
354 |
| - () -> 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 | + }, |
355 | 402 | logger,
|
356 | 403 | "application to be ready {0}",
|
357 | 404 | url);
|
|
0 commit comments