Skip to content

Improve unit test coverage for MSQ#13398

Merged
cryptoe merged 6 commits intoapache:masterfrom
LakshSingla:msq-fault-tests
Nov 29, 2022
Merged

Improve unit test coverage for MSQ#13398
cryptoe merged 6 commits intoapache:masterfrom
LakshSingla:msq-fault-tests

Conversation

@LakshSingla
Copy link
Copy Markdown
Contributor

@LakshSingla LakshSingla commented Nov 21, 2022

Description

This PR adds a new set of tests called MSQFaultsTest that aims to improve the testing coverage for MSQ by adding new unit tests for when the query should fault.


This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@kfaraz kfaraz added Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 Area - Testing labels Nov 21, 2022
Copy link
Copy Markdown
Contributor

@adarshsanjeev adarshsanjeev left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!
Tests added look good to me. Should there also be tests for TooManyInputFilesFault etc here?

Copy link
Copy Markdown
Contributor

@adarshsanjeev adarshsanjeev left a comment

Choose a reason for hiding this comment

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

New test case looks good as well. Thanks for making the changes!

@kfaraz
Copy link
Copy Markdown
Contributor

kfaraz commented Nov 28, 2022

@LakshSingla , it seems a real overkill to have 30k rows of data just to get a specific exception in a unit test.
Can we simplify this somehow?

@LakshSingla
Copy link
Copy Markdown
Contributor Author

@kfaraz MAX_PARTITIONS (25k) is a constant defined above which the query would fail. To get this many partitions, in my understanding we would require at least 25000 rows. I can think of the following options to prevent this static file here:

  1. Create a file programmatically and then run the tests.
  2. Create a method and override MAX_WORKERS (which doesn't seem right to me to do for the sake of testing).
  3. Use some Guice magic to inject MAX_WORKERS (similar reasoning as above).
    Do you have any opinions on the above or an alternate approach that you think might be suitable? Thanks!

@kfaraz
Copy link
Copy Markdown
Contributor

kfaraz commented Nov 28, 2022

Yes, @LakshSingla , the first option seems most reasonable. You shouldn't have to generate the file either. You could maybe add a utility method in MsqTestBase which gives you a mock file with the required number of rows and columns?

* Helper method that populates a temporary file with {@code numRows} rows and {@code numColumns} columns where the
* first column is a string 'timestamp' while the rest are string columns with junk value
*/
protected File generateTemporaryNdJsonFile(final int numRows, final int numColumns) throws IOException
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 we can add a new class for this and the previous method. MSQTestFileUtils?

Copy link
Copy Markdown
Contributor

@cryptoe cryptoe left a comment

Choose a reason for hiding this comment

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

Thanks @LakshSingla !!

@cryptoe cryptoe merged commit 79df11c into apache:master Nov 29, 2022
@clintropolis clintropolis added this to the 26.0 milestone Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 Area - Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants