Пример #1
0
        public override async Task RunAsync(string[] args)
        {
            Dictionary <string, string>?properties = CreateTestProperties(ref args);

            // This test kills connections, so we don't want warnings.
            properties["Ice.Warn.Connections"]    = "0";
            await using Communicator communicator = Initialize(properties, observer: Instrumentation.GetObserver());
            AllTests.Run(this, communicator, false).Shutdown();
        }
Пример #2
0
        public static async Task <int> Main(string[] args)
        {
            ICommunicatorObserver?      observer   = Instrumentation.GetObserver();
            Dictionary <string, string> properties = CreateTestProperties(ref args);

            properties["Ice.Warn.Dispatch"] = "0";
            // This test kills connections, so we don't want warnings.
            properties["Ice.Warn.Connections"] = "0";

            await using var communicator = CreateCommunicator(properties, observer: observer);
            return(await RunTestAsync <Collocated>(communicator, args));
        }
Пример #3
0
        public static async Task <int> Main(string[] args)
        {
            Dictionary <string, string> properties = CreateTestProperties(ref args);

            // This test kills connections, so we don't want warnings.
            properties["Ice.Warn.Connections"] = "0";

            await using var communicator = CreateCommunicator(properties, observer: Instrumentation.GetObserver());
            await communicator.ActivateAsync();

            return(await RunTestAsync <Client>(communicator, args));
        }
Пример #4
0
        public override async Task RunAsync(string[] args)
        {
            ICommunicatorObserver?      observer   = Instrumentation.GetObserver();
            Dictionary <string, string>?properties = CreateTestProperties(ref args);

            properties["Ice.Warn.Dispatch"] = "0";
            // This test kills connections, so we don't want warnings.
            properties["Ice.Warn.Connections"]    = "0";
            await using Communicator communicator = Initialize(properties, observer: observer);

            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));
            communicator.CreateObjectAdapter("TestAdapter").Add("retry", new Retry());
            await AllTests.Run(this, communicator, true).ShutdownAsync();
        }
Пример #5
0
        public override async Task RunAsync(string[] args)
        {
            Dictionary <string, string>?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";
            await using Communicator 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";
            await using Communicator communicator2 = Initialize(properties, observer: Instrumentation.GetObserver());
            AllTests.Run(this, communicator, communicator2, GetTestProxy("retry", 0)).Shutdown();
        }
Пример #6
0
        public override async Task RunAsync(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";
            await 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";
            await using var communicator2    = Initialize(properties, observer: Instrumentation.GetObserver());
            AllTests.allTests(this, communicator, communicator2, $"retry:{GetTestEndpoint(0)}").shutdown();
        }
Пример #7
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("retry", new Retry());
            communicator2.CreateObjectAdapter().Add("retry", new Retry());
            AllTests.allTests(this, communicator, communicator2, "retry").shutdown();
        }
Пример #8
0
        public override async Task RunAsync(string[] args)
        {
            ICommunicatorObserver?      observer   = Instrumentation.GetObserver();
            Dictionary <string, string>?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";
            await using Communicator 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";
            await using Communicator? communicator2 = Initialize(properties, observer: observer);
            communicator.CreateObjectAdapter().Add("retry", new Retry());
            communicator2.CreateObjectAdapter().Add("retry", new Retry());
            await AllTests.Run(this, communicator, communicator2, "retry").ShutdownAsync();
        }
