Skip to content
Closed
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
59 changes: 37 additions & 22 deletions pkg/ddc/alluxio/deprecated_label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,73 +75,88 @@

}

// TestAlluxioEngine_HasDeprecatedCommonLabelname tests the detection of deprecated labels in the Alluxio engine.
// This test verifies whether the HasDeprecatedCommonLabelname method can correctly identify if a DaemonSet
// contains deprecated label formats.
func TestAlluxioEngine_HasDeprecatedCommonLabelname(t *testing.T) {

// worker-name = e.name+"-worker"
daemonSetWithSelector := &v1.DaemonSet{
ObjectMeta: metav1.ObjectMeta{
Name: "hbase-worker",
Namespace: "fluid",
Name: "hbase-worker",
Namespace: "fluid",
},
Spec: v1.DaemonSetSpec{
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{NodeSelector: map[string]string{"data.fluid.io/storage-fluid-hbase": "selector"}},
Spec: corev1.PodSpec{
NodeSelector: map[string]string{
"data.fluid.io/storage-fluid-hbase": "selector",
},
},
},
},
}

daemonSetWithoutSelector := &v1.DaemonSet{
ObjectMeta: metav1.ObjectMeta{
Name: "hadoop-worker",
Namespace: "fluid",
Name: "hadoop-worker",
Namespace: "fluid", /
},
Spec: v1.DaemonSetSpec{
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{NodeSelector: map[string]string{"data.fluid.io/storage-fluid-hbase": "selector"}},
Spec: corev1.PodSpec{
NodeSelector: map[string]string{
"data.fluid.io/storage-fluid-hbase": "selector",
},
},
},
},
}

Check failure on line 112 in pkg/ddc/alluxio/deprecated_label_test.go

View workflow job for this annotation

GitHub Actions / staticcheck

expected operand, found '/' (compile)

Check failure on line 112 in pkg/ddc/alluxio/deprecated_label_test.go

View workflow job for this annotation

GitHub Actions / staticcheck

syntax error: unexpected /, expected expression (compile)

Check failure on line 112 in pkg/ddc/alluxio/deprecated_label_test.go

View workflow job for this annotation

GitHub Actions / lint

expected operand, found '/' (typecheck)

Check failure on line 112 in pkg/ddc/alluxio/deprecated_label_test.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected /, expected expression (typecheck)

runtimeObjs := []runtime.Object{}
runtimeObjs = append(runtimeObjs, daemonSetWithSelector)
runtimeObjs = append(runtimeObjs, daemonSetWithoutSelector)
scheme := runtime.NewScheme()
scheme.AddKnownTypes(v1.SchemeGroupVersion, daemonSetWithSelector)
fakeClient := fake.NewFakeClientWithScheme(scheme, runtimeObjs...)

testCases := []struct {
name string
namespace string
out bool
isErr bool
name string
namespace string
out bool
isErr bool
}{
{
name: "hbase",
name: "hbase",
namespace: "fluid",
out: true,
out: true,
isErr: false,
},
{
name: "none",
name: "none",
namespace: "fluid",
out: false,
out: false,
isErr: false,
},
{
name: "hadoop",
name: "hadoop",
namespace: "fluid",
out: false,
out: false,
isErr: false,
},
}

for _, test := range testCases {
engine := getTestAlluxioEngine(fakeClient, test.name, test.namespace)
out, err := engine.HasDeprecatedCommonLabelname()
if out != test.out {
t.Errorf("input parameter is %s-%s,expected %t, got %t", test.namespace, test.name, test.out, out)
t.Errorf(
"Dataset %s/%s test failed: expected %t, got %t",
test.namespace, test.name, test.out, out,
)
}
isErr := err != nil
if isErr != test.isErr {
t.Errorf("input parameter is %s-%s,expected %t, got %t", test.namespace, test.name, test.isErr, isErr)
t.Errorf(

Check failure on line 156 in pkg/ddc/alluxio/deprecated_label_test.go

View workflow job for this annotation

GitHub Actions / lint

missing ',' in composite literal (typecheck)
"Dataset %s/%s error check failed: expected error %t, got %t",
test.namespace, test.name, test.isErr, isErr,
)

Check failure on line 159 in pkg/ddc/alluxio/deprecated_label_test.go

View workflow job for this annotation

GitHub Actions / lint

missing ',' in composite literal (typecheck)
}
}
}
Loading