mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-10 07:34:04 -08:00
write to temp dir and remove it at the end.
Signed-off-by: Krasi Georgiev <krasi.root@gmail.com>
This commit is contained in:
parent
2c2a962da3
commit
740662644e
|
@ -28,8 +28,13 @@ import (
|
|||
|
||||
var promPath string
|
||||
var promConfig = filepath.Join("..", "..", "documentation", "examples", "prometheus.yml")
|
||||
var promData = filepath.Join(os.TempDir(), "data")
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
flag.Parse()
|
||||
if testing.Short() {
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
var err error
|
||||
promPath, err = os.Getwd()
|
||||
if err != nil {
|
||||
|
@ -38,8 +43,6 @@ func TestMain(m *testing.M) {
|
|||
}
|
||||
promPath = filepath.Join(promPath, "prometheus")
|
||||
|
||||
flag.Parse()
|
||||
if !testing.Short() {
|
||||
build := exec.Command("go", "build", "-o", promPath)
|
||||
output, err := build.CombinedOutput()
|
||||
if err != nil {
|
||||
|
@ -49,8 +52,8 @@ func TestMain(m *testing.M) {
|
|||
|
||||
exitCode := m.Run()
|
||||
os.Remove(promPath)
|
||||
os.RemoveAll(promData)
|
||||
os.Exit(exitCode)
|
||||
}
|
||||
}
|
||||
|
||||
// As soon as prometheus starts responding to http request should be able to accept Interrupt signals for a gracefull shutdown.
|
||||
|
@ -59,7 +62,7 @@ func TestStartupInterrupt(t *testing.T) {
|
|||
t.Skip("skipping test in short mode.")
|
||||
}
|
||||
|
||||
prom := exec.Command(promPath, "--config.file="+promConfig)
|
||||
prom := exec.Command(promPath, "--config.file="+promConfig, "--storage.tsdb.path="+promData)
|
||||
err := prom.Start()
|
||||
if err != nil {
|
||||
t.Errorf("execution error: %v", err)
|
||||
|
|
Loading…
Reference in a new issue