Пример #9
0
        public static async Task RunAsync(TestHelper helper, bool colocated)
        {
            Communicator communicator = helper.Communicator;
            bool         ice1         = helper.Protocol == Protocol.Ice1;

            TextWriter output = helper.Output;

            var retry1 = IRetryPrx.Parse(helper.GetTestProxy("retry"), communicator);

            output.Write("calling regular operation with first proxy... ");
            output.Flush();
            Instrumentation.TestInvocationReset();
            retry1.Op(false);
            Instrumentation.TestInvocationCount(1);
            Instrumentation.TestFailureCount(0);
            Instrumentation.TestRetryCount(0);
            output.WriteLine("ok");

            output.Write("calling operation to kill connection with second proxy... ");
            output.Flush();
            Instrumentation.TestInvocationReset();
            try
            {
                retry1.Op(true);
                TestHelper.Assert(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();
            Instrumentation.TestInvocationReset();
            retry1.Op(false);
            Instrumentation.TestInvocationCount(1);
            Instrumentation.TestFailureCount(0);
            Instrumentation.TestRetryCount(0);
            output.WriteLine("ok");

            output.Write("calling regular AMI operation with first proxy... ");
            Instrumentation.TestInvocationReset();
            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... ");
            Instrumentation.TestInvocationReset();
            try
            {
                retry1.OpAsync(true).Wait();
                TestHelper.Assert(false);
            }
            catch (AggregateException ex)
            {
                TestHelper.Assert(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... ");
            Instrumentation.TestInvocationReset();
            retry1.OpAsync(false).Wait();
            Instrumentation.TestInvocationCount(1);
            Instrumentation.TestFailureCount(0);
            Instrumentation.TestRetryCount(0);
            output.WriteLine("ok");

            output.Write("testing non-idempotent operation... ");
            Instrumentation.TestInvocationReset();
            try
            {
                retry1.OpNotIdempotent();
                TestHelper.Assert(false);
            }
            catch (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
            Instrumentation.TestInvocationReset();
            try
            {
                retry1.OpSystemException();
                TestHelper.Assert(false);
            }
            catch (SystemFailure)
            {
            }
            Instrumentation.TestInvocationCount(1);
            Instrumentation.TestFailureCount(1);
            Instrumentation.TestRetryCount(0);

            try
            {
                retry1.OpSystemExceptionAsync().Wait();
                TestHelper.Assert(false);
            }
            catch (AggregateException ex)
            {
                TestHelper.Assert(ex.InnerException is SystemFailure);
            }
            Instrumentation.TestInvocationCount(1);
            Instrumentation.TestFailureCount(1);
            Instrumentation.TestRetryCount(0);
            output.WriteLine("ok");

            if (!colocated)
            {
                output.Write("testing retry with fixed reference... ");
                output.Flush();
                var adapter = communicator.CreateObjectAdapter(protocol: ice1 ? Protocol.Ice1 : Protocol.Ice2);
                var bidir   = adapter.AddWithUUID(new Bidir(), IBidirPrx.Factory);
                (await retry1.GetConnectionAsync()).Adapter = adapter;
                retry1.OpBidirRetry(bidir);

                output.WriteLine("ok");
            }

            if (!ice1)
            {
                output.Write("testing cancellation and retries... ");
                output.Flush();
                Instrumentation.TestInvocationReset();
                try
                {
                    // No more than 2 retries before timeout kicks-in
                    retry1.Clone(invocationTimeout: TimeSpan.FromMilliseconds(500)).OpIdempotent(4);
                    TestHelper.Assert(false);
                }
                catch (OperationCanceledException)
                {
                    Instrumentation.TestRetryCount(2);
                    retry1.OpIdempotent(-1);
                }
                output.WriteLine("ok");

                output.Write("testing retry after delay... ");
                output.Flush();
                Instrumentation.TestInvocationReset();
                try
                {
                    // No retries before timeout kicks-in
                    retry1.Clone(invocationTimeout: TimeSpan.FromMilliseconds(400)).OpAfterDelay(2, 600);
                    TestHelper.Assert(false);
                }
                catch (OperationCanceledException)
                {
                    Instrumentation.TestRetryCount(0);
                    retry1.OpAfterDelay(-1, 0);
                }

                {
                    Instrumentation.TestInvocationReset();
                    // No retries before timeout kicks-in
                    int n = retry1.Clone(invocationTimeout: TimeSpan.FromMilliseconds(500)).OpAfterDelay(4, 50);
                    Instrumentation.TestRetryCount(4);
                    retry1.OpAfterDelay(-1, 0);
                    TestHelper.Assert(n == 4);
                }

                {
                    // No more than 5 invocation attempts with the default settings
                    Instrumentation.TestInvocationReset();
                    // No retries before timeout kicks-in
                    try
                    {
                        retry1.Clone(invocationTimeout: TimeSpan.FromMilliseconds(500)).OpAfterDelay(5, 50);
                        TestHelper.Assert(false);
                    }
                    catch (SystemFailure)
                    {
                        Instrumentation.TestRetryCount(4);
                        retry1.OpAfterDelay(-1, 0);
                    }
                }
                output.WriteLine("ok");

                if (!colocated)
                {
                    output.Write("testing retry other replica... ");
                    output.Flush();
                    // Build a multi-endpoint proxy by hand.
                    // TODO: should the TestHelper help with that?
                    var sb = new StringBuilder(helper.GetTestProxy("replicated"));
                    sb.Append("?alt-endpoint=");
                    sb.Append(helper.Host.Contains(":") ? $"[{helper.Host}]" : helper.Host);
                    sb.Append(':');
                    sb.Append(helper.BasePort + 1);

                    IReplicatedPrx?replicated = IReplicatedPrx.Parse(sb.ToString(), communicator);

                    replicated.IcePing();
                    TestHelper.Assert(((IPConnection)replicated.GetCachedConnection() !).RemoteEndpoint !.Port ==
                                      helper.BasePort);

                    Instrumentation.TestInvocationReset();
                    replicated.OtherReplica();
                    Instrumentation.TestRetryCount(1);
                    TestHelper.Assert(((IPConnection)replicated.GetCachedConnection() !).RemoteEndpoint !.Port ==
                                      helper.BasePort + 1);

                    try
                    {
                        var nonreplicated = INonReplicatedPrx.Parse(helper.GetTestProxy("replicated"), communicator);

                        nonreplicated.IcePing();
                        TestHelper.Assert(((IPConnection)nonreplicated.GetCachedConnection() !).RemoteEndpoint !.Port ==
                                          helper.BasePort);
                        nonreplicated.OtherReplica();
                        TestHelper.Assert(false);
                    }
                    catch (SystemFailure)
                    {
                    }
                    output.WriteLine("ok");

                    output.Write("testing retry request size max... ");
                    output.Flush();
                    {
                        Dictionary <string, string> properties = communicator.GetProperties();
                        properties["Ice.RetryRequestMaxSize"] = "1024";
                        await using var communicator2         = new Communicator(properties);
                        var retry2 = IRetryPrx.Parse(helper.GetTestProxy("retry"), communicator2);

                        byte[] data = Enumerable.Range(0, 1024).Select(i => (byte)i).ToArray();

                        retry1.OpWithData(1, 0, data); // Succeed no retry request size limit

                        try
                        {
                            retry2.OpWithData(1, 0, data); // Fails because retry request size limit
                            TestHelper.Assert(false);
                        }
                        catch (SystemFailure)
                        {
                            // Expected
                            retry2.OpWithData(0, 0, Array.Empty <byte>()); // Reset the counter
                        }
                    }
                    output.WriteLine("ok");

                    output.Write("testing retry buffer size max... ");
                    output.Flush();
                    {
                        Dictionary <string, string> properties = communicator.GetProperties();
                        properties["Ice.RetryBufferMaxSize"] = "2048";
                        await using var communicator2        = new Communicator(properties);
                        var retry2 = IRetryPrx.Parse(helper.GetTestProxy("retry"), communicator2);

                        byte[] data = Enumerable.Range(0, 1024).Select(i => (byte)i).ToArray();

                        // Use two connections to simulate two concurrent retries, the first should succeed
                        // and the second should fail because the buffer size max.
                        Task t1 = retry2.Clone(label: "conn-1").OpWithDataAsync(2, 1000, data);
                        Thread.Sleep(100); // Ensure the first request it is send before the second request
                        Task t2 = retry2.Clone(label: "conn-2").OpWithDataAsync(2, 0, data);

                        // T1 succeed, T2 Fail because buffer size max
                        t1.Wait();
                        try
                        {
                            t2.Wait();
                            TestHelper.Assert(false);
                        }
                        catch (AggregateException ex)
                        {
                            // expected
                            TestHelper.Assert(ex.InnerException is SystemFailure);
                            retry2.OpWithData(0, 0, Array.Empty <byte>()); // Reset the counter
                        }
                        retry2.Clone(label: "conn-1").OpWithData(2, 100, data);
                    }
                    output.WriteLine("ok");
                }
            }
            await retry1.ShutdownAsync();
        }