Skip to content

Commit 7b83b11

Browse files
committed
fix the DomainCRD
1 parent 706f70b commit 7b83b11

File tree

2 files changed

+220
-277
lines changed

2 files changed

+220
-277
lines changed

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

Lines changed: 14 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.nio.file.Files;
1010
import java.nio.file.Path;
1111
import java.nio.file.Paths;
12+
import java.util.HashMap;
1213
import java.util.Map;
1314
import java.util.logging.Level;
1415
import oracle.kubernetes.operator.utils.Domain;
@@ -36,6 +37,7 @@ public class ITPodsRestart extends BaseTest {
3637
private static Operator operator1;
3738
private static String domainUid = "";
3839
private static String restartTmpDir = "";
40+
private static String originalYaml;
3941

4042
/**
4143
* This method gets called only once before any of the test methods are executed. It does the
@@ -59,6 +61,11 @@ public static void staticPrepare() throws Exception {
5961
Files.createDirectories(Paths.get(restartTmpDir));
6062

6163
domain = createPodsRestartdomain();
64+
originalYaml =
65+
BaseTest.getUserProjectsDir()
66+
+ "/weblogic-domains/"
67+
+ domain.getDomainUid()
68+
+ "/domain.yaml";
6269
Assert.assertNotNull(domain);
6370
}
6471
}
@@ -319,20 +326,19 @@ public void testAdminServerRestartVersions() throws Exception {
319326
Assume.assumeFalse(QUICKTEST);
320327
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
321328
logTestBegin(testMethodName);
322-
String originalYaml =
323-
BaseTest.getUserProjectsDir()
324-
+ "/weblogic-domains/"
325-
+ domain.getDomainUid()
326-
+ "/domain.yaml";
329+
327330
try {
328331
logger.info("Modifying the Domain CRD..");
329332
DomainCRD crd = new DomainCRD(originalYaml);
330-
String yaml = crd.addObjectNodeToAdminServer("restartVersion", "v1.1");
331-
logger.info(yaml);
333+
Map<String, String> admin = new HashMap();
334+
admin.put("restartVersion", "v1.1");
335+
crd.addObjectNodeToAdminServer(admin);
336+
String modYaml = crd.getYamlTree();
337+
logger.info(modYaml);
332338
Path path = Paths.get(restartTmpDir, "restart.admin.yaml");
333339
logger.log(Level.INFO, "Path of the modified domain.yaml :{0}", path.toString());
334340
Charset charset = StandardCharsets.UTF_8;
335-
Files.write(path, yaml.getBytes(charset));
341+
Files.write(path, modYaml.getBytes(charset));
336342
logger.log(Level.INFO, "Running kubectl apply -f {0}", path.toString());
337343
ExecResult exec = TestUtils.exec("kubectl apply -f " + path.toString());
338344
logger.info(exec.stdout());
@@ -347,104 +353,6 @@ public void testAdminServerRestartVersions() throws Exception {
347353
logger.info("SUCCESS - " + testMethodName);
348354
}
349355

350-
// @Test
351-
public void testClusterRestartVersions() throws Exception {
352-
Assume.assumeFalse(QUICKTEST);
353-
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
354-
logTestBegin(testMethodName);
355-
ExecResult result;
356-
String originalYaml =
357-
BaseTest.getUserProjectsDir()
358-
+ "/weblogic-domains/"
359-
+ domain.getDomainUid()
360-
+ "/domain.yaml";
361-
try {
362-
result =
363-
TestUtils.exec(
364-
"kubectl get Domain "
365-
+ domain.getDomainUid()
366-
+ " -n "
367-
+ domain.getDomainNS()
368-
+ " --output json");
369-
DomainCRD parser = new DomainCRD();
370-
String yaml =
371-
parser.addRestartVersionToCluster(
372-
result.stdout(), domain.getDomainMap().get("clusterName").toString(), "v1.1");
373-
Path path = Paths.get(restartTmpDir, "restart.cluster.yaml");
374-
Charset charset = StandardCharsets.UTF_8;
375-
Files.write(path, yaml.getBytes(charset));
376-
result = TestUtils.exec("kubectl apply -f " + path.toString());
377-
// TODO - verify that the pod is restarting
378-
} finally {
379-
result = TestUtils.exec("kubectl apply -f " + originalYaml);
380-
}
381-
logger.info("SUCCESS - " + testMethodName);
382-
}
383-
384-
// @Test
385-
public void testMSRestartVersions() throws Exception {
386-
Assume.assumeFalse(QUICKTEST);
387-
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
388-
logTestBegin(testMethodName);
389-
ExecResult result;
390-
String originalYaml =
391-
BaseTest.getUserProjectsDir()
392-
+ "/weblogic-domains/"
393-
+ domain.getDomainUid()
394-
+ "/domain.yaml";
395-
try {
396-
result =
397-
TestUtils.exec(
398-
"kubectl get Domain "
399-
+ domain.getDomainUid()
400-
+ " -n "
401-
+ domain.getDomainNS()
402-
+ " --output json");
403-
DomainCRD parser = new DomainCRD();
404-
String yaml = parser.addRestartVersionToMS(result.stdout(), "managed-server1", "v1.1");
405-
Path path = Paths.get(restartTmpDir, "restart.ms.yaml");
406-
Charset charset = StandardCharsets.UTF_8;
407-
Files.write(path, yaml.getBytes(charset));
408-
result = TestUtils.exec("kubectl apply -f " + path.toString());
409-
// TODO - verify that the pod is restarting
410-
} finally {
411-
result = TestUtils.exec("kubectl apply -f " + originalYaml);
412-
}
413-
logger.info("SUCCESS - " + testMethodName);
414-
}
415-
416-
// @Test
417-
public void testDomainRestartVersions() throws Exception {
418-
Assume.assumeFalse(QUICKTEST);
419-
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
420-
logTestBegin(testMethodName);
421-
ExecResult result;
422-
String originalYaml =
423-
BaseTest.getUserProjectsDir()
424-
+ "/weblogic-domains/"
425-
+ domain.getDomainUid()
426-
+ "/domain.yaml";
427-
try {
428-
result =
429-
TestUtils.exec(
430-
"kubectl get Domain "
431-
+ domain.getDomainUid()
432-
+ " -n "
433-
+ domain.getDomainNS()
434-
+ " --output json");
435-
DomainCRD parser = new DomainCRD();
436-
String yaml = parser.addRestartVersionToDomain(result.stdout(), "v1.1");
437-
Path path = Paths.get(restartTmpDir, "restart.ms.yaml");
438-
Charset charset = StandardCharsets.UTF_8;
439-
Files.write(path, yaml.getBytes(charset));
440-
result = TestUtils.exec("kubectl apply -f " + path.toString());
441-
// TODO - verify that the pod is restarting
442-
} finally {
443-
result = TestUtils.exec("kubectl apply -f " + originalYaml);
444-
}
445-
logger.info("SUCCESS - " + testMethodName);
446-
}
447-
448356
private static Domain createPodsRestartdomain() throws Exception {
449357

450358
Map<String, Object> domainMap = TestUtils.loadYaml(DOMAINONPV_WLST_YAML);

0 commit comments

Comments
 (0)