Search in sources :

Example 31 with GridTestKernalContext

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

the class InlineIndexColumnTest method testBytes.

/**
 */
@Test
public void testBytes() throws Exception {
    DataRegionConfiguration plcCfg = new DataRegionConfiguration().setInitialSize(1024 * MB).setMaxSize(1024 * MB);
    PageMemory pageMem = new PageMemoryNoStoreImpl(log, new UnsafeMemoryProvider(log), null, PAGE_SIZE, plcCfg, new DataRegionMetricsImpl(plcCfg, new GridTestKernalContext(log())), false);
    pageMem.start();
    long pageId = 0L;
    long page = 0L;
    try {
        pageId = pageMem.allocatePage(CACHE_ID, 1, PageIdAllocator.FLAG_DATA);
        page = pageMem.acquirePage(CACHE_ID, pageId);
        long pageAddr = pageMem.readLock(CACHE_ID, pageId, page);
        int off = 0;
        IndexKeyTypeSettings keyTypeSettings = new IndexKeyTypeSettings().inlineObjHash(false).stringOptimizedCompare(false);
        InlineIndexKeyType keyType = InlineIndexKeyTypeRegistry.get(Value.BYTES, keyTypeSettings);
        int maxSize = 3 + 3;
        int savedBytesCnt = keyType.put(pageAddr, off, idxKey(ValueBytes.get(new byte[] { 1, 2, 3, 4, 5 }), keyTypeSettings), maxSize);
        assertTrue(savedBytesCnt > 0);
        assertTrue(savedBytesCnt <= maxSize);
        maxSize = 3 + 5;
        assertTrue(Arrays.equals(new byte[] { 1, 2, 3 }, (byte[]) keyType.get(pageAddr, off, maxSize).key()));
        savedBytesCnt = keyType.put(pageAddr, off, idxKey(ValueBytes.get(new byte[] { 1, 2, 3, 4, 5 }), keyTypeSettings), maxSize);
        assertTrue(savedBytesCnt > 0);
        assertTrue(savedBytesCnt <= maxSize);
        assertTrue(Arrays.equals(new byte[] { 1, 2, 3, 4, 5 }, (byte[]) keyType.get(pageAddr, off, maxSize).key()));
    } finally {
        if (page != 0L)
            pageMem.releasePage(CACHE_ID, pageId, page);
        pageMem.stop(true);
    }
}
Also used : DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) PageMemoryNoStoreImpl(org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl) StringInlineIndexKeyType(org.apache.ignite.internal.cache.query.index.sorted.inline.types.StringInlineIndexKeyType) InlineIndexKeyType(org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndexKeyType) 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) IndexKeyTypeSettings(org.apache.ignite.internal.cache.query.index.sorted.IndexKeyTypeSettings) AbstractIndexingCommonTest(org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest) Test(org.junit.Test)

Example 32 with GridTestKernalContext

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

the class GridLogCommandHandlerTest method testHandleAsyncFromAndToNotSet.

/**
 * @throws Exception If failed.
 */
@Test
public void testHandleAsyncFromAndToNotSet() throws Exception {
    IgniteConfiguration cfg = new IgniteConfiguration();
    cfg.setIgniteHome(igniteHome);
    GridTestKernalContext ctx = newContext(cfg);
    GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx);
    GridRestLogRequest req = new GridRestLogRequest();
    req.path(igniteHome + "/work/log/" + "test.log");
    IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req);
    assertNull(resp.result().getError());
    assertEquals(GridRestResponse.STATUS_SUCCESS, resp.result().getSuccessStatus());
    assertNotNull(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 33 with GridTestKernalContext

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

the class GridQueryCommandHandlerTest method testUnsupportedCommands.

/**
 * @throws Exception If failed.
 */
@Test
public void testUnsupportedCommands() throws Exception {
    GridTestKernalContext ctx = newContext(grid().configuration());
    ctx.add(new GridTimeoutProcessor(ctx));
    QueryCommandHandler cmdHnd = new QueryCommandHandler(ctx);
    Collection<GridRestCommand> commands = cmdHnd.supportedCommands();
    assertFalse(commands.contains(GridRestCommand.LOG));
}
Also used : GridRestCommand(org.apache.ignite.internal.processors.rest.GridRestCommand) GridTimeoutProcessor(org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 34 with GridTestKernalContext

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

the class GridLogCommandHandlerTest method testHandleAsyncPathIsOutsideIgniteHome.

/**
 * @throws Exception If failed.
 */
@Test
public void testHandleAsyncPathIsOutsideIgniteHome() 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(2);
    req.path("/home/users/mytest.log");
    IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req);
    assertEquals("Request parameter 'path' must contain a path to valid log file.", 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 35 with GridTestKernalContext

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

the class GridLogCommandHandlerTest method testHandleAsync.

/**
 * @throws Exception If failed.
 */
@Test
public void testHandleAsync() 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(2);
    req.path(igniteHome + "/work/log/" + "test.log");
    IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req);
    assertNull(resp.result().getError());
    assertEquals(GridRestResponse.STATUS_SUCCESS, resp.result().getSuccessStatus());
    assertNotNull(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)

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