[Agent] [Executor] fix bugs
This commit is contained in:
@@ -15,7 +15,7 @@ func BasicCommandExists(commandName string) bool {
|
||||
cmd := exec.Command("command", "-v", commandName)
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
log.DebugF("指令 %s 不存在", commandName)
|
||||
log.DebugF("指令 %s 不存在 => %s", commandName, err.Error())
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
|
||||
@@ -2,6 +2,7 @@ package executor
|
||||
|
||||
import (
|
||||
"github.com/magiconair/properties/assert"
|
||||
"strconv"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -57,3 +58,11 @@ func TestBasicSystemdUp(t *testing.T) {
|
||||
t.Logf("result ok is %v resultLog is %v", ok, resultLog)
|
||||
|
||||
}
|
||||
|
||||
func TestBasicCommandExists(t *testing.T) {
|
||||
|
||||
exists := BasicCommandExists("docker-compose")
|
||||
|
||||
t.Logf("command exists is => %s", strconv.FormatBool(exists))
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +34,11 @@ var wgetCommand = []string{
|
||||
"/home/wdd/IdeaProjects/ProjectOctopus/agent-go/executor/script/123",
|
||||
}
|
||||
|
||||
var echoPathCommand = []string{
|
||||
"echo",
|
||||
"$PATH",
|
||||
}
|
||||
|
||||
var pipelineCommandFalse = []string{
|
||||
"ls",
|
||||
"/etc",
|
||||
@@ -67,7 +72,7 @@ func TestReadTimeOutput(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAllCommandExecutor(t *testing.T) {
|
||||
ok, result := AllCommandExecutor(wgetCommand)
|
||||
ok, result := AllCommandExecutor(echoPathCommand)
|
||||
|
||||
t.Logf("执行结果为 => %#v", ok)
|
||||
t.Logf("执行日志为 => %#v", result)
|
||||
|
||||
Reference in New Issue
Block a user