Search in sources :

Example 11 with GridTestKernalContext

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

the class GridLogCommandHandlerTest method testHandleAsyncPathNotSet.

/**
     * @throws Exception If failed.
     */
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());
}
Also used : 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 12 with GridTestKernalContext

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

the class MarshallerContextLockingSelfTest method beforeTest.

/** {@inheritDoc} */
@Override
protected void beforeTest() throws Exception {
    innerLog = new InnerLogger();
    IgniteConfiguration iCfg = new IgniteConfiguration();
    iCfg.setClientMode(false);
    ctx = new GridTestKernalContext(innerLog, iCfg) {

        @Override
        public IgniteLogger log(Class<?> cls) {
            return innerLog;
        }
    };
    ctx.setSystemExecutorService(Executors.newFixedThreadPool(THREADS));
    ctx.add(new PoolProcessor(ctx));
    ctx.add(new GridClosureProcessor(ctx));
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridClosureProcessor(org.apache.ignite.internal.processors.closure.GridClosureProcessor) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) PoolProcessor(org.apache.ignite.internal.processors.pool.PoolProcessor) IgniteLogger(org.apache.ignite.IgniteLogger)

Example 13 with GridTestKernalContext

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

the class GridTcpCommunicationSpiMultithreadedSelfTest method beforeTestsStarted.

/** {@inheritDoc} */
@Override
protected void beforeTestsStarted() throws Exception {
    spis.clear();
    nodes.clear();
    spiRsrcs.clear();
    lsnrs.clear();
    Map<ClusterNode, GridSpiTestContext> ctxs = new HashMap<>();
    timeoutProcessor = new GridTimeoutProcessor(new GridTestKernalContext(log));
    timeoutProcessor.start(true);
    timeoutProcessor.onKernalStart(true);
    for (int i = 0; i < getSpiCount(); i++) {
        CommunicationSpi<Message> spi = newCommunicationSpi();
        GridTestUtils.setFieldValue(spi, IgniteSpiAdapter.class, "igniteInstanceName", "grid-" + i);
        IgniteTestResources rsrcs = new IgniteTestResources();
        GridTestNode node = new GridTestNode(rsrcs.getNodeId());
        node.order(i);
        GridSpiTestContext ctx = initSpiContext();
        ctx.timeoutProcessor(timeoutProcessor);
        ctx.setLocalNode(node);
        info(">>> Initialized context: nodeId=" + ctx.localNode().id());
        spiRsrcs.add(rsrcs);
        rsrcs.inject(spi);
        MessageListener lsnr = new MessageListener(rsrcs.getNodeId());
        spi.setListener(lsnr);
        lsnrs.put(rsrcs.getNodeId(), lsnr);
        info("Lsnrs: " + lsnrs);
        node.setAttributes(spi.getNodeAttributes());
        node.setAttribute(ATTR_MACS, F.concat(U.allLocalMACs(), ", "));
        nodes.add(node);
        spi.spiStart(getTestIgniteInstanceName() + (i + 1));
        spis.put(rsrcs.getNodeId(), spi);
        spi.onContextInitialized(ctx);
        ctxs.put(node, ctx);
    }
    // For each context set remote nodes.
    for (Entry<ClusterNode, GridSpiTestContext> e : ctxs.entrySet()) {
        for (ClusterNode n : nodes) {
            if (!n.equals(e.getKey()))
                e.getValue().remoteNodes().add(n);
        }
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridSpiTestContext(org.apache.ignite.testframework.GridSpiTestContext) GridTimeoutProcessor(org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor) GridTestMessage(org.apache.ignite.spi.communication.GridTestMessage) Message(org.apache.ignite.plugin.extensions.communication.Message) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) GridTestNode(org.apache.ignite.testframework.GridTestNode) IgniteTestResources(org.apache.ignite.testframework.junits.IgniteTestResources)

Example 14 with GridTestKernalContext

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

the class GridQueryCommandHandlerTest method testUnsupportedCommands.

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

Example 15 with GridTestKernalContext

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

the class GridLogCommandHandlerTest method testHandleAsyncFromAndToNotSet.

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

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