@Ignore("TODO: test is disabled")
  @Test
  public void testQueueWhenRoleMissing() throws Exception {
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(DISTRIBUTED_ACK);
    DistributedRegion r = (DistributedRegion) createRootRegion(factory.create());
    final CachePerfStats stats = r.getCachePerfStats();
    long queuedOps = stats.getReliableQueuedOps();
    r.create("createKey", "createValue", "createCBArg");
    r.invalidate("createKey", "invalidateCBArg");
    r.put("createKey", "putValue", "putCBArg");
    r.destroy("createKey", "destroyCBArg");
    assertEquals(queuedOps + 4, stats.getReliableQueuedOps());
    queuedOps = stats.getReliableQueuedOps();
    {
      Map m = new TreeMap();
      m.put("aKey", "aValue");
      m.put("bKey", "bValue");
      r.putAll(m);
    }
    assertEquals(queuedOps + 2, stats.getReliableQueuedOps());
    queuedOps = stats.getReliableQueuedOps();
    r.invalidateRegion("invalidateRegionCBArg");
    assertEquals(queuedOps + 1, stats.getReliableQueuedOps());
    queuedOps = stats.getReliableQueuedOps();
    r.clear();
    assertEquals(queuedOps + 1, stats.getReliableQueuedOps());
    queuedOps = stats.getReliableQueuedOps();
    // @todo darrel: try some other ops

    VM vm = getHost(0).getVM(0);
    // now create a system that fills this role since it does not create the
    // region our queue should not be flushed
    vm.invoke(new SerializableRunnable() {
      @Override
      public void run() {
        Properties config = new Properties();
        config.setProperty(ROLES, "missing");
        getSystem(config);
      }
    });

    // we still should have everything queued since the region is not created
    assertEquals(queuedOps, stats.getReliableQueuedOps());

    // now create the region
    vm.invoke(new CacheSerializableRunnable("create root") {
      @Override
      public void run2() throws CacheException {
        AttributesFactory factory = new AttributesFactory();
        factory.setScope(DISTRIBUTED_ACK);
        factory.setDataPolicy(NORMAL);
        factory.setSubscriptionAttributes(new SubscriptionAttributes(ALL));
        TestCacheListener cl = new TestCacheListener() {
          @Override
          public void afterCreate2(EntryEvent event) {}

          @Override
          public void afterUpdate2(EntryEvent event) {}

          @Override
          public void afterInvalidate2(EntryEvent event) {}

          @Override
          public void afterDestroy2(EntryEvent event) {}
        };
        cl.enableEventHistory();
        factory.addCacheListener(cl);
        createRootRegion(factory.create());
      }
    });
    // after some amount of time we should see the queuedOps flushed
    WaitCriterion ev = new WaitCriterion() {
      @Override
      public boolean done() {
        return stats.getReliableQueuedOps() == 0;
      }

      @Override
      public String description() {
        return "waiting for reliableQueuedOps to become 0";
      }
    };
    GeodeAwaitility.await().untilAsserted(ev);

    // now check that the queued op was delivered
    vm.invoke(new CacheSerializableRunnable("check") {
      @Override
      public void run2() throws CacheException {
        Region r = getRootRegion();
        assertEquals(null, r.getEntry("createKey"));
        // assertIndexDetailsEquals("putValue", r.getEntry("createKey").getValue());
        {
          int evIdx = 0;
          TestCacheListener cl = (TestCacheListener) r.getAttributes().getCacheListener();
          List events = cl.getEventHistory();
          {
            CacheEvent ce = (CacheEvent) events.get(evIdx++);
            assertEquals(REGION_CREATE, ce.getOperation());
          }
          {
            EntryEvent ee = (EntryEvent) events.get(evIdx++);
            assertEquals(CREATE, ee.getOperation());
            assertEquals("createKey", ee.getKey());
            assertEquals("createValue", ee.getNewValue());
            assertEquals(null, ee.getOldValue());
            assertEquals("createCBArg", ee.getCallbackArgument());
            assertEquals(true, ee.isOriginRemote());
          }
          {
            EntryEvent ee = (EntryEvent) events.get(evIdx++);
            assertEquals(INVALIDATE, ee.getOperation());
            assertEquals("createKey", ee.getKey());
            assertEquals(null, ee.getNewValue());
            assertEquals("createValue", ee.getOldValue());
            assertEquals("invalidateCBArg", ee.getCallbackArgument());
            assertEquals(true, ee.isOriginRemote());
          }
          {
            EntryEvent ee = (EntryEvent) events.get(evIdx++);
            assertEquals(UPDATE, ee.getOperation());
            assertEquals("createKey", ee.getKey());
            assertEquals("putValue", ee.getNewValue());
            assertEquals(null, ee.getOldValue());
            assertEquals("putCBArg", ee.getCallbackArgument());
            assertEquals(true, ee.isOriginRemote());
          }
          {
            EntryEvent ee = (EntryEvent) events.get(evIdx++);
            assertEquals(DESTROY, ee.getOperation());
            assertEquals("createKey", ee.getKey());
            assertEquals(null, ee.getNewValue());
            assertEquals("putValue", ee.getOldValue());
            assertEquals("destroyCBArg", ee.getCallbackArgument());
            assertEquals(true, ee.isOriginRemote());
          }
          {
            EntryEvent ee = (EntryEvent) events.get(evIdx++);
            assertEquals(PUTALL_CREATE, ee.getOperation());
            assertEquals("aKey", ee.getKey());
            assertEquals("aValue", ee.getNewValue());
            assertEquals(null, ee.getOldValue());
            assertEquals(null, ee.getCallbackArgument());
            assertEquals(true, ee.isOriginRemote());
          }
          {
            EntryEvent ee = (EntryEvent) events.get(evIdx++);
            assertEquals(PUTALL_CREATE, ee.getOperation());
            assertEquals("bKey", ee.getKey());
            assertEquals("bValue", ee.getNewValue());
            assertEquals(null, ee.getOldValue());
            assertEquals(null, ee.getCallbackArgument());
            assertEquals(true, ee.isOriginRemote());
          }
          {
            RegionEvent re = (RegionEvent) events.get(evIdx++);
            assertEquals(REGION_INVALIDATE, re.getOperation());
            assertEquals("invalidateRegionCBArg", re.getCallbackArgument());
            assertEquals(true, re.isOriginRemote());
          }
          {
            RegionEvent re = (RegionEvent) events.get(evIdx++);
            assertEquals(REGION_CLEAR, re.getOperation());
            assertEquals(null, re.getCallbackArgument());
            assertEquals(true, re.isOriginRemote());
          }

          assertEquals(evIdx, events.size());
        }
      }
    });
  }
Make sure that cache operations are queued when a required role is missing
geode-core/src/distributedTest/java/org/apache/geode/cache30/QueueMsgDUnitTest.java