Skip to content

Commit fb903f5

Browse files
committed
go fmt
Signed-off-by: trafalgarzzz <trafalgarz@outlook.com>
1 parent cceec98 commit fb903f5

14 files changed

Lines changed: 89 additions & 84 deletions

pkg/ddc/alluxio/cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ func (e *AlluxioEngine) queryCacheStatus() (states cacheStates, err error) {
6868
// - When the Dataset's UfsTotal field is empty
6969
// - When the Dataset's UfsTotal field contains the metadata sync pending message
7070
// The cached percentage is calculated as (cached bytes / UfsTotal bytes) * 100.
71-
//
71+
//
7272
// Parameters:
7373
// - dataset (v1alpha1.Dataset): Pointer to the Dataset object containing UFS metadata.
7474
// The Status.UfsTotal field must be a valid human-readable size string (e.g. "10GiB")
7575
// - states (cacheStates): Pointer to the cache state structure that will be modified in-place.
7676
// The cached field must be a valid human-readable size string (e.g. "5GiB")
77-
//
77+
//
7878
// Returns:
7979
// - None: Modifies the states.cachedPercentage field directly with formatted percentage string.
8080
// The percentage is stored as a string using cachedPercentageFormat (e.g. "45.60%")

pkg/ddc/alluxio/load_data.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ func (e *AlluxioEngine) genDataLoadValue(image string, targetDataset *datav1alph
175175
// It obtains master pod details, creates file utilities, and checks readiness.
176176
//
177177
// Returns:
178-
// ready bool - Runtime readiness status (true = ready, false = not ready).
178+
//
179+
// ready bool - Runtime readiness status (true = ready, false = not ready).
179180
func (e *AlluxioEngine) CheckRuntimeReady() (ready bool) {
180181
podName, containerName := e.getMasterPodInfo()
181182
fileUtils := operations.NewAlluxioFileUtils(podName, containerName, e.namespace, e.Log)

pkg/ddc/alluxio/master_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,9 @@ func TestCheckMasterReady(t *testing.T) {
166166

167167
// TestShouldSetupMaster tests the ShouldSetupMaster function of AlluxioEngine.
168168
// Functionality: Verifies if the Alluxio master should be set up based on runtime status.
169-
// Parameters:
169+
// Parameters:
170170
// - t *testing.T: Standard testing object for test reporting and logging.
171+
//
171172
// Return: None (testing function).
172173
// Notes:
173174
// - Uses fake client to simulate interactions with Kubernetes API.

pkg/ddc/alluxio/transform_resources.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ func (e *AlluxioEngine) transformResourcesForMaster(runtime *datav1alpha1.Alluxi
4848
}
4949

5050
// transformResourcesForWorker is responsible for transforming and setting resource limits for the Alluxio Worker component.
51-
// This function updates the resource requirements for the Worker and JobWorker based on the runtime configuration
51+
// This function updates the resource requirements for the Worker and JobWorker based on the runtime configuration
5252
// and ensures that memory requests meet the required constraints.
5353
//
5454
// Parameters:
55-
// - runtime: *datav1alpha1.AlluxioRuntime, the runtime configuration of Alluxio, including resource definitions
56-
// for Worker and JobWorker.
55+
// - runtime: *datav1alpha1.AlluxioRuntime, the runtime configuration of Alluxio, including resource definitions
56+
// for Worker and JobWorker.
5757
// - value: *Alluxio, the Alluxio runtime instance used to store the transformed resource information.
58-
//
58+
//
5959
// Return value:
6060
// - error: Returns an error if any issue occurs during resource transformation; otherwise, returns nil.
6161
func (e *AlluxioEngine) transformResourcesForWorker(runtime *datav1alpha1.AlluxioRuntime, value *Alluxio) error {

pkg/ddc/alluxio/transform_resources_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ func TestTransformResourcesForWorkerWithTieredStore(t *testing.T) {
218218

219219
// Test cases structured to validate different tiered storage configurations
220220
var tests = []struct {
221-
runtime *datav1alpha1.AlluxioRuntime // Input Alluxio runtime configuration
222-
alluxioValue *Alluxio // Expected output configuration
221+
runtime *datav1alpha1.AlluxioRuntime // Input Alluxio runtime configuration
222+
alluxioValue *Alluxio // Expected output configuration
223223
}{
224224
{&datav1alpha1.AlluxioRuntime{
225225
ObjectMeta: metav1.ObjectMeta{
@@ -229,20 +229,20 @@ func TestTransformResourcesForWorkerWithTieredStore(t *testing.T) {
229229
Spec: datav1alpha1.AlluxioRuntimeSpec{
230230
TieredStore: datav1alpha1.TieredStore{
231231
Levels: []datav1alpha1.Level{{
232-
MediumType: common.Memory, // Memory-based tiered storage configuration
232+
MediumType: common.Memory, // Memory-based tiered storage configuration
233233
Quota: &result, // 20Gi quota allocation
234234
}},
235235
},
236236
},
237237
}, &Alluxio{
238-
Properties: map[string]string{}, // Expected empty properties map
238+
Properties: map[string]string{}, // Expected empty properties map
239239
}},
240240
}
241241
// Iterate through test cases to validate transformation logic
242242
for _, test := range tests {
243243
// Initialize test environment with mocked dependencies
244244
engine := &AlluxioEngine{
245-
Log: fake.NullLogger(), // Discard logging output
245+
Log: fake.NullLogger(), // Discard logging output
246246
name: "test",
247247
namespace: "test",
248248
}
@@ -472,12 +472,12 @@ func TestTransformResourcesForWorkerWithOnlyRequest(t *testing.T) {
472472
// resource requests are handled as expected.
473473
//
474474
// The function performs the following steps:
475-
// 1. Defines resource requirements with limits for memory (20Gi) and CPU (500m).
476-
// 2. Sets up test cases to validate the transformation logic, including scenarios with and without
477-
// tiered store configurations.
478-
// 3. Initializes an AlluxioEngine instance with a fake client and runtime objects for testing.
479-
// 4. Transforms the resource requirements for the worker using the AlluxioEngine.
480-
// 5. Validates the transformed resource limits and requests against the expected results.
475+
// 1. Defines resource requirements with limits for memory (20Gi) and CPU (500m).
476+
// 2. Sets up test cases to validate the transformation logic, including scenarios with and without
477+
// tiered store configurations.
478+
// 3. Initializes an AlluxioEngine instance with a fake client and runtime objects for testing.
479+
// 4. Transforms the resource requirements for the worker using the AlluxioEngine.
480+
// 5. Validates the transformed resource limits and requests against the expected results.
481481
//
482482
// Test cases include:
483483
// - A scenario where tiered store configuration is provided, ensuring memory limits and requests are set correctly.

pkg/ddc/alluxio/transform_test.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ func TestTransformMaster(t *testing.T) {
183183
}
184184
}
185185

186-
// TestTransformWorkers verifies that the transformWorkers function correctly transforms
187-
// the worker configuration of AlluxioRuntime into the expected Alluxio structure.
188-
// It tests different network modes, node selectors, and image pull secrets to ensure
186+
// TestTransformWorkers verifies that the transformWorkers function correctly transforms
187+
// the worker configuration of AlluxioRuntime into the expected Alluxio structure.
188+
// It tests different network modes, node selectors, and image pull secrets to ensure
189189
// correct transformation behavior.
190190
func TestTransformWorkers(t *testing.T) {
191191
testCases := map[string]struct {
@@ -588,19 +588,21 @@ func TestGetMediumTypeFromVolumeSource(t *testing.T) {
588588
}
589589
}
590590

591-
// TestAlluxioEngine_allocateSinglePort is a unit test function that tests
591+
// TestAlluxioEngine_allocateSinglePort is a unit test function that tests
592592
// the `allocateSinglePort` method of the `AlluxioEngine` struct.
593-
// The function verifies the behavior of port allocation for Alluxio master
593+
// The function verifies the behavior of port allocation for Alluxio master
594594
// and worker components under different scenarios,
595-
// including when properties are set, unset, or when runtime specifications
595+
// including when properties are set, unset, or when runtime specifications
596596
// are provided.
597-
//
597+
//
598598
// Parameters:
599-
// - t: A testing.T object provided by the Go testing framework, used to
599+
// - t: A testing.T object provided by the Go testing framework, used to
600+
//
600601
// manage test state and support formatted test logs.
601602
//
602603
// Returns:
603-
// - None. The function is a test function and does not return any value.
604+
// - None. The function is a test function and does not return any value.
605+
//
604606
// It reports test failures using the `t.Errorf` method.
605607
func TestAlluxioEngine_allocateSinglePort(t *testing.T) {
606608
// Define the fields required for the AlluxioEngine struct.
@@ -902,10 +904,10 @@ func TestAlluxioEngine_allocatePorts(t *testing.T) {
902904
//
903905
// Test Cases:
904906
// 1. "master properties is not null":
905-
// - Ensures that when master-specific properties exist, they override the global properties.
907+
// - Ensures that when master-specific properties exist, they override the global properties.
906908
//
907909
// 2. "properties is not null for master":
908-
// - Ensures that both master-specific and additional global properties are correctly handled.
910+
// - Ensures that both master-specific and additional global properties are correctly handled.
909911
//
910912
// The function iterates over multiple test cases and checks if the transformed properties
911913
// match the expected values. If the transformation does not produce the expected result, the test fails.

pkg/ddc/alluxio/transform_ufs_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import (
2323
v1 "k8s.io/api/core/v1"
2424
)
2525

26-
// TestTransformDatasetToVolume is a unit test function that verifies the transformation of a Dataset into a UFSPath
27-
// in the Alluxio runtime. It ensures that the Dataset's mount points are correctly converted into corresponding
26+
// TestTransformDatasetToVolume is a unit test function that verifies the transformation of a Dataset into a UFSPath
27+
// in the Alluxio runtime. It ensures that the Dataset's mount points are correctly converted into corresponding
2828
// container and host paths.
2929
//
3030
// Parameters:
@@ -60,7 +60,7 @@ func TestTransformDatasetToVolume(t *testing.T) {
6060
}},
6161
},
6262
}, &Alluxio{}, ufsPath},
63-
63+
6464
// Test case 2: Mount with a path specified
6565
{&datav1alpha1.AlluxioRuntime{}, &datav1alpha1.Dataset{
6666
Spec: datav1alpha1.DatasetSpec{
@@ -72,7 +72,7 @@ func TestTransformDatasetToVolume(t *testing.T) {
7272
},
7373
}, &Alluxio{}, ufsPath1},
7474
}
75-
75+
7676
// Iterate through all test cases and run the test.
7777
for _, test := range tests {
7878
// Create an instance of AlluxioEngine to call the function under test.

pkg/ddc/alluxio/utils_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,17 @@ func Test_lookUpUsedCapacity(t *testing.T) {
222222
node corev1.Node
223223
usedCapacityMap map[string]int64
224224
}
225-
225+
226226
internalIP := "192.168.1.147"
227227
var usageForInternalIP int64 = 1024
228-
228+
229229
internalHost := "slave001"
230230
var usageForInternalHost int64 = 4096
231-
231+
232232
usedCapacityMap := map[string]int64{}
233233
usedCapacityMap[internalIP] = usageForInternalIP
234234
usedCapacityMap[internalHost] = usageForInternalHost
235-
235+
236236
tests := []struct {
237237
name string
238238
args args
@@ -485,16 +485,16 @@ func TestGetMasterPod(t *testing.T) {
485485
}
486486
}
487487

488-
// TestGetMasterStatefulset tests the getMasterStatefulset method of the AlluxioEngine struct.
489-
// It verifies that the method correctly retrieves the expected StatefulSet based on the provided
490-
// AlluxioRuntime, name, and namespace. The test includes a sample runtime and expected
491-
// StatefulSet, checking for both successful retrieval and error scenarios.
492-
//
493-
// Parameters:
494-
// - t: The test framework's context, which provides methods for logging and error reporting.
495-
//
496-
// Returns:
497-
// - The test does not return any value, but it reports errors using the t.Error and
488+
// TestGetMasterStatefulset tests the getMasterStatefulset method of the AlluxioEngine struct.
489+
// It verifies that the method correctly retrieves the expected StatefulSet based on the provided
490+
// AlluxioRuntime, name, and namespace. The test includes a sample runtime and expected
491+
// StatefulSet, checking for both successful retrieval and error scenarios.
492+
//
493+
// Parameters:
494+
// - t: The test framework's context, which provides methods for logging and error reporting.
495+
//
496+
// Returns:
497+
// - The test does not return any value, but it reports errors using the t.Error and
498498
// t.Errorf methods to indicate whether the test passed or failed.
499499
func TestGetMasterStatefulset(t *testing.T) {
500500
type fields struct {

pkg/ddc/jindo/dataset_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ func TestUpdateDatasetStatus(t *testing.T) {
253253
}
254254
}
255255

256-
// TestBindToDataset tests the BindToDataset method of JindoEngine to verify whether it can correctly bind the dataset to the runtime
257-
// and update the dataset's cache state and HCFS status. The test creates mock Dataset and JindoRuntime objects,
256+
// TestBindToDataset tests the BindToDataset method of JindoEngine to verify whether it can correctly bind the dataset to the runtime
257+
// and update the dataset's cache state and HCFS status. The test creates mock Dataset and JindoRuntime objects,
258258
// uses a fake client to simulate operations, and finally checks if the dataset's Phase, CacheStates, and HCFSStatus match the expected results.
259259
func TestBindToDataset(t *testing.T) {
260260
testDatasetInputs := []*datav1alpha1.Dataset{

pkg/ddc/jindo/delete_volume_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,19 @@ func doTestCases(testCases []TestCase, t *testing.T) {
8383
//
8484
// Test Strategy:
8585
// 1. Setup test environment with mocked Kubernetes resources:
86-
// - PVs with 'CreatedBy=fluid' annotation to simulate Fluid-managed persistent volumes
87-
// - PVCs with different configurations (normal vs error cases)
88-
// 2. Create 3 test scenarios using parameterized test pattern:
89-
// Case 1: Normal deletion (JindoEngineCommon)
90-
// - Input: Valid PV/PVC without conflicting annotations
91-
// - Expected: Successful deletion (isDeleted=true, isErr=false)
92-
// Case 2: Protected PVC deletion (JindoEngineErr)
93-
// - Input: PVC with 'CreatedBy=fluid' annotation (protected resource)
94-
// - Expected: Failed deletion (isErr=true)
95-
// Case 3: Missing runtime scenario (JindoEngineNoRunTime)
96-
// - Input: Engine with runtime=false configuration
97-
// - Expected: Failed deletion (isErr=true)
98-
// 3. Verification: Uses doTestCases() helper to validate deletion outcomes against expectations
86+
// - PVs with 'CreatedBy=fluid' annotation to simulate Fluid-managed persistent volumes
87+
// - PVCs with different configurations (normal vs error cases)
88+
// 2. Create 3 test scenarios using parameterized test pattern:
89+
// Case 1: Normal deletion (JindoEngineCommon)
90+
// - Input: Valid PV/PVC without conflicting annotations
91+
// - Expected: Successful deletion (isDeleted=true, isErr=false)
92+
// Case 2: Protected PVC deletion (JindoEngineErr)
93+
// - Input: PVC with 'CreatedBy=fluid' annotation (protected resource)
94+
// - Expected: Failed deletion (isErr=true)
95+
// Case 3: Missing runtime scenario (JindoEngineNoRunTime)
96+
// - Input: Engine with runtime=false configuration
97+
// - Expected: Failed deletion (isErr=true)
98+
// 3. Verification: Uses doTestCases() helper to validate deletion outcomes against expectations
9999
//
100100
// Test Resources:
101101
// - fake.NewFakeClientWithScheme: Simulates Kubernetes API server with predefined resources

0 commit comments

Comments
 (0)