@@ -19,6 +19,7 @@ import (
1919
2020 multigresv1alpha1 "github.com/numtide/multigres-operator/api/v1alpha1"
2121 "github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster"
22+ "github.com/numtide/multigres-operator/pkg/resolver"
2223 "github.com/numtide/multigres-operator/pkg/testutil"
2324)
2425
@@ -124,8 +125,10 @@ func TestMultigresClusterReconciliation(t *testing.T) {
124125 },
125126 Spec : multigresv1alpha1.TopoServerSpec {
126127 Etcd : & multigresv1alpha1.EtcdSpec {
127- Image : "etcd:latest" ,
128- Replicas : ptr .To (int32 (3 )), // Default from logic
128+ Image : "etcd:latest" ,
129+ Replicas : ptr .To (int32 (3 )), // Default from logic
130+ Storage : multigresv1alpha1.StorageSpec {Size : resolver .DefaultEtcdStorageSize },
131+ Resources : resolver .DefaultResourcesEtcd (),
129132 },
130133 },
131134 },
@@ -149,8 +152,9 @@ func TestMultigresClusterReconciliation(t *testing.T) {
149152 Spec : corev1.PodSpec {
150153 Containers : []corev1.Container {
151154 {
152- Name : "multiadmin" ,
153- Image : "admin:latest" ,
155+ Name : "multiadmin" ,
156+ Image : "admin:latest" ,
157+ Resources : resolver .DefaultResourcesAdmin (),
154158 },
155159 },
156160 },
@@ -278,18 +282,45 @@ func TestMultigresClusterReconciliation(t *testing.T) {
278282 t .Fatalf ("Failed to create controller, %v" , err )
279283 }
280284
281- // 4. Create the Input
285+ // 4. Create Defaults (Templates)
286+ // The controller expects "default" templates to exist when TemplateDefaults are not specified.
287+ // We create empty templates so the resolution succeeds and falls back to hardcoded defaults or inline specs.
288+ emptyCore := & multigresv1alpha1.CoreTemplate {
289+ ObjectMeta : metav1.ObjectMeta {Name : "default" , Namespace : namespace },
290+ Spec : multigresv1alpha1.CoreTemplateSpec {},
291+ }
292+ if err := k8sClient .Create (ctx , emptyCore ); client .IgnoreAlreadyExists (err ) != nil {
293+ t .Fatalf ("Failed to create default core template: %v" , err )
294+ }
295+
296+ emptyCell := & multigresv1alpha1.CellTemplate {
297+ ObjectMeta : metav1.ObjectMeta {Name : "default" , Namespace : namespace },
298+ Spec : multigresv1alpha1.CellTemplateSpec {},
299+ }
300+ if err := k8sClient .Create (ctx , emptyCell ); client .IgnoreAlreadyExists (err ) != nil {
301+ t .Fatalf ("Failed to create default cell template: %v" , err )
302+ }
303+
304+ emptyShard := & multigresv1alpha1.ShardTemplate {
305+ ObjectMeta : metav1.ObjectMeta {Name : "default" , Namespace : namespace },
306+ Spec : multigresv1alpha1.ShardTemplateSpec {},
307+ }
308+ if err := k8sClient .Create (ctx , emptyShard ); client .IgnoreAlreadyExists (err ) != nil {
309+ t .Fatalf ("Failed to create default shard template: %v" , err )
310+ }
311+
312+ // 5. Create the Input
282313 if err := k8sClient .Create (ctx , tc .cluster ); err != nil {
283314 t .Fatalf ("Failed to create the initial cluster, %v" , err )
284315 }
285316
286- // 5 . Assert Logic: Wait for Children
317+ // 6 . Assert Logic: Wait for Children
287318 // This ensures the controller has run and reconciled at least once successfully
288319 if err := watcher .WaitForMatch (tc .wantResources ... ); err != nil {
289320 t .Errorf ("Resources mismatch:\n %v" , err )
290321 }
291322
292- // 6 . Verify Parent Finalizer (Manual Check)
323+ // 7 . Verify Parent Finalizer (Manual Check)
293324 // We check this manually to avoid fighting with status/spec diffs in the watcher
294325 fetchedCluster := & multigresv1alpha1.MultigresCluster {}
295326 if err := k8sClient .Get (ctx , client .ObjectKeyFromObject (tc .cluster ), fetchedCluster ); err != nil {
0 commit comments