MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestIngest

Function TestIngest

integration/remote_write_v2_test.go:273–394  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

271}
272
273func TestIngest(t *testing.T) {
274 const blockRangePeriod = 5 * time.Second
275
276 s, err := e2e.NewScenario(networkName)
277 require.NoError(t, err)
278 defer s.Close()
279
280 // Start dependencies.
281 consul := e2edb.NewConsulWithName("consul")
282 require.NoError(t, s.StartAndWaitReady(consul))
283
284 flags := mergeFlags(
285 AlertmanagerLocalFlags(),
286 map[string]string{
287 "-store.engine": blocksStorageEngine,
288 "-blocks-storage.backend": "filesystem",
289 "-blocks-storage.tsdb.head-compaction-interval": "4m",
290 "-blocks-storage.bucket-store.sync-interval": "15m",
291 "-blocks-storage.bucket-store.index-cache.backend": tsdb.IndexCacheBackendInMemory,
292 "-blocks-storage.tsdb.block-ranges-period": blockRangePeriod.String(),
293 "-blocks-storage.tsdb.ship-interval": "1s",
294 "-blocks-storage.tsdb.retention-period": ((blockRangePeriod * 2) - 1).String(),
295 "-blocks-storage.tsdb.enable-native-histograms": "true",
296 // Ingester.
297 "-ring.store": "consul",
298 "-consul.hostname": consul.NetworkHTTPEndpoint(),
299 // Distributor.
300 "-distributor.replication-factor": "1",
301 "-distributor.remote-writev2-enabled": "true",
302 // Store-gateway.
303 "-store-gateway.sharding-enabled": "false",
304 // alert manager
305 "-alertmanager.web.external-url": "http://localhost/alertmanager",
306 },
307 )
308
309 // make alert manager config dir
310 require.NoError(t, writeFileToSharedDir(s, "alertmanager_configs", []byte{}))
311
312 path := path.Join(s.SharedDir(), "cortex-1")
313
314 flags = mergeFlags(flags, map[string]string{"-blocks-storage.filesystem.dir": path})
315 // Start Cortex replicas.
316 cortex := e2ecortex.NewSingleBinary("cortex", flags, "")
317 require.NoError(t, s.StartAndWaitReady(cortex))
318
319 // Wait until Cortex replicas have updated the ring state.
320 require.NoError(t, cortex.WaitSumMetrics(e2e.Equals(float64(512)), "cortex_ring_tokens_total"))
321
322 c, err := e2ecortex.NewClient(cortex.HTTPEndpoint(), cortex.HTTPEndpoint(), "", "", "user-1")
323 require.NoError(t, err)
324
325 now := time.Now()
326
327 // series push
328 symbols1, series, expectedVector := e2e.GenerateSeriesV2("test_series", now, prompb.Label{Name: "job", Value: "test"}, prompb.Label{Name: "foo", Value: "bar"})
329 writeStats, err := c.PushV2(symbols1, series)
330 require.NoError(t, err)

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
StartAndWaitReadyMethod · 0.95
SharedDirMethod · 0.95
PushV2Method · 0.95
QueryMethod · 0.95
MetadataMethod · 0.95
NewScenarioFunction · 0.92
NewSingleBinaryFunction · 0.92
EqualsFunction · 0.92
NewClientFunction · 0.92
GenerateSeriesV2Function · 0.92

Tested by

no test coverage detected