public async Task IoExceptionRetryableRequestsTestAsync() { AmazonS3Config config = new AmazonS3Config { RegionEndpoint = Amazon.RegionEndpoint.USEast1, MaxErrorRetry = 2 }; CSMTestUtilities testUtils = new CSMTestUtilities { Service = "S3", ApiCall = "CreateBucket", Domain = "s3.amazonaws.com", Region = "us-east-1", AttemptCount = config.MaxErrorRetry + 1, SdkException = "IOException", SdkExceptionMessage = "I/O", MaxRetriesExceeded = 1, StashCount = config.MaxErrorRetry + 3 }; var task = Task.Run(() => testUtils.UDPListener()); AmazonS3Client client = new MockS3Client(config); var exception = await Record.ExceptionAsync(async() => await client.PutBucketAsync(new PutBucketRequest { BucketName = "TestBucket" })); Assert.NotNull(exception); Assert.IsType <IOException>(exception); Thread.Sleep(10); testUtils.EndTest(); task.Wait(); testUtils.Validate(task.Result); }
public void IoExceptionRetryableRequestsTest() { var task = Task.Run(() => UDPListener()); AmazonS3Config config = new AmazonS3Config { RegionEndpoint = Amazon.RegionEndpoint.USEast1, MaxErrorRetry = 2 }; AmazonS3Client client = new MockS3Client(config); try { client.PutBucketAsync(new PutBucketRequest { BucketName = "TestBucket" }).Wait(); } catch (Exception e) { } using (var udpClient = new UdpClient()) { udpClient.Send(Encoding.UTF8.GetBytes("Exit"), Encoding.UTF8.GetBytes("Exit").Length, "127.0.0.1", 31000); Thread.Sleep(10); } Assert.Equal(5, task.Result.Count); CSMTestUtilities testUtils = new CSMTestUtilities { Service = "S3", ApiCall = "CreateBucket", Domain = "s3.amazonaws.com", Region = "us-east-1", AttemptCount = 3, SdkException = "IOException", SdkExceptionMessage = "I/O" }; foreach (var value in task.Result) { if (!value.Equals("Exit")) { try { testUtils.Validate(JsonConvert.DeserializeObject <MonitoringAPICallEvent>(value)); } catch (Exception e) { testUtils.Validate(JsonConvert.DeserializeObject <MonitoringAPICallAttempt>(value)); } } else { break; } } }