コード例 #1
0
        public async Task TestFailoverWithRetryPolicyDoesNotRetryTxCommit()
        {
            var testRetryPolicy = new TestRetryPolicy();
            var cfg             = new IgniteClientConfiguration {
                RetryPolicy = testRetryPolicy
            };

            using var server = new FakeServer(reqId => reqId % 2 == 0);
            using var client = await server.ConnectClientAsync(cfg);

            var tx = await client.Transactions.BeginAsync();

            Assert.ThrowsAsync <IgniteClientException>(async() => await tx.CommitAsync());
            Assert.IsEmpty(testRetryPolicy.Invocations);
        }
コード例 #2
0
ファイル: FakeServerTests.cs プロジェクト: liyuj/ignite-3
        public async Task TestFakeServerDropsConnectionOnSpecifiedRequestCount()
        {
            using var server = new FakeServer(reqId => reqId % 3 == 0);
            using var client = await server.ConnectClientAsync();

            // 2 requests succeed, 3rd fails.
            await client.Tables.GetTablesAsync();

            await client.Tables.GetTablesAsync();

            Assert.CatchAsync(async() => await client.Tables.GetTablesAsync());

            // Reconnect by FailoverSocket logic.
            await client.Tables.GetTablesAsync();
        }
コード例 #3
0
ファイル: RetryPolicyTests.cs プロジェクト: liyuj/ignite-3
        public async Task TestZeroRetryLimitDoesNotLimitRetryCount()
        {
            var cfg = new IgniteClientConfiguration
            {
                RetryPolicy = new RetryAllPolicy {
                    RetryLimit = 0
                }
            };

            using var server = new FakeServer(reqId => reqId % 10 != 0);
            using var client = await server.ConnectClientAsync(cfg);

            for (var i = 0; i < IterCount; i++)
            {
                await client.Tables.GetTablesAsync();
            }
        }
コード例 #4
0
ファイル: RetryPolicyTests.cs プロジェクト: liyuj/ignite-3
        public async Task TestFailoverWithRetryPolicyCompletesOperationWithoutException()
        {
            var cfg = new IgniteClientConfiguration
            {
                RetryPolicy = new RetryAllPolicy {
                    RetryLimit = 1
                }
            };

            using var server = new FakeServer(reqId => reqId % 2 == 0);
            using var client = await server.ConnectClientAsync(cfg);

            for (int i = 0; i < IterCount; i++)
            {
                await client.Tables.GetTablesAsync();
            }
        }
コード例 #5
0
ファイル: RetryPolicyTests.cs プロジェクト: liyuj/ignite-3
        public async Task TestFailoverWithRetryPolicyThrowsOnRetryLimitExceeded()
        {
            var cfg = new IgniteClientConfiguration
            {
                RetryPolicy = new TestRetryPolicy {
                    RetryLimit = 5
                }
            };

            using var server = new FakeServer(reqId => reqId > 1);
            using var client = await server.ConnectClientAsync(cfg);

            await client.Tables.GetTablesAsync();

            var ex = Assert.ThrowsAsync <IgniteClientException>(async() => await client.Tables.GetTablesAsync());

            Assert.AreEqual("Operation failed after 5 retries, examine InnerException for details.", ex !.Message);
        }
コード例 #6
0
ファイル: RetryPolicyTests.cs プロジェクト: liyuj/ignite-3
        public async Task TestTableOperationWithTxIsNotRetried()
        {
            var cfg = new IgniteClientConfiguration
            {
                RetryPolicy = new TestRetryPolicy()
            };

            using var server = new FakeServer(reqId => reqId % 2 == 0);
            using var client = await server.ConnectClientAsync(cfg);

            var tx = await client.Transactions.BeginAsync();

            var table = await client.Tables.GetTableAsync(FakeServer.ExistingTableName);

            var ex = Assert.ThrowsAsync <IgniteClientException>(async() => await table !.RecordBinaryView.UpsertAsync(tx, new IgniteTuple()));

            StringAssert.StartsWith("Socket is closed due to an error", ex !.Message);
        }
コード例 #7
0
ファイル: RetryPolicyTests.cs プロジェクト: liyuj/ignite-3
        public async Task TestRetryOperationWithPayloadReusesPooledBufferCorrectly()
        {
            var cfg = new IgniteClientConfiguration
            {
                RetryPolicy = new TestRetryPolicy {
                    RetryLimit = 1
                }
            };

            using var server = new FakeServer(reqId => reqId % 2 == 0);
            using var client = await server.ConnectClientAsync(cfg);

            for (int i = 0; i < IterCount; i++)
            {
                var table = await client.Tables.GetTableAsync(FakeServer.ExistingTableName);

                Assert.IsNotNull(table);
            }
        }
コード例 #8
0
ファイル: RetryPolicyTests.cs プロジェクト: liyuj/ignite-3
        public async Task TestTableOperationWithoutTxIsRetried()
        {
            var cfg = new IgniteClientConfiguration
            {
                RetryPolicy = new TestRetryPolicy {
                    RetryLimit = 1
                }
            };

            using var server = new FakeServer(reqId => reqId % 2 == 0);
            using var client = await server.ConnectClientAsync(cfg);

            for (int i = 0; i < IterCount; i++)
            {
                var table = await client.Tables.GetTableAsync(FakeServer.ExistingTableName);

                await table !.RecordBinaryView.UpsertAsync(null, new IgniteTuple());
            }
        }
コード例 #9
0
ファイル: FakeServerTests.cs プロジェクト: apache/ignite-3
        public async Task TestFakeServerDropsConnectionOnSpecifiedRequestCount()
        {
            var cfg = new IgniteClientConfiguration
            {
                RetryPolicy = RetryNonePolicy.Instance
            };

            using var server = new FakeServer(reqId => reqId % 3 == 0);
            using var client = await server.ConnectClientAsync(cfg);

            // 2 requests succeed, 3rd fails.
            await client.Tables.GetTablesAsync();

            await client.Tables.GetTablesAsync();

            Assert.CatchAsync(async() => await client.Tables.GetTablesAsync());

            // Reconnect by FailoverSocket logic.
            await client.Tables.GetTablesAsync();
        }