@@ -923,25 +923,12 @@ pub fn error_policy(
923923
924924#[ cfg( test) ]
925925mod test {
926- use std:: { collections:: BTreeMap , str:: FromStr } ;
927-
928926 use rstest:: * ;
929- use stackable_operator:: {
930- database_connections:: drivers:: jdbc:: JdbcDatabaseConnection ,
931- v2:: types:: {
932- kubernetes:: { NamespaceName , Uid } ,
933- operator:: ClusterName ,
934- } ,
935- } ;
936927
937928 use super :: * ;
938929 use crate :: {
939- controller:: {
940- build:: { config_map:: build_rolegroup_config_map, properties:: ConfigFileName } ,
941- validate:: { ValidatedCluster , ValidatedClusterConfig } ,
942- } ,
943- crd:: { PROP_SEGMENT_CACHE_LOCATIONS , authentication:: AuthenticationClassesResolved } ,
944- extensions:: get_extension_list,
930+ controller:: build:: { config_map:: build_rolegroup_config_map, properties:: ConfigFileName } ,
931+ crd:: PROP_SEGMENT_CACHE_LOCATIONS ,
945932 } ;
946933
947934 #[ rstest]
@@ -960,82 +947,23 @@ mod test {
960947 #[ case] tested_rolegroup_name : & str ,
961948 #[ case] expected_druid_segment_cache_property : & str ,
962949 ) {
963- let cluster_cr =
964- std:: fs:: File :: open ( format ! ( "test/resources/druid_controller/{druid_manifest}" ) )
950+ let yaml =
951+ std:: fs:: read_to_string ( format ! ( "test/resources/druid_controller/{druid_manifest}" ) )
965952 . unwrap ( ) ;
966- let deserializer = serde_yaml:: Deserializer :: from_reader ( & cluster_cr) ;
967- let druid: v1alpha1:: DruidCluster =
968- serde_yaml:: with:: singleton_map_recursive:: deserialize ( deserializer) . unwrap ( ) ;
969-
970- let resolved_product_image: ResolvedProductImage = druid
971- . spec
972- . image
973- . resolve (
974- CONTAINER_IMAGE_BASE_NAME ,
975- "oci.example.org" ,
976- crate :: built_info:: PKG_VERSION ,
977- )
978- . expect ( "test: resolved product image is always valid" ) ;
953+ let druid = crate :: controller:: validate:: test_support:: druid_from_yaml ( & yaml) ;
979954
980- let druid_tls_security = DruidTlsSecurity :: new (
981- & AuthenticationClassesResolved {
982- auth_classes : vec ! [ ] ,
983- } ,
984- Some ( "tls" . to_string ( ) ) ,
985- ) ;
955+ let cluster = crate :: controller:: validate:: test_support:: validated_cluster ( & druid) ;
986956
987957 // The segment cache property is injected dynamically by the config_map builder from the
988958 // merged resources of the validated role group config.
989- let rg = druid
990- . merged_role ( & DruidRole :: Historical )
991- . expect ( "merged historical role" )
959+ let rg = cluster
960+ . role_group_configs
961+ . get ( & DruidRole :: Historical )
962+ . expect ( "historical role groups" )
992963 . get ( tested_rolegroup_name)
993964 . expect ( "tested rolegroup" )
994965 . clone ( ) ;
995966
996- // The build step renders jvm.config from the erased role; populate the one role the test
997- // exercises.
998- let mut roles = BTreeMap :: new ( ) ;
999- roles. insert (
1000- DruidRole :: Historical ,
1001- druid. get_role ( & DruidRole :: Historical ) ,
1002- ) ;
1003-
1004- let extensions = get_extension_list ( & druid, & druid_tls_security, & None ) ;
1005- let metadata_storage_type = druid
1006- . spec
1007- . cluster_config
1008- . metadata_database
1009- . as_metadata_storage_type ( )
1010- . to_string ( ) ;
1011- let metadata_db_connection = druid
1012- . spec
1013- . cluster_config
1014- . metadata_database
1015- . jdbc_connection_details ( "metadata" )
1016- . expect ( "test: valid metadata db connection" ) ;
1017-
1018- let cluster = ValidatedCluster :: new (
1019- ClusterName :: from_str ( & druid. name_any ( ) ) . expect ( "test: valid cluster name" ) ,
1020- NamespaceName :: from_str ( "default" ) . expect ( "test: valid namespace" ) ,
1021- Uid :: from_str ( "c27b3971-ca72-42c1-80a4-abdfc1db0ddd" ) . expect ( "test: valid uid" ) ,
1022- resolved_product_image. clone ( ) ,
1023- ValidatedClusterConfig {
1024- zookeeper_connection_string : "zookeeper-connection-string" . to_string ( ) ,
1025- opa_connection_string : None ,
1026- s3_connection : None ,
1027- deep_storage_bucket_name : None ,
1028- druid_tls_security,
1029- druid_auth_config : None ,
1030- extensions,
1031- metadata_storage_type,
1032- metadata_db_connection,
1033- deep_storage : druid. spec . cluster_config . deep_storage . clone ( ) ,
1034- } ,
1035- BTreeMap :: new ( ) ,
1036- roles,
1037- ) ;
1038-
1039967 let rolegroup_ref = RoleGroupRef {
1040968 cluster : ObjectRef :: from_obj ( & druid) ,
1041969 role : DruidRole :: Historical . to_string ( ) ,
0 commit comments