forked from temporalio/features
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test that repros TS crash due to proto changes (temporalio#423)
- Loading branch information
1 parent
69ca251
commit 917c8bc
Showing
15 changed files
with
241 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Basic activity | ||
The most basic workflow which just runs an activity and returns its result. | ||
Importantly, without setting a workflow execution timeout. | ||
|
||
|
||
# Detailed spec | ||
It's important that the workflow execution timeout is not set here, because server will propagate that to all un-set | ||
activity timeouts. We had a bug where TS would crash (after proto changes from gogo to google) because it was expecting | ||
timeouts to be set to zero rather than null. |
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,54 @@ | ||
namespace activity.basic_no_workflow_timeout; | ||
|
||
using Temporalio.Activities; | ||
using Temporalio.Client; | ||
using Temporalio.Exceptions; | ||
using Temporalio.Features.Harness; | ||
using Temporalio.Worker; | ||
using Temporalio.Workflows; | ||
|
||
class Feature : IFeature | ||
{ | ||
public void ConfigureWorker(Runner runner, TemporalWorkerOptions options) => | ||
options.AddWorkflow<MyWorkflow>().AddAllActivities(new MyActivities(runner.Client)); | ||
|
||
[Workflow] | ||
class MyWorkflow | ||
{ | ||
private string? activityResult; | ||
|
||
[WorkflowRun] | ||
public async Task RunAsync() | ||
{ | ||
await Workflow.ExecuteActivityAsync( | ||
(MyActivities act) => act.Echo(), | ||
new() | ||
{ | ||
ScheduleToCloseTimeout = TimeSpan.FromMinutes(1) | ||
}); | ||
|
||
await Workflow.ExecuteActivityAsync( | ||
(MyActivities act) => act.Echo(), | ||
new() | ||
{ | ||
StartToCloseTimeout = TimeSpan.FromMinutes(1) | ||
}); | ||
} | ||
|
||
[WorkflowSignal] | ||
public async Task SetActivityResultAsync(string res) => activityResult = res; | ||
} | ||
|
||
class MyActivities | ||
{ | ||
private readonly ITemporalClient client; | ||
|
||
public MyActivities(ITemporalClient client) => this.client = client; | ||
|
||
[Activity] | ||
public async Task<string> Echo() | ||
{ | ||
return "hi"; | ||
} | ||
} | ||
} |
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,40 @@ | ||
package retry_on_error | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/temporalio/features/harness/go/harness" | ||
"go.temporal.io/sdk/client" | ||
"go.temporal.io/sdk/workflow" | ||
) | ||
|
||
var Feature = harness.Feature{ | ||
Workflows: Workflow, | ||
Activities: Echo, | ||
StartWorkflowOptionsMutator: func(o *client.StartWorkflowOptions) { | ||
o.WorkflowExecutionTimeout = 0 | ||
}, | ||
} | ||
|
||
func Workflow(ctx workflow.Context) (string, error) { | ||
ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ | ||
StartToCloseTimeout: 1 * time.Minute, | ||
}) | ||
|
||
var result string | ||
err := workflow.ExecuteActivity(ctx, Echo).Get(ctx, &result) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ | ||
ScheduleToCloseTimeout: 1 * time.Minute, | ||
}) | ||
err = workflow.ExecuteActivity(ctx, Echo).Get(ctx, &result) | ||
return result, err | ||
} | ||
|
||
func Echo(_ context.Context) (string, error) { | ||
return "echo", nil | ||
} |
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,41 @@ | ||
package activity.basic_no_workflow_timeout; | ||
|
||
import io.temporal.activity.ActivityInterface; | ||
import io.temporal.activity.ActivityMethod; | ||
import io.temporal.client.WorkflowOptions; | ||
import io.temporal.sdkfeatures.Feature; | ||
import io.temporal.sdkfeatures.SimpleWorkflow; | ||
import java.time.Duration; | ||
|
||
@ActivityInterface | ||
public interface feature extends Feature, SimpleWorkflow { | ||
@ActivityMethod | ||
String echo(); | ||
|
||
class Impl implements feature { | ||
@Override | ||
public void workflow() { | ||
var activities = | ||
activities( | ||
feature.class, builder -> builder.setStartToCloseTimeout(Duration.ofMinutes(1))); | ||
|
||
activities.echo(); | ||
|
||
var activitiesSched2Close = | ||
activities( | ||
feature.class, builder -> builder.setScheduleToCloseTimeout(Duration.ofMinutes(1))); | ||
|
||
activitiesSched2Close.echo(); | ||
} | ||
|
||
@Override | ||
public String echo() { | ||
return "hi"; | ||
} | ||
} | ||
|
||
@Override | ||
default void workflowOptions(WorkflowOptions.Builder builder) { | ||
builder.setWorkflowExecutionTimeout(Duration.ZERO); | ||
} | ||
} |
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,32 @@ | ||
from datetime import timedelta | ||
|
||
from temporalio import activity, workflow | ||
|
||
from harness.python.feature import register_feature | ||
|
||
|
||
@workflow.defn | ||
class Workflow: | ||
@workflow.run | ||
async def run(self) -> str: | ||
await workflow.execute_activity( | ||
echo, | ||
schedule_to_close_timeout=timedelta(minutes=1), | ||
) | ||
return await workflow.execute_activity( | ||
echo, | ||
start_to_close_timeout=timedelta(minutes=1), | ||
) | ||
|
||
|
||
@activity.defn | ||
async def echo() -> str: | ||
return "echo" | ||
|
||
|
||
register_feature( | ||
workflows=[Workflow], | ||
activities=[echo], | ||
expect_activity_error="activity attempt 5 failed", | ||
start_options={"execution_timeout": None}, | ||
) |
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,26 @@ | ||
import { Feature } from '@temporalio/harness'; | ||
import * as wf from '@temporalio/workflow'; | ||
|
||
const activities = wf.proxyActivities<typeof activitiesImpl>({ | ||
startToCloseTimeout: '1 minute', | ||
}); | ||
const activitiesSched2Close = wf.proxyActivities<typeof activitiesImpl>({ | ||
scheduleToCloseTimeout: '1 minute', | ||
}); | ||
|
||
export async function workflow(): Promise<string> { | ||
await activitiesSched2Close.echo('hello'); | ||
return await activities.echo('hello'); | ||
} | ||
|
||
const activitiesImpl = { | ||
async echo(input: string): Promise<string> { | ||
return input; | ||
}, | ||
}; | ||
|
||
export const feature = new Feature({ | ||
workflow, | ||
workflowStartOptions: { workflowExecutionTimeout: undefined }, | ||
activities: activitiesImpl, | ||
}); |
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
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
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
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
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