Skip to content

Commit 3476689

Browse files
committed
Merge branch 'develop' of https://github.com/oracle/weblogic-kubernetes-operator into wsapp
2 parents 2a8c527 + 799c65b commit 3476689

File tree

105 files changed

+1917
-1214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+1917
-1214
lines changed

docs-source/content/developerguide/building.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ $ docker build --build-arg VERSION=<version> -t weblogic-kubernetes-operator:som
4343

4444
Replace `<version>` with the version of the project found in the `pom.xml` file in the project root directory.
4545

46-
{{% notice note %}}
47-
If you have not used the base image (`store/oracle/serverjre:8`) before, you will need to visit the [Docker Store web interface](https://store.docker.com/images/oracle-serverjre-8) and accept the license agreement before the Docker Store will give you permission to pull that image.
48-
{{% /notice %}}
49-
5046
We recommend that you use a tag other than `latest`, to make it easy to distinguish your image. In the example above, the tag could be the GitHub ID of the developer.
5147

5248
#### Running the operator from an IDE

integration-tests/USECASES.MD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ Basic Use Cases described above are verified in all the domain configurations. A
7373
| Server pods restarted by changing imagePullPolicy | Verify admin and managed server pods being restarted by property change: imagePullPolicy: IfNotPresent --> imagePullPolicy: Never |
7474
| Server pods restarted by changing includeServerOutInPodLog | Verify admin and managed server pods being restarted by property change: includeServerOutInPodLog: true --> includeServerOutInPodLog: false |
7575
| Server pods restarted by changing logHomeEnable | Verify admin and managed server pods being restarted by property change: logHomeEnabled: true --> logHomeEnabled: false |
76+
| Server pods restarted by changing containerSecurityContext | Verify admin and managed server pods being restarted by adding property change: containerSecurityContext: runAsUser: 1000 fsGroup: 2000 |
77+
| Server pods restarted by changing podSecurityContex | Verify admin and managed server pods being restarted by adding property change: podSecurityContext: runAsUser: 1000 fsGroup: 2000 |
78+
| Server pods restarted by changing resources | Verify admin and managed server pods being restarted by adding property change: resources: limits: cpu: "1" requests: cpu: "0.5" args: - -cpus - "2" |
7679

7780
Configuration Overrides Usecases
7881

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

Lines changed: 128 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
package oracle.kubernetes.operator;
66

7+
import java.nio.file.Files;
8+
import java.nio.file.Paths;
79
import java.util.Map;
810
import oracle.kubernetes.operator.utils.Domain;
911
import oracle.kubernetes.operator.utils.Operator;
@@ -26,6 +28,7 @@ public class ITPodsRestart extends BaseTest {
2628

2729
private static Domain domain = null;
2830
private static Operator operator1;
31+
private static String domainUid = "";
2932

3033
/**
3134
* This method gets called only once before any of the test methods are executed. It does the
@@ -84,10 +87,10 @@ public void testServerPodsRestartByChangingEnvProperty() throws Exception {
8487
logTestBegin(testMethodName);
8588

8689
logger.info(
87-
"About to testDomainServerPodRestart for Domain: "
90+
"About to verifyDomainServerPodRestart for Domain: "
8891
+ domain.getDomainUid()
8992
+ " env property: StdoutDebugEnabled=false to StdoutDebugEnabled=true");
90-
domain.testDomainServerPodRestart(
93+
domain.verifyDomainServerPodRestart(
9194
"\"-Dweblogic.StdoutDebugEnabled=false\"", "\"-Dweblogic.StdoutDebugEnabled=true\"");
9295

9396
logger.info("SUCCESS - " + testMethodName);
@@ -107,10 +110,10 @@ public void testServerPodsRestartByChangingLogHomeEnabled() throws Exception {
107110
logTestBegin(testMethodName);
108111

109112
logger.info(
110-
"About to testDomainServerPodRestart for Domain: "
113+
"About to verifyDomainServerPodRestart for Domain: "
111114
+ domain.getDomainUid()
112115
+ " logHomeEnabled: true --> logHomeEnabled: false");
113-
domain.testDomainServerPodRestart("logHomeEnabled: true", "logHomeEnabled: false");
116+
domain.verifyDomainServerPodRestart("logHomeEnabled: true", "logHomeEnabled: false");
114117

115118
logger.info("SUCCESS - " + testMethodName);
116119
}
@@ -129,10 +132,10 @@ public void testServerPodsRestartByChangingImagePullPolicy() throws Exception {
129132
logTestBegin(testMethodName);
130133

131134
logger.info(
132-
"About to testDomainServerPodRestart for Domain: "
135+
"About to verifyDomainServerPodRestart for Domain: "
133136
+ domain.getDomainUid()
134137
+ " imagePullPolicy: IfNotPresent --> imagePullPolicy: Never ");
135-
domain.testDomainServerPodRestart(
138+
domain.verifyDomainServerPodRestart(
136139
"imagePullPolicy: \"IfNotPresent\"", "imagePullPolicy: \"Never\" ");
137140

138141
logger.info("SUCCESS - " + testMethodName);
@@ -152,10 +155,10 @@ public void testServerPodsRestartByChangingIncludeServerOutInPodLog() throws Exc
152155
logTestBegin(testMethodName);
153156

154157
logger.info(
155-
"About to testDomainServerPodRestart for Domain: "
158+
"About to verifyDomainServerPodRestart for Domain: "
156159
+ domain.getDomainUid()
157160
+ " includeServerOutInPodLog: true --> includeServerOutInPodLog: false");
158-
domain.testDomainServerPodRestart(
161+
domain.verifyDomainServerPodRestart(
159162
"includeServerOutInPodLog: true", "includeServerOutInPodLog: false");
160163

161164
logger.info("SUCCESS - " + testMethodName);
@@ -176,12 +179,12 @@ public void testServerPodsRestartByChangingZImage() throws Exception {
176179

177180
try {
178181
logger.info(
179-
"About to testDomainServerPodRestart for Domain: "
182+
"About to verifyDomainServerPodRestart for Domain: "
180183
+ domain.getDomainUid()
181184
+ " Image property: store/oracle/weblogic:12.2.1.3 to store/oracle/weblogic:duplicate");
182185

183186
TestUtils.exec("docker tag store/oracle/weblogic:12.2.1.3 store/oracle/weblogic:duplicate");
184-
domain.testDomainServerPodRestart(
187+
domain.verifyDomainServerPodRestart(
185188
"\"store/oracle/weblogic:12.2.1.3\"", "\"store/oracle/weblogic:duplicate\"");
186189
} finally {
187190
TestUtils.exec("docker rmi -f store/oracle/weblogic:duplicate");
@@ -190,13 +193,127 @@ public void testServerPodsRestartByChangingZImage() throws Exception {
190193
logger.info("SUCCESS - " + testMethodName);
191194
}
192195

196+
/**
197+
* Modify/Add the containerSecurityContext section at ServerPod Level using kubectl apply -f
198+
* cont.security.context.domain.yaml. Verify all the pods re-started. The property tested is:
199+
* serverPod: containerSecurityContext: runAsUser: 1000 fsGroup: 1000.
200+
*
201+
* @throws Exception - assertion fails due to unmatched value or errors occurred if tested servers
202+
* are not restarted or after restart the server yaml file doesn't include the new added
203+
* property
204+
*/
205+
@Test
206+
public void testServerPodsRestartByChangingContSecurityContext() throws Exception {
207+
Assume.assumeFalse(QUICKTEST);
208+
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
209+
logTestBegin(testMethodName);
210+
211+
// firstly ensure that original domain.yaml doesn't include the property-to-be-added
212+
String domainFileName =
213+
BaseTest.getUserProjectsDir() + "/weblogic-domains/" + domainUid + "/domain.yaml";
214+
boolean result =
215+
(new String(Files.readAllBytes(Paths.get(domainFileName)))).contains("fsGroup: 1000");
216+
Assert.assertFalse(result);
217+
218+
// domainYaml: the yaml file name with changed property under resources dir
219+
String domainYaml = "cont.security.context.domain.yaml";
220+
logger.info(
221+
"About to verifyDomainServerPodRestart for Domain: "
222+
+ domain.getDomainUid()
223+
+ " change container securityContext:\n"
224+
+ " runAsUser: 1000\n"
225+
+ " fsGroup: 1000 ");
226+
domain.verifyDomainServerPodRestart(domainYaml);
227+
domain.findServerPropertyChange("securityContext", "admin-server");
228+
domain.findServerPropertyChange("securityContext", "managed-server1");
229+
230+
logger.info("SUCCESS - " + testMethodName);
231+
}
232+
233+
/**
234+
* Modify/Add the podSecurityContext section at ServerPod level using kubectl apply -f
235+
* pod.security.context.domain.yaml. Verify all the pods re-started. The property tested is:
236+
* podSecurityContext: runAsUser: 1000 fsGroup: 2000.
237+
*
238+
* @throws Exception - assertion fails due to unmatched value or errors occurred if tested servers
239+
* are not restarted or after restart the server yaml file doesn't include the new added
240+
* property
241+
*/
242+
@Test
243+
public void testServerPodsRestartByChangingPodSecurityContext() throws Exception {
244+
Assume.assumeFalse(QUICKTEST);
245+
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
246+
logTestBegin(testMethodName);
247+
248+
// firstly ensure that original domain.yaml doesn't include the property-to-be-added
249+
String domainFileName =
250+
BaseTest.getUserProjectsDir() + "/weblogic-domains/" + domainUid + "/domain.yaml";
251+
boolean result =
252+
(new String(Files.readAllBytes(Paths.get(domainFileName)))).contains("fsGroup: 2000");
253+
Assert.assertFalse(result);
254+
255+
// domainYaml: the yaml file name with changed property under resources dir
256+
String domainYaml = "pod.security.context.domain.yaml";
257+
258+
logger.info(
259+
"About to verifyDomainServerPodRestart for Domain: "
260+
+ domain.getDomainUid()
261+
+ " change securityContext:\n"
262+
+ " runAsUser: 1000\n"
263+
+ " fsGroup: 2000 ");
264+
domain.verifyDomainServerPodRestart(domainYaml);
265+
domain.findServerPropertyChange("fsGroup: 2000", "admin-server");
266+
domain.findServerPropertyChange("fsGroup: 2000", "managed-server1");
267+
268+
logger.info("SUCCESS - " + testMethodName);
269+
}
270+
271+
/**
272+
* Modify/Add resources at ServerPod level using kubectl apply -f domain.yaml. Verify all pods
273+
* re-started. The property tested is: resources: limits: cpu: "1" requests: cpu: "0.5" args: -
274+
* -cpus - "2".
275+
*
276+
* @throws Exception - assertion fails due to unmatched value or errors occurred if tested servers
277+
* are not restarted or after restart the server yaml file doesn't include the new added
278+
* property
279+
*/
280+
@Test
281+
public void testServerPodsRestartByChangingResource() throws Exception {
282+
Assume.assumeFalse(QUICKTEST);
283+
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
284+
logTestBegin(testMethodName);
285+
286+
// firstly ensure that original domain.yaml doesn't include the property-to-be-addeded
287+
String domainFileName =
288+
BaseTest.getUserProjectsDir() + "/weblogic-domains/" + domainUid + "/domain.yaml";
289+
boolean result =
290+
(new String(Files.readAllBytes(Paths.get(domainFileName)))).contains("cpu: 500m");
291+
Assert.assertFalse(result);
292+
293+
// domainYaml: the yaml file name with changed property under resources dir
294+
String domainYaml = "resource.domain.yaml";
295+
296+
logger.info(
297+
"About to verifyDomainServerPodRestart for Domain: "
298+
+ domain.getDomainUid()
299+
+ " change resource:\n"
300+
+ " cpu: 500m");
301+
domain.verifyDomainServerPodRestart(domainYaml);
302+
domain.findServerPropertyChange("cpu: 500m", "admin-server");
303+
domain.findServerPropertyChange("cpu: 500m", "managed-server1");
304+
305+
logger.info("SUCCESS - " + testMethodName);
306+
}
307+
193308
private static Domain createPodsRestartdomain() throws Exception {
194309

195310
Map<String, Object> domainMap = TestUtils.loadYaml(DOMAINONPV_WLST_YAML);
196311
domainMap.put("domainUID", "domainpodsrestart");
197312
domainMap.put("initialManagedServerReplicas", new Integer("1"));
198313

199-
logger.info("Creating Domain domain& verifing the domain creation");
314+
domainUid = (String) domainMap.get("domainUID");
315+
logger.info("Creating and verifying the domain creation with domainUid: " + domainUid);
316+
200317
domain = TestUtils.createDomain(domainMap);
201318
domain.verifyDomainCreated();
202319

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

Lines changed: 90 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -823,13 +823,13 @@ private void createPV() throws Exception {
823823
}
824824

825825
/**
826-
* verify domain server pods get restarted after a property change
826+
* Verify domain server pods get restarted after a property change.
827827
*
828-
* @param oldPropertyString
829-
* @param newPropertyString
830-
* @throws Exception
828+
* @param oldPropertyString - the old property value
829+
* @param newPropertyString - the new property value
830+
* @throws Exception - IOException or errors occurred if the tested server is not restarted
831831
*/
832-
public void testDomainServerPodRestart(String oldPropertyString, String newPropertyString)
832+
public void verifyDomainServerPodRestart(String oldPropertyString, String newPropertyString)
833833
throws Exception {
834834
logger.info("Inside testDomainServerPodRestart");
835835
String content =
@@ -879,6 +879,91 @@ public void testDomainServerPodRestart(String oldPropertyString, String newPrope
879879
logger.info("Done - testDomainServerPodRestart");
880880
}
881881

882+
/**
883+
* Get runtime server yaml file and verify the changed property is in that file.
884+
*
885+
* @param changedProperty - the changed/added property
886+
* @param serverName - server name that is being tested
887+
* @throws Exception - test FAILURE Exception if the changed property is not found in the server
888+
* yaml file
889+
*/
890+
public void findServerPropertyChange(String changedProperty, String serverName) throws Exception {
891+
logger.info("Inside findServerPropertyChange");
892+
// get runtime server pod yaml file
893+
String outDir = BaseTest.getUserProjectsDir() + "/weblogic-domains/" + domainUid + "/";
894+
StringBuffer command = new StringBuffer();
895+
command
896+
.append("kubectl get po/")
897+
.append(
898+
domainUid
899+
+ "-"
900+
+ serverName
901+
+ " -o yaml -n "
902+
+ domainNS
903+
+ "|"
904+
+ "grep "
905+
+ "\""
906+
+ changedProperty
907+
+ "\"");
908+
logger.info("kubectl execut with command: " + command.toString());
909+
TestUtils.exec(command.toString());
910+
911+
String result = ((TestUtils.exec(command.toString())).stdout());
912+
logger.info(
913+
"in the method findServerPropertyChange, " + command.toString() + " return " + result);
914+
if (!result.contains(changedProperty)) {
915+
throw new Exception(
916+
"FAILURE: didn't find the property: " + changedProperty + " for the server" + serverName);
917+
}
918+
919+
logger.info("Done - findServerPropertyChange");
920+
}
921+
922+
/**
923+
* Verify domain server pods get restarted after the property change by kubectl apply -f new
924+
* domain yaml file with added/changed property.
925+
*
926+
* @param fileNameWithChangedProperty - the fragment of domain yaml file with new added property
927+
* change
928+
* @throws Exception - IOException or errors occurred if the tested server is not restarted
929+
*/
930+
public void verifyDomainServerPodRestart(String fileNameWithChangedProperty) throws Exception {
931+
logger.info("Inside testDomainServerPodRestart domainYamlWithChangedProperty");
932+
933+
String newDomainYamlFile =
934+
BaseTest.getUserProjectsDir() + "/weblogic-domains/" + domainUid + "/domain_new.yaml";
935+
String domainYamlFile =
936+
BaseTest.getUserProjectsDir() + "/weblogic-domains/" + domainUid + "/domain.yaml";
937+
String fileWithChangedProperty =
938+
BaseTest.getProjectRoot()
939+
+ "/integration-tests/src/test/resources/"
940+
+ fileNameWithChangedProperty;
941+
942+
// copy the original domain.yaml to domain_new.yaml
943+
TestUtils.copyFile(domainYamlFile, newDomainYamlFile);
944+
945+
// append the file with changed property to the end of domain_new.yaml
946+
Files.write(
947+
Paths.get(newDomainYamlFile),
948+
Files.readAllBytes(Paths.get(fileWithChangedProperty)),
949+
StandardOpenOption.APPEND);
950+
951+
// kubectl apply the new constructed domain_new.yaml
952+
StringBuffer command = new StringBuffer();
953+
command.append("kubectl apply -f ").append(newDomainYamlFile);
954+
logger.info("kubectl execut with command: " + command.toString());
955+
TestUtils.exec(command.toString());
956+
957+
// verify the servers in the domain are being restarted in a sequence
958+
verifyAdminServerRestarted();
959+
verifyManagedServersRestarted();
960+
961+
// make domain.yaml include the new changed property
962+
TestUtils.copyFile(newDomainYamlFile, domainYamlFile);
963+
964+
logger.info("Done - testDomainServerPodRestart with domainYamlWithChangedProperty");
965+
}
966+
882967
/**
883968
* verify that admin server pod gets restarted.
884969
*
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Add podSecurityContext section at ServerPod Level
2+
# Make sure all pod(s) re-started
3+
#serverPod:
4+
# containerSecurityContext:
5+
# runAsUser: 1000
6+
# fsGroup: 1000
7+
# The generated server pods should look like:
8+
#spec:
9+
# containers:
10+
# - name: weblogic.server
11+
# securityContext:
12+
13+
serverPod:
14+
containerSecurityContext:
15+
runAsUser: 1000
16+
fsGroup: 1000
17+
env:
18+
- name: JAVA_OPTIONS
19+
value: "-Dweblogic.StdoutDebugEnabled=false"
20+
- name: USER_MEM_ARGS
21+
value: "-Djava.security.egd=file:/dev/./urandom -Xms64m -Xmx256m "
22+
volumes:
23+
- name: weblogic-domain-storage-volume
24+
persistentVolumeClaim:
25+
claimName: domainpodsrestart-weblogic-sample-pvc
26+
volumeMounts:
27+
- mountPath: /shared
28+
name: weblogic-domain-storage-volume
29+

0 commit comments

Comments
 (0)