Skip to content

Commit 895c51d

Browse files
Configure JMS Server logs on PV and verify (#1924)
* configure jms server logs on PV and verify * undo jms logs on pv * fixing rolling restart assertions
1 parent 8660662 commit 895c51d

File tree

6 files changed

+56
-75
lines changed

6 files changed

+56
-75
lines changed

new-integration-tests/src/test/java/oracle/weblogic/kubernetes/ItCoherenceTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,6 @@ private void rollingRestartDomainAndVerify() {
384384
String newRestartVersion = patchDomainResourceWithNewRestartVersion(domainUid, domainNamespace);
385385
logger.info("New restart version : {0}", newRestartVersion);
386386

387-
assertTrue(assertDoesNotThrow(
388-
() -> (verifyRollingRestartOccurred(pods, 1, domainNamespace)),
389-
"More than one pod was restarted at same time"), "Rolling restart failed");
387+
assertTrue(verifyRollingRestartOccurred(pods, 1, domainNamespace), "Rolling restart failed");
390388
}
391389
}

new-integration-tests/src/test/java/oracle/weblogic/kubernetes/ItMiiUpdateDomainConfig.java

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -287,27 +287,8 @@ public void beforeEach() {
287287
@DisplayName("Check the server logs are written on PV, look for string RUNNING in server log")
288288
public void testServerLogsAreOnPV() {
289289

290-
// check server logs are written on PV
291-
String command = "grep RUNNING /shared/logs/" + adminServerName + ".log";
292-
logger.info("Checking server logs are written on PV by running the command {0} on pod {1}, namespace {2}",
293-
command, adminServerPodName, domainNamespace);
294-
V1Pod adminPod = assertDoesNotThrow(() ->
295-
Kubernetes.getPod(domainNamespace, null, adminServerPodName),
296-
"Could not get the admin pod in namespace " + domainNamespace);
297-
298-
ExecResult result = assertDoesNotThrow(() -> Kubernetes.exec(adminPod, null, true,
299-
"/bin/sh", "-c", command),
300-
String.format("Could not execute the command %s in pod %s, namespace %s",
301-
command, adminServerPodName, domainNamespace));
302-
logger.info("Command {0} returned with exit value {1}, stderr {2}, stdout {3}",
303-
command, result.exitValue(), result.stderr(), result.stdout());
304-
305-
// checking for exitValue 0 for success fails sometimes as k8s exec api returns non-zero exit value even on success,
306-
// so checking for exitValue non-zero and stderr not empty for failure, otherwise its success
307-
assertFalse(result.exitValue() != 0 && result.stderr() != null && !result.stderr().isEmpty(),
308-
String.format("Command %s failed with exit value %s, stderr %s, stdout %s",
309-
command, result.exitValue(), result.stderr(), result.stdout()));
310-
290+
// check server logs are written on PV and look for string RUNNING in log
291+
checkLogsOnPV("grep RUNNING /shared/logs/" + adminServerName + ".log", adminServerPodName);
311292
}
312293

313294
/**
@@ -391,10 +372,8 @@ public void testMiiDeleteSystemResources() {
391372
String newRestartVersion = patchDomainResourceWithNewRestartVersion(domainUid, domainNamespace);
392373
logger.log(Level.INFO, "New restart version is {0}", newRestartVersion);
393374

394-
assertTrue(assertDoesNotThrow(
395-
() -> (verifyRollingRestartOccurred(pods, 1, domainNamespace)),
396-
"More than one pod was restarted at same time"),
397-
"Rolling restart failed");
375+
assertTrue(verifyRollingRestartOccurred(pods, 1, domainNamespace),
376+
"Rolling restart failed");
398377

399378
// Even if pods are created, need the service to created
400379
for (int i = 1; i <= replicaCount; i++) {
@@ -411,12 +390,13 @@ public void testMiiDeleteSystemResources() {
411390

412391
/**
413392
* Start a WebLogic domain using model-in-image.
414-
* Create a configmap with sparse JDBC/JMS model files.
393+
* Create a configmap with sparse JDBC/JMS model files using LOG_HOME(which is on PV) ENV var for JMS Server log file.
415394
* Patch the domain resource with the configmap.
416395
* Update the restart version of the domain resource.
417396
* Verify rolling restart of the domain by comparing PodCreationTimestamp
418397
* for all the server pods before and after rolling restart.
419398
* Verify SystemResource configurations using Rest API call to admin server.
399+
* Verify JMS Server logs are written on PV.
420400
*/
421401
@Test
422402
@Order(4)
@@ -455,10 +435,8 @@ public void testMiiAddSystemResources() {
455435
String newRestartVersion = patchDomainResourceWithNewRestartVersion(domainUid, domainNamespace);
456436
logger.log(Level.INFO, "New restart version is {0}", newRestartVersion);
457437

458-
assertTrue(assertDoesNotThrow(
459-
() -> (verifyRollingRestartOccurred(pods, 1, domainNamespace)),
460-
"More than one pod was restarted at same time"),
461-
"Rolling restart failed");
438+
assertTrue(verifyRollingRestartOccurred(pods, 1, domainNamespace),
439+
"Rolling restart failed");
462440

463441
// Even if pods are created, need the service to created
464442
for (int i = 1; i <= replicaCount; i++) {
@@ -474,6 +452,9 @@ public void testMiiAddSystemResources() {
474452
assertTrue(checkSystemResourceConfiguration("JMSSystemResources",
475453
"TestClusterJmsModule2", "200"), "JMSSystemResources not found");
476454
logger.info("Found the JMSSystemResource configuration");
455+
456+
// check JMS logs are written on PV
457+
checkLogsOnPV("ls -ltr /shared/logs/*jms_messages.log", managedServerPrefix + "1");
477458
}
478459

479460
/**
@@ -521,9 +502,7 @@ public void testMiiAddDynmicClusteriWithNoReplica() {
521502
String newRestartVersion = patchDomainResourceWithNewRestartVersion(domainUid, domainNamespace);
522503
logger.log(Level.INFO, "New restart version : {0}", newRestartVersion);
523504

524-
assertTrue(assertDoesNotThrow(
525-
() -> (verifyRollingRestartOccurred(pods, 1, domainNamespace)),
526-
"More than one pod was restarted at same time"),
505+
assertTrue(verifyRollingRestartOccurred(pods, 1, domainNamespace),
527506
"Rolling restart failed");
528507

529508
// The ServerNamePrefix for the new configured cluster is config-server
@@ -599,9 +578,7 @@ public void testMiiAddDynamicCluster() {
599578
// Check if the admin server pod has been restarted
600579
// by comparing the PodCreationTime before and after rolling restart
601580

602-
assertTrue(assertDoesNotThrow(
603-
() -> (verifyRollingRestartOccurred(pods, 1, domainNamespace)),
604-
"More than one pod was restarted at same time"),
581+
assertTrue(verifyRollingRestartOccurred(pods, 1, domainNamespace),
605582
"Rolling restart failed");
606583

607584
// The ServerNamePrefix for the new dynamic cluster is dynamic-server
@@ -676,9 +653,7 @@ public void testMiiAddConfiguredCluster() {
676653
String newRestartVersion = patchDomainResourceWithNewRestartVersion(domainUid, domainNamespace);
677654
logger.log(Level.INFO, "New restart version : {0}", newRestartVersion);
678655

679-
assertTrue(assertDoesNotThrow(
680-
() -> (verifyRollingRestartOccurred(pods, 1, domainNamespace)),
681-
"More than one pod was restarted at same time"),
656+
assertTrue(verifyRollingRestartOccurred(pods, 1, domainNamespace),
682657
"Rolling restart failed");
683658

684659
// The ServerNamePrefix for the new configured cluster is config-server
@@ -744,9 +719,7 @@ public void testMiiUpdateWebLogicCredential() {
744719
logger.info("Wait for domain {0} admin server pod {1} in namespace {2} to be restarted",
745720
domainUid, adminServerPodName, domainNamespace);
746721

747-
assertTrue(assertDoesNotThrow(
748-
() -> (verifyRollingRestartOccurred(pods, 1, domainNamespace)),
749-
"More than one pod was restarted at same time"),
722+
assertTrue(verifyRollingRestartOccurred(pods, 1, domainNamespace),
750723
"Rolling restart failed");
751724

752725
// check if the new credentials are valid and the old credentials are not valid any more
@@ -1030,4 +1003,27 @@ private static void createJobToChangePermissionsOnPvHostPath(String pvName, Stri
10301003
}
10311004
}
10321005

1006+
private void checkLogsOnPV(String commandToExecuteInsidePod, String podName) {
1007+
logger.info("Checking logs are written on PV by running the command {0} on pod {1}, namespace {2}",
1008+
commandToExecuteInsidePod, podName, domainNamespace);
1009+
V1Pod serverPod = assertDoesNotThrow(() ->
1010+
Kubernetes.getPod(domainNamespace, null, podName),
1011+
String.format("Could not get the server Pod {0} in namespace {1}",
1012+
podName, domainNamespace));
1013+
1014+
ExecResult result = assertDoesNotThrow(() -> Kubernetes.exec(serverPod, null, true,
1015+
"/bin/sh", "-c", commandToExecuteInsidePod),
1016+
String.format("Could not execute the command %s in pod %s, namespace %s",
1017+
commandToExecuteInsidePod, podName, domainNamespace));
1018+
logger.info("Command {0} returned with exit value {1}, stderr {2}, stdout {3}",
1019+
commandToExecuteInsidePod, result.exitValue(), result.stderr(), result.stdout());
1020+
1021+
// checking for exitValue 0 for success fails sometimes as k8s exec api returns non-zero exit value even on success,
1022+
// so checking for exitValue non-zero and stderr not empty for failure, otherwise its success
1023+
assertFalse(result.exitValue() != 0 && result.stderr() != null && !result.stderr().isEmpty(),
1024+
String.format("Command %s failed with exit value %s, stderr %s, stdout %s",
1025+
commandToExecuteInsidePod, result.exitValue(), result.stderr(), result.stdout()));
1026+
1027+
}
1028+
10331029
}

new-integration-tests/src/test/java/oracle/weblogic/kubernetes/ItOperatorRestart.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,7 @@ public void testOperatorRestartWhenPodRoll() {
300300
logger.info("Wait for domain {0} server pods in namespace {1} to be restarted",
301301
domainUid, domainNamespace);
302302

303-
assertTrue(assertDoesNotThrow(
304-
() -> (verifyRollingRestartOccurred(pods, 1, domainNamespace)),
305-
"More than one pod was restarted at same time"),
303+
assertTrue(verifyRollingRestartOccurred(pods, 1, domainNamespace),
306304
"Rolling restart failed");
307305

308306
for (int i = 1; i <= replicaCount; i++) {

new-integration-tests/src/test/java/oracle/weblogic/kubernetes/ItPodsRestart.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
9797
// get a unique operator namespace
9898
logger.info("Getting a unique namespace for operator");
9999
assertNotNull(namespaces.get(0), "Namespace list is null");
100-
String opNamespace = namespaces.get(0);
100+
final String opNamespace = namespaces.get(0);
101101

102102
// get a unique domain namespace
103103
logger.info("Getting a unique namespace for WebLogic domain");
@@ -215,9 +215,7 @@ public void testServerPodsRestartByChangingResource() {
215215
// verify the server pods are rolling restarted and back to ready state
216216
logger.info("Verifying rolling restart occurred for domain {0} in namespace {1}",
217217
domainUid, domainNamespace);
218-
assertTrue(assertDoesNotThrow(
219-
() -> verifyRollingRestartOccurred(podsWithTimeStamps, 1, domainNamespace),
220-
"More than one pod was restarted at same time"),
218+
assertTrue(verifyRollingRestartOccurred(podsWithTimeStamps, 1, domainNamespace),
221219
String.format("Rolling restart failed for domain %s in namespace %s", domainUid, domainNamespace));
222220

223221
}
@@ -272,9 +270,7 @@ public void testServerPodsRestartByChangingIncludeServerOutInPodLog() {
272270
// verify the server pods are rolling restarted and back to ready state
273271
logger.info("Verifying rolling restart occurred for domain {0} in namespace {1}",
274272
domainUid, domainNamespace);
275-
assertTrue(assertDoesNotThrow(
276-
() -> verifyRollingRestartOccurred(podsWithTimeStamps, 1, domainNamespace),
277-
"More than one pod was restarted at same time"),
273+
assertTrue(verifyRollingRestartOccurred(podsWithTimeStamps, 1, domainNamespace),
278274
String.format("Rolling restart failed for domain %s in namespace %s", domainUid, domainNamespace));
279275

280276
}
@@ -340,9 +336,7 @@ public void testServerPodsRestartByChangingEnvProperty() {
340336
// verify the server pods are rolling restarted and back to ready state
341337
logger.info("Verifying rolling restart occurred for domain {0} in namespace {1}",
342338
domainUid, domainNamespace);
343-
assertTrue(assertDoesNotThrow(
344-
() -> verifyRollingRestartOccurred(podsWithTimeStamps, 1, domainNamespace),
345-
"More than one pod was restarted at same time"),
339+
assertTrue(verifyRollingRestartOccurred(podsWithTimeStamps, 1, domainNamespace),
346340
String.format("Rolling restart failed for domain %s in namespace %s", domainUid, domainNamespace));
347341

348342
}
@@ -407,9 +401,7 @@ public void testServerPodsRestartByChaningPodSecurityContext() {
407401
// verify the server pods are rolling restarted and back to ready state
408402
logger.info("Verifying rolling restart occurred for domain {0} in namespace {1}",
409403
domainUid, domainNamespace);
410-
assertTrue(assertDoesNotThrow(
411-
() -> verifyRollingRestartOccurred(podsWithTimeStamps, 1, domainNamespace),
412-
"More than one pod was restarted at same time"),
404+
assertTrue(verifyRollingRestartOccurred(podsWithTimeStamps, 1, domainNamespace),
413405
String.format("Rolling restart failed for domain %s in namespace %s", domainUid, domainNamespace));
414406

415407
}
@@ -465,9 +457,7 @@ public void testServerPodsRestartByChangingImagePullPolicy() {
465457
// verify the server pods are rolling restarted and back to ready state
466458
logger.info("Verifying rolling restart occurred for domain {0} in namespace {1}",
467459
domainUid, domainNamespace);
468-
assertTrue(assertDoesNotThrow(
469-
() -> verifyRollingRestartOccurred(podsWithTimeStamps, 1, domainNamespace),
470-
"More than one pod was restarted at same time"),
460+
assertTrue(verifyRollingRestartOccurred(podsWithTimeStamps, 1, domainNamespace),
471461
String.format("Rolling restart failed for domain %s in namespace %s", domainUid, domainNamespace));
472462

473463
}

new-integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/impl/Pod.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import static java.util.concurrent.TimeUnit.SECONDS;
1616
import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
1717
import static org.awaitility.Awaitility.with;
18-
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
1918

2019
public class Pod {
2120

@@ -48,8 +47,7 @@ public static boolean verifyRollingRestartOccurred(Map<String, DateTime> pods, i
4847
namespace,
4948
condition.getElapsedTimeInMS(),
5049
condition.getRemainingTimeInMS()))
51-
.until(assertDoesNotThrow(() -> podRestarted(entry.getKey(), pods, maxUnavailable, namespace),
52-
String.format("pod %s didn't restart in namespace %s", entry.getKey(), namespace)));
50+
.until(podRestarted(entry.getKey(), pods, maxUnavailable, namespace));
5351

5452
// check pods are in ready status
5553
retry
@@ -60,8 +58,7 @@ public static boolean verifyRollingRestartOccurred(Map<String, DateTime> pods, i
6058
namespace,
6159
condition.getElapsedTimeInMS(),
6260
condition.getRemainingTimeInMS()))
63-
.until(assertDoesNotThrow(() -> podReady(namespace, null, entry.getKey()),
64-
String.format("pod %s didn't become ready in namespace %s", entry.getKey(), namespace)));
61+
.until(podReady(namespace, null, entry.getKey()));
6562
}
6663

6764
return true;

new-integration-tests/src/test/resources/wdt-models/model.jms2.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ resources:
66
Target: 'cluster-1'
77
JMSServer:
88
TestClusterJmsServer2:
9-
ProductionPausedAtStartup: false
10-
ConsumptionPausedAtStartup: false
11-
Target: 'cluster-1'
12-
PersistentStore: 'TestClusterFileStore2'
13-
InsertionPausedAtStartup: false
14-
MessageCompressionOptions: GZIP_DEFAULT_COMPRESSION
9+
JmsMessageLogFile:
10+
FileName: "@@ENV:LOG_HOME@@/jms_messages.log"
11+
ProductionPausedAtStartup: false
12+
ConsumptionPausedAtStartup: false
13+
Target: 'cluster-1'
14+
PersistentStore: 'TestClusterFileStore2'
15+
InsertionPausedAtStartup: false
16+
MessageCompressionOptions: GZIP_DEFAULT_COMPRESSION
1517

1618
JMSSystemResource:
1719
TestClusterJmsModule2:

0 commit comments

Comments
 (0)