mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -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 promPath string
|
||||||
var promConfig = filepath.Join("..", "..", "documentation", "examples", "prometheus.yml")
|
var promConfig = filepath.Join("..", "..", "documentation", "examples", "prometheus.yml")
|
||||||
|
var promData = filepath.Join(os.TempDir(), "data")
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
|
flag.Parse()
|
||||||
|
if testing.Short() {
|
||||||
|
os.Exit(m.Run())
|
||||||
|
}
|
||||||
var err error
|
var err error
|
||||||
promPath, err = os.Getwd()
|
promPath, err = os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -38,8 +43,6 @@ func TestMain(m *testing.M) {
|
||||||
}
|
}
|
||||||
promPath = filepath.Join(promPath, "prometheus")
|
promPath = filepath.Join(promPath, "prometheus")
|
||||||
|
|
||||||
flag.Parse()
|
|
||||||
if !testing.Short() {
|
|
||||||
build := exec.Command("go", "build", "-o", promPath)
|
build := exec.Command("go", "build", "-o", promPath)
|
||||||
output, err := build.CombinedOutput()
|
output, err := build.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -49,9 +52,9 @@ func TestMain(m *testing.M) {
|
||||||
|
|
||||||
exitCode := m.Run()
|
exitCode := m.Run()
|
||||||
os.Remove(promPath)
|
os.Remove(promPath)
|
||||||
|
os.RemoveAll(promData)
|
||||||
os.Exit(exitCode)
|
os.Exit(exitCode)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// As soon as prometheus starts responding to http request should be able to accept Interrupt signals for a gracefull shutdown.
|
// As soon as prometheus starts responding to http request should be able to accept Interrupt signals for a gracefull shutdown.
|
||||||
func TestStartupInterrupt(t *testing.T) {
|
func TestStartupInterrupt(t *testing.T) {
|
||||||
|
@ -59,7 +62,7 @@ func TestStartupInterrupt(t *testing.T) {
|
||||||
t.Skip("skipping test in short mode.")
|
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()
|
err := prom.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("execution error: %v", err)
|
t.Errorf("execution error: %v", err)
|
||||||
|
|
Loading…
Reference in a new issue