@@ -53,7 +53,6 @@ func init() {
5353// It covers cases where the Helm release exists, doesn't exist, encounters errors during checking/installation,
5454// and verifies the correct handling of each situation through mock implementations and hook injections.
5555func TestSetupMasterInternal (t * testing.T ) {
56- // Mock implementations for helm.CheckRelease under different scenarios
5756 mockExecCheckReleaseCommonFound := func (name string , namespace string ) (exist bool , err error ) {
5857 return true , nil
5958 }
@@ -63,16 +62,13 @@ func TestSetupMasterInternal(t *testing.T) {
6362 mockExecCheckReleaseErr := func (name string , namespace string ) (exist bool , err error ) {
6463 return false , errors .New ("fail to check release" )
6564 }
66-
67- // Mock implementations for helm.InstallRelease under different scenarios
6865 mockExecInstallReleaseCommon := func (name string , namespace string , valueFile string , chartName string ) error {
6966 return nil
7067 }
7168 mockExecInstallReleaseErr := func (name string , namespace string , valueFile string , chartName string ) error {
7269 return errors .New ("fail to install dataload chart" )
7370 }
7471
75- // Helper functions for unhooking mocked implementations
7672 wrappedUnhookCheckRelease := func () {
7773 err := gohook .UnHook (helm .CheckRelease )
7874 if err != nil {
@@ -86,7 +82,6 @@ func TestSetupMasterInternal(t *testing.T) {
8682 }
8783 }
8884
89- // Setup test Kubernetes objects
9085 juicefsSecret := & v1.Secret {
9186 ObjectMeta : metav1.ObjectMeta {
9287 Name : "test" ,
@@ -105,7 +100,6 @@ func TestSetupMasterInternal(t *testing.T) {
105100 testObjs := []runtime.Object {}
106101 testObjs = append (testObjs , (* juicefsruntime ).DeepCopy (), (* juicefsSecret ).DeepCopy ())
107102
108- // Create test dataset objects
109103 var datasetInputs = []datav1alpha1.Dataset {
110104 {
111105 ObjectMeta : metav1.ObjectMeta {
@@ -132,13 +126,11 @@ func TestSetupMasterInternal(t *testing.T) {
132126 }
133127 client := fake .NewFakeClientWithScheme (testScheme , testObjs ... )
134128
135- // Build runtime information
136129 runtimeInfo , err := base .BuildRuntimeInfo ("hbase" , "fluid" , "juicefs" )
137130 if err != nil {
138131 t .Errorf ("fail to create the runtimeInfo with error %v" , err )
139132 }
140133
141- // Initialize JuiceFS engine instance
142134 engine := JuiceFSEngine {
143135 name : "test" ,
144136 namespace : "fluid" ,
@@ -151,14 +143,12 @@ func TestSetupMasterInternal(t *testing.T) {
151143 },
152144 runtimeInfo : runtimeInfo ,
153145 }
154-
155- // Setup port allocator for testing
156146 err = portallocator .SetupRuntimePortAllocator (client , & net.PortRange {Base : 10 , Size : 100 }, "bitmap" , GetReservedPorts )
157147 if err != nil {
158148 t .Fatal (err .Error ())
159149 }
160150
161- // Test case 1: Existing Helm release scenario
151+ // check release found
162152 err = gohook .Hook (helm .CheckRelease , mockExecCheckReleaseCommonFound , nil )
163153 if err != nil {
164154 t .Fatal (err .Error ())
@@ -169,7 +159,7 @@ func TestSetupMasterInternal(t *testing.T) {
169159 }
170160 wrappedUnhookCheckRelease ()
171161
172- // Test case 2: Error during release check
162+ // check release error
173163 err = gohook .Hook (helm .CheckRelease , mockExecCheckReleaseErr , nil )
174164 if err != nil {
175165 t .Fatal (err .Error ())
@@ -180,13 +170,13 @@ func TestSetupMasterInternal(t *testing.T) {
180170 }
181171 wrappedUnhookCheckRelease ()
182172
183- // Test case 3: Missing Helm release scenario
173+ // check release not found
184174 err = gohook .Hook (helm .CheckRelease , mockExecCheckReleaseCommonNotFound , nil )
185175 if err != nil {
186176 t .Fatal (err .Error ())
187177 }
188178
189- // Subcase 3a: Error during release installation
179+ // install release with error
190180 err = gohook .Hook (helm .InstallRelease , mockExecInstallReleaseErr , nil )
191181 if err != nil {
192182 t .Fatal (err .Error ())
@@ -197,7 +187,7 @@ func TestSetupMasterInternal(t *testing.T) {
197187 }
198188 wrappedUnhookInstallRelease ()
199189
200- // Subcase 3b: Successful release installation
190+ // install release successfully
201191 err = gohook .Hook (helm .InstallRelease , mockExecInstallReleaseCommon , nil )
202192 if err != nil {
203193 t .Fatal (err .Error ())
0 commit comments