184 lines
4.4 KiB
Go
184 lines
4.4 KiB
Go
package k8s_exec
|
|
|
|
import (
|
|
"agent-go/utils"
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestCmiiK8sOperator_DeploymentAll(t *testing.T) {
|
|
|
|
start := time.Now()
|
|
deploymentList := CmiiOperator.DeploymentAll("devflight")
|
|
elapsed := time.Since(start).Milliseconds()
|
|
fmt.Printf("执行耗时: %d ms\n", elapsed)
|
|
|
|
var nameList []string
|
|
|
|
count := 1
|
|
for _, deployment := range deploymentList {
|
|
if deployment.Spec.Replicas != nil {
|
|
count++
|
|
}
|
|
nameList = append(nameList, deployment.Name)
|
|
}
|
|
|
|
t.Logf("deployment list lenght is => %d", count)
|
|
t.Logf("deployment name list are => %d", count)
|
|
|
|
utils.BeautifulPrint(nameList)
|
|
//for _, deployment := range deploymentList {
|
|
// utils.BeautifulPrint(deployment)
|
|
// println()
|
|
//}
|
|
|
|
}
|
|
func TestCmiiK8sOperator_DeploymentAllInterface(t *testing.T) {
|
|
|
|
start := time.Now()
|
|
deploymentList := CmiiOperator.DeploymentAllInterface("devflight")
|
|
elapsed := time.Since(start).Milliseconds()
|
|
fmt.Printf("执行耗时: %d ms\n", elapsed)
|
|
|
|
t.Logf("deployment list lenght is => %d", len(deploymentList))
|
|
|
|
for _, deployment := range deploymentList {
|
|
utils.BeautifulPrint(deployment)
|
|
println()
|
|
}
|
|
}
|
|
|
|
func TestCmiiK8sOperator_DeploymentFizz(t *testing.T) {
|
|
|
|
start := time.Now()
|
|
deploymentFizz := CmiiOperator.DeploymentFizz("demo", "helm-proxysql")
|
|
elapsed := time.Since(start).Milliseconds()
|
|
fmt.Printf("执行耗时: %d ms\n", elapsed)
|
|
|
|
t.Logf("deployment list lenght is => %d", len(deploymentFizz))
|
|
|
|
cmiiDeploymentInterface := CmiiDeploymentInterface{}
|
|
for _, pod := range deploymentFizz {
|
|
utils.BeautifulPrint(pod)
|
|
|
|
convert := cmiiDeploymentInterface.Convert(pod)
|
|
utils.BeautifulPrint(convert)
|
|
}
|
|
|
|
// elastic search
|
|
|
|
}
|
|
|
|
func TestCmiiK8sOperator_DeploymentScale(t *testing.T) {
|
|
start := time.Now()
|
|
|
|
CmiiOperator.DeploymentScale("devflight", "cmii-uav-depotautoreturn", 0)
|
|
elapsed := time.Since(start).Milliseconds()
|
|
fmt.Printf("执行耗时: %d ms\n", elapsed)
|
|
|
|
}
|
|
|
|
func TestCmiiK8sOperator_DeploymentUpdateTag(t *testing.T) {
|
|
|
|
start := time.Now()
|
|
CmiiOperator.DeploymentUpdateTag("demo", "cmii-uav-platform", "5.2.0-011001")
|
|
elapsed := time.Since(start).Milliseconds()
|
|
fmt.Printf("执行耗时: %d ms\n", elapsed)
|
|
}
|
|
|
|
func TestDeploymentRestart(t *testing.T) {
|
|
CmiiOperator.DeploymentRestart("int", "cmii-uav-user")
|
|
}
|
|
|
|
func TestCmiiK8sOperator_DeploymentOneInterface(t *testing.T) {
|
|
start := time.Now()
|
|
deploy := CmiiOperator.DeploymentOneInterface("devflight", "cmii-uav-depotautoreturn")
|
|
elapsed := time.Since(start).Milliseconds()
|
|
fmt.Printf("执行耗时: %d ms\n", elapsed)
|
|
|
|
utils.BeautifulPrint(*deploy)
|
|
}
|
|
|
|
func TestCmiiK8sOperator_PodAll(t *testing.T) {
|
|
start := time.Now()
|
|
podList := CmiiOperator.PodAll("devflight")
|
|
elapsed := time.Since(start).Milliseconds()
|
|
fmt.Printf("执行耗时: %d ms\n", elapsed)
|
|
|
|
for _, pod := range podList {
|
|
println()
|
|
utils.BeautifulPrint(pod)
|
|
println()
|
|
break
|
|
}
|
|
}
|
|
|
|
func TestCmiiK8sOperator_PodFizz(t *testing.T) {
|
|
start := time.Now()
|
|
podList := CmiiOperator.PodFizz("devflight", "cmii-uav-data-post-process")
|
|
elapsed := time.Since(start).Milliseconds()
|
|
fmt.Printf("执行耗时: %d ms\n", elapsed)
|
|
t.Logf("pod list lenght is => %d", len(podList))
|
|
|
|
cmiiPodInterface := CmiiPodInterface{}
|
|
for _, pod := range podList {
|
|
println()
|
|
utils.BeautifulPrint(pod)
|
|
println()
|
|
convert := cmiiPodInterface.Convert(pod)
|
|
utils.BeautifulPrint(convert)
|
|
}
|
|
|
|
}
|
|
|
|
func TestCmiiDeploymentInterface_Convert(t *testing.T) {
|
|
|
|
log.DebugF("dadasdadasd")
|
|
|
|
}
|
|
|
|
func TestCmiiK8sOperator_PodFizz2(t *testing.T) {
|
|
|
|
start := time.Now()
|
|
podList := CmiiOperator.PodFizz("devflight", "notice")
|
|
elapsed := time.Since(start).Milliseconds()
|
|
fmt.Printf("执行耗时: %d ms\n", elapsed)
|
|
t.Logf("pod list lenght is => %d", len(podList))
|
|
|
|
podInterface := CmiiPodInterface{}
|
|
|
|
for _, pod := range podList {
|
|
convert := podInterface.Convert(pod)
|
|
|
|
println()
|
|
utils.BeautifulPrint(&convert)
|
|
println()
|
|
}
|
|
|
|
}
|
|
|
|
func TestCmiiK8sOperator_NodeAll(t *testing.T) {
|
|
start := time.Now()
|
|
nodeList := CmiiOperator.NodeAll("uat")
|
|
elapsed := time.Since(start).Milliseconds()
|
|
fmt.Printf("执行耗时: %d ms\n", elapsed)
|
|
|
|
for _, node := range nodeList {
|
|
|
|
println()
|
|
utils.BeautifulPrint(node)
|
|
println()
|
|
}
|
|
}
|
|
|
|
func TestCmiiK8sOperator_NodeAllInterface(t *testing.T) {
|
|
cmiiNodeInterfaces := CmiiOperator.NodeAllInterface("uat")
|
|
|
|
for _, nodeInterface := range cmiiNodeInterfaces {
|
|
println()
|
|
utils.BeautifulPrint(nodeInterface)
|
|
println()
|
|
}
|
|
}
|