Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address flaky unit tests #831

Merged
merged 4 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/TriggerService.Tests/CromwellOnAzureEnvironmentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
namespace TriggerService.Tests
{
[TestClass]
[Ignore]
public class CromwellOnAzureEnvironmentTests
{
private const string azureName = "test";
Expand Down Expand Up @@ -160,8 +159,7 @@ private TriggerHostedService SetCromwellOnAzureEnvironment(string accountAuthori
ApplicationInsightsAccountName = "fakeappinsights"
});

var azureCloudConfig = AzureCloudConfig.FromKnownCloudNameAsync().Result;
var environment = new TriggerHostedService(logger, triggerServiceOptions.Object, cromwellApiClient, repository, storageUtility.Object, azureCloudConfig);
var environment = new TriggerHostedService(logger, triggerServiceOptions.Object, cromwellApiClient, repository, storageUtility.Object, AzureCloudConfig.ForUnitTesting());
return environment;
}

Expand Down
4 changes: 1 addition & 3 deletions src/TriggerService.Tests/ProcessAbortRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
namespace TriggerService.Tests
{
[TestClass]
[Ignore]
public class ProcessAbortRequestTests
{
public ProcessAbortRequestTests()
Expand Down Expand Up @@ -103,8 +102,7 @@ public async Task FailedAbortRequestFileGetsMovedToFailedSubdirectory()
.Setup(x => x.GetStorageAccountsUsingMsiAsync(It.IsAny<string>()))
.Returns(Task.FromResult((new List<IAzureStorage>(), azureStorage.Object)));

var azureCloudConfig = AzureCloudConfig.FromKnownCloudNameAsync().Result;
var cromwellOnAzureEnvironment = new TriggerHostedService(logger, triggerServiceOptions.Object, cromwellApiClient, repository.Object, storageUtility.Object, azureCloudConfig);
var cromwellOnAzureEnvironment = new TriggerHostedService(logger, triggerServiceOptions.Object, cromwellApiClient, repository.Object, storageUtility.Object, AzureCloudConfig.ForUnitTesting());
await cromwellOnAzureEnvironment.ProcessAndAbortWorkflowsAsync();
return (newTriggerName, newTriggerContent);
}
Expand Down
8 changes: 2 additions & 6 deletions src/TriggerService.Tests/ProcessNewWorkflowTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
namespace TriggerService.Tests
{
[TestClass]
[Ignore]
public class ProcessNewWorkflowTests
{
public ProcessNewWorkflowTests()
Expand Down Expand Up @@ -121,14 +120,13 @@ public async Task NewWorkflowsThatFailToPostToCromwellAreMovedToFailedSubdirecto
storageUtility
.Setup(x => x.GetStorageAccountsUsingMsiAsync(It.IsAny<string>()))
.Returns(Task.FromResult((new List<IAzureStorage>(), azureStorage.Object)));
var azureCloudConfig = AzureCloudConfig.FromKnownCloudNameAsync().Result;
var cromwellOnAzureEnvironment = new TriggerHostedService(
logger,
optionsMock.Object,
cromwellApiClient,
tesTaskRepository,
storageUtility.Object,
azureCloudConfig);
AzureCloudConfig.ForUnitTesting());

await cromwellOnAzureEnvironment.ProcessAndAbortWorkflowsAsync();

Expand Down Expand Up @@ -209,15 +207,13 @@ public async Task NewWorkflowsThatFailToParseAsJsonAreAnotatedAndMovedToFailedSu
.Setup(x => x.GetStorageAccountsUsingMsiAsync(It.IsAny<string>()))
.Returns(Task.FromResult((new List<IAzureStorage>(), azureStorage.Object)));

var azureCloudConfig = AzureCloudConfig.FromKnownCloudNameAsync().Result;

var cromwellOnAzureEnvironment = new TriggerHostedService(
logger,
triggerServiceOptions.Object,
cromwellApiClient2,
tesTaskRepository,
storageUtility.Object,
azureCloudConfig);
AzureCloudConfig.ForUnitTesting());

await cromwellOnAzureEnvironment.ProcessAndAbortWorkflowsAsync();
Assert.IsTrue(newTriggerName.StartsWith("failed/"));
Expand Down
3 changes: 1 addition & 2 deletions src/TriggerService.Tests/TriggerEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ public async Task TriggerEngineRunsAndOnlyLogsAvailabilityOncePerSystemUponAvail
.Setup(x => x.GetStorageAccountsUsingMsiAsync(It.IsAny<string>()))
.Returns(Task.FromResult((new List<IAzureStorage>(), azureStorage.Object)));

var azureCloudConfig = AzureCloudConfig.FromKnownCloudNameAsync().Result;
var triggerHostedService = new TriggerHostedService(logger, triggerServiceOptions.Object, cromwellApiClient, tesTaskRepository, storageUtility.Object, azureCloudConfig);
var triggerHostedService = new TriggerHostedService(logger, triggerServiceOptions.Object, cromwellApiClient, tesTaskRepository, storageUtility.Object, AzureCloudConfig.ForUnitTesting());

//var engine = new TriggerHostedService(loggerFactory, environment.Object, TimeSpan.FromMilliseconds(25), TimeSpan.FromMilliseconds(25));
_ = Task.Run(() => triggerHostedService.StartAsync(new System.Threading.CancellationToken()));
Expand Down
2 changes: 0 additions & 2 deletions src/TriggerService.Tests/TriggerService.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj" />
<ProjectReference Include="..\ga4gh-tes\src\Tes\Tes.csproj" />
<ProjectReference Include="..\TriggerService\TriggerService.csproj" />
</ItemGroup>
</Project>
4 changes: 1 addition & 3 deletions src/TriggerService.Tests/UpdateWorkflowStatusTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
namespace TriggerService.Tests
{
[TestClass]
[Ignore]
public class UpdateWorkflowStatusTests
{
public UpdateWorkflowStatusTests()
Expand Down Expand Up @@ -431,8 +430,7 @@ static string ShardString(int shard) =>
.Setup(x => x.GetStorageAccountsUsingMsiAsync(It.IsAny<string>()))
.Returns(Task.FromResult((new List<IAzureStorage>(), azureStorage.Object)));

var azureCloudConfig = AzureCloudConfig.FromKnownCloudNameAsync().Result;
var cromwellOnAzureEnvironment = new TriggerHostedService(logger, triggerServiceOptions.Object, cromwellApiClient.Object, repository.Object, storageUtility.Object, azureCloudConfig);
var cromwellOnAzureEnvironment = new TriggerHostedService(logger, triggerServiceOptions.Object, cromwellApiClient.Object, repository.Object, storageUtility.Object, AzureCloudConfig.ForUnitTesting());

await cromwellOnAzureEnvironment.UpdateWorkflowStatusesAsync();

Expand Down
Loading