@@ -361,6 +361,34 @@ func TestGenerateStaticPorts(t *testing.T) {
361361 }
362362}
363363
364+ // TestTransformShortCircuit tests the transformShortCircuit method of the AlluxioEngine.
365+ // This test validates if the AlluxioEngine correctly handles the short circuit policy and configuration
366+ // under different tiered storage configurations.
367+ //
368+ // Test cases include:
369+ // 1. When the storage tier contains an emptyDir type volume, verify if the short circuit policy and configuration are correctly set.
370+ // 2. When the storage tier does not contain an emptyDir type volume, verify if the short circuit policy and configuration are correctly set.
371+ //
372+ // Each test case simulates the GetTieredStoreInfo method of RuntimeInfo, providing different storage tier configurations,
373+ // and checks whether the AlluxioEngine correctly processes these configurations, generating the expected short circuit policy and attributes.
374+ //
375+ // Parameters:
376+ // - t *testing.T: The testing framework's testing object, used to report test failures and log outputs.
377+ //
378+ // Test case structure:
379+ // - Name: The name of the test case, describing the scenario being tested.
380+ // - RuntimeInfo: The simulated RuntimeInfo object that provides storage tier information.
381+ // - MockPatchFunc: A function that mocks the GetTieredStoreInfo method of RuntimeInfo, returning a specific storage tier configuration.
382+ // - Value: The Alluxio configuration object that stores the output of the transformShortCircuit method.
383+ // - want: The expected result, including the short circuit policy, configuration, and key-value pairs of properties.
384+ //
385+ // Test logic:
386+ // 1. Use the gomonkey library to mock the GetTieredStoreInfo method of RuntimeInfo to return the storage tier configuration defined in the test case.
387+ // 2. Call the transformShortCircuit method to process the RuntimeInfo and Alluxio configuration.
388+ // 3. Check whether the Fuse.ShortCircuitPolicy in the Alluxio configuration matches the expected value.
389+ // 4. Check whether the ShortCircuit structure in the Alluxio configuration matches the expected value.
390+ // 5. If the test case defines expected property key-value pairs, check whether the properties in the Alluxio configuration are set correctly.
391+ // 6. Reset the gomonkey patch to ensure no impact on other test cases.
364392func TestTransformShortCircuit (t * testing.T ) {
365393 engine := & AlluxioEngine {Log : fake .NullLogger ()}
366394
0 commit comments