report stdout/stderr on failure

This commit is contained in:
Christopher Boumenot 2017-10-10 18:44:10 -07:00
Родитель f21ef819c1
Коммит 69291b8b76
2 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -64,6 +64,19 @@ teardown(){
echo "status_file=$status_file"; [[ "$status_file" = *'Enable succeeded: \n[stdout]\nHelloStdout\n\n[stderr]\nHelloStderr\n'* ]]
}
@test "handler command: enable - captures stdout/stderr into .status on error" {
mk_container sh -c "fake-waagent install && fake-waagent enable && wait-for-enable"
push_settings '
{
"commandToExecute": "ls /does-not-exist"
}' ''
run start_container
echo "$output"
status_file="$(container_read_file /var/lib/waagent/Extension/status/0.status)"
echo "status_file=$status_file"; [[ "$status_file" = *'Enable failed: failed to execute command: command terminated with exit status=2\n[stdout]\n\n[stderr]\nls: cannot access'* ]]
}
@test "handler command: enable - doesn't process the same sequence number again" {
mk_container sh -c \
"fake-waagent install && fake-waagent enable && wait-for-enable && fake-waagent enable && wait-for-enable"

Просмотреть файл

@ -60,7 +60,7 @@ func main() {
msg, err := cmd.f(ctx, hEnv, seqNum)
if err != nil {
ctx.Log("event", "failed to handle", "error", err)
reportStatus(ctx, hEnv, seqNum, status.StatusError, cmd, err.Error())
reportStatus(ctx, hEnv, seqNum, status.StatusError, cmd, err.Error()+msg)
os.Exit(1)
}
reportStatus(ctx, hEnv, seqNum, status.StatusSuccess, cmd, msg)