e2e-tests: Unhardcode test scenarios project names

Make the CloneUsingHAGerrit2 scenario use the automatically generated
project name, which is its own class name. Get its delegate project
scenarios to use that same name consistently. Use an underscore-prefixed
_PROJECT keyword for that purpose, based on the core framework practice.

Have the CreateProjectUsingHAGerrit1 and DeleteProjectUsingHAGerrit
scenarios still support configurable test project names, as independant
scenarios. Reuse core framework's JAVA_OPTS support for that matter, by
means of introducing the PROJECT keyword in scenario json data files.

CloneUsingHAGerrit2 still enforces its own consistent test project name,
through its aggregating use of CreateProjectUsingHAGerrit1 and
DeleteProjectUsingHAGerrit. The 'project' JAVA_OPTS property (defining
PROJECT) should not be set in that case.

Change-Id: I32d74308ae9f52e6ac71d61299db12104f233dff
diff --git a/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/CloneUsingHAGerrit2.json b/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/CloneUsingHAGerrit2.json
index a9f852b..3fd506d 100644
--- a/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/CloneUsingHAGerrit2.json
+++ b/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/CloneUsingHAGerrit2.json
@@ -1,6 +1,6 @@
 [
   {
-    "url": "http://HOSTNAME:HTTP_PORT2/loadtest-repo",
+    "url": "http://HOSTNAME:HTTP_PORT2/_PROJECT",
     "cmd": "clone"
   }
 ]
diff --git a/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateProjectUsingHAGerrit1.json b/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateProjectUsingHAGerrit1.json
index 0ec65ef..da3f028 100644
--- a/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateProjectUsingHAGerrit1.json
+++ b/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/CreateProjectUsingHAGerrit1.json
@@ -1,5 +1,5 @@
 [
   {
-    "url": "http://HOSTNAME:HTTP_PORT1/a/projects/loadtest-repo"
+    "url": "http://HOSTNAME:HTTP_PORT1/a/projects/PROJECT"
   }
 ]
diff --git a/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/DeleteProjectUsingHAGerrit.json b/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/DeleteProjectUsingHAGerrit.json
index 460e7fe..be47699 100644
--- a/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/DeleteProjectUsingHAGerrit.json
+++ b/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/DeleteProjectUsingHAGerrit.json
@@ -1,5 +1,5 @@
 [
   {
-    "url": "http://HOSTNAME/a/projects/loadtest-repo/delete-project~delete"
+    "url": "http://HOSTNAME/a/projects/PROJECT/delete-project~delete"
   }
 ]
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 bd658c8..9b457ac 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
@@ -23,17 +23,19 @@
 
 class CloneUsingHAGerrit2 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 = {
-    replaceProperty("http_port2", 8082, in)
+    val next = replaceProperty("http_port2", 8082, in)
+    replaceKeyWith("_project", default, next)
   }
 
   private val test: ScenarioBuilder = scenario(name)
     .feed(data)
     .exec(gitRequest)
 
-  private val createProject = new CreateProjectUsingHAGerrit1
-  private val deleteProject = new DeleteProjectUsingHAGerrit
+  private val createProject = new CreateProjectUsingHAGerrit1(default)
+  private val deleteProject = new DeleteProjectUsingHAGerrit(default)
 
   setUp(
     createProject.test.inject(
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 7c21c90..ad2cbd9 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
@@ -14,16 +14,22 @@
 
 package com.ericsson.gerrit.plugins.highavailability.scenarios
 
-import com.google.gerrit.scenarios.GerritSimulation
+import com.google.gerrit.scenarios.ProjectSimulation
 import io.gatling.core.Predef._
 import io.gatling.core.feeder.FileBasedFeederBuilder
 import io.gatling.core.structure.ScenarioBuilder
 
-class CreateProjectUsingHAGerrit1 extends GerritSimulation {
+class CreateProjectUsingHAGerrit1 extends ProjectSimulation {
   private val data: FileBasedFeederBuilder[Any]#F#F = jsonFile(resource).convert(url).queue
 
+  def this(default: String) {
+    this()
+    this.default = default
+  }
+
   override def replaceOverride(in: String): String = {
-    replaceProperty("http_port1", 8081, in)
+    val next = replaceProperty("http_port1", 8081, in)
+    super.replaceOverride(next)
   }
 
   val test: ScenarioBuilder = scenario(name)
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 2725963..091cd7b 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
@@ -14,14 +14,19 @@
 
 package com.ericsson.gerrit.plugins.highavailability.scenarios
 
-import com.google.gerrit.scenarios.GerritSimulation
+import com.google.gerrit.scenarios.ProjectSimulation
 import io.gatling.core.Predef._
 import io.gatling.core.feeder.FileBasedFeederBuilder
 import io.gatling.core.structure.ScenarioBuilder
 
-class DeleteProjectUsingHAGerrit extends GerritSimulation {
+class DeleteProjectUsingHAGerrit 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)