# Is it possible to create a loop around a challenge

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-create-a-loop-around-a-challenge/117892>\
**Category:** Elasticsearch\
**Tags:** rally\
**Created:** [January 31, 2018, 8:03pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-loop-around-a-challenge/117892 "2018-01-31T20:03:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dipanjan44](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@dipanjan44](https://discuss.elastic.co/u/dipanjan44)\
**Post date:** [January 31, 2018, 8:03pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-loop-around-a-challenge/117892/1 "2018-01-31T20:03:55Z")

</div>

I would like to loop through my challenge using rally. I have a create, insert and delete operation inside the challenge. I would like to loop through it 10 times or say for 24 hrs. Is there a provision of doing it without copying the same challenge multiple times?

---

<div class="post-metadata">

**Author:** ![matt.veitas](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@matt.veitas](https://discuss.elastic.co/u/matt.veitas)\
**Post date:** [February 1, 2018, 12:20am UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-loop-around-a-challenge/117892/2 "2018-02-01T00:20:04Z")

</div>

You might be able to use loops provided in Jina2: [http://jinja.pocoo.org/docs/2.10/tricks/](http://jinja.pocoo.org/docs/2.10/tricks/)

---

<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:** [February 2, 2018, 9:53am UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-loop-around-a-challenge/117892/3 "2018-02-02T09:53:42Z")

</div>

@matt.veitas is correct with the loop idea. In my answer in the thread "[Increase data size in Rally existing tracks](https://discuss.elastic.co/t/increase-data-size-in-rally-existing-tracks/116514/2?u=danielmitterdorfer)" I have provided an example how loops can be used.

If you want to run multiple iterations of the same benchmarking trial (without restarting Elasticsearch) you can also use the command line parameter `--laps`, e.g. `--laps=12` will run the same benchmark twelve times. Rally will _not_ restart Elasticsearch in between and will (usually) recreate the index at the beginning of each iteration (lap).

---

<div class="post-metadata">

**Author:** ![dipanjan44](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@dipanjan44](https://discuss.elastic.co/u/dipanjan44)\
**Post date:** [February 2, 2018, 5:27pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-loop-around-a-challenge/117892/4 "2018-02-02T17:27:24Z")

</div>

Thanks Daniel.

Is there a provision to introduce a time-lag between 2 laps. Like I want every lap to start 5 mins after the end of the last lap.

---

<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:** [February 5, 2018, 8:27am UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-loop-around-a-challenge/117892/5 "2018-02-05T08:27:28Z")

</div>

Hi @dipanjan44

no this is not possible at the moment. Why do you want this?

To me this sounds that it would be better if you instead just invoke Rally several times instead. In your Benchmarking script you could do something like this:

```auto
#!/usr/bin/env bash

# Rally invocation here, e.g.:
esrally --target-hosts="10.17.1.33:9200,10.17.1.34:9200" --track="geonames"
# wait for 5 minutes
sleep(300)
# invoke Rally again, maybe with different parameters
esrally --target-hosts="10.17.1.33:9200,10.17.1.34:9200" --track="geonames"
# wait for 5 minutes
sleep(300)
#....

```

---

<div class="post-metadata">

**Author:** ![dipanjan44](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@dipanjan44](https://discuss.elastic.co/u/dipanjan44)\
**Post date:** [February 5, 2018, 5:22pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-loop-around-a-challenge/117892/6 "2018-02-05T17:22:49Z")

</div>

Hi Daniel, I wanted this because I want to test the reliability of the ES server by running one test after the other but at the same time would like to give a little room to the ES server to release the hardware before the next test kicks in. This way i can ensure that the hardware resources are getting released with a decrease in load.

---

<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:** [February 6, 2018, 7:26am UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-loop-around-a-challenge/117892/7 "2018-02-06T07:26:49Z")

</div>

This sounds more like a longer-term stress test to me. If you are really interested in the absolute numbers you need to be aware that you will experience ordering bias (the question is just to what degree and different workloads show different sensitivity to ordering bias).

If you want to solve this within Rally you can use a [custom runner](http://esrally.readthedocs.io/en/stable/adding_tracks.html#custom-runners) but you need to write your own track for this.

Create a file `track.py`:

```auto
import time

def sleep(es, params):
    time.sleep(params["duration"])

def register(registry):
    registry.register_runner("sleep", sleep)

```

In `track.json` you can use it as follows:

```auto
  "schedule": [
    {
      "operation": {
        "operation-type": "sleep",
        "duration": 300,
        "include-in-reporting": false
      }
    }
# ... Other tasks here ...
  ]

```

You can specify the number of seconds to sleep with `duration`. As you are not interested in any metrics for the `sleep` operation you can set `include-in-reporting` to `false`.

---

<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:** [March 6, 2018, 7:27am UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-loop-around-a-challenge/117892/8 "2018-03-06T07:27:36Z")

</div>

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