@@ -208,12 +208,18 @@ func TestTransformResourcesForWorkerNoValue(t *testing.T) {
208208 }
209209}
210210
211+ // TestTransformResourcesForWorkerWithTieredStore tests resource configuration conversion logic for Alluxio worker with tiered storage settings
212+ // This test validates:
213+ // - Correct transformation of tiered store quotas into Kubernetes resource requests
214+ // - Proper handling of memory resource allocation boundaries
215+ // - Absence of unintended resource limits when not explicitly specified
211216func TestTransformResourcesForWorkerWithTieredStore (t * testing.T ) {
212217 result := resource .MustParse ("20Gi" )
213218
219+ // Test cases structured to validate different tiered storage configurations
214220 var tests = []struct {
215- runtime * datav1alpha1.AlluxioRuntime
216- alluxioValue * Alluxio
221+ runtime * datav1alpha1.AlluxioRuntime // Input Alluxio runtime configuration
222+ alluxioValue * Alluxio // Expected output configuration
217223 }{
218224 {& datav1alpha1.AlluxioRuntime {
219225 ObjectMeta : metav1.ObjectMeta {
@@ -223,37 +229,45 @@ func TestTransformResourcesForWorkerWithTieredStore(t *testing.T) {
223229 Spec : datav1alpha1.AlluxioRuntimeSpec {
224230 TieredStore : datav1alpha1.TieredStore {
225231 Levels : []datav1alpha1.Level {{
226- MediumType : common .Memory ,
227- Quota : & result ,
232+ MediumType : common .Memory , // Memory-based tiered storage configuration
233+ Quota : & result , // 20Gi quota allocation
228234 }},
229235 },
230236 },
231237 }, & Alluxio {
232- Properties : map [string ]string {},
238+ Properties : map [string ]string {}, // Expected empty properties map
233239 }},
234240 }
241+ // Iterate through test cases to validate transformation logic
235242 for _ , test := range tests {
243+ // Initialize test environment with mocked dependencies
236244 engine := & AlluxioEngine {
237- Log : fake .NullLogger (),
245+ Log : fake .NullLogger (), // Discard logging output
238246 name : "test" ,
239247 namespace : "test" ,
240248 }
249+ // Build runtime information with tiered store configuration
241250 engine .runtimeInfo , _ = base .BuildRuntimeInfo ("test" , "test" , "alluxio" , base .WithTieredStore (test .runtime .Spec .TieredStore ))
251+ // Configure Kubernetes API client mock
242252 runtimeObjs := []runtime.Object {}
243253 runtimeObjs = append (runtimeObjs , test .runtime .DeepCopy ())
244254 s := runtime .NewScheme ()
245255 s .AddKnownTypes (datav1alpha1 .GroupVersion , test .runtime )
246256 _ = corev1 .AddToScheme (s )
247257 client := fake .NewFakeClientWithScheme (s , runtimeObjs ... )
248258 engine .Client = client
259+ // Execute core transformation logic
249260 err := engine .transformResourcesForWorker (test .runtime , test .alluxioValue )
261+ // Validate error handling and resource allocation
250262 t .Log (err )
251263 if err != nil {
252264 t .Errorf ("expected no err, got err %v" , err )
253265 }
266+ // Verify memory request matches tiered store quota
254267 if test .alluxioValue .Worker .Resources .Requests [corev1 .ResourceMemory ] != "20Gi" {
255268 t .Errorf ("expected 20Gi, got %v" , test .alluxioValue .Worker .Resources .Requests [corev1 .ResourceMemory ])
256269 }
270+ // Ensure no memory limit is set by default
257271 if result , found := test .alluxioValue .Worker .Resources .Limits [corev1 .ResourceMemory ]; found {
258272 t .Errorf ("expected nil, got %v" , result )
259273 }
0 commit comments