From 03685c0972b29559125c462b04542b7ecb040ff1 Mon Sep 17 00:00:00 2001 From: HDZ <1416453048@qq.com> Date: Tue, 20 May 2025 21:29:43 +0800 Subject: [PATCH 1/2] Add comments/notation to TestCheckIfRemountRequired(t *testing.T) in pkg\ddc\alluxio\ufs_test.go. Signed-off-by: HDZ <1416453048@qq.com> --- pkg/ddc/alluxio/ufs_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pkg/ddc/alluxio/ufs_test.go b/pkg/ddc/alluxio/ufs_test.go index 445b1a6e4d8..5ea7826ba50 100644 --- a/pkg/ddc/alluxio/ufs_test.go +++ b/pkg/ddc/alluxio/ufs_test.go @@ -1010,6 +1010,29 @@ func TestUpdateMountTime(t *testing.T) { } } +// TestCheckIfRemountRequired tests the checkIfRemountRequired function in AlluxioEngine. +// It verifies whether the system correctly identifies when a remount is required based on: +// - Runtime's last mount time +// - Pod's container start time +// - Dataset mount configurations +// +// Test cases: +// 1. When pod started AFTER last mount time (expect remount) +// - Runtime mount time: yesterday +// - Pod start time: yesterday + 1 day +// - Expected: ["/path"] (remount required) +// 2. When pod started BEFORE last mount time (expect no remount) +// - Runtime mount time: yesterday +// - Pod start time: yesterday - 1 day +// - Expected: [] (no remount needed) +// +// The test: +// - Creates mock runtime, pod and dataset objects +// - Initializes fake Kubernetes client with test objects +// - Mocks AlluxioFileUtils operations: +// - Always reports Ready() = true +// - FindUnmountedAlluxioPaths() returns original paths +// - Compares actual remount paths with expected results func TestCheckIfRemountRequired(t *testing.T) { yesterday := time.Now().AddDate(0, 0, -1) From e55bd73a755bf851300057faeafa1af59dfd9762 Mon Sep 17 00:00:00 2001 From: cheyang Date: Sun, 25 May 2025 10:17:00 +0800 Subject: [PATCH 2/2] fix go fmt issue Signed-off-by: cheyang --- pkg/ddc/alluxio/ufs_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/ddc/alluxio/ufs_test.go b/pkg/ddc/alluxio/ufs_test.go index 5ea7826ba50..4f39e0d4f7b 100644 --- a/pkg/ddc/alluxio/ufs_test.go +++ b/pkg/ddc/alluxio/ufs_test.go @@ -164,6 +164,7 @@ func TestTotalStorageBytes(t *testing.T) { }) } } + // TestTotalFileNums validates the AlluxioEngine's ability to correctly retrieve total file numbers from the Alluxio runtime. // The test performs the following operations: // - Creates mock AlluxioRuntime configurations @@ -173,7 +174,7 @@ func TestTotalStorageBytes(t *testing.T) { // Test Components: // - fields: Contains the Alluxio runtime configuration and engine identity // - tests: Table-driven test cases with expected values and error conditions -//! +// ! // Flow: // 1. Initialize AlluxioEngine with test parameters // 2. Mock Kubernetes command execution using function patch @@ -1030,8 +1031,8 @@ func TestUpdateMountTime(t *testing.T) { // - Creates mock runtime, pod and dataset objects // - Initializes fake Kubernetes client with test objects // - Mocks AlluxioFileUtils operations: -// - Always reports Ready() = true -// - FindUnmountedAlluxioPaths() returns original paths +// - Always reports Ready() = true +// - FindUnmountedAlluxioPaths() returns original paths // - Compares actual remount paths with expected results func TestCheckIfRemountRequired(t *testing.T) { yesterday := time.Now().AddDate(0, 0, -1)