Skip to content

Commit

Permalink
Skip flaky tests (#705)
Browse files Browse the repository at this point in the history
  • Loading branch information
laura-rodriguez authored Mar 19, 2024
1 parent c9e4849 commit 8738e4c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 21 deletions.
4 changes: 3 additions & 1 deletion src/Okta.Sdk.IntegrationTest/ApplicationScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace Okta.Sdk.IntegrationTest
{

[Collection(name: nameof(ApplicationScenarios))]
public class ApplicationScenarios
{
private ApplicationApi _applicationApi;
Expand Down Expand Up @@ -315,7 +317,7 @@ public async Task GetApplication()
};

var createdApp = await _applicationApi.CreateApplicationAsync(app);

Thread.Sleep(3000);
try
{
var retrievedById = await _applicationApi.GetApplicationAsync(createdApp.Id);
Expand Down
2 changes: 2 additions & 0 deletions src/Okta.Sdk.IntegrationTest/IdentityProvidersScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,8 @@ public async Task DeleteIdp()
await _idpApi.DeactivateIdentityProviderAsync(createdIdp.Id);
await _idpApi.DeleteIdentityProviderAsync(createdIdp.Id);

Thread.Sleep(3000);

// Deleting by ID should result in 403 Forbidden
await Assert.ThrowsAsync<ApiException>(async () =>
await _idpApi.GetIdentityProviderAsync(idpId));
Expand Down
33 changes: 22 additions & 11 deletions src/Okta.Sdk.IntegrationTest/OAuthScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@
using Polly;
using RestSharp;
using Xunit;
using Xunit.Abstractions;

namespace Okta.Sdk.IntegrationTest
{

[Collection(name:nameof(OAuthScenarios))]
public class OAuthScenarios
{
public OAuthScenarios()
private readonly ITestOutputHelper output;

public OAuthScenarios(ITestOutputHelper output)
{
//CleanUsers();
this.output = output;
}

private static void CleanUsers()
Expand Down Expand Up @@ -80,7 +86,7 @@ public async Task RetrieveAccessToken()
requestOptions.Data = JObject.Parse(payload);

var serviceResponse = await apiClient.PostAsync<JObject>("/oauth2/v1/clients", requestOptions);

output.WriteLine("Create client response {0}", serviceResponse.Data.ToString());
var clientId = serviceResponse.Data["client_id"].ToString();

try
Expand Down Expand Up @@ -123,7 +129,7 @@ public async Task RetrieveAccessToken()
}
}

[Fact ]
[Fact(Skip = "Replication makes test flaky OKTA-710533")]
public async Task ListAppsWithAccessToken()
{
var guid = Guid.NewGuid();
Expand Down Expand Up @@ -166,7 +172,7 @@ public async Task ListAppsWithAccessToken()
requestOptions.Data = JObject.Parse(payload);

var serviceResponse = await apiClient.PostAsync<JObject>("/oauth2/v1/clients", requestOptions);

output.WriteLine("Create client response {0}", serviceResponse.Data.ToString());
var clientId = serviceResponse.Data["client_id"].ToString();

try
Expand Down Expand Up @@ -304,7 +310,7 @@ public async Task ListAppsWithInvalidAccessToken()
}
}

[Fact]
[Fact(Skip = "Replication makes test flaky OKTA-710533")]
public async Task GetUserWithAccessToken()
{
var guid = Guid.NewGuid();
Expand Down Expand Up @@ -349,12 +355,15 @@ public async Task GetUserWithAccessToken()

var serviceResponse = await apiClient.PostAsync<JObject>("/oauth2/v1/clients", requestOptions);

output.WriteLine("Create client response {0}", serviceResponse.Data.ToString());

var clientId = serviceResponse.Data["client_id"].ToString();

var roleAssignmentPayload = $@"{{'type':'SUPER_ADMIN'}}";
var roleAssignmentRequest = GetBasicRequestOptions();
roleAssignmentRequest.Data = JObject.Parse(roleAssignmentPayload);

Thread.Sleep(3000);
var roleAssignmentResponse = await apiClient.PostAsync<JObject>($"/oauth2/v1/clients/{clientId}/roles", roleAssignmentRequest);


Expand Down Expand Up @@ -427,7 +436,7 @@ public async Task GetUserWithAccessToken()
}
}

[Fact]
[Fact(Skip = "Replication makes test flaky OKTA-710533")]
public async Task ListUsersWithPagination()
{
var guid = Guid.NewGuid();
Expand Down Expand Up @@ -471,10 +480,10 @@ public async Task ListUsersWithPagination()
requestOptions.Data = JObject.Parse(payload);

var serviceResponse = await apiClient.PostAsync<JObject>("/oauth2/v1/clients", requestOptions);

output.WriteLine("Create client response {0}", serviceResponse.Data.ToString());
var clientId = serviceResponse.Data["client_id"].ToString();

Thread.Sleep(3000);
Thread.Sleep(6000);

var roleAssignmentPayload = $@"{{'type':'SUPER_ADMIN'}}";
var roleAssignmentRequest = GetBasicRequestOptions();
Expand Down Expand Up @@ -536,6 +545,8 @@ public async Task ListUsersWithPagination()
requestOptions = GetBasicRequestOptions();
requestOptions.Data = JObject.Parse(grantPayload);

Thread.Sleep(3000);

// Add grant to the service
var grantResponse = await apiClient.PostAsync<JObject>($"/api/v1/apps/{clientId}/grants", requestOptions);

Expand Down Expand Up @@ -594,7 +605,7 @@ public async Task ListUsersWithPagination()
}
}

