Skip to content

Commit 226169e

Browse files
committed
refactor callShellScriptByExecToPod
1 parent ba501c1 commit 226169e

File tree

5 files changed

+51
-93
lines changed

5 files changed

+51
-93
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: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,18 @@ public void testCreateDomainWithStartPolicyAdminOnly() throws Exception {
251251
try {
252252
domain = TestUtils.createDomain(DOMAIN_ADMINONLY_YAML);
253253
domain.verifyDomainCreated();
254+
// change domain config by modifying accept backlog on adminserver tuning
254255
modifyDomainConfig(domain);
255-
256+
domain.shutdownUsingServerStartPolicy();
257+
domain.restartUsingServerStartPolicy();
256258
} finally {
257259
if (domain != null) {
258260
// create domain on existing dir
259-
// domain.destroy();
261+
domain.destroy();
260262
}
261263
}
262264

263-
// domain.createDomainOnExistingDirectory();
265+
domain.createDomainOnExistingDirectory();
264266

265267
logger.info("SUCCESS - " + testMethodName);
266268
}
@@ -515,24 +517,25 @@ private Domain testAdvancedUseCasesForADomain(Operator operator, Domain domain)
515517

516518
private void modifyDomainConfig(Domain domain) throws Exception {
517519
String adminPod = domain.getDomainUid() + "-" + domain.getAdminServerName();
520+
String scriptsLocInPod = "/u01/oracle";
518521
TestUtils.copyFileViaCat(
519522
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/modifyAcceptBacklog.py",
520-
appLocationInPod + "/modifyAcceptBacklog.py",
523+
scriptsLocInPod + "/modifyAcceptBacklog.py",
521524
adminPod,
522525
domain.getDomainNS());
523526

524527
TestUtils.copyFileViaCat(
525528
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/callpyscript.sh",
526-
appLocationInPod + "/callpyscript.sh",
529+
scriptsLocInPod + "/callpyscript.sh",
527530
adminPod,
528531
domain.getDomainNS());
529532
String[] args = {
530-
appLocationInPod + "/modifyAcceptBacklog.py",
533+
scriptsLocInPod + "/modifyAcceptBacklog.py",
531534
BaseTest.getUsername(),
532535
BaseTest.getPassword(),
533536
"t3://" + adminPod + ":" + domain.getDomainMap().get("t3ChannelPort")
534537
};
535-
domain.callShellScriptByExecToPod(
536-
adminPod, domain.getDomainNS(), appLocationInPod, "callpyscript.sh", args);
538+
TestUtils.callShellScriptByExecToPod(
539+
adminPod, domain.getDomainNS(), scriptsLocInPod, "callpyscript.sh", args);
537540
}
538541
}

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

Lines changed: 14 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,20 @@ public void deployWebAppViaWLST(
487487
adminPod,
488488
domainNS);
489489

490-
callShellScriptByExecToPod(
491-
username, password, webappName, appLocationInPod, useAdminPortToDeploy);
490+
String[] args = {
491+
appLocationInPod + "/deploywebapp.py",
492+
BaseTest.getUsername(),
493+
BaseTest.getPassword(),
494+
useAdminPortToDeploy
495+
? (domainMap.getOrDefault("adminPort", 7001)).toString()
496+
: "t3://" + adminPod + ":" + t3ChannelPort,
497+
webappName,
498+
appLocationInPod + "/" + webappName + ".war",
499+
clusterName
500+
};
501+
502+
TestUtils.callShellScriptByExecToPod(
503+
adminPod, domainNS, appLocationInPod, "callpyscript.sh", args);
492504
}
493505

