Merge branch 'stable-3.1' into stable-3.2

* stable-3.1:
  rest-api-changes.txt: requirement.fallback_text snake-case
  e2e-tests: Rename 'default' to projectName for explicitness
  e2e-tests: Rename 'unique' to uniqueName for explicitness
  e2e-tests: Rename 'name' to className for explicitness
  GerritSimulation: Fix json keys parsing's alphabetical order
  GerritSimulation: Rename 'pack' to packageName for clarity
  GerritSimulation: Remove unnecessary use of 'this'
  e2e-tests: Remove unnecessary type specifications

Change-Id: Ia99a25244f4a1c4869b47bdcf03f803874458260
This commit is contained in:
Marco Miller
2020-09-25 16:02:24 -04:00
20 changed files with 79 additions and 77 deletions

View File

@@ -7057,7 +7057,7 @@ The `Requirement` entity contains information about a requirement relative to a
|=========================== |===========================
|Field Name | |Description |Field Name | |Description
|`status` | | Status of the requirement. Can be either `OK`, `NOT_READY` or `RULE_ERROR`. |`status` | | Status of the requirement. Can be either `OK`, `NOT_READY` or `RULE_ERROR`.
|`fallbackText` | | A human readable reason |`fallback_text` | | A human readable reason
|`type` | | |`type` | |
Alphanumerical (plus hyphens or underscores) string to identify what the requirement is and why it Alphanumerical (plus hyphens or underscores) string to identify what the requirement is and why it
was triggered. Can be seen as a class: requirements sharing the same type were created for a similar was triggered. Can be seen as a class: requirements sharing the same type were created for a similar

View File

