public static IEnumerable <object[]> CreateRetriableExecuteTestData()
        {
            var defaultPolicy  = Driver.RetryPolicy.Builder().Build();
            var customerPolicy = Driver.RetryPolicy.Builder().WithMaxRetries(10).Build();

            var capacityExceeded = new CapacityExceededException("qldb", ErrorType.Receiver, "errorCode", "requestId", HttpStatusCode.ServiceUnavailable);
            var occConflict      = new OccConflictException("qldb", new BadRequestException("oops"));
            var invalidSession   = new InvalidSessionException("invalid session");
            var http500          = new AmazonQLDBSessionException("", 0, "", "", HttpStatusCode.ServiceUnavailable);

            return(new List <object[]>()
            {
                // No exception, No retry.
                new object[] { defaultPolicy, new Exception[0], false, Times.Never() },
                // Generic Driver exception.
                new object[] { defaultPolicy, new Exception[] { new QldbDriverException("generic") }, true,
                               Times.Never() },
                // Not supported Txn exception.
                new object[] { defaultPolicy, new Exception[] { new QldbTransactionException("txnid1111111",
                                                                                             new QldbDriverException("qldb")) }, true, Times.Never() },
                // Not supported exception.
                new object[] { defaultPolicy, new Exception[] { new ArgumentException("qldb") }, true,
                               Times.Never() },
                // Transaction expiry.
                new object[] { defaultPolicy,
                               new Exception[] { new InvalidSessionException("Transaction 324weqr2314 has expired") },
                               true, Times.Never() },
                // Retry OCC within retry limit.
                new object[] { defaultPolicy, new Exception[] { occConflict, occConflict, occConflict }, false,
                               Times.Exactly(3) },
                // Retry ISE within retry limit.
                new object[] { defaultPolicy, new Exception[] { invalidSession, invalidSession, invalidSession }, false,
                               Times.Exactly(3) },
                // Retry mixed exceptions within retry limit.
                new object[] { defaultPolicy, new Exception[] { invalidSession, occConflict, http500 }, false,
                               Times.Exactly(3) },
                // Retry OCC exceed limit.
                new object[] { defaultPolicy, new Exception[] { occConflict, invalidSession, http500, invalidSession,
                                                                occConflict }, true, Times.Exactly(4) },
                // Retry CapacityExceededException exceed limit.
                new object[] { defaultPolicy, new Exception[] { capacityExceeded, capacityExceeded, capacityExceeded,
                                                                capacityExceeded, capacityExceeded }, true, Times.Exactly(4) },
                // Retry customized policy within retry limit.
                new object[] { customerPolicy, new Exception[] { invalidSession, invalidSession, invalidSession,
                                                                 invalidSession, invalidSession, invalidSession, invalidSession, invalidSession }, false,
                               Times.Exactly(8) },
            });
        }
Example #2
0
 private protected static bool IsTransactionExpiredException(InvalidSessionException ise)
 {
     return(Regex.Match(ise.Message, @"Transaction\s.*\shas\sexpired").Success);
 }