Skip to content

Commit 5323444

Browse files
committed
merge the changes from develop
1 parent 9ea90ed commit 5323444

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed

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

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44

55
package oracle.kubernetes.operator;
66

7+
import java.nio.charset.Charset;
8+
import java.nio.charset.StandardCharsets;
79
import java.nio.file.Files;
10+
import java.nio.file.Path;
811
import java.nio.file.Paths;
912
import java.util.Map;
1013
import oracle.kubernetes.operator.utils.Domain;
14+
import oracle.kubernetes.operator.utils.DomainCRD;
15+
import oracle.kubernetes.operator.utils.ExecResult;
1116
import oracle.kubernetes.operator.utils.Operator;
1217
import oracle.kubernetes.operator.utils.TestUtils;
1318
import org.junit.AfterClass;
@@ -29,6 +34,7 @@ public class ITPodsRestart extends BaseTest {
2934
private static Domain domain = null;
3035
private static Operator operator1;
3136
private static String domainUid = "";
37+
private static String restartTmpDir = "";
3238

3339
/**
3440
* This method gets called only once before any of the test methods are executed. It does the
@@ -48,6 +54,8 @@ public static void staticPrepare() throws Exception {
4854
if (operator1 == null) {
4955
operator1 = TestUtils.createOperator(OPERATOR1_YAML);
5056
}
57+
restartTmpDir = BaseTest.getResultDir() + "/restarttemp";
58+
Files.createDirectories(Paths.get(restartTmpDir));
5159

5260
domain = createPodsRestartdomain();
5361
Assert.assertNotNull(domain);
@@ -305,6 +313,138 @@ public void testServerPodsRestartByChangingResource() throws Exception {
305313
logger.info("SUCCESS - " + testMethodName);
306314
}
307315

316+
@Test
317+
public void testAdminServerRestartVersions() throws Exception {
318+
Assume.assumeFalse(QUICKTEST);
319+
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
320+
logTestBegin(testMethodName);
321+
String originalYaml =
322+
BaseTest.getUserProjectsDir()
323+
+ "/weblogic-domains/"
324+
+ domain.getDomainUid()
325+
+ "/domain.yaml";
326+
try {
327+
DomainCRD crd = new DomainCRD();
328+
String yaml =
329+
crd.addRestartVersionToAdminServer(
330+
TestUtils.exec(
331+
"kubectl get Domain "
332+
+ domain.getDomainUid()
333+
+ " -n "
334+
+ domain.getDomainNS()
335+
+ " --output json")
336+
.stdout(),
337+
"v1.1");
338+
Path path = Paths.get(restartTmpDir, "restart.admin.yaml");
339+
Charset charset = StandardCharsets.UTF_8;
340+
Files.write(path, yaml.getBytes(charset));
341+
logger.info(TestUtils.exec("kubectl apply -f " + path.toString()).stdout());
342+
domain.verifyAdminServerRestarted();
343+
} finally {
344+
TestUtils.exec("kubectl apply -f " + originalYaml);
345+
domain.verifyAdminServerRestarted();
346+
}
347+
logger.info("SUCCESS - " + testMethodName);
348+
}
349+
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+
308448
private static Domain createPodsRestartdomain() throws Exception {
309449

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

0 commit comments

Comments
 (0)