Skip to content

Commit 1891ccb

Browse files
committed
fix docs and unit tests
1 parent 1141298 commit 1891ccb

2 files changed

Lines changed: 40 additions & 18 deletions

File tree

rust/operator-binary/src/crd/listener.rs

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ mod tests {
359359
};
360360

361361
use super::*;
362-
use crate::crd::authentication::ResolvedAuthenticationClasses;
362+
use crate::crd::{authentication::ResolvedAuthenticationClasses, role::KafkaRole};
363363

364364
fn default_cluster_info() -> KubernetesClusterInfo {
365365
KubernetesClusterInfo {
@@ -369,9 +369,6 @@ mod tests {
369369

370370
#[test]
371371
fn test_get_kafka_listeners_config() {
372-
let object_name = "simple-kafka-broker-default";
373-
let cluster_info = default_cluster_info();
374-
375372
let kafka_cluster = r#"
376373
apiVersion: kafka.stackable.tech/v1alpha1
377374
kind: KafkaCluster
@@ -405,9 +402,12 @@ mod tests {
405402
"internalTls".to_string(),
406403
Some("tls".to_string()),
407404
);
408-
405+
let cluster_info = default_cluster_info();
406+
// "simple-kafka-broker-default"
407+
let rolegroup_ref = kafka.rolegroup_ref(&KafkaRole::Broker, "default");
409408
let config =
410-
get_kafka_listener_config(&kafka, &kafka_security, object_name, &cluster_info).unwrap();
409+
get_kafka_listener_config(&kafka, &kafka_security, &rolegroup_ref, &cluster_info)
410+
.unwrap();
411411

412412
assert_eq!(
413413
config.listeners(),
@@ -433,7 +433,12 @@ mod tests {
433433
kafka_security.client_port_name()
434434
),
435435
internal_name = KafkaListenerName::Internal,
436-
internal_host = pod_fqdn(&kafka, object_name, &cluster_info).unwrap(),
436+
internal_host = pod_fqdn(
437+
&kafka,
438+
&rolegroup_ref.rolegroup_headless_service_name(),
439+
&cluster_info
440+
)
441+
.unwrap(),
437442
internal_port = kafka_security.internal_port(),
438443
)
439444
);
@@ -459,7 +464,8 @@ mod tests {
459464
Some("tls".to_string()),
460465
);
461466
let config =
462-
get_kafka_listener_config(&kafka, &kafka_security, object_name, &cluster_info).unwrap();
467+
get_kafka_listener_config(&kafka, &kafka_security, &rolegroup_ref, &cluster_info)
468+
.unwrap();
463469

464470
assert_eq!(
465471
config.listeners(),
@@ -485,7 +491,12 @@ mod tests {
485491
kafka_security.client_port_name()
486492
),
487493
internal_name = KafkaListenerName::Internal,
488-
internal_host = pod_fqdn(&kafka, object_name, &cluster_info).unwrap(),
494+
internal_host = pod_fqdn(
495+
&kafka,
496+
&rolegroup_ref.rolegroup_headless_service_name(),
497+
&cluster_info
498+
)
499+
.unwrap(),
489500
internal_port = kafka_security.internal_port(),
490501
)
491502
);
@@ -510,7 +521,8 @@ mod tests {
510521
);
511522

512523
let config =
513-
get_kafka_listener_config(&kafka, &kafka_security, object_name, &cluster_info).unwrap();
524+
get_kafka_listener_config(&kafka, &kafka_security, &rolegroup_ref, &cluster_info)
525+
.unwrap();
514526

515527
assert_eq!(
516528
config.listeners(),
@@ -536,7 +548,12 @@ mod tests {
536548
kafka_security.client_port_name()
537549
),
538550
internal_name = KafkaListenerName::Internal,
539-
internal_host = pod_fqdn(&kafka, object_name, &cluster_info).unwrap(),
551+
internal_host = pod_fqdn(
552+
&kafka,
553+
&rolegroup_ref.rolegroup_headless_service_name(),
554+
&cluster_info
555+
)
556+
.unwrap(),
540557
internal_port = kafka_security.internal_port(),
541558
)
542559
);
@@ -557,9 +574,6 @@ mod tests {
557574

558575
#[test]
559576
fn test_get_kafka_kerberos_listeners_config() {
560-
let object_name = "simple-kafka-broker-default";
561-
let cluster_info = default_cluster_info();
562-
563577
let kafka_cluster = r#"
564578
apiVersion: kafka.stackable.tech/v1alpha1
565579
kind: KafkaCluster
@@ -592,9 +606,12 @@ mod tests {
592606
"tls".to_string(),
593607
Some("tls".to_string()),
594608
);
595-
609+
let cluster_info = default_cluster_info();
610+
// "simple-kafka-broker-default"
611+
let rolegroup_ref = kafka.rolegroup_ref(&KafkaRole::Broker, "default");
596612
let config =
597-
get_kafka_listener_config(&kafka, &kafka_security, object_name, &cluster_info).unwrap();
613+
get_kafka_listener_config(&kafka, &kafka_security, &rolegroup_ref, &cluster_info)
614+
.unwrap();
598615

599616
assert_eq!(
600617
config.listeners(),
@@ -623,7 +640,12 @@ mod tests {
623640
kafka_security.client_port_name()
624641
),
625642
internal_name = KafkaListenerName::Internal,
626-
internal_host = pod_fqdn(&kafka, object_name, &cluster_info).unwrap(),
643+
internal_host = pod_fqdn(
644+
&kafka,
645+
&rolegroup_ref.rolegroup_headless_service_name(),
646+
&cluster_info
647+
)
648+
.unwrap(),
627649
internal_port = kafka_security.internal_port(),
628650
bootstrap_name = KafkaListenerName::Bootstrap,
629651
bootstrap_host = node_address_cmd(STACKABLE_LISTENER_BROKER_DIR),

rust/operator-binary/src/resource/statefulset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub enum Error {
161161
/// The broker rolegroup [`StatefulSet`] runs the rolegroup, as configured by the administrator.
162162
///
163163
/// The [`Pod`](`stackable_operator::k8s_openapi::api::core::v1::Pod`)s are accessible through the corresponding
164-
/// [`Service`](`stackable_operator::k8s_openapi::api::core::v1::Service`) from [`build_rolegroup_service`](`crate::resource::service::build_rolegroup_service`).
164+
/// [`Service`](`stackable_operator::k8s_openapi::api::core::v1::Service`) from [`build_rolegroup_service`](`crate::resource::service::build_rolegroup_headless_service`).
165165
#[allow(clippy::too_many_arguments)]
166166
pub fn build_broker_rolegroup_statefulset(
167167
kafka: &v1alpha1::KafkaCluster,

0 commit comments

Comments
 (0)