This is an automated email from the ASF dual-hosted git repository. agoncharuk pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push: new 5bb8464 IGNITE-12522 Extend test coverage for IGNITE-12104 - Fixes #7233. 5bb8464 is described below commit 5bb8464150c523f04bbc09d54474d836ad79f101 Author: Vladislav Pyatkov <vldpyat...@gmail.com> AuthorDate: Tue Feb 11 12:27:27 2020 +0300 IGNITE-12522 Extend test coverage for IGNITE-12104 - Fixes #7233. Signed-off-by: Alexey Goncharuk <alexey.goncha...@gmail.com> --- ...ntTiesLoadClassDirectlyFromClassLoaderTest.java | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PCountTiesLoadClassDirectlyFromClassLoaderTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PCountTiesLoadClassDirectlyFromClassLoaderTest.java index 6f4e91b..e3330b4 100644 --- a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PCountTiesLoadClassDirectlyFromClassLoaderTest.java +++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PCountTiesLoadClassDirectlyFromClassLoaderTest.java @@ -19,7 +19,11 @@ package org.apache.ignite.p2p; import java.net.URL; import java.net.URLClassLoader; +import java.util.Map; +import java.util.UUID; import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteDeploymentException; +import org.apache.ignite.compute.ComputeTask; import org.apache.ignite.configuration.DeploymentMode; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.typedef.internal.U; @@ -40,6 +44,9 @@ public class GridP2PCountTiesLoadClassDirectlyFromClassLoaderTest extends GridCo /** Compute task name. */ private static String COMPUTE_TASK_NAME = "org.apache.ignite.tests.p2p.compute.ExternalCallable"; + /** Compute task name. */ + private static String COMPUTE_STEALING_TASK_NAME = "org.apache.ignite.tests.p2p.JobStealingTask"; + /** Deployment mode. */ private DeploymentMode depMode; @@ -88,6 +95,83 @@ public class GridP2PCountTiesLoadClassDirectlyFromClassLoaderTest extends GridCo } /** + * @throws Exception if error occurs. + */ + public void executeP2PTaskWithRestartMaster(DeploymentMode depMode) throws Exception { + try { + CountTriesClassLoader testCntLdr = new CountTriesClassLoader(Thread.currentThread() + .getContextClassLoader()); + + this.depMode = depMode; + + Thread.currentThread().setContextClassLoader(testCntLdr); + + String path = GridTestProperties.getProperty(CLS_PATH_PROPERTY); + + ClassLoader urlClsLdr = new URLClassLoader(new URL[] {new URL(path)}, testCntLdr); + + Ignite ignite = startGrids(2); + + Map<UUID, Integer> res = (Map<UUID, Integer>)ignite.compute(ignite.cluster().forRemotes()).execute( + (ComputeTask<Integer, Object>)urlClsLdr.loadClass(COMPUTE_STEALING_TASK_NAME).newInstance(), 1); + + info("Result: " + res); + + int cnt = testCntLdr.count; + + ignite.compute(ignite.cluster().forRemotes()).execute(COMPUTE_STEALING_TASK_NAME, 2); + ignite.compute(ignite.cluster().forRemotes()).execute(COMPUTE_STEALING_TASK_NAME, 3); + ignite.compute(ignite.cluster().forRemotes()).execute(COMPUTE_STEALING_TASK_NAME, 4); + + assertEquals(cnt, testCntLdr.count); + + ignite.close(); + + ignite = startGrid(0); + + try { + ignite.compute().execute(COMPUTE_STEALING_TASK_NAME, 5); + + if (depMode != DeploymentMode.CONTINUOUS) + fail("Task should be undeployed."); + } + catch (IgniteDeploymentException e) { + if (depMode != DeploymentMode.CONTINUOUS) + assertTrue(e.getMessage(), e.getMessage().contains("Unknown task name or failed to auto-deploy task")); + else + fail(e.getMessage()); + } + } + finally { + stopAllGrids(); + } + } + + /** + * @throws Exception if error occur. + */ + @Test + public void testRestartPrivateMode() throws Exception { + executeP2PTaskWithRestartMaster(DeploymentMode.PRIVATE); + } + + /** + * @throws Exception if error occur. + */ + @Test + public void testRestartIsolatedMode() throws Exception { + executeP2PTaskWithRestartMaster(DeploymentMode.ISOLATED); + } + + /** + * @throws Exception if error occur. + */ + @Test + public void testRestartSharedMode() throws Exception { + executeP2PTaskWithRestartMaster(DeploymentMode.SHARED); + } + + /** * @throws Exception if error occur. */ @Test