Skip to content

Commit b6f79c0

Browse files
committed
use krun.sh to copy files and create dir on pv
1 parent 346f0e0 commit b6f79c0

File tree

4 files changed

+42
-58
lines changed

4 files changed

+42
-58
lines changed

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

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import java.nio.file.Files;
88
import java.nio.file.Paths;
9+
import java.nio.file.StandardCopyOption;
910
import java.util.Map;
1011
import java.util.Properties;
1112
import java.util.logging.FileHandler;
@@ -672,14 +673,7 @@ public void testWldfScaling(Operator operator, Domain domain) throws Exception {
672673
String adminPodName = domainUid + "-" + adminServerName;
673674
String domainName = (String) domainMap.get("domainName");
674675

675-
String scriptsDir =
676-
"/scratch/acceptance_test_pv/persistentVolume-"
677-
+ domainUid
678-
+ "/domains/"
679-
+ domainUid
680-
+ "/bin/scripts";
681-
682-
copyScalingScriptToPod(scriptsDir, domainUid, adminPodName, domainNS);
676+
copyScalingScriptToPod( domainUid, adminPodName, domainNS);
683677
TestUtils.createRbacPoliciesForWldfScaling();
684678

685679
// deploy opensessionapp
@@ -737,18 +731,23 @@ protected void logTestBegin(String testName) throws Exception {
737731
TestUtils.renewK8sClusterLease(getProjectRoot(), getLeaseId());
738732
}
739733

740-
private void copyScalingScriptToPod(
741-
String dirPathToCreate, String domainUid, String podName, String domainNS) throws Exception {
734+
private void copyScalingScriptToPod(String domainUid, String podName, String domainNS)
735+
throws Exception {
736+
737+
String pvDir = BaseTest.getPvRoot() + "/acceptance_test_pv/persistentVolume-" + domainUid;
738+
String scriptsDir = pvDir + "/domains/" + domainUid + "/bin/scripts";
742739

743740
// create scripts dir under domain pv
744-
TestUtils.createDirUnderDomainPV(dirPathToCreate);
745-
741+
TestUtils.createDirUnderDomainPV(scriptsDir);
742+
// workaround for the issue with not allowing .. in the host-path in krun.sh
743+
Files.copy(Paths.get(getProjectRoot() + "/src/scripts/scaling/scalingAction.sh"),
744+
Paths.get(getResultDir()+"/scalingAction.sh"), StandardCopyOption.REPLACE_EXISTING);
746745
// copy script to pod
747-
TestUtils.copyFileViaCat(
748-
getProjectRoot() + "/src/scripts/scaling/scalingAction.sh",
749-
"/shared/domains/" + domainUid + "/bin/scripts/scalingAction.sh",
750-
podName,
751-
domainNS);
746+
String cpUsingKrunCmd = getProjectRoot() + "/src/integration-tests/bash/krun.sh -m "
747+
+ getResultDir() + ":/tmpdir -m " + pvDir
748+
+ ":/pvdir -c 'cp -f /tmpdir/scalingAction.sh /pvdir/domains/domainonpvwdt/bin/scripts' -n "
749+
+ domainNS;
750+
TestUtils.exec(cpUsingKrunCmd, true);
752751
}
753752

754753
private void callWebAppAndVerifyScaling(Domain domain, int replicas) throws Exception {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ protected void createPv() throws Exception {
938938
pvMap.values().removeIf(Objects::isNull);
939939

940940
// k8s job mounts PVROOT /scratch/<usr>/wl_k8s_test_results to /scratch, create PV/PVC
941-
new PersistentVolume("acceptance_test_pv/persistentVolume-" + domainUid, pvMap);
941+
new PersistentVolume(BaseTest.getPvRoot() +"acceptance_test_pv/persistentVolume-" + domainUid, pvMap);
942942

943943
String cmd =
944944
BaseTest.getProjectRoot()

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

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,14 @@ public class PersistentVolume {
2121
public PersistentVolume(String dirPath, Map pvMap) throws Exception {
2222
this.dirPath = dirPath;
2323
this.pvMap = pvMap;
24-
24+
2525
String cmd =
2626
BaseTest.getProjectRoot()
27-
+ "/src/integration-tests/bash/krun.sh -m "+BaseTest.getPvRoot()+":/sharedparent -c 'mkdir -m 777 -p /sharedparent/"
28-
+ dirPath
27+
+ "/src/integration-tests/bash/krun.sh -m "+BaseTest.getPvRoot()+":/sharedparent -c 'mkdir -m 777 -p "
28+
+ dirPath.replace(BaseTest.getPvRoot(), "/sharedparent/")
2929
+ "'";
30-
31-
ExecResult result = ExecCommand.exec(cmd);
32-
if (result.exitValue() != 0) {
33-
throw new RuntimeException(
34-
"FAILURE: command to create domain PV directory "
35-
+ cmd
36-
+ " failed, returned "
37-
+ result.stdout()
38-
+ result.stderr());
39-
}
40-
logger.info("command result " + result.stdout().trim());
30+
31+
TestUtils.exec(cmd, true);
4132

4233
Path parentDir =
4334
pvMap.get("domainUID") != null
@@ -60,16 +51,7 @@ public PersistentVolume(String dirPath, Map pvMap) throws Exception {
6051
+ BaseTest.getUserProjectsDir();
6152
logger.info("Executing cmd " + cmdPvPvc);
6253

63-
result = ExecCommand.exec(cmdPvPvc);
64-
if (result.exitValue() != 0) {
65-
throw new RuntimeException(
66-
"FAILURE: command to create PV/PVC "
67-
+ cmdPvPvc
68-
+ " failed, returned "
69-
+ result.stdout()
70-
+ result.stderr());
71-
}
72-
logger.info("command result " + result.stdout().trim());
54+
TestUtils.exec(cmdPvPvc, true);
7355
}
7456

7557
public String getDirPath() {

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

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,12 +1022,13 @@ public static void callShellScriptByExecToPod(
10221022
}
10231023

10241024
public static void createDirUnderDomainPV(String dirPath) throws Exception {
1025-
1025+
dirPath = dirPath.replace(BaseTest.getPvRoot(), "/sharedparent/");
10261026
String crdCmd =
10271027
BaseTest.getProjectRoot()
1028-
+ "/src/integration-tests/bash/job.sh \"mkdir -p "
1029-
+ dirPath
1030-
+ "\"";
1028+
+ "/src/integration-tests/bash/krun.sh -m "+BaseTest.getPvRoot()+":/sharedparent -c 'mkdir -m 777 -p "
1029+
+ dirPath
1030+
+ "'";
1031+
10311032
ExecResult result = ExecCommand.exec(crdCmd);
10321033
if (result.exitValue() != 0) {
10331034
throw new RuntimeException(
@@ -1046,31 +1047,33 @@ public static void createWldfModule(String adminPodName, String domainNS, int t3
10461047
// copy wldf.py script tp pod
10471048
copyFileViaCat(
10481049
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/wldf/wldf.py",
1049-
"/shared/wldf.py",
1050+
BaseTest.getAppLocationInPod() +"/wldf.py",
10501051
adminPodName,
10511052
domainNS);
10521053

10531054
// copy callpyscript.sh to pod
10541055
copyFileViaCat(
10551056
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/callpyscript.sh",
1056-
"/shared/callpyscript.sh",
1057+
BaseTest.getAppLocationInPod() + "/callpyscript.sh",
10571058
adminPodName,
10581059
domainNS);
10591060

10601061
// arguments to shell script to call py script
1061-
String arguments =
1062-
"/shared/wldf.py "
1063-
+ BaseTest.getUsername()
1064-
+ " "
1065-
+ BaseTest.getPassword()
1066-
+ " t3://"
1062+
1063+
String[] args = {
1064+
BaseTest.getAppLocationInPod() + "/wldf.py",
1065+
BaseTest.getUsername(),
1066+
BaseTest.getPassword(),
1067+
" t3://"
10671068
+ adminPodName
10681069
+ ":"
1069-
+ t3ChannelPort;
1070-
1070+
+ t3ChannelPort,
1071+
1072+
};
1073+
10711074
// call callpyscript.sh in pod to deploy wldf module
1072-
TestUtils.callShellScriptByExecToPod(
1073-
"/shared/callpyscript.sh", arguments, adminPodName, domainNS);
1075+
TestUtils.callShellScriptByExecToPod(
1076+
adminPodName, domainNS, BaseTest.getAppLocationInPod(), "callpyscript.sh", args);
10741077
}
10751078

10761079
public static void createRbacPoliciesForWldfScaling() throws Exception {

0 commit comments

Comments
 (0)