public async Task SingleInvalidRequestAsync() { AmazonDynamoDBConfig config = new AmazonDynamoDBConfig { RegionEndpoint = Amazon.RegionEndpoint.USEast1 }; CSMTestUtilities testUtils = new CSMTestUtilities { Service = "DynamoDB", ApiCall = "DeleteTable", AttemptCount = 1, Domain = "dynamodb.us-east-1.amazonaws.com", Region = "us-east-1", AWSException = "ResourceNotFoundException", AWSExceptionMessage = "Requested resource not found", HttpStatusCode = 400, MaxRetriesExceeded = 0, StashCount = 3 }; var task = Task.Run(() => testUtils.UDPListener()); AmazonDynamoDBClient client = new AmazonDynamoDBClient(config); var exception = await Record.ExceptionAsync(async() => await client.DeleteTableAsync(new DeleteTableRequest { TableName = "foobar" })); Assert.NotNull(exception); Assert.IsType <ResourceNotFoundException>(exception); Thread.Sleep(10); testUtils.EndTest(); task.Wait(); testUtils.Validate(task.Result); }
public async Task SingleSuccessfulRequestAsync() { AmazonDynamoDBConfig config = new AmazonDynamoDBConfig { RegionEndpoint = Amazon.RegionEndpoint.USEast1 }; CSMTestUtilities testUtils = new CSMTestUtilities { Service = "DynamoDB", ApiCall = "ListTables", AttemptCount = 1, Domain = "dynamodb.us-east-1.amazonaws.com", Region = "us-east-1", HttpStatusCode = 200, MaxRetriesExceeded = 0, StashCount = 3 }; var task = Task.Run(() => testUtils.UDPListener()); AmazonDynamoDBClient client = new AmazonDynamoDBClient(config); await client.ListTablesAsync(new ListTablesRequest { }); Thread.Sleep(10); testUtils.EndTest(); task.Wait(); testUtils.Validate(task.Result); }
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 SingleSuccessfulRequest() { ThreadPool.QueueUserWorkItem(UDPListener); CSMTestUtilities testUtils = new CSMTestUtilities { Service = "DynamoDB", ApiCall = "ListTables", AttemptCount = 1, Domain = "dynamodb.us-east-1.amazonaws.com", Region = "us-east-1", HttpStatusCode = 200, MaxRetriesExceeded = 0, StashCount = 3 }; AmazonDynamoDBConfig config = new AmazonDynamoDBConfig { RegionEndpoint = Amazon.RegionEndpoint.USEast1 }; AmazonDynamoDBClient client = new AmazonDynamoDBClient(config); client.ListTables(new ListTablesRequest { }); Thread.Sleep(10); testUtils.EndTest(); testUtils.Validate(stash); }
public async Task WebExceptionRetryableRequestsWithHttpStatusCodeTestAsync() { AmazonDynamoDBConfig config = new AmazonDynamoDBConfig { RegionEndpoint = Amazon.RegionEndpoint.USEast1, MaxErrorRetry = 2 }; CSMTestUtilities testUtils = new CSMTestUtilities { Service = "DynamoDB", ApiCall = "PutItem", Domain = "dynamodb.us-east-1.amazonaws.com", Region = "us-east-1", AttemptCount = config.MaxErrorRetry + 1, SdkException = "AmazonServiceException", SdkExceptionMessage = "WebException", HttpStatusCode = 400, MaxRetriesExceeded = 1, StashCount = config.MaxErrorRetry + 3 }; var task = Task.Run(() => testUtils.UDPListener()); var errorResponse = new Mock <HttpWebResponse>(); exceptionType = new WebException("Test exception", null, WebExceptionStatus.ConnectFailure, errorResponse.Object); errorResponse.SetupGet(foo => foo.StatusCode).Returns(HttpStatusCode.BadRequest); AmazonDynamoDBClient client = new MockDDBClient(config, exceptionType); Random generator = new Random(); Dictionary <string, AttributeValue> attributes = new Dictionary <string, AttributeValue>(); attributes["TestAttribute"] = new AttributeValue { S = generator.Next(0, 999999).ToString("D6") }; PutItemRequest request = new PutItemRequest { TableName = "TestTable", Item = attributes }; var exception = await Record.ExceptionAsync(async() => await client.PutItemAsync(request)); Assert.NotNull(exception); Assert.IsType <AmazonServiceException>(exception); Assert.IsType <WebException>(exception.InnerException); Thread.Sleep(10); testUtils.EndTest(); task.Wait(); testUtils.Validate(task.Result); }
public async Task IoExceptionRetryableRequestsTestAsync() { AmazonDynamoDBConfig config = new AmazonDynamoDBConfig { RegionEndpoint = Amazon.RegionEndpoint.USEast1, MaxErrorRetry = 0 }; CSMTestUtilities testUtils = new CSMTestUtilities { Service = "DynamoDB", ApiCall = "PutItem", Domain = "dynamodb.us-east-1.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()); exceptionType = new IOException(); AmazonDynamoDBClient client = new MockDDBClient(config, exceptionType); Random generator = new Random(); Dictionary <string, AttributeValue> attributes = new Dictionary <string, AttributeValue>(); attributes["TestAttribute"] = new AttributeValue { S = generator.Next(0, 999999).ToString("D6") }; PutItemRequest request = new PutItemRequest { TableName = "TestTable", Item = attributes }; var exception = await Record.ExceptionAsync(async() => await client.PutItemAsync(request)); Assert.NotNull(exception); Assert.IsType <IOException>(exception); Thread.Sleep(10); testUtils.EndTest(); task.Wait(); testUtils.Validate(task.Result); }