MCPcopy
hub / github.com/grafana/tempo / TestBackendShards

Function TestBackendShards

modules/frontend/search_sharder_test.go:1050–1168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1048}
1049
1050func TestBackendShards(t *testing.T) {
1051 tcs := []struct {
1052 name string
1053 maxShards int
1054 searchEnd uint32
1055 expected []shardtracker.Shard
1056 }{
1057 {
1058 name: "1 shard, puts all jobs in one shard",
1059 maxShards: 1,
1060 searchEnd: 50,
1061 expected: []shardtracker.Shard{
1062 {TotalJobs: 8, CompletedThroughSeconds: 1},
1063 },
1064 },
1065 {
1066 name: "2 shards, split evenly between",
1067 maxShards: 2,
1068 searchEnd: 50,
1069 expected: []shardtracker.Shard{
1070 {TotalJobs: 4, CompletedThroughSeconds: 30},
1071 {TotalJobs: 4, CompletedThroughSeconds: 1},
1072 },
1073 },
1074 {
1075 name: "3 shards, one for each block",
1076 maxShards: 3,
1077 searchEnd: 50,
1078 expected: []shardtracker.Shard{
1079 {TotalJobs: 2, CompletedThroughSeconds: 40},
1080 {TotalJobs: 2, CompletedThroughSeconds: 30},
1081 {TotalJobs: 4, CompletedThroughSeconds: 1},
1082 },
1083 },
1084 {
1085 name: "4 shards, one for each block",
1086 maxShards: 4,
1087 searchEnd: 50,
1088 expected: []shardtracker.Shard{
1089 {TotalJobs: 2, CompletedThroughSeconds: 40},
1090 {TotalJobs: 2, CompletedThroughSeconds: 30},
1091 {TotalJobs: 2, CompletedThroughSeconds: 20},
1092 {TotalJobs: 2, CompletedThroughSeconds: 1},
1093 },
1094 },
1095 {
1096 name: "5 shards, one for each block",
1097 maxShards: 5,
1098 searchEnd: 50,
1099 expected: []shardtracker.Shard{
1100 {TotalJobs: 2, CompletedThroughSeconds: 40},
1101 {TotalJobs: 2, CompletedThroughSeconds: 30},
1102 {TotalJobs: 2, CompletedThroughSeconds: 20},
1103 {TotalJobs: 2, CompletedThroughSeconds: 10},
1104 },
1105 },
1106 {
1107 name: "4 shards, search end forces 2 blocks in the first shard",

Callers

nothing calls this directly

Calls 4

MustParseFunction · 0.92
backendJobsFuncFunction · 0.85
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected