Skip to content

Commit c107806

Browse files
committed
Sync-up with latest develop branch jenkins-ignore
2 parents 210b059 + a2869d8 commit c107806

File tree

7 files changed

+85
-65
lines changed

7 files changed

+85
-65
lines changed

build-tools/src/main/resources/weblogic-kubernetes-operator/checkstyle/customized_google_checks.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
<property name="eachLine" value="true"/>
2828
</module>
2929

30+
<module name="RegexpHeader">
31+
<property name="headerFile" value="build-tools/src/main/resources/weblogic-kubernetes-operator/checkstyle/java.header"/>
32+
<property name="fileExtensions" value="java"/>
33+
</module>
34+
3035
<module name="TreeWalker">
3136
<module name="OuterTypeFilename"/>
3237
<module name="IllegalTokenText">
@@ -42,7 +47,7 @@
4247
<property name="allowNonPrintableEscapes" value="true"/>
4348
</module>
4449
<module name="LineLength">
45-
<property name="max" value="100"/>
50+
<property name="max" value="120"/>
4651
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
4752
</module>
4853
<module name="AvoidStarImport"/>
@@ -193,7 +198,7 @@
193198
<module name="CustomImportOrder">
194199
<property name="sortImportsInGroupAlphabetically" value="true"/>
195200
<property name="separateLineBetweenGroups" value="true"/>
196-
<property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
201+
<property name="customImportOrderRules" value="STANDARD_JAVA_PACKAGE###THIRD_PARTY_PACKAGE###STATIC"/>
197202
</module>
198203
<module name="MethodParamPad"/>
199204
<module name="NoWhitespaceBefore">
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
^// Copyright (\d\d\d\d, )+Oracle Corporation and\/or its affiliates\. All rights reserved\.$
2+
^// Licensed under the Universal Permissive License v 1\.0 as shown at$
3+
^// http://oss\.oracle\.com/licenses/upl\.$

integration-tests/USECASES.MD

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ Java integration tests cover the below use cases:
1919

2020
**Advanced Use Cases**
2121

22-
6. Verify domain life cycle (destroy and create) should not have any impact on operator managing the domain and web app load balancing and admin external service.
22+
6. set precreateService true and verify that the services are created for the managed servers that are not started
2323
7. Cluster scale up/down using operator REST endpoint, webapp load balancing should adjust accordingly.
24-
8. Operator life cycle (destroy and create) should not impact the running domain.
24+
8. Verify that the services are created for the managed servers that are not started
25+
9. Verify domain life cycle (destroy and create) should not have any impact on operator managing the domain and web app load balancing and admin external service.
26+
10. Operator life cycle (destroy and create) should not impact the running domain.
2527

2628
Also the below use cases are covered for Quick test:
2729

28-
9. Verify the liveness probe by killing managed server 1 process 3 times to kick pod auto-restart.
29-
10. Shutdown the domain by changing domain `serverStartPolicy` to `NEVER`.
30+
11. Verify the liveness probe by killing managed server 1 process 3 times to kick pod auto-restart.
31+
12. Shutdown the domain by changing domain `serverStartPolicy` to `NEVER`.
3032

3133

