[ADD] add test code

This commit is contained in:
zhoujunhao 2018-06-13 11:43:35 +08:00
parent 46e970ef3c
commit e80d6cba78

View File

@ -39,9 +39,9 @@ func NewCheanManager(ctx context.Context, kubeclient *kubernetes.Clientset) *Che
func (c *CheanManager) Start() { func (c *CheanManager) Start() {
logrus.Info("clean up module starts....") logrus.Info("clean up module starts....")
go c.CollectingTasks() c.CollectingTasks()
fmt.Println("TaskSlice",TaskSlice) fmt.Println("TaskSlice",TaskSlice)
go c.PerformTasks() c.PerformTasks()
} }
// InSlice checks given string in string slice or not. // InSlice checks given string in string slice or not.
@ -307,16 +307,17 @@ func (c *CheanManager) DeleteResources(deleteMap map[string]string) {
} }
func (c *CheanManager) CollectingTasks() { func (c *CheanManager) CollectingTasks() {
util.Exec(c.ctx, func() error { run := func() { util.Exec(c.ctx, func() error {
c.cleanNamespaces() c.cleanNamespaces()
c.cleanStaAndRep() c.cleanStaAndRep()
c.cleanService() c.cleanService()
return nil return nil
}, time.Minute*24) }, time.Minute*24)}
go run()
} }
func (c *CheanManager) PerformTasks() { func (c *CheanManager) PerformTasks() {
util.Exec(c.ctx, func() error { run := func() {util.Exec(c.ctx, func() error {
fmt.Println("长度:",len(TaskSlice)) fmt.Println("长度:",len(TaskSlice))
for _, v := range TaskSlice { for _, v := range TaskSlice {
if v.IsTimeout() { if v.IsTimeout() {
@ -324,5 +325,6 @@ func (c *CheanManager) PerformTasks() {
} }
} }
return nil return nil
}, time.Minute*12) }, time.Minute*12)}
go run()
} }