-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clone request in retry strategy (#342)
Add request cloning in between retries.
- Loading branch information
1 parent
9fd6123
commit 9183827
Showing
3 changed files
with
115 additions
and
11 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
src/Okta.Sdk.IntegrationTests/DefaultRetryStrategyScenarios.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// <copyright file="DefaultRetryStrategyScenarios.cs" company="Okta, Inc"> | ||
// Copyright (c) 2014 - present Okta, Inc. All rights reserved. | ||
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information. | ||
// </copyright> | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using Okta.Sdk.Configuration; | ||
using Xunit; | ||
|
||
namespace Okta.Sdk.IntegrationTests | ||
{ | ||
public class DefaultRetryStrategyScenarios | ||
{ | ||
[Fact] | ||
public void RetryShouldNotThrowInvalidOperationException() | ||
{ | ||
List<string> guidList = new List<string>(); | ||
|
||
for (int i = 0; i < 150; i++) | ||
{ | ||
guidList.Add(Guid.NewGuid().ToString()); | ||
} | ||
|
||
var oktaClient = new OktaClient( | ||
null, | ||
new HttpClient(), | ||
null, | ||
new DefaultRetryStrategy( | ||
OktaClientConfiguration.DefaultMaxRetries, | ||
OktaClientConfiguration.DefaultRequestTimeout)); | ||
|
||
// Forcing several parallel requests to trigger rate limiting | ||
guidList | ||
.AsParallel() | ||
.ForAll(t => | ||
{ | ||
var log = oktaClient.Logs | ||
.GetLogs( | ||
q: $"eventType eq \"user.lifecycle.create\" and target.id eq \"{t.Trim()}\"", | ||
since: DateTime.Now.Add(TimeSpan.FromDays(-180d)).ToString("yyyy-MM-dd")) | ||
.Select(ev => ev.Actor.AlternateId) | ||
.FirstOrDefault(); | ||
try | ||
{ | ||
Assert.True(log.Result == null, "not found"); | ||
} | ||
catch (AggregateException e) | ||
{ | ||
foreach (var ex in e.Flatten().InnerExceptions) | ||
{ | ||
Assert.False(ex.GetType() == typeof(InvalidOperationException) && ex.Message.Contains("The request message was already sent"), "The request shouldn't be reused."); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters