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());
}
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));
}
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);
}
}
}
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));
}
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());
}
Aggregations