Marian Harbach | ebeb154 | 2019-12-13 10:42:46 +0100 | [diff] [blame] | 1 | :linkattrs: |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 2 | = Gerrit Code Review - End to end load tests |
| 3 | |
David Pursehouse | a9513c7 | 2020-01-30 15:13:44 +0900 | [diff] [blame] | 4 | This document provides a description of a Gerrit load test scenario implemented using the |
Marco Miller | 7c41df7 | 2020-01-30 15:58:32 -0500 | [diff] [blame^] | 5 | link:https://gatling.io/[Gatling,role=external,window=_blank] framework. |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 6 | |
Marco Miller | 9a9d42f | 2020-01-30 08:53:21 -0500 | [diff] [blame] | 7 | Similar scenarios have been successfully used to compare performance of different Gerrit versions |
| 8 | or study the Gerrit response under different load profiles. |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 9 | |
| 10 | == What is Gatling? |
| 11 | |
Marco Miller | 9a9d42f | 2020-01-30 08:53:21 -0500 | [diff] [blame] | 12 | Gatling is a load testing tool which provides out of the box support for the HTTP protocol. |
| 13 | Documentation on how to write an HTTP load test can be found |
Marco Miller | 7c41df7 | 2020-01-30 15:58:32 -0500 | [diff] [blame^] | 14 | link:https://gatling.io/docs/current/http/http_protocol/[here,role=external,window=_blank]. |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 15 | |
David Pursehouse | a9513c7 | 2020-01-30 15:13:44 +0900 | [diff] [blame] | 16 | However, in the scenario we are proposing, we are leveraging the |
Marco Miller | 7c41df7 | 2020-01-30 15:58:32 -0500 | [diff] [blame^] | 17 | link:https://github.com/GerritForge/gatling-git[Gatling Git extension,role=external,window=_blank] |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 18 | to run tests at Git protocol level. |
| 19 | |
Marco Miller | 9a9d42f | 2020-01-30 08:53:21 -0500 | [diff] [blame] | 20 | Gatling is written in Scala, but the abstraction provided by the Gatling DSL makes the scenarios |
| 21 | implementation easy even without any Scala knowledge. |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 22 | |
| 23 | Examples of scenarios can be found in the `e2e-tests` directory. |
| 24 | |
Marco Miller | 62c30e5 | 2020-01-30 15:45:02 -0500 | [diff] [blame] | 25 | == How to build the tests |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 26 | |
Marco Miller | 7c41df7 | 2020-01-30 15:58:32 -0500 | [diff] [blame^] | 27 | An link:https://www.scala-sbt.org/download.html[sbt-based installation,role=external,window=_blank] |
| 28 | of link:https://www.scala-lang.org/download/[Scala,role=external,window=_blank] is required. |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 29 | |
Marco Miller | 9a9d42f | 2020-01-30 08:53:21 -0500 | [diff] [blame] | 30 | The `scalaVersion` used by `sbt` once installed is defined in the `build.sbt` file. That specific |
| 31 | version of Scala is automatically used by `sbt` while building: |
Marco Miller | 0b6dd4b | 2020-01-29 17:24:17 -0500 | [diff] [blame] | 32 | |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 33 | ---- |
| 34 | sbt compile |
| 35 | ---- |
| 36 | |
Marco Miller | 0499d24 | 2020-01-30 11:44:27 -0500 | [diff] [blame] | 37 | The following warning, if present when executing `sbt` commands, can be removed by creating the |
Marco Miller | 7c41df7 | 2020-01-30 15:58:32 -0500 | [diff] [blame^] | 38 | link:https://www.scala-sbt.org/1.x/docs/Using-Sonatype.html#step+3%3A+Credentials[related credentials file,role=external,window=_blank] |
Marco Miller | 0499d24 | 2020-01-30 11:44:27 -0500 | [diff] [blame] | 39 | locally. Dummy values for `user` and `password` in that file can be used initially. Notice the |
| 40 | plural form for the file name, expected by the warning (below), compared to the one from that linked |
| 41 | example which is singular. |
| 42 | |
| 43 | ---- |
| 44 | [warn] Credentials file ~/.sbt/sonatype_credentials does not exist |
| 45 | ---- |
| 46 | |
Marco Miller | 62c30e5 | 2020-01-30 15:45:02 -0500 | [diff] [blame] | 47 | === How to build using Docker |
Marco Miller | 75a6046 | 2020-01-30 12:14:15 -0500 | [diff] [blame] | 48 | |
| 49 | ---- |
| 50 | docker build . -t e2e-tests |
| 51 | ---- |
| 52 | |
Marco Miller | 62c30e5 | 2020-01-30 15:45:02 -0500 | [diff] [blame] | 53 | == How to set-up |
| 54 | |
| 55 | === SSH keys |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 56 | |
Marco Miller | ccd7855 | 2020-01-29 17:36:08 -0500 | [diff] [blame] | 57 | If 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 Pursehouse | 8d9c8a8 | 2020-01-30 15:11:45 +0900 | [diff] [blame] | 59 | link:https://stackoverflow.com/questions/53134212/invalid-privatekey-when-using-jsch[otherwise,role=external,window=_blank]): |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 60 | |
| 61 | ---- |
| 62 | ssh-keygen -m PEM -t rsa -C "test@mail.com" -f /tmp/ssh-keys/id_rsa |
| 63 | ---- |
| 64 | |
Marco Miller | ccd7855 | 2020-01-29 17:36:08 -0500 | [diff] [blame] | 65 | *NOTE*: Don't forget to add the public keys for the testing user(s) to your git server. |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 66 | |
Marco Miller | 62c30e5 | 2020-01-30 15:45:02 -0500 | [diff] [blame] | 67 | === Input file |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 68 | |
Marco Miller | c00b018 | 2020-01-29 17:56:05 -0500 | [diff] [blame] | 69 | The `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 |
| 71 | during the load test. Example below: |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 72 | |
| 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 | |
| 86 | Valid commands are: |
Marco Miller | c00b018 | 2020-01-29 17:56:05 -0500 | [diff] [blame] | 87 | |
| 88 | * `fetch` |
| 89 | * `pull` |
| 90 | * `push` |
| 91 | * `clone` |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 92 | |
Marco Miller | 62c30e5 | 2020-01-30 15:45:02 -0500 | [diff] [blame] | 93 | == How to run tests |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 94 | |
| 95 | Run all tests: |
| 96 | ---- |
| 97 | sbt "gatling:test" |
| 98 | ---- |
| 99 | |
| 100 | Run a single test: |
| 101 | ---- |
| 102 | sbt "gatling:testOnly com.google.gerrit.scenarios.ReplayRecordsFromFeederScenario" |
| 103 | ---- |
| 104 | |
| 105 | Generate the last report: |
| 106 | ---- |
| 107 | sbt "gatling:lastReport" |
| 108 | ---- |
| 109 | |
Marco Miller | 62c30e5 | 2020-01-30 15:45:02 -0500 | [diff] [blame] | 110 | === How to run using Docker |
Marco Miller | 75a6046 | 2020-01-30 12:14:15 -0500 | [diff] [blame] | 111 | |
| 112 | ---- |
| 113 | docker run -it e2e-tests -s com.google.gerrit.scenarios.ReplayRecordsFromFeederScenario |
| 114 | ---- |
| 115 | |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 116 | GERRIT |
| 117 | ------ |
| 118 | Part of link:index.html[Gerrit Code Review] |
| 119 | |
| 120 | SEARCHBOX |
| 121 | --------- |
| 122 | |
| 123 | [scala]: |