Skip to content

Commit f8b869f

Browse files
committed
fix
1 parent 2c4fb9a commit f8b869f

File tree

1 file changed

+44
-23
lines changed

1 file changed

+44
-23
lines changed

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

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44

55
package oracle.kubernetes.operator;
66

7+
import static org.junit.Assert.assertTrue;
8+
79
import java.nio.file.Files;
810
import java.nio.file.Paths;
911
import java.nio.file.StandardCopyOption;
1012
import java.nio.file.StandardOpenOption;
1113
import java.util.Map;
1214
import oracle.kubernetes.operator.utils.Domain;
15+
import oracle.kubernetes.operator.utils.K8sTestUtils;
1316
import oracle.kubernetes.operator.utils.Operator;
1417
import oracle.kubernetes.operator.utils.Operator.RESTCertType;
1518
import oracle.kubernetes.operator.utils.TestUtils;
@@ -33,8 +36,9 @@ public class ITMultipleClusters extends BaseTest {
3336

3437
private static Operator operatorForBackwardCompatibility;
3538
private static Operator operatorForRESTCertChain;
36-
39+
3740
private static String TWO_CONFIGURED_CLUSTER_SCRIPT = "create-domain-two-configured-cluster.py";
41+
private static String domainUid = "";
3842

3943
/**
4044
* This method gets called only once before any of the test methods are executed. It does the
@@ -82,7 +86,8 @@ public static void staticUnPrepare() throws Exception {
8286
public void testCreateDomainTwoConfiguredCluster() throws Exception {
8387
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
8488
logTestBegin(testMethodName);
85-
String template = getResultDir() +"/samples/scripts/common/domain-template.yaml";
89+
String template =
90+
BaseTest.getProjectRoot() + "/kubernetes/samples/scripts/common/domain-template.yaml";
8691
logger.info("Creating Operator & waiting for the script to complete execution");
8792
// create operator1
8893
if (operator1 == null) {
@@ -91,35 +96,51 @@ public void testCreateDomainTwoConfiguredCluster() throws Exception {
9196
Domain domain = null;
9297
boolean testCompletedSuccessfully = false;
9398
try {
94-
Map<String, Object> domainMap = TestUtils.loadYaml(DOMAINONPV_WLST_YAML);
99+
Map<String, Object> domainMap = TestUtils.loadYaml(DOMAINONPV_WLST_YAML);
95100
domainMap.put("domainUID", "customsitdomain");
96101
domainMap.put(
97102
"createDomainPyScript",
98-
"integration-tests/src/test/resources/domain-home-on-pv/"+TWO_CONFIGURED_CLUSTER_SCRIPT);
99-
100-
String add = " - clusterName: %CLUSTER_NAME%-2\n" +
101-
" serverStartState: \"RUNNING\"\n" +
102-
" replicas: %INITIAL_MANAGED_SERVER_REPLICAS%\n" +
103-
"~";
104-
Files.copy(Paths.get(template), Paths.get(template+".org"),
105-
StandardCopyOption.REPLACE_EXISTING);
106-
107-
Files.write(
108-
Paths.get(template),
109-
add.getBytes(),
110-
StandardOpenOption.APPEND);
111-
112-
domain = TestUtils.createDomain(DOMAINONPV_WLST_YAML);
103+
"integration-tests/src/test/resources/domain-home-on-pv/"
104+
+ TWO_CONFIGURED_CLUSTER_SCRIPT);
105+
106+
String add =
107+
" - clusterName: %CLUSTER_NAME%-2\n"
108+
+ " serverStartState: \"RUNNING\"\n"
109+
+ " replicas: %INITIAL_MANAGED_SERVER_REPLICAS%\n";
110+
logger.info("Making a backup of the domain template file:" + template);
111+
if (!Files.exists(Paths.get(template + ".org"))) {
112+
Files.copy(Paths.get(template), Paths.get(template + ".org"));
113+
}
114+
logger.info("Appended the domain template file");
115+
Files.write(Paths.get(template), add.getBytes(), StandardOpenOption.APPEND);
116+
logger.info("Appended the domain template file");
117+
domain = TestUtils.createDomain(domainMap);
113118
domain.verifyDomainCreated();
119+
K8sTestUtils testUtil = new K8sTestUtils();
120+
String domain1LabelSelector = String.format("weblogic.domainUID in (%s)", domainUid);
121+
String namespace = domain.getDomainNS();
122+
String pods[] = {
123+
domainUid + "-" + domain.getAdminServerName(),
124+
domainUid + "-managed-server1",
125+
domainUid + "-managed-server2",
126+
domainUid + "new-managed-server1",
127+
domainUid + "new-managed-server2",
128+
};
129+
for (String pod : pods) {
130+
assertTrue(
131+
pod + " Pod not running", testUtil.isPodRunning(namespace, domain1LabelSelector, pod));
132+
}
133+
114134
testBasicUseCases(domain);
115135
if (!SMOKETEST) domain.testWlsLivenessProbe();
116136
testCompletedSuccessfully = true;
117137
} finally {
118-
if (domain != null && !SMOKETEST && (JENKINS || testCompletedSuccessfully))
119-
Files.copy(Paths.get(template+".org"),Paths.get(template),
120-
StandardCopyOption.REPLACE_EXISTING);
121-
domain.shutdownUsingServerStartPolicy();
122-
138+
if (domain != null && !SMOKETEST && (JENKINS || testCompletedSuccessfully)) {
139+
Files.copy(
140+
Paths.get(template + ".org"), Paths.get(template), StandardCopyOption.REPLACE_EXISTING);
141+
Files.delete(Paths.get(template + ".org"));
142+
}
143+
domain.shutdownUsingServerStartPolicy();
123144
}
124145
logger.info("SUCCESS - " + testMethodName);
125146
}

0 commit comments

Comments
 (0)