-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix race condition on stop #1081
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
Open
mamidenn
wants to merge
3
commits into
danielgerlag:master
Choose a base branch
from
mamidenn:fix-race-condition-on-stop-min
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be made static?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to have simple access to the value from the new
SqliteStopScenario
as well as aligning it with the way all the other scenario setups have static connection strings.