Allow to configure a list of projects known from the start

An instance ('simulated user') is only using projects that it knows of.
The list of known projects could be grown by either creating a project
or by querying projects, in which case one of the returned projects in
the query was added to the list of known projects.

However, for some usecases certain projects should be tested against,
e.g. they have a specific property like unusually high number of refs.
Such a directed test was not possible yet.

This change allows to configure a list of projects that each simulated
user knows from the beginning of the test. If the querying and creation
of projects is deactivated (by setting the respective probability to 0),
the test will only work with these projects.

Change-Id: I4f9e58c9b12930251aad73dcc7962a534541a036
diff --git a/README.md b/README.md
index 2d026f0..0b9ef23 100644
--- a/README.md
+++ b/README.md
@@ -52,6 +52,7 @@
 | `testrun.duration`                              | Duration for which to run the tests                                                   | `null` (indefinitely)   |
 | `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`                   |
 | `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 bdec749..1fa1193 100644
--- a/config.sample.yaml
+++ b/config.sample.yaml
@@ -9,6 +9,7 @@
     createProjects:
       enabled: true
       number: 1
+    knownProjects: []
 
 actions:
   clone_project:
diff --git a/container/tools/config/parser.py b/container/tools/config/parser.py
index c7e45fc..51622ec 100644
--- a/container/tools/config/parser.py
+++ b/container/tools/config/parser.py
@@ -22,7 +22,10 @@
     "gerrit": {"url": None, "user": "admin", "password": "secret"},
     "testrun": {
         "duration": None,
-        "initialization": {"createProjects": {"enabled": True, "number": 1}},
+        "initialization": {
+            "createProjects": {"enabled": True, "number": 1},
+            "knownProjects": list(),
+        },
     },
     "actions": {
         "clone_project": {"probability": 1},
diff --git a/container/tools/start_test.py b/container/tools/start_test.py
index d1fe684..31ea3d8 100755
--- a/container/tools/start_test.py
+++ b/container/tools/start_test.py
@@ -43,6 +43,11 @@
         self.action_config = test_config["actions"]
 
         self.owned_projects = set()
+        if test_config["testrun"]["initialization"]["knownProjects"]:
+            self.owned_projects = set(
+                test_config["testrun"]["initialization"]["knownProjects"]
+            )
+
         self.cloned_projects = set()
 
         if test_config["testrun"]["initialization"]["createProjects"]["enabled"]: