blob: 92c069dac06a2520c76b4ff1ddfa11f7214e8b49 [file] [log] [blame]
Marian Harbachebeb1542019-12-13 10:42:46 +01001:linkattrs:
Fabio Ponciroli386aebb2019-05-21 20:30:41 -07002= Gerrit Code Review - End to end load tests
3
David Pursehousea9513c72020-01-30 15:13:44 +09004This document provides a description of a Gerrit load test scenario implemented using the
Marco Miller7c41df72020-01-30 15:58:32 -05005link:https://gatling.io/[Gatling,role=external,window=_blank] framework.
Fabio Ponciroli386aebb2019-05-21 20:30:41 -07006
Marco Miller9a9d42f2020-01-30 08:53:21 -05007Similar scenarios have been successfully used to compare performance of different Gerrit versions
8or study the Gerrit response under different load profiles.
Fabio Ponciroli386aebb2019-05-21 20:30:41 -07009
10== What is Gatling?
11
Marco Miller9a9d42f2020-01-30 08:53:21 -050012Gatling is a load testing tool which provides out of the box support for the HTTP protocol.
13Documentation on how to write an HTTP load test can be found
Marco Miller7c41df72020-01-30 15:58:32 -050014link:https://gatling.io/docs/current/http/http_protocol/[here,role=external,window=_blank].
Fabio Ponciroli386aebb2019-05-21 20:30:41 -070015
David Pursehousea9513c72020-01-30 15:13:44 +090016However, in the scenario we are proposing, we are leveraging the
Marco Miller7c41df72020-01-30 15:58:32 -050017link:https://github.com/GerritForge/gatling-git[Gatling Git extension,role=external,window=_blank]
Fabio Ponciroli386aebb2019-05-21 20:30:41 -070018to run tests at Git protocol level.
19
Marco Miller9a9d42f2020-01-30 08:53:21 -050020Gatling is written in Scala, but the abstraction provided by the Gatling DSL makes the scenarios
21implementation easy even without any Scala knowledge.
Fabio Ponciroli386aebb2019-05-21 20:30:41 -070022
23Examples of scenarios can be found in the `e2e-tests` directory.
24
Marco Miller62c30e52020-01-30 15:45:02 -050025== How to build the tests
Fabio Ponciroli386aebb2019-05-21 20:30:41 -070026
Marco Miller7c41df72020-01-30 15:58:32 -050027An link:https://www.scala-sbt.org/download.html[sbt-based installation,role=external,window=_blank]
28of link:https://www.scala-lang.org/download/[Scala,role=external,window=_blank] is required.
Fabio Ponciroli386aebb2019-05-21 20:30:41 -070029
Marco Miller9a9d42f2020-01-30 08:53:21 -050030The `scalaVersion` used by `sbt` once installed is defined in the `build.sbt` file. That specific
31version of Scala is automatically used by `sbt` while building:
Marco Miller0b6dd4b2020-01-29 17:24:17 -050032
Fabio Ponciroli386aebb2019-05-21 20:30:41 -070033----
34sbt compile
35----
36
Marco Miller0499d242020-01-30 11:44:27 -050037The following warning, if present when executing `sbt` commands, can be removed by creating the
Marco Miller7c41df72020-01-30 15:58:32 -050038link:https://www.scala-sbt.org/1.x/docs/Using-Sonatype.html#step+3%3A+Credentials[related credentials file,role=external,window=_blank]
Marco Miller0499d242020-01-30 11:44:27 -050039locally. Dummy values for `user` and `password` in that file can be used initially. Notice the
40plural form for the file name, expected by the warning (below), compared to the one from that linked
41example which is singular.
42
43----
44[warn] Credentials file ~/.sbt/sonatype_credentials does not exist
45----
46
Marco Miller62c30e52020-01-30 15:45:02 -050047=== How to build using Docker
Marco Miller75a60462020-01-30 12:14:15 -050048
49----
50docker build . -t e2e-tests
51----
52
Marco Miller62c30e52020-01-30 15:45:02 -050053== How to set-up
54
55=== SSH keys
Fabio Ponciroli386aebb2019-05-21 20:30:41 -070056
Marco Millerccd78552020-01-29 17:36:08 -050057If you are running SSH commands, the private keys of the users used for testing need to go in
58`/tmp/ssh-keys`. The keys need to be generated this way (JSch won't validate them
David Pursehouse8d9c8a82020-01-30 15:11:45 +090059link:https://stackoverflow.com/questions/53134212/invalid-privatekey-when-using-jsch[otherwise,role=external,window=_blank]):
Fabio Ponciroli386aebb2019-05-21 20:30:41 -070060
61----
62ssh-keygen -m PEM -t rsa -C "test@mail.com" -f /tmp/ssh-keys/id_rsa
63----
64
Marco Millerccd78552020-01-29 17:36:08 -050065*NOTE*: Don't forget to add the public keys for the testing user(s) to your git server.
Fabio Ponciroli386aebb2019-05-21 20:30:41 -070066
Marco Miller62c30e52020-01-30 15:45:02 -050067=== Input file
Fabio Ponciroli386aebb2019-05-21 20:30:41 -070068
Marco Millerc00b0182020-01-29 17:56:05 -050069The `ReplayRecordsFromFeederScenario` is fed with the data coming from the
70`src/test/resources/data/requests.json` file. Such a file contains the commands and repo used
71during the load test. Example below:
Fabio Ponciroli386aebb2019-05-21 20:30:41 -070072
73----
74[
75 {
76 "url": "ssh://admin@localhost:29418/loadtest-repo.git",
77 "cmd": "clone"
78 },
79 {
80 "url": "http://localhost:8080/loadtest-repo.git",
81 "cmd": "fetch"
82 }
83]
84----
85
86Valid commands are:
Marco Millerc00b0182020-01-29 17:56:05 -050087
88* `fetch`
89* `pull`
90* `push`
91* `clone`
Fabio Ponciroli386aebb2019-05-21 20:30:41 -070092
Marco Miller62c30e52020-01-30 15:45:02 -050093== How to run tests
Fabio Ponciroli386aebb2019-05-21 20:30:41 -070094
95Run all tests:
96----
97sbt "gatling:test"
98----
99
100Run a single test:
101----
102sbt "gatling:testOnly com.google.gerrit.scenarios.ReplayRecordsFromFeederScenario"
103----
104
105Generate the last report:
106----
107sbt "gatling:lastReport"
108----
109
Marco Miller62c30e52020-01-30 15:45:02 -0500110=== How to run using Docker
Marco Miller75a60462020-01-30 12:14:15 -0500111
112----
113docker run -it e2e-tests -s com.google.gerrit.scenarios.ReplayRecordsFromFeederScenario
114----
115
Fabio Ponciroli386aebb2019-05-21 20:30:41 -0700116GERRIT
117------
118Part of link:index.html[Gerrit Code Review]
119
120SEARCHBOX
121---------
122
123[scala]: