Search in sources :

Example 6 with GridTestKernalContext

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

the class GridLogCommandHandlerTest method testHandleAsyncFromGreaterThanTo.

/**
     * @throws Exception If failed.
     */
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());
}
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)

Example 7 with GridTestKernalContext

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

the class GridLogCommandHandlerTest method testHandleAsyncForNonExistingLines.

/**
     * @throws Exception If failed.
     */
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());
}
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)

Example 8 with GridTestKernalContext

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

the class GridQueryCommandHandlerTest method testSupportedCommands.

/**
     * @throws Exception If failed.
     */
public void testSupportedCommands() throws Exception {
    GridTestKernalContext ctx = newContext(grid().configuration());
    ctx.add(new GridTimeoutProcessor(ctx));
    QueryCommandHandler cmdHnd = new QueryCommandHandler(ctx);
    Collection<GridRestCommand> commands = cmdHnd.supportedCommands();
    assertEquals(5, commands.size());
    assertTrue(commands.contains(GridRestCommand.EXECUTE_SQL_QUERY));
    assertTrue(commands.contains(GridRestCommand.EXECUTE_SQL_FIELDS_QUERY));
    assertTrue(commands.contains(GridRestCommand.EXECUTE_SCAN_QUERY));
    assertTrue(commands.contains(GridRestCommand.FETCH_SQL_QUERY));
    assertTrue(commands.contains(GridRestCommand.CLOSE_SQL_QUERY));
}
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)

Example 9 with GridTestKernalContext

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

the class BinaryMarshallerSelfTest method binaryMarshaller.

/**
     * @return Binary marshaller.
     */
protected BinaryMarshaller binaryMarshaller(BinaryNameMapper nameMapper, BinaryIdMapper mapper, BinarySerializer serializer, Collection<BinaryTypeConfiguration> cfgs, Collection<String> excludedClasses) throws IgniteCheckedException {
    IgniteConfiguration iCfg = new IgniteConfiguration();
    BinaryConfiguration bCfg = new BinaryConfiguration();
    bCfg.setNameMapper(nameMapper);
    bCfg.setIdMapper(mapper);
    bCfg.setSerializer(serializer);
    bCfg.setCompactFooter(compactFooter());
    bCfg.setTypeConfigurations(cfgs);
    iCfg.setBinaryConfiguration(bCfg);
    iCfg.setClientMode(false);
    iCfg.setDiscoverySpi(new TcpDiscoverySpi() {

        @Override
        public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException {
        //No-op.
        }
    });
    BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), iCfg, new NullLogger());
    BinaryMarshaller marsh = new BinaryMarshaller();
    MarshallerContextTestImpl marshCtx = new MarshallerContextTestImpl(null, excludedClasses);
    GridTestKernalContext kernCtx = new GridTestKernalContext(log, iCfg);
    kernCtx.add(new GridDiscoveryManager(kernCtx));
    marshCtx.onMarshallerProcessorStarted(kernCtx, null);
    marsh.setContext(marshCtx);
    IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, iCfg);
    return marsh;
}
Also used : DiscoverySpiCustomMessage(org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage) GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) NullLogger(org.apache.ignite.logger.NullLogger) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) IgniteException(org.apache.ignite.IgniteException) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) MarshallerContextTestImpl(org.apache.ignite.marshaller.MarshallerContextTestImpl) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 10 with GridTestKernalContext

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

the class GridHashMapLoadTest method testMapEntry.

/**
     * @throws Exception If failed.
     */
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);
    }
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) IgniteInternalTx(org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx) GridCacheMapEntry(org.apache.ignite.internal.processors.cache.GridCacheMapEntry) GridTestLog4jLogger(org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger) GridCacheMvccCandidate(org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate)

Aggregations

GridTestKernalContext (org.apache.ignite.testframework.junits.GridTestKernalContext)19 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)10 GridRestResponse (org.apache.ignite.internal.processors.rest.GridRestResponse)7 GridRestLogRequest (org.apache.ignite.internal.processors.rest.request.GridRestLogRequest)7 GridTimeoutProcessor (org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor)3 HashMap (java.util.HashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 IgniteException (org.apache.ignite.IgniteException)2 GridDiscoveryManager (org.apache.ignite.internal.managers.discovery.GridDiscoveryManager)2 GridClosureProcessor (org.apache.ignite.internal.processors.closure.GridClosureProcessor)2 PoolProcessor (org.apache.ignite.internal.processors.pool.PoolProcessor)2 GridResourceProcessor (org.apache.ignite.internal.processors.resource.GridResourceProcessor)2 GridRestCommand (org.apache.ignite.internal.processors.rest.GridRestCommand)2 NullLogger (org.apache.ignite.logger.NullLogger)2 MarshallerContextTestImpl (org.apache.ignite.marshaller.MarshallerContextTestImpl)2 DiscoverySpiCustomMessage (org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage)2 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 IgniteLogger (org.apache.ignite.IgniteLogger)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1