Skip to content

SOLR-18332: More qt-removal from tests, rd 3 - #4721

Draft
gerlowskija wants to merge 2 commits into
apache:mainfrom
gerlowskija:qt-removal-rd-3
Draft

SOLR-18332: More qt-removal from tests, rd 3#4721
gerlowskija wants to merge 2 commits into
apache:mainfrom
gerlowskija:qt-removal-rd-3

Conversation

@gerlowskija

Copy link
Copy Markdown
Contributor

The 'qt' parameter and several related methods in SolrJ are deprecated.
This deprecation may not stick, but it's still worth minimizing use of this
feature as much as possible.

Many tests rely on it unnecessarily; this PR is one in a number of batches
slowly removing these usages. This one focuses on solr-core tests that
dispatch through the req()/assertQ/assertJQ/assertQEx helpers; passing the
handler explicitly instead of embedding it as a 'qt' request param.

The 'qt' parameter and several related methods in SolrJ are deprecated.
This deprecation may not stick, but it's still worth minimizing use of this
feature as much as possible.

Many tests rely on it unnecessarily; this PR is one in a number of batches
slowly removing these usages. This one focuses on solr-core tests that
dispatch through the req()/assertQ/assertJQ/assertQEx helpers; passing the
handler explicitly instead of embedding it as a 'qt' request param.
@gerlowskija

Copy link
Copy Markdown
Contributor Author

Not quite ready for primetime yet - I don't like all of the method overloads for assertQ and others, but not sure what I can do about it...

Ideas welcome! 🤔

// now switch the order:
booster.setTopQueryResults(reader, query, false, new String[] {"a", "x"}, null);
assertQ(
null,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this null because you didn't want to add a message on failure?

@gerlowskija gerlowskija Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In short, yes. This is the main thing I dislike about this PR.

I'm 100% happy with the default assertQ error message here. In an ideal world I'd create an assertQ override for cases like this, where I need a non-default query endpoint but am 100% happy with the default assertQ error message. But there's no great way to do that since "message" and "requestHandler" are both strings and the signature of the reqHandler-but-no-message method would by indistinguishable from the existing "message-but-no-reqHandler" method.

I toyed a bit with a fluent-ish solution here, where the message gets provided by a wrapping call and could be dropped from all of our little assertFoo helpers. e.g.

withMessage(
    "This is my message on failure",
    () -> assertQ(...))

Another alternative: assertQ and friends already take in a SolrQueryRequest (typically created via req() calls) and SQR has a getPath method that could probably be used rather than providing the requestHandler as a separate method param in assertQ. This seems like the simplest solution, except that SolrQueryRequest.getPath seems to be largely unused, and I don't have quite enough context to know why. If we could go this route it'd look like:

assertQ(
    reqWithPath("/elevate", baseParams),
    "//([@numFound='4']")

@@ -1663,9 +1598,9 @@ public void testOnlyRepresentativeIsVisibleWhenCollapsing() throws Exception {
// only representative elevated doc visible
assertQ(
"",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's worth adding a proper message in for the null or "", and the failure messages help you understand what the test is about..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In theory, I agree. In practice:

  1. It's hard to write a good error message for an assertion like this that's running many XPath checks. Taking this particular case as an example: what would a good message look like, that's better than what assertQ does by default (which prints both the XPath expression that caused the failure and corresponding section of the results)?
  2. Bandwidth. If I stop to spruce up every little thing that could be improved I'm worried the larger qt effort will never get across the line.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fair enough. In this case, perfection is the enemy of ever getting to the end of this effort ;-)

@epugh

epugh commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Not quite ready for primetime yet - I don't like all of the method overloads for assertQ and others, but not sure what I can do about it...

Ideas welcome! 🤔

I guess I don't think they are terrible...

String exceptionMessage,
SolrQueryRequest req,
SolrException.ErrorCode code,
String handler) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's a matter of taste but shouldn't the handler & request come first?

@Test
public void testBoolOuterAndInnerNamesComposed() throws Exception {
assertJQ(
HANDLER,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe instead of overloading various assertion methods, we add a wrapping method like handler(String,SolrQueryRequest) that puts the handler into the SQR, like in the context I guess. Could use "qt". The ultimate point is to get the tests to not use "qt"; it's not wrong if we find it convenient for the plumbing/infra to maybe use it behind the scenes.

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.

3 participants