Skip to content

SOLR-18188: Misc test fixes#4496

Merged
dsmiley merged 7 commits into
apache:mainfrom
dsmiley:misc-test-fixes
Jun 5, 2026
Merged

SOLR-18188: Misc test fixes#4496
dsmiley merged 7 commits into
apache:mainfrom
dsmiley:misc-test-fixes

Conversation

@dsmiley

@dsmiley dsmiley commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

A set of test-related misc fixes / docs that I didn't want to include in #4451 and that which weren't PR/commit worthy by themselves.

I'll merge this in a couple days with a lengthy commit message.

dsmiley and others added 7 commits June 1, 2026 00:23
- PrepRecoveryOp: add class-level javadoc
- ShowFileRequestHandlerTest, TestPrometheusResponseWriter, TestCborDataFormat: close response streams to fix resource leaks
- TestDistributedTracing: retry logic for span assertions to reduce flakiness

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
setSoTimeout(1000) is classic "fix the thread that won't die during test teardown" advice. The accept loop in SocketProxy blocks indefinitely on
serverSocket.accept(). Without a timeout, when the test calls close(), the acceptor thread is stuck in accept() and can't notice it should stop — it lingers until the JVM
exits or some other socket event breaks it out. This causes test hangs or "thread leaked" warnings from the Solr test framework.
Move proxy.close() from the finally block to before server.stop(). If
proxy.close() stays in the finally block and qtp.join() blocks
indefinitely (e.g. stuck PrepRecoveryOp handlers or H2C session
threads), the finally block is never reached and the SocketProxy
acceptor thread leaks. Closing the proxy first ensures cleanup even
when server shutdown hangs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dsmiley dsmiley merged commit 8c49326 into apache:main Jun 5, 2026
5 of 6 checks passed
@dsmiley dsmiley deleted the misc-test-fixes branch June 5, 2026 20:01
dsmiley added a commit that referenced this pull request Jun 9, 2026
Accumulated from several commits on the misc-test-fixes branch.

PrepRecoveryOp: add class-level javadoc to explain its purpose.

ShowFileRequestHandlerTest, TestPrometheusResponseWriter,
TestCborDataFormat: close response streams to fix resource leaks
flagged by the test framework.

TestDistributedTracing: add retry logic around span assertions to
reduce flakiness caused by timing-sensitive telemetry delivery.

SocketProxy: call setSoTimeout(1000) on the server socket so the
accept loop unblocks promptly when close() is called. Without a
timeout the acceptor thread blocks indefinitely in accept() and
leaks, causing test hangs or "thread leaked" warnings.

JettySolrRunner: move proxy.close() to before server.stop() rather
than leaving it in the finally block. If qtp.join() hangs (e.g. stuck
PrepRecoveryOp handlers or H2C session threads) the finally block is
never reached, leaving the SocketProxy acceptor thread leaked. Closing
the proxy first ensures cleanup even when server shutdown hangs.

HttpJettySolrClientCompatibilityTest: switch from @ClassRule to @rule
so the Jetty server lifecycle is per-test as intended.

TestSolrJ: delete this file -- it contains no actual tests.

ClientUtils: add Objects.requireNonNull() guard on serverRootUrl to
surface null earlier with a clear error rather than a cryptic NPE
downstream.

AbstractFullDistribZkTestBase: wrap control-collection creation in
RetryUtil.retryOnException() to tolerate transient ZooKeeper errors
during setup. Also move coreClients.clear(),
solrClientByCollection.clear(), and super.destroyServers() into a
finally block after ExecutorUtil.shutdownAndAwaitTermination() so
teardown always completes even if the executor shutdown throws.

HttpPartitionTest: decrease leaderConflictResolveWait to 10sec so 
stale PrepRecoveryOp handlers time out within the Jetty graceful stop window

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants