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
|`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` | |
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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -22,19 +22,19 @@ import scala.concurrent.duration._
class CloneUsingBothProtocols extends GitSimulation {
private val data: FeederBuilder = jsonFile(resource).convert(keys).queue
private val default: String = name
private val duration: Int = 2
private val projectName = className
private val duration = 2
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)
.exec(gitRequest)
private val createProject = new CreateProject(default)
private val deleteProject = new DeleteProject(default)
private val createProject = new CreateProject(projectName)
private val deleteProject = new DeleteProject(projectName)
setUp(
createProject.test.inject(

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -15,9 +15,9 @@
package com.google.gerrit.scenarios
class ProjectSimulation extends GerritSimulation {
protected var default: String = "project"
protected var projectName: String = "defaultTestProject"
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 {
private val data: FeederBuilder = jsonFile(resource).convert(keys).circular
private val default: String = name
private val projectName = className
override def relativeRuntimeWeight = 30
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) {
feed(data)
.exec(gitRequest)
}
private val createProject = new CreateProject(default)
private val deleteProject = new DeleteProject(default)
private val createProject = new CreateProject(projectName)
private val deleteProject = new DeleteProject(projectName)
private val maxBeforeDelete: Int = maxExecutionTime - deleteProject.maxExecutionTime
setUp(

View File

@@ -23,8 +23,8 @@ import scala.concurrent.duration._
class SubmitChange extends GerritSimulation {
private val data: FeederBuilder = jsonFile(resource).convert(keys).queue
private val default: String = name
private var createChange = new CreateChange(default)
private val projectName = className
private var createChange = new CreateChange(projectName)
override def relativeRuntimeWeight = 10
@@ -33,16 +33,16 @@ class SubmitChange extends GerritSimulation {
this.createChange = createChange
}
val test: ScenarioBuilder = scenario(unique)
val test: ScenarioBuilder = scenario(uniqueName)
.feed(data)
.exec(session => {
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 deleteProject = new DeleteProject(default)
private val deleteProject = new DeleteProject(projectName)
setUp(
createProject.test.inject(