Files
ProjectOctopus/agent-go/a_executor/BaseFunction_test.go
2024-07-17 10:56:44 +08:00

80 lines
1.8 KiB
Go
Executable File

package a_executor
import (
"testing"
"wdd.io/agent-common/assert"
"wdd.io/agent-go/a_agent"
)
var agentOP = &AgentOsOperator{
InstallCommandPrefix: []string{
"yum", "install", "-y",
},
RemoveCommandPrefix: []string{"yum", "remove", "-y"},
CanAccessInternet: true,
IsOsTypeUbuntu: false,
IsOsTypeCentOS: true,
IsOsTypeEuler: true,
IsAgentInnerWall: true,
AgentArch: "amd64",
AgentOSReleaseCode: "focal",
AgentServerInfo: &a_agent.AgentServerInfo{
ServerName: "",
ServerIPPbV4: "",
ServerIPInV4: "10.250.0.100",
ServerIPPbV6: "",
ServerIPInV6: "",
Location: "",
Provider: "",
ManagePort: "",
CPUCore: "",
CPUBrand: "",
OSInfo: "",
OSKernelInfo: "",
TCPControl: "",
Virtualization: "",
IoSpeed: "",
MemoryTotal: "",
DiskTotal: "",
DiskUsage: "",
Comment: "",
MachineID: "",
AgentVersion: "",
},
OssOfflinePrefix: "http://10.250.0.100:9000/octopus/",
}
func TestBaseFunc(t *testing.T) {
//command := "DISABLE_SELINUX"
//command := "installDocker"
//command := "installDockerCompose"
command := "installHarbor"
funcArgs := []string{
"10.250.0.147",
"",
"",
"",
}
//agentOP.Exec("shutdownFirewall")
//agentOP.Exec("modifyHostname")
//agentOP.Exec("disableSwap")
//agentOP.Exec("enableSwap")
//agentOP.Exec("removeDocker")
//agentOP.Exec("installDocker", "20")
//agentOP.Exec("removeDockerCompose")
//agentOP.Exec("installDockerCompose")
//agentOP.Exec("installHelm")
//agentOP.Exec("installHarbor")
//agentOP.Exec("chronyToMaster", "192.168.0.8")
//agentOP.Exec("installZSH")
//agentOP.Exec("ok")
exec, strings := agentOP.Exec(command, funcArgs...)
assert.Equal(t, exec, true, "exec should be true!")
t.Logf("[%s] exec result are %s", command, strings)
}