Skip to content

Commit

Permalink
Address flaky unit tests (#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
BMurri authored Nov 11, 2024
1 parent d22a03b commit 5bacc21
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 20 deletions.
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

0 comments on commit 5bacc21

Please sign in to comment.