test: Don't run TestResolved() in parallel and reduce to 2 runs (#1544)

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
Simon Pasquier 2018-09-11 12:55:48 +02:00 committed by Max Inden
parent c8acbf1a5f
commit 460b7a72fc
2 changed files with 48 additions and 66 deletions

View File

@ -15,7 +15,6 @@ package test
import (
"fmt"
"sync"
"testing"
"time"
@ -272,12 +271,8 @@ receivers:
func TestResolved(t *testing.T) {
t.Parallel()
var wg sync.WaitGroup
wg.Add(10)
for i := 0; i < 10; i++ {
go func() {
conf := `
for i := 0; i < 2; i++ {
conf := `
global:
resolve_timeout: 10s
@ -293,38 +288,34 @@ receivers:
- url: 'http://%s'
`
at := NewAcceptanceTest(t, &AcceptanceOpts{
Tolerance: 150 * time.Millisecond,
})
at := NewAcceptanceTest(t, &AcceptanceOpts{
Tolerance: 150 * time.Millisecond,
})
co := at.Collector("webhook")
wh := NewWebhook(co)
co := at.Collector("webhook")
wh := NewWebhook(co)
am := at.Alertmanager(fmt.Sprintf(conf, wh.Address()))
am := at.Alertmanager(fmt.Sprintf(conf, wh.Address()))
am.Push(At(1),
Alert("alertname", "test", "lbl", "v1"),
Alert("alertname", "test", "lbl", "v2"),
Alert("alertname", "test", "lbl", "v3"),
)
am.Push(At(1),
Alert("alertname", "test", "lbl", "v1"),
Alert("alertname", "test", "lbl", "v2"),
Alert("alertname", "test", "lbl", "v3"),
)
co.Want(Between(2, 2.5),
Alert("alertname", "test", "lbl", "v1").Active(1),
Alert("alertname", "test", "lbl", "v2").Active(1),
Alert("alertname", "test", "lbl", "v3").Active(1),
)
co.Want(Between(12, 13),
Alert("alertname", "test", "lbl", "v1").Active(1, 11),
Alert("alertname", "test", "lbl", "v2").Active(1, 11),
Alert("alertname", "test", "lbl", "v3").Active(1, 11),
)
co.Want(Between(2, 2.5),
Alert("alertname", "test", "lbl", "v1").Active(1),
Alert("alertname", "test", "lbl", "v2").Active(1),
Alert("alertname", "test", "lbl", "v3").Active(1),
)
co.Want(Between(12, 13),
Alert("alertname", "test", "lbl", "v1").Active(1, 11),
Alert("alertname", "test", "lbl", "v2").Active(1, 11),
Alert("alertname", "test", "lbl", "v3").Active(1, 11),
)
at.Run()
wg.Done()
}()
at.Run()
}
wg.Wait()
}
func TestResolvedFilter(t *testing.T) {

View File

@ -15,7 +15,6 @@ package test
import (
"fmt"
"sync"
"testing"
"time"
@ -272,12 +271,8 @@ receivers:
func TestResolved(t *testing.T) {
t.Parallel()
var wg sync.WaitGroup
wg.Add(10)
for i := 0; i < 10; i++ {
go func() {
conf := `
for i := 0; i < 2; i++ {
conf := `
global:
resolve_timeout: 10s
@ -293,38 +288,34 @@ receivers:
- url: 'http://%s'
`
at := NewAcceptanceTest(t, &AcceptanceOpts{
Tolerance: 150 * time.Millisecond,
})
at := NewAcceptanceTest(t, &AcceptanceOpts{
Tolerance: 150 * time.Millisecond,
})
co := at.Collector("webhook")
wh := NewWebhook(co)
co := at.Collector("webhook")
wh := NewWebhook(co)
am := at.Alertmanager(fmt.Sprintf(conf, wh.Address()))
am := at.Alertmanager(fmt.Sprintf(conf, wh.Address()))
am.Push(At(1),
Alert("alertname", "test", "lbl", "v1"),
Alert("alertname", "test", "lbl", "v2"),
Alert("alertname", "test", "lbl", "v3"),
)
am.Push(At(1),
Alert("alertname", "test", "lbl", "v1"),
Alert("alertname", "test", "lbl", "v2"),
Alert("alertname", "test", "lbl", "v3"),
)
co.Want(Between(2, 2.5),
Alert("alertname", "test", "lbl", "v1").Active(1),
Alert("alertname", "test", "lbl", "v2").Active(1),
Alert("alertname", "test", "lbl", "v3").Active(1),
)
co.Want(Between(12, 13),
Alert("alertname", "test", "lbl", "v1").Active(1, 11),
Alert("alertname", "test", "lbl", "v2").Active(1, 11),
Alert("alertname", "test", "lbl", "v3").Active(1, 11),
)
co.Want(Between(2, 2.5),
Alert("alertname", "test", "lbl", "v1").Active(1),
Alert("alertname", "test", "lbl", "v2").Active(1),
Alert("alertname", "test", "lbl", "v3").Active(1),
)
co.Want(Between(12, 13),
Alert("alertname", "test", "lbl", "v1").Active(1, 11),
Alert("alertname", "test", "lbl", "v2").Active(1, 11),
Alert("alertname", "test", "lbl", "v3").Active(1, 11),
)
at.Run()
wg.Done()
}()
at.Run()
}
wg.Wait()
}
func TestResolvedFilter(t *testing.T) {