Exemplo n.º 1
0
            public override void run(string[] args)
            {
                var observer   = Instrumentation.getObserver();
                var properties = createTestProperties(ref args);

                properties["Ice.RetryIntervals"] = "0 1 10 1";
                properties["Ice.Warn.Dispatch"]  = "0";
                //
                // This test kills connections, so we don't want warnings.
                //
                properties["Ice.Warn.Connections"] = "0";
                using (var communicator = initialize(properties, observer: observer))
                {
                    //
                    // Configure a second communicator for the invocation timeout
                    // + retry test, we need to configure a large retry interval
                    // to avoid time-sensitive failures.
                    //
                    properties["Ice.RetryIntervals"] = "0 1 10000";
                    using (var communicator2 = initialize(properties, observer: observer))
                    {
                        communicator.createObjectAdapter("").Add(new RetryI(), "retry");
                        communicator2.createObjectAdapter("").Add(new RetryI(), "retry");
                        AllTests.allTests(this, communicator, communicator2, "retry").shutdown();
                    }
                }
            }
Exemplo n.º 2
0
Arquivo: Client.cs Projeto: zk2013/ice
            public override void run(string[] args)
            {
                var initData = new Ice.InitializationData();

                initData.observer = Instrumentation.getObserver();

                initData.properties = createTestProperties(ref args);
                initData.properties.setProperty("Ice.RetryIntervals", "0 1 10 1");

                //
                // This test kills connections, so we don't want warnings.
                //
                initData.properties.setProperty("Ice.Warn.Connections", "0");
                using (var communicator = initialize(initData))
                {
                    //
                    // Configure a second communicator for the invocation timeout
                    // + retry test, we need to configure a large retry interval
                    // to avoid time-sensitive failures.
                    //
                    initData.properties.setProperty("Ice.RetryIntervals", "0 1 10000");
                    initData.observer = Instrumentation.getObserver();
                    using (var communicator2 = initialize(initData))
                    {
                        var retry = AllTests.allTests(this, communicator, communicator2, "retry:" + getTestEndpoint(0));
                        retry.shutdown();
                    }
                }
            }
Exemplo n.º 3
0
            public override void run(string[] args)
            {
                var initData = new Ice.InitializationData();

                initData.observer = Instrumentation.getObserver();

                initData.properties = createTestProperties(ref args);
                initData.properties.setProperty("Ice.RetryIntervals", "0 1 10 1");
                initData.properties.setProperty("Ice.Warn.Dispatch", "0");

                //
                // This test kills connections, so we don't want warnings.
                //
                initData.properties.setProperty("Ice.Warn.Connections", "0");
                initData.properties.setProperty("Ice.Package.Test", "Ice.retry");
                using (var communicator = initialize(initData))
                {
                    //
                    // Configure a second communicator for the invocation timeout
                    // + retry test, we need to configure a large retry interval
                    // to avoid time-sensitive failures.
                    //
                    initData.properties.setProperty("Ice.RetryIntervals", "0 1 10000");
                    using (var communicator2 = initialize(initData))
                    {
                        communicator.createObjectAdapter("").add(new RetryI(), Ice.Util.stringToIdentity("retry"));
                        communicator2.createObjectAdapter("").add(new RetryI(), Ice.Util.stringToIdentity("retry"));

                        Test.RetryPrx retry = AllTests.allTests(this, communicator, communicator2, "retry");
                        retry.shutdown();
                    }
                }
            }
Exemplo n.º 4
0
Arquivo: Client.cs Projeto: yzun/ice
        public override void run(string[] args)
        {
            var properties = createTestProperties(ref args);

            properties["Ice.RetryIntervals"] = "0 1 10 1";

            //
            // This test kills connections, so we don't want warnings.
            //
            properties["Ice.Warn.Connections"] = "0";
            using var communicator             = initialize(properties, observer: Instrumentation.GetObserver());
            //
            // Configure a second communicator for the invocation timeout
            // + retry test, we need to configure a large retry interval
            // to avoid time-sensitive failures.
            //
            properties["Ice.RetryIntervals"] = "0 1 10000";
            using var communicator2          = initialize(properties, observer: Instrumentation.GetObserver());
            AllTests.allTests(this, communicator, communicator2, $"retry:{getTestEndpoint(0)}").shutdown();
        }
