From bb1a86b2b3bd4d6958e4610bf91d967b50bd81b3 Mon Sep 17 00:00:00 2001 From: zhoujunhao <18853925545@163.com> Date: Tue, 12 Jun 2018 12:34:53 +0800 Subject: [PATCH] [ADD] add test code --- appruntimesync/clean/clean.go | 50 ++++++++++++----------------------- 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/appruntimesync/clean/clean.go b/appruntimesync/clean/clean.go index ec9dd6644..6ac51f489 100644 --- a/appruntimesync/clean/clean.go +++ b/appruntimesync/clean/clean.go @@ -25,38 +25,9 @@ func (c *CheanManager) Start() { } -func checkSliceBInA(a []string, b []string) (isIn bool, diffSlice []string) { - - lengthA := len(a) - - for _, valueB := range b { - - temp := valueB //遍历取出B中的元素 - - for j := 0; j < lengthA; j++ { - if temp == a[j] { //如果相同 比较下一个 - break - } else { - if lengthA == (j + 1) { //如果不同 查看a的元素个数及当前比较元素的位置 将不同的元素添加到返回slice中 - diffSlice = append(diffSlice, temp) - fmt.Println("---->", diffSlice) - } - } - } - } - - if len(diffSlice) == 0 { - isIn = true - } else { - isIn = false - } - - return isIn, diffSlice -} - func (c *CheanManager) Run() { nameList := make([]string, 0, 200) - alllist := make([]string,0,300) + alllist := make([]string, 0, 300) Namespaces1, err := c.kubeclient.CoreV1().Namespaces().List(meta_v1.ListOptions{}) if err != nil { fmt.Println(err) @@ -70,12 +41,25 @@ func (c *CheanManager) Run() { ALLTeantsList, err := db.GetManager().TenantDao().GetALLTenants() - for _, v := range ALLTeantsList { alllist = append(alllist, v.UUID) } + + + StatefulSets, err := c.kubeclient.StatefulSets("824b2e9dcc4d461a852ddea20369d377").List(meta_v1.ListOptions{}) + ReplicationControllers, err := c.kubeclient.ReplicationControllers("c69c40ecedae41ca9fbb6c3cec0926f2").List(meta_v1.ListOptions{}) + + fmt.Println(StatefulSets.Items[0].Name) + fmt.Println(StatefulSets.Items[0].GenerateName) + fmt.Println(StatefulSets.Items[0].UID) + fmt.Println(StatefulSets.Items[0].Namespace) + fmt.Println(StatefulSets.Items[0].Labels) + fmt.Println("----------------------") + fmt.Println(ReplicationControllers.Items[0].Name) + fmt.Println(ReplicationControllers.Items[0].GenerateName) + fmt.Println(ReplicationControllers.Items[0].UID) + fmt.Println(ReplicationControllers.Items[0].Namespace) + fmt.Println(ReplicationControllers.Items[0].Labels) - isIn,diffSlice := checkSliceBInA(nameList,alllist) - fmt.Println(isIn,diffSlice) }