fix percolate stats tests failures

This commit is contained in:
Shay Banon 2013-07-21 14:25:26 +02:00
parent 09362f47e9
commit 6a25395c97
2 changed files with 119 additions and 112 deletions

View File

@ -19,11 +19,6 @@
package org.elasticsearch.test.integration.indices.stats; package org.elasticsearch.test.integration.indices.stats;
import java.io.IOException;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.Random;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.indices.stats.CommonStats; import org.elasticsearch.action.admin.indices.stats.CommonStats;
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags;
@ -36,12 +31,15 @@ import org.elasticsearch.common.Priority;
import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.BytesStreamInput; import org.elasticsearch.common.io.stream.BytesStreamInput;
import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.test.integration.AbstractNodesTests; import org.elasticsearch.test.integration.AbstractNodesTests;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.io.IOException;
import java.util.EnumSet;
import java.util.Random;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
@ -328,8 +326,8 @@ public class SimpleIndexStatsTests extends AbstractNodesTests {
@Test @Test
public void testFlagOrdinalOrder() { public void testFlagOrdinalOrder() {
Flag[] flags = new Flag[] { Flag.Store, Flag.Indexing, Flag.Get, Flag.Search, Flag.Merge, Flag.Flush, Flag.Refresh, 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 }; Flag.FilterCache, Flag.IdCache, Flag.FieldData, Flag.Docs, Flag.Warmer, Flag.Percolate};
assertThat(flags.length, equalTo(Flag.values().length)); assertThat(flags.length, equalTo(Flag.values().length));
for (int i = 0; i < flags.length; i++) { for (int i = 0; i < flags.length; i++) {
@ -338,7 +336,7 @@ public class SimpleIndexStatsTests extends AbstractNodesTests {
} }
private static void set(Flag flag, IndicesStatsRequestBuilder builder, boolean set) { private static void set(Flag flag, IndicesStatsRequestBuilder builder, boolean set) {
switch(flag) { switch (flag) {
case Docs: case Docs:
builder.setDocs(set); builder.setDocs(set);
break; break;
@ -375,6 +373,9 @@ public class SimpleIndexStatsTests extends AbstractNodesTests {
case Warmer: case Warmer:
builder.setWarmer(set); builder.setWarmer(set);
break; break;
case Percolate:
builder.setPercolate(set);
break;
default: default:
assert false : "new flag? " + flag; assert false : "new flag? " + flag;
break; break;
@ -382,7 +383,7 @@ public class SimpleIndexStatsTests extends AbstractNodesTests {
} }
private static boolean isSet(Flag flag, CommonStats response) { private static boolean isSet(Flag flag, CommonStats response) {
switch(flag) { switch (flag) {
case Docs: case Docs:
return response.getDocs() != null; return response.getDocs() != null;
case FieldData: case FieldData:
@ -407,6 +408,8 @@ public class SimpleIndexStatsTests extends AbstractNodesTests {
return response.getStore() != null; return response.getStore() != null;
case Warmer: case Warmer:
return response.getWarmer() != null; return response.getWarmer() != null;
case Percolate:
return response.getPercolate() != null;
default: default:
assert false : "new flag? " + flag; assert false : "new flag? " + flag;
return false; return false;

View File

@ -514,7 +514,8 @@ public class SimplePercolatorTests extends AbstractSharedClusterTest {
IndicesStatsResponse indicesResponse = client().admin().indices().prepareStats("test").execute().actionGet(); IndicesStatsResponse indicesResponse = client().admin().indices().prepareStats("test").execute().actionGet();
assertThat(indicesResponse.getTotal().getPercolate().getCount(), equalTo(5l)); // We have 5 partitions assertThat(indicesResponse.getTotal().getPercolate().getCount(), equalTo(5l)); // We have 5 partitions
assertThat(indicesResponse.getTotal().getPercolate().getTimeInMillis(), greaterThan(0l)); // it might be too fast to be counted in milliseconds...
//assertThat(indicesResponse.getTotal().getPercolate().getTimeInMillis(), greaterThan(0l));
assertThat(indicesResponse.getTotal().getPercolate().getCurrent(), equalTo(0l)); assertThat(indicesResponse.getTotal().getPercolate().getCurrent(), equalTo(0l));
NodesStatsResponse nodesResponse = client().admin().cluster().prepareNodesStats().execute().actionGet(); NodesStatsResponse nodesResponse = client().admin().cluster().prepareNodesStats().execute().actionGet();
@ -525,7 +526,8 @@ public class SimplePercolatorTests extends AbstractSharedClusterTest {
percolateSumTime += nodeStats.getIndices().getPercolate().getTimeInMillis(); percolateSumTime += nodeStats.getIndices().getPercolate().getTimeInMillis();
} }
assertThat(percolateCount, equalTo(5l)); // We have 5 partitions assertThat(percolateCount, equalTo(5l)); // We have 5 partitions
assertThat(percolateSumTime, greaterThan(0l)); // it might be too fast to be counted in milliseconds...
//assertThat(percolateSumTime, greaterThan(0l));
logger.info("--> Second percolate request"); logger.info("--> Second percolate request");
response = client().preparePercolate("test", "type") response = client().preparePercolate("test", "type")
@ -536,7 +538,8 @@ public class SimplePercolatorTests extends AbstractSharedClusterTest {
indicesResponse = client().admin().indices().prepareStats().setPercolate(true).execute().actionGet(); indicesResponse = client().admin().indices().prepareStats().setPercolate(true).execute().actionGet();
assertThat(indicesResponse.getTotal().getPercolate().getCount(), equalTo(10l)); assertThat(indicesResponse.getTotal().getPercolate().getCount(), equalTo(10l));
assertThat(indicesResponse.getTotal().getPercolate().getTimeInMillis(), greaterThan(0l)); // it might be too fast to be counted in milliseconds...
//assertThat(indicesResponse.getTotal().getPercolate().getTimeInMillis(), greaterThan(0l));
assertThat(indicesResponse.getTotal().getPercolate().getCurrent(), equalTo(0l)); assertThat(indicesResponse.getTotal().getPercolate().getCurrent(), equalTo(0l));
nodesResponse = client().admin().cluster().prepareNodesStats().execute().actionGet(); nodesResponse = client().admin().cluster().prepareNodesStats().execute().actionGet();
@ -547,7 +550,8 @@ public class SimplePercolatorTests extends AbstractSharedClusterTest {
percolateSumTime += nodeStats.getIndices().getPercolate().getTimeInMillis(); percolateSumTime += nodeStats.getIndices().getPercolate().getTimeInMillis();
} }
assertThat(percolateCount, equalTo(10l)); assertThat(percolateCount, equalTo(10l));
assertThat(percolateSumTime, greaterThan(0l)); // it might be too fast to be counted in milliseconds...
//assertThat(percolateSumTime, greaterThan(0l));
} }
public static String[] convertFromTextArray(Text[] texts) { public static String[] convertFromTextArray(Text[] texts) {