-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement Request 37123351 - [36572474->14.1.2.0.1] ENH: Add servic…
…e guardian property to enable reducing the frequency of thread dumps in log (14.1.2.0 cl 112624 --> ce/14.1.2.0) [git-p4: depot-paths = "//dev/coherence-ce/release/coherence-ce-v14.1.2.0/": change = 113199]
- Loading branch information
Showing
2 changed files
with
150 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
prj/test/unit/coherence-core-tests/src/test/java/com/tangosol/net/GuardSupportTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. | ||
* | ||
* Licensed under the Universal Permissive License v 1.0 as shown at | ||
* https://oss.oracle.com/licenses/upl. | ||
*/ | ||
package com.tangosol.net; | ||
|
||
import com.oracle.coherence.common.util.Duration; | ||
|
||
import com.oracle.coherence.testing.SystemPropertyResource; | ||
|
||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.Matchers.lessThan; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static com.oracle.coherence.common.util.Duration.Magnitude.MILLI; | ||
import static com.tangosol.net.GuardSupport.PROP_LOG_THREADDUMP_INTERVAL; | ||
|
||
/** | ||
* Unit tests for GuardSupport. | ||
* | ||
* @since 25.03 | ||
* @author jf 2024.10.1 | ||
*/ | ||
public class GuardSupportTest | ||
{ | ||
@Test | ||
public void testOverrideLogThreadDumpInterval() | ||
{ | ||
final String TEST_LOG_THREADDUMP_INTERVAL = "1h"; | ||
|
||
try (SystemPropertyResource resource = new SystemPropertyResource(PROP_LOG_THREADDUMP_INTERVAL, TEST_LOG_THREADDUMP_INTERVAL)) | ||
{ | ||
assertThat(GuardSupport.getLogThreaddumpIntervalMs(), is(new Duration(TEST_LOG_THREADDUMP_INTERVAL).as(MILLI))); | ||
} | ||
} | ||
|
||
@Test | ||
public void testDefaultLogThreadDumpInterval() | ||
{ | ||
System.clearProperty(PROP_LOG_THREADDUMP_INTERVAL); | ||
assertThat(GuardSupport.getLogThreaddumpIntervalMs(), is(new Duration(GuardSupport.DEFAULT_LOG_THREADDUMP_INTERVAL).as(MILLI))); | ||
} | ||
|
||
@Test | ||
public void testCeilingForLogThreadDumpInterval() | ||
{ | ||
final String TEST_LOG_THREADDUMP_INTERVAL = "5d"; | ||
|
||
assertThat(GuardSupport.MAX_LOG_THREADDUMP_INTERVAL_MS, lessThan(new Duration(TEST_LOG_THREADDUMP_INTERVAL).as(MILLI))); | ||
try (SystemPropertyResource resource = new SystemPropertyResource(PROP_LOG_THREADDUMP_INTERVAL, TEST_LOG_THREADDUMP_INTERVAL)) | ||
{ | ||
long ldtInterval = GuardSupport.getLogThreaddumpIntervalMs(); | ||
|
||
assertThat(ldtInterval, is(GuardSupport.MAX_LOG_THREADDUMP_INTERVAL_MS)); | ||
assertThat(ldtInterval, lessThan(new Duration(TEST_LOG_THREADDUMP_INTERVAL).as(MILLI))); | ||
} | ||
} | ||
|
||
@Test | ||
public void testDefaultOnInvalidValueForLogThreadDumpInterval() | ||
{ | ||
final String TEST_LOG_THREADDUMP_INTERVAL = "invalidDuration"; | ||
|
||
try (SystemPropertyResource resource = new SystemPropertyResource(PROP_LOG_THREADDUMP_INTERVAL, TEST_LOG_THREADDUMP_INTERVAL)) | ||
{ | ||
assertThat(GuardSupport.getLogThreaddumpIntervalMs(), is(new Duration(GuardSupport.DEFAULT_LOG_THREADDUMP_INTERVAL).as(MILLI))); | ||
} | ||
} | ||
} |