Skip to content

Commit ceadd59

Browse files
authored
Merge pull request #453 from oracle/improve_samples_OOTB_experience
Support custom PVC, default domain home and default log home
2 parents 42fdf78 + 9912112 commit ceadd59

File tree

30 files changed

+198
-175
lines changed

30 files changed

+198
-175
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,11 @@ public void testWLDFScaling(Operator operator, Domain domain) throws Exception {
273273
String scriptsDir =
274274
"/scratch/acceptance_test_pv/persistentVolume-"
275275
+ domainUid
276-
+ "/domain/"
277-
+ domainName
276+
+ "/domains/"
277+
+ domainUid
278278
+ "/bin/scripts";
279279

280-
copyScalingScriptToPod(scriptsDir, domainName, adminPodName, domainNS);
280+
copyScalingScriptToPod(scriptsDir, domainUid, adminPodName, domainNS);
281281
TestUtils.createRBACPoliciesForWLDFScaling();
282282

283283
// deploy opensessionapp
@@ -391,15 +391,15 @@ public static String getBranchName() {
391391
}
392392

393393
private void copyScalingScriptToPod(
394-
String dirPathToCreate, String domainName, String podName, String domainNS) throws Exception {
394+
String dirPathToCreate, String domainUID, String podName, String domainNS) throws Exception {
395395

396396
// create scripts dir under domain pv
397397
TestUtils.createDirUnderDomainPV(dirPathToCreate);
398398

399399
// copy script to pod
400400
TestUtils.kubectlcp(
401401
getProjectRoot() + "/src/scripts/scaling/scalingAction.sh",
402-
"/shared/domain/" + domainName + "/bin/scripts/scalingAction.sh",
402+
"/shared/domains/" + domainUID + "/bin/scripts/scalingAction.sh",
403403
// "/shared/scalingAction.sh",
404404
podName,
405405
domainNS);

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

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public Domain(String inputYaml) throws Exception {
6262
createPV();
6363
createSecret();
6464
generateInputYaml();
65-
callCreateDomainScript();
65+
callCreateDomainScript(userProjectsDir + "/weblogic-domains/" + domainUid);
6666
createLoadBalancer();
6767
}
6868

@@ -411,13 +411,13 @@ public Map<String, Object> getDomainMap() {
411411

412412
public void deletePVCAndCheckPVReleased() throws Exception {
413413
StringBuffer cmd = new StringBuffer("kubectl get pv ");
414-
cmd.append(domainUid).append("-weblogic-domain-pv -n ").append(domainNS);
414+
cmd.append(domainUid).append("-pv -n ").append(domainNS);
415415

416416
ExecResult result = ExecCommand.exec(cmd.toString());
417417
if (result.exitValue() == 0) {
418418
logger.info("Status of PV before deleting PVC " + result.stdout());
419419
}
420-
TestUtils.deletePVC(domainUid + "-weblogic-domain-pvc", domainNS);
420+
TestUtils.deletePVC(domainUid + "-pvc", domainNS);
421421
String reclaimPolicy = (String) domainMap.get("weblogicDomainStorageReclaimPolicy");
422422
boolean pvReleased = TestUtils.checkPVReleased(domainUid, domainNS);
423423
if (reclaimPolicy != null && reclaimPolicy.equals("Recycle") && !pvReleased) {
@@ -430,14 +430,23 @@ public void deletePVCAndCheckPVReleased() throws Exception {
430430

431431
public void createDomainOnExistingDirectory() throws Exception {
432432
String domainStoragePath = domainMap.get("weblogicDomainStoragePath").toString();
433-
String domainDir = domainStoragePath + "/domain/" + domainMap.get("domainName").toString();
433+
String domainDir = domainStoragePath + "/domains/" + domainMap.get("domainUID").toString();
434434
logger.info("making sure the domain directory exists");
435435
if (domainDir != null && !(new File(domainDir).exists())) {
436436
throw new RuntimeException(
437437
"FAIL: the domain directory " + domainDir + " does not exist, exiting!");
438438
}
439439
logger.info("Run the script to create domain");
440-
StringBuffer cmd = new StringBuffer("cd ");
440+
try {
441+
callCreateDomainScript(userProjectsDir + "/weblogic-domains2/" + domainUid);
442+
} catch (RuntimeException re) {
443+
re.printStackTrace();
444+
logger.info("[SUCCESS] create domain job failed, this is the expected behavior");
445+
return;
446+
}
447+
throw new RuntimeException("FAIL: unexpected result, create domain job did not report error");
448+
449+
/* StringBuffer cmd = new StringBuffer("cd ");
441450
cmd.append(BaseTest.getProjectRoot())
442451
.append(" && helm install kubernetes/charts/weblogic-domain");
443452
cmd.append(" --name ")
@@ -454,7 +463,7 @@ public void createDomainOnExistingDirectory() throws Exception {
454463
} else {
455464
throw new RuntimeException(
456465
"FAIL: unexpected result, create domain job exit code: " + result.exitValue());
457-
}
466+
} */
458467
}
459468

460469
public void verifyAdminConsoleViaLB() throws Exception {
@@ -534,9 +543,11 @@ private void createPV() throws Exception {
534543
+ "/kubernetes/samples/scripts/create-weblogic-domain-pv-pvc/create-pv-pvc-inputs.yaml"));
535544
Map<String, Object> pvMap = yaml.load(pv_is);
536545
pv_is.close();
537-
pvMap.put("domainName", domainMap.get("domainName"));
538546
pvMap.put("domainUID", domainUid);
539547

548+
// each domain uses its own pv for now
549+
domainMap.put("persistentVolumeClaimName", domainUid + "-pvc");
550+
540551
if (domainMap.get("weblogicDomainStorageReclaimPolicy") != null) {
541552
pvMap.put(
542553
"weblogicDomainStorageReclaimPolicy",
@@ -545,6 +556,7 @@ private void createPV() throws Exception {
545556
if (domainMap.get("weblogicDomainStorageSize") != null) {
546557
pvMap.put("weblogicDomainStorageSize", domainMap.get("weblogicDomainStorageSize"));
547558
}
559+
pvMap.put("baseName", domainUid);
548560
pvMap.put("namespace", domainNS);
549561

550562
weblogicDomainStorageReclaimPolicy = (String) pvMap.get("weblogicDomainStorageReclaimPolicy");
@@ -590,13 +602,13 @@ private void generateInputYaml() throws Exception {
590602
TestUtils.createInputFile(domainMap, generatedInputYamlFile);
591603
}
592604

593-
private void callCreateDomainScript() throws Exception {
605+
private void callCreateDomainScript(String outputDir) throws Exception {
594606
StringBuffer cmd = new StringBuffer(BaseTest.getProjectRoot());
595607
cmd.append(
596608
"/kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain.sh -i ")
597609
.append(generatedInputYamlFile)
598610
.append(" -e -v -o ")
599-
.append(userProjectsDir);
611+
.append(outputDir);
600612
logger.info("Running " + cmd);
601613
ExecResult result = ExecCommand.exec(cmd.toString());
602614
if (result.exitValue() != 0) {
@@ -755,6 +767,9 @@ private void initialize(String inputYaml) throws Exception {
755767

756768
// read input domain yaml to test
757769
domainMap = TestUtils.loadYaml(inputYaml);
770+
if (domainMap.get("domainName") == null) {
771+
domainMap.put("domainName", domainMap.get("domainUID"));
772+
}
758773

759774
// read sample domain inputs
760775
Yaml dyaml = new Yaml();

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ public LoadBalancer(Map lbMap) throws Exception {
2121
this.lbMap = lbMap;
2222
Path parentDir =
2323
Files.createDirectories(
24-
Paths.get(
25-
BaseTest.getUserProjectsDir() + "/weblogic-domains/" + lbMap.get("domainUID")));
24+
Paths.get(BaseTest.getUserProjectsDir() + "/loadbalancers/" + lbMap.get("domainUID")));
2625
// generate input yaml
2726
TestUtils.createInputFile(lbMap, parentDir + "/lb-inputs.yaml");
2827

@@ -33,7 +32,9 @@ public LoadBalancer(Map lbMap) throws Exception {
3332
+ " -i "
3433
+ parentDir
3534
+ "/lb-inputs.yaml -e -o "
36-
+ BaseTest.getUserProjectsDir();
35+
+ BaseTest.getUserProjectsDir()
36+
+ "/loadbalancers/"
37+
+ lbMap.get("domainUID");
3738
logger.info("Executing cmd " + cmdLb);
3839

3940
ExecResult result = ExecCommand.exec(cmdLb);

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,24 @@ public PersistentVolume(String dirPath, Map pvMap) throws Exception {
3939
logger.info("command result " + result.stdout().trim());
4040

4141
Path parentDir =
42-
Files.createDirectories(
43-
Paths.get(
44-
BaseTest.getUserProjectsDir() + "/weblogic-domains/" + pvMap.get("domainUID")));
42+
pvMap.get("domainUID") != null
43+
? Files.createDirectories(
44+
Paths.get(BaseTest.getUserProjectsDir() + "/pv-pvcs/" + pvMap.get("domainUID")))
45+
: Files.createDirectories(Paths.get(BaseTest.getUserProjectsDir() + "/pv-pvcs/"));
46+
4547
// generate input yaml
46-
TestUtils.createInputFile(pvMap, parentDir + "/pv-inputs.yaml");
48+
TestUtils.createInputFile(pvMap, parentDir + "/" + pvMap.get("baseName") + "-pv-inputs.yaml");
4749

4850
// create PV/PVC
4951
String cmdPvPvc =
5052
BaseTest.getProjectRoot()
5153
+ "/kubernetes/samples/scripts/create-weblogic-domain-pv-pvc/create-pv-pvc.sh "
5254
+ " -i "
5355
+ parentDir
54-
+ "/pv-inputs.yaml -e -o "
55-
+ BaseTest.getUserProjectsDir();
56+
+ "/"
57+
+ pvMap.get("baseName")
58+
+ "-pv-inputs.yaml -e -o "
59+
+ parentDir;
5660
logger.info("Executing cmd " + cmdPvPvc);
5761

5862
result = ExecCommand.exec(cmdPvPvc);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public static void deletePVC(String pvcName, String namespace) throws Exception
179179

180180
public static boolean checkPVReleased(String domainUid, String namespace) throws Exception {
181181
StringBuffer cmd = new StringBuffer("kubectl get pv ");
182-
cmd.append(domainUid).append("-weblogic-domain-pv -n ").append(namespace);
182+
cmd.append(domainUid).append("-pv -n ").append(namespace);
183183

184184
int i = 0;
185185
while (i < BaseTest.getMaxIterationsPod()) {

integration-tests/src/test/resources/domain3.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33

44
adminServerName: admin-server
5-
domainName: base_domain
5+
domainName: domain3
66
domainUID: domain3
77
clusterName: cluster-1
88
configuredManagedServerCount: 4
@@ -17,4 +17,4 @@ adminNodePort: 30703
1717
namespace: test1
1818
loadBalancerWebPort: 30307
1919
loadBalancerDashboardPort: 30317
20-
createDomainFilesDir: wdt
20+
createDomainFilesDir: wdt

integration-tests/src/test/resources/domain4.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33

44
adminServerName: admin-server
5-
domainName: base_domain
5+
domainName: domain4
66
domainUID: domain4
77
clusterName: cluster-1
88
clusterType: CONFIGURED
@@ -18,4 +18,4 @@ adminNodePort: 30704
1818
namespace: test2
1919
loadBalancerWebPort: 30308
2020
loadBalancerDashboardPort: 30318
21-
createDomainFilesDir: wdt
21+
createDomainFilesDir: wdt

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
scriptAct = wn1.createScriptAction('ScriptActionScaleUp')
3838
scriptAct.setEnabled(true)
3939
scriptAct.setTimeout(0)
40-
scriptAct.setWorkingDirectory('/shared/domain/base_domain/bin/scripts/')
41-
scriptAct.setPathToScript('/shared/domain/base_domain/bin/scripts/scalingAction.sh')
40+
scriptAct.setWorkingDirectory('/shared/domains/domain3/bin/scripts/')
41+
scriptAct.setPathToScript('/shared/domains/domain3/bin/scripts/scalingAction.sh')
4242
props = Properties()
4343
props.setProperty("INTERNAL_OPERATOR_CERT", operator_cert_data);
4444
#props.setProperty("KUBERNETES_SERVICE_HOST", k8s_master_host);

kubernetes/samples/scripts/common/validate.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ function validateOutputDir {
120120
shift
121121
local in2=${1}
122122
shift
123-
internalValidateInputsFileDoesNotExistOrIsTheSame ${dir} ${in1} ${in2}
124123
internalValidateGeneratedYamlFilesDoNotExist ${dir} $@
125124
else
126125
validationError "${dir} exists but is not a directory."

kubernetes/samples/scripts/create-weblogic-domain-load-balancer/create-load-balancer-inputs.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ adminPort: 7001
1111
adminServerName: admin-server
1212

1313
# Name of the WebLogic domain to create
14-
domainName: base_domain
14+
# By default, this is the same as the domainUID
15+
domainName: domain1
1516

1617
# Unique ID identifying a domain.
1718
# This ID must not contain an underscope ("_"), and must be lowercase and unique across all domains in a Kubernetes cluster.

0 commit comments

Comments
 (0)