Skip to content

Commit

Permalink
IWF-439: Add comments for integration test workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
stevo89519 committed Jan 17, 2025
1 parent 87f7ded commit 731c067
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 deletions.
7 changes: 4 additions & 3 deletions integ/workflow/any_command_close/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) {
if req.GetWorkflowType() == WorkflowType {
h.invokeHistory[req.GetWorkflowStateId()+"_start"]++

// Starting the first state, return trigger signals
if req.GetWorkflowStateId() == State1 {
// Proceed after either signal is received
c.JSON(http.StatusOK, iwfidl.WorkflowStateStartResponse{
CommandRequest: &iwfidl.CommandRequest{
SignalCommands: []iwfidl.SignalCommand{
Expand All @@ -61,8 +61,8 @@ func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) {
})
return
}
// Starting the second state, return "all completed"
if req.GetWorkflowStateId() == State2 {
// Go straight to the decide methods without any commands
c.JSON(http.StatusOK, iwfidl.WorkflowStateStartResponse{
CommandRequest: &iwfidl.CommandRequest{
DeciderTriggerType: iwfidl.ALL_COMMAND_COMPLETED.Ptr(),
Expand All @@ -86,11 +86,11 @@ func (h *handler) ApiV1WorkflowStateDecide(c *gin.Context) {
if req.GetWorkflowType() == WorkflowType {
h.invokeHistory[req.GetWorkflowStateId()+"_decide"]++

// Trigger signals and move to next state
if req.GetWorkflowStateId() == State1 {
signalResults := req.GetCommandResults()
h.invokeData["signalCommandResultsLength"] = len(signalResults.SignalResults)

// Trigger signals
h.invokeData["signalChannelName0"] = signalResults.SignalResults[0].GetSignalChannelName()
h.invokeData["signalCommandId0"] = signalResults.SignalResults[0].GetCommandId()
h.invokeData["signalStatus0"] = signalResults.SignalResults[0].GetSignalRequestStatus()
Expand All @@ -100,6 +100,7 @@ func (h *handler) ApiV1WorkflowStateDecide(c *gin.Context) {
h.invokeData["signalStatus1"] = signalResults.SignalResults[1].GetSignalRequestStatus()
h.invokeData["signalValue1"] = signalResults.SignalResults[1].GetSignalValue()

// Move to State 2
c.JSON(http.StatusOK, iwfidl.WorkflowStateDecideResponse{
StateDecision: &iwfidl.StateDecision{
NextStates: []iwfidl.StateMovement{
Expand Down
4 changes: 1 addition & 3 deletions integ/workflow/any_command_combination/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) {
if req.GetWorkflowType() == WorkflowType {
h.invokeHistory[req.GetWorkflowStateId()+"_start"]++

// Starting the first state
if req.GetWorkflowStateId() == State1 {
// If the state has already retried an invalid command, return trigger signals and completion metrics
if h.hasS1RetriedForInvalidCommandId {
Expand Down Expand Up @@ -130,7 +129,6 @@ func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) {
return
}

// Starting the second state
if req.GetWorkflowStateId() == State2 {
// If the state has already retried an invalid command, return signals and completion metrics
if h.hasS2RetriedForInvalidCommandId {
Expand Down Expand Up @@ -185,7 +183,7 @@ func (h *handler) ApiV1WorkflowStateDecide(c *gin.Context) {
if req.GetWorkflowType() == WorkflowType {
h.invokeHistory[req.GetWorkflowStateId()+"_decide"]++

// Trigger signals and move to next state
// Trigger signals and move to State 2
if req.GetWorkflowStateId() == State1 {
h.invokeData["s1_commandResults"] = req.GetCommandResults()

Expand Down
7 changes: 3 additions & 4 deletions integ/workflow/any_timer_signal/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) {
if req.GetWorkflowType() == WorkflowType {
h.invokeHistory[req.GetWorkflowStateId()+"_start"]++

// Starting the first state
if req.GetWorkflowStateId() == State1 {
var timerCommands []iwfidl.TimerCommand
context := req.GetContext()
Expand Down Expand Up @@ -72,8 +71,8 @@ func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) {
return
}

// Starting the second state, return "all completed"
if req.GetWorkflowStateId() == State2 {
// Go straight to the decide methods without any commands
c.JSON(http.StatusOK, iwfidl.WorkflowStateStartResponse{
CommandRequest: &iwfidl.CommandRequest{
DeciderTriggerType: iwfidl.ALL_COMMAND_COMPLETED.Ptr(),
Expand Down Expand Up @@ -101,14 +100,14 @@ func (h *handler) ApiV1WorkflowStateDecide(c *gin.Context) {
var movements []iwfidl.StateMovement

context := req.GetContext()
// On first state attempt, trigger signals and stay on the first state
// On first State 1 attempt, trigger signals and stay on the first state
if context.GetStateExecutionId() == State1+"-"+"1" {
h.invokeData["signalChannelName1"] = signalResults.SignalResults[0].GetSignalChannelName()
h.invokeData["signalCommandId1"] = signalResults.SignalResults[0].GetCommandId()
h.invokeData["signalStatus1"] = signalResults.SignalResults[0].GetSignalRequestStatus()
movements = []iwfidl.StateMovement{{StateId: State1}}
} else {
// After the first state attempt, trigger signals and move to next state
// After the first State 1 attempt, trigger signals and move to next state
h.invokeData["signalChannelName2"] = signalResults.SignalResults[0].GetSignalChannelName()
h.invokeData["signalCommandId2"] = signalResults.SignalResults[0].GetCommandId()
h.invokeData["signalStatus2"] = signalResults.SignalResults[0].GetSignalRequestStatus()
Expand Down
8 changes: 3 additions & 5 deletions integ/workflow/conditional_close/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) {
if req.GetWorkflowType() == WorkflowType {
h.invokeHistory[req.GetWorkflowStateId()+"_start"]++

// Starting the first state
if req.GetWorkflowStateId() == State1 {

// Return channel name
// Proceed when channel is published to
cmdReq := &iwfidl.CommandRequest{
InterStateChannelCommands: []iwfidl.InterStateChannelCommand{
{
Expand All @@ -81,8 +79,8 @@ func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) {
}
input := req.GetStateInput()

// Return signal instead
if input.GetData() == "use-signal-channel" {
// Proceed when signal is published to
cmdReq = &iwfidl.CommandRequest{
SignalCommands: []iwfidl.SignalCommand{
{
Expand Down Expand Up @@ -121,7 +119,7 @@ func (h *handler) ApiV1WorkflowStateDecide(c *gin.Context) {
// Wait for 3 seconds so that the channel can have a new message
time.Sleep(time.Second * 3)
} else if context.GetStateExecutionId() == "S1-3" {
// send internal channel message within the state execution
// Send internal channel message within the state execution
// and expecting the messages are processed by the conditional check
internalChanPub = []iwfidl.InterStateChannelPublishing{
{
Expand Down
2 changes: 1 addition & 1 deletion integ/workflow/deadend/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (h *handler) ApiV1WorkflowWorkerRpc(c *gin.Context) {
}

if req.RpcName == RPCTriggerState {
// Move to first state
// Move to State 1
c.JSON(http.StatusOK, iwfidl.WorkflowWorkerRpcResponse{
StateDecision: &iwfidl.StateDecision{NextStates: []iwfidl.StateMovement{
{
Expand Down
2 changes: 1 addition & 1 deletion integ/workflow/interstate/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (h *handler) ApiV1WorkflowStateDecide(c *gin.Context) {
if req.GetWorkflowType() == WorkflowType {
h.invokeHistory[req.GetWorkflowStateId()+"_decide"]++
if req.GetWorkflowStateId() == State1 {
// First state requires no pre-reqs
// State 1 requires no pre-reqs
// Move to state 21 & 22:
// 21 - Will wait for channel 1
// 22 - Will wait 3 seconds then publish to channel 1
Expand Down

0 comments on commit 731c067

Please sign in to comment.