summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <dpursehouse@collab.net>2020-03-22 11:05:58 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-03-22 11:05:58 +0000
commitcc766db13568bf437363b45218e36af664f26354 (patch)
tree56f0141cabd21614444eccdb40d8f02cd8b2583d
parent73f4630fab479ab21c1556c7c72c9d2acee826af (diff)
parent5b8d6d95b0a3abeefd85423e59e14af0e29df025 (diff)
Merge changes from topics "json-constant-renamed", "non-core-scenarios" into stable-3.1
* changes: e2e-tests: Rename the now reused json filename constant e2e-tests: Refactor documentation about functional e2e-tests: Move core json files into scala package e2e-tests: Support adding/running non-core scenarios
-rw-r--r--Documentation/dev-e2e-tests.txt62
-rw-r--r--Documentation/dev-readme.txt4
-rw-r--r--e2e-tests/src/test/resources/data/.gitignore4
-rw-r--r--e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/CloneUsingBothProtocols.json (renamed from e2e-tests/src/test/resources/data/CloneUsingBothProtocols.json)0
-rw-r--r--e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/CreateProject.json (renamed from e2e-tests/src/test/resources/data/CreateProject.json)0
-rw-r--r--e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/DeleteProject.json (renamed from e2e-tests/src/test/resources/data/DeleteProject.json)0
-rw-r--r--e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/ReplayRecordsFromFeeder.json (renamed from e2e-tests/src/test/resources/data/ReplayRecordsFromFeeder.json)0
-rw-r--r--e2e-tests/src/test/scala/.gitignore4
-rw-r--r--e2e-tests/src/test/scala/com/google/gerrit/scenarios/CloneUsingBothProtocols.scala2
-rw-r--r--e2e-tests/src/test/scala/com/google/gerrit/scenarios/CreateProject.scala2
-rw-r--r--e2e-tests/src/test/scala/com/google/gerrit/scenarios/DeleteProject.scala2
-rw-r--r--e2e-tests/src/test/scala/com/google/gerrit/scenarios/GerritSimulation.scala4
-rw-r--r--e2e-tests/src/test/scala/com/google/gerrit/scenarios/ReplayRecordsFromFeeder.scala2
13 files changed, 66 insertions, 20 deletions
diff --git a/Documentation/dev-e2e-tests.txt b/Documentation/dev-e2e-tests.txt
index e013e5ba82..672981fdb7 100644
--- a/Documentation/dev-e2e-tests.txt
+++ b/Documentation/dev-e2e-tests.txt
@@ -1,28 +1,36 @@
-= Gerrit Code Review - End to end load tests
+= Gerrit Code Review - End to end tests
-This document provides a description of a Gerrit load test scenario implemented using the
-link:https://gatling.io/[Gatling] framework.
+This document provides descriptions of Gerrit end-to-end (`e2e`) test scenarios implemented using
+the link:https://gatling.io/[Gatling] framework.
Similar scenarios have been successfully used to compare performance of different Gerrit versions
-or study the Gerrit response under different load profiles.
+or study the Gerrit response under different load profiles. Although mostly for load, scenarios can
+either be for link:https://gatling.io/load-testing-continuous-integration/[load or functional]
+(e2e) testing purposes. Functional scenarios may then reuse this framework and Gatling's usability
+features such as its protocols (more below) and
+link:https://en.wikipedia.org/wiki/Domain-specific_language[DSL].
+
+That cross test-scope reusability applies to both Gerrit core scenarios and non-core ones, such as
+for Gerrit plugins or other potential extensions. End-to-end testing may then include scopes like
+feature integration, deployment, smoke (and load) testing. These load and functional test scopes
+should remain orthogonal to the unit and component (aka Gerrit `IT`-suffixed or `acceptance`) ones.
+The term `acceptance` though may still be coined by organizations to target e2e functional testing.
== What is Gatling?
-Gatling is a load testing tool which provides out of the box support for the HTTP protocol.
+Gatling is mostly a load testing tool which provides out of the box support for the HTTP protocol.
Documentation on how to write an HTTP load test can be found
-link:https://gatling.io/docs/current/http/http_protocol/[here].
-
-However, in the scenario we are proposing, we are leveraging the
-link:https://github.com/GerritForge/gatling-git[Gatling Git extension] to run tests at Git
-protocol level.
+link:https://gatling.io/docs/current/http/http_protocol/[here]. However, in the scenarios that were
+initially proposed, the link:https://github.com/GerritForge/gatling-git[Gatling Git extension] was
+leveraged to run tests at the Git protocol level.
Gatling is written in Scala, but the abstraction provided by the Gatling DSL makes the scenarios
implementation easy even without any Scala knowledge. The
link:https://gitenterprise.me/2019/12/20/stress-your-gerrit-with-gatling/[Stress your Gerrit with Gatling]
blog post has more introductory information.
-Examples of scenarios can be found in the `e2e-tests` directory. The files in that directory
-should be formatted using the mainstream
+Examples of scenarios can be found in the `e2e-tests` directory. The files in that directory should
+be formatted using the mainstream
link:https://plugins.jetbrains.com/plugin/1347-scala[Scala plugin for IntelliJ]. The latter is not
mandatory but preferred for `sbt` and Scala IDE purposes in this project.
@@ -85,10 +93,11 @@ ssh-keyscan -t rsa -p 29418 localhost > ~/.ssh/known_hosts
=== Input file
The `CloneUsingBothProtocols` scenario is fed with the data coming from the
-`src/test/resources/data/CloneUsingBothProtocols.json` file. Such a file contains the commands and
-repository used during the load test. That file currently looks like below. This scenario serves
-as a simple example with no actual load in it. It can be used to test or validate the local setup.
-More complex scenarios can be further developed, under the `com.google.gerrit.scenarios` package.
+`src/test/resources/data/com/google/gerrit/scenarios/CloneUsingBothProtocols.json` file. Such a
+file contains the commands and repository used during the e2e test. That file currently looks like
+below. This scenario serves as a simple example with no actual load in it. It can be used to test
+or validate the local setup. More complex scenarios can be further developed, under the
+`com.google.gerrit.scenarios` package.
----
[
@@ -150,6 +159,27 @@ link:http://logback.qos.ch/manual/configuration.html[configures] Gatling's loggi
docker run -it e2e-tests -s com.google.gerrit.scenarios.CloneUsingBothProtocols
----
+=== How to run non-core scenarios
+
+Locally adding non-core scenarios, for example from Gerrit plugins, is as simple as copying such
+files in. Copying is necessary over linking, unless running using Docker (above) is not required.
+Docker does not support links for files it has to copy over through the Dockerfile (here, the
+scenario files). Here is how to proceed for adding such external (e.g., plugin) scenario files in:
+
+----
+pushd e2e-tests/src/test/scala
+cp -r (or, ln -s) scalaPackageStructure .
+popd
+
+pushd e2e-tests/src/test/resources/data
+cp -r (or, ln -s) jsonFilesPackageStructure .
+popd
+----
+
+The destination folders above readily git-ignore every non-core scenario file added under them. If
+running using Docker, `e2e-tests/Dockerfile` may require another `COPY` line for the hereby added
+scenarios. Aforementioned `sbt` or `docker` commands can then be used to run the added tests.
+
GERRIT
------
Part of link:index.html[Gerrit Code Review]
diff --git a/Documentation/dev-readme.txt b/Documentation/dev-readme.txt
index 031a6a0a82..ad25147a95 100644
--- a/Documentation/dev-readme.txt
+++ b/Documentation/dev-readme.txt
@@ -63,8 +63,8 @@ see <<dev-bazel#tests,Running Unit Tests with Bazel>>.
[[e2e]]
=== End-to-end tests
-<<dev-e2e-tests#,This document>> describes how load test scenarios are
-implemented using link:https://gatling.io/[`Gatling`].
+<<dev-e2e-tests#,This document>> describes how `e2e` (load or functional) test
+scenarios are implemented using link:https://gatling.io/[`Gatling`].
== Local server
diff --git a/e2e-tests/src/test/resources/data/.gitignore b/e2e-tests/src/test/resources/data/.gitignore
new file mode 100644
index 0000000000..735445973f
--- /dev/null
+++ b/e2e-tests/src/test/resources/data/.gitignore
@@ -0,0 +1,4 @@
+*
+!*/
+!/com/google/gerrit/scenarios/*
+!/.gitignore
diff --git a/e2e-tests/src/test/resources/data/CloneUsingBothProtocols.json b/e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/CloneUsingBothProtocols.json
index 0335b2f0f1..0335b2f0f1 100644
--- a/e2e-tests/src/test/resources/data/CloneUsingBothProtocols.json
+++ b/e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/CloneUsingBothProtocols.json
diff --git a/e2e-tests/src/test/resources/data/CreateProject.json b/e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/CreateProject.json
index 2e54de55c2..2e54de55c2 100644
--- a/e2e-tests/src/test/resources/data/CreateProject.json
+++ b/e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/CreateProject.json
diff --git a/e2e-tests/src/test/resources/data/DeleteProject.json b/e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/DeleteProject.json
index 9312fb47a0..9312fb47a0 100644
--- a/e2e-tests/src/test/resources/data/DeleteProject.json
+++ b/e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/DeleteProject.json
diff --git a/e2e-tests/src/test/resources/data/ReplayRecordsFromFeeder.json b/e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/ReplayRecordsFromFeeder.json
index 86f9bf135b..86f9bf135b 100644
--- a/e2e-tests/src/test/resources/data/ReplayRecordsFromFeeder.json
+++ b/e2e-tests/src/test/resources/data/com/google/gerrit/scenarios/ReplayRecordsFromFeeder.json
diff --git a/e2e-tests/src/test/scala/.gitignore b/e2e-tests/src/test/scala/.gitignore
new file mode 100644
index 0000000000..735445973f
--- /dev/null
+++ b/e2e-tests/src/test/scala/.gitignore
@@ -0,0 +1,4 @@
+*
+!*/
+!/com/google/gerrit/scenarios/*
+!/.gitignore
diff --git a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/CloneUsingBothProtocols.scala b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/CloneUsingBothProtocols.scala
index 7b39e76c4e..19fbf1bb27 100644
--- a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/CloneUsingBothProtocols.scala
+++ b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/CloneUsingBothProtocols.scala
@@ -15,11 +15,13 @@
package com.google.gerrit.scenarios
import io.gatling.core.Predef._
+import io.gatling.core.feeder.FileBasedFeederBuilder
import io.gatling.core.structure.ScenarioBuilder
import scala.concurrent.duration._
class CloneUsingBothProtocols extends GitSimulation {
+ private val data: FileBasedFeederBuilder[Any]#F = jsonFile(resource).queue
private val test: ScenarioBuilder = scenario(name)
.feed(data)
diff --git a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/CreateProject.scala b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/CreateProject.scala
index 60602e06d2..58c8994d8c 100644
--- a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/CreateProject.scala
+++ b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/CreateProject.scala
@@ -15,9 +15,11 @@
package com.google.gerrit.scenarios
import io.gatling.core.Predef._
+import io.gatling.core.feeder.FileBasedFeederBuilder
import io.gatling.core.structure.ScenarioBuilder
class CreateProject extends GerritSimulation {
+ private val data: FileBasedFeederBuilder[Any]#F = jsonFile(resource).queue
val test: ScenarioBuilder = scenario(name)
.feed(data)
diff --git a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/DeleteProject.scala b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/DeleteProject.scala
index ba4879617a..4b723cb0b8 100644
--- a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/DeleteProject.scala
+++ b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/DeleteProject.scala
@@ -15,9 +15,11 @@
package com.google.gerrit.scenarios
import io.gatling.core.Predef._
+import io.gatling.core.feeder.FileBasedFeederBuilder
import io.gatling.core.structure.ScenarioBuilder
class DeleteProject extends GerritSimulation {
+ private val data: FileBasedFeederBuilder[Any]#F = jsonFile(resource).queue
val test: ScenarioBuilder = scenario(name)
.feed(data)
diff --git a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/GerritSimulation.scala b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/GerritSimulation.scala
index 3e1607bfcf..b628bc7924 100644
--- a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/GerritSimulation.scala
+++ b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/GerritSimulation.scala
@@ -16,7 +16,6 @@ package com.google.gerrit.scenarios
import com.github.barbasa.gatling.git.GatlingGitConfiguration
import io.gatling.core.Predef._
-import io.gatling.core.feeder.FileBasedFeederBuilder
import io.gatling.http.Predef.http
import io.gatling.http.protocol.HttpProtocolBuilder
import io.gatling.http.request.builder.HttpRequestBuilder
@@ -24,8 +23,9 @@ import io.gatling.http.request.builder.HttpRequestBuilder
class GerritSimulation extends Simulation {
implicit val conf: GatlingGitConfiguration = GatlingGitConfiguration()
+ private val path: String = this.getClass.getPackage.getName.replaceAllLiterally(".", "/")
protected val name: String = this.getClass.getSimpleName
- protected val data: FileBasedFeederBuilder[Any]#F = jsonFile(s"data/$name.json").circular
+ protected val resource: String = s"data/$path/$name.json"
protected val httpRequest: HttpRequestBuilder = http(name).post("${url}")
protected val httpProtocol: HttpProtocolBuilder = http.basicAuth(
diff --git a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/ReplayRecordsFromFeeder.scala b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/ReplayRecordsFromFeeder.scala
index b41e7123ee..32df1b5286 100644
--- a/e2e-tests/src/test/scala/com/google/gerrit/scenarios/ReplayRecordsFromFeeder.scala
+++ b/e2e-tests/src/test/scala/com/google/gerrit/scenarios/ReplayRecordsFromFeeder.scala
@@ -15,11 +15,13 @@
package com.google.gerrit.scenarios
import io.gatling.core.Predef._
+import io.gatling.core.feeder.FileBasedFeederBuilder
import io.gatling.core.structure.ScenarioBuilder
import scala.concurrent.duration._
class ReplayRecordsFromFeeder extends GitSimulation {
+ private val data: FileBasedFeederBuilder[Any]#F = jsonFile(resource).circular
private val test: ScenarioBuilder = scenario(name)
.repeat(10000) {