From a2e48115f88dc49192aa11ec2827e285c12487b7 Mon Sep 17 00:00:00 2001 From: falcon <1612759455@qq.com> Date: Tue, 11 Mar 2025 18:31:03 +0800 Subject: [PATCH 1/3] Add notation to Test_lookUpUsedCapacity in pkg\ddc\alluxio\utils_test.go. Signed-off-by: falcon <1612759455@qq.com> --- pkg/ddc/alluxio/utils_test.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pkg/ddc/alluxio/utils_test.go b/pkg/ddc/alluxio/utils_test.go index 06483082640..3dce7a260cf 100644 --- a/pkg/ddc/alluxio/utils_test.go +++ b/pkg/ddc/alluxio/utils_test.go @@ -206,7 +206,20 @@ func Test_isPortInUsed(t *testing.T) { } } + +// Test_lookUpUsedCapacity verifies the functionality of lookUpUsedCapacity in retrieving used capacity values based on node identifiers. +// This test validates two key scenarios: +// 1. Capacity lookup using the node's internal IP address (NodeInternalIP type). +// 2. Capacity lookup using the node's internal DNS hostname (NodeInternalDNS type). +// For each case, it checks if the returned value matches the expected capacity from the provided map. +// +// Parameters: +// - t (testing.T): The test object to run the test case. +// +// Returns: +// - None. func Test_lookUpUsedCapacity(t *testing.T) { + // Define test parameters and initial capacity data type args struct { node corev1.Node usedCapacityMap map[string]int64 @@ -221,7 +234,8 @@ func Test_lookUpUsedCapacity(t *testing.T) { usedCapacityMap := map[string]int64{} usedCapacityMap[internalIP] = usageForInternalIP usedCapacityMap[internalHost] = usageForInternalHost - + + // Define test cases tests := []struct { name string args args @@ -262,6 +276,8 @@ func Test_lookUpUsedCapacity(t *testing.T) { want: usageForInternalHost, }, } + + // Run test cases for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := lookUpUsedCapacity(tt.args.node, tt.args.usedCapacityMap); got != tt.want { From 34a019941ead0f3c3e471f3b586f1e9fde2c8a7c Mon Sep 17 00:00:00 2001 From: falcon <1612759455@qq.com> Date: Wed, 12 Mar 2025 00:26:30 +0800 Subject: [PATCH 2/3] Add notation to Test_lookUpUsedCapacity in pkg\ddc\alluxio\utils_test.go Signed-off-by: falcon <1612759455@qq.com> --- pkg/ddc/alluxio/utils_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/ddc/alluxio/utils_test.go b/pkg/ddc/alluxio/utils_test.go index 3dce7a260cf..24459558c25 100644 --- a/pkg/ddc/alluxio/utils_test.go +++ b/pkg/ddc/alluxio/utils_test.go @@ -206,7 +206,6 @@ func Test_isPortInUsed(t *testing.T) { } } - // Test_lookUpUsedCapacity verifies the functionality of lookUpUsedCapacity in retrieving used capacity values based on node identifiers. // This test validates two key scenarios: // 1. Capacity lookup using the node's internal IP address (NodeInternalIP type). From 3d11480dd62eb8308e22b873f51855344c6f6baa Mon Sep 17 00:00:00 2001 From: falcon <1612759455@qq.com> Date: Thu, 13 Mar 2025 15:54:49 +0800 Subject: [PATCH 3/3] Add notation to Test_lookUpUsedCapacity in pkg\ddc\alluxio\utils_test.go Signed-off-by: falcon <1612759455@qq.com> --- pkg/ddc/alluxio/utils_test.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/ddc/alluxio/utils_test.go b/pkg/ddc/alluxio/utils_test.go index 24459558c25..89c0c47fef7 100644 --- a/pkg/ddc/alluxio/utils_test.go +++ b/pkg/ddc/alluxio/utils_test.go @@ -218,23 +218,21 @@ func Test_isPortInUsed(t *testing.T) { // Returns: // - None. func Test_lookUpUsedCapacity(t *testing.T) { - // Define test parameters and initial capacity data type args struct { node corev1.Node usedCapacityMap map[string]int64 } - + internalIP := "192.168.1.147" var usageForInternalIP int64 = 1024 - + internalHost := "slave001" var usageForInternalHost int64 = 4096 - + usedCapacityMap := map[string]int64{} usedCapacityMap[internalIP] = usageForInternalIP usedCapacityMap[internalHost] = usageForInternalHost - // Define test cases tests := []struct { name string args args @@ -275,8 +273,6 @@ func Test_lookUpUsedCapacity(t *testing.T) { want: usageForInternalHost, }, } - - // Run test cases for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := lookUpUsedCapacity(tt.args.node, tt.args.usedCapacityMap); got != tt.want {