-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Migrate several indexing and compaction integration tests to embedded-tests #18207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate several indexing and compaction integration tests to embedded-tests #18207
Conversation
ITPerfectRollupParallelIndexTest and ITBestEffortRollupParallelIndexTest to embedded-tests
…rfect_rollup_test
…rfect_rollup_test
…druid into add_embedded_perfect_rollup_test
ITPerfectRollupParallelIndexTest and ITBestEffortRollupParallelIndexTest to embedded-tests
...ests/src/test/java/org/apache/druid/testing/embedded/compact/EmbeddedAutoCompactionTest.java
Fixed
Show fixed
Hide fixed
...rc/test/java/org/apache/druid/testing/embedded/indexing/EmbeddedKafkaClusterMetricsTest.java
Fixed
Show fixed
Hide fixed
Bug: Concurrent append uses lock of type APPEND which always uses a lock version of epoch 1970-01-01. This can cause data loss in a flow as follows: - Ingest data using an APPEND task to an empty interval - Mark all the segments as unused - Re-run the APPEND task - Data is not visible since old segment IDs (now unused) are allocated again Fix: In segment allocation, do not reuse an old segment ID, used or unused. This fix was already done for some cases back in #16380 . An embedded test for this has been included in #18207
| @@ -0,0 +1,3 @@ | |||
| {"timestamp": "2013-08-31T01:02:33Z", "page": "Gypsy Danger", "language" : "en", "tags": ["t1", "t2"], "user" : "nuclear", "unpatrolled" : "true", "newPage" : "true", "robot": "false", "anonymous": "false", "namespace":"article", "continent":"North America", "country":"United States", "region":"Bay Area", "city":"San Francisco", "added": 57, "deleted": 200, "delta": -143} | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drive by comment/nit: i know this isn't new, but imo we should fix the problem of referring to this dataset as 'wikipedia' because it is confusing with the quickstart wikipedia data which is also going to be used in some tests, and this stuff only has a vaguely similar schema, maybe tiny-wikipedia or something to indicate that its a very small dataset would help clear things up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion! I will rename these datasets accordingly.
…rfect_rollup_test
…rfect_rollup_test
clintropolis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this lgtm, thanks for the builder stuff it feels to me like this should be a lot more ergonomic and less error prone than either the old IT templates or trying to hand craft json specs.
seems fine to merge after fixing up the todo comment one way or another.
One thing I was thinking about while reviewing is that i believe we are perhaps losing some minor coverage of auth stuff during this transition since I think the base ITs had basic-auth setup, though afaict not much in the way of roles and stuff in most tests (so i think was only authentication that would have been tested except for those that extend AbstractAuthConfigurationTest). I think that is probably fine though as long as we migrate the auth tests over to run on this framework, though they probably don't cast quite a wide of net in terms of APIs being called since those tests are more focused on authorization. I don't think I am suggesting we just bake basic auth into random tests or anything, and really its a bit of a negative of the old frameworks that you have to hunt across several files to determine what configuration is actually active for a given test, but maybe something we should watch out for as we move tests over.
embedded-tests/src/test/java/org/apache/druid/testing/embedded/indexing/IndexTaskTest.java
Outdated
Show resolved
Hide resolved
| import java.util.TreeSet; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| public abstract class CompactionTestBase extends EmbeddedClusterTestBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other than maybe the cluster config, most of the utility methods on this class don't seem too related to compaction, should they live somewhere more common? Is fine to change this later, just want to avoid copy and paste of these methods down the line or like weird extending of compaction test base for things that aren't doing any compaction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ); | ||
|
|
||
| // Wait for scheduler to pick up the compaction job | ||
| // TODO: make this latch-based |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should either do this or transition from a TODO to a comment about how someone in the future can improve this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please don't commit todo comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, must have missed this in the cleanup.
| .ofTypeIndexParallel() | ||
| .jsonInputFormat() | ||
| .inlineInputSourceWithData(Resources.InlineData.JSON_2_ROWS) | ||
| .isoTimestampColumn("timestamp") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would be nicer to have .timestampColumn("timestamp", "iso"). Makes it easier to sub in "auto" or whatever other format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did have that initially. But realized that most tests are just using an ISO timestamp. So used this syntax sugar instead.
For a fully custom timestamp, there is also the option to use.
.dataSchema(d -> d.withTimestamp(new TimestampSpec(...)))Please let me know which one you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with either one.
| * Verifies the result of a SELECT query | ||
| * | ||
| * @param field Field to select | ||
| * @param result CSV result with special strings {@code ||} to represent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do this rather than accept the CSV as-is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I didn't want to do this initially, but it made for more readable tests as it avoided all the escaping of empty strings and newlines.
verifyScanResult("added", "...||31||...||62");vs
verifyScanResult("added", "\"\"\n31\"\"\n62");Please let me know if this seems hacky and if you feel that it is cleaner to just use the original.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. To me the first form is hard to get used to. I keep wanting to read the || as field separators rather than newlines. The second is also weird looking though. I can't think of a good solution immediately. I'm ok with what you think is best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried a bunch of different symbols, but nothing really conveyed a "newline" well-enough, not even ↵ or ⏎.
The empty strings are probably the worse of the two though.
Using ellipsis for now, but keeping newline \n as is.
So, we would have something like this:
verifyScanResult("added", "...\n31\n...\n62");| ); | ||
|
|
||
| // Wait for scheduler to pick up the compaction job | ||
| // TODO: make this latch-based |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please don't commit todo comments.
| * | ||
| * @return ID of the task. | ||
| */ | ||
| protected String runTask(TaskBuilder<?, ?, ?> taskBuilder, String dataSource) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, protected methods on a base class aren't the best way to do utility APIs. Other test cases might want some of these utility methods, but not to be "compaction tests". Also, some tests might want to extend multiple base classes, and this approach makes it impossible.
With MSQ tests we have EmbeddedMSQApis, something that collects together utility APIs without using a base class approach. Something similar might work here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks for the suggestion!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved most methods to EmbeddedClusterApis itself so that all tests can benefit from it.
I have still kept some of the protected methods in CompactionTestBase but these mostly just act as syntax sugar over the methods in EmbeddedClusterApis to keep the diff in the compaction test classes small.
| /** | ||
| * Constants and utility methods used in embedded cluster tests. | ||
| */ | ||
| public class Resources |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this to embedded-tests means that it's now tougher for extensions to write their own tests that pull in Resources. Can you split this up? Such as having some Resources in services, and MoreResources in embedded-tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
Thanks for calling this out, @clintropolis ! I do plan to migrate the auth tests as well to the embedded framework. |
|
@gianm , @clintropolis , thanks for the feedback! |
Approved, since the only remaining comment (about |
Summary
Changes
TaskBuilderutility to createTaskobjects using fluent syntaxembedded-testsTest migrations
ITPerfectRollupParallelIndexTestIndexParallelTaskTestITBestEffortRollupParallelIndexTestIndexParallelTaskTest, added as a new test parameter which uses dynamic partitioningITAutoCompactionTestAutoCompactionTestITAutoCompactionLockContentionTestAutoCompactionUpgradeTestITAutoCompactionLockContentionTestKafkaClusterMetricsTest, methodtest_ingestClusterMetrics_compactionSkipsLockedIntervals()ITCompactionTaskTestCompactionTaskTestITCompactionSparseColumnTestCompactionSparseColumnTestITOverlordResourceTestOverlordClientTestITOverlordResourceNotFoundTestOverlordClientTestNew nested tests
EmbeddedCentralizedSchemaPublishFailureTestfor the groupcds-task-schema-publish-disabledEmbeddedCentralizedSchemaMetadataQueryDisabledTestfor the groupcds-coordinator-metadata-query-disabledTest run times
IndexParallelTaskTest(indexer)AutoCompactionTest(indexer)CompactionSparseColumnTest(indexer)ITPerfectRollupParallelIndexTestITPerfectRollupParallelIndexTest(Indexer, shuffle deep store test, only 1 config changed)
ITPerfectRollupParallelIndexTest(MM, shuffle deep store test, only 1 config changed)
ITBestEffortRollupParallelIndexTestITBestEffortRollupParallelIndexTestITAutoCompactionTest(middle manager)ITAutoCompactionTest(indexer)ITCompactionSparseColumnTest(indexer)This PR has: