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); }
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(); }
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(); } }
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(); } }
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); }
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); }
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); } }
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()); } }
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(); }