From a83067c77c9aa56a409f36181207ca949791c088 Mon Sep 17 00:00:00 2001 From: windows <1525454094@qq.com> Date: Sun, 9 Mar 2025 15:59:53 +0800 Subject: [PATCH 1/2] Add comments/notation to TestTransformShortCircuit in pkg\ddc\alluxio\transform_test.go. Signed-off-by: windows <1525454094@qq.com> --- pkg/ddc/alluxio/transform_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pkg/ddc/alluxio/transform_test.go b/pkg/ddc/alluxio/transform_test.go index 4f27550d119..d7d147cd3ae 100755 --- a/pkg/ddc/alluxio/transform_test.go +++ b/pkg/ddc/alluxio/transform_test.go @@ -351,6 +351,33 @@ func TestGenerateStaticPorts(t *testing.T) { } } +// TestTransformShortCircuit 测试 AlluxioEngine 的 transformShortCircuit 方法。 +// 该测试函数验证了在不同存储层级配置下,AlluxioEngine 是否正确处理短路策略(Short Circuit Policy)和短路配置(Short Circuit Configuration)。 +// +// 测试用例包括: +// 1. 当存储层级包含 emptyDir 类型的卷时,验证短路策略和短路配置是否正确设置。 +// 2. 当存储层级不包含 emptyDir 类型的卷时,验证短路策略和短路配置是否正确设置。 +// +// 每个测试用例通过模拟 RuntimeInfo 的 GetTieredStoreInfo 方法,提供不同的存储层级配置, +// 并检查 AlluxioEngine 是否正确处理这些配置,生成预期的短路策略和属性。 +// +// 参数: +// - t *testing.T:测试框架提供的测试对象,用于报告测试失败和日志记录。 +// +// 测试用例结构: +// - Name:测试用例的名称,描述测试的场景。 +// - RuntimeInfo:模拟的 RuntimeInfo 对象,提供存储层级信息。 +// - MockPatchFunc:用于模拟 RuntimeInfo 的 GetTieredStoreInfo 方法,返回特定的存储层级配置。 +// - Value:Alluxio 配置对象,用于存储 transformShortCircuit 方法的输出。 +// - want:期望的结果,包括短路策略、短路配置和属性键值对。 +// +// 测试逻辑: +// 1. 使用 gomonkey 库模拟 RuntimeInfo 的 GetTieredStoreInfo 方法,返回测试用例中定义的存储层级配置。 +// 2. 调用 transformShortCircuit 方法,处理 RuntimeInfo 和 Alluxio 配置。 +// 3. 检查 Alluxio 配置中的 Fuse.ShortCircuitPolicy 是否符合预期。 +// 4. 检查 Alluxio 配置中的 ShortCircuit 结构体是否符合预期。 +// 5. 如果测试用例中定义了期望的属性键值对,检查 Alluxio 配置中的属性是否正确设置。 +// 6. 重置 gomonkey 的补丁,确保不影响其他测试用例。 func TestTransformShortCircuit(t *testing.T) { engine := &AlluxioEngine{Log: fake.NullLogger()} From 8bef50ac87ba85756728121024c3f99e9bec7c4f Mon Sep 17 00:00:00 2001 From: windows <1525454094@qq.com> Date: Mon, 17 Mar 2025 17:34:07 +0800 Subject: [PATCH 2/2] Add note in English Signed-off-by: windows <1525454094@qq.com> --- pkg/ddc/alluxio/transform_test.go | 46 ++++++++++++++++--------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/pkg/ddc/alluxio/transform_test.go b/pkg/ddc/alluxio/transform_test.go index d7d147cd3ae..1de61d5516e 100755 --- a/pkg/ddc/alluxio/transform_test.go +++ b/pkg/ddc/alluxio/transform_test.go @@ -351,33 +351,35 @@ func TestGenerateStaticPorts(t *testing.T) { } } -// TestTransformShortCircuit 测试 AlluxioEngine 的 transformShortCircuit 方法。 -// 该测试函数验证了在不同存储层级配置下,AlluxioEngine 是否正确处理短路策略(Short Circuit Policy)和短路配置(Short Circuit Configuration)。 +// TestTransformShortCircuit tests the transformShortCircuit method of the AlluxioEngine. +// This test validates if the AlluxioEngine correctly handles the short circuit policy and configuration +// under different tiered storage configurations. // -// 测试用例包括: -// 1. 当存储层级包含 emptyDir 类型的卷时,验证短路策略和短路配置是否正确设置。 -// 2. 当存储层级不包含 emptyDir 类型的卷时,验证短路策略和短路配置是否正确设置。 +// Test cases include: +// 1. When the storage tier contains an emptyDir type volume, verify if the short circuit policy and configuration are correctly set. +// 2. When the storage tier does not contain an emptyDir type volume, verify if the short circuit policy and configuration are correctly set. // -// 每个测试用例通过模拟 RuntimeInfo 的 GetTieredStoreInfo 方法,提供不同的存储层级配置, -// 并检查 AlluxioEngine 是否正确处理这些配置,生成预期的短路策略和属性。 +// Each test case simulates the GetTieredStoreInfo method of RuntimeInfo, providing different storage tier configurations, +// and checks whether the AlluxioEngine correctly processes these configurations, generating the expected short circuit policy and attributes. // -// 参数: -// - t *testing.T:测试框架提供的测试对象,用于报告测试失败和日志记录。 +// Parameters: +// - t *testing.T: The testing framework's testing object, used to report test failures and log outputs. // -// 测试用例结构: -// - Name:测试用例的名称,描述测试的场景。 -// - RuntimeInfo:模拟的 RuntimeInfo 对象,提供存储层级信息。 -// - MockPatchFunc:用于模拟 RuntimeInfo 的 GetTieredStoreInfo 方法,返回特定的存储层级配置。 -// - Value:Alluxio 配置对象,用于存储 transformShortCircuit 方法的输出。 -// - want:期望的结果,包括短路策略、短路配置和属性键值对。 +// Test case structure: +// - Name: The name of the test case, describing the scenario being tested. +// - RuntimeInfo: The simulated RuntimeInfo object that provides storage tier information. +// - MockPatchFunc: A function that mocks the GetTieredStoreInfo method of RuntimeInfo, returning a specific storage tier configuration. +// - Value: The Alluxio configuration object that stores the output of the transformShortCircuit method. +// - want: The expected result, including the short circuit policy, configuration, and key-value pairs of properties. // -// 测试逻辑: -// 1. 使用 gomonkey 库模拟 RuntimeInfo 的 GetTieredStoreInfo 方法,返回测试用例中定义的存储层级配置。 -// 2. 调用 transformShortCircuit 方法,处理 RuntimeInfo 和 Alluxio 配置。 -// 3. 检查 Alluxio 配置中的 Fuse.ShortCircuitPolicy 是否符合预期。 -// 4. 检查 Alluxio 配置中的 ShortCircuit 结构体是否符合预期。 -// 5. 如果测试用例中定义了期望的属性键值对,检查 Alluxio 配置中的属性是否正确设置。 -// 6. 重置 gomonkey 的补丁,确保不影响其他测试用例。 +// Test logic: +// 1. Use the gomonkey library to mock the GetTieredStoreInfo method of RuntimeInfo to return the storage tier configuration defined in the test case. +// 2. Call the transformShortCircuit method to process the RuntimeInfo and Alluxio configuration. +// 3. Check whether the Fuse.ShortCircuitPolicy in the Alluxio configuration matches the expected value. +// 4. Check whether the ShortCircuit structure in the Alluxio configuration matches the expected value. +// 5. If the test case defines expected property key-value pairs, check whether the properties in the Alluxio configuration are set correctly. +// 6. Reset the gomonkey patch to ensure no impact on other test cases. + func TestTransformShortCircuit(t *testing.T) { engine := &AlluxioEngine{Log: fake.NullLogger()}