Merge branch 'stable-3.1'

* stable-3.1:
  CreateChangesTriggeringGc: Customize data to execute garbage collection
  e2e-tests: Reuse the now available numberKey from GerritSimulation

Change-Id: I55aa51870de3beee8008ae462e2c1dc3b3a4cd14
diff --git a/src/test/README.md b/src/test/README.md
index ecb8bfb..23a51b2 100644
--- a/src/test/README.md
+++ b/src/test/README.md
@@ -25,3 +25,22 @@
 scala package one from the scenario classes. The core framework expects
 such a directory structure for both the scala and resources (json data)
 files.
+
+There are two environment properties that can be configured:
+
+The ```minute_multiplier``` property defines a value that get
+multiplied by 60 to represent the time needed by the test before
+creating the last change which triggers the plugin. Its default is ```1```
+and can be set using another value:
+
+```bash
+   -Dcom.ericsson.gerrit.plugins.gcconductor.scenarios.minute_multiplier=5
+```
+
+The ```loose_objects``` property represents the value of loose objects
+required to trigger garbage collection. Its default value is ```400``` and
+can be set using another value:
+
+```bash
+   -Dcom.ericsson.gerrit.plugins.gcconductor.scenarios.loose_objects=50
+```
diff --git a/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/CreateChangesTriggeringGc.scala b/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/CreateChangesTriggeringGc.scala
index bc74935..c6a4534 100644
--- a/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/CreateChangesTriggeringGc.scala
+++ b/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/CreateChangesTriggeringGc.scala
@@ -24,19 +24,19 @@
 
 class CreateChangesTriggeringGc extends ProjectSimulation {
   private val data: FeederBuilder = jsonFile(resource).convert(keys).circular
-  private val numberKey = "_number"
 
-  lazy val DefaultSecondsToNextEvaluation = 60
-  private lazy val DefaultLooseObjectsToEnqueueGc = 400
+  private lazy val minuteMultiplier = getProperty("minute_multiplier", 1).toInt
+  lazy val secondsToNextEvaluation: Int = 60 * minuteMultiplier
+  private lazy val looseObjectsToEnqueueGc = getProperty("loose_objects", 400).toInt
   private lazy val LooseObjectsPerChange = 2
   private lazy val ChangesMultiplier = 8
   lazy val changesPerSecond: Int = 4 * ChangesMultiplier
   val ChangesForLastEvaluation: Int = single
 
   lazy val secondsForLastEvaluation: Int = SecondsPerWeightUnit
-  private lazy val changesToEnqueueGc = DefaultLooseObjectsToEnqueueGc * ChangesMultiplier / LooseObjectsPerChange
+  private lazy val changesToEnqueueGc = looseObjectsToEnqueueGc * ChangesMultiplier / LooseObjectsPerChange
   lazy val secondsToChanges: Int = changesToEnqueueGc / changesPerSecond
-  private lazy val maxSecondsToEnqueueGc = secondsToChanges + DefaultSecondsToNextEvaluation + secondsForLastEvaluation
+  private lazy val maxSecondsToEnqueueGc = secondsToChanges + secondsToNextEvaluation + secondsForLastEvaluation
 
   override def relativeRuntimeWeight: Int = maxSecondsToEnqueueGc / SecondsPerWeightUnit
 
@@ -50,7 +50,7 @@
     .feed(data)
     .exec(httpRequest
       .body(ElFileBody(body)).asJson
-      .check(regex("\"" + numberKey + "\":(\\d+),").saveAs(numberKey)))
+      .check(regex("\"_" + numberKey + "\":(\\d+),").saveAs(numberKey)))
     .exec(session => {
       deleteChanges.upToNumber = session(numberKey).as[Int]
       session
diff --git a/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/CreateChangesTriggeringGcWithProject.scala b/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/CreateChangesTriggeringGcWithProject.scala
index 7c1b201..f0859ba 100644
--- a/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/CreateChangesTriggeringGcWithProject.scala
+++ b/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/CreateChangesTriggeringGcWithProject.scala
@@ -36,7 +36,7 @@
     createChanges.test.inject(
       nothingFor(stepWaitTime(createChanges) seconds),
       constantUsersPerSec(createChanges.changesPerSecond) during (createChanges.secondsToChanges seconds),
-      nothingFor(createChanges.DefaultSecondsToNextEvaluation seconds),
+      nothingFor(createChanges.secondsToNextEvaluation seconds),
       nothingFor(createChanges.secondsForLastEvaluation / 2 seconds),
       atOnceUsers(createChanges.ChangesForLastEvaluation)
     ),
diff --git a/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/DeleteChangesAfterGc.scala b/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/DeleteChangesAfterGc.scala
index 4775551..3019aed 100644
--- a/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/DeleteChangesAfterGc.scala
+++ b/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/DeleteChangesAfterGc.scala
@@ -22,7 +22,6 @@
 
 class DeleteChangesAfterGc extends GerritSimulation {
   private val data: FeederBuilder = jsonFile(resource).convert(keys).circular
-  private val numberKey = "number"
   var upToNumber = 1
 
   private lazy val OrderOfChangesToDelete = 200