MCPcopy Index your code
hub / github.com/cortexproject/cortex / TestVerticalShardingFuzz

Function TestVerticalShardingFuzz

integration/query_fuzz_test.go:664–778  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

662}
663
664func TestVerticalShardingFuzz(t *testing.T) {
665 s, err := e2e.NewScenario(networkName)
666 require.NoError(t, err)
667 defer s.Close()
668
669 // Start dependencies.
670 consul1 := e2edb.NewConsulWithName("consul1")
671 consul2 := e2edb.NewConsulWithName("consul2")
672 require.NoError(t, s.StartAndWaitReady(consul1, consul2))
673
674 flags := mergeFlags(
675 AlertmanagerLocalFlags(),
676 map[string]string{
677 "-store.engine": blocksStorageEngine,
678 "-blocks-storage.backend": "filesystem",
679 "-blocks-storage.tsdb.head-compaction-interval": "4m",
680 "-blocks-storage.tsdb.block-ranges-period": "2h",
681 "-blocks-storage.tsdb.ship-interval": "1h",
682 "-blocks-storage.bucket-store.sync-interval": "15m",
683 "-blocks-storage.tsdb.retention-period": "2h",
684 "-blocks-storage.bucket-store.index-cache.backend": tsdb.IndexCacheBackendInMemory,
685 // Ingester.
686 "-ring.store": "consul",
687 "-consul.hostname": consul1.NetworkHTTPEndpoint(),
688 // Distributor.
689 "-distributor.replication-factor": "1",
690 // Store-gateway.
691 "-store-gateway.sharding-enabled": "false",
692 // alert manager
693 "-alertmanager.web.external-url": "http://localhost/alertmanager",
694 },
695 )
696 // make alert manager config dir
697 require.NoError(t, writeFileToSharedDir(s, "alertmanager_configs", []byte{}))
698
699 path1 := path.Join(s.SharedDir(), "cortex-1")
700 path2 := path.Join(s.SharedDir(), "cortex-2")
701
702 flags1 := mergeFlags(flags, map[string]string{"-blocks-storage.filesystem.dir": path1})
703 // Start Cortex replicas.
704 cortex1 := e2ecortex.NewSingleBinary("cortex-1", flags1, "")
705 // Enable vertical sharding for the second Cortex instance.
706 flags2 := mergeFlags(flags, map[string]string{
707 "-frontend.query-vertical-shard-size": "2",
708 "-blocks-storage.filesystem.dir": path2,
709 "-consul.hostname": consul2.NetworkHTTPEndpoint(),
710 })
711 cortex2 := e2ecortex.NewSingleBinary("cortex-2", flags2, "")
712 require.NoError(t, s.StartAndWaitReady(cortex1, cortex2))
713
714 // Wait until Cortex replicas have updated the ring state.
715 require.NoError(t, cortex1.WaitSumMetrics(e2e.Equals(float64(512)), "cortex_ring_tokens_total"))
716 require.NoError(t, cortex2.WaitSumMetrics(e2e.Equals(float64(512)), "cortex_ring_tokens_total"))
717
718 c1, err := e2ecortex.NewClient(cortex1.HTTPEndpoint(), cortex1.HTTPEndpoint(), "", "", "user-1")
719 require.NoError(t, err)
720 c2, err := e2ecortex.NewClient(cortex2.HTTPEndpoint(), cortex2.HTTPEndpoint(), "", "", "user-1")
721 require.NoError(t, err)

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
StartAndWaitReadyMethod · 0.95
SharedDirMethod · 0.95
PushMethod · 0.95
NewScenarioFunction · 0.92
NewSingleBinaryFunction · 0.92
EqualsFunction · 0.92
NewClientFunction · 0.92
writeFileToSharedDirFunction · 0.85
waitUntilReadyFunction · 0.85
runQueryFuzzTestCasesFunction · 0.85

Tested by

no test coverage detected