Skip to content

Commit 3dabfe5

Browse files
authored
Executor: Adds WaitForInstanceStart to StartIntance (#15)
* Executor: Adds WaitForInstanceStart to StartIntance Signed-off-by: joshvanl <[email protected]> * Update tests to account for start waiting for the orchestration state to become non-pending Signed-off-by: joshvanl <[email protected]> --------- Signed-off-by: joshvanl <[email protected]>
1 parent d9f84c6 commit 3dabfe5

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

backend/executor.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@ func (g *grpcExecutor) StartInstance(ctx context.Context, req *protos.CreateInst
478478
return nil, err
479479
}
480480

481+
_, err := g.WaitForInstanceStart(ctx, &protos.GetInstanceRequest{InstanceId: instanceID})
482+
if err != nil {
483+
return nil, err
484+
}
485+
481486
return &protos.CreateInstanceResponse{InstanceId: instanceID}, nil
482487
}
483488

tests/grpc/grpc_test.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,10 @@ func Test_Grpc_WaitForInstanceStart_Timeout(t *testing.T) {
100100
cancelListener := startGrpcListener(t, r)
101101
defer cancelListener()
102102

103-
id, err := grpcClient.ScheduleNewOrchestration(ctx, "WaitForInstanceStartThrowsException", api.WithInput("世界"))
104-
require.NoError(t, err)
103+
go grpcClient.ScheduleNewOrchestration(ctx, "WaitForInstanceStartThrowsException", api.WithInput("世界"), api.WithInstanceID("helloworld"))
105104
timeoutCtx, cancelTimeout := context.WithTimeout(ctx, time.Second)
106105
defer cancelTimeout()
107-
_, err = grpcClient.WaitForOrchestrationStart(timeoutCtx, id, api.WithFetchPayloads(true))
106+
_, err := grpcClient.WaitForOrchestrationStart(timeoutCtx, "helloworld", api.WithFetchPayloads(true))
108107
if assert.Error(t, err) {
109108
assert.Contains(t, err.Error(), "context deadline exceeded")
110109
}
@@ -121,11 +120,10 @@ func Test_Grpc_WaitForInstanceStart_ConnectionResume(t *testing.T) {
121120

122121
cancelListener := startGrpcListener(t, r)
123122

124-
id, err := grpcClient.ScheduleNewOrchestration(ctx, "WaitForInstanceStartThrowsException", api.WithInput("世界"))
125-
require.NoError(t, err)
123+
go grpcClient.ScheduleNewOrchestration(ctx, "WaitForInstanceStartThrowsException", api.WithInput("世界"), api.WithInstanceID("worldhello"))
126124
timeoutCtx, cancelTimeout := context.WithTimeout(ctx, time.Second)
127125
defer cancelTimeout()
128-
_, err = grpcClient.WaitForOrchestrationStart(timeoutCtx, id, api.WithFetchPayloads(true))
126+
_, err := grpcClient.WaitForOrchestrationStart(timeoutCtx, "worldhello", api.WithFetchPayloads(true))
129127
if assert.Error(t, err) {
130128
assert.Contains(t, err.Error(), "context deadline exceeded")
131129
}
@@ -139,7 +137,7 @@ func Test_Grpc_WaitForInstanceStart_ConnectionResume(t *testing.T) {
139137
// workitem should be retried and completed.
140138
timeoutCtx, cancelTimeout = context.WithTimeout(ctx, 30*time.Second)
141139
defer cancelTimeout()
142-
metadata, err := grpcClient.WaitForOrchestrationCompletion(timeoutCtx, id, api.WithFetchPayloads(true))
140+
metadata, err := grpcClient.WaitForOrchestrationCompletion(timeoutCtx, "worldhello", api.WithFetchPayloads(true))
143141
require.NoError(t, err)
144142
assert.True(t, api.OrchestrationMetadataIsComplete(metadata))
145143
assert.Equal(t, "42", metadata.Output.Value)

0 commit comments

Comments
 (0)