Skip to content

Commit 86b8386

Browse files
committed
add overrride options for wdt template and domain template
1 parent 0b608d2 commit 86b8386

File tree

2 files changed

+71
-53
lines changed

2 files changed

+71
-53
lines changed

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

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void testCreateDomainTwoConfiguredCluster() throws Exception {
9999
&& ((String) domainMap.get("loadBalancer")).equalsIgnoreCase("VOYAGER"))) {
100100
domainMap.put("voyagerWebPort", new Integer("30366"));
101101
}
102-
addCluster2ToDomainTemplate();
102+
addCluster2ToDomainTemplate(domainMap);
103103
domain = TestUtils.createDomain(domainMap);
104104
domain.verifyDomainCreated();
105105
String pods[] = {
@@ -156,7 +156,7 @@ public void testCreateDomainTwoMixedCluster() throws Exception {
156156
&& ((String) domainMap.get("loadBalancer")).equalsIgnoreCase("VOYAGER"))) {
157157
domainMap.put("voyagerWebPort", new Integer("30377"));
158158
}
159-
addCluster2ToDomainTemplate();
159+
addCluster2ToDomainTemplate(domainMap);
160160
domain = TestUtils.createDomain(domainMap);
161161
domain.verifyDomainCreated();
162162
String pods[] = {
@@ -194,9 +194,9 @@ public void testCreateDomainTwoClusterWDTInImage() throws Exception {
194194
String DOMAINUID = "twoclusterdomainwdt";
195195
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
196196
logTestBegin(testMethodName);
197-
String wdttemplate =
198-
BaseTest.getProjectRoot()
199-
+ "/integration-tests/src/test/resources/wdt/config.cluster.topology.yaml";
197+
// String wdttemplate =
198+
// BaseTest.getProjectRoot()
199+
// + "/integration-tests/src/test/resources/wdt/config.cluster.topology.yaml";
200200
logger.info("Creating Operator & waiting for the script to complete execution");
201201
if (operator1 == null) {
202202
operator1 = TestUtils.createOperator(OPERATOR1_YAML);
@@ -212,17 +212,25 @@ public void testCreateDomainTwoClusterWDTInImage() throws Exception {
212212
&& ((String) domainMap.get("loadBalancer")).equalsIgnoreCase("VOYAGER"))) {
213213
domainMap.put("voyagerWebPort", new Integer("30377"));
214214
}
215-
addCluster2ToDomainTemplate();
216-
logger.log(Level.INFO, "Making a backup of the wdt template file:{0}", wdttemplate);
217-
if (!Files.exists(Paths.get(wdttemplate + ".org"))) {
218-
Files.copy(Paths.get(wdttemplate), Paths.get(wdttemplate + ".org"));
219-
}
220-
Files.copy(
221-
Paths.get(
222-
BaseTest.getProjectRoot()
223-
+ "/integration-tests/src/test/resources/multipleclusters/wdtmultipledynclusters.yml"),
224-
Paths.get(wdttemplate),
225-
StandardCopyOption.REPLACE_EXISTING);
215+
domainMap.put(
216+
"customWdtTemplate",
217+
BaseTest.getProjectRoot()
218+
+ "/integration-tests/src/test/resources/multipleclusters/wdtmultipledynclusters.yml");
219+
domainMap.put(
220+
"customDomainTemplate",
221+
BaseTest.getProjectRoot() + "/integration-tests/src/test/resources/multipleclusters/");
222+
addCluster2ToDomainTemplate(domainMap);
223+
// logger.log(Level.INFO, "Making a backup of the wdt template file:{0}", wdttemplate);
224+
// if (!Files.exists(Paths.get(wdttemplate + ".org"))) {
225+
// Files.copy(Paths.get(wdttemplate), Paths.get(wdttemplate + ".org"));
226+
// }
227+
// Files.copy(
228+
// Paths.get(
229+
// BaseTest.getProjectRoot()
230+
// +
231+
// "/integration-tests/src/test/resources/multipleclusters/wdtmultipledynclusters.yml"),
232+
// Paths.get(wdttemplate),
233+
// StandardCopyOption.REPLACE_EXISTING);
226234
domain = TestUtils.createDomain(domainMap);
227235
domain.verifyDomainCreated();
228236
String pods[] = {
@@ -242,14 +250,14 @@ public void testCreateDomainTwoClusterWDTInImage() throws Exception {
242250
if (domain != null && !SMOKETEST && (JENKINS || testCompletedSuccessfully)) {
243251
domain.destroy();
244252
}
245-
restoreDomainTemplate();
246-
if (Files.exists(Paths.get(wdttemplate + ".org"))) {
247-
Files.copy(
248-
Paths.get(wdttemplate + ".org"),
249-
Paths.get(wdttemplate),
250-
StandardCopyOption.REPLACE_EXISTING);
251-
Files.deleteIfExists(Paths.get(wdttemplate + ".org"));
252-
}
253+
// restoreDomainTemplate();
254+
// if (Files.exists(Paths.get(wdttemplate + ".org"))) {
255+
// Files.copy(
256+
// Paths.get(wdttemplate + ".org"),
257+
// Paths.get(wdttemplate),
258+
// StandardCopyOption.REPLACE_EXISTING);
259+
// Files.deleteIfExists(Paths.get(wdttemplate + ".org"));
260+
// }
253261
}
254262
logger.log(Level.INFO, "SUCCESS - {0}", testMethodName);
255263
}
@@ -259,17 +267,18 @@ public void testCreateDomainTwoClusterWDTInImage() throws Exception {
259267
*
260268
* @throws IOException when append fails
261269
*/
262-
private void addCluster2ToDomainTemplate() throws IOException {
270+
private void addCluster2ToDomainTemplate(Map<String, Object> domainMap) throws IOException {
263271
String add =
264272
" - clusterName: %CLUSTER_NAME%-2\n"
265273
+ " serverStartState: \"RUNNING\"\n"
266274
+ " replicas: %INITIAL_MANAGED_SERVER_REPLICAS%\n";
267-
logger.info("Making a backup of the domain template file:" + template);
268-
if (!Files.exists(Paths.get(template + ".org"))) {
269-
Files.copy(Paths.get(template), Paths.get(template + ".org"));
270-
}
271-
Files.write(Paths.get(template), add.getBytes(), StandardOpenOption.APPEND);
272-
byte[] readAllBytes = Files.readAllBytes(Paths.get(template));
275+
String customDomainTemplate =
276+
System.getProperty("java.io.tmpdir") + "/customDomainTemplate.yaml";
277+
Files.copy(
278+
Paths.get(template), Paths.get(customDomainTemplate), StandardCopyOption.REPLACE_EXISTING);
279+
Files.write(Paths.get(customDomainTemplate), add.getBytes(), StandardOpenOption.APPEND);
280+
domainMap.put("customDomainTemplate", customDomainTemplate);
281+
byte[] readAllBytes = Files.readAllBytes(Paths.get(customDomainTemplate));
273282
logger.info(new String(readAllBytes, StandardCharsets.UTF_8));
274283
}
275284

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

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,13 @@ protected void initialize(Map<String, Object> inputDomainMap) throws Exception {
13921392
TestUtils.exec(
13931393
"cp -rf " + BaseTest.getProjectRoot() + "/kubernetes/samples " + BaseTest.getResultDir());
13941394

1395+
if (inputDomainMap.containsKey("customDomainTemplate")) {
1396+
Files.copy(
1397+
Paths.get((String) inputDomainMap.get("customDomainTemplate")),
1398+
Paths.get(
1399+
BaseTest.getResultDir() + "/kubernetes/samples/scripts/common/domain-template.yaml"));
1400+
}
1401+
13951402
this.voyager =
13961403
(System.getenv("LB_TYPE") != null && System.getenv("LB_TYPE").equalsIgnoreCase("VOYAGER"))
13971404
|| (inputDomainMap.containsKey("loadBalancer")
@@ -1708,29 +1715,31 @@ private void changeClusterTypeInCreateDomainJobTemplate() throws Exception {
17081715

17091716
// change CLUSTER_TYPE to CONFIGURED in create-domain-job-template.yaml for configured cluster
17101717
// as samples only support DYNAMIC cluster
1711-
if (clusterType.equalsIgnoreCase("CONFIGURED")) {
1712-
1713-
// domain in image
1714-
if (domainMap.containsKey("domainHomeImageBase")
1715-
&& domainHomeImageBuildPath.contains("wdt")) {
1716-
TestUtils.copyFile(
1717-
BaseTest.getProjectRoot()
1718-
+ "/integration-tests/src/test/resources/wdt/config.cluster.topology.yaml",
1719-
BaseTest.getResultDir()
1720-
+ "/docker-images/OracleWebLogic/samples/12213-domain-home-in-image-wdt/simple-topology.yaml");
1721-
ExecResult exec =
1722-
TestUtils.exec(
1723-
"cat "
1724-
+ BaseTest.getResultDir()
1725-
+ "/docker-images/OracleWebLogic/samples/12213-domain-home-in-image-wdt/simple-topology.yaml");
1726-
logger.info(exec.stdout());
1727-
} else {
1728-
// domain on pv
1729-
StringBuffer createDomainJobTemplateFile = new StringBuffer(BaseTest.getResultDir());
1730-
createDomainJobTemplateFile.append(
1731-
"/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain-job-template.yaml");
1732-
TestUtils.exec("sed -i -e 's?DYNAMIC?CONFIGURED?g' " + createDomainJobTemplateFile);
1718+
1719+
// domain in image
1720+
if (domainMap.containsKey("domainHomeImageBase") && domainHomeImageBuildPath.contains("wdt")) {
1721+
String wdtTemplatePath =
1722+
BaseTest.getProjectRoot()
1723+
+ "/integration-tests/src/test/resources/wdt/config.cluster.topology.yaml";
1724+
if (domainMap.containsKey("customWdtTemplate")) {
1725+
wdtTemplatePath = (String) domainMap.get("customWdtTemplate");
17331726
}
1727+
TestUtils.copyFile(
1728+
wdtTemplatePath,
1729+
BaseTest.getResultDir()
1730+
+ "/docker-images/OracleWebLogic/samples/12213-domain-home-in-image-wdt/simple-topology.yaml");
1731+
ExecResult exec =
1732+
TestUtils.exec(
1733+
"cat "
1734+
+ BaseTest.getResultDir()
1735+
+ "/docker-images/OracleWebLogic/samples/12213-domain-home-in-image-wdt/simple-topology.yaml");
1736+
logger.info(exec.stdout());
1737+
} else if (clusterType.equalsIgnoreCase("CONFIGURED")) {
1738+
// domain on pv
1739+
StringBuffer createDomainJobTemplateFile = new StringBuffer(BaseTest.getResultDir());
1740+
createDomainJobTemplateFile.append(
1741+
"/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain-job-template.yaml");
1742+
TestUtils.exec("sed -i -e 's?DYNAMIC?CONFIGURED?g' " + createDomainJobTemplateFile);
17341743
}
17351744
}
17361745

0 commit comments

Comments
 (0)