Skip to content

Commit 5b2974d

Browse files
authored
Merge pull request #1126 from oracle/owls75142
Add test to verify domain restart works after domain configuration change
2 parents bb4c373 + b7fec9e commit 5b2974d

File tree

5 files changed

+95
-78
lines changed

5 files changed

+95
-78
lines changed

integration-tests/USECASES.MD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Basic Use Cases described above are verified in all the domain configurations. A
4343
| Domain | Use Case |
4444
| --- | --- |
4545
| Domain on PV using WDT | WLDF scaling |
46-
| Domain with ADMIN_ONLY | making sure only admin server is started and managed servers are not started. Shutdown domain by deleting domain CRD. Create domain on existing PV dir, pv is already populated by a shutdown domain. |
46+
| Domain with ADMIN_ONLY | making sure only admin server is started and managed servers are not started. Make some changes in domain configuration by changing admin server tuning backlog configuration and restart domain. Shutdown domain by deleting domain CRD. Create domain on existing PV dir, pv is already populated by a shutdown domain. |
4747
| Domain with situational config | create domain with listen address not set for admin server and t3 channel/NAP and incorrect file for admin server log location. Introspector should override these with sit-config automatically. Also, with some junk value for t3 channel public address and using custom situational config override replace with valid public address using secret. Also, on Jenkins this domain uses NFS instead of HOSTPATH PV storage |
4848
| Two domains managed by two operators | verify scaling and restart of one domain doesn't impact another domain. Delete domain resources using delete script from samples. |
4949
| Domain with Recycle policy | create domain with pvReclaimPolicy="Recycle" and using Configured cluster. Verify that the PV is deleted once the domain and PVC are deleted |

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,9 @@ public void testTwoDomainsManagedByTwoOperators() throws Exception {
235235

236236
/**
237237
* Create operator if its not running and create domain with serverStartPolicy="ADMIN_ONLY".
238-
* Verify only admin server is created. shutdown by deleting domain CRD. Create domain on existing
239-
* PV dir, pv is already populated by a shutdown domain.
238+
* Verify only admin server is created. Make domain configuration change and restart the domain.
239+
* shutdown by deleting domain CRD. Create domain on existing PV dir, pv is already populated by a
240+
* shutdown domain.
240241
*
241242
* @throws Exception exception
242243
*/
@@ -255,6 +256,10 @@ public void testCreateDomainWithStartPolicyAdminOnly() throws Exception {
255256
try {
256257
domain = TestUtils.createDomain(DOMAIN_ADMINONLY_YAML);
257258
domain.verifyDomainCreated();
259+
// change domain config by modifying accept backlog on adminserver tuning
260+
modifyDomainConfig(domain);
261+
domain.shutdownUsingServerStartPolicy();
262+
domain.restartUsingServerStartPolicy();
258263
} finally {
259264
if (domain != null) {
260265
// create domain on existing dir
@@ -516,4 +521,28 @@ private Domain testAdvancedUseCasesForADomain(Operator operator, Domain domain)
516521
}
517522
return domain;
518523
}
524+
525+
private void modifyDomainConfig(Domain domain) throws Exception {
526+
String adminPod = domain.getDomainUid() + "-" + domain.getAdminServerName();
527+
String scriptsLocInPod = "/u01/oracle";
528+
TestUtils.copyFileViaCat(
529+
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/modifyAcceptBacklog.py",
530+
scriptsLocInPod + "/modifyAcceptBacklog.py",
531+
adminPod,
532+
domain.getDomainNs());
533+
534+
TestUtils.copyFileViaCat(
535+
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/callpyscript.sh",
536+
scriptsLocInPod + "/callpyscript.sh",
537+
adminPod,
538+
domain.getDomainNs());
539+
String[] args = {
540+
scriptsLocInPod + "/modifyAcceptBacklog.py",
541+
BaseTest.getUsername(),
542+
BaseTest.getPassword(),
543+
"t3://" + adminPod + ":" + domain.getDomainMap().get("t3ChannelPort")
544+
};
545+
TestUtils.callShellScriptByExecToPod(
546+
adminPod, domain.getDomainNs(), scriptsLocInPod, "callpyscript.sh", args);
547+
}
519548
}

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

Lines changed: 19 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,25 @@ public void deployWebAppViaWlst(
483483
adminPod,
484484
domainNS);
485485

486-
callShellScriptByExecToPod(
487-
username, password, webappName, appLocationInPod, useAdminPortToDeploy);
486+
String t3Url = "t3://" + adminPod + ":";
487+
if (useAdminPortToDeploy) {
488+
t3Url = t3Url + domainMap.getOrDefault("adminPort", 7001);
489+
} else {
490+
t3Url = t3Url + t3ChannelPort;
491+
}
492+
493+
String[] args = {
494+
appLocationInPod + "/deploywebapp.py",
495+
BaseTest.getUsername(),
496+
BaseTest.getPassword(),
497+
t3Url,
498+
webappName,
499+
appLocationInPod + "/" + webappName + ".war",
500+
clusterName
501+
};
502+
503+
TestUtils.callShellScriptByExecToPod(
504+
adminPod, domainNS, appLocationInPod, "callpyscript.sh", args);
488505
}
489506

