-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug of missing IwfWorkflowType system search attribute when no wo…
…rkflowStartOptions (#309)
- Loading branch information
1 parent
34052f7
commit aae2109
Showing
3 changed files
with
100 additions
and
5 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,77 @@ | ||
package integ | ||
|
||
import ( | ||
"context" | ||
"github.com/indeedeng/iwf/service/common/ptr" | ||
"strconv" | ||
"testing" | ||
"time" | ||
|
||
"github.com/indeedeng/iwf/gen/iwfidl" | ||
"github.com/indeedeng/iwf/integ/workflow/basic" | ||
"github.com/indeedeng/iwf/service" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestStartWorkflowNoOptionsTemporal(t *testing.T) { | ||
if !*temporalIntegTest { | ||
t.Skip() | ||
} | ||
doTestStartWorkflowWithoutStartOptions(t, service.BackendTypeTemporal) | ||
} | ||
|
||
func TestStartWorkflowNoOptionsCadence(t *testing.T) { | ||
if !*cadenceIntegTest { | ||
t.Skip() | ||
} | ||
doTestStartWorkflowWithoutStartOptions(t, service.BackendTypeCadence) | ||
} | ||
|
||
func doTestStartWorkflowWithoutStartOptions(t *testing.T, backendType service.BackendType) { | ||
if !*cadenceIntegTest { | ||
t.Skip() | ||
} | ||
|
||
wfHandler := basic.NewHandler() | ||
closeFunc1 := startWorkflowWorker(wfHandler) | ||
defer closeFunc1() | ||
|
||
client, closeFunc2 := startIwfServiceWithClient(backendType) | ||
defer closeFunc2() | ||
|
||
// start a workflow | ||
apiClient := iwfidl.NewAPIClient(&iwfidl.Configuration{ | ||
Servers: []iwfidl.ServerConfiguration{ | ||
{ | ||
URL: "http://localhost:" + testIwfServerPort, | ||
}, | ||
}, | ||
}) | ||
wfId := "TestStartWorkflowWithoutStartOptions" + strconv.Itoa(int(time.Now().UnixNano())) | ||
wfInput := &iwfidl.EncodedObject{ | ||
Encoding: iwfidl.PtrString("json"), | ||
Data: iwfidl.PtrString("test data"), | ||
} | ||
req := apiClient.DefaultApi.ApiV1WorkflowStartPost(context.Background()) | ||
startReq := iwfidl.WorkflowStartRequest{ | ||
WorkflowId: wfId, | ||
IwfWorkflowType: basic.WorkflowType, | ||
WorkflowTimeoutSeconds: 100, | ||
IwfWorkerUrl: "http://localhost:" + testWorkflowServerPort, | ||
StartStateId: ptr.Any(basic.State1), | ||
StateInput: wfInput, | ||
} | ||
_, httpResp, err := req.WorkflowStartRequest(startReq).Execute() | ||
panicAtHttpError(err, httpResp) | ||
|
||
requestedSAs := []iwfidl.SearchAttributeKeyAndType{ | ||
{ | ||
Key: ptr.Any(service.SearchAttributeIwfWorkflowType), | ||
ValueType: iwfidl.KEYWORD.Ptr(), | ||
}, | ||
} | ||
response, err := client.DescribeWorkflowExecution(context.Background(), wfId, "", requestedSAs) | ||
assertions := assert.New(t) | ||
attribute := response.SearchAttributes[service.SearchAttributeIwfWorkflowType] | ||
assertions.Equal(basic.WorkflowType, attribute.GetStringValue()) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package utils | ||
|
||
func MergeMap(first map[string]interface{}, second map[string]interface{}) map[string]interface{} { | ||
out := make(map[string]interface{}, len(first)) | ||
for k, v := range first { | ||
out[k] = v | ||
} | ||
|
||
for k, v := range second { | ||
out[k] = v | ||
} | ||
return out | ||
} |