/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); hndLatch = new CountDownLatch(1); startGrid(0); }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); stopAllGrids(); }
/** * @throws Exception If failed. */ @Test public void testBlockingWorker() throws Exception { IgniteEx ignite = grid(0); GridWorker worker = new GridWorker(ignite.name(), "test-worker", log) { @Override protected void body() throws InterruptedException { Thread.sleep(Long.MAX_VALUE); } }; new IgniteThread(worker).start(); while (worker.runner() == null) Thread.sleep(10); ignite.context().workersRegistry().register(worker); assertTrue(hndLatch.await(ignite.configuration().getFailureDetectionTimeout() * 2, TimeUnit.MILLISECONDS)); Thread runner = worker.runner(); runner.interrupt(); runner.join(1000); assertFalse(runner.isAlive()); } }