use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.
the class PageMemoryImplTest method createPageMemory.
/**
* @param throttlingPlc Throttling Policy.
* @throws Exception If creating mock failed.
*/
private PageMemoryImpl createPageMemory(PageMemoryImpl.ThrottlingPolicy throttlingPlc) throws Exception {
long[] sizes = new long[5];
for (int i = 0; i < sizes.length; i++) sizes[i] = MAX_SIZE * MB / 4;
sizes[4] = 5 * MB;
DirectMemoryProvider provider = new UnsafeMemoryProvider(log);
IgniteConfiguration igniteCfg = new IgniteConfiguration();
igniteCfg.setDataStorageConfiguration(new DataStorageConfiguration());
GridTestKernalContext kernalCtx = new GridTestKernalContext(new GridTestLog4jLogger(), igniteCfg);
kernalCtx.add(new IgnitePluginProcessor(kernalCtx, igniteCfg, Collections.<PluginProvider>emptyList()));
GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(kernalCtx, null, null, null, new NoOpPageStoreManager(), new NoOpWALManager(), null, new IgniteCacheDatabaseSharedManager(), null, null, null, null, null, null, null, null);
CheckpointWriteProgressSupplier noThrottle = Mockito.mock(CheckpointWriteProgressSupplier.class);
Mockito.when(noThrottle.currentCheckpointPagesCount()).thenReturn(1_000_000);
Mockito.when(noThrottle.evictedPagesCntr()).thenReturn(new AtomicInteger(0));
Mockito.when(noThrottle.syncedPagesCounter()).thenReturn(new AtomicInteger(1_000_000));
Mockito.when(noThrottle.writtenPagesCounter()).thenReturn(new AtomicInteger(1_000_000));
PageMemoryImpl mem = new PageMemoryImpl(provider, sizes, sharedCtx, PAGE_SIZE, (fullPageId, byteBuf, tag) -> {
assert false : "No page replacement (rotation with disk) should happen during the test";
}, new GridInClosure3X<Long, FullPageId, PageMemoryEx>() {
@Override
public void applyx(Long page, FullPageId fullId, PageMemoryEx pageMem) {
}
}, new CheckpointLockStateChecker() {
@Override
public boolean checkpointLockIsHeldByThread() {
return true;
}
}, new DataRegionMetricsImpl(igniteCfg.getDataStorageConfiguration().getDefaultDataRegionConfiguration()), throttlingPlc, noThrottle);
mem.start();
return mem;
}
use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.
the class GridHashMapLoadTest method testMapEntry.
/**
* @throws Exception If failed.
*/
@Test
public void testMapEntry() throws Exception {
Map<Integer, GridCacheMapEntry> map = new HashMap<>(5 * 1024 * 1024);
int i = 0;
GridCacheTestContext<Integer, Integer> ctx = new GridCacheTestContext<>(new GridTestKernalContext(new GridTestLog4jLogger()));
while (true) {
Integer key = i++;
map.put(key, new GridCacheMapEntry(ctx, ctx.toCacheKeyObject(key)) {
@Override
public boolean tmLock(IgniteInternalTx tx, long timeout, @Nullable GridCacheVersion serOrder, GridCacheVersion serReadVer, boolean read) {
return false;
}
@Override
protected void checkThreadChain(GridCacheMvccCandidate owner) {
// No-op.
}
@Override
public void txUnlock(IgniteInternalTx tx) {
// No-op.
}
@Override
public boolean removeLock(GridCacheVersion ver) {
return false;
}
});
if (i % 100000 == 0)
info("Inserted objects: " + i / 2);
}
}
use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.
the class GridLogCommandHandlerTest method testHandleAsyncPathNotSet.
/**
* @throws Exception If failed.
*/
@Test
public void testHandleAsyncPathNotSet() throws Exception {
GridTestKernalContext ctx = newContext();
ctx.config().setIgniteHome(igniteHome);
GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx);
GridRestLogRequest req = new GridRestLogRequest();
req.to(5);
req.from(2);
IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req);
assertNull(resp.result().getError());
assertEquals(GridRestResponse.STATUS_SUCCESS, resp.result().getSuccessStatus());
assertNotNull(resp.result().getResponse());
}
use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.
the class GridLogCommandHandlerTest method testHandleAsyncForNonExistingLines.
/**
* @throws Exception If failed.
*/
@Test
public void testHandleAsyncForNonExistingLines() throws Exception {
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setIgniteHome(igniteHome);
GridTestKernalContext ctx = newContext(cfg);
GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx);
GridRestLogRequest req = new GridRestLogRequest();
req.to(50);
req.from(20);
req.path(igniteHome + "/work/log/" + "test.log");
IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req);
assertEquals("Request parameter 'from' and 'to' are for lines that do not exist in log file.", resp.result().getError());
assertEquals(GridRestResponse.STATUS_FAILED, resp.result().getSuccessStatus());
assertNull(resp.result().getResponse());
}
use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.
the class GridLogCommandHandlerTest method testHandleAsyncFromGreaterThanTo.
/**
* @throws Exception If failed.
*/
@Test
public void testHandleAsyncFromGreaterThanTo() throws Exception {
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setIgniteHome(igniteHome);
GridTestKernalContext ctx = newContext(cfg);
GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx);
GridRestLogRequest req = new GridRestLogRequest();
req.to(5);
req.from(7);
req.path(igniteHome + "/work/log/" + "test.log");
IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req);
assertEquals("Request parameter 'from' must be less than 'to'.", resp.result().getError());
assertEquals(GridRestResponse.STATUS_FAILED, resp.result().getSuccessStatus());
assertNull(resp.result().getResponse());
}
Aggregations