Пример #1
0
        public void TestExecuteException()
        {
            var svc = new TestIgniteServiceSerializable {
                ThrowExecute = true
            };

            Services.DeployMultiple(SvcName, svc, Grids.Length, 1);

            var svc0 = Services.GetService <TestIgniteServiceSerializable>(SvcName);

            // Execution failed, but service exists.
            Assert.IsNotNull(svc0);
            Assert.IsFalse(svc0.Executed);
        }
Пример #2
0
        public void TestInitException()
        {
            var svc = new TestIgniteServiceSerializable {
                ThrowInit = true
            };

            var ex = Assert.Throws <IgniteException>(() => Services.DeployMultiple(SvcName, svc, Grids.Length, 1));

            Assert.AreEqual("Expected exception", ex.Message);

            var svc0 = Services.GetService <TestIgniteServiceSerializable>(SvcName);

            Assert.IsNull(svc0);
        }
Пример #3
0
        public void TestCancelException()
        {
            var svc = new TestIgniteServiceSerializable {
                ThrowCancel = true
            };

            Services.DeployMultiple(SvcName, svc, 2, 1);

            CheckServiceStarted(Grid1);

            Services.CancelAll();

            // Cancellation failed, but service is removed.
            AssertNoService();
        }
Пример #4
0
        public void TestInitException()
        {
            var svc = new TestIgniteServiceSerializable {
                ThrowInit = true
            };

            var ex = Assert.Throws <IgniteException>(() => Services.DeployMultiple(SvcName, svc, Grids.Length, 1));

            Assert.AreEqual("Expected exception", ex.Message);
            Assert.IsTrue(ex.InnerException.Message.Contains("PlatformCallbackUtils.serviceInit(Native Method)"));

            var svc0 = Services.GetService <TestIgniteServiceSerializable>(SvcName);

            Assert.IsNull(svc0);
        }
Пример #5
0
        /// <summary>
        /// Verifies the deployment exception.
        /// </summary>
        private void VerifyDeploymentException(Action <IServices, IService> deploy, bool keepBinary)
        {
            var svc = new TestIgniteServiceSerializable {
                ThrowInit = true
            };

            var services = Services;

            if (keepBinary)
            {
                services = services.WithKeepBinary();
            }

            var deploymentException = Assert.Throws <ServiceDeploymentException>(() => deploy(services, svc));

            var text = keepBinary
                ? "Service deployment failed with a binary error. Examine BinaryCause for details."
                : "Service deployment failed with an exception. Examine InnerException for details.";

            Assert.AreEqual(text, deploymentException.Message);

            Exception ex;

            if (keepBinary)
            {
                Assert.IsNull(deploymentException.InnerException);

                ex = deploymentException.BinaryCause.Deserialize <Exception>();
            }
            else
            {
                Assert.IsNull(deploymentException.BinaryCause);

                ex = deploymentException.InnerException;
            }

            Assert.IsNotNull(ex);
            Assert.AreEqual("Expected exception", ex.Message);
            Assert.IsTrue(ex.StackTrace.Trim().StartsWith(
                              "at Apache.Ignite.Core.Tests.Services.ServicesTest.TestIgniteServiceSerializable.Init"));

            var svc0 = Services.GetService <TestIgniteServiceSerializable>(SvcName);

            Assert.IsNull(svc0);
        }
Пример #6
0
        public void TestCancelException()
        {
            var svc = new TestIgniteServiceSerializable {
                ThrowCancel = true
            };

            Services.DeployMultiple(SvcName, svc, Grids.Length, 1);

            CheckServiceStarted(Grid1);

            Services.CancelAll();

            // Cancellation failed, but service is removed.
            foreach (var grid in Grids)
            {
                Assert.IsNull(grid.GetServices().GetService <ITestIgniteService>(SvcName));
            }
        }
Пример #7
0
        public void TestDeployClusterSingleton()
        {
            var svc = new TestIgniteServiceSerializable();

            Services.DeployClusterSingleton(SvcName, svc);

            var svc0 = Services.GetServiceProxy <ITestIgniteService>(SvcName);

            // Check that only one node has the service.
            foreach (var grid in Grids)
            {
                if (grid.GetCluster().GetLocalNode().Id == svc0.NodeId)
                {
                    CheckServiceStarted(grid);
                }
                else
                {
                    Assert.IsNull(grid.GetServices().GetService <TestIgniteServiceSerializable>(SvcName));
                }
            }
        }
