kudobuilder / kuttl

KUbernetes Test TooL (kuttl)
https://kuttl.dev
Apache License 2.0
636 stars 83 forks source link

Use .Script to describe command if .Command is empty. #494

Closed porridge closed 5 months ago

porridge commented 8 months ago

What this PR does / why we need it:

Introduce a String() method that summarizes a command paying attention to .Script too, and use it in appropriate places.

While at it, also provide a command summary when it exits non-zero. Before this change, the error was:

    logger.go:42: 12:47:52 | basic-central/62-unset-expose-monitoring | running command: [some command and args]
    logger.go:42: 12:47:52 | basic-central/62-unset-expose-monitoring | <command output, if any>
    logger.go:42: 12:47:53 | basic-central/62-unset-expose-monitoring | test step failed 62-unset-expose-monitoring
    logger.go:42: 12:47:53 | basic-central/62-unset-expose-monitoring | collecting log output for [type==pod,label: app=central]
    logger.go:42: 12:47:53 | basic-central/62-unset-expose-monitoring | < potentially pages and pages of collector output >
    [...]
    logger.go:42: 12:47:53 | basic-central/62-unset-expose-monitoring | < potentially pages and pages of collector output >
    case.go:366: failed in step 62-unset-expose-monitoring
    case.go:368: exit status 1

After this change, the last line will be a more helpful:

    case.go:368: command "some command and args" failed, exit status 1

Fixes #493