From 172233ead1d1cb89dee7c2be5f57675c5aab5f41 Mon Sep 17 00:00:00 2001 From: cheyang Date: Thu, 3 Feb 2022 19:03:13 +0800 Subject: [PATCH] Support Alluxio, To #37688693 Signed-off-by: cheyang --- pkg/ddc/base/runtime_helper_test.go | 80 +++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/pkg/ddc/base/runtime_helper_test.go b/pkg/ddc/base/runtime_helper_test.go index fcf3db4a86b..ffc42f20e81 100644 --- a/pkg/ddc/base/runtime_helper_test.go +++ b/pkg/ddc/base/runtime_helper_test.go @@ -22,6 +22,7 @@ import ( datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1" "github.com/fluid-cloudnative/fluid/pkg/common" "github.com/fluid-cloudnative/fluid/pkg/utils/fake" + "sigs.k8s.io/controller-runtime/pkg/client" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -500,3 +501,82 @@ func TestGetTemplateToInjectForFuse(t *testing.T) { } } } + +func TestGetFuseDaemonset(t *testing.T) { + type testCase struct { + name string + namespace string + runtimeType string + ds *appsv1.DaemonSet + setClient bool + wantErr bool + } + + tests := []testCase{ + { + name: "alluxio", + namespace: "default", + runtimeType: common.ALLUXIO_RUNTIME, + ds: &appsv1.DaemonSet{ + ObjectMeta: metav1.ObjectMeta{ + Name: "alluxio-fuse", + Namespace: "default", + }, + }, + setClient: true, + wantErr: false, + }, { + name: "jindo", + namespace: "default", + runtimeType: common.JindoRuntime, + ds: &appsv1.DaemonSet{ + ObjectMeta: metav1.ObjectMeta{ + Name: "jindo-jindofs-fuse", + Namespace: "default", + }, + }, + setClient: true, + wantErr: false, + }, { + name: "noclient", + namespace: "default", + runtimeType: common.JindoRuntime, + ds: &appsv1.DaemonSet{ + ObjectMeta: metav1.ObjectMeta{ + Name: "jindo-jindofs-fuse", + Namespace: "default", + }, + }, + setClient: false, + wantErr: true, + }, + } + + for _, test := range tests { + var fakeClient client.Client + if test.setClient { + objs := []runtime.Object{} + s := runtime.NewScheme() + _ = corev1.AddToScheme(s) + _ = datav1alpha1.AddToScheme(s) + _ = appsv1.AddToScheme(s) + objs = append(objs, test.ds) + fakeClient = fake.NewFakeClientWithScheme(s, objs...) + } + + runtimeInfo := RuntimeInfo{ + name: test.name, + namespace: test.namespace, + runtimeType: test.runtimeType, + } + + if fakeClient != nil { + runtimeInfo.SetClient(fakeClient) + } + + _, err := runtimeInfo.getFuseDaemonset() + if (err == nil) == test.wantErr { + t.Errorf("testcase %s is failed, want err %v, got err %v", test.name, test.wantErr, err) + } + } +}