Exemplo n.º 5
0
            allTests(global::Test.TestHelper helper,
                     Ice.Communicator communicator,
                     Ice.Communicator communicator2,
                     string rf)
            {
                Instrumentation.testInvocationReset();

                var output = helper.getWriter();

                output.Write("testing stringToProxy... ");
                output.Flush();
                var base1 = communicator.stringToProxy(rf);

                test(base1 != null);
                var base2 = communicator.stringToProxy(rf);

                test(base2 != null);
                output.WriteLine("ok");

                output.Write("testing checked cast... ");
                output.Flush();
                Test.RetryPrx retry1 = Test.RetryPrxHelper.checkedCast(base1);
                test(retry1 != null);
                test(retry1.Equals(base1));
                Test.RetryPrx retry2 = Test.RetryPrxHelper.checkedCast(base2);
                test(retry2 != null);
                test(retry2.Equals(base2));
                output.WriteLine("ok");

                output.Write("calling regular operation with first proxy... ");
                output.Flush();
                retry1.op(false);
                output.WriteLine("ok");

                Instrumentation.testInvocationCount(3);

                output.Write("calling operation to kill connection with second proxy... ");
                output.Flush();
                try
                {
                    retry2.op(true);
                    test(false);
                }
                catch (Ice.UnknownLocalException)
                {
                    // Expected with collocation
                }
                catch (Ice.ConnectionLostException)
                {
                }
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(1);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                output.Write("calling regular operation with first proxy again... ");
                output.Flush();
                retry1.op(false);
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(0);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                output.Write("calling regular AMI operation with first proxy... ");
                retry1.opAsync(false).Wait();
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(0);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                output.Write("calling AMI operation to kill connection with second proxy... ");
                try
                {
                    retry2.opAsync(true).Wait();
                    test(false);
                }
                catch (System.AggregateException ex)
                {
                    test(ex.InnerException is ConnectionLostException ||
                         ex.InnerException is UnknownLocalException);
                }

                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(1);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                output.Write("calling regular AMI operation with first proxy again... ");
                retry1.opAsync(false).Wait();
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(0);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                output.Write("testing idempotent operation... ");
                test(retry1.opIdempotent(4) == 4);
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(0);
                Instrumentation.testRetryCount(4);
                test(retry1.opIdempotentAsync(4).Result == 4);
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(0);
                Instrumentation.testRetryCount(4);
                output.WriteLine("ok");

                output.Write("testing non-idempotent operation... ");
                try
                {
                    retry1.opNotIdempotent();
                    test(false);
                }
                catch (Ice.LocalException)
                {
                }
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(1);
                Instrumentation.testRetryCount(0);
                try
                {
                    retry1.opNotIdempotentAsync().Wait();
                    test(false);
                }
                catch (System.AggregateException ex)
                {
                    test(ex.InnerException is LocalException);
                }
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(1);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                if (retry1.ice_getConnection() == null)
                {
                    Instrumentation.testInvocationCount(1);

                    output.Write("testing system exception... ");
                    try
                    {
                        retry1.opSystemException();
                        test(false);
                    }
                    catch (SystemFailure)
                    {
                    }
                    Instrumentation.testInvocationCount(1);
                    Instrumentation.testFailureCount(1);
                    Instrumentation.testRetryCount(0);
                    try
                    {
                        retry1.opSystemExceptionAsync().Wait();
                        test(false);
                    }
                    catch (System.AggregateException ex)
                    {
                        test(ex.InnerException is SystemFailure);
                    }
                    Instrumentation.testInvocationCount(1);
                    Instrumentation.testFailureCount(1);
                    Instrumentation.testRetryCount(0);
                    output.WriteLine("ok");
                }

                {
                    output.Write("testing invocation timeout and retries... ");
                    output.Flush();

                    retry2 = Test.RetryPrxHelper.checkedCast(communicator2.stringToProxy(retry1.ToString()));
                    try
                    {
                        // No more than 2 retries before timeout kicks-in
                        ((Test.RetryPrx)retry2.ice_invocationTimeout(500)).opIdempotent(4);
                        test(false);
                    }
                    catch (InvocationTimeoutException)
                    {
                        Instrumentation.testRetryCount(2);
                        retry2.opIdempotent(-1); // Reset the counter
                        Instrumentation.testRetryCount(-1);
                    }
                    try
                    {
                        // No more than 2 retries before timeout kicks-in
                        Test.RetryPrx prx = (Test.RetryPrx)retry2.ice_invocationTimeout(500);
                        prx.opIdempotentAsync(4).Wait();
                        test(false);
                    }
                    catch (System.AggregateException ex)
                    {
                        test(ex.InnerException is InvocationTimeoutException);
                        Instrumentation.testRetryCount(2);
                        retry2.opIdempotent(-1); // Reset the counter
                        Instrumentation.testRetryCount(-1);
                    }
                    if (retry1.ice_getConnection() != null)
                    {
                        // The timeout might occur on connection establishment or because of the sleep. What's
                        // important here is to make sure there are 4 retries and that no calls succeed to
                        // ensure retries with the old connection timeout semantics work.
                        Test.RetryPrx retryWithTimeout =
                            (Test.RetryPrx)retry1.ice_invocationTimeout(-2).ice_timeout(200);
                        try
                        {
                            retryWithTimeout.sleep(500);
                            test(false);
                        }
                        catch (Ice.TimeoutException)
                        {
                        }
                        Instrumentation.testRetryCount(4);
                    }
                    output.WriteLine("ok");
                }
                return(retry1);
            }
