Merge "e2e-tests: Add {Approve|Submit}Change core scenarios" into stable-2.16
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"labels": {
|
||||||
|
"Code-Review": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"url": "http://HOSTNAME:HTTP_PORT/a/changes/",
|
||||||
|
"number": "NUMBER"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"url": "http://HOSTNAME:HTTP_PORT/a/changes/",
|
"url": "http://HOSTNAME:HTTP_PORT/a/changes/",
|
||||||
"project": "_PROJECT"
|
"project": "PROJECT"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"url": "http://HOSTNAME:HTTP_PORT/a/changes/",
|
"url": "http://HOSTNAME:HTTP_PORT/a/changes/",
|
||||||
"number": "_NUMBER"
|
"number": "NUMBER"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"url": "http://HOSTNAME:HTTP_PORT/a/changes/"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
// Copyright (C) 2020 The Android Open Source Project
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package com.google.gerrit.scenarios
|
||||||
|
|
||||||
|
import io.gatling.core.Predef.{atOnceUsers, _}
|
||||||
|
import io.gatling.core.feeder.FeederBuilder
|
||||||
|
import io.gatling.core.structure.ScenarioBuilder
|
||||||
|
import io.gatling.http.Predef.http
|
||||||
|
|
||||||
|
class ApproveChange extends GerritSimulation {
|
||||||
|
private val data: FeederBuilder = jsonFile(resource).convert(keys).queue
|
||||||
|
private var createChange: Option[CreateChange] = None
|
||||||
|
|
||||||
|
def this(createChange: CreateChange) {
|
||||||
|
this()
|
||||||
|
this.createChange = Some(createChange)
|
||||||
|
}
|
||||||
|
|
||||||
|
val test: ScenarioBuilder = scenario(unique)
|
||||||
|
.feed(data)
|
||||||
|
.exec(session => {
|
||||||
|
if (createChange.nonEmpty) {
|
||||||
|
session.set("number", createChange.get.number)
|
||||||
|
} else {
|
||||||
|
session
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.exec(http(unique)
|
||||||
|
.post("${url}${number}/revisions/current/review")
|
||||||
|
.body(ElFileBody(body)).asJson)
|
||||||
|
|
||||||
|
setUp(
|
||||||
|
test.inject(
|
||||||
|
atOnceUsers(1)
|
||||||
|
)).protocols(httpProtocol)
|
||||||
|
}
|
||||||
@@ -21,26 +21,31 @@ import io.gatling.http.Predef._
|
|||||||
|
|
||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
|
|
||||||
class CreateChange extends GerritSimulation {
|
class CreateChange extends ProjectSimulation {
|
||||||
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 numberKey = "_number"
|
private val numberKey = "_number"
|
||||||
|
var number = 0
|
||||||
|
|
||||||
override def relativeRuntimeWeight = 2
|
override def relativeRuntimeWeight = 2
|
||||||
|
|
||||||
private val test: ScenarioBuilder = scenario(unique)
|
def this(default: String) {
|
||||||
|
this()
|
||||||
|
this.default = default
|
||||||
|
}
|
||||||
|
|
||||||
|
val test: ScenarioBuilder = scenario(unique)
|
||||||
.feed(data)
|
.feed(data)
|
||||||
.exec(httpRequest
|
.exec(httpRequest
|
||||||
.body(ElFileBody(body)).asJson
|
.body(ElFileBody(body)).asJson
|
||||||
.check(regex("\"" + numberKey + "\":(\\d+),").saveAs(numberKey)))
|
.check(regex("\"" + numberKey + "\":(\\d+),").saveAs(numberKey)))
|
||||||
.exec(session => {
|
.exec(session => {
|
||||||
deleteChange.number = Some(session(numberKey).as[Int])
|
number = session(numberKey).as[Int]
|
||||||
session
|
session
|
||||||
})
|
})
|
||||||
|
|
||||||
private val createProject = new CreateProject(default)
|
private val createProject = new CreateProject(default)
|
||||||
private val deleteProject = new DeleteProject(default)
|
private val deleteProject = new DeleteProject(default)
|
||||||
private val deleteChange = new DeleteChange
|
private val deleteChange = new DeleteChange(this)
|
||||||
|
|
||||||
setUp(
|
setUp(
|
||||||
createProject.test.inject(
|
createProject.test.inject(
|
||||||
|
|||||||
@@ -21,15 +21,20 @@ import io.gatling.http.Predef.http
|
|||||||
|
|
||||||
class DeleteChange extends GerritSimulation {
|
class DeleteChange extends GerritSimulation {
|
||||||
private val data: FeederBuilder = jsonFile(resource).convert(keys).queue
|
private val data: FeederBuilder = jsonFile(resource).convert(keys).queue
|
||||||
var number: Option[Int] = None
|
private var createChange: Option[CreateChange] = None
|
||||||
|
|
||||||
override def relativeRuntimeWeight = 2
|
override def relativeRuntimeWeight = 2
|
||||||
|
|
||||||
|
def this(createChange: CreateChange) {
|
||||||
|
this()
|
||||||
|
this.createChange = Some(createChange)
|
||||||
|
}
|
||||||
|
|
||||||
val test: ScenarioBuilder = scenario(unique)
|
val test: ScenarioBuilder = scenario(unique)
|
||||||
.feed(data)
|
.feed(data)
|
||||||
.exec(session => {
|
.exec(session => {
|
||||||
if (number.nonEmpty) {
|
if (createChange.nonEmpty) {
|
||||||
session.set("number", number.get)
|
session.set("number", createChange.get.number)
|
||||||
} else {
|
} else {
|
||||||
session
|
session
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ class GerritSimulation extends Simulation {
|
|||||||
val precedes = replaceKeyWith("_number", 0, number.toString)
|
val precedes = replaceKeyWith("_number", 0, number.toString)
|
||||||
replaceProperty("number", 1, precedes)
|
replaceProperty("number", 1, precedes)
|
||||||
case ("project", project) =>
|
case ("project", project) =>
|
||||||
val precedes = replaceKeyWith("_project", name, project.toString)
|
var precedes = replaceKeyWith("_project", name, project.toString)
|
||||||
|
precedes = replaceOverride(precedes)
|
||||||
replaceProperty("project", precedes)
|
replaceProperty("project", precedes)
|
||||||
case ("entries", entries) =>
|
case ("entries", entries) =>
|
||||||
replaceProperty("projects_entries", "1", entries.toString)
|
replaceProperty("projects_entries", "1", entries.toString)
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
// Copyright (C) 2020 The Android Open Source Project
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package com.google.gerrit.scenarios
|
||||||
|
|
||||||
|
import io.gatling.core.Predef.{atOnceUsers, _}
|
||||||
|
import io.gatling.core.feeder.FeederBuilder
|
||||||
|
import io.gatling.core.structure.ScenarioBuilder
|
||||||
|
import io.gatling.http.Predef.http
|
||||||
|
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
|
||||||
|
class SubmitChange extends GerritSimulation {
|
||||||
|
private val data: FeederBuilder = jsonFile(resource).convert(keys).queue
|
||||||
|
private val default: String = name
|
||||||
|
|
||||||
|
private val test: ScenarioBuilder = scenario(unique)
|
||||||
|
.feed(data)
|
||||||
|
.exec(session => {
|
||||||
|
session.set("number", createChange.number)
|
||||||
|
})
|
||||||
|
.exec(http(unique).post("${url}${number}/submit"))
|
||||||
|
|
||||||
|
private val createProject = new CreateProject(default)
|
||||||
|
private val createChange = new CreateChange(default)
|
||||||
|
private val approveChange = new ApproveChange(createChange)
|
||||||
|
private val deleteProject = new DeleteProject(default)
|
||||||
|
|
||||||
|
setUp(
|
||||||
|
createProject.test.inject(
|
||||||
|
nothingFor(stepWaitTime(createProject) seconds),
|
||||||
|
atOnceUsers(1)
|
||||||
|
),
|
||||||
|
createChange.test.inject(
|
||||||
|
nothingFor(stepWaitTime(createChange) seconds),
|
||||||
|
atOnceUsers(1)
|
||||||
|
),
|
||||||
|
approveChange.test.inject(
|
||||||
|
nothingFor(stepWaitTime(approveChange) seconds),
|
||||||
|
atOnceUsers(1)
|
||||||
|
),
|
||||||
|
test.inject(
|
||||||
|
nothingFor(stepWaitTime(this) seconds),
|
||||||
|
atOnceUsers(1)
|
||||||
|
),
|
||||||
|
deleteProject.test.inject(
|
||||||
|
nothingFor(stepWaitTime(deleteProject) seconds),
|
||||||
|
atOnceUsers(1)
|
||||||
|
),
|
||||||
|
).protocols(httpProtocol)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user