Skip to content

Commit

Permalink
IWF-473: Fixing flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel27m committed Feb 21, 2025
1 parent 8194a71 commit 5b84b13
Showing 1 changed file with 4 additions and 25 deletions.
29 changes: 4 additions & 25 deletions integ/workflow/wf_ignore_already_started/routers.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package wf_ignore_already_started

import (
"github.com/indeedeng/iwf/integ/helpers"
"github.com/gin-gonic/gin"
"github.com/indeedeng/iwf/gen/iwfidl"
"github.com/indeedeng/iwf/service"
"github.com/indeedeng/iwf/service/common/ptr"
"log"
"net/http"
"strconv"
"sync"
"testing"
"time"

"github.com/gin-gonic/gin"
"github.com/indeedeng/iwf/gen/iwfidl"
"github.com/indeedeng/iwf/service"
)

/**
Expand All @@ -29,7 +25,6 @@ const (

type handler struct {
invokeHistory sync.Map
invokeData sync.Map
}

func NewHandler() *handler {
Expand All @@ -55,12 +50,6 @@ func (h *handler) ApiV1WorkflowStateStart(c *gin.Context, t *testing.T) {
}

if req.GetWorkflowStateId() == State1 {
nowInt, err := strconv.Atoi(req.StateInput.GetData())
if err != nil {
helpers.FailTestWithError(err, t)
}
now := int64(nowInt)
h.invokeData.Store("scheduled_at", now)
c.JSON(http.StatusOK, iwfidl.WorkflowStateStartResponse{
CommandRequest: &iwfidl.CommandRequest{
TimerCommands: []iwfidl.TimerCommand{
Expand Down Expand Up @@ -95,11 +84,6 @@ func (h *handler) ApiV1WorkflowStateDecide(c *gin.Context, t *testing.T) {
}

if req.GetWorkflowStateId() == State1 {
now := time.Now().Unix()
h.invokeData.Store("fired_at", now)
timerResults := req.GetCommandResults()
timerId := timerResults.GetTimerResults()[0].GetCommandId()
h.invokeData.Store("timer_id", timerId)
c.JSON(http.StatusOK, iwfidl.WorkflowStateDecideResponse{
StateDecision: &iwfidl.StateDecision{
NextStates: []iwfidl.StateMovement{
Expand All @@ -122,10 +106,5 @@ func (h *handler) GetTestResult() (map[string]int64, map[string]interface{}) {
invokeHistory[key.(string)] = value.(int64)
return true
})
invokeData := make(map[string]interface{})
h.invokeData.Range(func(key, value interface{}) bool {
invokeData[key.(string)] = value
return true
})
return invokeHistory, invokeData
return invokeHistory, nil
}

0 comments on commit 5b84b13

Please sign in to comment.