Skip to content

Speed up TestOnReconnectListenerSupport by porting to SolrCloudTestCase - #4702

Merged
janhoy merged 1 commit into
apache:mainfrom
janhoy:speedup-test-onreconnect-listener
Aug 5, 2026
Merged

Speed up TestOnReconnectListenerSupport by porting to SolrCloudTestCase#4702
janhoy merged 1 commit into
apache:mainfrom
janhoy:speedup-test-onreconnect-listener

Conversation

@janhoy

@janhoy janhoy commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

The test spun up 4 Jetty nodes (1 control + 3 cloud, sliceCount=2/fixShardCount(3)) via the legacy AbstractFullDistribZkTestBase, plus a control collection — yet only ever creates and inspects a 1-shard/1-replica collection.

Rewritten on SolrCloudTestCase with a single node, using the cloud-managed configset (ManagedIndexSchemaFactory, which is what registers ZkIndexSchemaReader as an OnReconnect listener — the behavior under test). All assertions are preserved:

  • ZkIndexSchemaReader registered as an OnReconnect listener for the core
  • after collection RELOAD, the old core's listener is unregistered and the new core's is registered
  • after collection DELETE, the listener is unregistered (now with an explicit wait instead of a one-shot check)

Measured locally: suite time drops from ~14s to ~3s (test method 13.6s → 0.7s). Also one fewer test on the legacy AbstractFullDistribZkTestBase.

Test-only change, no changelog entry.

Why and how

Crave is shutting down. We need to speed up our tests. I asked claude to pick 50 solr-core tests at random and look for speed improvements. It picked this first and improved it from 13 to 1 seconds.

The test booted 4 Jetty nodes (control + 3 shards) via the legacy
AbstractFullDistribZkTestBase, but only ever inspects a 1x1 collection.
Rewritten on SolrCloudTestCase with a single node using the cloud-managed
configset, preserving all assertions. Suite time drops from ~14s to ~3s.
@dsmiley

dsmiley commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

BTW we needn't tell an LLM to find tests to improve "at random"; that seems inefficient. Our test suite prints the slowest tests at the end... and furthermore I strongly suspect Develocity can tell us the slowest ones. We may want to approach this by identifying a theme and tackling that theme to have good focus/context. Perhaps retiring AbstractFullDistribZkTestBase would be a good theme. But I'd recommend beginning with a conversation and not action.

@janhoy

janhoy commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

This is a spike, fixing one random independent test. Not a start of something bigger or a strategy suggestion. It simply proves that just by looking at a few random tests there was lots to gain.

For strategies, one could look into a certain base class, identify polling and sleep patterns etc.

And ad proven in the other PR I put up, some test scenarios, not all, are good candidates for mocks.

@janhoy
janhoy merged commit e8cc2dc into apache:main Aug 5, 2026
4 of 6 checks passed
@janhoy janhoy added this to the 10.x milestone Aug 5, 2026
dsmiley pushed a commit that referenced this pull request Aug 8, 2026
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