ensure that modificatons to the enum order trigger test failures since we rely on the ordinal
This commit is contained in:
parent
7e77ddb88f
commit
a10c80e20f
|
@ -169,6 +169,8 @@ public class CommonStatsFlags implements Streamable {
|
|||
}
|
||||
|
||||
public static enum Flag {
|
||||
// Do not change the order of these flags we use
|
||||
// the ordinal for encoding! Only append to the end!
|
||||
Store("store"),
|
||||
Indexing("indexing"),
|
||||
Get("get"),
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.test.integration.indices.stats;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -285,6 +286,17 @@ public class SimpleIndexStatsTests extends AbstractNodesTests {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlagOrdinalOrder() {
|
||||
Flag[] flags = new Flag[] { Flag.Store, Flag.Indexing, Flag.Get, Flag.Search, Flag.Merge, Flag.Flush, Flag.Refresh,
|
||||
Flag.FilterCache, Flag.IdCache, Flag.FieldData, Flag.Docs, Flag.Warmer };
|
||||
|
||||
assertThat(flags.length, equalTo(Flag.values().length));
|
||||
for (int i = 0; i < flags.length; i++) {
|
||||
assertThat("ordinal has changed - this breaks the wire protocol. Only append to new values", i, equalTo(flags[i].ordinal()));
|
||||
}
|
||||
}
|
||||
|
||||
private static void set(Flag flag, IndicesStatsRequestBuilder builder, boolean set) {
|
||||
switch(flag) {
|
||||
case Docs:
|
||||
|
|
Loading…
Reference in New Issue