mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-03 04:07:51 +08:00
[ADD] add test code
This commit is contained in:
parent
30121d23e7
commit
bb1a86b2b3
@ -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)
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user