Skip to content

Commit e17af4b

Browse files
committed
Merge branch 'openshift-istio-test' into 'release/4.2'
Openshift istio test See merge request weblogic-cloud/weblogic-kubernetes-operator!4958
2 parents 1f655f0 + a4c08d7 commit e17af4b

File tree

5 files changed

+202
-29
lines changed

5 files changed

+202
-29
lines changed

Jenkinsfile.openshift

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
//
55

6-
CRON_SETTINGS = '''H 1 * * * % MAVEN_PROFILE_NAME=wko-okd-wls-srg
7-
H 2 * * * % MAVEN_PROFILE_NAME=wko-okd-wls-mrg
8-
H 3 * * * % MAVEN_PROFILE_NAME=wko-okd-fmw-cert'''
6+
CRON_SETTINGS = '''H 1 * * 0 % MAVEN_PROFILE_NAME=wko-okd-wls-srg
7+
H 3 * * 0 % MAVEN_PROFILE_NAME=wko-okd-wls-mrg
8+
H 5 * * 0 % MAVEN_PROFILE_NAME=wko-okd-fmw-cert'''
99

1010
pipeline {
1111
agent { label 'large' }
@@ -15,7 +15,7 @@ pipeline {
1515
}
1616
triggers {
1717
// timer trigger for "nightly build"
18-
parameterizedCron(env.JOB_NAME == 'wko-release42-nightly-okd' ?
18+
parameterizedCron(env.JOB_NAME == 'openshift-release42-weekly' ?
1919
CRON_SETTINGS : '')
2020
}
2121

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItIstioMiiDomain.java

+70-23
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2025, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes;
@@ -45,6 +45,7 @@
4545
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME;
4646
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG;
4747
import static oracle.weblogic.kubernetes.TestConstants.OCNE;
48+
import static oracle.weblogic.kubernetes.TestConstants.OKD;
4849
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER;
4950
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_SECRET_NAME;
5051
import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
@@ -65,6 +66,7 @@
6566
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withStandardRetryPolicy;
6667
import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.createConfigMapAndVerify;
6768
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
69+
import static oracle.weblogic.kubernetes.utils.ExecCommand.exec;
6870
import static oracle.weblogic.kubernetes.utils.FileUtils.generateFileFromTemplate;
6971
import static oracle.weblogic.kubernetes.utils.FileUtils.replaceStringInFile;
7072
import static oracle.weblogic.kubernetes.utils.ImageUtils.createBaseRepoSecret;
@@ -126,8 +128,19 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
126128
// Label the domain/operator namespace with istio-injection=enabled
127129
Map<String, String> labelMap = new HashMap<>();
128130
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);
131144

132145
// install and verify operator
133146
installAndVerifyOperator(opNamespace, domainNamespace);
@@ -221,33 +234,59 @@ void testIstioModelInImageDomain() throws UnknownHostException, IOException, Int
221234
Path targetHttpFile = assertDoesNotThrow(
222235
() -> generateFileFromTemplate(srcHttpFile.toString(), "istio-http.yaml", templateMap));
223236
logger.info("Generated Http VS/Gateway file path is {0}", targetHttpFile);
237+
if (OKD) {
238+
replaceStringInFile(targetHttpFile.toString(), domainNamespace + ".org", "*");
239+
}
224240

225241
boolean deployRes = assertDoesNotThrow(
226242
() -> deployHttpIstioGatewayAndVirtualservice(targetHttpFile));
227243
assertTrue(deployRes, "Failed to deploy Http Istio Gateway/VirtualService");
228244

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+
}
245267

268+
String hostAndPort = "";
246269
String workManagers = "/management/weblogic/latest/domainConfig/selfTuning/workManagers/";
247270
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();
251290
}
252291

253292
String url = "http://" + hostAndPort + "/management/tenant-monitoring/servers/";
@@ -351,7 +390,15 @@ private static void enableStrictMode(String namespace) {
351390

352391
private void checkApp(String url) {
353392
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+
},
355402
logger,
356403
"application to be ready {0}",
357404
url);

integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/TestActions.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2025, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes.actions;
@@ -750,6 +750,20 @@ public static void addLabelsToNamespace(String name, Map<String, String> labels)
750750
Namespace.addLabelsToNamespace(name, labels);
751751
}
752752

