public void createServer(VM server, final int port, final boolean eviction,
      final MirrorType mirrorType) {

    // Don't use ephemeral ports since those will probably fall out of the range as dictated by
    // AvailablePort.lowerBound and AvailablePort.upperBound. Usually that's OK unless the server
    // intends to be restarted using the same port as originally assigned ephemerally. There's
    // always a race when restarting servers, but this should reduce the problem just a bit.
    int actualPort = port == 0 ? AvailablePortHelper.getRandomAvailableTCPPort() : port;

    SerializableRunnable createServer = new CacheSerializableRunnable("Create Cache Server") {
      @Override
      public void run2() throws CacheException {
        LogWriterUtils.getLogWriter().info("### Create Cache Server. ###");
        AttributesFactory factory = new AttributesFactory();
        factory.setScope(Scope.DISTRIBUTED_ACK);
        factory.setMirrorType(mirrorType);

        // setting the eviction attributes.
        if (eviction) {
          EvictionAttributes evictAttrs =
              EvictionAttributes.createLRUEntryAttributes(100000, EvictionAction.OVERFLOW_TO_DISK);
          factory.setEvictionAttributes(evictAttrs);
        }

        for (final String region : regions) {
          createRegion(region, factory.createRegionAttributes());
        }

        try {
          startBridgeServer(actualPort, true);
        }

        catch (Exception ex) {
          Assert.fail("While starting CacheServer", ex);
        }
      }
    };

    server.invoke(createServer);
  }
The port on which the cache server was started in this VM
geode-cq/src/distributedTest/java/org/apache/geode/cache/query/cq/dunit/CqQueryUsingPoolDUnitTest.java