Marian Harbach | ebeb154 | 2019-12-13 10:42:46 +0100 | [diff] [blame] | 1 | :linkattrs: |
Marco Miller | 0ca836a | 2020-03-20 11:38:29 -0400 | [diff] [blame] | 2 | = Gerrit Code Review - End to end tests |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 3 | |
Marco Miller | 0ca836a | 2020-03-20 11:38:29 -0400 | [diff] [blame] | 4 | This document provides descriptions of Gerrit end-to-end (`e2e`) test scenarios implemented using |
Marco Miller | faa512f | 2020-03-24 15:13:18 -0400 | [diff] [blame] | 5 | the 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 |
Marco Miller | 0ca836a | 2020-03-20 11:38:29 -0400 | [diff] [blame] | 8 | or study the Gerrit response under different load profiles. Although mostly for load, scenarios can |
David Pursehouse | 4655c8e | 2020-03-24 08:38:25 +0900 | [diff] [blame] | 9 | either be for link:https://gatling.io/load-testing-continuous-integration/[load or functional,role=external,window=_blank] |
Marco Miller | 0ca836a | 2020-03-20 11:38:29 -0400 | [diff] [blame] | 10 | (e2e) testing purposes. Functional scenarios may then reuse this framework and Gatling's usability |
| 11 | features such as its protocols (more below) and |
David Pursehouse | 4655c8e | 2020-03-24 08:38:25 +0900 | [diff] [blame] | 12 | link:https://en.wikipedia.org/wiki/Domain-specific_language[DSL,role=external,window=_blank]. |
Marco Miller | 0ca836a | 2020-03-20 11:38:29 -0400 | [diff] [blame] | 13 | |
| 14 | That cross test-scope reusability applies to both Gerrit core scenarios and non-core ones, such as |
| 15 | for Gerrit plugins or other potential extensions. End-to-end testing may then include scopes like |
| 16 | feature integration, deployment, smoke (and load) testing. These load and functional test scopes |
| 17 | should remain orthogonal to the unit and component (aka Gerrit `IT`-suffixed or `acceptance`) ones. |
| 18 | The term `acceptance` though may still be coined by organizations to target e2e functional testing. |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 19 | |
| 20 | == What is Gatling? |
| 21 | |
Marco Miller | 0ca836a | 2020-03-20 11:38:29 -0400 | [diff] [blame] | 22 | Gatling is mostly a load testing tool which provides out of the box support for the HTTP protocol. |
Marco Miller | 9a9d42f | 2020-01-30 08:53:21 -0500 | [diff] [blame] | 23 | Documentation on how to write an HTTP load test can be found |
Marco Miller | 7c41df7 | 2020-01-30 15:58:32 -0500 | [diff] [blame] | 24 | link:https://gatling.io/docs/current/http/http_protocol/[here,role=external,window=_blank]. |
David Pursehouse | 4655c8e | 2020-03-24 08:38:25 +0900 | [diff] [blame] | 25 | However, in the scenarios that were initially proposed, the |
| 26 | link:https://github.com/GerritForge/gatling-git[Gatling Git extension,role=external,window=_blank] was |
Marco Miller | 0ca836a | 2020-03-20 11:38:29 -0400 | [diff] [blame] | 27 | leveraged to run tests at the Git protocol level. |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 28 | |
Marco Miller | 9a9d42f | 2020-01-30 08:53:21 -0500 | [diff] [blame] | 29 | Gatling is written in Scala, but the abstraction provided by the Gatling DSL makes the scenarios |
Marco Miller | 6c2c5eb | 2020-08-27 14:11:36 -0400 | [diff] [blame] | 30 | implementation easy even without any Scala knowledge. The online `End-to-end tests` |
Marco Miller | d183987 | 2020-09-03 17:46:24 -0400 | [diff] [blame] | 31 | link:https://www.gerritcodereview.com/presentations.html#list-of-presentations[presentation,role=external,window=_blank] |
| 32 | links posted on the homepage have more introductory information. |
Fabio Ponciroli | e224456 | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 33 | |
Hamza Kaced | 2e37e27 | 2020-07-30 23:18:39 -0400 | [diff] [blame] | 34 | == IDE: IntelliJ |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 35 | |
Marco Miller | 0ca836a | 2020-03-20 11:38:29 -0400 | [diff] [blame] | 36 | Examples of scenarios can be found in the `e2e-tests` directory. The files in that directory should |
| 37 | be formatted using the mainstream |
David Pursehouse | 9b02057 | 2020-02-03 08:33:49 +0900 | [diff] [blame] | 38 | link:https://plugins.jetbrains.com/plugin/1347-scala[Scala plugin for IntelliJ,role=external,window=_blank]. |
| 39 | The latter is not mandatory but preferred for `sbt` and Scala IDE purposes in this project. |
Marco Miller | d183987 | 2020-09-03 17:46:24 -0400 | [diff] [blame] | 40 | So, Eclipse can also be used alongside as a development IDE; this is described below. |
Hamza Kaced | 2e37e27 | 2020-07-30 23:18:39 -0400 | [diff] [blame] | 41 | |
| 42 | === Eclipse |
| 43 | |
Marco Miller | d183987 | 2020-09-03 17:46:24 -0400 | [diff] [blame] | 44 | 1. Install the link:http://scala-ide.org/docs/user/gettingstarted.html[Scala plugin for Eclipse,role=external,window=_blank]. |
Marco Miller | 4f89844 | 2020-09-29 14:18:51 -0400 | [diff] [blame] | 45 | 2. Run `sbt eclipse` from the `e2e-tests` root directory. |
| 46 | 3. Import the resulting `e2e-tests` eclipse file inside the Gerrit project, in Eclipse. |
| 47 | 4. You should see errors in Eclipse telling you there are missing packages. |
| 48 | 5. This is due to the sbt-eclipse plugin not properly linking the Gerrit Gatling e2e tests with |
Hamza Kaced | 2e37e27 | 2020-07-30 23:18:39 -0400 | [diff] [blame] | 49 | Gatling Git plugin. |
Marco Miller | 4f89844 | 2020-09-29 14:18:51 -0400 | [diff] [blame] | 50 | 6. You then have to right-click on the root directory and choose the build path->link source option. |
| 51 | 7. Then you have to browse to `.sbt/1.0/staging`, find the folder where gatling-git is contained, |
Hamza Kaced | 2e37e27 | 2020-07-30 23:18:39 -0400 | [diff] [blame] | 52 | and choose that. |
Marco Miller | 4f89844 | 2020-09-29 14:18:51 -0400 | [diff] [blame] | 53 | 8. That last step should link the gatling-git plugin to the project; e2e tests should not show |
Hamza Kaced | 2e37e27 | 2020-07-30 23:18:39 -0400 | [diff] [blame] | 54 | errors anymore. |
Marco Miller | 4f89844 | 2020-09-29 14:18:51 -0400 | [diff] [blame] | 55 | 9. You may get errors in the gatling-git directory; these should not affect Gerrit Gatling |
Hamza Kaced | 2e37e27 | 2020-07-30 23:18:39 -0400 | [diff] [blame] | 56 | development and can be ignored. |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 57 | |
Marco Miller | 62c30e5 | 2020-01-30 15:45:02 -0500 | [diff] [blame] | 58 | == How to build the tests |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 59 | |
Marco Miller | 7c41df7 | 2020-01-30 15:58:32 -0500 | [diff] [blame] | 60 | An link:https://www.scala-sbt.org/download.html[sbt-based installation,role=external,window=_blank] |
| 61 | 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] | 62 | |
Marco Miller | 9a9d42f | 2020-01-30 08:53:21 -0500 | [diff] [blame] | 63 | The `scalaVersion` used by `sbt` once installed is defined in the `build.sbt` file. That specific |
| 64 | version of Scala is automatically used by `sbt` while building: |
Marco Miller | 0b6dd4b | 2020-01-29 17:24:17 -0500 | [diff] [blame] | 65 | |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 66 | ---- |
| 67 | sbt compile |
| 68 | ---- |
| 69 | |
Marco Miller | 0499d24 | 2020-01-30 11:44:27 -0500 | [diff] [blame] | 70 | 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] | 71 | 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 | d890da5 | 2020-01-31 11:08:42 -0500 | [diff] [blame] | 72 | locally. Dummy values for `user` and `password` in that file can be used initially. |
Marco Miller | 0499d24 | 2020-01-30 11:44:27 -0500 | [diff] [blame] | 73 | |
| 74 | ---- |
| 75 | [warn] Credentials file ~/.sbt/sonatype_credentials does not exist |
| 76 | ---- |
| 77 | |
Marco Miller | b7c5dd0 | 2020-03-27 17:27:36 -0400 | [diff] [blame] | 78 | The other warning below can be safely ignored, so far. Running the proposed `sbt evicted` command |
| 79 | should only list `scala-java8-compat_2.12` as `[warn]`. The other dependency conflicts should show |
| 80 | as `[info]`. All of the listed conflicts get usually resolved seamlessly or so. |
| 81 | |
| 82 | ---- |
| 83 | [warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings. |
| 84 | ---- |
| 85 | |
Marco Miller | 51820c7 | 2020-01-30 17:21:18 -0500 | [diff] [blame] | 86 | Every `sbt` command can include an optional log level |
Marco Miller | d421f80 | 2020-01-30 18:19:39 -0500 | [diff] [blame] | 87 | link:https://www.scala-sbt.org/1.x/docs/Howto-Logging.html#Change+the+logging+level+globally[argument,role=external,window=_blank]. |
Marco Miller | 51820c7 | 2020-01-30 17:21:18 -0500 | [diff] [blame] | 88 | Below, `[info]` logs are no longer shown: |
| 89 | |
| 90 | ---- |
| 91 | sbt --warn compile |
| 92 | ---- |
| 93 | |
Marco Miller | 62c30e5 | 2020-01-30 15:45:02 -0500 | [diff] [blame] | 94 | === How to build using Docker |
Marco Miller | 75a6046 | 2020-01-30 12:14:15 -0500 | [diff] [blame] | 95 | |
| 96 | ---- |
| 97 | docker build . -t e2e-tests |
| 98 | ---- |
| 99 | |
Marco Miller | 62c30e5 | 2020-01-30 15:45:02 -0500 | [diff] [blame] | 100 | == How to set-up |
| 101 | |
| 102 | === SSH keys |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 103 | |
Marco Miller | ccd7855 | 2020-01-29 17:36:08 -0500 | [diff] [blame] | 104 | If you are running SSH commands, the private keys of the users used for testing need to go in |
David Ostrovsky | 0cba3e3 | 2021-11-29 20:05:13 +0100 | [diff] [blame] | 105 | `/tmp/ssh-keys`. The keys need to be generated this way and won't be validated. |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 106 | |
| 107 | ---- |
Marco Miller | f00947e | 2020-01-31 14:35:58 -0500 | [diff] [blame] | 108 | mkdir /tmp/ssh-keys |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 109 | ssh-keygen -m PEM -t rsa -C "test@mail.com" -f /tmp/ssh-keys/id_rsa |
| 110 | ---- |
| 111 | |
Marco Miller | f00947e | 2020-01-31 14:35:58 -0500 | [diff] [blame] | 112 | The public key in `/tmp/ssh-keys/id_rsa.pub` has to be added to the test user(s) `SSH Keys` in |
| 113 | Gerrit. Now, the host from which the latter runs may need public key scanning to become known. |
| 114 | This applies to the local user that runs the forthcoming `sbt` testing commands. An example |
| 115 | assuming `localhost` follows: |
| 116 | |
| 117 | ---- |
| 118 | ssh-keyscan -t rsa -p 29418 localhost > ~/.ssh/known_hosts |
| 119 | ---- |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 120 | |
Marco Miller | 62c30e5 | 2020-01-30 15:45:02 -0500 | [diff] [blame] | 121 | === Input file |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 122 | |
Marco Miller | 3f46efd | 2020-02-01 11:06:11 -0500 | [diff] [blame] | 123 | The `CloneUsingBothProtocols` scenario is fed with the data coming from the |
Marco Miller | 28c26cd | 2020-03-19 16:41:25 -0400 | [diff] [blame] | 124 | `src/test/resources/data/com/google/gerrit/scenarios/CloneUsingBothProtocols.json` file. Such a |
Marco Miller | 0ca836a | 2020-03-20 11:38:29 -0400 | [diff] [blame] | 125 | file contains the commands and repository used during the e2e test. That file currently looks like |
Marco Miller | 28c26cd | 2020-03-19 16:41:25 -0400 | [diff] [blame] | 126 | below. This scenario serves as a simple example with no actual load in it. It can be used to test |
| 127 | or validate the local setup. More complex scenarios can be further developed, under the |
Marco Miller | 2536cee | 2020-09-17 16:53:41 -0400 | [diff] [blame] | 128 | `com.google.gerrit.scenarios` package. The uppercase keywords are set through |
Marco Miller | 1b10068 | 2020-09-21 11:30:31 -0400 | [diff] [blame] | 129 | link:#_environment_properties[environment properties,role=external,window=_blank]. |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 130 | |
| 131 | ---- |
| 132 | [ |
| 133 | { |
Marco Miller | b39b794 | 2020-04-03 15:21:22 -0400 | [diff] [blame] | 134 | "url": "ssh://admin@HOSTNAME:SSH_PORT/_PROJECT", |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 135 | "cmd": "clone" |
| 136 | }, |
| 137 | { |
Marco Miller | a543a93 | 2020-07-15 13:45:31 -0400 | [diff] [blame] | 138 | "url": "HTTP_SCHEME://HOSTNAME:HTTP_PORT/_PROJECT", |
Marco Miller | 3f46efd | 2020-02-01 11:06:11 -0500 | [diff] [blame] | 139 | "cmd": "clone" |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 140 | } |
| 141 | ] |
| 142 | ---- |
| 143 | |
| 144 | Valid commands are: |
Marco Miller | c00b018 | 2020-01-29 17:56:05 -0500 | [diff] [blame] | 145 | |
Marco Miller | cc4810b | 2020-02-13 13:06:41 -0500 | [diff] [blame] | 146 | * `clone` |
Marco Miller | c00b018 | 2020-01-29 17:56:05 -0500 | [diff] [blame] | 147 | * `fetch` |
| 148 | * `pull` |
| 149 | * `push` |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 150 | |
Marco Miller | f5eb7e4 | 2020-03-12 15:05:26 -0400 | [diff] [blame] | 151 | === Project and HTTP credentials |
| 152 | |
Marco Miller | cc4810b | 2020-02-13 13:06:41 -0500 | [diff] [blame] | 153 | The example above assumes that the `loadtest-repo` project exists in the Gerrit under test. The |
Marco Miller | f5eb7e4 | 2020-03-12 15:05:26 -0400 | [diff] [blame] | 154 | `CloneUsingBothProtocols` scenario already includes creating that project and deleting it once done |
| 155 | with it. That scenario class can be used as an example of how a scenario can compose itself |
| 156 | alongside other scenarios (here, `CreateProject` and `DeleteProject`). |
| 157 | |
| 158 | The `HTTP Credentials` or password obtained from test user's `Settings` (in Gerrit) may be |
| 159 | required, in `src/test/resources/application.conf`, depending on the above commands used. That |
| 160 | file's `http` section shows which shell environment variables can be used to set those credentials. |
| 161 | |
| 162 | Executing the `CloneUsingBothProtocols` scenario, as is, does require setting the http credentials. |
| 163 | That is because of the aforementioned create/delete project (http) scenarios composed within it. |
Marco Miller | d92fae8 | 2020-01-31 14:45:28 -0500 | [diff] [blame] | 164 | |
Marco Miller | 6ba2376 | 2020-04-02 14:07:29 -0400 | [diff] [blame] | 165 | === Environment properties |
| 166 | |
| 167 | The `JAVA_OPTS` environment variable |
Marco Miller | 7472026 | 2020-04-28 16:51:43 -0400 | [diff] [blame] | 168 | link:https://gatling.io/docs/current/cookbook/passing_parameters[can optionally be used,role=external,window=_blank] |
| 169 | to define non-default values for keys found in scenario `json` data files. That variable can |
| 170 | currently be set with either one or many of these supported properties, from the core framework: |
Marco Miller | 6ba2376 | 2020-04-02 14:07:29 -0400 | [diff] [blame] | 171 | |
| 172 | * `-Dcom.google.gerrit.scenarios.hostname=localhost` |
| 173 | * `-Dcom.google.gerrit.scenarios.ssh_port=29418` |
| 174 | * `-Dcom.google.gerrit.scenarios.http_port=8080` |
Marco Miller | a543a93 | 2020-07-15 13:45:31 -0400 | [diff] [blame] | 175 | * `-Dcom.google.gerrit.scenarios.http_scheme=http` |
David Åkerman | 2f9757f | 2022-02-16 10:25:37 +0100 | [diff] [blame] | 176 | * `-Dcom.google.gerrit.scenarios.username=admin` |
David Åkerman | 6e9dc53 | 2022-02-16 10:48:31 +0100 | [diff] [blame] | 177 | * `-Dcom.google.gerrit.scenarios.replica_hostname=localhost` |
David Åkerman | 9aac9a8 | 2022-02-16 11:57:42 +0100 | [diff] [blame] | 178 | * `-Dcom.google.gerrit.scenarios.project_prefix=` |
Marco Miller | 6ba2376 | 2020-04-02 14:07:29 -0400 | [diff] [blame] | 179 | |
| 180 | Above, the properties can be set with values matching specific deployment topologies under test. |
Marco Miller | 2536cee | 2020-09-17 16:53:41 -0400 | [diff] [blame] | 181 | The name of the property corresponds to the uppercase keyword found in the json file. For example, |
Marco Miller | 1b10068 | 2020-09-21 11:30:31 -0400 | [diff] [blame] | 182 | `hostname` above will set the value of `HOSTNAME` in the |
| 183 | link:#_input_file[aforementioned example,role=external,window=_blank]. |
Marco Miller | 16406aa | 2020-04-03 11:26:45 -0400 | [diff] [blame] | 184 | |
Marco Miller | a543a93 | 2020-07-15 13:45:31 -0400 | [diff] [blame] | 185 | The example values shown above are the currently coded default ones. For example, the `http` scheme |
Marco Miller | cdb2927 | 2020-09-17 17:15:36 -0400 | [diff] [blame] | 186 | above could be replaced with `https`. The framework may support differing or more properties over time. |
| 187 | |
| 188 | ==== Replication delay |
| 189 | |
| 190 | The `replication_delay` property allows test scenario steps to wait for that many seconds, prior to |
| 191 | expecting a done replication. Its default is `15` seconds and can be set using another value: |
| 192 | |
| 193 | * `-Dcom.google.gerrit.scenarios.replication_delay=15` |
| 194 | |
| 195 | There is a short time buffer added to this property. Now, the replication starts after replication |
| 196 | plugin's own `replicationDelay`, in seconds, and typically takes some more seconds to complete. |
| 197 | That whole replication time depends on the system under test. Therefore, this property here should |
| 198 | be set to a value high enough, so that the test checks for a done replication at the right time. |
Marco Miller | 16406aa | 2020-04-03 11:26:45 -0400 | [diff] [blame] | 199 | |
David Åkerman | 4e63537 | 2022-02-16 11:28:34 +0100 | [diff] [blame] | 200 | ==== Context path |
| 201 | |
| 202 | The `context_path` property allows test scenarios to send Gerrit REST requests to Gerrit instances |
| 203 | that use a context path in the URL. Its default is no context path and can be set using another value: |
| 204 | |
| 205 | * `-Dcom.google.gerrit.scenarios.context_path=/context` |
| 206 | |
David Åkerman | 4dae9de | 2022-04-20 11:19:00 +0200 | [diff] [blame] | 207 | ==== Authentication |
| 208 | |
| 209 | The `authenticated` property allows test scenarios to use authenticated HTTP clones. Its default is |
| 210 | no authentication: |
| 211 | |
| 212 | * `-Dcom.google.gerrit.scenarios.authenticated=false` |
| 213 | |
Marco Miller | 2536cee | 2020-09-17 16:53:41 -0400 | [diff] [blame] | 214 | ==== Automatic properties |
| 215 | |
Marco Miller | 1b10068 | 2020-09-21 11:30:31 -0400 | [diff] [blame] | 216 | The link:#_input_file[example keywords,role=external,window=_blank] also include `_PROJECT`, |
| 217 | prefixed with an underscore, which means that its value gets automatically generated by the |
| 218 | scenario. Any property setting for it is therefore not applicable. Its usage differs from the |
| 219 | non-prefixed `PROJECT` keyword, in that sense. Using the latter instead in json files requires |
| 220 | setting this `JAVA_OPTS` property: |
Marco Miller | 2536cee | 2020-09-17 16:53:41 -0400 | [diff] [blame] | 221 | |
| 222 | * `-Dcom.google.gerrit.scenarios.project=myOwnTestRepoProjectName` |
| 223 | |
| 224 | Other automatic keys may be used and implemented, always prefixed with an underscore that tells so. |
Marco Miller | 2f6d90d | 2020-09-17 16:08:09 -0400 | [diff] [blame] | 225 | |
| 226 | ==== Plugin scenarios |
| 227 | |
| 228 | Plugin or otherwise non-core scenarios can also use such properties. The core java package |
Marco Miller | 16406aa | 2020-04-03 11:26:45 -0400 | [diff] [blame] | 229 | `com.google.gerrit.scenarios` from the example above has to be replaced with the one under which |
| 230 | those scenario classes are. Such extending scenarios can also add extension-specific properties. |
Marco Miller | c044885 | 2020-09-04 12:51:36 -0400 | [diff] [blame] | 231 | Examples of this can be found in these Gerrit plugins test code: |
| 232 | |
Marco Miller | 95fc71f | 2020-09-17 17:59:06 -0400 | [diff] [blame] | 233 | * `link:https://gerrit.googlesource.com/plugins/gc-conductor[gc-conductor,role=external,window=_blank]` |
Jacek Centkowski | 839fab1 | 2020-09-11 17:05:18 +0200 | [diff] [blame] | 234 | * `link:https://gerrit.googlesource.com/plugins/high-availability[high-availability,role=external,window=_blank]` |
| 235 | * `link:https://gerrit.googlesource.com/plugins/multi-site[multi-site,role=external,window=_blank]` |
| 236 | * `link:https://gerrit.googlesource.com/plugins/rename-project[rename-project,role=external,window=_blank]` |
Marco Miller | 6ba2376 | 2020-04-02 14:07:29 -0400 | [diff] [blame] | 237 | |
Marco Miller | e9859dc | 2020-09-17 16:04:08 -0400 | [diff] [blame] | 238 | ==== Power factor |
Fabio Ponciroli | e224456 | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 239 | |
Marco Miller | 0b2c50a | 2020-04-17 14:04:08 -0400 | [diff] [blame] | 240 | The following core property can be optionally set depending on the runtime environment. The test |
| 241 | environments used as reference for scenarios development assume its default value, `1.0`. For |
| 242 | slower or more complex execution environments, the value can be increased this way for example: |
| 243 | |
| 244 | * `-Dcom.google.gerrit.scenarios.power_factor=1.5` |
| 245 | |
| 246 | This will make the scenario steps take half more time to expect proper completion. A value smaller |
| 247 | than the default, say `0.8`, will make scenarios wait somewhat less than how they were developed. |
| 248 | Scenario development is often done using locally running Gerrit systems under test, which are |
| 249 | sometimes dockerized. |
| 250 | |
Nguyen Tuan Khang Phan | 58117f4 | 2021-01-14 15:22:42 -0500 | [diff] [blame] | 251 | ==== Number of users |
| 252 | |
| 253 | The `number_of_users` property can be used to scale scenario steps to run with the specified number |
| 254 | of concurrent users. The value of this property remains `1` by default. For example, this sets the |
| 255 | number of concurrent users to 10: |
| 256 | |
| 257 | * `-Dcom.google.gerrit.scenarios.number_of_users=10` |
| 258 | |
| 259 | This will make scenarios that support the `number_of_users` property to inject that many users |
| 260 | concurrently for load testing. |
| 261 | |
Marco Miller | 62c30e5 | 2020-01-30 15:45:02 -0500 | [diff] [blame] | 262 | == How to run tests |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 263 | |
| 264 | Run all tests: |
| 265 | ---- |
| 266 | sbt "gatling:test" |
| 267 | ---- |
| 268 | |
| 269 | Run a single test: |
| 270 | ---- |
Marco Miller | 3f46efd | 2020-02-01 11:06:11 -0500 | [diff] [blame] | 271 | sbt "gatling:testOnly com.google.gerrit.scenarios.CloneUsingBothProtocols" |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 272 | ---- |
| 273 | |
| 274 | Generate the last report: |
| 275 | ---- |
| 276 | sbt "gatling:lastReport" |
| 277 | ---- |
| 278 | |
Marco Miller | 51820c7 | 2020-01-30 17:21:18 -0500 | [diff] [blame] | 279 | The `src/test/resources/logback.xml` file |
Marco Miller | d421f80 | 2020-01-30 18:19:39 -0500 | [diff] [blame] | 280 | link:http://logback.qos.ch/manual/configuration.html[configures,role=external,window=_blank] |
Marco Miller | 7472026 | 2020-04-28 16:51:43 -0400 | [diff] [blame] | 281 | Gatling's logging level. To quickly enable |
| 282 | link:https://gatling.io/docs/current/general/debugging#logback[detailed logging,role=external,window=_blank] |
| 283 | of `http` requests and responses, the `root level` can be set to `trace` in that file. |
Marco Miller | 51820c7 | 2020-01-30 17:21:18 -0500 | [diff] [blame] | 284 | |
Marco Miller | 62c30e5 | 2020-01-30 15:45:02 -0500 | [diff] [blame] | 285 | === How to run using Docker |
Marco Miller | 75a6046 | 2020-01-30 12:14:15 -0500 | [diff] [blame] | 286 | |
| 287 | ---- |
Marco Miller | 3f46efd | 2020-02-01 11:06:11 -0500 | [diff] [blame] | 288 | docker run -it e2e-tests -s com.google.gerrit.scenarios.CloneUsingBothProtocols |
Marco Miller | 75a6046 | 2020-01-30 12:14:15 -0500 | [diff] [blame] | 289 | ---- |
| 290 | |
Marco Miller | 61ccca5 | 2020-03-18 09:59:59 -0400 | [diff] [blame] | 291 | === How to run non-core scenarios |
| 292 | |
| 293 | Locally adding non-core scenarios, for example from Gerrit plugins, is as simple as copying such |
| 294 | files in. Copying is necessary over linking, unless running using Docker (above) is not required. |
| 295 | Docker does not support links for files it has to copy over through the Dockerfile (here, the |
| 296 | scenario files). Here is how to proceed for adding such external (e.g., plugin) scenario files in: |
| 297 | |
| 298 | ---- |
| 299 | pushd e2e-tests/src/test/scala |
| 300 | cp -r (or, ln -s) scalaPackageStructure . |
| 301 | popd |
| 302 | |
| 303 | pushd e2e-tests/src/test/resources/data |
| 304 | cp -r (or, ln -s) jsonFilesPackageStructure . |
| 305 | popd |
| 306 | ---- |
| 307 | |
| 308 | The destination folders above readily git-ignore every non-core scenario file added under them. If |
| 309 | running using Docker, `e2e-tests/Dockerfile` may require another `COPY` line for the hereby added |
| 310 | scenarios. Aforementioned `sbt` or `docker` commands can then be used to run the added tests. |
| 311 | |
Fabio Ponciroli | 386aebb | 2019-05-21 20:30:41 -0700 | [diff] [blame] | 312 | GERRIT |
| 313 | ------ |
| 314 | Part of link:index.html[Gerrit Code Review] |
| 315 | |
| 316 | SEARCHBOX |
| 317 | --------- |
| 318 | |
| 319 | [scala]: |