use of io.strimzi.api.kafka.model.listener.arraylistener.KafkaListenerType in project strimzi by strimzi.
the class MultipleListenersST method generateTestCases.
/**
* Generates stochastic count of GenericKafkaListener for each type. Every type of listener has it's own count and
* port generation interval.
* @return HashMap which holds all generated listeners
*/
private Map<KafkaListenerType, List<GenericKafkaListener>> generateTestCases() {
LOGGER.info("Starting to generate test cases for multiple listeners");
int stochasticCount;
for (KafkaListenerType kafkaListenerType : KafkaListenerType.values()) {
LOGGER.info("Generating {} listener", kafkaListenerType.name());
List<GenericKafkaListener> testCaseListeners = new ArrayList<>(5);
switch(kafkaListenerType) {
case NODEPORT:
stochasticCount = ThreadLocalRandom.current().nextInt(2, 5);
for (int j = 0; j < stochasticCount; j++) {
boolean stochasticCommunication = ThreadLocalRandom.current().nextInt(2) == 0;
testCaseListeners.add(new GenericKafkaListenerBuilder().withName(KafkaListenerType.NODEPORT.toValue() + j).withPort(10900 + j).withType(KafkaListenerType.NODEPORT).withTls(stochasticCommunication).build());
}
break;
case LOADBALANCER:
stochasticCount = ThreadLocalRandom.current().nextInt(2, 3);
for (int j = 0; j < stochasticCount; j++) {
boolean stochasticCommunication = ThreadLocalRandom.current().nextInt(2) == 0;
testCaseListeners.add(new GenericKafkaListenerBuilder().withName(KafkaListenerType.LOADBALANCER.toValue().substring(0, 5) + j).withPort(11900 + j).withType(KafkaListenerType.LOADBALANCER).withTls(stochasticCommunication).withNewConfiguration().withFinalizers(LB_FINALIZERS).endConfiguration().build());
}
break;
case ROUTE:
// TODO: bug with unique ports per listener which should be fixed now in Kafka 2.7.0
testCaseListeners.add(new GenericKafkaListenerBuilder().withName(KafkaListenerType.ROUTE.toValue()).withPort(12091).withType(KafkaListenerType.ROUTE).withTls(true).build());
break;
case INTERNAL:
stochasticCount = ThreadLocalRandom.current().nextInt(2, 4);
for (int j = 0; j < stochasticCount; j++) {
boolean stochasticCommunication = ThreadLocalRandom.current().nextInt(2) == 0;
testCaseListeners.add(new GenericKafkaListenerBuilder().withName(KafkaListenerType.INTERNAL.toValue() + j).withPort(13900 + j).withType(KafkaListenerType.INTERNAL).withTls(stochasticCommunication).build());
}
}
LOGGER.info("Generating listeners with type {} -> {}", kafkaListenerType.name(), testCaseListeners.toArray());
testCases.put(kafkaListenerType, testCaseListeners);
}
LOGGER.info("Finished with generation of test cases for multiple listeners");
return testCases;
}
use of io.strimzi.api.kafka.model.listener.arraylistener.KafkaListenerType in project strimzi-kafka-operator by strimzi.
the class MultipleListenersST method generateTestCases.
/**
* Generates stochastic count of GenericKafkaListener for each type. Every type of listener has it's own count and
* port generation interval.
* @return HashMap which holds all generated listeners
*/
private Map<KafkaListenerType, List<GenericKafkaListener>> generateTestCases() {
LOGGER.info("Starting to generate test cases for multiple listeners");
int stochasticCount;
for (KafkaListenerType kafkaListenerType : KafkaListenerType.values()) {
LOGGER.info("Generating {} listener", kafkaListenerType.name());
List<GenericKafkaListener> testCaseListeners = new ArrayList<>(5);
switch(kafkaListenerType) {
case NODEPORT:
stochasticCount = ThreadLocalRandom.current().nextInt(2, 5);
for (int j = 0; j < stochasticCount; j++) {
boolean stochasticCommunication = ThreadLocalRandom.current().nextInt(2) == 0;
testCaseListeners.add(new GenericKafkaListenerBuilder().withName(KafkaListenerType.NODEPORT.toValue() + j).withPort(10900 + j).withType(KafkaListenerType.NODEPORT).withTls(stochasticCommunication).build());
}
break;
case LOADBALANCER:
stochasticCount = ThreadLocalRandom.current().nextInt(2, 3);
for (int j = 0; j < stochasticCount; j++) {
boolean stochasticCommunication = ThreadLocalRandom.current().nextInt(2) == 0;
testCaseListeners.add(new GenericKafkaListenerBuilder().withName(KafkaListenerType.LOADBALANCER.toValue().substring(0, 5) + j).withPort(11900 + j).withType(KafkaListenerType.LOADBALANCER).withTls(stochasticCommunication).withNewConfiguration().withFinalizers(LB_FINALIZERS).endConfiguration().build());
}
break;
case ROUTE:
// TODO: bug with unique ports per listener which should be fixed now in Kafka 2.7.0
testCaseListeners.add(new GenericKafkaListenerBuilder().withName(KafkaListenerType.ROUTE.toValue()).withPort(12091).withType(KafkaListenerType.ROUTE).withTls(true).build());
break;
case INTERNAL:
stochasticCount = ThreadLocalRandom.current().nextInt(2, 4);
for (int j = 0; j < stochasticCount; j++) {
boolean stochasticCommunication = ThreadLocalRandom.current().nextInt(2) == 0;
testCaseListeners.add(new GenericKafkaListenerBuilder().withName(KafkaListenerType.INTERNAL.toValue() + j).withPort(13900 + j).withType(KafkaListenerType.INTERNAL).withTls(stochasticCommunication).build());
}
}
LOGGER.info("Generating listeners with type {} -> {}", kafkaListenerType.name(), testCaseListeners.toArray());
testCases.put(kafkaListenerType, testCaseListeners);
}
LOGGER.info("Finished with generation of test cases for multiple listeners");
return testCases;
}
Aggregations