MINOR: Update JUnit to 4.13 and annotate log cleaner integration test#6248
MINOR: Update JUnit to 4.13 and annotate log cleaner integration test#6248ijuma merged 6 commits intoapache:trunkfrom
Conversation
|
Relevant sections of gradle's profile report that take more than 5 seconds:
|
ewencp
left a comment
There was a problem hiding this comment.
A couple of comments, but mostly looks good as it is mostly a mechanical change.
You got my hopes up with this, I've been refreshing the junit 4.13 release issue daily waiting for beta to be approved and released as its final version :)
| exceptionRule.expectMessage("ZStandard compression is not supported for magic " + magic); | ||
| } | ||
| private void assumeV2OrNotZstd(byte magic) { | ||
| assumeTrue(compressionType != CompressionType.ZSTD || magic == MAGIC_VALUE_V2); |
There was a problem hiding this comment.
why the shift to checking exact v2 rather than that it is >= if zstd? given our default would be to preserve the feature moving forward, it seems better to write these tests to work for future updates by default (as appears to be the case with the code previously) and only have to edit them if we made a change that wasn't compatible with v2 zstd support.
There was a problem hiding this comment.
Just an oversight, I think I did it right in the other class. Will fix.
| public void testFilterToBatchDiscard() { | ||
| if (compression != CompressionType.NONE || magic >= RecordBatch.MAGIC_VALUE_V2) { | ||
| expectExceptionWithZStd(compression, magic); | ||
| if ((compression != CompressionType.NONE && compression != CompressionType.ZSTD) || |
There was a problem hiding this comment.
If we're starting to use Assume, this seems like it should be one since the condition just skips the whole test?
There was a problem hiding this comment.
I was thinking the same, but didn't do it in the end. Will change.
|
@ewencp I was refreshing it regularly too and eventually decided that we don't need to wait for it since the rate of change in that branch is nearly 0 and the beta is in the central Maven repo. We'll just bump to final when that happens. |
|
JDK 11 build passed, JDK 8 build had one flake:
|
|
@ewencp I've addressed the comments and fixed a few more things I noticed. |
ewencp
left a comment
There was a problem hiding this comment.
One last nit on the version checking in one of the tests, but otherwise LGTM (modulo getting a clean, non-timed-out build)
| } | ||
|
|
||
| private void assumeV2OrNotZstd() { | ||
| assumeTrue(compression != CompressionType.ZSTD || magic == MAGIC_VALUE_V2); |
There was a problem hiding this comment.
magic comparison to v2 has same equality change here as in the previous test. any reason not to >=?
There was a problem hiding this comment.
Sorry for missing this one, fixed.
mumrah
left a comment
There was a problem hiding this comment.
LGTM, one small comment inline
| Thread.currentThread().interrupt(); | ||
| expectedException.expect(InterruptException.class); | ||
| consumer.poll(Duration.ZERO); | ||
| assertThrows(InterruptException.class, () -> consumer.poll(Duration.ZERO)); |
There was a problem hiding this comment.
Oh wow, this is so much nicer than the rule thing or explicit catches. +1
| MemoryRecords records = builder.build(); | ||
| assertEquals(0, records.sizeInBytes()); | ||
| assertEquals(bufferOffset, buffer.position()); | ||
| Supplier<MemoryRecordsBuilder> builderSupplier = () -> new MemoryRecordsBuilder(buffer, magic, |
There was a problem hiding this comment.
Since the build method of the builder is what you're testing here, I don't think the Supplier is necessary.
There was a problem hiding this comment.
The checks happen in the constructor, right?
if (magic < RecordBatch.MAGIC_VALUE_V2) {
if (isTransactional)
throw new IllegalArgumentException("Transactional records are not supported for magic " + magic);
if (isControlBatch)
throw new IllegalArgumentException("Control records are not supported for magic " + magic);
if (compressionType == CompressionType.ZSTD)
throw new IllegalArgumentException("ZStandard compression is not supported for magic " + magic);
}There was a problem hiding this comment.
Gotcha. I (incorrectly) assumed the "build" method.
|
retest this please |
1 similar comment
|
retest this please |
|
Tests passed, merging to trunk. |
…apache#6248) JUnit 4.13 fixes the issue where `Category` and `Parameterized` annotations could not be used together. It also deprecates `ExpectedException` and `assertThat`. Given this, we: - Replace `ExpectedException` with the newly introduced `assertThrows`. - Replace `Assert.assertThat` with `MatcherAssert.assertThat`. - Annotate `AbstractLogCleanerIntegrationTest` with `IntegrationTest` category. Reviewers: Ewen Cheslack-Postava <ewen@confluent.io>, David Arthur <mumrah@gmail.com>
JUnit 4.13 fixes the issue where
CategoryandParameterizedannotationscould not be used together. It also deprecates
ExpectedExceptionandassertThat. Given this, we:ExpectedExceptionwith the newly introducedassertThrows.Assert.assertThatwithMatcherAssert.assertThat.AbstractLogCleanerIntegrationTestwithIntegrationTestcategory.Committer Checklist (excluded from commit message)