CreateChangesTriggeringGc: Customize data to execute garbage collection
Before this change, the default values of the plugin's configuration
were taken as the values used during the test. This isn't the case
anymore, as every environment can have its own configuration by
specifying gc-conductor plugin properties in the gerrit.config file,
leading to a failure in the gatling tests.
This change introduces two optional environment properties to configure
the gatling test according to the system.
The first property is minute_multiplier, which multiplies the default
number of seconds which is 60 seconds. If not configured, this value is
set to 1.
The second property is loose_objects, used to control the number of
changes used during the test. If not configured, this variable is set to
the plugin's default value, 400.
Change-Id: I81eb81542b4218e71d4d3a42863c9109a3af4af9
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..bbd1f59 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
@@ -26,17 +26,18 @@
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
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)
),