mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-25 06:16:40 +00:00
Further improve InternalTTestTests (#55081)
A small follow-up to #54910. Now that we can generated consistent set of internal aggs to reduce, we no longer need to keep agg parameters as class variables. Related to #54910
This commit is contained in:
parent
16921ebbd8
commit
6861295706
@ -31,28 +31,28 @@ import static java.util.Collections.emptyList;
|
|||||||
|
|
||||||
public class InternalTTestTests extends InternalAggregationTestCase<InternalTTest> {
|
public class InternalTTestTests extends InternalAggregationTestCase<InternalTTest> {
|
||||||
|
|
||||||
private TTestType type = randomFrom(TTestType.values());
|
|
||||||
private int tails = randomIntBetween(1, 2);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InternalTTest createTestInstance(String name, Map<String, Object> metadata) {
|
protected InternalTTest createTestInstance(String name, Map<String, Object> metadata) {
|
||||||
TTestState state = randomState(Long.MAX_VALUE);
|
TTestState state = randomState(Long.MAX_VALUE, randomFrom(TTestType.values()), randomIntBetween(1, 2));
|
||||||
DocValueFormat formatter = randomNumericDocValueFormat();
|
DocValueFormat formatter = randomNumericDocValueFormat();
|
||||||
return new InternalTTest(name, state, formatter, metadata);
|
return new InternalTTest(name, state, formatter, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<InternalTTest> randomResultsToReduce(String name, int size) {
|
protected List<InternalTTest> randomResultsToReduce(String name, int size) {
|
||||||
|
TTestType type = randomFrom(TTestType.values());
|
||||||
|
int tails = randomIntBetween(1, 2);
|
||||||
List<InternalTTest> inputs = new ArrayList<>(size);
|
List<InternalTTest> inputs = new ArrayList<>(size);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
TTestState state = randomState(Long.MAX_VALUE / size); // Make sure the sum of all the counts doesn't wrap
|
// Make sure the sum of all the counts doesn't wrap and type and tail parameters are consistent
|
||||||
|
TTestState state = randomState(Long.MAX_VALUE / size, type, tails);
|
||||||
DocValueFormat formatter = randomNumericDocValueFormat();
|
DocValueFormat formatter = randomNumericDocValueFormat();
|
||||||
inputs.add(new InternalTTest(name, state, formatter, null));
|
inputs.add(new InternalTTest(name, state, formatter, null));
|
||||||
}
|
}
|
||||||
return inputs;
|
return inputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TTestState randomState(long maxCount) {
|
private TTestState randomState(long maxCount, TTestType type, int tails) {
|
||||||
if (type == TTestType.PAIRED) {
|
if (type == TTestType.PAIRED) {
|
||||||
return new PairedTTestState(randomStats(maxCount), tails);
|
return new PairedTTestState(randomStats(maxCount), tails);
|
||||||
} else {
|
} else {
|
||||||
@ -100,7 +100,7 @@ public class InternalTTestTests extends InternalAggregationTestCase<InternalTTes
|
|||||||
name += randomAlphaOfLength(5);
|
name += randomAlphaOfLength(5);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
state = randomState(Long.MAX_VALUE);
|
state = randomState(Long.MAX_VALUE, randomFrom(TTestType.values()), randomIntBetween(1, 2));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (metadata == null) {
|
if (metadata == null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user