Exemplo n.º 6
0
        allTests(global::Test.TestHelper helper,
                 Ice.Communicator communicator,
                 Ice.Communicator communicator2,
                 string rf)
        {
            Instrumentation.testInvocationReset();

            var output = helper.getWriter();

            output.Write("testing stringToProxy... ");
            output.Flush();
            var base1 = IObjectPrx.Parse(rf, communicator);
            var base2 = IObjectPrx.Parse(rf, communicator);

            output.WriteLine("ok");

            output.Write("testing checked cast... ");
            output.Flush();
            Test.IRetryPrx retry1 = Test.IRetryPrx.CheckedCast(base1);
            test(retry1.Equals(base1));
            Test.IRetryPrx retry2 = Test.IRetryPrx.CheckedCast(base2);
            test(retry2.Equals(base2));
            output.WriteLine("ok");

            output.Write("calling regular operation with first proxy... ");
            output.Flush();
            retry1.op(false);
            output.WriteLine("ok");

            Instrumentation.testInvocationCount(3);

            output.Write("calling operation to kill connection with second proxy... ");
            output.Flush();
            try
            {
                retry2.op(true);
                test(false);
            }
            catch (UnhandledException)
            {
                // Expected with collocation
            }
            catch (ConnectionLostException)
            {
            }
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(1);
            Instrumentation.testRetryCount(0);
            output.WriteLine("ok");

            output.Write("calling regular operation with first proxy again... ");
            output.Flush();
            retry1.op(false);
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(0);
            Instrumentation.testRetryCount(0);
            output.WriteLine("ok");

            output.Write("calling regular AMI operation with first proxy... ");
            retry1.opAsync(false).Wait();
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(0);
            Instrumentation.testRetryCount(0);
            output.WriteLine("ok");

            output.Write("calling AMI operation to kill connection with second proxy... ");
            try
            {
                retry2.opAsync(true).Wait();
                test(false);
            }
            catch (System.AggregateException ex)
            {
                test(ex.InnerException is ConnectionLostException ||
                     ex.InnerException is UnhandledException);
            }

            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(1);
            Instrumentation.testRetryCount(0);
            output.WriteLine("ok");

            output.Write("calling regular AMI operation with first proxy again... ");
            retry1.opAsync(false).Wait();
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(0);
            Instrumentation.testRetryCount(0);
            output.WriteLine("ok");

            output.Write("testing idempotent operation... ");
            test(retry1.opIdempotent(4) == 4);
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(0);
            Instrumentation.testRetryCount(4);
            test(retry1.opIdempotentAsync(4).Result == 4);
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(0);
            Instrumentation.testRetryCount(4);
            output.WriteLine("ok");

            if (retry1.GetCachedConnection() != null)
            {
                output.Write("testing non-idempotent operation with bi-dir proxy... ");
                try
                {
                    retry1.Clone(fixedConnection: retry1.GetCachedConnection()).opIdempotent(4);
                }
                catch (Ice.UnhandledException)
                {
                }
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(1);
                Instrumentation.testRetryCount(0);
                test(retry1.opIdempotent(4) == 4);
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(0);
                // It succeeded after 3 retry because of the failed opIdempotent on the fixed proxy above
                Instrumentation.testRetryCount(3);
                output.WriteLine("ok");
            }

            output.Write("testing non-idempotent operation... ");
            try
            {
                retry1.opNotIdempotent();
                test(false);
            }
            catch (Ice.UnhandledException)
            {
            }
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(1);
            Instrumentation.testRetryCount(0);
            try
            {
                retry1.opNotIdempotentAsync().Wait();
                test(false);
            }
            catch (System.AggregateException ex)
            {
                test(ex.InnerException is UnhandledException);
            }
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(1);
            Instrumentation.testRetryCount(0);
            output.WriteLine("ok");

            output.Write("testing system exception... "); // it's just a regular remote exception
            try
            {
                retry1.opSystemException();
                test(false);
            }
            catch (Test.SystemFailure)
            {
            }
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(0);
            Instrumentation.testRetryCount(0);
            try
            {
                retry1.opSystemExceptionAsync().Wait();
                test(false);
            }
            catch (System.AggregateException ex)
            {
                test(ex.InnerException is Test.SystemFailure);
            }
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(0);
            Instrumentation.testRetryCount(0);
            output.WriteLine("ok");

            {
                output.Write("testing invocation timeout and retries... ");
                output.Flush();

                retry2 = Test.IRetryPrx.Parse(retry1.ToString(), communicator2);
                try
                {
                    // No more than 2 retries before timeout kicks-in
                    retry2.Clone(invocationTimeout: 500).opIdempotent(4);
                    test(false);
                }
                catch (TimeoutException)
                {
                    Instrumentation.testRetryCount(2);
                    retry2.opIdempotent(-1); // Reset the counter
                    Instrumentation.testRetryCount(-1);
                }
                try
                {
                    // No more than 2 retries before timeout kicks-in
                    Test.IRetryPrx prx = retry2.Clone(invocationTimeout: 500);
                    prx.opIdempotentAsync(4).Wait();
                    test(false);
                }
                catch (System.AggregateException ex)
                {
                    test(ex.InnerException is TimeoutException);
                    Instrumentation.testRetryCount(2);
                    retry2.opIdempotent(-1); // Reset the counter
                    Instrumentation.testRetryCount(-1);
                }
                output.WriteLine("ok");
            }
            return(retry1);
        }
