Skip to content

Commit

Permalink
Test UnregisteredClient invoking RPC and improve check IsRPCError (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
longquanzheng authored Nov 8, 2024
1 parent 22029b8 commit 654c49d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions integ/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ ELASTICSEARCH_VERSION=7.16.2
MYSQL_VERSION=8
POSTGRESQL_VERSION=13
TEMPORAL_VERSION=1.25
TEMPORAL_ADMIN_TOOLS_VERSION=1.25.2-tctl-1.18.1-cli-1.1.1
TEMPORAL_UI_VERSION=2.31.2
2 changes: 1 addition & 1 deletion integ/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ services:
environment:
- TEMPORAL_ADDRESS=temporal:7233
- TEMPORAL_CLI_ADDRESS=temporal:7233
image: temporalio/admin-tools:${TEMPORAL_VERSION}
image: temporalio/admin-tools:${TEMPORAL_ADMIN_TOOLS_VERSION}
networks:
- temporal-network
stdin_open: true
Expand Down
5 changes: 5 additions & 0 deletions integ/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ func TestRPCWorkflow(t *testing.T) {
rpcErr, _ := err.(*iwf.ApiError)
assert.Equal(t, "worker API error, status:501, errorType:test-error-type", rpcErr.Response.GetDetail())

// Test unregister client
unregClient := iwf.NewUnregisteredClient(nil)
err = unregClient.InvokeRPCByName(context.Background(), wfId, "", "TestErrorRPC", 1, nil, nil)
assert.NotNil(t, err)

var rpcOutput int
err = client.InvokeRPC(context.Background(), wfId, "", wf.TestRPC, 1, &rpcOutput)
assert.Nil(t, err)
Expand Down
4 changes: 2 additions & 2 deletions integ/workflow_uncompleted_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ func TestStateApiTimeoutWorkflow(t *testing.T) {

fmt.Println(err)

expectedMsg := "workflow is not completed successfully, closedStatus: FAILED, failedErrorType(applies if failed as closedStatus):STATE_API_FAIL_MAX_OUT_RETRY_ERROR_TYPE, error message:activity error (type: StateApiWaitUntil, scheduledEventID: 8, startedEventID: 9, identity: ): activity StartToClose timeout (type: StartToClose)"
assert.Equal(t, expectedMsg, err.Error())
expectedMsg := "workflow is not completed successfully, closedStatus: FAILED, failedErrorType(applies if failed as closedStatus):STATE_API_FAIL_MAX_OUT_RETRY_ERROR_TYPE, error message:activity error "
assert.True(t, strings.HasPrefix(err.Error(), expectedMsg))

out, err2 := client.GetComplexWorkflowResults(context.Background(), wfId, "")
assert.Nil(t, out)
Expand Down
2 changes: 1 addition & 1 deletion iwf/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func IsWorkflowNotExistsError(err error) bool {

func IsRPCError(err error) bool {
apiError, ok := err.(*ApiError)
if !ok || apiError.Response == nil {
if !ok {
return false
}
return apiError.StatusCode == 420
Expand Down

0 comments on commit 654c49d

Please sign in to comment.