239 lines
5.6 KiB
Go
239 lines
5.6 KiB
Go
package k8s_exec
|
|
|
|
import (
|
|
"agent-go/utils"
|
|
"fmt"
|
|
"github.com/magiconair/properties/assert"
|
|
"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_ReplicaSetExists(t *testing.T) {
|
|
|
|
cmiiEnv := "uavcloud-devflight"
|
|
appName := "cmii-admin-data-bf8f87cb7"
|
|
|
|
exists := CmiiOperator.ReplicaSetExists(cmiiEnv, appName)
|
|
|
|
utils.BeautifulPrint(*exists)
|
|
}
|
|
|
|
func TestCmiiK8sOperator_ReplicaSetByAppName(t *testing.T) {
|
|
|
|
cmiiEnv := "uavcloud-devflight"
|
|
appName := "cmii-admin-data"
|
|
|
|
exists := CmiiOperator.ReplicaSetByAppName(cmiiEnv, appName)
|
|
|
|
for _, replicaSet := range exists {
|
|
utils.BeautifulPrint(replicaSet)
|
|
}
|
|
}
|
|
|
|
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 TestCmiiK8sOperator_PodByAppName(t *testing.T) {
|
|
cmiiEnv := "uavcloud-devflight"
|
|
nodeName := "dev-01.ecs.io"
|
|
|
|
exists := CmiiOperator.PodByNodeName(cmiiEnv, nodeName)
|
|
|
|
for _, podInterface := range exists {
|
|
utils.BeautifulPrint(podInterface)
|
|
}
|
|
}
|
|
|
|
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_PodByNodeName(t *testing.T) {
|
|
cmiiEnv := "uavcloud-devflight"
|
|
appName := "cmii-admin-data"
|
|
|
|
exists := CmiiOperator.PodByAppName(cmiiEnv, appName)
|
|
|
|
for _, podInterface := range exists {
|
|
utils.BeautifulPrint(podInterface)
|
|
}
|
|
}
|
|
|
|
func TestCmiiK8sOperator_DeploymentStatusCheck(t *testing.T) {
|
|
|
|
cmiiEnv := "devflight"
|
|
appName := "cmii-uav-gateway"
|
|
|
|
check := CmiiOperator.DeploymentStatusCheck(cmiiEnv, appName, 180)
|
|
assert.Equal(t, check, true, "deployment run failed!")
|
|
|
|
}
|
|
|
|
func TestCmiiK8sOperator_NodeAll(t *testing.T) {
|
|
start := time.Now()
|
|
nodeList := CmiiOperator.NodeAll("dev")
|
|
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()
|
|
}
|
|
}
|