fix duplicate doc tests, ensure no bulk rejection

This commit is contained in:
Jörg Prante 2017-04-02 22:06:58 +02:00
parent 25f529acd2
commit b2ad4f2b25
3 changed files with 20 additions and 9 deletions

View file

@ -1,6 +1,6 @@
group = org.xbib group = org.xbib
name = elasticsearch-extras-client name = elasticsearch-extras-client
version = 5.3.0.0 version = 5.3.0.1
elasticsearch-client-transport.version = 5.3.0 elasticsearch-client-transport.version = 5.3.0
xbib-metrics.version = 1.0.0 xbib-metrics.version = 1.0.0

View file

@ -24,14 +24,15 @@ public class BulkNodeDuplicateIDTest extends NodeTestBase {
private static final Logger logger = LogManager.getLogger(BulkNodeDuplicateIDTest.class.getName()); private static final Logger logger = LogManager.getLogger(BulkNodeDuplicateIDTest.class.getName());
private static final Long MAX_ACTIONS = 1000L; private static final long MAX_ACTIONS = 100L;
private static final Long NUM_ACTIONS = 12345L; private static final long NUM_ACTIONS = 12345L;
@Test @Test
public void testDuplicateDocIDs() throws Exception { public void testDuplicateDocIDs() throws Exception {
long numactions = NUM_ACTIONS;
final BulkNodeClient client = ClientBuilder.builder() final BulkNodeClient client = ClientBuilder.builder()
.put(ClientBuilder.MAX_CONCURRENT_REQUESTS, 2) // avoid EsRejectedExecutionException
.put(ClientBuilder.MAX_ACTIONS_PER_REQUEST, MAX_ACTIONS) .put(ClientBuilder.MAX_ACTIONS_PER_REQUEST, MAX_ACTIONS)
.setMetric(new SimpleBulkMetric()) .setMetric(new SimpleBulkMetric())
.setControl(new SimpleBulkControl()) .setControl(new SimpleBulkControl())
@ -55,11 +56,16 @@ public class BulkNodeDuplicateIDTest extends NodeTestBase {
logger.warn("skipping, no node available"); logger.warn("skipping, no node available");
} finally { } finally {
client.shutdown(); client.shutdown();
assertEquals(numactions, client.getMetric().getSucceeded().getCount());
if (client.hasThrowable()) { if (client.hasThrowable()) {
logger.error("error", client.getThrowable()); logger.error("error", client.getThrowable());
} }
assertFalse(client.hasThrowable()); assertFalse(client.hasThrowable());
logger.info("numactions = {}, submitted = {}, succeeded= {}, failed = {}", NUM_ACTIONS,
client.getMetric().getSubmitted().getCount(),
client.getMetric().getSucceeded().getCount(),
client.getMetric().getFailed().getCount());
assertEquals(NUM_ACTIONS, client.getMetric().getSubmitted().getCount());
assertEquals(NUM_ACTIONS, client.getMetric().getSucceeded().getCount());
} }
} }
} }

View file

@ -24,15 +24,15 @@ public class BulkTransportDuplicateIDTest extends NodeTestBase {
private static final Logger logger = LogManager.getLogger(BulkTransportDuplicateIDTest.class.getName()); private static final Logger logger = LogManager.getLogger(BulkTransportDuplicateIDTest.class.getName());
private static final Long MAX_ACTIONS = 1000L; private static final long MAX_ACTIONS = 100L;
private static final Long NUM_ACTIONS = 12345L; private static final long NUM_ACTIONS = 12345L;
@Test @Test
public void testDuplicateDocIDs() throws Exception { public void testDuplicateDocIDs() throws Exception {
long numactions = NUM_ACTIONS;
final BulkTransportClient client = ClientBuilder.builder() final BulkTransportClient client = ClientBuilder.builder()
.put(getClientSettings()) .put(getClientSettings())
.put(ClientBuilder.MAX_CONCURRENT_REQUESTS, 2) // avoid EsRejectedExecutionException
.put(ClientBuilder.MAX_ACTIONS_PER_REQUEST, MAX_ACTIONS) .put(ClientBuilder.MAX_ACTIONS_PER_REQUEST, MAX_ACTIONS)
.setMetric(new SimpleBulkMetric()) .setMetric(new SimpleBulkMetric())
.setControl(new SimpleBulkControl()) .setControl(new SimpleBulkControl())
@ -56,11 +56,16 @@ public class BulkTransportDuplicateIDTest extends NodeTestBase {
logger.warn("skipping, no node available"); logger.warn("skipping, no node available");
} finally { } finally {
client.shutdown(); client.shutdown();
assertEquals(numactions, client.getMetric().getSucceeded().getCount());
if (client.hasThrowable()) { if (client.hasThrowable()) {
logger.error("error", client.getThrowable()); logger.error("error", client.getThrowable());
} }
assertFalse(client.hasThrowable()); assertFalse(client.hasThrowable());
logger.info("numactions = {}, submitted = {}, succeeded= {}, failed = {}", NUM_ACTIONS,
client.getMetric().getSubmitted().getCount(),
client.getMetric().getSucceeded().getCount(),
client.getMetric().getFailed().getCount());
assertEquals(NUM_ACTIONS, client.getMetric().getSubmitted().getCount());
assertEquals(NUM_ACTIONS, client.getMetric().getSucceeded().getCount());
} }
} }
} }