-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test to reproduce race condition
If the host is stopped as soon as WorkflowCompleted LifeCycleEvent is raised, some persistence providers cannot persist the 'Completed' state in time.
- Loading branch information
Showing
11 changed files
with
180 additions
and
11 deletions.
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
test/WorkflowCore.IntegrationTests/Scenarios/StopScenario.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,47 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using WorkflowCore.Interface; | ||
using WorkflowCore.Models; | ||
using WorkflowCore.Models.LifeCycleEvents; | ||
using WorkflowCore.Testing; | ||
using Xunit; | ||
|
||
namespace WorkflowCore.IntegrationTests.Scenarios | ||
{ | ||
public class StopScenario : WorkflowTest<StopScenario.StopWorkflow, object> | ||
{ | ||
public class StopWorkflow : IWorkflow | ||
{ | ||
public string Id => "StopWorkflow"; | ||
public int Version => 1; | ||
public void Build(IWorkflowBuilder<object> builder) | ||
{ | ||
builder.StartWith(context => ExecutionResult.Next()); | ||
} | ||
} | ||
|
||
public StopScenario() => Setup(); | ||
|
||
[Fact] | ||
public async Task Scenario() | ||
{ | ||
var tcs = new TaskCompletionSource<object>(); | ||
Host.OnLifeCycleEvent += async (evt) => | ||
{ | ||
if (evt is WorkflowCompleted) | ||
{ | ||
await Host.StopAsync(CancellationToken.None); | ||
tcs.SetResult(default); | ||
} | ||
}; | ||
|
||
var workflowId = StartWorkflow(default); | ||
await tcs.Task; | ||
|
||
GetStatus(workflowId).Should().Be(WorkflowStatus.Complete); | ||
} | ||
|
||
protected override void Dispose(bool disposing) { } | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
test/WorkflowCore.Tests.DynamoDB/Scenarios/DynamoStopScenario.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,18 @@ | ||
using System; | ||
using Amazon.DynamoDBv2; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using WorkflowCore.IntegrationTests.Scenarios; | ||
using Xunit; | ||
|
||
namespace WorkflowCore.Tests.DynamoDB.Scenarios | ||
{ | ||
[Collection("DynamoDb collection")] | ||
public class DynamoStopScenario : StopScenario | ||
{ | ||
protected override void ConfigureServices(IServiceCollection services) | ||
{ | ||
var cfg = new AmazonDynamoDBConfig {ServiceURL = DynamoDbDockerSetup.ConnectionString}; | ||
services.AddWorkflow(x => x.UseAwsDynamoPersistence(DynamoDbDockerSetup.Credentials, cfg, "tests-")); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
test/WorkflowCore.Tests.MongoDB/Scenarios/MongoStopScenario.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,16 @@ | ||
using System; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using WorkflowCore.IntegrationTests.Scenarios; | ||
using Xunit; | ||
|
||
namespace WorkflowCore.Tests.MongoDB.Scenarios | ||
{ | ||
[Collection("Mongo collection")] | ||
public class MongoStopScenario : StopScenario | ||
{ | ||
protected override void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddWorkflow(x => x.UseMongoDB(MongoDockerSetup.ConnectionString, "integration-tests")); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
test/WorkflowCore.Tests.MySQL/Scenarios/MysqlStopScenario.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,16 @@ | ||
using System; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using WorkflowCore.IntegrationTests.Scenarios; | ||
using Xunit; | ||
|
||
namespace WorkflowCore.Tests.MySQL.Scenarios | ||
{ | ||
[Collection("Mysql collection")] | ||
public class MysqlStopScenario : StopScenario | ||
{ | ||
protected override void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddWorkflow(x => x.UseMySQL(MysqlDockerSetup.ScenarioConnectionString, true, true)); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
test/WorkflowCore.Tests.PostgreSQL/Scenarios/PostgresStopScenario.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,16 @@ | ||
using System; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using WorkflowCore.IntegrationTests.Scenarios; | ||
using Xunit; | ||
|
||
namespace WorkflowCore.Tests.PostgreSQL.Scenarios | ||
{ | ||
[Collection("Postgres collection")] | ||
public class PostgresStopScenario : StopScenario | ||
{ | ||
protected override void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddWorkflow(x => x.UsePostgreSQL(PostgresDockerSetup.ScenarioConnectionString, true, true)); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
test/WorkflowCore.Tests.Redis/Scenarios/RedisStopScenario.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,16 @@ | ||
using System; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using WorkflowCore.IntegrationTests.Scenarios; | ||
using Xunit; | ||
|
||
namespace WorkflowCore.Tests.Redis.Scenarios | ||
{ | ||
[Collection("Redis collection")] | ||
public class RedisStopScenario : StopScenario | ||
{ | ||
protected override void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddWorkflow(x => x.UseRedisPersistence(RedisDockerSetup.ConnectionString, "scenario-")); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
test/WorkflowCore.Tests.SqlServer/Scenarios/SqlServerStopScenario.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,16 @@ | ||
using System; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using WorkflowCore.IntegrationTests.Scenarios; | ||
using Xunit; | ||
|
||
namespace WorkflowCore.Tests.SqlServer.Scenarios | ||
{ | ||
[Collection("SqlServer collection")] | ||
public class SqlServerStopScenario : StopScenario | ||
{ | ||
protected override void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddWorkflow(x => x.UseSqlServer(SqlDockerSetup.ScenarioConnectionString, true, true)); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
test/WorkflowCore.Tests.Sqlite/Scenarios/SqliteStopScenario.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,17 @@ | ||
using System; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using WorkflowCore.IntegrationTests.Scenarios; | ||
using WorkflowCore.Tests.Sqlite; | ||
using Xunit; | ||
|
||
namespace WorkflowCore.Tests.Sqlite.Scenarios | ||
{ | ||
[Collection("Sqlite collection")] | ||
public class SqliteStopScenario : StopScenario | ||
{ | ||
protected override void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddWorkflow(x => x.UseSqlite(SqliteSetup.ConnectionString, true)); | ||
} | ||
} | ||
} |
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