use of org.apache.ignite.internal.util.distributed.SingleNodeMessage in project ignite by apache.
the class CacheGroupKeyChangeTest method testCacheStartOnClientDuringRotation.
/**
* @throws Exception If failed.
*/
@Test
public void testCacheStartOnClientDuringRotation() throws Exception {
T2<IgniteEx, IgniteEx> nodes = startTestGrids(true);
IgniteEx node0 = nodes.get1();
IgniteEx node1 = nodes.get2();
IgniteEx client = startClientGrid(getConfiguration("client"));
node0.cluster().state(ClusterState.ACTIVE);
String grpName = "shared";
createEncryptedCache(client, null, cacheName(), grpName);
awaitPartitionMapExchange();
TestRecordingCommunicationSpi commSpi = TestRecordingCommunicationSpi.spi(node1);
commSpi.blockMessages((node, message) -> message instanceof SingleNodeMessage);
IgniteFuture<Void> changeKeyFut = node0.encryption().changeCacheGroupKey(Collections.singleton(grpName));
commSpi.waitForBlocked();
String cacheName = "userCache";
IgniteInternalFuture<?> cacheStartFut = runAsync(() -> {
client.getOrCreateCache(cacheConfiguration(cacheName, grpName));
});
commSpi.stopBlock();
changeKeyFut.get(MAX_AWAIT_MILLIS);
cacheStartFut.get(MAX_AWAIT_MILLIS);
IgniteCache<Integer, String> cache = client.cache(cacheName);
for (int i = 0; i < 200; i++) cache.put(i, String.valueOf(i));
checkEncryptedCaches(node0, client);
checkGroupKey(CU.cacheId(grpName), INITIAL_KEY_ID + 1, MAX_AWAIT_MILLIS);
checkEncryptedCaches(node0, node1);
}
use of org.apache.ignite.internal.util.distributed.SingleNodeMessage in project ignite by apache.
the class CacheGroupKeyChangeTest method testCacheStartDuringRotation.
/**
* @throws Exception If failed.
*/
@Test
public void testCacheStartDuringRotation() throws Exception {
T2<IgniteEx, IgniteEx> grids = startTestGrids(true);
createEncryptedCache(grids.get1(), grids.get2(), cacheName(), null);
TestRecordingCommunicationSpi commSpi = TestRecordingCommunicationSpi.spi(grids.get2());
commSpi.blockMessages((node, msg) -> msg instanceof SingleNodeMessage);
IgniteFuture<Void> fut = grids.get1().encryption().changeCacheGroupKey(Collections.singleton(cacheName()));
commSpi.waitForBlocked();
IgniteCache<Integer, Integer> cache = grids.get1().createCache(cacheConfiguration("cache1", null));
for (int i = 0; i < 100; i++) cache.put(i, i);
commSpi.stopBlock();
fut.get();
checkGroupKey(CU.cacheId(cacheName()), INITIAL_KEY_ID + 1, MAX_AWAIT_MILLIS);
checkGroupKey(CU.cacheId("cache1"), INITIAL_KEY_ID, MAX_AWAIT_MILLIS);
}
use of org.apache.ignite.internal.util.distributed.SingleNodeMessage in project ignite by apache.
the class CacheGroupKeyChangeTest method testClientJoinDuringRotation.
/**
* @throws Exception If failed.
*/
@Test
public void testClientJoinDuringRotation() throws Exception {
T2<IgniteEx, IgniteEx> nodes = startTestGrids(true);
IgniteEx node0 = nodes.get1();
IgniteEx node1 = nodes.get2();
node0.cluster().state(ClusterState.ACTIVE);
createEncryptedCache(node0, node1, cacheName(), null);
awaitPartitionMapExchange();
TestRecordingCommunicationSpi commSpi = TestRecordingCommunicationSpi.spi(node1);
commSpi.blockMessages((node, message) -> message instanceof SingleNodeMessage);
IgniteFuture<Void> changeKeyFut = node0.encryption().changeCacheGroupKey(Collections.singleton(cacheName()));
commSpi.waitForBlocked();
IgniteEx client = startClientGrid(getConfiguration("client"));
assertTrue(!changeKeyFut.isDone());
commSpi.stopBlock();
changeKeyFut.get(MAX_AWAIT_MILLIS);
checkEncryptedCaches(node0, client);
checkGroupKey(CU.cacheId(cacheName()), INITIAL_KEY_ID + 1, MAX_AWAIT_MILLIS);
}
use of org.apache.ignite.internal.util.distributed.SingleNodeMessage in project ignite by apache.
the class CacheGroupKeyChangeTest method testRejectNodeJoinDuringRotation.
/**
* @throws Exception If failed.
*/
@Test
@SuppressWarnings("ThrowableNotThrown")
public void testRejectNodeJoinDuringRotation() throws Exception {
T2<IgniteEx, IgniteEx> grids = startTestGrids(true);
createEncryptedCache(grids.get1(), grids.get2(), cacheName(), null);
int grpId = CU.cacheId(cacheName());
assertEquals(0, grids.get1().context().encryption().getActiveKey(grpId).id());
TestRecordingCommunicationSpi commSpi = TestRecordingCommunicationSpi.spi(grids.get2());
commSpi.blockMessages((node, msg) -> msg instanceof SingleNodeMessage);
IgniteFuture<Void> fut = grids.get1().encryption().changeCacheGroupKey(Collections.singleton(cacheName()));
commSpi.waitForBlocked();
assertThrowsWithCause(() -> startGrid(3), IgniteCheckedException.class);
commSpi.stopBlock();
fut.get();
checkGroupKey(grpId, INITIAL_KEY_ID + 1, MAX_AWAIT_MILLIS);
checkEncryptedCaches(grids.get1(), grids.get2());
}
use of org.apache.ignite.internal.util.distributed.SingleNodeMessage in project ignite by apache.
the class MasterKeyChangeTest method testRejectCacheStartDuringRotation.
/**
* @throws Exception If failed.
*/
@Test
public void testRejectCacheStartDuringRotation() throws Exception {
T2<IgniteEx, IgniteEx> grids = startTestGrids(true);
createEncryptedCache(grids.get1(), grids.get2(), cacheName(), null);
assertTrue(checkMasterKeyName(DEFAULT_MASTER_KEY_NAME));
TestRecordingCommunicationSpi commSpi = TestRecordingCommunicationSpi.spi(grids.get2());
commSpi.blockMessages((node, msg) -> msg instanceof SingleNodeMessage);
IgniteFuture<Void> fut = grids.get1().encryption().changeMasterKey(MASTER_KEY_NAME_2);
commSpi.waitForBlocked();
assertThrowsWithCause(() -> {
grids.get1().getOrCreateCache(new CacheConfiguration<>("newCache").setEncryptionEnabled(true));
}, IgniteCheckedException.class);
commSpi.stopBlock();
fut.get();
assertTrue(checkMasterKeyName(MASTER_KEY_NAME_2));
createEncryptedCache(grids.get1(), grids.get2(), "cache2", null);
checkEncryptedCaches(grids.get1(), grids.get2());
}
Aggregations