mirror of
https://github.com/prometheus/prometheus.git
synced 2025-09-21 13:51:00 +02:00
parallelize ./scrape test
Signed-off-by: pipiland2612 <nguyen.t.dang.minh@gmail.com>
This commit is contained in:
parent
82a4b12507
commit
1607b5c8cc
@ -745,6 +745,7 @@ func setupTestServer(t *testing.T, typ string, toWrite []byte) *httptest.Server
|
|||||||
|
|
||||||
// TestManagerCTZeroIngestion tests scrape manager for various CT cases.
|
// TestManagerCTZeroIngestion tests scrape manager for various CT cases.
|
||||||
func TestManagerCTZeroIngestion(t *testing.T) {
|
func TestManagerCTZeroIngestion(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
const (
|
const (
|
||||||
// _total suffix is required, otherwise expfmt with OMText will mark metric as "unknown"
|
// _total suffix is required, otherwise expfmt with OMText will mark metric as "unknown"
|
||||||
expectedMetricName = "expected_metric_total"
|
expectedMetricName = "expected_metric_total"
|
||||||
@ -917,6 +918,7 @@ func generateTestHistogram(i int) *dto.Histogram {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestManagerCTZeroIngestionHistogram(t *testing.T) {
|
func TestManagerCTZeroIngestionHistogram(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
const mName = "expected_histogram"
|
const mName = "expected_histogram"
|
||||||
|
|
||||||
for _, tc := range []struct {
|
for _, tc := range []struct {
|
||||||
@ -952,6 +954,7 @@ func TestManagerCTZeroIngestionHistogram(t *testing.T) {
|
|||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
@ -1156,6 +1159,7 @@ func requireTargets(
|
|||||||
|
|
||||||
// TestTargetDisappearsAfterProviderRemoved makes sure that when a provider is dropped, (only) its targets are dropped.
|
// TestTargetDisappearsAfterProviderRemoved makes sure that when a provider is dropped, (only) its targets are dropped.
|
||||||
func TestTargetDisappearsAfterProviderRemoved(t *testing.T) {
|
func TestTargetDisappearsAfterProviderRemoved(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
@ -1256,6 +1260,7 @@ scrape_configs:
|
|||||||
// TestOnlyProviderStaleTargetsAreDropped makes sure that when a job has only one provider with multiple targets
|
// TestOnlyProviderStaleTargetsAreDropped makes sure that when a job has only one provider with multiple targets
|
||||||
// and when the provider can no longer discover some of those targets, only those stale targets are dropped.
|
// and when the provider can no longer discover some of those targets, only those stale targets are dropped.
|
||||||
func TestOnlyProviderStaleTargetsAreDropped(t *testing.T) {
|
func TestOnlyProviderStaleTargetsAreDropped(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
@ -442,6 +442,7 @@ func (*testLoop) getCache() *scrapeCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestScrapePoolStop(t *testing.T) {
|
func TestScrapePoolStop(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
sp := &scrapePool{
|
sp := &scrapePool{
|
||||||
activeTargets: map[uint64]*Target{},
|
activeTargets: map[uint64]*Target{},
|
||||||
loops: map[uint64]loop{},
|
loops: map[uint64]loop{},
|
||||||
@ -501,6 +502,7 @@ func TestScrapePoolStop(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestScrapePoolReload(t *testing.T) {
|
func TestScrapePoolReload(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
var mtx sync.Mutex
|
var mtx sync.Mutex
|
||||||
numTargets := 20
|
numTargets := 20
|
||||||
|
|
||||||
@ -866,6 +868,7 @@ func TestScrapePoolAppender(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestScrapePoolRaces(t *testing.T) {
|
func TestScrapePoolRaces(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
interval, _ := model.ParseDuration("1s")
|
interval, _ := model.ParseDuration("1s")
|
||||||
timeout, _ := model.ParseDuration("500ms")
|
timeout, _ := model.ParseDuration("500ms")
|
||||||
newConfig := func() *config.ScrapeConfig {
|
newConfig := func() *config.ScrapeConfig {
|
||||||
@ -998,6 +1001,7 @@ func newBasicScrapeLoopWithFallback(t testing.TB, ctx context.Context, scraper s
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestScrapeLoopStopBeforeRun(t *testing.T) {
|
func TestScrapeLoopStopBeforeRun(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
scraper := &testScraper{}
|
scraper := &testScraper{}
|
||||||
sl := newBasicScrapeLoop(t, context.Background(), scraper, nil, 1)
|
sl := newBasicScrapeLoop(t, context.Background(), scraper, nil, 1)
|
||||||
|
|
||||||
@ -1102,6 +1106,7 @@ func TestScrapeLoopStop(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestScrapeLoopRun(t *testing.T) {
|
func TestScrapeLoopRun(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
var (
|
var (
|
||||||
signal = make(chan struct{}, 1)
|
signal = make(chan struct{}, 1)
|
||||||
errc = make(chan error)
|
errc = make(chan error)
|
||||||
@ -3922,6 +3927,7 @@ func TestCheckAddError(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestScrapeReportSingleAppender(t *testing.T) {
|
func TestScrapeReportSingleAppender(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
s := teststorage.New(t)
|
s := teststorage.New(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
@ -4331,6 +4337,7 @@ test_summary_count 199
|
|||||||
|
|
||||||
// Testing whether we can automatically convert scraped classic histograms into native histograms with custom buckets.
|
// Testing whether we can automatically convert scraped classic histograms into native histograms with custom buckets.
|
||||||
func TestConvertClassicHistogramsToNHCB(t *testing.T) {
|
func TestConvertClassicHistogramsToNHCB(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
genTestCounterText := func(name string, value int, withMetadata bool) string {
|
genTestCounterText := func(name string, value int, withMetadata bool) string {
|
||||||
if withMetadata {
|
if withMetadata {
|
||||||
return fmt.Sprintf(`
|
return fmt.Sprintf(`
|
||||||
@ -4741,6 +4748,7 @@ metric: <
|
|||||||
}
|
}
|
||||||
|
|
||||||
t.Run(fmt.Sprintf("%s with %s", name, metricsTextName), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%s with %s", name, metricsTextName), func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
simpleStorage := teststorage.New(t)
|
simpleStorage := teststorage.New(t)
|
||||||
defer simpleStorage.Close()
|
defer simpleStorage.Close()
|
||||||
|
|
||||||
@ -5367,6 +5375,7 @@ scrape_configs:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTargetScrapeConfigWithLabels(t *testing.T) {
|
func TestTargetScrapeConfigWithLabels(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
const (
|
const (
|
||||||
configTimeout = 1500 * time.Millisecond
|
configTimeout = 1500 * time.Millisecond
|
||||||
expectedTimeout = "1.5"
|
expectedTimeout = "1.5"
|
||||||
@ -5521,6 +5530,7 @@ func TestTargetScrapeConfigWithLabels(t *testing.T) {
|
|||||||
|
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
t.Run(c.name, func(t *testing.T) {
|
t.Run(c.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
select {
|
select {
|
||||||
case <-run(t, c.cfg, c.targets):
|
case <-run(t, c.cfg, c.targets):
|
||||||
case <-time.After(10 * time.Second):
|
case <-time.After(10 * time.Second):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user