Merge branch 'stable-3.0' into stable-3.1
* stable-3.0:
Add {Create|Delete}ChangeUsingHAGerrits scenarios
Change-Id: Ia73e8647f8403883c2c5005589361749aa4f1d3f
diff --git a/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateChangeUsingHAGerrit1-body.json b/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateChangeUsingHAGerrit1-body.json
new file mode 100644
index 0000000..23bf26c
--- /dev/null
+++ b/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateChangeUsingHAGerrit1-body.json
@@ -0,0 +1,5 @@
+{
+ "project": "${project}",
+ "branch": "master",
+ "subject": "Change"
+}
diff --git a/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateChangeUsingHAGerrit1.json b/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateChangeUsingHAGerrit1.json
new file mode 100644
index 0000000..b535c1d
--- /dev/null
+++ b/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateChangeUsingHAGerrit1.json
@@ -0,0 +1,6 @@
+[
+ {
+ "url": "http://HOSTNAME:HTTP_PORT1/a/changes/",
+ "project": "_PROJECT"
+ }
+]
diff --git a/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateProjectUsingHAGerrit1-body.json b/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateProjectUsingHAGerrit1-body.json
new file mode 100644
index 0000000..bcf4708
--- /dev/null
+++ b/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateProjectUsingHAGerrit1-body.json
@@ -0,0 +1,3 @@
+{
+ "create_empty_commit": "true"
+}
diff --git a/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/DeleteChangeUsingHAGerrit2.json b/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/DeleteChangeUsingHAGerrit2.json
new file mode 100644
index 0000000..55167bd
--- /dev/null
+++ b/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/DeleteChangeUsingHAGerrit2.json
@@ -0,0 +1,6 @@
+[
+ {
+ "url": "http://HOSTNAME:HTTP_PORT2/a/changes/",
+ "number": "_NUMBER"
+ }
+]
diff --git a/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/CloneUsingHAGerrit2.scala b/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/CloneUsingHAGerrit2.scala
index 28891b1..03f516f 100644
--- a/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/CloneUsingHAGerrit2.scala
+++ b/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/CloneUsingHAGerrit2.scala
@@ -22,7 +22,7 @@
import scala.concurrent.duration._
class CloneUsingHAGerrit2 extends GitSimulation {
- private val data: FileBasedFeederBuilder[Any]#F#F = jsonFile(resource).convert(url).queue
+ private val data: FileBasedFeederBuilder[Any]#F#F = jsonFile(resource).convert(keys).queue
private var default: String = name
def this(default: String) {
diff --git a/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateChangeUsingHAGerrit1.scala b/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateChangeUsingHAGerrit1.scala
new file mode 100644
index 0000000..cab5797
--- /dev/null
+++ b/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateChangeUsingHAGerrit1.scala
@@ -0,0 +1,65 @@
+// 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.ericsson.gerrit.plugins.highavailability.scenarios
+
+import com.google.gerrit.scenarios.GerritSimulation
+import io.gatling.core.Predef.{atOnceUsers, _}
+import io.gatling.core.feeder.FileBasedFeederBuilder
+import io.gatling.core.structure.ScenarioBuilder
+import io.gatling.http.Predef._
+
+import scala.concurrent.duration._
+
+class CreateChangeUsingHAGerrit1 extends GerritSimulation {
+ private val data: FileBasedFeederBuilder[Any]#F#F = jsonFile(resource).convert(keys).queue
+ private val default: String = name
+ private val numberKey = "_number"
+
+ override def replaceOverride(in: String): String = {
+ replaceProperty("http_port1", 8081, in)
+ }
+
+ val test: ScenarioBuilder = scenario(unique)
+ .feed(data)
+ .exec(httpRequest
+ .body(ElFileBody(body)).asJson
+ .check(regex("\"" + numberKey + "\":(\\d+),").saveAs(numberKey)))
+ .exec(session => {
+ deleteChange.number = Some(session(numberKey).as[Int])
+ session
+ })
+
+ private val createProject = new CreateProjectUsingHAGerrit1(default)
+ private val deleteProject = new DeleteProjectUsingHAGerrit(default)
+ private val deleteChange = new DeleteChangeUsingHAGerrit2
+
+ setUp(
+ createProject.test.inject(
+ atOnceUsers(1)
+ ),
+ test.inject(
+ nothingFor(2 seconds),
+ atOnceUsers(1)
+ ),
+ deleteChange.test.inject(
+ nothingFor(20 seconds),
+ atOnceUsers(1)
+ ),
+ deleteProject.test.inject(
+ nothingFor(40 seconds),
+ atOnceUsers(1)
+ ),
+ ).protocols(httpProtocol)
+}
diff --git a/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateProjectUsingHAGerrit1.scala b/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateProjectUsingHAGerrit1.scala
index 958fd1e..679c055 100644
--- a/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateProjectUsingHAGerrit1.scala
+++ b/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateProjectUsingHAGerrit1.scala
@@ -20,7 +20,7 @@
import io.gatling.core.structure.ScenarioBuilder
class CreateProjectUsingHAGerrit1 extends ProjectSimulation {
- private val data: FileBasedFeederBuilder[Any]#F#F = jsonFile(resource).convert(url).queue
+ private val data: FileBasedFeederBuilder[Any]#F#F = jsonFile(resource).convert(keys).queue
def this(default: String) {
this()
@@ -34,7 +34,7 @@
val test: ScenarioBuilder = scenario(unique)
.feed(data)
- .exec(httpRequest)
+ .exec(httpRequest.body(RawFileBody(body)).asJson)
setUp(
test.inject(
diff --git a/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/DeleteChangeUsingHAGerrit2.scala b/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/DeleteChangeUsingHAGerrit2.scala
new file mode 100644
index 0000000..b7c73a9
--- /dev/null
+++ b/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/DeleteChangeUsingHAGerrit2.scala
@@ -0,0 +1,47 @@
+// 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.ericsson.gerrit.plugins.highavailability.scenarios
+
+import com.google.gerrit.scenarios.GerritSimulation
+import io.gatling.core.Predef.{atOnceUsers, _}
+import io.gatling.core.feeder.FileBasedFeederBuilder
+import io.gatling.core.structure.ScenarioBuilder
+import io.gatling.http.Predef.http
+
+class DeleteChangeUsingHAGerrit2 extends GerritSimulation {
+ private val data: FileBasedFeederBuilder[Any]#F#F = jsonFile(resource).convert(keys).queue
+ var number: Option[Int] = None
+
+ override def replaceOverride(in: String): String = {
+ replaceProperty("http_port2", 8082, in)
+ }
+
+ val test: ScenarioBuilder = scenario(unique)
+ .feed(data)
+ .exec(session => {
+ if (number.nonEmpty) {
+ session.set("number", number.get)
+ } else {
+ session
+ }
+ })
+ .exec(http(unique).delete("${url}${number}"))
+
+ setUp(
+ test.inject(
+ atOnceUsers(1)
+ ),
+ ).protocols(httpProtocol)
+}
diff --git a/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/DeleteProjectUsingHAGerrit.scala b/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/DeleteProjectUsingHAGerrit.scala
index b0232e6..d329573 100644
--- a/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/DeleteProjectUsingHAGerrit.scala
+++ b/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/DeleteProjectUsingHAGerrit.scala
@@ -20,7 +20,7 @@
import io.gatling.core.structure.ScenarioBuilder
class DeleteProjectUsingHAGerrit extends ProjectSimulation {
- private val data: FileBasedFeederBuilder[Any]#F#F = jsonFile(resource).convert(url).queue
+ private val data: FileBasedFeederBuilder[Any]#F#F = jsonFile(resource).convert(keys).queue
def this(default: String) {
this()