Skip to content

Commit 3774d79

Browse files
committed
remove duplicate code in JRFDomain.java
1 parent ddc8a38 commit 3774d79

File tree

3 files changed

+8
-151
lines changed

3 files changed

+8
-151
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public void testJRFDomainOnPVUsingWLST() throws Exception {
116116
// TODO: reconsider the logic to check the db readiness
117117
// The jrfdomain can not find the db pod even the db pod shows ready, sleep more time
118118
logger.info("waiting for the db to be visible to rcu script ...");
119-
Thread.sleep(60000);
119+
Thread.sleep(30000);
120120

121121
JRFDomain jrfdomain = null;
122122
boolean testCompletedSuccessfully = false;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ private void callWebAppAndCheckForServerNameInResponse(
12851285
* @throws Exception if removing the results dir fails or if create-domain-inputs.yaml cannot be
12861286
* accessed to read or if creating config map or secret fails for configoverrides
12871287
*/
1288-
private void initialize(Map<String, Object> inputDomainMap) throws Exception {
1288+
protected void initialize(Map<String, Object> inputDomainMap) throws Exception {
12891289
domainMap = inputDomainMap;
12901290
this.userProjectsDir = BaseTest.getUserProjectsDir();
12911291
this.projectRoot = BaseTest.getProjectRoot();

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

Lines changed: 6 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,15 @@
44

55
package oracle.kubernetes.operator.utils;
66

7-
import java.io.File;
8-
import java.io.FileInputStream;
9-
import java.io.InputStream;
107
import java.util.Map;
11-
import java.util.Objects;
128
import oracle.kubernetes.operator.BaseTest;
13-
import org.yaml.snakeyaml.Yaml;
149

1510
/** JRF Domain class with all the utility methods */
1611
public class JRFDomain extends Domain {
1712

1813
private static final String FMWINFRA_DOCKER_IMAGENAME =
1914
"phx.ocir.io/weblogick8s/oracle/fmw-infrastructure";
2015
private static final String FMWINFRA_DOCKER_IMAGETAG = "12.2.1.3";
21-
private static final String OCIR_REPO_SERVER = "phx.ocir.io";
2216

2317
/**
2418
* JRFDomain constructor
@@ -41,6 +35,7 @@ public JRFDomain(String inputYaml) throws Exception {
4135
*/
4236
public JRFDomain(Map<String, Object> inputDomainMap) throws Exception {
4337
initialize(inputDomainMap);
38+
updateDomainMapForJRF();
4439
createPV();
4540
createSecret();
4641
generateInputYaml();
@@ -50,166 +45,28 @@ public JRFDomain(Map<String, Object> inputDomainMap) throws Exception {
5045
}
5146

5247
/**
53-
* initialize the domain creation input properties
48+
* update the domainMap with jrf specific information
5449
*
55-
* @param inputDomainMap - jrf domain input properties map
5650
* @throws Exception - if any error occurs
5751
*/
58-
private void initialize(Map<String, Object> inputDomainMap) throws Exception {
59-
domainMap = inputDomainMap;
60-
this.userProjectsDir = BaseTest.getUserProjectsDir();
61-
this.projectRoot = BaseTest.getProjectRoot();
52+
private void updateDomainMapForJRF() throws Exception {
6253

63-
clusterType = (String) domainMap.getOrDefault("clusterType", "CONFIGURED");
64-
domainMap.put("clusterType", clusterType);
65-
66-
// copy samples to RESULT_DIR
67-
TestUtils.exec(
68-
"cp -rf " + BaseTest.getProjectRoot() + "/kubernetes/samples " + BaseTest.getResultDir());
69-
70-
this.voyager =
71-
System.getenv("LB_TYPE") != null && System.getenv("LB_TYPE").equalsIgnoreCase("VOYAGER");
72-
if (System.getenv("INGRESSPERDOMAIN") != null) {
73-
INGRESSPERDOMAIN = Boolean.parseBoolean(System.getenv("INGRESSPERDOMAIN"));
74-
}
75-
76-
domainMap.put("domainName", domainMap.get("domainUID"));
77-
78-
// read sample domain inputs
79-
String sampleDomainInputsFile =
80-
"/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain-inputs.yaml";
81-
if (domainMap.containsKey("domainHomeImageBase")) {
82-
sampleDomainInputsFile =
83-
"/samples/scripts/create-weblogic-domain/domain-home-in-image/create-domain-inputs.yaml";
84-
}
85-
Yaml dyaml = new Yaml();
86-
InputStream sampleDomainInputStream =
87-
new FileInputStream(new File(BaseTest.getResultDir() + sampleDomainInputsFile));
88-
logger.info(
89-
"loading domain inputs template file " + BaseTest.getResultDir() + sampleDomainInputsFile);
90-
Map<String, Object> sampleDomainMap = dyaml.load(sampleDomainInputStream);
91-
sampleDomainInputStream.close();
92-
93-
// add attributes with default values from sample domain inputs to domain map
94-
sampleDomainMap.forEach(domainMap::putIfAbsent);
95-
96-
domainUid = (String) domainMap.get("domainUID");
97-
// Customize the create domain job inputs
98-
domainNS = (String) domainMap.get("namespace");
99-
adminServerName = (String) domainMap.get("adminServerName");
100-
managedServerNameBase = (String) domainMap.get("managedServerNameBase");
101-
102-
initialManagedServerReplicas =
103-
((Integer) domainMap.get("initialManagedServerReplicas")).intValue();
104-
configuredManagedServerCount =
105-
((Integer) domainMap.get("configuredManagedServerCount")).intValue();
106-
exposeAdminT3Channel = ((Boolean) domainMap.get("exposeAdminT3Channel")).booleanValue();
107-
exposeAdminNodePort = ((Boolean) domainMap.get("exposeAdminNodePort")).booleanValue();
108-
t3ChannelPort = ((Integer) domainMap.get("t3ChannelPort")).intValue();
109-
clusterName = (String) domainMap.get("clusterName");
110-
clusterType = (String) domainMap.get("clusterType");
111-
serverStartPolicy = (String) domainMap.get("serverStartPolicy");
112-
113-
// write hostname in domain input map for public address
114-
if (exposeAdminT3Channel) {
115-
domainMap.put("t3PublicAddress", TestUtils.getHostName());
116-
}
117-
118-
String imageName = FMWINFRA_DOCKER_IMAGENAME;
119-
if (System.getenv("IMAGE_NAME_FMWINFRA") != null) {
120-
imageName = System.getenv("IMAGE_NAME_FMWINFRA");
121-
logger.info("IMAGE_NAME_FMWINFRA " + imageName);
122-
}
123-
124-
String imageTag = FMWINFRA_DOCKER_IMAGETAG;
125-
if (System.getenv("IMAGE_TAG_FMWINFRA") != null) {
126-
imageTag = System.getenv("IMAGE_TAG_FMWINFRA");
127-
logger.info("IMAGE_TAG_FMWINFRA " + imageTag);
128-
}
129-
domainMap.put("logHome", "/shared/logs/" + domainUid);
54+
// jrf specific input parameter
55+
domainMap.put("image", FMWINFRA_DOCKER_IMAGENAME + ":" + FMWINFRA_DOCKER_IMAGETAG);
13056

13157
if (!domainMap.containsKey("domainHomeImageBase")) {
132-
domainMap.put("domainHome", "/shared/domains/" + domainUid);
133-
13458
// update jrf/create-domain-script.sh with domain_name and rcuprefix
13559
TestUtils.replaceStringInFile(
13660
BaseTest.getResultDir() + "/jrf/create-domain-script.sh", "%RCUPREFIX%", domainUid);
13761
TestUtils.replaceStringInFile(
13862
BaseTest.getResultDir() + "/jrf/create-domain-script.sh", "%DOMAIN_NAME%", domainUid);
13963
domainMap.put("createDomainFilesDir", BaseTest.getResultDir() + "/jrf");
140-
domainMap.put("image", imageName + ":" + imageTag);
14164
}
14265

143-
if (domainMap.containsKey("domainHomeImageBuildPath")) {
144-
domainMap.put(
145-
"domainHomeImageBuildPath",
146-
BaseTest.getResultDir() + "/" + domainMap.get("domainHomeImageBuildPath"));
147-
}
14866
if (System.getenv("IMAGE_PULL_SECRET_FMWINFRA") != null) {
14967
domainMap.put("imagePullSecretName", System.getenv("IMAGE_PULL_SECRET_FMWINFRA"));
150-
if (System.getenv("WERCKER") != null) {
151-
// create docker registry secrets
152-
TestUtils.createDockerRegistrySecret(
153-
System.getenv("IMAGE_PULL_SECRET_FMWINFRA"),
154-
System.getenv(OCIR_REPO_SERVER),
155-
System.getenv("OCIR_REPO_USERNAME"),
156-
System.getenv("OCIR_REPO_PASSWORD"),
157-
System.getenv("OCIR_REPO_EMAIL"),
158-
domainNS);
159-
}
16068
} else {
161-
domainMap.put("imagePullSecretName", "docker-store");
162-
}
163-
// remove null values if any attributes
164-
domainMap.values().removeIf(Objects::isNull);
165-
166-
// create config map and secret for custom sit config
167-
if ((domainMap.get("configOverrides") != null)
168-
&& (domainMap.get("configOverridesFile") != null)) {
169-
170-
String configOverridesFile = domainMap.get("configOverridesFile").toString();
171-
172-
String cmd =
173-
"kubectl -n "
174-
+ domainNS
175-
+ " create cm "
176-
+ domainUid
177-
+ "-"
178-
+ domainMap.get("configOverrides")
179-
+ " --from-file "
180-
+ BaseTest.getProjectRoot()
181-
+ configOverridesFile;
182-
ExecResult result = ExecCommand.exec(cmd);
183-
if (result.exitValue() != 0) {
184-
throw new Exception("FAILURE: command " + cmd + " failed, returned " + result.stderr());
185-
}
186-
cmd =
187-
"kubectl -n "
188-
+ domainNS
189-
+ " label cm "
190-
+ domainUid
191-
+ "-"
192-
+ domainMap.get("configOverrides")
193-
+ " weblogic.domainUID="
194-
+ domainUid;
195-
result = ExecCommand.exec(cmd);
196-
if (result.exitValue() != 0) {
197-
throw new Exception("FAILURE: command " + cmd + " failed, returned " + result.stderr());
198-
}
199-
// create secret for custom sit config t3 public address
200-
cmd =
201-
"kubectl -n "
202-
+ domainNS
203-
+ " create secret generic "
204-
+ domainUid
205-
+ "-"
206-
+ "t3publicaddress "
207-
+ " --from-literal=hostname="
208-
+ TestUtils.getHostName();
209-
result = ExecCommand.exec(cmd);
210-
if (result.exitValue() != 0) {
211-
throw new Exception("FAILURE: command " + cmd + " failed, returned " + result.stderr());
212-
}
69+
domainMap.put("imagePullSecretName", "ocir-store}");
21370
}
21471
}
21572
}

0 commit comments

Comments
 (0)