Skip to content

Commit 47dbff4

Browse files
committed
initial cut for sharing PV across domains
1 parent 1f3ca45 commit 47dbff4

File tree

4 files changed

+113
-3
lines changed

4 files changed

+113
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class BaseTest {
4545
public static final String DOMAIN_SAMPLE_DEFAULTS_YAML = "domainsampledefaults.yaml";
4646
public static final String DOMAININIMAGE_WLST_YAML = "domaininimagewlst.yaml";
4747
public static final String DOMAININIMAGE_WDT_YAML = "domaininimagewdt.yaml";
48+
public static final String DOMAINONSHARINGPV_WLST_YAML = "domainonsharingpvwlst.yaml";
4849

4950
// property file used to configure constants for integration tests
5051
public static final String APP_PROPS_FILE = "OperatorIT.properties";

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

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,87 @@ public void testTwoDomainsManagedByTwoOperators() throws Exception {
229229
}
230230
logger.info("SUCCESS - " + testMethodName);
231231
}
232+
233+
/**
234+
* Create one operator if it is not running. Create domain domain1 and domain2 dynamic cluster in
235+
* default namespace, managed by operator. Both domains sharre one PV. Verify scaling for domain2
236+
* cluster from 2 to 3 servers and back to 2, plus verify no impact on domain1. Cycle domain1 down
237+
* and back up, plus verify no impact on domain2. shutdown by the domains using the delete
238+
* resource script from samples.
239+
*
240+
* <p>ToDo: configured cluster support is removed from samples, modify the test to create
241+
*
242+
* @throws Exception
243+
*/
244+
@Test
245+
public void testTwoDomainsManagedByOneOperatorSharingPV() throws Exception {
246+
Assume.assumeFalse(QUICKTEST);
247+
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
248+
logTestBegin(testMethodName);
249+
logger.info("Creating Domain domain1 & verifing the domain creation");
250+
251+
logger.info("Checking if operator1 and domain1 are running, if not creating");
252+
if (operator1 == null) {
253+
operator1 = TestUtils.createOperator(OPERATOR1_YAML);
254+
}
255+
256+
Domain domain1 = null, domain2 = null;
257+
boolean testCompletedSuccessfully = false;
258+
try {
259+
// load input yaml to map and add configOverrides
260+
Map<String, Object> domain1Map = TestUtils.loadYaml(DOMAINONSHARINGPV_WLST_YAML);
261+
domain1Map.put("domainUID", "d1onpv");
262+
domain1Map.put("adminNodePort", new Integer("30711"));
263+
domain1Map.put("t3ChannelPort", new Integer("30011"));
264+
domain1Map.put("voyagerWebPort", new Integer("30388"));
265+
domain1 = TestUtils.createDomain(domain1Map);
266+
domain1.verifyDomainCreated();
267+
testBasicUseCases(domain1);
268+
269+
Map<String, Object> domain2Map = TestUtils.loadYaml(DOMAINONSHARINGPV_WLST_YAML);
270+
domain2Map.put("domainUID", "d2onpv");
271+
domain2Map.put("adminNodePort", new Integer("30712"));
272+
domain2Map.put("t3ChannelPort", new Integer("30021"));
273+
// wdtDomainMap.put("clusterType", "Configured");
274+
domain2Map.put("voyagerWebPort", new Integer("30399"));
275+
domain2 = TestUtils.createDomain(domain2Map);
276+
domain2.verifyDomainCreated();
277+
testBasicUseCases(domain2);
278+
logger.info("Verify the only remaining running domain domain1 is unaffected");
279+
domain1.verifyDomainCreated();
280+
281+
testClusterScaling(operator1, domain2);
282+
283+
logger.info("Verify the only remaining running domain domain1 is unaffected");
284+
domain1.verifyDomainCreated();
285+
286+
logger.info("Destroy and create domain1 and verify no impact on domain2");
287+
domain1.destroy();
288+
domain1.create();
289+
290+
logger.info("Verify no impact on domain2");
291+
domain2.verifyDomainCreated();
292+
testCompletedSuccessfully = true;
293+
294+
} finally {
295+
String domainUidsToBeDeleted = "";
296+
297+
if (domain1 != null && (JENKINS || testCompletedSuccessfully)) {
298+
domainUidsToBeDeleted = domain1.getDomainUid();
299+
}
300+
if (domain2 != null && (JENKINS || testCompletedSuccessfully)) {
301+
domainUidsToBeDeleted = domainUidsToBeDeleted + "," + domain2.getDomainUid();
302+
}
303+
if (!domainUidsToBeDeleted.equals("")) {
304+
logger.info("About to delete domains: " + domainUidsToBeDeleted);
305+
TestUtils.deleteWeblogicDomainResources(domainUidsToBeDeleted);
306+
TestUtils.verifyAfterDeletion(domain1);
307+
TestUtils.verifyAfterDeletion(domain2);
308+
}
309+
}
310+
logger.info("SUCCESS - " + testMethodName);
311+
}
312+
232313
/**
233314
* Create operator if its not running and create domain with serverStartPolicy="ADMIN_ONLY".
234315
* Verify only admin server is created. shutdown by deleting domain CRD. Create domain on existing

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public class Domain {
6363
protected String userProjectsDir = "";
6464
private String projectRoot = "";
6565
private boolean ingressPerDomain = true;
66+
private boolean pvSharing = false;
6667
private String imageTag;
6768
private String imageName;
6869

@@ -873,10 +874,12 @@ protected void createPV() throws Exception {
873874
+ "/samples/scripts/create-weblogic-domain-pv-pvc/create-pv-pvc-inputs.yaml"));
874875
pvMap = yaml.load(pv_is);
875876
pv_is.close();
876-
pvMap.put("domainUID", domainUid);
877877

878-
// each domain uses its own pv for now
879-
if (domainUid != null)
878+
logger.info("pvSharing for this domain is: " + pvSharing);
879+
if (!pvSharing) pvMap.put("domainUID", domainUid);
880+
881+
// Now there is only one pvSharing test case and we just use"baseName" as PVC
882+
if ((domainUid != null) && !pvSharing)
880883
domainMap.put("persistentVolumeClaimName", domainUid + "-" + pvMap.get("baseName") + "-pvc");
881884
else domainMap.put("persistentVolumeClaimName", pvMap.get("baseName") + "-pvc");
882885

@@ -1473,6 +1476,10 @@ protected void initialize(Map<String, Object> inputDomainMap) throws Exception {
14731476
clusterName = (String) domainMap.get("clusterName");
14741477
clusterType = (String) domainMap.getOrDefault("clusterType", "DYNAMIC");
14751478
serverStartPolicy = ((String) domainMap.get("serverStartPolicy")).trim();
1479+
if (domainMap.containsKey("pvSharing")) {
1480+
pvSharing = ((Boolean) domainMap.get("pvSharing")).booleanValue();
1481+
}
1482+
logger.info("pvSharing for this domain is: " + pvSharing);
14761483

14771484
if (exposeAdminT3Channel) {
14781485
domainMap.put("t3PublicAddress", TestUtils.getHostName());
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
# This domain inputs file is used to create 2 domain with same namespace, same pv using wlst option and traefik load balancer.
5+
6+
adminServerName: admin-server
7+
domainUID: domainonpvwlst
8+
clusterName: cluster-1
9+
configuredManagedServerCount: 4
10+
initialManagedServerReplicas: 2
11+
managedServerNameBase: managed-server
12+
#weblogicDomainStoragePath will be ignored, PV dir will be created at /<baseDir>/<USER>/acceptance_test_pv
13+
#weblogicDomainStoragePath: /scratch/external-domain-home/pv001/
14+
pvSharing: true
15+
exposeAdminT3Channel: true
16+
exposeAdminNodePort: true
17+
namespace: default
18+
loadBalancer: TRAEFIK
19+
ingressPerDomain: true
20+
createDomainPyScript: integration-tests/src/test/resources/domain-home-on-pv/create-domain-custom-nap.py
21+
voyagerWebPort: 30305

0 commit comments

Comments
 (0)