3234
## Full test Configuration & Use Cases - Runs Quick test Configuration & Use cases and the below

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,9 @@ public void testDomainInImageUsingWDT() throws Exception {
502502

503503
private Domain testAdvancedUseCasesForADomain(Operator operator, Domain domain) throws Exception {
504504
if (!SMOKETEST) {
505+
domain.enablePrecreateService();
505506
testClusterScaling(operator, domain);
507+
domain.verifyServicesCreated(true);
506508
testDomainLifecyle(operator, domain);
507509
testOperatorLifecycle(operator, domain);
508510
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public void testServerPodsRestartByChangingZImage() throws Exception {
196196
logTestBegin(testMethodName);
197197

198198
try {
199-
TestUtils.ExecAndPrintLog("docker images");
199+
TestUtils.exec("docker images", true);
200200
logger.info(
201201
"About to verifyDomainServerPodRestart for Domain: "
202202
+ domain.getDomainUid()
@@ -213,8 +213,8 @@ public void testServerPodsRestartByChangingZImage() throws Exception {
213213
// tag image with repo name
214214
String tag =
215215
"docker tag " + getWeblogicImageName() + ":" + getWeblogicImageTag() + " " + newImage;
216-
TestUtils.ExecAndPrintLog(tag);
217-
TestUtils.ExecAndPrintLog("docker images");
216+
TestUtils.exec(tag, true);
217+
TestUtils.exec("docker images", true);
218218

219219
// login and push image to ocir
220220
TestUtils.loginAndPushImageToOCIR(newImage);

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

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,17 @@ public void verifyPodsCreated() throws Exception {
143143
* @throws Exception
144144
*/
145145
public void verifyServicesCreated() throws Exception {
146+
verifyServicesCreated(false);
147+
}
148+
149+
/**
150+
* verify services are created
151+
*
152+
* @param precreateService - if true check services are created for configuredManagedServerCount
153+
* number of servers else check for initialManagedServerReplicas number of servers
154+
* @throws Exception
155+
*/
156+
public void verifyServicesCreated(boolean precreateService) throws Exception {
146157
// check admin service
147158
logger.info("Checking if admin service(" + domainUid + "-" + adminServerName + ") is created");
148159
TestUtils.checkServiceCreated(domainUid + "-" + adminServerName, domainNS);
@@ -159,7 +170,9 @@ public void verifyServicesCreated() throws Exception {
159170

160171
if (!serverStartPolicy.equals("ADMIN_ONLY")) {
161172
// check managed server services
162-
for (int i = 1; i <= initialManagedServerReplicas; i++) {
173+
for (int i = 1;
174+
i <= (precreateService ? configuredManagedServerCount : initialManagedServerReplicas);
175+
i++) {
163176
logger.info(
164177
"Checking if managed service("
165178
+ domainUid
@@ -598,9 +611,7 @@ public void destroy() throws Exception {
598611
public void shutdown() throws Exception {
599612
int replicas = TestUtils.getClusterReplicas(domainUid, clusterName, domainNS);
600613
String cmd = "kubectl delete domain " + domainUid + " -n " + domainNS;
601-
ExecResult result = TestUtils.exec(cmd.toString());
602-
String output = result.stdout().trim();
603-
logger.info("command to delete domain " + cmd + " \n returned " + output);
614+
ExecResult result = TestUtils.exec(cmd.toString(), true);
604615
verifyDomainDeleted(replicas);
605616
}
606617

@@ -611,15 +622,8 @@ public void shutdown() throws Exception {
611622
*/
612623
public void shutdownUsingServerStartPolicy() throws Exception {
613624
int replicas = TestUtils.getClusterReplicas(domainUid, clusterName, domainNS);
614-
String cmd =
615-
"kubectl patch domain "
616-
+ domainUid
617-
+ " -n "
618-
+ domainNS
619-
+ " -p '{\"spec\":{\"serverStartPolicy\":\"NEVER\"}}' --type merge";
620-
ExecResult result = TestUtils.exec(cmd);
621-
String output = result.stdout().trim();
622-
logger.info("command to shutdown domain " + cmd + " \n returned " + output);
625+
String patchStr = "'{\"spec\":{\"serverStartPolicy\":\"NEVER\"}}' ";
626+
TestUtils.kubectlpatch(domainUid, domainNS, patchStr);
623627
verifyServerPodsDeleted(replicas);
624628
}
625629

@@ -629,18 +633,23 @@ public void shutdownUsingServerStartPolicy() throws Exception {
629633
* @throws Exception
630634
*/
631635
public void restartUsingServerStartPolicy() throws Exception {
632-
String cmd =
633-
"kubectl patch domain "
634-
+ domainUid
635-
+ " -n "
636-
+ domainNS
637-
+ " -p '{\"spec\":{\"serverStartPolicy\":\"IF_NEEDED\"}}' --type merge";
638-
ExecResult result = TestUtils.exec(cmd);
639-
String output = result.stdout().trim();
640-
logger.info("command to restart domain " + cmd + " \n returned " + output);
636+
String patchStr = "'{\"spec\":{\"serverStartPolicy\":\"IF_NEEDED\"}}'";
637+
TestUtils.kubectlpatch(domainUid, domainNS, patchStr);
641638
verifyPodsCreated();
642639
verifyServersReady();
643640
}
641+
642+
/**
643+
* add precreateService true in domain.yaml
644+
*
645+
* @throws Exception
646+
*/
647+
public void enablePrecreateService() throws Exception {
648+
String patchStr = "'{\"spec\":{\"serverService\":{\"precreateService\":true}}}'";
649+
TestUtils.kubectlpatch(domainUid, domainNS, patchStr);
650+
verifyServicesCreated(true);
651+
}
652+
644653
/**
645654
* verify domain is deleted
646655
*
@@ -1792,17 +1801,13 @@ public int getLoadBalancerWebPort() {
17921801
* @throws Exception
17931802
*/
17941803
public void shutdownManagedServerUsingServerStartPolicy(String msName) throws Exception {
1795-
String cmd =
1796-
"kubectl patch domain "
1797-
+ domainUid
1798-
+ " -n "
1799-
+ domainNS
1800-
+ " -p '{\"spec\":{\"managedServers\":[{\"serverName\":\""
1804+
logger.info("About to shutdown managed server <" + msName + ">");
1805+
String patchStr =
1806+
"'{\"spec\":{\"managedServers\":[{\"serverName\":\""
18011807
+ msName
1802-
+ "\",\"serverStartPolicy\":\"NEVER\"}]}}' --type merge";
1808+
+ "\",\"serverStartPolicy\":\"NEVER\"}]}}' ";
1809+
TestUtils.kubectlpatch(domainUid, domainNS, patchStr);
18031810

1804-
logger.info("command to shutdown managed server <" + msName + "> is: " + cmd);
1805-
TestUtils.exec(cmd);
18061811
TestUtils.checkPodDeleted(domainUid + "-" + msName, domainNS);
18071812
}
18081813

@@ -1813,17 +1818,13 @@ public void shutdownManagedServerUsingServerStartPolicy(String msName) throws Ex
18131818
* @throws Exception
18141819
*/
18151820
public void restartManagedServerUsingServerStartPolicy(String msName) throws Exception {
1816-
String cmd =
1817-
"kubectl patch domain "
1818-
+ domainUid
1819-
+ " -n "
1820-
+ domainNS
1821-
+ " -p '{\"spec\":{\"managedServers\":[{\"serverName\":\""
1821+
logger.info("About to restart managed server <" + msName + "> ");
1822+
String patchStr =
1823+
"'{\"spec\":{\"managedServers\":[{\"serverName\":\""
18221824
+ msName
1823-
+ "\",\"serverStartPolicy\":\"IF_NEEDED\"}]}}' --type merge";
1825+
+ "\",\"serverStartPolicy\":\"IF_NEEDED\"}]}}'";
1826+
TestUtils.kubectlpatch(domainUid, domainNS, patchStr);
18241827

1825-
logger.info("command to restart managed server <" + msName + "> is: " + cmd);
1826-
TestUtils.exec(cmd);
18271828
TestUtils.checkPodCreated(domainUid + "-" + msName, domainNS);
18281829
TestUtils.checkPodReady(domainUid + "-" + msName, domainNS);
18291830
}

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

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -233,17 +233,23 @@ public static void deletePVC(String pvcName, String namespace, String domainUid,
233233
}
234234

235235
public static ExecResult exec(String cmd) throws Exception {
236+
return exec(cmd, false);
237+
}
238+
239+
public static ExecResult exec(String cmd, boolean debug) throws Exception {
236240
ExecResult result = ExecCommand.exec(cmd);
237-
if (result.exitValue() != 0) {
241+
if (result.exitValue() != 0 || debug) {
238242
logger.info(
239-
"Command "
243+
"\nCommand "
240244
+ cmd
241-
+ " return value "
245+
+ "\nreturn value: "
242246
+ result.exitValue()
243-
+ " \n failed with stderr = "
247+
+ "\nstderr = "
244248
+ result.stderr()
245-
+ " \n stdout = "
249+
+ "\nstdout = "
246250
+ result.stdout());
251+
}
252+
if (result.exitValue() != 0) {
247253
throw new RuntimeException(
248254
"FAILURE: Command "
249255
+ cmd
@@ -252,6 +258,7 @@ public static ExecResult exec(String cmd) throws Exception {
252258
+ " \n stdout = "
253259
+ result.stdout());
254260
}
261+
255262
return result;
256263
}
257264

@@ -1403,16 +1410,16 @@ public static ExecResult loginAndPushImageToOCIR(String image) throws Exception
14031410
return result;
14041411
}
14051412

1406-
public static void ExecAndPrintLog(String command) throws Exception {
1407-
ExecResult result = ExecCommand.exec(command);
1408-
logger.info(
1409-
"\nCommand "
1410-
+ command
1411-
+ "\nreturn value: "
1412-
+ result.exitValue()
1413-
+ "\nstderr = "
1414-
+ result.stderr()
1415-
+ "\nstdout = "
1416-
+ result.stdout());
1413+
public static ExecResult kubectlpatch(String domainUid, String domainNS, String patchStr)
1414+
throws Exception {
1415+
String cmd =
1416+
"kubectl patch domain "
1417+
+ domainUid
1418+
+ " -n "
1419+
+ domainNS
1420+
+ " -p "
1421+
+ patchStr
1422+
+ " --type merge";
1423+
return exec(cmd, true);
14171424
}
14181425
}

0 commit comments

Comments
 (0)