753+
/**
754+
* Add labels to a namespace.
755+
*
756+
* @param name name of the namespace
757+
* @param labels map of labels to add to the namespace
758+
* @param result to return result
759+
* @return if replaced
760+
*/
761+
public static Callable<Boolean> addLabelsToNamespace(String name, Map<String, String> labels, boolean result) {
762+
return (() -> {
763+
return Namespace.addLabelsToNamespace(name, labels, result);
764+
});
765+
}
766+
753767
/**
754768
* Create a namespace with unique name.
755769
*

integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/Namespace.java

+30-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2025, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes.actions.impl;
@@ -94,4 +94,33 @@ public static void addLabelsToNamespace(String name, Map<String, String> labels)
9494
getLogger().severe("Namespace {0} not found or failed to add labels", name);
9595
}
9696
}
97+
98+
/**
99+
* Add labels to a namespace.
100+
*
101+
* @param name name of the namespace
102+
* @param labels map of labels to add to the namespace
103+
* @param result to return the result
104+
* @return if replaced
105+
* @throws ApiException when adding labels to namespace fails
106+
*/
107+
public static boolean addLabelsToNamespace(String name, Map<String, String> labels, boolean result) {
108+
boolean success = false;
109+
try {
110+
V1NamespaceList namespaces = Kubernetes.listNamespacesAsObjects();
111+
if (!namespaces.getItems().isEmpty()) {
112+
for (var ns : namespaces.getItems()) {
113+
if (name.equals(ns.getMetadata().getName())) {
114+
ns.metadata(ns.getMetadata().labels(labels));
115+
Kubernetes.replaceNamespace(ns);
116+
return true;
117+
}
118+
}
119+
getLogger().severe("Namespace {0} not found or failed to add labels", name);
120+
}
121+
} catch (ApiException ex) {
122+
return success;
123+
}
124+
return success;
125+
}
97126
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Copyright (c) 2025, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
apiVersion: v1
5+
kind: Service
6+
metadata:
7+
name: istio-ingressgateway
8+
namespace: NAMESPACE
9+
spec:
10+
type: ClusterIP
11+
selector:
12+
istio: ingressgateway
13+
ports:
14+
- name: http2
15+
port: 80
16+
targetPort: 8080
17+
- name: https
18+
port: 443
19+
targetPort: 8443
20+
---
21+
apiVersion: apps/v1
22+
kind: Deployment
23+
metadata:
24+
name: istio-ingressgateway
25+
namespace: NAMESPACE
26+
spec:
27+
selector:
28+
matchLabels:
29+
istio: ingressgateway
30+
template:
31+
metadata:
32+
annotations:
33+
# Select the gateway injection template (rather than the default sidecar template)
34+
inject.istio.io/templates: gateway
35+
labels:
36+
# Set a unique label for the gateway. This is required to ensure Gateways can select this workload
37+
istio: ingressgateway
38+
# Enable gateway injection. If connecting to a revisioned control plane, replace with "istio.io/rev: revision-name"
39+
sidecar.istio.io/inject: "true"
40+
spec:
41+
containers:
42+
- name: istio-proxy
43+
image: auto # The image will automatically update each time the pod starts.
44+
45+
---
46+
# Set up roles to allow reading credentials for TLS
47+
apiVersion: rbac.authorization.k8s.io/v1
48+
kind: Role
49+
metadata:
50+
name: istio-ingressgateway-sds
51+
namespace: NAMESPACE
52+
rules:
53+
- apiGroups: [""]
54+
resources: ["secrets"]
55+
verbs: ["get", "watch", "list"]
56+
---
57+
apiVersion: rbac.authorization.k8s.io/v1
58+
kind: RoleBinding
59+
metadata:
60+
name: istio-ingressgateway-sds
61+
roleRef:
62+
apiGroup: rbac.authorization.k8s.io
63+
kind: Role
64+
name: istio-ingressgateway-sds
65+
subjects:
66+
- kind: ServiceAccount
67+
name: default
68+
#---
69+
# Allow outside traffic to access the gateway
70+
# This is optional, only needed in case your cluster contains restrictive NetworkPolicies
71+
#apiVersion: networking.k8s.io/v1
72+
#kind: NetworkPolicy
73+
#metadata:
74+
# name: gatewayingress
75+
#spec:
76+
# podSelector:
77+
# matchLabels:
78+
# istio: ingressgateway
79+
# ingress:
80+
# - {}
81+
# policyTypes:
82+
# - Ingress
83+

0 commit comments

Comments
 (0)