[Fact]
[Fact(Skip = "Replication makes test flaky OKTA-710533")]
public async Task ListUsersWithPaginationAndRetry()
{
var guid = Guid.NewGuid();
Expand Down Expand Up @@ -641,7 +652,7 @@ public async Task ListUsersWithPaginationAndRetry()

var clientId = serviceResponse.Data["client_id"].ToString();

Thread.Sleep(3000);
Thread.Sleep(6000);

var roleAssignmentPayload = $@"{{'type':'SUPER_ADMIN'}}";
var roleAssignmentRequest = GetBasicRequestOptions();
Expand Down Expand Up @@ -695,7 +706,7 @@ public async Task ListUsersWithPaginationAndRetry()
// this delay and the below retry policy are to handle:
// https://developer.okta.com/docs/api/resources/users.html#list-users-with-search
// "Queries data from a replicated store, so changes aren’t always immediately available in search results."
await Task.Delay(6000);
await Task.Delay(8000);

try
{
Expand Down
3 changes: 2 additions & 1 deletion src/Okta.Sdk.IntegrationTest/UserScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

namespace Okta.Sdk.IntegrationTest
{
[Collection(name: nameof(UserScenarios))]
public class UserScenarios
{
private UserApi _userApi;
Expand Down Expand Up @@ -424,7 +425,7 @@ public async Task UpdateUserProfile(string nickName)
}
}

[Fact]
[Fact(Skip = "Replication makes test flaky OKTA-710533")]
public async Task UpdateUserUserType()
{
var guid = Guid.NewGuid();
Expand Down
14 changes: 8 additions & 6 deletions src/Okta.Sdk.IntegrationTest/mappingScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

namespace Okta.Sdk.IntegrationTest
{


[Collection(name: nameof(mappingScenarios))]
public class mappingScenarios
{
private UserTypeApi _userTypeApi;
Expand All @@ -29,7 +30,7 @@ public mappingScenarios()

}

[Fact]
[Fact(Skip = "Replication makes test flaky OKTA-710533")]
public async Task ListProfileMappings()
{
var randomSuffix = GetRandomSuffix();
Expand All @@ -45,7 +46,7 @@ public async Task ListProfileMappings()
Name = $"list_profile_mapping_{randomSuffix}",
});

Thread.Sleep(6000);
Thread.Sleep(10000);
var mappings = await _profileMappingApi.ListProfileMappings(sourceId: userType.Id)
.ToListAsync();

Expand All @@ -60,7 +61,7 @@ public async Task ListProfileMappings()
}
}

[Fact]
[Fact(Skip = "Replication makes test flaky OKTA-710533")]
public async Task GetProfileMapping()
{
var randomSuffix = GetRandomSuffix();
Expand Down Expand Up @@ -98,7 +99,7 @@ public async Task GetProfileMapping()
}
}

[Fact]
[Fact(Skip = "Replication makes test flaky OKTA-710533")]
public async Task UpdateProfileMapping()
{
var randomSuffix = GetRandomSuffix();
Expand Down Expand Up @@ -224,8 +225,9 @@ public async Task UpdateProfileMapping()
};

createdIdp = await _idpApi.CreateIdentityProviderAsync(idp);
var idpId = createdIdp.Id;

Thread.Sleep(6000);
Thread.Sleep(8000);

var mappings = await _profileMappingApi
.ListProfileMappings(sourceId: createdIdp.Id)
Expand Down
3 changes: 1 addition & 2 deletions src/Okta.Sdk.IntegrationTest/xunit.runner.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"parallelizeAssembly": false,
"parallelizeTestCollections": false,
"maxParallelThreads": 1
"parallelizeTestCollections": false
}

0 comments on commit 8738e4c

Please sign in to comment.