@Test
  public void testQueriesWithFilterKeysOnPRLocalAndRemoteWithBucketDestroy() {

    // Set Query Observer in cache on server1
    server1.invoke(new CacheSerializableRunnable("Set QueryObserver in cache on server1") {
      @Override
      public void run2() throws CacheException {

        class MyQueryObserver extends IndexTrackingQueryObserver {

          @Override
          public void startQuery(Query query) {
            // Destroy only for first query.
            if (query.getQueryString().contains("ID>=0")) {
              Region pr = CacheFactory.getAnyInstance().getRegion(PartitionedRegionName1);
              Region KeyRegion = null;
              for (int i = 3; i < 7; i++) {
                KeyRegion = ((PartitionedRegion) pr).getBucketRegion(i/* key */);
                if (KeyRegion != null) {
                  KeyRegion.destroyRegion();
                }
              }
            }
          }
        }

        QueryObserverHolder.setInstance(new MyQueryObserver());
      }
    });

    client.invoke(new CacheSerializableRunnable("Test query on client and server") {

      @Override
      public void run2() throws CacheException {
        Set filter = getFilter(0, 2);

        TestServerQueryFunction func = new TestServerQueryFunction("LDS Server function-2");
        function = new TestQueryFunction("queryFunction");

        for (int i = 0; i < queries.length; i++) {

          QueryUsingFunctionContextDUnitTest test = new QueryUsingFunctionContextDUnitTest();
          ArrayList queryResults2 =
              test.runQueryOnClientUsingFunc(function, PartitionedRegionName1, filter, queries[i]);

          // The Partition Region has 20 buckets with 100 values and key i goes in bucket j=(i%20)
          // So each bucket has 5 keys so for 3 buckets 3*5.
          if (i == 0 && queryResults2.size() != 3 * 5) {
            fail("Result size should have been 15 but was" + queryResults2.size());
          }
        }
      }
    });
    // Reset Query Observer in cache on server1
    server1.invoke(new CacheSerializableRunnable("Reset Query Observer on server1") {
      @Override
      public void run2() throws CacheException {
        QueryObserverHolder.reset();
      }
    });

  }
Test on PR on one server only using filter.
geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/QueryUsingFunctionContextDUnitTest.java