-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix continueAsNew with large snapshot(>4MB) (#482)
- Loading branch information
1 parent
b9ce8b9
commit 1bed2dc
Showing
22 changed files
with
297 additions
and
148 deletions.
There are no files selected for viewing
26 changes: 0 additions & 26 deletions
26
.github/workflows/ci-cadence-integ-test-disable-sticky.yml
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package integ | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/indeedeng/iwf/gen/iwfidl" | ||
"github.com/indeedeng/iwf/integ/workflow/signal" | ||
"github.com/indeedeng/iwf/service" | ||
"github.com/indeedeng/iwf/service/common/ptr" | ||
"github.com/stretchr/testify/assert" | ||
"net/http" | ||
"strconv" | ||
"strings" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestLargeDataAttributesTemporalContinueAsNew(t *testing.T) { | ||
if !*temporalIntegTest { | ||
t.Skip() | ||
} | ||
for i := 0; i < *repeatIntegTest; i++ { | ||
doTestLargeQueryAttributes(t, service.BackendTypeTemporal, minimumContinueAsNewConfigV0()) | ||
smallWaitForFastTest() | ||
} | ||
} | ||
|
||
func doTestLargeQueryAttributes(t *testing.T, backendType service.BackendType, config *iwfidl.WorkflowConfig) { | ||
if !*temporalIntegTest { | ||
t.Skip() | ||
} | ||
assertions := assert.New(t) | ||
|
||
// start test workflow server | ||
wfHandler := signal.NewHandler() | ||
closeFunc1 := startWorkflowWorker(wfHandler) | ||
defer closeFunc1() | ||
|
||
_, closeFunc2 := startIwfServiceWithClient(backendType) | ||
defer closeFunc2() | ||
|
||
wfId := signal.WorkflowType + strconv.Itoa(int(time.Now().UnixNano())) | ||
|
||
// start a workflow | ||
apiClient := iwfidl.NewAPIClient(&iwfidl.Configuration{ | ||
Servers: []iwfidl.ServerConfiguration{ | ||
{ | ||
URL: "http://localhost:" + testIwfServerPort, | ||
}, | ||
}, | ||
}) | ||
req := apiClient.DefaultApi.ApiV1WorkflowStartPost(context.Background()) | ||
_, httpResp, err := req.WorkflowStartRequest(iwfidl.WorkflowStartRequest{ | ||
WorkflowId: wfId, | ||
IwfWorkflowType: signal.WorkflowType, | ||
WorkflowTimeoutSeconds: 86400, | ||
IwfWorkerUrl: "http://localhost:" + testWorkflowServerPort, | ||
StartStateId: ptr.Any(signal.State1), | ||
// this is necessary for large DAs | ||
// otherwise the workflow task will fail when trying to execute a stateAPI with data attributes >4MB | ||
StateOptions: &signal.StateOptionsForLargeDataAttributes, | ||
WorkflowStartOptions: &iwfidl.WorkflowStartOptions{ | ||
WorkflowConfigOverride: config, | ||
}, | ||
}).Execute() | ||
panicAtHttpError(err, httpResp) | ||
|
||
assertions.Equal(httpResp.StatusCode, http.StatusOK) | ||
|
||
// Define the size of the string in bytes (1 MB = 1024 * 1024 bytes) | ||
const size = 1024 * 1024 | ||
|
||
OneMbDataObject := iwfidl.EncodedObject{ | ||
Encoding: iwfidl.PtrString("json"), | ||
Data: iwfidl.PtrString(strings.Repeat("a", size)), | ||
} | ||
|
||
// setting a large data object to test, especially continueAsNew | ||
// because there is a 4MB limit for GRPC in temporal | ||
setReq := apiClient.DefaultApi.ApiV1WorkflowDataobjectsSetPost(context.Background()) | ||
for i := 0; i < 5; i++ { | ||
|
||
httpResp2, err := setReq.WorkflowSetDataObjectsRequest(iwfidl.WorkflowSetDataObjectsRequest{ | ||
WorkflowId: wfId, | ||
Objects: []iwfidl.KeyValue{ | ||
{ | ||
Key: iwfidl.PtrString("large-data-object-" + strconv.Itoa(i)), | ||
Value: &OneMbDataObject, | ||
}, | ||
}, | ||
}).Execute() | ||
|
||
panicAtHttpError(err, httpResp2) | ||
} | ||
|
||
// signal the workflow to complete | ||
for i := 0; i < 4; i++ { | ||
signalVal := iwfidl.EncodedObject{ | ||
Encoding: iwfidl.PtrString("json"), | ||
Data: iwfidl.PtrString(fmt.Sprintf("test-data-%v", i)), | ||
} | ||
|
||
req2 := apiClient.DefaultApi.ApiV1WorkflowSignalPost(context.Background()) | ||
httpResp2, err := req2.WorkflowSignalRequest(iwfidl.WorkflowSignalRequest{ | ||
WorkflowId: wfId, | ||
SignalChannelName: signal.SignalName, | ||
SignalValue: &signalVal, | ||
}).Execute() | ||
|
||
panicAtHttpError(err, httpResp2) | ||
} | ||
|
||
// wait for the workflow | ||
reqWait := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background()) | ||
_, httpResp, err = reqWait.WorkflowGetRequest(iwfidl.WorkflowGetRequest{ | ||
WorkflowId: wfId, | ||
}).Execute() | ||
panicAtHttpError(err, httpResp) | ||
} |
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
Oops, something went wrong.