494506
/**
@@ -1273,87 +1285,6 @@ protected void createLoadBalancer() throws Exception {
12731285
new LoadBalancer(lbMap);
12741286
}
12751287

1276-
public void callShellScriptByExecToPod(
1277-
String podName, String domainNS, String scriptsLocInPod, String shScriptName, String[] args)
1278-
throws Exception {
1279-
StringBuffer cmdKubectlSh = new StringBuffer("kubectl -n ");
1280-
cmdKubectlSh
1281-
.append(domainNS)
1282-
.append(" exec -it ")
1283-
.append(podName)
1284-
.append(" -- bash -c 'chmod +x ")
1285-
.append(scriptsLocInPod)
1286-
.append(" && ")
1287-
.append(scriptsLocInPod)
1288-
.append("/")
1289-
.append(shScriptName)
1290-
.append(" ")
1291-
.append(String.join(" ", args).toString())
1292-
.append("'");
1293-
1294-
logger.info("Command to call kubectl sh file " + cmdKubectlSh);
1295-
TestUtils.exec(cmdKubectlSh.toString());
1296-
}
1297-
1298-
private void callShellScriptByExecToPod(
1299-
String username, String password, String webappName, String appLocationInPod)
1300-
throws Exception {
1301-
callShellScriptByExecToPod(username, password, webappName, appLocationInPod, false);
1302-
}
1303-
1304-
private void callShellScriptByExecToPod(
1305-
String username,
1306-
String password,
1307-
String webappName,
1308-
String appLocationInPod,
1309-
boolean usingAdminPortToDeploy)
1310-
throws Exception {
1311-
1312-
StringBuffer cmdKubectlSh = new StringBuffer("kubectl -n ");
1313-
cmdKubectlSh
1314-
.append(domainNS)
1315-
.append(" exec -it ")
1316-
.append(domainUid)
1317-
.append("-")
1318-
.append(adminServerName)
1319-
.append(" -- bash -c 'chmod +x -R ")
1320-
.append(appLocationInPod)
1321-
.append(" && ")
1322-
.append(appLocationInPod)
1323-
.append("/callpyscript.sh ")
1324-
.append(appLocationInPod)
1325-
.append("/deploywebapp.py ")
1326-
.append(username)
1327-
.append(" ")
1328-
.append(password)
1329-
.append(" t3://")
1330-
// .append(TestUtils.getHostName())
1331-
.append(domainUid)
1332-
.append("-")
1333-
.append(adminServerName)
1334-
.append(":");
1335-
1336-
if (usingAdminPortToDeploy) {
1337-
String adminPort = (domainMap.getOrDefault("adminPort", 7001)).toString();
1338-
cmdKubectlSh.append(adminPort);
1339-
} else {
1340-
cmdKubectlSh.append(t3ChannelPort);
1341-
}
1342-
1343-
cmdKubectlSh
1344-
.append(" ")
1345-
.append(webappName)
1346-
.append(" ")
1347-
.append(appLocationInPod)
1348-
.append("/")
1349-
.append(webappName)
1350-
.append(".war ")
1351-
.append(clusterName)
1352-
.append("'");
1353-
logger.info("Command to call kubectl sh file " + cmdKubectlSh);
1354-
TestUtils.exec(cmdKubectlSh.toString());
1355-
}
1356-
13571288
private void callWebAppAndWaitTillReady(String curlCmd) throws Exception {
13581289
for (int i = 0; i < maxIterations; i++) {
13591290
ExecResult result = TestUtils.exec(curlCmd);

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,4 +1422,26 @@ public static ExecResult kubectlpatch(String domainUid, String domainNS, String
14221422
+ " --type merge";
14231423
return exec(cmd, true);
14241424
}
1425+
1426+
public static void callShellScriptByExecToPod(
1427+
String podName, String domainNS, String scriptsLocInPod, String shScriptName, String[] args)
1428+
throws Exception {
1429+
StringBuffer cmdKubectlSh = new StringBuffer("kubectl -n ");
1430+
cmdKubectlSh
1431+
.append(domainNS)
1432+
.append(" exec -it ")
1433+
.append(podName)
1434+
.append(" -- bash -c 'chmod +x -R ")
1435+
.append(scriptsLocInPod)
1436+
.append(" && ")
1437+
.append(scriptsLocInPod)
1438+
.append("/")
1439+
.append(shScriptName)
1440+
.append(" ")
1441+
.append(String.join(" ", args).toString())
1442+
.append("'");
1443+
1444+
logger.info("Command to call kubectl sh file " + cmdKubectlSh);
1445+
TestUtils.exec(cmdKubectlSh.toString());
1446+
}
14251447
}

integration-tests/src/test/resources/modifyAcceptBacklog.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import time as systime
55

66
connect(sys.argv[1],sys.argv[2],sys.argv[3])
7+
edit()
8+
startEdit()
79
cd('/Servers/admin-server')
810
cmo.setAcceptBacklog(4000)
9-
11+
save()
1012
activate()

0 commit comments

Comments
 (0)