Пример #8
0
        public void TestCancelException()
        {
            var svc = new TestIgniteServiceSerializable { ThrowCancel = true };

            Services.DeployMultiple(SvcName, svc, 2, 1);

            CheckServiceStarted(Grid1);

            Services.CancelAll();

            // Cancellation failed, but service is removed.
            AssertNoService();
        }
Пример #9
0
        public void TestExecuteException()
        {
            var svc = new TestIgniteServiceSerializable { ThrowExecute = true };

            Services.DeployMultiple(SvcName, svc, Grids.Length, 1);

            var svc0 = Services.GetService<TestIgniteServiceSerializable>(SvcName);

            // Execution failed, but service exists.
            Assert.IsNotNull(svc0);
            Assert.IsFalse(svc0.Executed);
        }
Пример #10
0
        public void TestInitException()
        {
            var svc = new TestIgniteServiceSerializable { ThrowInit = true };

            var ex = Assert.Throws<IgniteException>(() => Services.DeployMultiple(SvcName, svc, Grids.Length, 1));
            Assert.AreEqual("Expected exception", ex.Message);

            var svc0 = Services.GetService<TestIgniteServiceSerializable>(SvcName);

            Assert.IsNull(svc0);
        }
Пример #11
0
        public void TestDeployMultiple()
        {
            var svc = new TestIgniteServiceSerializable();

            Services.DeployMultiple(SvcName, svc, Grids.Length * 5, 5);

            foreach (var grid in Grids.Where(x => !x.GetConfiguration().ClientMode))
                CheckServiceStarted(grid, 5);
        }
Пример #12
0
        public void TestDeployNodeSingleton()
        {
            var svc = new TestIgniteServiceSerializable();

            Services.DeployNodeSingleton(SvcName, svc);

            Assert.AreEqual(1, Grid1.GetServices().GetServices<ITestIgniteService>(SvcName).Count);
            Assert.AreEqual(1, Grid2.GetServices().GetServices<ITestIgniteService>(SvcName).Count);
            Assert.AreEqual(0, Grid3.GetServices().GetServices<ITestIgniteService>(SvcName).Count);
        }
Пример #13
0
        public void TestDeployClusterSingleton()
        {
            var svc = new TestIgniteServiceSerializable();

            Services.DeployClusterSingleton(SvcName, svc);

            var svc0 = Services.GetServiceProxy<ITestIgniteService>(SvcName);

            // Check that only one node has the service.
            foreach (var grid in Grids)
            {
                if (grid.GetCluster().GetLocalNode().Id == svc0.NodeId)
                    CheckServiceStarted(grid);
                else
                    Assert.IsNull(grid.GetServices().GetService<TestIgniteServiceSerializable>(SvcName));
            }
        }
Пример #14
0
        public void TestInitException()
        {
            var svc = new TestIgniteServiceSerializable { ThrowInit = true };

            var ex = Assert.Throws<IgniteException>(() => Services.DeployMultiple(SvcName, svc, Grids.Length, 1));
            Assert.AreEqual("Expected exception", ex.Message);
            Assert.IsNotNull(ex.InnerException);
            Assert.IsTrue(ex.InnerException.Message.Contains("PlatformCallbackUtils.serviceInit(Native Method)"));

            var svc0 = Services.GetService<TestIgniteServiceSerializable>(SvcName);

            Assert.IsNull(svc0);
        }
Пример #15
0
        public void TestCancelException()
        {
            var svc = new TestIgniteServiceSerializable { ThrowCancel = true };

            Services.DeployMultiple(SvcName, svc, Grids.Length, 1);

            CheckServiceStarted(Grid1);

            Services.CancelAll();

            // Cancellation failed, but service is removed.
            foreach (var grid in Grids)
                Assert.IsNull(grid.GetServices().GetService<ITestIgniteService>(SvcName));
        }
Пример #16
0
        public void TestDeployMultiple()
        {
            var svc = new TestIgniteServiceSerializable();

            Services.DeployMultiple(SvcName, svc, Grids.Length * 5, 5);

            foreach (var grid in Grids)
                CheckServiceStarted(grid, 5);
        }