Do not rely on static port allocation for WireMock tests

The WireMock tests were assuming that a static port allocation
is always available, which may or may not be true, depending
on where the tests are executed.

Also, using a static port allocation does not allow to run
tests with multiple runs, for example:
bazel test --runs_per_test=5 plugins/high-availability/...

Change-Id: Ib1523ac52fd91cf027a9623443b61c6a4d8f9791
diff --git a/src/test/java/com/ericsson/gerrit/plugins/highavailability/index/AbstractIndexForwardingIT.java b/src/test/java/com/ericsson/gerrit/plugins/highavailability/index/AbstractIndexForwardingIT.java
index 83f86d0..fe6cfce 100644
--- a/src/test/java/com/ericsson/gerrit/plugins/highavailability/index/AbstractIndexForwardingIT.java
+++ b/src/test/java/com/ericsson/gerrit/plugins/highavailability/index/AbstractIndexForwardingIT.java
@@ -49,10 +49,8 @@
     sysModule = "com.ericsson.gerrit.plugins.highavailability.Module",
     httpModule = "com.ericsson.gerrit.plugins.highavailability.HttpModule")
 public abstract class AbstractIndexForwardingIT extends LightweightPluginDaemonTest {
-  private static final int PORT = 18889;
-  private static final String URL = "http://localhost:" + PORT;
 
-  @Rule public WireMockRule wireMockRule = new WireMockRule(options().port(PORT));
+  @Rule public WireMockRule wireMockRule = new WireMockRule(options().dynamicPort());
 
   @Inject SitePaths sitePaths;
 
@@ -62,7 +60,7 @@
     FileBasedConfig fileBasedConfig =
         new FileBasedConfig(
             sitePaths.etc_dir.resolve(Configuration.PLUGIN_CONFIG_FILE).toFile(), FS.DETECTED);
-    fileBasedConfig.setString("peerInfo", "static", "url", URL);
+    fileBasedConfig.setString("peerInfo", "static", "url", url());
     fileBasedConfig.setInt("http", null, "retryInterval", 100);
     fileBasedConfig.save();
     beforeAction();
@@ -88,6 +86,10 @@
     verify(postRequestedFor(urlEqualTo(expectedRequest)));
   }
 
+  private String url() {
+    return "http://localhost:" + wireMockRule.port();
+  }
+
   /** Perform pre-test setup. */
   protected abstract void beforeAction() throws Exception;