mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 06:04:05 -08:00
return error exit status in prometheus cli (#4296)
Signed-off-by: mikeykhalil <mikeyfkhalil@gmail.com>
This commit is contained in:
parent
f7e1a94b03
commit
5e9056d2f3
|
@ -595,6 +595,7 @@ func main() {
|
||||||
}
|
}
|
||||||
if err := g.Run(); err != nil {
|
if err := g.Run(); err != nil {
|
||||||
level.Error(logger).Log("err", err)
|
level.Error(logger).Log("err", err)
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
level.Info(logger).Log("msg", "See you next time!")
|
level.Info(logger).Log("msg", "See you next time!")
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -155,3 +156,20 @@ func TestComputeExternalURL(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Let's provide an invalid configuration file and verify the exit status indicates the error.
|
||||||
|
func TestFailedStartupExitCode(t *testing.T) {
|
||||||
|
fakeInputFile := "fake-input-file"
|
||||||
|
expectedExitStatus := 1
|
||||||
|
|
||||||
|
prom := exec.Command(promPath, "--config.file="+fakeInputFile)
|
||||||
|
err := prom.Run()
|
||||||
|
testutil.NotOk(t, err, "")
|
||||||
|
|
||||||
|
if exitError, ok := err.(*exec.ExitError); ok {
|
||||||
|
status := exitError.Sys().(syscall.WaitStatus)
|
||||||
|
testutil.Equals(t, expectedExitStatus, status.ExitStatus())
|
||||||
|
} else {
|
||||||
|
t.Errorf("unable to retrieve the exit status for prometheus: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue