Skip to content

Commit fd7e1c5

Browse files
sankarpnrjeberhard
authored andcommitted
Openshift istio tests in main branch
1 parent 7c6ac75 commit fd7e1c5

File tree

5 files changed

+202
-28
lines changed

5 files changed

+202
-28
lines changed

Jenkinsfile.openshift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
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 2 * * * % MAVEN_PROFILE_NAME=wko-okd-wls-mrg
7-
H 3 * * * % MAVEN_PROFILE_NAME=wko-okd-fmw-cert'''
6+
CRON_SETTINGS = '''H 2 * * 3 % MAVEN_PROFILE_NAME=wko-okd-wls-mrg
7+
H 4 * * 3 % MAVEN_PROFILE_NAME=wko-okd-fmw-cert'''
88

99
pipeline {
1010
agent { label 'large' }
@@ -15,7 +15,7 @@ pipeline {
1515

1616
triggers {
1717
// timer trigger for "nightly build"
18-
parameterizedCron(env.JOB_NAME == 'openshift-dev' ?
18+
parameterizedCron(env.JOB_NAME == 'openshift-main-weekly' ?
1919
CRON_SETTINGS : '')
2020
}
2121

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

Lines changed: 72 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_NAME;
4545
import static oracle.weblogic.kubernetes.TestConstants.MII_BASIC_IMAGE_TAG;
4646
import static oracle.weblogic.kubernetes.TestConstants.OCNE;
47+
import static oracle.weblogic.kubernetes.TestConstants.OKD;
4748
import static oracle.weblogic.kubernetes.TestConstants.OKE_CLUSTER;
4849
import static oracle.weblogic.kubernetes.TestConstants.TEST_IMAGES_REPO_SECRET_NAME;
4950
import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR;
@@ -64,6 +65,7 @@
6465
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.withStandardRetryPolicy;
6566
import static oracle.weblogic.kubernetes.utils.ConfigMapUtils.createConfigMapAndVerify;
6667
import static oracle.weblogic.kubernetes.utils.DomainUtils.createDomainAndVerify;
68+
import static oracle.weblogic.kubernetes.utils.ExecCommand.exec;
6769
import static oracle.weblogic.kubernetes.utils.FileUtils.generateFileFromTemplate;
6870
import static oracle.weblogic.kubernetes.utils.FileUtils.replaceStringInFile;
6971
import static oracle.weblogic.kubernetes.utils.ImageUtils.createBaseRepoSecret;
@@ -88,6 +90,7 @@
8890
@Tag("kind-parallel")
8991
@Tag("olcne-srg")
9092
@Tag("oke-parallel")
93+
@Tag("okd-wls-mrg")
9194
class 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);

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 30 additions & 1 deletion
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+
*/
106+
public static boolean addLabelsToNamespace(String name, Map<String, String> labels, boolean result) {
107+
boolean success = false;
108+
try {
109+
V1NamespaceList namespaces = Kubernetes.listNamespacesAsObjects();
110+
if (!namespaces.getItems().isEmpty()) {
111+
for (var ns : namespaces.getItems()) {
112+
if (name.equals(ns.getMetadata().getName())) {
113+
ns.metadata(ns.getMetadata().labels(labels));
114+
Kubernetes.replaceNamespace(ns);
115+
return true;
116+
}
117+
}
118+
getLogger().severe("Namespace {0} not found or failed to add labels", name);
119+
}
120+
} catch (ApiException ex) {
121+
return success;
122+
}
123+
return success;
124+
}
125+
97126
}
Lines changed: 83 additions & 0 deletions
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)