@Test
  public void testIndexUpdateWithRegionClear() {

    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);

    final String regionName = "portfolio";

    hooked = false;

    // Create region and an index on it
    vm0.invoke(new CacheSerializableRunnable("Create region and index") {

      @Override
      public void run2() throws CacheException {
        Cache cache = getCache();
        Region region = cache.createRegionFactory(RegionShortcut.LOCAL).create(regionName);
        QueryService qService = cache.getQueryService();

        try {
          qService.createIndex("idIndex", "ID", SEPARATOR + regionName);
          qService.createIndex("secIdIndex", "pos.secId",
              SEPARATOR + regionName + " p, p.positions.values pos");
        } catch (Exception e) {
          fail("Index creation failed." + e);
        }
      }
    });

    class LocalTestHook implements TestHook {

      @Override
      public void hook(int spot) throws RuntimeException {
        switch (spot) {
          case 6: // processAction in IndexManager
            hooked = true;
            // wait until some thread unhooks.
            while (hooked) {
              Wait.pause(20);
            }
            break;
          default:
            break;
        }
      }

    }

    // Asynch invocation for continuous index updates
    AsyncInvocation<Void> indexUpdateAsysnch =
        vm0.invokeAsync(new CacheSerializableRunnable("index updates") {

          @Override
          public void run2() throws CacheException {

            Region region = getCache().getRegion(regionName);
            for (int i = 0; i < 100; i++) {
              if (i == 50) {
                IndexManager.testHook = new LocalTestHook();
              }
              region.put(i, new Portfolio(i));
              if (i == 50) {
                Wait.pause(20);
              }
            }
          }
        });

    // Region.clear() which should block other region updates.
    vm0.invoke(new CacheSerializableRunnable("Clear the region") {

      @Override
      public void run2() throws CacheException {
        Region region = getCache().getRegion(regionName);

        while (!hooked) {
          Wait.pause(100);
        }
        if (hooked) {
          hooked = false;
          IndexManager.testHook = null;
          region.clear();
        }

        try {
          QueryService qservice = getCache().getQueryService();
          Index index = qservice.getIndex(region, "idIndex");
          if (((CompactRangeIndex) index).getIndexStorage().size() > 1) {
            fail(
                "After clear region size is supposed to be zero as all index updates are blocked. Current region size is: "
                    + region.size());
          }
        } finally {
          IndexManager.testHook = null;
        }
      }
    });

    // Kill asynch thread
    ThreadUtils.join(indexUpdateAsysnch, 20000);

    // Verify region size which must be 50
    vm0.invoke(new CacheSerializableRunnable("Check region size") {

      @Override
      public void run2() throws CacheException {
        Region region = getCache().getRegion(regionName);
        if (region.size() > 50) {
          fail("After clear region size is supposed to be 50 as all index updates are blocked "
              + region.size());
        }
      }
    });
  }
This tests if index updates are blocked while region.clear() is called and indexes are being
reinitialized.
geode-core/src/distributedTest/java/org/apache/geode/cache/query/internal/index/ConcurrentIndexInitOnOverflowRegionDUnitTest.java