Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ The Apache Software Foundation (https://www.apache.org/).
This distribution has a binary dependency on jersey, which is available under the CDDL
License. The source code of jersey can be found at https://github.com/jersey/jersey/.

This distribution has a binary test dependency on jqwik, which is available under
the Eclipse Public License 2.0. The source code can be found at
https://github.com/jlink/jqwik.

The streams-scala (streams/streams-scala) module was donated by Lightbend and the original code was copyrighted by them:
Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
Copyright (C) 2017-2018 Alexis Seigneurin.
Expand Down
4 changes: 0 additions & 4 deletions NOTICE-binary
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ The Apache Software Foundation (https://www.apache.org/).
This distribution has a binary dependency on jersey, which is available under the CDDL
License. The source code of jersey can be found at https://github.com/jersey/jersey/.

This distribution has a binary test dependency on jqwik, which is available under
the Eclipse Public License 2.0. The source code can be found at
https://github.com/jlink/jqwik.

The streams-scala (streams/streams-scala) module was donated by Lightbend and the original code was copyrighted by them:
Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
Copyright (C) 2017-2018 Alexis Seigneurin.
Expand Down
5 changes: 1 addition & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,6 @@ project(':metadata') {
testFixturesImplementation libs.junitJupiter

testImplementation libs.junitJupiter
testImplementation libs.jqwik
testImplementation libs.mockitoCore
testImplementation testFixtures(project(':clients'))
testImplementation testFixtures(project(':raft'))
Expand Down Expand Up @@ -2211,7 +2210,6 @@ project(':raft') {
testFixturesImplementation project(':clients')
testFixturesImplementation testFixtures(project(':clients'))
testFixturesImplementation project(':server-common')
testFixturesImplementation libs.jqwik
testFixturesImplementation libs.junitJupiter
testFixturesImplementation libs.mockitoCore
testFixturesImplementation libs.slf4jApi
Expand All @@ -2223,7 +2221,6 @@ project(':raft') {
testImplementation libs.jacksonDataformatYaml
testImplementation libs.junitJupiter
testImplementation libs.mockitoCore
testImplementation libs.jqwik
testImplementation testLog4j2Libs

testRuntimeOnly runtimeTestLibs
Expand Down Expand Up @@ -2289,7 +2286,7 @@ project(':raft') {

test {
useJUnitPlatform {
includeEngines 'jqwik', 'junit-jupiter'
includeEngines 'junit-jupiter'
}
}

Expand Down
1 change: 0 additions & 1 deletion checkstyle/import-control-group-coordinator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<allow pkg="javax.net.ssl" />
<allow pkg="javax.security" />
<allow pkg="javax.crypto" />
<allow pkg="net.jqwik.api" />

<!-- no one depends on the server -->
<disallow pkg="kafka" />
Expand Down
1 change: 0 additions & 1 deletion checkstyle/import-control-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
<allow pkg="javax.net.ssl" />
<allow pkg="javax.security" />
<allow pkg="javax.crypto" />
<allow pkg="net.jqwik.api" />

<!-- no one depends on the server -->
<disallow pkg="kafka" />
Expand Down
1 change: 0 additions & 1 deletion checkstyle/import-control-server-common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
<allow pkg="java.security" />
<allow pkg="javax.net.ssl" />
<allow pkg="javax.security" />
<allow pkg="net.jqwik.api" />
<allow pkg="javax.crypto" />

<!-- no one depends on the server -->
Expand Down
1 change: 0 additions & 1 deletion checkstyle/import-control-server.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
<allow pkg="java.security" />
<allow pkg="javax.net.ssl" />
<allow pkg="javax.security" />
<allow pkg="net.jqwik.api" />
<allow pkg="org.apache.commons.validator.routines" />

<!-- no one depends on the server -->
Expand Down
1 change: 0 additions & 1 deletion checkstyle/import-control-storage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<allow pkg="java.security" />
<allow pkg="javax.net.ssl" />
<allow pkg="javax.security" />
<allow pkg="net.jqwik.api" />

<!-- no one depends on the server -->
<disallow pkg="kafka" />
Expand Down
2 changes: 0 additions & 2 deletions checkstyle/import-control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
<allow pkg="javax.net.ssl" />
<allow pkg="javax.security" />
<allow pkg="org.ietf.jgss" />
<allow pkg="net.jqwik.api" />

<!-- no one depends on the server -->
<disallow pkg="kafka" />
Expand Down Expand Up @@ -474,7 +473,6 @@
<allow pkg="org.apache.kafka.storage.log.metrics" />
<allow pkg="org.apache.kafka.test"/>
<allow pkg="com.fasterxml.jackson" />
<allow pkg="net.jqwik"/>
</subpackage>

<subpackage name="snapshot">
Expand Down
2 changes: 0 additions & 2 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ versions += [
jopt: "5.0.4",
jose4j: "0.9.6",
junit: "5.14.3",
jqwik: "1.9.2",
kafka_0110: "0.11.0.3",
kafka_10: "1.0.2",
kafka_11: "1.1.1",
Expand Down Expand Up @@ -194,7 +193,6 @@ libs += [
junitJupiterApi: "org.junit.jupiter:junit-jupiter-api:$versions.junit",
junitPlatformSuiteEngine: "org.junit.platform:junit-platform-suite-engine:$versions.junitPlatform",
junitPlatformLanucher: "org.junit.platform:junit-platform-launcher:$versions.junitPlatform",
jqwik: "net.jqwik:jqwik:$versions.jqwik",
hamcrest: "org.hamcrest:hamcrest:$versions.hamcrest",
kafkaStreams_0110: "org.apache.kafka:kafka-streams:$versions.kafka_0110",
kafkaStreams_10: "org.apache.kafka:kafka-streams:$versions.kafka_10",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@
import org.apache.kafka.server.common.ApiMessageAndVersion;
import org.apache.kafka.server.common.MetadataVersion;

import net.jqwik.api.Arbitraries;
import net.jqwik.api.Arbitrary;
import net.jqwik.api.ForAll;
import net.jqwik.api.Property;
import net.jqwik.api.Provide;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -328,23 +322,9 @@ public void testPartitionRegistrationToRecord_ElrShouldBeNullIfEmpty() {
assertTrue(exceptions.isEmpty());
}

@Property
public void testConsistentEqualsAndHashCode(
@ForAll("uniqueSamples") PartitionRegistration a,
@ForAll("uniqueSamples") PartitionRegistration b
) {
if (a.equals(b)) {
assertEquals(a.hashCode(), b.hashCode(), "a=" + a + "\nb=" + b);
}

if (a.hashCode() != b.hashCode()) {
assertNotEquals(a, b, "a=" + a + "\nb=" + b);
}
}

@Provide
Arbitrary<PartitionRegistration> uniqueSamples() {
return Arbitraries.of(
@Test
public void testConsistentEqualsAndHashCode() {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I changed the test slightly. The original would pick 2 random samples 1000 times. Since they are only 9 samples so 9x9=81 combinations, we can always try them all as it takes milliseconds to run.

List<PartitionRegistration> samples = List.of(
new PartitionRegistration.Builder().setReplicas(new int[] {1, 2, 3}).setIsr(new int[] {1, 2, 3}).
setDirectories(new Uuid[]{Uuid.fromString("HyTsxr8hT6Gq5heZMA2Bug"), Uuid.fromString("ePwTiSgFRvaKRBaUX3EcZQ"), Uuid.fromString("F3zwSDR1QWGKNNLMowVoYg")}).
setLeader(1).setLeaderRecoveryState(LeaderRecoveryState.RECOVERED).setLeaderEpoch(100).setPartitionEpoch(200).setElr(new int[] {1, 2, 3}).build(),
Expand Down Expand Up @@ -374,6 +354,16 @@ Arbitrary<PartitionRegistration> uniqueSamples() {
setLeader(1).setLeaderRecoveryState(LeaderRecoveryState.RECOVERED).setLeaderEpoch(100).setPartitionEpoch(200).setElr(new int[] {2, 3}).setLastKnownElr(new int[] {1, 2}).build()
);

for (PartitionRegistration a : samples) {
for (PartitionRegistration b : samples) {
if (a.equals(b)) {
assertEquals(a.hashCode(), b.hashCode(), "a=" + a + "\nb=" + b);
}
if (a.hashCode() != b.hashCode()) {
assertNotEquals(a, b, "a=" + a + "\nb=" + b);
}
}
}
}

@Test
Expand Down
Loading
Loading