@@ -781,6 +781,100 @@ mod tests {
781781 assert_eq ! ( heap. value. as_deref( ) , Some ( "409" ) ) ;
782782 }
783783
784+ #[ test]
785+ fn vector_agent_adds_vector_container_to_statefulset ( ) {
786+ // Enabling the Vector agent wires a `vector` sidecar onto the StatefulSet, mounting the
787+ // `config` (for `vector.yaml`) and `log` volumes. The env vars the sidecar carries are set
788+ // by the upstream `vector_container` helper, so this only pins the wiring seam this operator
789+ // owns: that the sidecar is added at all when the agent is enabled. Without the agent, no
790+ // such container exists.
791+ let sts = build_sts (
792+ r#"
793+ apiVersion: zookeeper.stackable.tech/v1alpha1
794+ kind: ZookeeperCluster
795+ metadata:
796+ name: simple-zookeeper
797+ spec:
798+ image:
799+ productVersion: "3.9.5"
800+ clusterConfig:
801+ vectorAggregatorConfigMapName: vector-aggregator-discovery
802+ servers:
803+ roleGroups:
804+ default:
805+ replicas: 1
806+ config:
807+ logging:
808+ enableVectorAgent: true
809+ "# ,
810+ "default" ,
811+ ) ;
812+
813+ let vector = sts
814+ . spec
815+ . as_ref ( )
816+ . unwrap ( )
817+ . template
818+ . spec
819+ . as_ref ( )
820+ . unwrap ( )
821+ . containers
822+ . iter ( )
823+ . find ( |c| c. name == VECTOR_CONTAINER_NAME . as_ref ( ) )
824+ . expect ( "vector container" ) ;
825+
826+ let mount_names: Vec < & str > = vector
827+ . volume_mounts
828+ . as_ref ( )
829+ . unwrap ( )
830+ . iter ( )
831+ . map ( |m| m. name . as_str ( ) )
832+ . collect ( ) ;
833+ assert ! (
834+ mount_names. contains( & CONFIG_VOLUME_NAME . as_ref( ) ) ,
835+ "vector container missing `config` volume mount: {mount_names:?}"
836+ ) ;
837+ assert ! (
838+ mount_names. contains( & LOG_VOLUME_NAME . as_ref( ) ) ,
839+ "vector container missing `log` volume mount: {mount_names:?}"
840+ ) ;
841+ }
842+
843+ #[ test]
844+ fn no_vector_container_without_agent ( ) {
845+ // Sanity counterpart: with the agent disabled (the default), the StatefulSet carries no
846+ // `vector` sidecar.
847+ let sts = build_sts (
848+ r#"
849+ apiVersion: zookeeper.stackable.tech/v1alpha1
850+ kind: ZookeeperCluster
851+ metadata:
852+ name: simple-zookeeper
853+ spec:
854+ image:
855+ productVersion: "3.9.5"
856+ servers:
857+ roleGroups:
858+ default:
859+ replicas: 1
860+ "# ,
861+ "default" ,
862+ ) ;
863+
864+ let has_vector = sts
865+ . spec
866+ . as_ref ( )
867+ . unwrap ( )
868+ . template
869+ . spec
870+ . as_ref ( )
871+ . unwrap ( )
872+ . containers
873+ . iter ( )
874+ . any ( |c| c. name == VECTOR_CONTAINER_NAME . as_ref ( ) ) ;
875+ assert ! ( !has_vector, "unexpected vector container without the agent" ) ;
876+ }
877+
784878 #[ test]
785879 fn env_overrides_apply_with_role_group_precedence ( ) {
786880 // Candidate #4: `envOverrides` land on the zookeeper container, with the rolegroup value
0 commit comments