[ Agent ] [ CMII ] - 新增Node部分

This commit is contained in:
zeaslity
2024-01-11 14:54:01 +08:00
parent bc231b0866
commit 3800dc57af
19 changed files with 2036 additions and 143 deletions

View File

@@ -2,8 +2,10 @@ package k8s_exec
import (
"agent-go/utils"
"fmt"
"github.com/magiconair/properties/assert"
"testing"
"time"
)
func TestFindAppNotHealthyOrRestartCountGreaterThanN(t *testing.T) {
@@ -33,7 +35,7 @@ func TestFindDeploymentReplicasSmallerThanN(t *testing.T) {
func TestGetCmiiAllDeploymentFromEnv(t *testing.T) {
BackupAllDeploymentFromEnv("uat")
BackupAllDeploymentFromEnv("uavms")
}
@@ -48,7 +50,9 @@ func TestBackupAllCmiiDeploymentToMap(t *testing.T) {
func TestUpdateCmiiDeploymentImageTag(t *testing.T) {
//tag := UpdateCmiiDeploymentImageTag("devflight", "cmii-uav-depotautoreturn", "123sdsa45678")
tag := UpdateCmiiDeploymentImageTag("demo", "cmii-uav-platform", "5.2.0-011004")
//tag := UpdateCmiiDeploymentImageTag("demo", "cmii-uav-platform", "5.2.0-011101")
tag := UpdateCmiiDeploymentImageTag("demo", "cmii-uav-waypoint", "5.2.0-011102")
//tag := UpdateCmiiDeploymentImageTag("uavms", "uavms-lowaltitude-platform", "5.1.0-011103")
assert.Equal(t, tag, true, "update image tag failed !")
}
@@ -64,6 +68,10 @@ func TestRestartCmiiBackendDeployment(t *testing.T) {
RestartCmiiBackendDeployment("devflight")
}
func TestRestartCmiiFrontendDeployment(t *testing.T) {
RestartCmiiFrontendDeployment("devflight")
}
func TestFindDeploymentNotHealthy(t *testing.T) {
notHealthy := FindDeploymentNotHealthy("devflight")
@@ -72,3 +80,52 @@ func TestFindDeploymentNotHealthy(t *testing.T) {
utils.BeautifulPrint(deploymentInterface)
}
}
func TestFindAllNodeNotHealthy(t *testing.T) {
start := time.Now()
allNodeNotHealthy := FindAllNodeNotHealthy()
elapsed := time.Since(start).Milliseconds()
fmt.Printf("执行耗时: %d ms\n", elapsed)
for _, nodeInterface := range allNodeNotHealthy {
println()
utils.BeautifulPrint(nodeInterface)
println()
}
}
func TestFindPodNotHealthy(t *testing.T) {
podNotHealthy := FindPodNotHealthy("int")
podNotHealthy = FilterAllCmiiPodSoft(podNotHealthy)
for _, podInterface := range podNotHealthy {
t.Logf("[%s] [%s]", podInterface.Name, podInterface.PodPhase)
}
}
func TestFindPodNotHealthy_And_Delete(t *testing.T) {
podNotHealthy := FindPodNotHealthy("int")
podNotHealthy = FilterAllCmiiPodSoft(podNotHealthy)
for _, podInterface := range podNotHealthy {
t.Logf("[%s] [%s]", podInterface.Name, podInterface.PodPhase)
podDelete := CmiiOperator.PodDelete(podInterface.Namespace, podInterface.Name)
assert.Equal(t, podDelete, true, "delete of ", podInterface.Namespace, podInterface.Name, " failed !")
}
}
func TestFilterAllCmiiAppStrict(t *testing.T) {
allInterface := CmiiOperator.DeploymentAllInterface("devflight")
FilterAllCmiiAppStrict(allInterface)
}
func TestRestartDeploymentFromList(t *testing.T) {
allInterface := CmiiOperator.DeploymentAllInterface("devflight")
allInterface = FilterAllCmiiAppSoft(allInterface)
RestartDeploymentFromList(allInterface)
}