Merge changes Ie477a079,I605c6b5f into stable-2.16
* changes: GerritSimulation: Support runtime factor property GerritSimulation: Add replaceOverride javadoc tags
This commit is contained in:
@@ -167,6 +167,17 @@ Further above, the `_PROJECT` keyword is prefixed with an underscore, which mean
|
||||
gets automatically generated by the scenario. Any property setting for it is therefore not
|
||||
applicable. Its usage differs from the non-prefixed `PROJECT` keyword, in that sense.
|
||||
|
||||
The following core property can be optionally set depending on the runtime environment. The test
|
||||
environments used as reference for scenarios development assume its default value, `1.0`. For
|
||||
slower or more complex execution environments, the value can be increased this way for example:
|
||||
|
||||
* `-Dcom.google.gerrit.scenarios.power_factor=1.5`
|
||||
|
||||
This will make the scenario steps take half more time to expect proper completion. A value smaller
|
||||
than the default, say `0.8`, will make scenarios wait somewhat less than how they were developed.
|
||||
Scenario development is often done using locally running Gerrit systems under test, which are
|
||||
sometimes dockerized.
|
||||
|
||||
== How to run tests
|
||||
|
||||
Run all tests:
|
||||
|
||||
@@ -31,8 +31,9 @@ class GerritSimulation extends Simulation {
|
||||
protected val body: String = s"$pathName-body.json"
|
||||
protected val unique: String = name + "-" + this.hashCode()
|
||||
|
||||
private val powerFactor: Double = replaceProperty("power_factor", 1.0).toDouble
|
||||
private val SecondsPerWeightUnit: Int = 2
|
||||
val maxExecutionTime: Int = SecondsPerWeightUnit * relativeRuntimeWeight
|
||||
val maxExecutionTime: Int = (SecondsPerWeightUnit * relativeRuntimeWeight * powerFactor).toInt
|
||||
private var cumulativeWaitTime: Int = 0
|
||||
|
||||
/**
|
||||
@@ -73,11 +74,15 @@ class GerritSimulation extends Simulation {
|
||||
replaceProperty(term, term, in)
|
||||
}
|
||||
|
||||
private def replaceProperty(term: String, default: Any): String = {
|
||||
replaceProperty(term, default, term.toUpperCase)
|
||||
}
|
||||
|
||||
protected def replaceProperty(term: String, default: Any, in: String): String = {
|
||||
val property = pack + "." + term
|
||||
var value = default
|
||||
default match {
|
||||
case _: String =>
|
||||
case _: String | _: Double =>
|
||||
val propertyValue = Option(System.getProperty(property))
|
||||
if (propertyValue.nonEmpty) {
|
||||
value = propertyValue.get
|
||||
@@ -103,6 +108,9 @@ class GerritSimulation extends Simulation {
|
||||
* override def replaceOverride(in: String): String = {
|
||||
* // Simple e.g., replaceProperty("EXTENSION_JSON_KEY", "default", in)
|
||||
* </pre>
|
||||
*
|
||||
* @param in which string to perform the replacements.
|
||||
* @return the resulting String.
|
||||
*/
|
||||
def replaceOverride(in: String): String = {
|
||||
in
|
||||
|
||||
Reference in New Issue
Block a user