( t *testing.T, applyLimits func(limits *validation.Limits, localLimit, globalLimit int), runMaxFn func(limiter *Limiter) int, globalLimitShardByMetricNameSupport bool, )
| 80 | } |
| 81 | |
| 82 | func runLimiterMaxFunctionTest( |
| 83 | t *testing.T, |
| 84 | applyLimits func(limits *validation.Limits, localLimit, globalLimit int), |
| 85 | runMaxFn func(limiter *Limiter) int, |
| 86 | globalLimitShardByMetricNameSupport bool, |
| 87 | ) { |
| 88 | tests := map[string]struct { |
| 89 | localLimit int |
| 90 | globalLimit int |
| 91 | ringReplicationFactor int |
| 92 | ringZoneAwarenessEnabled bool |
| 93 | ringIngesterCount int |
| 94 | ringZonesCount int |
| 95 | shardByAllLabels bool |
| 96 | shardSize int |
| 97 | expectedDefaultSharding int |
| 98 | expectedShuffleSharding int |
| 99 | }{ |
| 100 | "both local and global limits are disabled": { |
| 101 | localLimit: 0, |
| 102 | globalLimit: 0, |
| 103 | ringReplicationFactor: 1, |
| 104 | ringIngesterCount: 1, |
| 105 | ringZonesCount: 1, |
| 106 | shardByAllLabels: false, |
| 107 | expectedDefaultSharding: math.MaxInt32, |
| 108 | expectedShuffleSharding: math.MaxInt32, |
| 109 | }, |
| 110 | "only local limit is enabled": { |
| 111 | localLimit: 1000, |
| 112 | globalLimit: 0, |
| 113 | ringReplicationFactor: 1, |
| 114 | ringIngesterCount: 1, |
| 115 | ringZonesCount: 1, |
| 116 | shardByAllLabels: false, |
| 117 | expectedDefaultSharding: 1000, |
| 118 | expectedShuffleSharding: 1000, |
| 119 | }, |
| 120 | "only global limit is enabled with shard-by-all-labels=false and replication-factor=1": { |
| 121 | localLimit: 0, |
| 122 | globalLimit: 1000, |
| 123 | ringReplicationFactor: 1, |
| 124 | ringIngesterCount: 10, |
| 125 | ringZonesCount: 1, |
| 126 | shardByAllLabels: false, |
| 127 | shardSize: 5, |
| 128 | expectedDefaultSharding: func() int { |
| 129 | if globalLimitShardByMetricNameSupport { |
| 130 | return 1000 |
| 131 | } |
| 132 | return math.MaxInt32 |
| 133 | }(), |
| 134 | expectedShuffleSharding: func() int { |
| 135 | if globalLimitShardByMetricNameSupport { |
| 136 | return 1000 |
| 137 | } |
| 138 | return math.MaxInt32 |
| 139 | }(), |
no test coverage detected