Exemplo n.º 7
0
            allTests(global::Test.TestHelper helper,
                     Ice.Communicator communicator,
                     Ice.Communicator communicator2,
                     string rf)
            {
                Instrumentation.testInvocationReset();

                var output = helper.getWriter();

                output.Write("testing stringToProxy... ");
                output.Flush();
                var base1 = communicator.stringToProxy(rf);

                test(base1 != null);
                var base2 = communicator.stringToProxy(rf);

                test(base2 != null);
                output.WriteLine("ok");

                output.Write("testing checked cast... ");
                output.Flush();
                Test.RetryPrx retry1 = Test.RetryPrxHelper.checkedCast(base1);
                test(retry1 != null);
                test(retry1.Equals(base1));
                Test.RetryPrx retry2 = Test.RetryPrxHelper.checkedCast(base2);
                test(retry2 != null);
                test(retry2.Equals(base2));
                output.WriteLine("ok");

                output.Write("calling regular operation with first proxy... ");
                output.Flush();
                retry1.op(false);
                output.WriteLine("ok");

                Instrumentation.testInvocationCount(3);

                output.Write("calling operation to kill connection with second proxy... ");
                output.Flush();
                try
                {
                    retry2.op(true);
                    test(false);
                }
                catch (Ice.UnknownLocalException)
                {
                    // Expected with collocation
                }
                catch (Ice.ConnectionLostException)
                {
                }
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(1);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                output.Write("calling regular operation with first proxy again... ");
                output.Flush();
                retry1.op(false);
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(0);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                Callback cb = new Callback();

                output.Write("calling regular AMI operation with first proxy... ");
                retry1.begin_op(false).whenCompleted(
                    () =>
                {
                    cb.called();
                },
                    (Ice.Exception ex) =>
                {
                    test(false);
                });
                cb.check();
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(0);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                output.Write("calling AMI operation to kill connection with second proxy... ");
                retry2.begin_op(true).whenCompleted(
                    () =>
                {
                    test(false);
                },
                    (Ice.Exception ex) =>
                {
                    test(ex is Ice.ConnectionLostException || ex is Ice.UnknownLocalException);
                    cb.called();
                });
                cb.check();
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(1);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                output.Write("calling regular AMI operation with first proxy again... ");
                retry1.begin_op(false).whenCompleted(
                    () =>
                {
                    cb.called();
                },
                    (Ice.Exception ex) =>
                {
                    test(false);
                });
                cb.check();
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(0);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                output.Write("testing idempotent operation... ");
                test(retry1.opIdempotent(4) == 4);
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(0);
                Instrumentation.testRetryCount(4);
                test(retry1.end_opIdempotent(retry1.begin_opIdempotent(4)) == 4);
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(0);
                Instrumentation.testRetryCount(4);
                output.WriteLine("ok");

                output.Write("testing non-idempotent operation... ");
                try
                {
                    retry1.opNotIdempotent();
                    test(false);
                }
                catch (Ice.LocalException)
                {
                }
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(1);
                Instrumentation.testRetryCount(0);
                try
                {
                    retry1.end_opNotIdempotent(retry1.begin_opNotIdempotent());
                    test(false);
                }
                catch (Ice.LocalException)
                {
                }
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(1);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                if (retry1.ice_getConnection() == null)
                {
                    Instrumentation.testInvocationCount(1);

                    output.Write("testing system exception... ");
                    try
                    {
                        retry1.opSystemException();
                        test(false);
                    }
                    catch (SystemFailure)
                    {
                    }
                    Instrumentation.testInvocationCount(1);
                    Instrumentation.testFailureCount(1);
                    Instrumentation.testRetryCount(0);
                    try
                    {
                        retry1.end_opSystemException(retry1.begin_opSystemException());
                        test(false);
                    }
                    catch (SystemFailure)
                    {
                    }
                    Instrumentation.testInvocationCount(1);
                    Instrumentation.testFailureCount(1);
                    Instrumentation.testRetryCount(0);
                    output.WriteLine("ok");
                }

                output.Write("testing invocation timeout and retries... ");
                output.Flush();

                retry2 = Test.RetryPrxHelper.checkedCast(communicator2.stringToProxy(retry1.ToString()));
                try
                {
                    // No more than 2 retries before timeout kicks-in
                    ((Test.RetryPrx)retry2.ice_invocationTimeout(500)).opIdempotent(4);
                    test(false);
                }
                catch (Ice.InvocationTimeoutException)
                {
                    Instrumentation.testRetryCount(2);
                    retry2.opIdempotent(-1); // Reset the counter
                    Instrumentation.testRetryCount(-1);
                }
                try
                {
                    // No more than 2 retries before timeout kicks-in
                    Test.RetryPrx prx = (Test.RetryPrx)retry2.ice_invocationTimeout(500);
                    prx.end_opIdempotent(prx.begin_opIdempotent(4));
                    test(false);
                }
                catch (Ice.InvocationTimeoutException)
                {
                    Instrumentation.testRetryCount(2);
                    retry2.opIdempotent(-1); // Reset the counter
                    Instrumentation.testRetryCount(-1);
                }
                output.WriteLine("ok");
                return(retry1);
            }