@@ -28,7 +28,7 @@ class ApproveChange extends GerritSimulation {
this.createChange = Some(createChange) this.createChange = Some(createChange)
} }
val test: ScenarioBuilder = scenario(unique) val test: ScenarioBuilder = scenario(uniqueName)
.feed(data) .feed(data)
.exec(session => { .exec(session => {
if (createChange.nonEmpty) { if (createChange.nonEmpty) {
@@ -37,7 +37,7 @@ class ApproveChange extends GerritSimulation {
session session
} }
}) })
.exec(http(unique) .exec(http(uniqueName)
.post("${url}${number}/revisions/current/review") .post("${url}${number}/revisions/current/review")
.body(ElFileBody(body)).asJson) .body(ElFileBody(body)).asJson)

View File

@@ -20,7 +20,7 @@ class CacheFlushSimulation extends GerritSimulation {
protected var producer: Option[CacheFlushSimulation] = None protected var producer: Option[CacheFlushSimulation] = None
protected var consumer: Option[CacheFlushSimulation] = None protected var consumer: Option[CacheFlushSimulation] = None
private var cacheEntriesBeforeFlush: Int = 0 private var cacheEntriesBeforeFlush = 0
def entriesBeforeFlush(entries: Int): Unit = { def entriesBeforeFlush(entries: Int): Unit = {
cacheEntriesBeforeFlush = entries cacheEntriesBeforeFlush = entries

View File

@@ -39,12 +39,12 @@ class CheckMasterBranchReplica1 extends ProjectSimulation {
private val submitChange = new SubmitChange(createChange) private val submitChange = new SubmitChange(createChange)
private val getBranch = new GetMasterBranchRevision private val getBranch = new GetMasterBranchRevision
private val test: ScenarioBuilder = scenario(unique) private val test: ScenarioBuilder = scenario(uniqueName)
.feed(data) .feed(data)
.exec(session => { .exec(session => {
session.set(getBranch.revisionKey, getBranch.revision.get) session.set(getBranch.revisionKey, getBranch.revision.get)
}) })
.exec(http(unique).get("${url}") .exec(http(uniqueName).get("${url}")
.check(regex(getBranch.revisionPattern) .check(regex(getBranch.revisionPattern)
.is(session => session(getBranch.revisionKey).as[String]))) .is(session => session(getBranch.revisionKey).as[String])))

View File

@@ -22,7 +22,7 @@ import scala.concurrent.duration._
class CheckNewProjectReplica1 extends GitSimulation { class CheckNewProjectReplica1 extends GitSimulation {
private val data: FeederBuilder = jsonFile(resource).convert(keys).queue private val data: FeederBuilder = jsonFile(resource).convert(keys).queue
private val default: String = name private val projectName = className
private lazy val replicationDuration = replicationDelay + SecondsPerWeightUnit private lazy val replicationDuration = replicationDelay + SecondsPerWeightUnit
@@ -30,16 +30,16 @@ class CheckNewProjectReplica1 extends GitSimulation {
override def replaceOverride(in: String): String = { override def replaceOverride(in: String): String = {
var next = replaceProperty("http_port1", 8081, in) var next = replaceProperty("http_port1", 8081, in)
next = replaceKeyWith("_project", default, next) next = replaceKeyWith("_project", projectName, next)
super.replaceOverride(next) super.replaceOverride(next)
} }
private val test: ScenarioBuilder = scenario(unique) private val test: ScenarioBuilder = scenario(uniqueName)
.feed(data) .feed(data)
.exec(gitRequest) .exec(gitRequest)
private val createProject = new CreateProject(default) private val createProject = new CreateProject(projectName)
private val deleteProject = new DeleteProject(default) private val deleteProject = new DeleteProject(projectName)
setUp( setUp(
createProject.test.inject( createProject.test.inject(

View File

@@ -27,7 +27,7 @@ class CheckProjectsCacheFlushEntries extends CacheFlushSimulation {
this.producer = Some(producer) this.producer = Some(producer)
} }
val test: ScenarioBuilder = scenario(unique) val test: ScenarioBuilder = scenario(uniqueName)
.feed(data) .feed(data)
.exec(session => { .exec(session => {
if (producer.nonEmpty) { if (producer.nonEmpty) {
@@ -36,7 +36,7 @@ class CheckProjectsCacheFlushEntries extends CacheFlushSimulation {
session session
} }
}) })
.exec(http(unique).get("${url}") .exec(http(uniqueName).get("${url}")
.check(regex("\"" + memKey + "\": (\\d+)") .check(regex("\"" + memKey + "\": (\\d+)")
.is(session => session(entriesKey).as[String]))) .is(session => session(entriesKey).as[String])))

View File

@@ -22,19 +22,19 @@ import scala.concurrent.duration._
class CloneUsingBothProtocols extends GitSimulation { class CloneUsingBothProtocols extends GitSimulation {
private val data: FeederBuilder = jsonFile(resource).convert(keys).queue private val data: FeederBuilder = jsonFile(resource).convert(keys).queue
private val default: String = name private val projectName = className
private val duration: Int = 2 private val duration = 2
override def replaceOverride(in: String): String = { override def replaceOverride(in: String): String = {
replaceKeyWith("_project", default, in) replaceKeyWith("_project", projectName, in)
} }
private val test: ScenarioBuilder = scenario(unique) private val test: ScenarioBuilder = scenario(uniqueName)
.feed(data) .feed(data)
.exec(gitRequest) .exec(gitRequest)
private val createProject = new CreateProject(default) private val createProject = new CreateProject(projectName)
private val deleteProject = new DeleteProject(default) private val deleteProject = new DeleteProject(projectName)
setUp( setUp(
createProject.test.inject( createProject.test.inject(

View File

@@ -28,12 +28,12 @@ class CreateChange extends ProjectSimulation {
override def relativeRuntimeWeight = 2 override def relativeRuntimeWeight = 2
def this(default: String) { def this(projectName: String) {
this() this()
this.default = default this.projectName = projectName
} }
val test: ScenarioBuilder = scenario(unique) val test: ScenarioBuilder = scenario(uniqueName)
.feed(data) .feed(data)
.exec(httpRequest .exec(httpRequest
.body(ElFileBody(body)).asJson .body(ElFileBody(body)).asJson
@@ -43,8 +43,8 @@ class CreateChange extends ProjectSimulation {
session session
}) })
private val createProject = new CreateProject(default) private val createProject = new CreateProject(projectName)
private val deleteProject = new DeleteProject(default) private val deleteProject = new DeleteProject(projectName)
private val deleteChange = new DeleteChange(this) private val deleteChange = new DeleteChange(this)
setUp( setUp(

View File

@@ -21,12 +21,12 @@ import io.gatling.core.structure.ScenarioBuilder
class CreateProject extends ProjectSimulation { class CreateProject extends ProjectSimulation {
private val data: FeederBuilder = jsonFile(resource).convert(keys).queue private val data: FeederBuilder = jsonFile(resource).convert(keys).queue
def this(default: String) { def this(projectName: String) {
this() this()
this.default = default this.projectName = projectName
} }
val test: ScenarioBuilder = scenario(unique) val test: ScenarioBuilder = scenario(uniqueName)
.feed(data) .feed(data)
.exec(httpRequest.body(ElFileBody(body)).asJson) .exec(httpRequest.body(ElFileBody(body)).asJson)

View File

@@ -30,7 +30,7 @@ class DeleteChange extends GerritSimulation {
this.createChange = Some(createChange) this.createChange = Some(createChange)
} }
val test: ScenarioBuilder = scenario(unique) val test: ScenarioBuilder = scenario(uniqueName)
.feed(data) .feed(data)
.exec(session => { .exec(session => {
if (createChange.nonEmpty) { if (createChange.nonEmpty) {
@@ -39,7 +39,7 @@ class DeleteChange extends GerritSimulation {
session session
} }
}) })
.exec(http(unique).delete("${url}${number}")) .exec(http(uniqueName).delete("${url}${number}"))
setUp( setUp(
test.inject( test.inject(

View File

@@ -21,12 +21,12 @@ import io.gatling.core.structure.ScenarioBuilder
class DeleteProject extends ProjectSimulation { class DeleteProject extends ProjectSimulation {
private val data: FeederBuilder = jsonFile(resource).convert(keys).queue private val data: FeederBuilder = jsonFile(resource).convert(keys).queue
def this(default: String) { def this(projectName: String) {
this() this()
this.default = default this.projectName = projectName
} }
val test: ScenarioBuilder = scenario(unique) val test: ScenarioBuilder = scenario(uniqueName)
.feed(data) .feed(data)
.exec(httpRequest) .exec(httpRequest)

View File

@@ -22,18 +22,18 @@ import scala.concurrent.duration._
class FlushProjectsCache extends CacheFlushSimulation { class FlushProjectsCache extends CacheFlushSimulation {
private val data: FeederBuilder = jsonFile(resource).convert(keys).queue private val data: FeederBuilder = jsonFile(resource).convert(keys).queue
private val default: String = name private val projectName = className
override def relativeRuntimeWeight = 2 override def relativeRuntimeWeight = 2
private val test: ScenarioBuilder = scenario(unique) private val test: ScenarioBuilder = scenario(uniqueName)
.feed(data) .feed(data)
.exec(httpRequest) .exec(httpRequest)
private val createProject = new CreateProject(default) private val createProject = new CreateProject(projectName)
private val getCacheEntriesAfterProject = new GetProjectsCacheEntries(this) private val getCacheEntriesAfterProject = new GetProjectsCacheEntries(this)
private val checkCacheEntriesAfterFlush = new CheckProjectsCacheFlushEntries(this) private val checkCacheEntriesAfterFlush = new CheckProjectsCacheFlushEntries(this)
private val deleteProject = new DeleteProject(default) private val deleteProject = new DeleteProject(projectName)
setUp( setUp(
createProject.test.inject( createProject.test.inject(

View File

@@ -23,7 +23,7 @@ import scala.concurrent.duration._
class FlushProjectsCacheThenRebuild extends GerritSimulation { class FlushProjectsCacheThenRebuild extends GerritSimulation {
private val data: FeederBuilder = jsonFile(resource).convert(keys).queue private val data: FeederBuilder = jsonFile(resource).convert(keys).queue
private val test: ScenarioBuilder = scenario(unique) private val test: ScenarioBuilder = scenario(uniqueName)
.feed(data) .feed(data)
.exec(httpRequest) .exec(httpRequest)

View File

@@ -23,20 +23,22 @@ import io.gatling.http.request.builder.HttpRequestBuilder
class GerritSimulation extends Simulation { class GerritSimulation extends Simulation {
implicit val conf: GatlingGitConfiguration = GatlingGitConfiguration() implicit val conf: GatlingGitConfiguration = GatlingGitConfiguration()
private val pack: String = this.getClass.getPackage.getName private val packageName = getClass.getPackage.getName
private val path: String = pack.replaceAllLiterally(".", "/") private val path = packageName.replaceAllLiterally(".", "/")
protected val name: String = this.getClass.getSimpleName
private val pathName: String = s"data/$path/$name" protected val className: String = getClass.getSimpleName
protected val resource: String = s"$pathName.json" private val pathName = s"data/$path/$className"
protected val body: String = s"$pathName-body.json" protected val resource = s"$pathName.json"
protected val unique: String = name + "-" + this.hashCode() protected val body = s"$pathName-body.json"
protected val uniqueName: String = className + "-" + hashCode()
protected val single = 1 protected val single = 1
val replicationDelay: Int = replaceProperty("replication_delay", 15).toInt val replicationDelay: Int = replaceProperty("replication_delay", 15).toInt
private val powerFactor: Double = replaceProperty("power_factor", 1.0).toDouble private val powerFactor = replaceProperty("power_factor", 1.0).toDouble
protected val SecondsPerWeightUnit: Int = 2 protected val SecondsPerWeightUnit = 2
val maxExecutionTime: Int = (SecondsPerWeightUnit * relativeRuntimeWeight * powerFactor).toInt val maxExecutionTime: Int = (SecondsPerWeightUnit * relativeRuntimeWeight * powerFactor).toInt
private var cumulativeWaitTime: Int = 0 private var cumulativeWaitTime = 0
/** /**
* How long a scenario step should wait before starting to execute. * How long a scenario step should wait before starting to execute.
@@ -53,29 +55,29 @@ class GerritSimulation extends Simulation {
currentWaitTime currentWaitTime
} }
protected val httpRequest: HttpRequestBuilder = http(unique).post("${url}") protected val httpRequest: HttpRequestBuilder = http(uniqueName).post("${url}")
protected val httpProtocol: HttpProtocolBuilder = http.basicAuth( protected val httpProtocol: HttpProtocolBuilder = http.basicAuth(
conf.httpConfiguration.userName, conf.httpConfiguration.userName,
conf.httpConfiguration.password) conf.httpConfiguration.password)
protected val keys: PartialFunction[(String, Any), Any] = { protected val keys: PartialFunction[(String, Any), Any] = {
case ("url", url) => case ("entries", entries) =>
var in = replaceOverride(url.toString) replaceProperty("projects_entries", "1", entries.toString)
in = replaceProperty("hostname", "localhost", in)
in = replaceProperty("http_port", 8080, in)
in = replaceProperty("http_scheme", "http", in)
replaceProperty("ssh_port", 29418, in)
case ("number", number) => case ("number", number) =>
val precedes = replaceKeyWith("_number", 0, number.toString) val precedes = replaceKeyWith("_number", 0, number.toString)
replaceProperty("number", 1, precedes) replaceProperty("number", 1, precedes)
case ("parent", parent) => case ("parent", parent) =>
replaceProperty("parent", "All-Projects", parent.toString) replaceProperty("parent", "All-Projects", parent.toString)
case ("project", project) => case ("project", project) =>
var precedes = replaceKeyWith("_project", name, project.toString) var precedes = replaceKeyWith("_project", className, project.toString)
precedes = replaceOverride(precedes) precedes = replaceOverride(precedes)
replaceProperty("project", precedes) replaceProperty("project", precedes)
case ("entries", entries) => case ("url", url) =>
replaceProperty("projects_entries", "1", entries.toString) var in = replaceOverride(url.toString)
in = replaceProperty("hostname", "localhost", in)
in = replaceProperty("http_port", 8080, in)
in = replaceProperty("http_scheme", "http", in)
replaceProperty("ssh_port", 29418, in)
} }
private def replaceProperty(term: String, in: String): String = { private def replaceProperty(term: String, in: String): String = {
@@ -87,7 +89,7 @@ class GerritSimulation extends Simulation {
} }
protected def replaceProperty(term: String, default: Any, in: String): String = { protected def replaceProperty(term: String, default: Any, in: String): String = {
val property = pack + "." + term val property = packageName + "." + term
var value = default var value = default
default match { default match {
case _: String | _: Double => case _: String | _: Double =>

View File

@@ -25,9 +25,9 @@ class GetMasterBranchRevision extends ProjectSimulation {
val revisionKey = "revision" val revisionKey = "revision"
val revisionPattern: String = "\"" + revisionKey + "\": \"(.+)\"" val revisionPattern: String = "\"" + revisionKey + "\": \"(.+)\""
val test: ScenarioBuilder = scenario(unique) val test: ScenarioBuilder = scenario(uniqueName)
.feed(data) .feed(data)
.exec(http(unique).get("${url}") .exec(http(uniqueName).get("${url}")
.check(regex(revisionPattern).saveAs(revisionKey))) .check(regex(revisionPattern).saveAs(revisionKey)))
.exec(session => { .exec(session => {
revision = Some(session(revisionKey).as[String]) revision = Some(session(revisionKey).as[String])

View File

@@ -27,9 +27,9 @@ class GetProjectsCacheEntries extends CacheFlushSimulation {
this.consumer = Some(consumer) this.consumer = Some(consumer)
} }
val test: ScenarioBuilder = scenario(unique) val test: ScenarioBuilder = scenario(uniqueName)
.feed(data) .feed(data)
.exec(http(unique).get("${url}") .exec(http(uniqueName).get("${url}")
.check(regex("\"" + memKey + "\": (\\d+)").saveAs(entriesKey))) .check(regex("\"" + memKey + "\": (\\d+)").saveAs(entriesKey)))
.exec(session => { .exec(session => {
if (consumer.nonEmpty) { if (consumer.nonEmpty) {

View File

@@ -22,9 +22,9 @@ import io.gatling.http.Predef.http
class ListProjects extends GerritSimulation { class ListProjects extends GerritSimulation {
private val data: FeederBuilder = jsonFile(resource).convert(keys).queue private val data: FeederBuilder = jsonFile(resource).convert(keys).queue
val test: ScenarioBuilder = scenario(unique) val test: ScenarioBuilder = scenario(uniqueName)
.feed(data) .feed(data)
.exec(http(unique).get("${url}")) .exec(http(uniqueName).get("${url}"))
setUp( setUp(
test.inject( test.inject(

View File

@@ -15,9 +15,9 @@
package com.google.gerrit.scenarios package com.google.gerrit.scenarios
class ProjectSimulation extends GerritSimulation { class ProjectSimulation extends GerritSimulation {
protected var default: String = "project" protected var projectName: String = "defaultTestProject"
override def replaceOverride(in: String): String = { override def replaceOverride(in: String): String = {
replaceProperty("project", default, in) replaceProperty("project", projectName, in)
} }
} }

View File

@@ -22,22 +22,22 @@ import scala.concurrent.duration._
class ReplayRecordsFromFeeder extends GitSimulation { class ReplayRecordsFromFeeder extends GitSimulation {
private val data: FeederBuilder = jsonFile(resource).convert(keys).circular private val data: FeederBuilder = jsonFile(resource).convert(keys).circular
private val default: String = name private val projectName = className
override def relativeRuntimeWeight = 30 override def relativeRuntimeWeight = 30
override def replaceOverride(in: String): String = { override def replaceOverride(in: String): String = {
replaceKeyWith("_project", default, in) replaceKeyWith("_project", projectName, in)
} }
private val test: ScenarioBuilder = scenario(unique) private val test: ScenarioBuilder = scenario(uniqueName)
.repeat(10) { .repeat(10) {
feed(data) feed(data)
.exec(gitRequest) .exec(gitRequest)
} }
private val createProject = new CreateProject(default) private val createProject = new CreateProject(projectName)
private val deleteProject = new DeleteProject(default) private val deleteProject = new DeleteProject(projectName)
private val maxBeforeDelete: Int = maxExecutionTime - deleteProject.maxExecutionTime private val maxBeforeDelete: Int = maxExecutionTime - deleteProject.maxExecutionTime
setUp( setUp(

View File

@@ -23,8 +23,8 @@ import scala.concurrent.duration._
class SubmitChange extends GerritSimulation { class SubmitChange extends GerritSimulation {
private val data: FeederBuilder = jsonFile(resource).convert(keys).queue private val data: FeederBuilder = jsonFile(resource).convert(keys).queue
private val default: String = name private val projectName = className
private var createChange = new CreateChange(default) private var createChange = new CreateChange(projectName)
override def relativeRuntimeWeight = 10 override def relativeRuntimeWeight = 10
@@ -33,16 +33,16 @@ class SubmitChange extends GerritSimulation {
this.createChange = createChange this.createChange = createChange
} }
val test: ScenarioBuilder = scenario(unique) val test: ScenarioBuilder = scenario(uniqueName)
.feed(data) .feed(data)
.exec(session => { .exec(session => {
session.set("number", createChange.number) session.set("number", createChange.number)
}) })
.exec(http(unique).post("${url}${number}/submit")) .exec(http(uniqueName).post("${url}${number}/submit"))
private val createProject = new CreateProject(default) private val createProject = new CreateProject(projectName)
private val approveChange = new ApproveChange(createChange) private val approveChange = new ApproveChange(createChange)
private val deleteProject = new DeleteProject(default) private val deleteProject = new DeleteProject(projectName)
setUp( setUp(
createProject.test.inject( createProject.test.inject(