@@ -7,16 +7,10 @@ import (
77 "context"
88 "fmt"
99 "net/http"
10- "os"
1110 "reflect"
1211 "testing"
1312 "time"
1413
15- localartifactsetv1alpha1 "github.com/kubean-io/kubean-api/apis/localartifactset/v1alpha1"
16- manifestv1alpha1 "github.com/kubean-io/kubean-api/apis/manifest/v1alpha1"
17- "github.com/kubean-io/kubean/pkg/util"
18-
19- corev1 "k8s.io/api/core/v1"
2014 "k8s.io/apimachinery/pkg/api/meta"
2115 "k8s.io/apimachinery/pkg/runtime"
2216 "k8s.io/apimachinery/pkg/types"
@@ -33,6 +27,8 @@ import (
3327 "github.com/kubean-io/kubean-api/apis"
3428 clusterv1alpha1 "github.com/kubean-io/kubean-api/apis/cluster/v1alpha1"
3529 clusteroperationv1alpha1 "github.com/kubean-io/kubean-api/apis/clusteroperation/v1alpha1"
30+ localartifactsetv1alpha1 "github.com/kubean-io/kubean-api/apis/localartifactset/v1alpha1"
31+ manifestv1alpha1 "github.com/kubean-io/kubean-api/apis/manifest/v1alpha1"
3632 "github.com/kubean-io/kubean-api/constants"
3733 clusterv1alpha1fake "github.com/kubean-io/kubean-api/generated/cluster/clientset/versioned/fake"
3834 clusteroperationv1alpha1fake "github.com/kubean-io/kubean-api/generated/clusteroperation/clientset/versioned/fake"
@@ -177,66 +173,6 @@ func TestCompareClusterConditions(t *testing.T) {
177173 }
178174}
179175
180- func TestFetchKubeanConfigProperty (t * testing.T ) {
181- genController := func () * Controller {
182- return & Controller {
183- Client : newFakeClient (),
184- ClientSet : clientsetfake .NewSimpleClientset (),
185- KubeanClusterSet : clusterv1alpha1fake .NewSimpleClientset (),
186- KubeanClusterOpsSet : clusteroperationv1alpha1fake .NewSimpleClientset (),
187- }
188- }
189- tests := []struct {
190- name string
191- controller * Controller
192- args func (controller * Controller )
193- want int
194- }{
195- {
196- name : "no config and default value" ,
197- controller : genController (),
198- args : func (controller * Controller ) {
199- // do nothing
200- },
201- want : 30 ,
202- },
203- {
204- name : "the config has been set to 25" ,
205- controller : genController (),
206- args : func (controller * Controller ) {
207- os .Setenv ("POD_NAMESPACE" , "" )
208- configMap := & corev1.ConfigMap {}
209- configMap .Name = KubeanConfigMapName
210- configMap .Namespace = util .GetCurrentNSOrDefault ()
211- configMap .Data = map [string ]string {"CLUSTER_OPERATIONS_BACKEND_LIMIT" : "25" }
212- controller .ClientSet .CoreV1 ().ConfigMaps (util .GetCurrentNSOrDefault ()).Create (context .Background (), configMap , metav1.CreateOptions {})
213- },
214- want : 25 ,
215- },
216- {
217- name : "the config has been set to 10000" ,
218- controller : genController (),
219- args : func (controller * Controller ) {
220- os .Setenv ("POD_NAMESPACE" , "" )
221- configMap := & corev1.ConfigMap {}
222- configMap .Name = KubeanConfigMapName
223- configMap .Namespace = util .GetCurrentNSOrDefault ()
224- configMap .Data = map [string ]string {"CLUSTER_OPERATIONS_BACKEND_LIMIT" : "10000" }
225- controller .ClientSet .CoreV1 ().ConfigMaps (util .GetCurrentNSOrDefault ()).Create (context .Background (), configMap , metav1.CreateOptions {})
226- },
227- want : 200 ,
228- },
229- }
230- for _ , test := range tests {
231- t .Run (test .name , func (t * testing.T ) {
232- test .args (test .controller )
233- if test .controller .FetchKubeanConfigProperty ().GetClusterOperationsBackEndLimit () != test .want {
234- t .Fatal ()
235- }
236- })
237- }
238- }
239-
240176func TestSortClusterOperationsByCreation (t * testing.T ) {
241177 controller := & Controller {
242178 Client : newFakeClient (),
0 commit comments