forked from kroxylicious/kroxylicious-junit5-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix kroxylicious#176: Changes needed to get the tests working, at least
Signed-off-by: Tom Bentley <[email protected]>
- Loading branch information
1 parent
56a64f8
commit fcda683
Showing
13 changed files
with
569 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
205 changes: 128 additions & 77 deletions
205
impl/src/main/java/io/kroxylicious/testing/kafka/common/KafkaClusterConfig.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
impl/src/main/java/io/kroxylicious/testing/kafka/common/MetadataMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright Kroxylicious Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.kroxylicious.testing.kafka.common; | ||
|
||
public enum MetadataMode { | ||
ZOOKEEPER, | ||
KRAFT_COMBINED, | ||
KRAFT_SEPARATE; | ||
|
||
/** | ||
* @return The total number of Kafka nodes (excludes any ZooKeeper nodes). | ||
*/ | ||
public int numNodes(int numControllers, int numBrokers) { | ||
return switch (this) { | ||
case KRAFT_SEPARATE -> numControllers + numBrokers; | ||
case KRAFT_COMBINED -> Math.max(numControllers, numBrokers); | ||
case ZOOKEEPER -> numBrokers; | ||
}; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
impl/src/main/java/io/kroxylicious/testing/kafka/common/NodeRole.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright Kroxylicious Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.kroxylicious.testing.kafka.common; | ||
|
||
import java.util.Collection; | ||
import java.util.EnumSet; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
public enum NodeRole { | ||
BROKER("broker"), | ||
CONTROLLER("controller"); | ||
|
||
private final String configRole; | ||
|
||
private NodeRole(String configRole) { | ||
this.configRole = configRole; | ||
} | ||
|
||
/** | ||
* @return The role, as it can be configured in a Kafka {@code server.properties} file. | ||
*/ | ||
public static String forConfig(Collection<NodeRole> roles) { | ||
return roles.stream().map(x -> x.configRole).distinct().collect(Collectors.joining(",")); | ||
} | ||
|
||
public static boolean isPureController(Set<NodeRole> roles) { | ||
return EnumSet.of(NodeRole.CONTROLLER).equals(roles); | ||
} | ||
|
||
public static boolean isCombinedNode(Set<NodeRole> roles) { | ||
return EnumSet.of(NodeRole.CONTROLLER, NodeRole.BROKER).equals(roles); | ||
} | ||
|
||
public static boolean isPureBroker(Set<NodeRole> roles) { | ||
return EnumSet.of(NodeRole.BROKER).equals(roles); | ||
} | ||
|
||
public static boolean hasBrokerRole(Set<NodeRole> roles) { | ||
return roles.contains(NodeRole.BROKER); | ||
} | ||
|
||
public static boolean hasControllerRole(Set<NodeRole> roles) { | ||
return roles.contains(NodeRole.CONTROLLER); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.