Skip to content

MLE-27388 Added test for 50x retry#1916

Merged
rjrudin merged 1 commit intodevelopfrom
feature/27388-actual-test
Mar 4, 2026
Merged

MLE-27388 Added test for 50x retry#1916
rjrudin merged 1 commit intodevelopfrom
feature/27388-actual-test

Conversation

@rjrudin
Copy link
Contributor

@rjrudin rjrudin commented Mar 4, 2026

No description provided.

@rjrudin rjrudin requested a review from BillFarber as a code owner March 4, 2026 16:33
Copilot AI review requested due to automatic review settings March 4, 2026 16:33
@rjrudin rjrudin requested a review from stevebio as a code owner March 4, 2026 16:33
@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Copyright Validation Results
Total: 4 | Passed: 3 | Failed: 0 | Skipped: 1 | at: 2026-03-04 17:08:22 UTC | commit: ec45dd6

⏭️ Skipped (Excluded) Files

  • marklogic-client-api/src/test/resources/logback-test.xml

✅ Valid Files

  • marklogic-client-api/src/main/java/com/marklogic/client/impl/OkHttpServices.java
  • marklogic-client-api/src/main/java/com/marklogic/client/impl/RetryContext.java
  • marklogic-client-api/src/test/java/com/marklogic/client/impl/okhttp/RetryOn50XResponseTest.java

✅ All files have valid copyright headers!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new JUnit test class intended to validate OkHttp-based retry behavior on 50x responses, and adjusts retry logging so that retry attempts are logged under RetryContext (with corresponding test logback configuration).

Changes:

  • Added RetryOn50XResponseTest that uses a custom OkHttp interceptor to simulate 502 responses and observe retries.
  • Refactored RetryContext to use its own SLF4J logger (via LoggerFactory) instead of receiving a logger instance.
  • Updated OkHttpServices call sites to use the new RetryContext constructor and enabled DEBUG logging for RetryContext in logback-test.xml.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
marklogic-client-api/src/test/resources/logback-test.xml Enables DEBUG logging for RetryContext during tests.
marklogic-client-api/src/test/java/com/marklogic/client/impl/okhttp/RetryOn50XResponseTest.java Adds tests for retry-on-502 behavior via an interceptor.
marklogic-client-api/src/main/java/com/marklogic/client/impl/RetryContext.java Switches retry logging to a class-level logger (no longer injected).
marklogic-client-api/src/main/java/com/marklogic/client/impl/OkHttpServices.java Updates RetryContext instantiations to match the new constructor signature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +74 to +83
@BeforeEach
void setUp() {
// Configure very short retry delays for testing
System.setProperty("com.marklogic.client.retry.maxDelay", "3");
System.setProperty("com.marklogic.client.retry.minRetry", "2");

// "Touch" the Common class to trigger the static block that removes existing configurators on
// DatabaseClientFactory.
Common.newServerPayload();
}
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test sets system properties com.marklogic.client.retry.maxDelay and com.marklogic.client.retry.minRetry, but OkHttpServices reads retry settings from RESTServices.MAX_DELAY_PROP (com.marklogic.client.maximumRetrySeconds) and RESTServices.MIN_RETRY_PROP (com.marklogic.client.minimumRetries). As-is, the test will run with defaults (up to ~120s retry window / 8 minimum retries), which can make it very slow/flaky and may not validate the intended behavior. Update the test to set/clear the actual property keys used by the retry logic (and keep in mind max delay is in seconds, not ms).

Copilot uses AI. Check for mistakes.
Comment on lines +80 to +82
// "Touch" the Common class to trigger the static block that removes existing configurators on
// DatabaseClientFactory.
Common.newServerPayload();
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Common.newServerPayload() is used here only to force Common's static initializer to run and clear existing configurators. That initializer will only run once per JVM, so subsequent test methods won't get any reset behavior from this call. For better test isolation, consider explicitly calling DatabaseClientFactory.removeConfigurators() (and then adding only the configurators this test needs) instead of relying on a one-time class initialization side effect.

Suggested change
// "Touch" the Common class to trigger the static block that removes existing configurators on
// DatabaseClientFactory.
Common.newServerPayload();
// Explicitly remove any previously registered configurators to ensure test isolation.
DatabaseClientFactory.removeConfigurators();

Copilot uses AI. Check for mistakes.
<appender-ref ref="STDOUT" />
</logger>

<logger name="com.marklogic.client.impl.RetryContext" level="DEBUG" additivity="false">
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a DEBUG logger for RetryContext in the shared logback-test.xml will enable verbose retry logging for the entire test suite. If this is only needed while developing/debugging this new test (and the test does not assert on logs), consider removing it or scoping it to just this test to avoid noisy CI output.

Suggested change
<logger name="com.marklogic.client.impl.RetryContext" level="DEBUG" additivity="false">
<logger name="com.marklogic.client.impl.RetryContext" level="WARN" additivity="false">

Copilot uses AI. Check for mistakes.
@rjrudin rjrudin force-pushed the feature/27388-actual-test branch from bec224e to ec45dd6 Compare March 4, 2026 17:07
@rjrudin rjrudin merged commit 61f6540 into develop Mar 4, 2026
5 checks passed
@rjrudin rjrudin deleted the feature/27388-actual-test branch March 4, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants