Skip to content

Commit

Permalink
upgrade to latest temporal sdk and proto changes (temporalio#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
samarabbas authored May 8, 2020
1 parent 6130352 commit dc0b9dd
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 55 deletions.
24 changes: 2 additions & 22 deletions common/testing/history_event_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ func InitializeHistoryEventGenerator(
historyEvent.EventType = eventpb.EventType_ActivityTaskCancelRequested
historyEvent.Attributes = &eventpb.HistoryEvent_ActivityTaskCancelRequestedEventAttributes{ActivityTaskCancelRequestedEventAttributes: &eventpb.ActivityTaskCancelRequestedEventAttributes{
DecisionTaskCompletedEventId: lastEvent.GetActivityTaskScheduledEventAttributes().DecisionTaskCompletedEventId,
ActivityId: lastEvent.GetActivityTaskScheduledEventAttributes().ActivityId,
ScheduledEventId: lastEvent.GetEventId(),
}}
return historyEvent
})
Expand All @@ -496,22 +496,6 @@ func InitializeHistoryEventGenerator(
}}
return historyEvent
})
activityCancelRequestFail := NewHistoryEventVertex(eventpb.EventType_RequestCancelActivityTaskFailed.String())
activityCancelRequestFail.SetDataFunc(func(input ...interface{}) interface{} {
lastEvent := input[0].(*eventpb.HistoryEvent)
lastGeneratedEvent := input[1].(*eventpb.HistoryEvent)
eventID := lastGeneratedEvent.GetEventId() + 1
versionBump := input[2].(int64)
subVersion := input[3].(int64)
version := lastGeneratedEvent.GetVersion() + versionBump + subVersion
historyEvent := getDefaultHistoryEvent(eventID, version)
historyEvent.EventType = eventpb.EventType_RequestCancelActivityTaskFailed
historyEvent.Attributes = &eventpb.HistoryEvent_RequestCancelActivityTaskFailedEventAttributes{RequestCancelActivityTaskFailedEventAttributes: &eventpb.RequestCancelActivityTaskFailedEventAttributes{
ActivityId: uuid.New(),
DecisionTaskCompletedEventId: lastEvent.GetActivityTaskCancelRequestedEventAttributes().DecisionTaskCompletedEventId,
}}
return historyEvent
})
decisionCompleteToATSchedule := NewHistoryEventEdge(decisionComplete, activitySchedule)

activityScheduleToStart := NewHistoryEventEdge(activitySchedule, activityStart)
Expand Down Expand Up @@ -541,14 +525,10 @@ func InitializeHistoryEventGenerator(
activityCancelReqToCancel := NewHistoryEventEdge(activityCancelRequest, activityCancel)
activityCancelReqToCancel.SetCondition(hasPendingActivity)

activityCancelReqToCancelFail := NewHistoryEventEdge(activityCancelRequest, activityCancelRequestFail)
activityCancelRequestFailToDecisionSchedule := NewHistoryEventEdge(activityCancelRequestFail, decisionSchedule)
activityCancelRequestFailToDecisionSchedule.SetCondition(notPendingDecisionTask)

activityModel.AddEdge(decisionCompleteToATSchedule, activityScheduleToStart, activityStartToComplete,
activityStartToFail, activityStartToTimedOut, decisionCompleteToATSchedule, activityCompleteToDecisionSchedule,
activityFailToDecisionSchedule, activityTimedOutToDecisionSchedule, activityCancelReqToCancel,
activityCancelReqToCancelFail, activityCancelToDecisionSchedule, activityCancelRequestFailToDecisionSchedule)
activityCancelToDecisionSchedule)

// Setup timer model
timerModel := NewHistoryEventModel()
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ require (
github.com/urfave/cli v1.20.0
github.com/valyala/fastjson v1.4.1
github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2
go.temporal.io/temporal v0.22.7
go.temporal.io/temporal-proto v0.20.33
go.temporal.io/temporal v0.22.8
go.temporal.io/temporal-proto v0.20.34
go.uber.org/atomic v1.6.0
go.uber.org/multierr v1.5.0
go.uber.org/zap v1.15.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,14 @@ go.opencensus.io v0.21.0 h1:mU6zScU4U1YAFPHEHYk+3JC4SY7JxgkqS10ZOSyksNg=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.temporal.io/temporal v0.22.7 h1:il0yKuZh8cioDF0Si+x1fmRrncWy9mB4mN4NbN7HzuQ=
go.temporal.io/temporal v0.22.7/go.mod h1:+3O0OE/Y5pAKG5vJQ8ROVpLyWLLnyPi+T12OIIxYVi0=
go.temporal.io/temporal v0.22.8 h1:9C56YlU+zoDzumd2BQvgJT/LQyAJ2HGF7yBg80zQr10=
go.temporal.io/temporal v0.22.8/go.mod h1:fCMDQ1ZBowNFc92Hny7nRXigLFJzXgD2zvAFQO4WMpI=
go.temporal.io/temporal-proto v0.20.31 h1:AlY49UhslnoUSV9HvnEewgy0ursxMPrOJAaQZHmDwzM=
go.temporal.io/temporal-proto v0.20.31/go.mod h1:Lv8L8YBpbp0Z7V5nbvw5UD0j7x0isebhCOIDLkBqn6s=
go.temporal.io/temporal-proto v0.20.33 h1:b5PmyTtT0YQdYIrro4GafCn7LqHiaTGdGnexUe5V2p4=
go.temporal.io/temporal-proto v0.20.33/go.mod h1:Lv8L8YBpbp0Z7V5nbvw5UD0j7x0isebhCOIDLkBqn6s=
go.temporal.io/temporal-proto v0.20.34 h1:IHv0Tpai7n0ayqTo6PZTASIFjdh9XvP+fOTcSmL/yw4=
go.temporal.io/temporal-proto v0.20.34/go.mod h1:Lv8L8YBpbp0Z7V5nbvw5UD0j7x0isebhCOIDLkBqn6s=
go.uber.org/atomic v1.5.0 h1:OI5t8sDa1Or+q8AeE+yKeB/SDYioSHAgcVljj9JIETY=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk=
Expand Down
8 changes: 6 additions & 2 deletions host/activity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,7 @@ func (s *integrationSuite) TestActivityCancellation() {
activityCounter := int32(0)
scheduleActivity := true
requestCancellation := false
activityScheduleID := int64(0)

dtHandler := func(execution *executionpb.WorkflowExecution, wt *commonpb.WorkflowType,
previousStartedEventID, startedEventID int64, history *eventpb.History) ([]*decisionpb.Decision, error) {
Expand All @@ -1130,6 +1131,7 @@ func (s *integrationSuite) TestActivityCancellation() {
buf := new(bytes.Buffer)
s.Nil(binary.Write(buf, binary.LittleEndian, activityCounter))

activityScheduleID = startedEventID + 2
return []*decisionpb.Decision{{
DecisionType: decisionpb.DecisionType_ScheduleActivityTask,
Attributes: &decisionpb.Decision_ScheduleActivityTaskDecisionAttributes{ScheduleActivityTaskDecisionAttributes: &decisionpb.ScheduleActivityTaskDecisionAttributes{
Expand All @@ -1149,7 +1151,7 @@ func (s *integrationSuite) TestActivityCancellation() {
return []*decisionpb.Decision{{
DecisionType: decisionpb.DecisionType_RequestCancelActivityTask,
Attributes: &decisionpb.Decision_RequestCancelActivityTaskDecisionAttributes{RequestCancelActivityTaskDecisionAttributes: &decisionpb.RequestCancelActivityTaskDecisionAttributes{
ActivityId: strconv.Itoa(int(activityCounter)),
ScheduledEventId: activityScheduleID,
}},
}}, nil
}
Expand Down Expand Up @@ -1247,6 +1249,7 @@ func (s *integrationSuite) TestActivityCancellationNotStarted() {
activityCounter := int32(0)
scheduleActivity := true
requestCancellation := false
activityScheduleID := int64(0)

dtHandler := func(execution *executionpb.WorkflowExecution, wt *commonpb.WorkflowType,
previousStartedEventID, startedEventID int64, history *eventpb.History) ([]*decisionpb.Decision, error) {
Expand All @@ -1255,6 +1258,7 @@ func (s *integrationSuite) TestActivityCancellationNotStarted() {
buf := new(bytes.Buffer)
s.Nil(binary.Write(buf, binary.LittleEndian, activityCounter))
s.Logger.Info("Scheduling activity")
activityScheduleID = startedEventID + 2
return []*decisionpb.Decision{{
DecisionType: decisionpb.DecisionType_ScheduleActivityTask,
Attributes: &decisionpb.Decision_ScheduleActivityTaskDecisionAttributes{ScheduleActivityTaskDecisionAttributes: &decisionpb.ScheduleActivityTaskDecisionAttributes{
Expand All @@ -1275,7 +1279,7 @@ func (s *integrationSuite) TestActivityCancellationNotStarted() {
return []*decisionpb.Decision{{
DecisionType: decisionpb.DecisionType_RequestCancelActivityTask,
Attributes: &decisionpb.Decision_RequestCancelActivityTaskDecisionAttributes{RequestCancelActivityTaskDecisionAttributes: &decisionpb.RequestCancelActivityTaskDecisionAttributes{
ActivityId: strconv.Itoa(int(activityCounter)),
ScheduledEventId: activityScheduleID,
}},
}}, nil
}
Expand Down
26 changes: 0 additions & 26 deletions service/history/stateBuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1253,32 +1253,6 @@ func (s *stateBuilderSuite) TestApplyEvents_EventTypeActivityTaskCancelRequested
s.Nil(err)
}

func (s *stateBuilderSuite) TestApplyEvents_EventTypeRequestCancelActivityTaskFailed() {
version := int64(1)
requestID := uuid.New()

execution := executionpb.WorkflowExecution{
WorkflowId: "some random workflow ID",
RunId: testRunID,
}

now := time.Now()
evenType := eventpb.EventType_RequestCancelActivityTaskFailed
event := &eventpb.HistoryEvent{
Version: version,
EventId: 130,
Timestamp: now.UnixNano(),
EventType: evenType,
Attributes: &eventpb.HistoryEvent_RequestCancelActivityTaskFailedEventAttributes{RequestCancelActivityTaskFailedEventAttributes: &eventpb.RequestCancelActivityTaskFailedEventAttributes{}},
}
s.mockUpdateVersion(event)
s.mockMutableState.EXPECT().GetExecutionInfo().Return(&persistence.WorkflowExecutionInfo{}).AnyTimes()
s.mockMutableState.EXPECT().ClearStickyness().Times(1)

_, err := s.stateBuilder.applyEvents(testNamespaceID, requestID, execution, s.toHistory(event), nil, false)
s.Nil(err)
}

func (s *stateBuilderSuite) TestApplyEvents_EventTypeActivityTaskCanceled() {
version := int64(1)
requestID := uuid.New()
Expand Down
3 changes: 0 additions & 3 deletions tools/cli/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,6 @@ func getEventAttributes(e *eventpb.HistoryEvent) interface{} {
case eventpb.EventType_ActivityTaskCancelRequested:
data = e.GetActivityTaskCancelRequestedEventAttributes()

case eventpb.EventType_RequestCancelActivityTaskFailed:
data = e.GetRequestCancelActivityTaskFailedEventAttributes()

case eventpb.EventType_ActivityTaskCanceled:
data = e.GetActivityTaskCanceledEventAttributes()

Expand Down

0 comments on commit dc0b9dd

Please sign in to comment.