Merge branch 'stable-3.1'

* stable-3.1:
  Documentation/user-inline-edit: Remove reference to missing image
  e2e-tests: Add support for automated project names
  e2e-tests: Support non-core JAVA_OPTS overriding
  ElasticChangeIndex: Fix typo in comment

Change-Id: I102eccdd4b8c64edf1ad7295e2503c708afe209c
This commit is contained in:
Marco Miller
2020-04-04 10:09:39 -04:00
11 changed files with 85 additions and 17 deletions

View File

@@ -112,11 +112,11 @@ or validate the local setup. More complex scenarios can be further developed, un
----
[
{
"url": "ssh://admin@HOSTNAME:SSH_PORT/loadtest-repo",
"url": "ssh://admin@HOSTNAME:SSH_PORT/_PROJECT",
"cmd": "clone"
},
{
"url": "http://HOSTNAME:HTTP_PORT/loadtest-repo",
"url": "http://HOSTNAME:HTTP_PORT/_PROJECT",
"cmd": "clone"
}
]
@@ -156,7 +156,19 @@ with either one or many of these supported properties, from the core framework:
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.
differing or more properties over time.
Plugin or otherwise non-core scenarios may do so just as well. The core java package
`com.google.gerrit.scenarios` from the example above has to be replaced with the one under which
those scenario classes are. Such extending scenarios can also add extension-specific properties.
Early examples of this can be found in the Gerrit
`link:https://gerrit.googlesource.com/plugins/high-availability[high-availability,role=external,window=_blank]`
and `link:https://gerrit.googlesource.com/plugins/multi-site[multi-site,role=external,window=_blank]`
plugins test code.
Further above, the `_PROJECT` keyword is prefixed with an underscore, which means that its value
gets automatically generated by the scenario. Any property setting for it is therefore not
applicable. Its usage differs from the non-prefixed `PROJECT` keyword, in that sense.
== How to run tests

View File

@@ -228,8 +228,6 @@ To download a change:
. Copy the desired scheme from the Download drop-down.
. Paste the command into a terminal window.
image::images/inline-edit-actions-download.png[width=600]
GERRIT
Part of link:index.html[Gerrit Code Review]

View File

@@ -1,10 +1,10 @@
[
{
"url": "ssh://admin@HOSTNAME:SSH_PORT/loadtest-repo",
"url": "ssh://admin@HOSTNAME:SSH_PORT/_PROJECT",
"cmd": "clone"
},
{
"url": "http://HOSTNAME:HTTP_PORT/loadtest-repo",
"url": "http://HOSTNAME:HTTP_PORT/_PROJECT",
"cmd": "clone"
}
]

View File

@@ -1,5 +1,5 @@
[
{
"url": "http://HOSTNAME:HTTP_PORT/a/projects/loadtest-repo"
"url": "http://HOSTNAME:HTTP_PORT/a/projects/PROJECT"
}
]

View File

@@ -1,5 +1,5 @@
[
{
"url": "http://HOSTNAME:HTTP_PORT/a/projects/loadtest-repo/delete-project~delete"
"url": "http://HOSTNAME:HTTP_PORT/a/projects/PROJECT/delete-project~delete"
}
]

View File

@@ -22,13 +22,18 @@ import scala.concurrent.duration._
class CloneUsingBothProtocols extends GitSimulation {
private val data: FileBasedFeederBuilder[Any]#F#F = jsonFile(resource).convert(url).queue
private val default: String = name
override def replaceOverride(in: String): String = {
replaceKeyWith("_project", default, in)
}
private val test: ScenarioBuilder = scenario(name)
.feed(data)
.exec(gitRequest)
private val createProject = new CreateProject
private val deleteProject = new DeleteProject
private val createProject = new CreateProject(default)
private val deleteProject = new DeleteProject(default)
setUp(
createProject.test.inject(

View File

@@ -18,9 +18,14 @@ import io.gatling.core.Predef._
import io.gatling.core.feeder.FileBasedFeederBuilder
import io.gatling.core.structure.ScenarioBuilder
class CreateProject extends GerritSimulation {
class CreateProject extends ProjectSimulation {
private val data: FileBasedFeederBuilder[Any]#F#F = jsonFile(resource).convert(url).queue
def this(default: String) {
this()
this.default = default
}
val test: ScenarioBuilder = scenario(name)
.feed(data)
.exec(httpRequest)

View File

@@ -18,9 +18,14 @@ import io.gatling.core.Predef._
import io.gatling.core.feeder.FileBasedFeederBuilder
import io.gatling.core.structure.ScenarioBuilder
class DeleteProject extends GerritSimulation {
class DeleteProject extends ProjectSimulation {
private val data: FileBasedFeederBuilder[Any]#F#F = jsonFile(resource).convert(url).queue
def this(default: String) {
this()
this.default = default
}
val test: ScenarioBuilder = scenario(name)
.feed(data)
.exec(httpRequest)

View File

@@ -35,13 +35,13 @@ class GerritSimulation extends Simulation {
protected val url: PartialFunction[(String, Any), Any] = {
case ("url", url) =>
var in = replaceProperty("hostname", "localhost", url.toString)
var in = replaceOverride(url.toString)
in = replaceProperty("hostname", "localhost", in)
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
protected def replaceProperty(term: String, default: Any, in: String): String = {
val property = pack + "." + term
var value = default
default match {
@@ -53,6 +53,26 @@ class GerritSimulation extends Simulation {
case _: Integer =>
value = Integer.getInteger(property, default.asInstanceOf[Integer])
}
replaceKeyWith(term, value, in)
}
protected def replaceKeyWith(term: String, value: Any, in: String): String = {
val key: String = term.toUpperCase
in.replaceAllLiterally(key, value.toString)
}
/**
* Meant to be optionally overridden by plugins or other extensions.
* Such potential overriding methods, such as the example below,
* typically return resulting call(s) to [[replaceProperty()]].
* This is usually similar to how [[url]] is implemented above.
*
* <pre>
* override def replaceOverride(in: String): String = {
* // Simple e.g., replaceProperty("EXTENSION_JSON_KEY", "default", in)
* </pre>
*/
def replaceOverride(in: String): String = {
in
}
}

View File

@@ -0,0 +1,23 @@
// Copyright (C) 2020 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.scenarios
class ProjectSimulation extends GerritSimulation {
protected var default: String = "project"
override def replaceOverride(in: String): String = {
replaceProperty("project", default, in)
}
}

View File

@@ -385,7 +385,7 @@ class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
ChangeField.SUBMIT_RULE_OPTIONS_STRICT,
cd);
// Stored-submit-record-leniant.
// Stored-submit-record-lenient.
decodeSubmitRecords(
source,
ChangeField.STORED_SUBMIT_RECORD_LENIENT.getName(),