e2e-tests: Add configurable cluster_port property By default, cluster_port is set to 80 to keep backward compatibility. This change allows to run GetProjectsCacheEntries and DeleteProjectUsingHAGerrit scenarios against one of the instances in the cluster instead of a load balancer port using an environment property: -Dcom.ericsson.gerrit.plugins.highavailability.scenarios.cluster_port=8080 This change helps to ease testing in a local setup. Change-Id: Ib7f3102ceb05aeec96d25b9f3df88a76bc3003fb
diff --git a/src/test/docker/README.md b/src/test/docker/README.md index d97e929..4604423 100644 --- a/src/test/docker/README.md +++ b/src/test/docker/README.md
@@ -55,7 +55,7 @@ created on gerrit 1 (port 8081) but from gerrit 2 (on 8082). The scenario therefore expects Gerrit HA to have properly synchronized the new project from 1 to 2. That project gets deleted after, here -using HA Gerrit straight (no specific port). +using HA Gerrit straight (through default http port 80). Scenario scala source files and their companion json resource ones are stored under the usual src/test directories. That structure follows the
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 2405b03..5720f53 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_SCHEME://HOSTNAME/a/projects/PROJECT/delete-project~delete" + "url": "HTTP_SCHEME://HOSTNAME:HTTP_PORT/a/projects/PROJECT/delete-project~delete" } ]
diff --git a/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/GetProjectsCacheEntries.json b/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/GetProjectsCacheEntries.json index 25521c7..e4e2643 100644 --- a/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/GetProjectsCacheEntries.json +++ b/src/test/resources/com/ericsson/gerrit/plugins/highavailability/scenarios/GetProjectsCacheEntries.json
@@ -1,5 +1,5 @@ [ { - "url": "HTTP_SCHEME://HOSTNAME/a/config/server/caches/projects" + "url": "HTTP_SCHEME://HOSTNAME:HTTP_PORT/a/config/server/caches/projects" } ]
diff --git a/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/ClusterDefault.scala b/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/ClusterDefault.scala new file mode 100644 index 0000000..dad2b35 --- /dev/null +++ b/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/ClusterDefault.scala
@@ -0,0 +1,19 @@ +// Copyright (C) 2021 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 + +class ClusterDefault { + val clusterHttpPort: Int = 80 +}
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 cdc6e9e..d9feedb 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
@@ -21,12 +21,18 @@ class DeleteProjectUsingHAGerrit extends ProjectSimulation { private val data: FeederBuilder = jsonFile(resource).convert(keys).queue + private val default: ClusterDefault = new ClusterDefault def this(projectName: String) { this() this.projectName = projectName } + override def replaceOverride(in: String): String = { + val next = replaceProperty("cluster_port", default.clusterHttpPort, in) + super.replaceOverride(next) + } + val test: ScenarioBuilder = scenario(uniqueName) .feed(data) .exec(httpRequest)
diff --git a/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/GetProjectsCacheEntries.scala b/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/GetProjectsCacheEntries.scala index 8a04245..6938c74 100644 --- a/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/GetProjectsCacheEntries.scala +++ b/src/test/scala/com/ericsson/gerrit/plugins/highavailability/scenarios/GetProjectsCacheEntries.scala
@@ -22,12 +22,17 @@ class GetProjectsCacheEntries extends CacheFlushSimulation { private val data: FeederBuilder = jsonFile(resource).convert(keys).queue + private val default: ClusterDefault = new ClusterDefault def this(consumer: CacheFlushSimulation) { this() this.consumer = Some(consumer) } + override def replaceOverride(in: String): String = { + replaceProperty("cluster_port", default.clusterHttpPort, in) + } + val test: ScenarioBuilder = scenario(uniqueName) .feed(data) .exec(http(uniqueName).get("${url}")