private void createQueryIndex(VM vm, final boolean create) {

    SerializableRunnable createIndex = new SerializableRunnable("Create index on PR") {

      @Override
      public void run() {

        // Query VERBOSE has to be true for the test
        assertTrue(DefaultQuery.QUERY_VERBOSE);

        QueryService qs = getCache().getQueryService();

        Index keyIndex1 = null;
        try {
          if (create) {
            keyIndex1 = qs.createIndex(IndexTrackingTestHook.INDEX_NAME,
                IndexType.FUNCTIONAL, "ID",
                SEPARATOR + "portfolio ");
            assertNotNull(keyIndex1);
            assertTrue(keyIndex1 instanceof PartitionedIndex);
          }
        } catch (Exception e) {
          Assert.fail("While creating Index on PR", e);
        }
        Region region = getCache().getRegion("portfolio");
        // Inject TestHook in QueryObserver before running query.
        IndexTrackingTestHook th = new IndexTrackingTestHook(region, NUM_BKTS / 2);
        QueryObserver observer = QueryObserverHolder.getInstance();
        assertTrue(QueryObserverHolder.hasObserver());

        ((IndexTrackingQueryObserver) observer).setTestHook(th);
      }
    };

    vm.invoke(createIndex);
  }
CReates a PR on a VM with NUM_BKTS buckets.
geode-core/src/distributedTest/java/org/apache/geode/cache/query/internal/index/IndexTrackingQueryObserverDUnitTest.java