Skip to content

Commit 19e9b4a

Browse files
committed
changes as per Vanaja's comments
1 parent 6d993cd commit 19e9b4a

File tree

3 files changed

+39
-46
lines changed

3 files changed

+39
-46
lines changed

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

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import static org.junit.Assert.assertTrue;
77

8-
import java.io.IOException;
98
import java.nio.file.Files;
109
import java.nio.file.Paths;
1110
import java.nio.file.StandardCopyOption;
@@ -34,7 +33,7 @@ public class ITMultipleClusters extends BaseTest {
3433
private static final String TWO_CONFIGURED_CLUSTER_SCRIPT =
3534
"create-domain-two-configured-cluster.py";
3635
private static final String TWO_MIXED_CLUSTER_SCRIPT = "create-domain-two-mixed-cluster.py";
37-
private static String template;
36+
private static String customDomainTemplate;
3837
private static final String DOMAINUID = "twoconfigclustdomain";
3938

4039
/**
@@ -48,8 +47,16 @@ public class ITMultipleClusters extends BaseTest {
4847
public static void staticPrepare() throws Exception {
4948
// initialize test properties and create the directories
5049
initialize(APP_PROPS_FILE);
51-
template =
50+
String template =
5251
BaseTest.getProjectRoot() + "/kubernetes/samples/scripts/common/domain-template.yaml";
52+
String add =
53+
" - clusterName: %CLUSTER_NAME%-2\n"
54+
+ " serverStartState: \"RUNNING\"\n"
55+
+ " replicas: %INITIAL_MANAGED_SERVER_REPLICAS%\n";
56+
customDomainTemplate = BaseTest.getResultDir() + "/customDomainTemplate.yaml";
57+
Files.copy(
58+
Paths.get(template), Paths.get(customDomainTemplate), StandardCopyOption.REPLACE_EXISTING);
59+
Files.write(Paths.get(customDomainTemplate), add.getBytes(), StandardOpenOption.APPEND);
5360
}
5461

5562
/**
@@ -89,6 +96,7 @@ public void testCreateDomainTwoConfiguredCluster() throws Exception {
8996
Map<String, Object> domainMap = TestUtils.loadYaml(DOMAINONPV_WLST_YAML);
9097
domainMap.put("domainUID", DOMAINUID);
9198
domainMap.put("clusterType", "CONFIGURED");
99+
domainMap.put("customDomainTemplate", customDomainTemplate);
92100
domainMap.put(
93101
"createDomainPyScript",
94102
"integration-tests/src/test/resources/domain-home-on-pv/"
@@ -98,7 +106,6 @@ public void testCreateDomainTwoConfiguredCluster() throws Exception {
98106
&& ((String) domainMap.get("loadBalancer")).equalsIgnoreCase("VOYAGER"))) {
99107
domainMap.put("voyagerWebPort", new Integer("30366"));
100108
}
101-
addCluster2ToDomainTemplate(domainMap);
102109
domain = TestUtils.createDomain(domainMap);
103110
domain.verifyDomainCreated();
104111
String pods[] = {
@@ -110,7 +117,6 @@ public void testCreateDomainTwoConfiguredCluster() throws Exception {
110117
DOMAINUID + "-new-managed-server2",
111118
};
112119
verifyServersStatus(domain, pods);
113-
114120
testBasicUseCases(domain);
115121
if (!SMOKETEST) {
116122
domain.testWlsLivenessProbe();
@@ -146,6 +152,7 @@ public void testCreateDomainTwoMixedCluster() throws Exception {
146152
try {
147153
Map<String, Object> domainMap = TestUtils.loadYaml(DOMAINONPV_WLST_YAML);
148154
domainMap.put("domainUID", DOMAINUID);
155+
domainMap.put("customDomainTemplate", customDomainTemplate);
149156
domainMap.put(
150157
"createDomainPyScript",
151158
"integration-tests/src/test/resources/domain-home-on-pv/" + TWO_MIXED_CLUSTER_SCRIPT);
@@ -154,7 +161,6 @@ public void testCreateDomainTwoMixedCluster() throws Exception {
154161
&& ((String) domainMap.get("loadBalancer")).equalsIgnoreCase("VOYAGER"))) {
155162
domainMap.put("voyagerWebPort", new Integer("30377"));
156163
}
157-
addCluster2ToDomainTemplate(domainMap);
158164
domain = TestUtils.createDomain(domainMap);
159165
domain.verifyDomainCreated();
160166
String pods[] = {
@@ -200,6 +206,7 @@ public void testCreateDomainTwoClusterWDTInImage() throws Exception {
200206
try {
201207
Map<String, Object> domainMap = TestUtils.loadYaml(DOMAININIMAGE_WDT_YAML);
202208
domainMap.put("domainUID", DOMAINUID);
209+
domainMap.put("customDomainTemplate", customDomainTemplate);
203210
if ((System.getenv("LB_TYPE") != null && System.getenv("LB_TYPE").equalsIgnoreCase("VOYAGER"))
204211
|| (domainMap.containsKey("loadBalancer")
205212
&& ((String) domainMap.get("loadBalancer")).equalsIgnoreCase("VOYAGER"))) {
@@ -209,7 +216,6 @@ public void testCreateDomainTwoClusterWDTInImage() throws Exception {
209216
"customWdtTemplate",
210217
BaseTest.getProjectRoot()
211218
+ "/integration-tests/src/test/resources/multipleclusters/wdtmultipledynclusters.yml");
212-
addCluster2ToDomainTemplate(domainMap);
213219
domain = TestUtils.createDomain(domainMap);
214220
domain.verifyDomainCreated();
215221
String pods[] = {
@@ -233,24 +239,6 @@ public void testCreateDomainTwoClusterWDTInImage() throws Exception {
233239
logger.log(Level.INFO, "SUCCESS - {0}", testMethodName);
234240
}
235241

236-
/**
237-
* Append a second cluster to the domain template
238-
*
239-
* @throws IOException when append fails
240-
*/
241-
private void addCluster2ToDomainTemplate(Map<String, Object> domainMap) throws IOException {
242-
String add =
243-
" - clusterName: %CLUSTER_NAME%-2\n"
244-
+ " serverStartState: \"RUNNING\"\n"
245-
+ " replicas: %INITIAL_MANAGED_SERVER_REPLICAS%\n";
246-
String customDomainTemplate =
247-
System.getProperty("java.io.tmpdir") + "/customDomainTemplate.yaml";
248-
Files.copy(
249-
Paths.get(template), Paths.get(customDomainTemplate), StandardCopyOption.REPLACE_EXISTING);
250-
Files.write(Paths.get(customDomainTemplate), add.getBytes(), StandardOpenOption.APPEND);
251-
domainMap.put("customDomainTemplate", customDomainTemplate);
252-
}
253-
254242
/**
255243
* Verifies all of the servers in the cluster are in Running status
256244
*

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,12 @@ public void testDomainInImageUsingWDT() throws Exception {
482482
Domain domain = null;
483483
boolean testCompletedSuccessfully = false;
484484
try {
485-
domain = TestUtils.createDomain(DOMAININIMAGE_WDT_YAML);
485+
Map<String, Object> domainMap = TestUtils.loadYaml(DOMAININIMAGE_WDT_YAML);
486+
domainMap.put(
487+
"customWdtTemplate",
488+
BaseTest.getProjectRoot()
489+
+ "/integration-tests/src/test/resources/wdt/config.cluster.topology.yaml");
490+
domain = TestUtils.createDomain(domainMap);
486491
domain.verifyDomainCreated();
487492

488493
testBasicUseCases(domain);

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.Map;
2323
import java.util.Objects;
2424
import java.util.StringTokenizer;
25+
import java.util.logging.Level;
2526
import java.util.logging.Logger;
2627
import javax.jms.ConnectionFactory;
2728
import javax.jms.QueueConnection;
@@ -1393,17 +1394,7 @@ protected void initialize(Map<String, Object> inputDomainMap) throws Exception {
13931394
TestUtils.exec(
13941395
"cp -rf " + BaseTest.getProjectRoot() + "/kubernetes/samples " + BaseTest.getResultDir());
13951396

1396-
if (inputDomainMap.containsKey("customDomainTemplate")) {
1397-
Files.copy(
1398-
Paths.get((String) inputDomainMap.get("customDomainTemplate")),
1399-
Paths.get(BaseTest.getResultDir() + "/samples/scripts/common/domain-template.yaml"),
1400-
StandardCopyOption.REPLACE_EXISTING);
1401-
}
1402-
logger.info("Domain Template");
1403-
byte[] readAllBytes =
1404-
Files.readAllBytes(
1405-
Paths.get(BaseTest.getResultDir() + "/samples/scripts/common/domain-template.yaml"));
1406-
logger.info(new String(readAllBytes, StandardCharsets.UTF_8));
1397+
copyDomainTemplate(inputDomainMap);
14071398

14081399
this.voyager =
14091400
(System.getenv("LB_TYPE") != null && System.getenv("LB_TYPE").equalsIgnoreCase("VOYAGER"))
@@ -1503,6 +1494,20 @@ protected void initialize(Map<String, Object> inputDomainMap) throws Exception {
15031494
createConfigMapAndSecretForSitConfig();
15041495
}
15051496

1497+
private void copyDomainTemplate(Map<String, Object> inputDomainMap) throws IOException {
1498+
if (inputDomainMap.containsKey("customDomainTemplate")) {
1499+
Files.copy(
1500+
Paths.get((String) inputDomainMap.get("customDomainTemplate")),
1501+
Paths.get(BaseTest.getResultDir() + "/samples/scripts/common/domain-template.yaml"),
1502+
StandardCopyOption.REPLACE_EXISTING);
1503+
}
1504+
logger.log(Level.FINEST, "Domain Template");
1505+
byte[] readAllBytes =
1506+
Files.readAllBytes(
1507+
Paths.get(BaseTest.getResultDir() + "/samples/scripts/common/domain-template.yaml"));
1508+
logger.log(Level.FINEST, new String(readAllBytes, StandardCharsets.UTF_8));
1509+
}
1510+
15061511
private String getNodeHost() throws Exception {
15071512
String cmd =
15081513
"kubectl describe pod "
@@ -1723,23 +1728,18 @@ private void changeClusterTypeInCreateDomainJobTemplate() throws Exception {
17231728
// as samples only support DYNAMIC cluster
17241729

17251730
// domain in image
1726-
if (domainMap.containsKey("domainHomeImageBase") && domainHomeImageBuildPath.contains("wdt")) {
1727-
String wdtTemplatePath =
1728-
BaseTest.getProjectRoot()
1729-
+ "/integration-tests/src/test/resources/wdt/config.cluster.topology.yaml";
1730-
if (domainMap.containsKey("customWdtTemplate")) {
1731-
wdtTemplatePath = (String) domainMap.get("customWdtTemplate");
1732-
}
1731+
String wdtTemplatePath = null;
1732+
if (domainMap.containsKey("customWdtTemplate")) {
17331733
TestUtils.copyFile(
1734-
wdtTemplatePath,
1734+
(String) domainMap.get("customWdtTemplate"),
17351735
BaseTest.getResultDir()
17361736
+ "/docker-images/OracleWebLogic/samples/12213-domain-home-in-image-wdt/simple-topology.yaml");
17371737
ExecResult exec =
17381738
TestUtils.exec(
17391739
"cat "
17401740
+ BaseTest.getResultDir()
17411741
+ "/docker-images/OracleWebLogic/samples/12213-domain-home-in-image-wdt/simple-topology.yaml");
1742-
logger.info(exec.stdout());
1742+
logger.log(Level.FINEST, exec.stdout());
17431743
} else if (clusterType.equalsIgnoreCase("CONFIGURED")) {
17441744
// domain on pv
17451745
StringBuffer createDomainJobTemplateFile = new StringBuffer(BaseTest.getResultDir());

0 commit comments

Comments
 (0)