Skip to content

Commit abd1107

Browse files
committed
Merge branch 'develop' into owls-69919-domain-resource-properties
Conflicts: kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/domain-custom-resource-template.yaml
2 parents b967e4d + 98d5034 commit abd1107

File tree

32 files changed

+694
-175
lines changed

32 files changed

+694
-175
lines changed

integration-tests/src/test/java/oracle/kubernetes/operator/ITOperator.java

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ public class ITOperator extends BaseTest {
5454
private static Operator operatorForDel1;
5555
private static Operator operatorForDel2;
5656

57+
private static boolean QUICKTEST;
58+
private static boolean SMOKETEST;
59+
60+
// Set QUICKTEST env var to true to run a small subset of tests.
61+
// Set SMOKETEST env var to true to run an even smaller subset
62+
// of tests, plus leave domain1 up and running when the test completes.
63+
static {
64+
QUICKTEST =
65+
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true");
66+
SMOKETEST =
67+
System.getenv("SMOKETEST") != null && System.getenv("SMOKETEST").equalsIgnoreCase("true");
68+
if (SMOKETEST) QUICKTEST = true;
69+
}
70+
5771
/**
5872
* This method gets called only once before any of the test methods are executed. It does the
5973
* initialization of the integration test properties defined in OperatorIT.properties and setting
@@ -103,16 +117,15 @@ public void test1CreateFirstOperatorAndDomain() throws Exception {
103117
logTestBegin("test1CreateFirstOperatorAndDomain");
104118
testCreateOperatorManagingDefaultAndTest1NS();
105119
Domain domain1 = testAllUseCasesForADomain(operator1, domain1YamlFile);
106-
domain1.testWlsLivenessProbe();
107-
domain1.shutdownUsingServerStartPolicy();
120+
if (!SMOKETEST) domain1.testWlsLivenessProbe();
121+
if (!SMOKETEST) domain1.shutdownUsingServerStartPolicy();
108122

109123
logger.info("SUCCESS - test1CreateFirstOperatorAndDomain");
110124
}
111125

112126
@Test
113127
public void test2CreateAnotherDomainInDefaultNS() throws Exception {
114-
Assume.assumeFalse(
115-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
128+
Assume.assumeFalse(QUICKTEST);
116129

117130
logTestBegin("test2CreateAnotherDomainInDefaultNS");
118131
logger.info("Creating Domain domain2 & verifing the domain creation");
@@ -129,8 +142,7 @@ public void test2CreateAnotherDomainInDefaultNS() throws Exception {
129142

130143
@Test
131144
public void test3CreateDomainInTest1NS() throws Exception {
132-
Assume.assumeFalse(
133-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
145+
Assume.assumeFalse(QUICKTEST);
134146

135147
logTestBegin("test3CreateDomainInTest1NS");
136148
logger.info("Creating Domain domain3 & verifing the domain creation");
@@ -146,8 +158,7 @@ public void test3CreateDomainInTest1NS() throws Exception {
146158

147159
@Test
148160
public void test4CreateAnotherOperatorManagingTest2NS() throws Exception {
149-
Assume.assumeFalse(
150-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
161+
Assume.assumeFalse(QUICKTEST);
151162

152163
logTestBegin("test4CreateAnotherOperatorManagingTest2NS");
153164
logger.info("Creating Operator & waiting for the script to complete execution");
@@ -158,8 +169,7 @@ public void test4CreateAnotherOperatorManagingTest2NS() throws Exception {
158169

159170
@Test
160171
public void test5CreateConfiguredDomainInTest2NS() throws Exception {
161-
Assume.assumeFalse(
162-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
172+
Assume.assumeFalse(QUICKTEST);
163173

164174
logTestBegin("test5CreateConfiguredDomainInTest2NS");
165175
logger.info("Creating Domain domain4 & verifing the domain creation");
@@ -198,8 +208,7 @@ public void test5CreateConfiguredDomainInTest2NS() throws Exception {
198208

199209
@Test
200210
public void test6CreateDomainWithStartPolicyAdminOnly() throws Exception {
201-
Assume.assumeFalse(
202-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
211+
Assume.assumeFalse(QUICKTEST);
203212

204213
logTestBegin("test6CreateDomainWithStartPolicyAdminOnly");
205214
logger.info("Checking if operator1 is running, if not creating");
@@ -215,8 +224,7 @@ public void test6CreateDomainWithStartPolicyAdminOnly() throws Exception {
215224

216225
@Test
217226
public void test7CreateDomainPVReclaimPolicyRecycle() throws Exception {
218-
Assume.assumeFalse(
219-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
227+
Assume.assumeFalse(QUICKTEST);
220228

221229
logTestBegin("test7CreateDomainPVReclaimPolicyRecycle");
222230
logger.info("Checking if operator1 is running, if not creating");
@@ -233,8 +241,7 @@ public void test7CreateDomainPVReclaimPolicyRecycle() throws Exception {
233241

234242
@Test
235243
public void test8CreateDomainOnExistingDir() throws Exception {
236-
Assume.assumeFalse(
237-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
244+
Assume.assumeFalse(QUICKTEST);
238245

239246
logTestBegin("test8CreateDomainOnExistingDir");
240247
if (operator1 == null) {
@@ -251,8 +258,8 @@ public void test8CreateDomainOnExistingDir() throws Exception {
251258

252259
// @Test
253260
public void testACreateDomainApacheLB() throws Exception {
254-
Assume.assumeFalse(
255-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
261+
Assume.assumeFalse(QUICKTEST);
262+
256263
logTestBegin("testACreateDomainApacheLB");
257264
logger.info("Creating Domain domain9 & verifing the domain creation");
258265
if (operator1 == null) {
@@ -268,8 +275,8 @@ public void testACreateDomainApacheLB() throws Exception {
268275

269276
@Test
270277
public void testBCreateDomainWithDefaultValuesInSampleInputs() throws Exception {
271-
Assume.assumeFalse(
272-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
278+
Assume.assumeFalse(QUICKTEST);
279+
273280
logTestBegin("testBCreateDomainWithDefaultValuesInSampleInputs");
274281
logger.info("Creating Domain domain10 & verifing the domain creation");
275282
if (operator1 == null) {
@@ -284,8 +291,7 @@ public void testBCreateDomainWithDefaultValuesInSampleInputs() throws Exception
284291

285292
@Test
286293
public void testDeleteOneDomain() throws Exception {
287-
Assume.assumeFalse(
288-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
294+
Assume.assumeFalse(QUICKTEST);
289295
logTestBegin("Deleting one domain.");
290296

291297
if (operatorForDel1 == null) {
@@ -303,8 +309,7 @@ public void testDeleteOneDomain() throws Exception {
303309

304310
@Test
305311
public void testDeleteTwoDomains() throws Exception {
306-
Assume.assumeFalse(
307-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
312+
Assume.assumeFalse(QUICKTEST);
308313
logTestBegin("Deleting two domains.");
309314

310315
if (operatorForDel2 == null) {
@@ -337,9 +342,11 @@ private Domain testAllUseCasesForADomain(Operator operator, String domainYamlFil
337342
logger.info("Creating Domain & verifing the domain creation");
338343
// create domain1
339344
Domain domain = testDomainCreation(domainYamlFile);
340-
testClusterScaling(operator, domain);
341-
testDomainLifecyle(operator, domain);
342-
testOperatorLifecycle(operator, domain);
345+
if (!SMOKETEST) {
346+
testClusterScaling(operator, domain);
347+
testDomainLifecyle(operator, domain);
348+
testOperatorLifecycle(operator, domain);
349+
}
343350
return domain;
344351
}
345352

integration-tests/src/test/java/oracle/kubernetes/operator/utils/TestUtils.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ public static void createRBACPoliciesForWLDFScaling() throws Exception {
728728
public static void deleteWeblogicDomainResources(String domainUid) throws Exception {
729729
StringBuilder cmd =
730730
new StringBuilder(BaseTest.getProjectRoot())
731-
.append("/kubernetes/delete-weblogic-domain-resources.sh ")
731+
.append("/kubernetes/samples/scripts/delete-weblogic-domain-resources.sh ")
732732
.append("-d ")
733733
.append(domainUid);
734734
logger.info("Running " + cmd);
@@ -763,7 +763,6 @@ public static void verifyBeforeDeletion(Domain domain) throws Exception {
763763
k8sTestUtils.verifyNoReplicaSets(domain1LabelSelector);
764764
k8sTestUtils.verifyServices(domain1LabelSelector, 5);
765765
k8sTestUtils.verifyPvcs(domain1LabelSelector, 1);
766-
k8sTestUtils.verifyIngresses(domainNs, domainUid, domain1LabelSelector, 1);
767766
k8sTestUtils.verifyConfigMaps(domain1LabelSelector, 1);
768767
k8sTestUtils.verifyNoServiceAccounts(domain1LabelSelector);
769768
k8sTestUtils.verifyNoRoles(domain1LabelSelector);
@@ -790,7 +789,6 @@ public static void verifyAfterDeletion(Domain domain) throws Exception {
790789
k8sTestUtils.verifyNoReplicaSets(domain1LabelSelector);
791790
k8sTestUtils.verifyServices(domain1LabelSelector, 0);
792791
k8sTestUtils.verifyPvcs(domain1LabelSelector, 0);
793-
k8sTestUtils.verifyIngresses(domainNs, domainUid, domain1LabelSelector, 0);
794792
k8sTestUtils.verifyConfigMaps(domain1LabelSelector, 0);
795793
k8sTestUtils.verifyNoServiceAccounts(domain1LabelSelector);
796794
k8sTestUtils.verifyNoRoles(domain1LabelSelector);

kubernetes/charts/weblogic-operator/templates/_operator-dep.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ spec:
4040
- name: "REMOTE_DEBUG_PORT"
4141
value: {{ .internalDebugHttpPort | quote }}
4242
{{- end }}
43+
{{- if .mockWLS }}
44+
- name: "MOCK_WLS"
45+
value: "true"
46+
{{- end }}
4347
volumeMounts:
4448
- name: "weblogic-operator-cm-volume"
4549
mountPath: "/operator/config"

kubernetes/charts/weblogic-operator/templates/_validate-inputs.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
{{- end -}}
3636
{{- $ignore := include "utils.verifyString" (list $scope "tillerNamespace") -}}
3737
{{- $ignore := include "utils.verifyString" (list $scope "tillerServiceAccount") -}}
38+
{{- $ignore := include "utils.verifyOptionalBoolean" (list $scope "mockWLS") -}}
3839
{{- $ignore:= include "utils.endValidation" $scope -}}
3940
{{- include "operator.operatorVerificationHook" (list $scope "pre-upgrade") }}
4041
{{- include "operator.operatorVerificationHook" (list $scope "pre-install") }}

kubernetes/samples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Sample scripts
44

5+
* [Sample Secret for WebLogic Amin Credentials](scripts/create-weblogic-domain/create-weblogic-credentials.sh) for creating a Kubernetes secret that contains the admin server credentials. This secret can then be used in creating a WebLogic domain custom resource.
56
* [Sample PV and PVC](scripts/create-weblogic-domain-pv-pvc/README.md) for creating a PV or PVC that can be used by a domain custom resource as the persistent storage for the WebLogic domain home or log files.
67
* [Sample domain home on a persistent volume](scripts/create-weblogic-domain/domain-home-on-pv/README.md) for creating a WebLogic domain home on an existing PV or PVC, and the domain customer resource YAML file for deploying the generated WebLogic domain.
78
* [Sample Elasticsearch and Kibana configuration](scripts/elasticsearch_and_kibana.yaml) for configuring the Elasticsearch and Kibana deployments and services for the operator's logs.

kubernetes/samples/charts/README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
Weblogic operator supports three types load balancers: TRAEFIK, VOYAGER, APACHE. We provide samples for each type to demostrate how to install and configure load balancer. Samples are located in following folders:
2-
traefik
3-
voyager
4-
ingress-per-domain
5-
apache-samples
6-
Note: apache-webtier is helm chart. It is used in apache-samples.
1+
# WebLogic Operator Load Balancer Samples
2+
3+
## Load balancer sample scripts
4+
5+
The Oracle WebLogic Server Kubernetes Operator supports three load balancers: TRAEFIK, VOYAGER, and APACHE. We provide samples that demonstrate how to install and configure each one. The samples are located in following folders:
6+
7+
* [traefik](traefik/README.md)
8+
* [voyager](voyager/README.md)
9+
* [apache-samples](apache-samples/README.md)
10+
* [ingress-per-domain](ingress-per-domain/README.md)
11+
* [apache-webtier](apache-webtier/README.md)
12+
13+
**Note**: The apache-webtier script contains a Helm chart that is used in the Apache samples.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
4+
#
5+
# Description
6+
# This sample script creates a Kubernetes secret for WebLogic domain admin credentials.
7+
#
8+
# The following pre-requisites must be handled prior to running this script:
9+
# * The kubernetes namespace must already be created
10+
#
11+
12+
script="${BASH_SOURCE[0]}"
13+
14+
#
15+
# Function to exit and print an error message
16+
# $1 - text of message
17+
function fail {
18+
echo [ERROR] $*
19+
exit 1
20+
}
21+
22+
# Try to execute kubectl to see whether kubectl is available
23+
function validateKubectlAvailable {
24+
if ! [ -x "$(command -v kubectl)" ]; then
25+
fail "kubectl is not installed"
26+
fi
27+
}
28+
29+
function usage {
30+
echo usage: ${script} -u username -p password [-d domainUID] [-n namespace] [-h]
31+
echo " -u username, must be specified."
32+
echo " -p password, must be specified."
33+
echo " -n namespace, optional."
34+
echo " -d domainUID, optional."
35+
echo " -h Help"
36+
exit $1
37+
}
38+
39+
#
40+
# Parse the command line options
41+
#
42+
domainUID=domain1
43+
namespace=default
44+
while getopts "hu:p:n:d:" opt; do
45+
case $opt in
46+
u) username="${OPTARG}"
47+
;;
48+
p) password="${OPTARG}"
49+
;;
50+
n) namespace="${OPTARG}"
51+
;;
52+
d) domainUID="${OPTARG}"
53+
;;
54+
h) usage 0
55+
;;
56+
*) usage 1
57+
;;
58+
esac
59+
done
60+
secretName=$domainUID-weblogic-credentials
61+
62+
if [ -z ${username} ]; then
63+
echo "${script}: -u must be specified."
64+
missingRequiredOption="true"
65+
fi
66+
67+
if [ -z ${password} ]; then
68+
echo "${script}: -p must be specified."
69+
missingRequiredOption="true"
70+
fi
71+
72+
if [ "${missingRequiredOption}" == "true" ]; then
73+
usage 1
74+
fi
75+
76+
# check and see if the secret already exists
77+
result=`kubectl get secret ${secretName} -n ${namespace} --ignore-not-found=true | grep ${secretName} | wc | awk ' { print $1; }'`
78+
if [ "${result:=Error}" != "0" ]; then
79+
fail "The secret ${secretName} already exists in namespace ${namespace}."
80+
fi
81+
82+
# create the secret
83+
kubectl -n $namespace create secret generic $secretName \
84+
--from-literal=username=$username \
85+
--from-literal=password=$password
86+
87+
# label the secret with domainUID
88+
kubectl label secret ${secretName} -n $namespace weblogic.domainUID=$domainUID weblogic.domainName=$domainUID
89+
90+
# Verify the secret exists
91+
SECRET=`kubectl get secret ${secretName} -n ${namespace} | grep ${secretName} | wc | awk ' { print $1; }'`
92+
if [ "${SECRET}" != "1" ]; then
93+
fail "The secret ${secretName} was not found in namespace ${namespace}"
94+
fi
95+
96+
echo "The secret ${secretName} has been successfully created in namespace ${namespace}"

kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/domain-custom-resource-template.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright 2017, 2018, Oracle Corporation and/or its affiliates. All rights reserved.
2+
23
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
34
#
45
# This is an example of how to define a Domain Custom Resource.
@@ -8,6 +9,10 @@ kind: Domain
89
metadata:
910
name: %DOMAIN_UID%
1011
namespace: %NAMESPACE%
12+
labels:
13+
weblogic.resourceVersion: domain-v2
14+
weblogic.domainUID: %DOMAIN_UID%
15+
weblogic.domainName: %DOMAIN_NAME%
1116
spec:
1217
# The domainUID must be unique across the entire Kubernetes Cluster. Each WebLogic Domain must
1318
# have its own unique domainUID. This does not have to be the same as the Domain Name. It is allowed
@@ -18,7 +23,7 @@ spec:
1823
domainName: %DOMAIN_NAME%
1924
# The WebLogic Domain Home
2025
domainHome: %DOMAIN_HOME%
21-
# The domain home is in a PV, not in the image
26+
# If the domain home is in the image
2227
domainHomeInImage: false
2328
# The Operator currently does not support other images
2429
image: "%WEBLOGIC_IMAGE%"

0 commit comments

Comments
 (0)