75 lines
2.0 KiB
Go
75 lines
2.0 KiB
Go
package k8s_exec
|
|
|
|
import (
|
|
"agent-go/utils"
|
|
"github.com/magiconair/properties/assert"
|
|
"testing"
|
|
)
|
|
|
|
func TestFindAppNotHealthyOrRestartCountGreaterThanN(t *testing.T) {
|
|
|
|
deploymentRestartCountGreaterThanN := FindAppNotHealthyOrRestartCountGreaterThanN("devflight", 10)
|
|
deploymentRestartCountGreaterThanN = FilterAllCmiiAppSoft(deploymentRestartCountGreaterThanN)
|
|
|
|
for _, deploymentInterface := range deploymentRestartCountGreaterThanN {
|
|
println()
|
|
utils.BeautifulPrint(deploymentInterface)
|
|
println()
|
|
}
|
|
|
|
}
|
|
|
|
func TestFindDeploymentReplicasSmallerThanN(t *testing.T) {
|
|
|
|
deploymentReplicasSmallerThanN := FindDeploymentReplicasSmallerThanN("devflight", 0)
|
|
|
|
for _, deploymentInterface := range deploymentReplicasSmallerThanN {
|
|
println()
|
|
utils.BeautifulPrint(deploymentInterface)
|
|
println()
|
|
}
|
|
|
|
}
|
|
|
|
func TestGetCmiiAllDeploymentFromEnv(t *testing.T) {
|
|
|
|
BackupAllDeploymentFromEnv("uat")
|
|
|
|
}
|
|
|
|
func TestBackupAllCmiiDeploymentToMap(t *testing.T) {
|
|
backendMap, frontendMap := BackupAllCmiiDeploymentToMap("demo")
|
|
|
|
utils.BeautifulPrint(backendMap)
|
|
utils.BeautifulPrint(frontendMap)
|
|
|
|
}
|
|
|
|
func TestUpdateCmiiDeploymentImageTag(t *testing.T) {
|
|
|
|
//tag := UpdateCmiiDeploymentImageTag("devflight", "cmii-uav-depotautoreturn", "123sdsa45678")
|
|
tag := UpdateCmiiDeploymentImageTag("demo", "cmii-uav-platform", "5.2.0-011004")
|
|
|
|
assert.Equal(t, tag, true, "update image tag failed !")
|
|
}
|
|
|
|
func TestRollBackCmiiDeploymentFromUpdateLog(t *testing.T) {
|
|
updateLog := RollBackCmiiDeploymentFromUpdateLog("2024-01-10-14-37-07 uavcloud-devflight cmii-uav-depotautoreturn 12345678 123sdsa45678")
|
|
|
|
assert.Equal(t, updateLog, true, "roll back from update log failed !")
|
|
}
|
|
|
|
func TestRestartCmiiBackendDeployment(t *testing.T) {
|
|
|
|
RestartCmiiBackendDeployment("devflight")
|
|
}
|
|
|
|
func TestFindDeploymentNotHealthy(t *testing.T) {
|
|
notHealthy := FindDeploymentNotHealthy("devflight")
|
|
|
|
notHealthy = FilterAllCmiiAppSoft(notHealthy)
|
|
for _, deploymentInterface := range notHealthy {
|
|
utils.BeautifulPrint(deploymentInterface)
|
|
}
|
|
}
|