Merge branch 'stable-3.0' into stable-3.1
* stable-3.0:
  e2e-tests: Add JAVA_OPTS support to the framework
  ElasticV{6,7}QueryChangesTest: Add comment about issue 10120
Change-Id: I332481174cb4f8d0e5255fc08ab49b5452eda029
			
			
This commit is contained in:
		| @@ -105,16 +105,16 @@ The `CloneUsingBothProtocols` scenario is fed with the data coming from the | ||||
| 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. | ||||
| `com.google.gerrit.scenarios` package. The uppercase keywords are discussed further below. | ||||
|  | ||||
| ---- | ||||
| [ | ||||
|   { | ||||
|     "url": "ssh://admin@localhost:29418/loadtest-repo", | ||||
|     "url": "ssh://admin@HOSTNAME:SSH_PORT/loadtest-repo", | ||||
|     "cmd": "clone" | ||||
|   }, | ||||
|   { | ||||
|     "url": "http://localhost:8080/loadtest-repo", | ||||
|     "url": "http://HOSTNAME:HTTP_PORT/loadtest-repo", | ||||
|     "cmd": "clone" | ||||
|   } | ||||
| ] | ||||
| @@ -141,6 +141,21 @@ file's `http` section shows which shell environment variables can be used to set | ||||
| Executing the `CloneUsingBothProtocols` scenario, as is, does require setting the http credentials. | ||||
| That is because of the aforementioned create/delete project (http) scenarios composed within it. | ||||
|  | ||||
| === Environment properties | ||||
|  | ||||
| The `JAVA_OPTS` environment variable | ||||
| link:https://gatling.io/docs/current/cookbook/passing_parameters[can optionally be used] to define | ||||
| non-default values for keys found in scenario `json` data files. That variable can currently be set | ||||
| with either one or many of these supported properties, from the core framework: | ||||
|  | ||||
| * `-Dcom.google.gerrit.scenarios.hostname=localhost` | ||||
| * `-Dcom.google.gerrit.scenarios.ssh_port=29418` | ||||
| * `-Dcom.google.gerrit.scenarios.http_port=8080` | ||||
|  | ||||
| Above, the properties can be set with values matching specific deployment topologies under test. | ||||
| The example values shown above are the currently coded default ones. The framework could support | ||||
| differing or more properties over time. Plugin (non-core) scenarios may do so just as well. | ||||
|  | ||||
| == How to run tests | ||||
|  | ||||
| Run all tests: | ||||
|   | ||||
| @@ -1,10 +1,10 @@ | ||||
| [ | ||||
|   { | ||||
|     "url": "ssh://admin@localhost:29418/loadtest-repo", | ||||
|     "url": "ssh://admin@HOSTNAME:SSH_PORT/loadtest-repo", | ||||
|     "cmd": "clone" | ||||
|   }, | ||||
|   { | ||||
|     "url": "http://localhost:8080/loadtest-repo", | ||||
|     "url": "http://HOSTNAME:HTTP_PORT/loadtest-repo", | ||||
|     "cmd": "clone" | ||||
|   } | ||||
| ] | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| [ | ||||
|   { | ||||
|     "url": "http://localhost:8080/a/projects/loadtest-repo" | ||||
|     "url": "http://HOSTNAME:HTTP_PORT/a/projects/loadtest-repo" | ||||
|   } | ||||
| ] | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| [ | ||||
|   { | ||||
|     "url": "http://localhost:8080/a/projects/loadtest-repo/delete-project~delete" | ||||
|     "url": "http://HOSTNAME:HTTP_PORT/a/projects/loadtest-repo/delete-project~delete" | ||||
|   } | ||||
| ] | ||||
|   | ||||
| @@ -21,7 +21,7 @@ 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 data: FileBasedFeederBuilder[Any]#F#F = jsonFile(resource).convert(url).queue | ||||
|  | ||||
|   private val test: ScenarioBuilder = scenario(name) | ||||
|       .feed(data) | ||||
|   | ||||
| @@ -19,7 +19,7 @@ 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 | ||||
|   private val data: FileBasedFeederBuilder[Any]#F#F = jsonFile(resource).convert(url).queue | ||||
|  | ||||
|   val test: ScenarioBuilder = scenario(name) | ||||
|       .feed(data) | ||||
|   | ||||
| @@ -19,7 +19,7 @@ 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 | ||||
|   private val data: FileBasedFeederBuilder[Any]#F#F = jsonFile(resource).convert(url).queue | ||||
|  | ||||
|   val test: ScenarioBuilder = scenario(name) | ||||
|       .feed(data) | ||||
|   | ||||
| @@ -23,7 +23,8 @@ 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(".", "/") | ||||
|   private val pack: String = this.getClass.getPackage.getName | ||||
|   private val path: String = pack.replaceAllLiterally(".", "/") | ||||
|   protected val name: String = this.getClass.getSimpleName | ||||
|   protected val resource: String = s"data/$path/$name.json" | ||||
|  | ||||
| @@ -31,4 +32,27 @@ class GerritSimulation extends Simulation { | ||||
|   protected val httpProtocol: HttpProtocolBuilder = http.basicAuth( | ||||
|     conf.httpConfiguration.userName, | ||||
|     conf.httpConfiguration.password) | ||||
|  | ||||
|   protected val url: PartialFunction[(String, Any), Any] = { | ||||
|     case ("url", url) => | ||||
|       var in = replaceProperty("hostname", "localhost", url.toString) | ||||
|       in = replaceProperty("http_port", 8080, in) | ||||
|       replaceProperty("ssh_port", 29418, in) | ||||
|   } | ||||
|  | ||||
|   private def replaceProperty(term: String, default: Any, in: String): String = { | ||||
|     val key: String = term.toUpperCase | ||||
|     val property = pack + "." + term | ||||
|     var value = default | ||||
|     default match { | ||||
|       case _: String => | ||||
|         val propertyValue = Option(System.getProperty(property)) | ||||
|         if (propertyValue.nonEmpty) { | ||||
|           value = propertyValue.get | ||||
|         } | ||||
|       case _: Integer => | ||||
|         value = Integer.getInteger(property, default.asInstanceOf[Integer]) | ||||
|     } | ||||
|     in.replaceAllLiterally(key, value.toString) | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -63,6 +63,8 @@ public class ElasticV6QueryChangesTest extends AbstractQueryChangesTest { | ||||
|  | ||||
|   @After | ||||
|   public void closeIndex() throws Exception { | ||||
|     // Close the index after each test to prevent exceeding Elasticsearch's | ||||
|     // shard limit (see Issue 10120). | ||||
|     client | ||||
|         .execute( | ||||
|             new HttpPost( | ||||
|   | ||||
| @@ -63,6 +63,8 @@ public class ElasticV7QueryChangesTest extends AbstractQueryChangesTest { | ||||
|  | ||||
|   @After | ||||
|   public void closeIndex() throws Exception { | ||||
|     // Close the index after each test to prevent exceeding Elasticsearch's | ||||
|     // shard limit (see Issue 10120). | ||||
|     client | ||||
|         .execute( | ||||
|             new HttpPost( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 David Pursehouse
					David Pursehouse