Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions pkg/ddc/alluxio/transform_volumes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,18 @@ func TestTransformMasterVolumes(t *testing.T) {

}

// TestTransformWorkerVolumes is a unit test function that tests the transformWorkerVolumes method of the AlluxioEngine.
// It defines a series of test cases to verify the correctness of volume and volume mount transformations for the Alluxio worker.
// Each test case includes an input AlluxioRuntime object and an expected Alluxio object, along with a flag to indicate if an error is expected.
// The function iterates through each test case, applies the transformWorkerVolumes method, and checks if the output matches the expected result.
// If an error occurs and it is not expected, or if the output does not match the expected result, the test fails with an appropriate error message.
func TestTransformWorkerVolumes(t *testing.T) {
type testCase struct {
name string
runtime *datav1alpha1.AlluxioRuntime
expect *Alluxio
expectErr bool
}

testCases := []testCase{
{
name: "all",
Expand All @@ -155,7 +159,8 @@ func TestTransformWorkerVolumes(t *testing.T) {
},
},
},
}, Worker: datav1alpha1.AlluxioCompTemplateSpec{
},
Worker: datav1alpha1.AlluxioCompTemplateSpec{
VolumeMounts: []corev1.VolumeMount{
{
Name: "test",
Expand All @@ -176,7 +181,8 @@ func TestTransformWorkerVolumes(t *testing.T) {
},
},
},
}, VolumeMounts: []corev1.VolumeMount{
},
VolumeMounts: []corev1.VolumeMount{
{
Name: "test",
MountPath: "/test",
Expand All @@ -185,7 +191,8 @@ func TestTransformWorkerVolumes(t *testing.T) {
},
},
expectErr: false,
}, {
},
{
name: "onlyVolumeMounts",
runtime: &datav1alpha1.AlluxioRuntime{
Spec: datav1alpha1.AlluxioRuntimeSpec{
Expand All @@ -210,7 +217,8 @@ func TestTransformWorkerVolumes(t *testing.T) {
},
},
},
}, VolumeMounts: []corev1.VolumeMount{
},
VolumeMounts: []corev1.VolumeMount{
{
Name: "test",
MountPath: "/test",
Expand All @@ -221,11 +229,11 @@ func TestTransformWorkerVolumes(t *testing.T) {
expectErr: true,
},
}

for _, testCase := range testCases {
engine := &AlluxioEngine{}
got := &Alluxio{}
err := engine.transformWorkerVolumes(testCase.runtime, got)

if err != nil && !testCase.expectErr {
t.Errorf("Got unexpected error %v", err)
}
Expand All @@ -237,9 +245,7 @@ func TestTransformWorkerVolumes(t *testing.T) {
if !reflect.DeepEqual(got, testCase.expect) {
t.Errorf("want %v, got %v for testcase %s", testCase.expect, got, testCase.name)
}

}

}

func TestTransformFuseVolumes(t *testing.T) {
Expand Down
Loading