490507
/**
@@ -1272,79 +1289,6 @@ protected void createLoadBalancer() throws Exception {
12721289
new LoadBalancer(lbMap);
12731290
}
12741291

1275-
private void callShellScriptByExecToPod(
1276-
String username, String password, String webappName, String appLocationInPod)
1277-
throws Exception {
1278-
callShellScriptByExecToPod(username, password, webappName, appLocationInPod, false);
1279-
}
1280-
1281-
private void callShellScriptByExecToPod(
1282-
String username,
1283-
String password,
1284-
String webappName,
1285-
String appLocationInPod,
1286-
boolean usingAdminPortToDeploy)
1287-
throws Exception {
1288-
1289-
StringBuffer cmdKubectlSh = new StringBuffer("kubectl -n ");
1290-
cmdKubectlSh
1291-
.append(domainNS)
1292-
.append(" exec -it ")
1293-
.append(domainUid)
1294-
.append("-")
1295-
.append(adminServerName)
1296-
.append(" -- bash -c 'chmod +x -R ")
1297-
.append(appLocationInPod)
1298-
.append(" && ")
1299-
.append(appLocationInPod)
1300-
.append("/callpyscript.sh ")
1301-
.append(appLocationInPod)
1302-
.append("/deploywebapp.py ")
1303-
.append(username)
1304-
.append(" ")
1305-
.append(password)
1306-
.append(" t3://")
1307-
// .append(TestUtils.getHostName())
1308-
.append(domainUid)
1309-
.append("-")
1310-
.append(adminServerName)
1311-
.append(":");
1312-
1313-
if (usingAdminPortToDeploy) {
1314-
String adminPort = (domainMap.getOrDefault("adminPort", 7001)).toString();
1315-
cmdKubectlSh.append(adminPort);
1316-
} else {
1317-
cmdKubectlSh.append(t3ChannelPort);
1318-
}
1319-
1320-
cmdKubectlSh
1321-
.append(" ")
1322-
.append(webappName)
1323-
.append(" ")
1324-
.append(appLocationInPod)
1325-
.append("/")
1326-
.append(webappName)
1327-
.append(".war ")
1328-
.append(clusterName)
1329-
.append("'");
1330-
logger.info("Command to call kubectl sh file " + cmdKubectlSh);
1331-
ExecResult result = ExecCommand.exec(cmdKubectlSh.toString());
1332-
String resultStr =
1333-
"Command= '"
1334-
+ cmdKubectlSh
1335-
+ "'"
1336-
+ ", exitValue="
1337-
+ result.exitValue()
1338-
+ ", stdout='"
1339-
+ result.stdout()
1340-
+ "'"
1341-
+ ", stderr='"
1342-
+ result.stderr()
1343-
+ "'";
1344-
if (result.exitValue() != 0 || !resultStr.contains("Deployment State : completed"))
1345-
throw new RuntimeException("FAILURE: webapp deploy failed - " + resultStr);
1346-
}
1347-
13481292
private void callWebAppAndWaitTillReady(String curlCmd) throws Exception {
13491293
for (int i = 0; i < maxIterations; i++) {
13501294
ExecResult result = TestUtils.exec(curlCmd);

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,38 @@ public static String callShellScriptByExecToPod(
972972
return result.stdout().trim();
973973
}
974974

975+
/**
976+
* exec into the pod and call the shell script with given arguments.
977+
*
978+
* @param podName pod name
979+
* @param domainNS namespace
980+
* @param scriptsLocInPod script location
981+
* @param shScriptName script name
982+
* @param args script arguments
983+
* @throws Exception exception
984+
*/
985+
public static void callShellScriptByExecToPod(
986+
String podName, String domainNS, String scriptsLocInPod, String shScriptName, String[] args)
987+
throws Exception {
988+
StringBuffer cmdKubectlSh = new StringBuffer("kubectl -n ");
989+
cmdKubectlSh
990+
.append(domainNS)
991+
.append(" exec -it ")
992+
.append(podName)
993+
.append(" -- bash -c 'chmod +x -R ")
994+
.append(scriptsLocInPod)
995+
.append(" && ")
996+
.append(scriptsLocInPod)
997+
.append("/")
998+
.append(shScriptName)
999+
.append(" ")
1000+
.append(String.join(" ", args).toString())
1001+
.append("'");
1002+
1003+
logger.info("Command to call kubectl sh file " + cmdKubectlSh);
1004+
TestUtils.exec(cmdKubectlSh.toString());
1005+
}
1006+
9751007
public static void createDirUnderDomainPV(String dirPath) throws Exception {
9761008

9771009
String crdCmd =
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2018, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
4+
import time as systime
5+
6+
connect(sys.argv[1],sys.argv[2],sys.argv[3])
7+
edit()
8+
startEdit()
9+
cd('/Servers/admin-server')
10+
cmo.setAcceptBacklog(4000)
11+
save()
12+
activate()

0 commit comments

Comments
 (0)