# ESRally - How to add assertion logic

**URL:** <https://discuss.elastic.co/t/esrally-how-to-add-assertion-logic/215074>\
**Category:** Elasticsearch\
**Tags:** rally\
**Created:** [January 15, 2020, 4:51am UTC](https://discuss.elastic.co/t/esrally-how-to-add-assertion-logic/215074 "2020-01-15T04:51:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbakti7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dbakti7/32/42250_2.png) [@dbakti7](https://discuss.elastic.co/u/dbakti7)\
**Post date:** [January 15, 2020, 4:51am UTC](https://discuss.elastic.co/t/esrally-how-to-add-assertion-logic/215074/1 "2020-01-15T04:51:17Z")

</div>

Is there any way to add assertion logic into ESRally?  
For example, after bulk operation is completed, I want to assert that number of documents indexed are as expected.  
I found that ESRally doesn't throw any error/stop when there is something wrong with corpus.  
For example, having 4 documents with one malformed document will still result in successful run, but there are only 3 documents in ES.

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [January 15, 2020, 6:57am UTC](https://discuss.elastic.co/t/esrally-how-to-add-assertion-logic/215074/2 "2020-01-15T06:57:24Z")

</div>

Hi,

this might be possible if you implement a custom runner. However, in your case a simpler solution might help. Rally has a "lenient" mode where Rally only records that an error has happened and reports this as "error rate". This mode is the default. There is also a strict mode which will abort the benchmark immediately when an error occurs. You can enable this mode with the command line flag `--on-error=abort` (the default is `--on-error=continue`, see also the [docs](https://esrally.readthedocs.io/en/stable/command_line_reference.html#on-error)).

Daniel

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 12, 2020, 6:57am UTC](https://discuss.elastic.co/t/esrally-how-to-add-assertion-logic/215074/3 "2020-02-12T06:57:26Z")

</div>

Closed on February 12, 2020, 6:57am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
