Search in sources :

Example 36 with GridTestKernalContext

use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.

the class GridLogCommandHandlerTest method testHandleAsyncFromEqualTo.

/**
 * @throws Exception If failed.
 */
@Test
public void testHandleAsyncFromEqualTo() 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(5);
    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());
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) GridRestResponse(org.apache.ignite.internal.processors.rest.GridRestResponse) GridRestLogRequest(org.apache.ignite.internal.processors.rest.request.GridRestLogRequest) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 37 with GridTestKernalContext

use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.

the class CacheFreeListSelfTest method createPageMemory.

/**
 * @return Page memory.
 */
protected PageMemory createPageMemory(int pageSize, DataRegionConfiguration plcCfg) {
    PageMemory pageMem = new PageMemoryNoStoreImpl(log, new UnsafeMemoryProvider(log), null, pageSize, plcCfg, new DataRegionMetricsImpl(plcCfg, new GridTestKernalContext(log())), true);
    pageMem.start();
    return pageMem;
}
Also used : PageMemoryNoStoreImpl(org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) DataRegionMetricsImpl(org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl) UnsafeMemoryProvider(org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider)

Example 38 with GridTestKernalContext

use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.

the class CacheFreeListSelfTest method createFreeList.

/**
 * @param pageSize Page size.
 * @return Free list.
 * @throws Exception If failed.
 */
private FreeList<CacheDataRow> createFreeList(int pageSize) throws Exception {
    DataRegionConfiguration plcCfg = new DataRegionConfiguration().setInitialSize(1024 * MB).setMaxSize(1024 * MB);
    pageMem = createPageMemory(pageSize, plcCfg);
    long metaPageId = pageMem.allocatePage(1, 1, PageIdAllocator.FLAG_DATA);
    IgniteConfiguration cfg = new IgniteConfiguration().setMetricExporterSpi(new NoopMetricExporterSpi());
    GridTestKernalContext ctx = new GridTestKernalContext(new GridTestLog4jLogger(), cfg);
    ctx.add(new GridMetricManager(ctx));
    ctx.add(new PerformanceStatisticsProcessor(ctx));
    DataRegionMetricsImpl regionMetrics = new DataRegionMetricsImpl(plcCfg, ctx);
    DataRegion dataRegion = new DataRegion(pageMem, plcCfg, regionMetrics, new NoOpPageEvictionTracker());
    PageLockTrackerManager pageLockTrackerManager = mock(PageLockTrackerManager.class);
    when(pageLockTrackerManager.createPageLockTracker(anyString())).thenReturn(PageLockTrackerManager.NOOP_LSNR);
    return new CacheFreeList(1, "freelist", dataRegion, null, metaPageId, true, pageLockTrackerManager, new GridTestKernalContext(log), null, PageIdAllocator.FLAG_IDX);
}
Also used : GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) CacheFreeList(org.apache.ignite.internal.processors.cache.persistence.freelist.CacheFreeList) DataRegionMetricsImpl(org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl) PageLockTrackerManager(org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.PageLockTrackerManager) PerformanceStatisticsProcessor(org.apache.ignite.internal.processors.performancestatistics.PerformanceStatisticsProcessor) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) NoOpPageEvictionTracker(org.apache.ignite.internal.processors.cache.persistence.evict.NoOpPageEvictionTracker) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) NoopMetricExporterSpi(org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi) GridMetricManager(org.apache.ignite.internal.processors.metric.GridMetricManager) GridTestLog4jLogger(org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger) DataRegion(org.apache.ignite.internal.processors.cache.persistence.DataRegion)

Example 39 with GridTestKernalContext

use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.

the class IndexStorageSelfTest method memory.

/**
 * @param clean Clean flag. If {@code true}, will clean previous memory state and allocate
 *      new empty page memory.
 * @return Page memory instance.
 */
protected PageMemory memory(boolean clean) throws Exception {
    DirectMemoryProvider provider = new MappedFileMemoryProvider(log(), allocationPath);
    DataRegionConfiguration plcCfg = new DataRegionConfiguration().setMaxSize(30L * 1024 * 1024).setInitialSize(30L * 1024 * 1024);
    return new PageMemoryNoStoreImpl(log, provider, null, PAGE_SIZE, plcCfg, new DataRegionMetricsImpl(plcCfg, new GridTestKernalContext(log())), true);
}
Also used : MappedFileMemoryProvider(org.apache.ignite.internal.mem.file.MappedFileMemoryProvider) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) PageMemoryNoStoreImpl(org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl) DirectMemoryProvider(org.apache.ignite.internal.mem.DirectMemoryProvider) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) DataRegionMetricsImpl(org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl)

Example 40 with GridTestKernalContext

use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.

the class GridDeploymentManagerStopSelfTest method testOnKernalStop.

/**
 * @throws Exception If failed.
 */
@Test
public void testOnKernalStop() throws Exception {
    DeploymentSpi spi = new GridTestDeploymentSpi();
    GridTestKernalContext ctx = newContext();
    ctx.config().setMarshaller(new JdkMarshaller());
    ctx.config().setDeploymentSpi(spi);
    GridResourceProcessor resProc = new GridResourceProcessor(ctx);
    resProc.setSpringContext(null);
    ctx.add(resProc);
    GridComponent mgr = new GridDeploymentManager(ctx);
    try {
        mgr.onKernalStop(true);
    } catch (Exception e) {
        error("Error during onKernalStop() callback.", e);
        assert false : "Unexpected exception " + e;
    }
}
Also used : GridComponent(org.apache.ignite.internal.GridComponent) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) JdkMarshaller(org.apache.ignite.marshaller.jdk.JdkMarshaller) GridResourceProcessor(org.apache.ignite.internal.processors.resource.GridResourceProcessor) DeploymentSpi(org.apache.ignite.spi.deployment.DeploymentSpi) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) GridCommonTest(org.apache.ignite.testframework.junits.common.GridCommonTest)

Aggregations

GridTestKernalContext (org.apache.ignite.testframework.junits.GridTestKernalContext)48 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)22 Test (org.junit.Test)21 DataRegionMetricsImpl (org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl)20 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)17 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)15 UnsafeMemoryProvider (org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider)14 PageMemory (org.apache.ignite.internal.pagemem.PageMemory)12 PageMemoryNoStoreImpl (org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl)11 DirectMemoryProvider (org.apache.ignite.internal.mem.DirectMemoryProvider)8 GridTimeoutProcessor (org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor)8 HashMap (java.util.HashMap)7 GridSystemViewManager (org.apache.ignite.internal.managers.systemview.GridSystemViewManager)7 JmxSystemViewExporterSpi (org.apache.ignite.internal.managers.systemview.JmxSystemViewExporterSpi)7 GridRestResponse (org.apache.ignite.internal.processors.rest.GridRestResponse)7 GridRestLogRequest (org.apache.ignite.internal.processors.rest.request.GridRestLogRequest)7 NoopMetricExporterSpi (org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi)7 ClusterNode (org.apache.ignite.cluster.ClusterNode)6 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)6 IndexKeyTypeSettings (org.apache.ignite.internal.cache.query.index.sorted.IndexKeyTypeSettings)6