Skip to content

Commit 1a14718

Browse files
authored
Merge pull request #1127 from oracle/sharingpv-integ-test
PR (ready to be merged): test for sharing PV across domains
2 parents 40e7489 + 790e246 commit 1a14718

File tree

4 files changed

+122
-4
lines changed

4 files changed

+122
-4
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
@@ -47,6 +47,7 @@ public class BaseTest {
4747
public static final String DOMAIN_SAMPLE_DEFAULTS_YAML = "domainsampledefaults.yaml";
4848
public static final String DOMAININIMAGE_WLST_YAML = "domaininimagewlst.yaml";
4949
public static final String DOMAININIMAGE_WDT_YAML = "domaininimagewdt.yaml";
50+
public static final String DOMAINONSHARINGPV_WLST_YAML = "domainonsharingpvwlst.yaml";
5051

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

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

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,88 @@ public void testTwoDomainsManagedByTwoOperators() throws Exception {
233233
logger.info("SUCCESS - " + testMethodName);
234234
}
235235

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

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public class Domain {
6969
private String domainHomeImageBuildPath = "";
7070
private String projectRoot = "";
7171
private boolean ingressPerDomain = true;
72+
private boolean pvSharing = false;
7273
private String imageTag;
7374
private String imageName;
7475
private boolean voyager;
@@ -898,12 +899,21 @@ protected void createPv() throws Exception {
898899
+ "/samples/scripts/create-weblogic-domain-pv-pvc/create-pv-pvc-inputs.yaml"));
899900
pvMap = yaml.load(pvis);
900901
pvis.close();
901-
pvMap.put("domainUID", domainUid);
902+
903+
logger.info("pvSharing for this domain is: " + pvSharing);
904+
if (!pvSharing) {
905+
pvMap.put("domainUID", domainUid);
906+
} else {
907+
pvMap.put("baseName", "weblogic-sharing");
908+
}
909+
logger.info("baseName of PVPVC for this domain is: " + (String) pvMap.get("baseName"));
902910

903-
// each domain uses its own pv for now
904-
if (domainUid != null)
911+
// Now there is only one pvSharing test case and we just use parameter "baseName"+"-pvc" as PVC
912+
if ((domainUid != null) && !pvSharing) {
905913
domainMap.put("persistentVolumeClaimName", domainUid + "-" + pvMap.get("baseName") + "-pvc");
906-
else domainMap.put("persistentVolumeClaimName", pvMap.get("baseName") + "-pvc");
914+
} else {
915+
domainMap.put("persistentVolumeClaimName", pvMap.get("baseName") + "-pvc");
916+
}
907917

908918
if (domainMap.get("weblogicDomainStorageReclaimPolicy") != null) {
909919
pvMap.put(
@@ -1426,6 +1436,10 @@ protected void initialize(Map<String, Object> inputDomainMap) throws Exception {
14261436
clusterName = (String) domainMap.get("clusterName");
14271437
clusterType = (String) domainMap.getOrDefault("clusterType", "DYNAMIC");
14281438
serverStartPolicy = ((String) domainMap.get("serverStartPolicy")).trim();
1439+
if (domainMap.containsKey("pvSharing")) {
1440+
pvSharing = ((Boolean) domainMap.get("pvSharing")).booleanValue();
1441+
}
1442+
logger.info("pvSharing for this domain is: " + pvSharing);
14291443

14301444
if (exposeAdminT3Channel) {
14311445
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 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)