public void validateMatchingCqs(VM server, final int mapSize, final String query,
      final int numCqSize) {
    server.invoke(new CacheSerializableRunnable("validateMatchingCqs") {
      @Override
      public void run2() throws CacheException {
        CqServiceImpl cqService = null;
        try {
          cqService =
              (CqServiceImpl) ((DefaultQueryService) getCache().getQueryService()).getCqService();
        } catch (Exception ex) {
          LogWriterUtils.getLogWriter().info("Failed to get the internal CqService.", ex);
          Assert.fail("Failed to get the internal CqService.", ex);
        }

        Map matchedCqMap = cqService.getMatchingCqMap();
        await()
            .untilAsserted(
                () -> assertEquals("The number of matched cq is not as expected.", mapSize,
                    matchedCqMap.size()));

        if (query != null) {
          if (!matchedCqMap.containsKey(query)) {
            fail("Query not found in the matched cq map. Query:" + query);
          }
          Collection cqs = (Collection) matchedCqMap.get(query);
          await()
              .untilAsserted(() -> assertEquals(
                  "Number of matched cqs are not equal to the expected matched cqs", numCqSize,
                  cqs.size()));
        }
      }
    });
  }
Performance test for Matching CQ optimization changes.
geode-cq/src/distributedTest/java/org/apache/geode/cache/query/cq/dunit/CqPerfUsingPoolDUnitTest.java