Make wait times between cycles configurable

The time between test cycles (one cycle through all actions that were
executed depending on the probability) was hard coded to be between
1 and 10 seconds.

This change allows to configure whether to wait between cycles at all
and to define a min- and max-time to wait.

Change-Id: I950a80e01fc941bd3b01b05a108921cae81be096
diff --git a/README.md b/README.md
index 0b9ef23..2d31104 100644
--- a/README.md
+++ b/README.md
@@ -53,6 +53,9 @@
 | `testrun.initialization.createProjects.enabled` | Whether to create new projects during initialization                                  | `true`                  |
 | `testrun.initialization.createProjects.number`  | How many new projects to create during initialization                                 | `1`                     |
 | `testrun.initialization.knownProjects`          | List of projects that the simulated user knows of from the beginning                  | `nil`                   |
+| `testrun.waitBetweenCycles.enabled`             | Whether to pause between test cycles                                                  | `true`                  |
+| `testrun.waitBetweenCycles.min`                 | Minimum time of pause                                                                 | `1`                     |
+| `testrun.waitBetweenCycles.max`                 | Maximum time of pause                                                                 | `10`                    |
 | `actions.*`                                     | Probability with which an action is performed in each cycle (`0`: never, `1`: always) | `1`                     |
 
 ### Available actions
diff --git a/config.sample.yaml b/config.sample.yaml
index 1fa1193..a931db1 100644
--- a/config.sample.yaml
+++ b/config.sample.yaml
@@ -10,6 +10,10 @@
       enabled: true
       number: 1
     knownProjects: []
+  waitBetweenCycles:
+    enabled: true
+    min: 1
+    max: 10
 
 actions:
   clone_project:
diff --git a/container/tools/config/parser.py b/container/tools/config/parser.py
index 51622ec..9eb1d6d 100644
--- a/container/tools/config/parser.py
+++ b/container/tools/config/parser.py
@@ -26,6 +26,7 @@
             "createProjects": {"enabled": True, "number": 1},
             "knownProjects": list(),
         },
+        "waitBetweenCycles": {"enabled": True, "min": 1, "max": 10},
     },
     "actions": {
         "clone_project": {"probability": 1},
diff --git a/container/tools/start_test.py b/container/tools/start_test.py
index 31ea3d8..37b8210 100755
--- a/container/tools/start_test.py
+++ b/container/tools/start_test.py
@@ -30,29 +30,31 @@
 
 class LoadTestInstance:
     def __init__(self, test_config):
-        self.url = test_config["gerrit"]["url"]
-        self.user = test_config["gerrit"]["user"]
-        self.pwd = test_config["gerrit"]["password"]
+        self.config = test_config
+
+        self.url = self.config["gerrit"]["url"]
+        self.user = self.config["gerrit"]["user"]
+        self.pwd = self.config["gerrit"]["password"]
 
         self.timeout = (
-            time.time() + test_config["testrun"]["duration"]
-            if test_config["testrun"]["duration"]
+            time.time() + self.config["testrun"]["duration"]
+            if self.config["testrun"]["duration"]
             else None
         )
 
-        self.action_config = test_config["actions"]
+        self.action_config = self.config["actions"]
 
         self.owned_projects = set()
-        if test_config["testrun"]["initialization"]["knownProjects"]:
+        if self.config["testrun"]["initialization"]["knownProjects"]:
             self.owned_projects = set(
-                test_config["testrun"]["initialization"]["knownProjects"]
+                self.config["testrun"]["initialization"]["knownProjects"]
             )
 
         self.cloned_projects = set()
 
-        if test_config["testrun"]["initialization"]["createProjects"]["enabled"]:
+        if self.config["testrun"]["initialization"]["createProjects"]["enabled"]:
             self._create_initial_projects(
-                test_config["testrun"]["initialization"]["createProjects"]["number"]
+                self.config["testrun"]["initialization"]["createProjects"]["number"]
             )
 
         self.log = logging.getLogger("ActionLogger")
@@ -62,7 +64,11 @@
             if self.timeout and time.time() >= self.timeout:
                 break
 
-            self._wait_random_seconds(1, 10)
+            if self.config["testrun"]["waitBetweenCycles"]["enabled"]:
+                self._wait_random_seconds(
+                    self.config["testrun"]["waitBetweenCycles"]["min"],
+                    self.config["testrun"]["waitBetweenCycles"]["max"],
+                )
 
             self._exec_create_project_action()
             self._exec_list_projects_action()