Skip to content

Commit

Permalink
Fix printHistory util and remove abusing in tests (cadence-workflow#1824
Browse files Browse the repository at this point in the history
)
  • Loading branch information
longquanzheng authored May 9, 2019
1 parent 189ecbc commit a33c480
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 67 deletions.
7 changes: 4 additions & 3 deletions common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package common

import (
"encoding/json"
"fmt"
"math/rand"
"sync"
"time"
Expand Down Expand Up @@ -256,9 +257,9 @@ func PrettyPrintHistory(history *workflow.History, logger log.Logger) {
logger.Error("Error serializing history: %v\n", tag.Error(err))
}

logger.Info("******************************************")
logger.Info("History", tag.DetailInfo(string(data)))
logger.Info("******************************************")
fmt.Println("******************************************")
fmt.Println("History", tag.DetailInfo(string(data)))
fmt.Println("******************************************")
}

// IsValidContext checks that the thrift context is not expired on cancelled.
Expand Down
17 changes: 0 additions & 17 deletions host/activity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,6 @@ func (s *integrationSuite) TestActivityRetry() {
}
}

s.printWorkflowHistory(s.domainName, &workflow.WorkflowExecution{
WorkflowId: common.StringPtr(id),
RunId: common.StringPtr(we.GetRunId()),
})
s.True(workflowComplete)
s.True(activityExecutedCount == 2)
}
Expand Down Expand Up @@ -836,10 +832,6 @@ func (s *integrationSuite) TestActivityTimeouts() {
}
}

s.printWorkflowHistory(s.domainName, &workflow.WorkflowExecution{
WorkflowId: common.StringPtr(id),
RunId: common.StringPtr(we.GetRunId()),
})
s.True(workflowComplete)
}

Expand Down Expand Up @@ -1024,10 +1016,6 @@ func (s *integrationSuite) TestActivityHeartbeatTimeouts() {
}
}

s.printWorkflowHistory(s.domainName, &workflow.WorkflowExecution{
WorkflowId: common.StringPtr(id),
RunId: common.StringPtr(we.GetRunId()),
})
s.True(workflowComplete)
s.False(failWorkflow, failReason)
s.Equal(activityCount, activitiesTimedout)
Expand Down Expand Up @@ -1286,9 +1274,4 @@ func (s *integrationSuite) TestActivityCancellationNotStarted() {
requestCancellation = false
_, err = poller.PollAndProcessDecisionTask(false, false)
s.True(err == nil || err == matching.ErrNoTasks)

s.printWorkflowHistory(s.domainName, &workflow.WorkflowExecution{
WorkflowId: common.StringPtr(id),
RunId: common.StringPtr(we.GetRunId()),
})
}
4 changes: 0 additions & 4 deletions host/cancelworkflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ GetHistoryLoop:
})
s.Nil(err)
history := historyResponse.History
common.PrettyPrintHistory(history, s.Logger)

lastEvent := history.Events[len(history.Events)-1]
if *lastEvent.EventType != workflow.EventTypeWorkflowExecutionCanceled {
Expand Down Expand Up @@ -337,7 +336,6 @@ CheckHistoryLoopForCancelSent:
})
s.Nil(err)
history := historyResponse.History
common.PrettyPrintHistory(history, s.Logger)

lastEvent := history.Events[len(history.Events)-2]
if *lastEvent.EventType != workflow.EventTypeExternalWorkflowExecutionCancelRequested {
Expand Down Expand Up @@ -374,7 +372,6 @@ GetHistoryLoop:
})
s.Nil(err)
history := historyResponse.History
common.PrettyPrintHistory(history, s.Logger)

lastEvent := history.Events[len(history.Events)-1]
if *lastEvent.EventType != workflow.EventTypeWorkflowExecutionCanceled {
Expand Down Expand Up @@ -507,7 +504,6 @@ CheckHistoryLoopForCancelSent:
})
s.Nil(err)
history := historyResponse.History
common.PrettyPrintHistory(history, s.Logger)

lastEvent := history.Events[len(history.Events)-2]
if *lastEvent.EventType != workflow.EventTypeRequestCancelExternalWorkflowExecutionFailed {
Expand Down
9 changes: 0 additions & 9 deletions host/continueasnew_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ GetHistoryLoop:
})
s.Nil(err)
history := historyResponse.History
common.PrettyPrintHistory(history, s.Logger)

lastEvent := history.Events[len(history.Events)-1]
if *lastEvent.EventType != workflow.EventTypeWorkflowExecutionTimedOut {
Expand Down Expand Up @@ -479,12 +478,4 @@ func (s *integrationSuite) TestChildWorkflowWithContinueAsNew() {
s.Equal([]byte("Child Done."), completedAttributes.Result)

s.Logger.Info("Parent Workflow Execution History: ")
s.printWorkflowHistory(s.domainName, &workflow.WorkflowExecution{
WorkflowId: common.StringPtr(parentID),
RunId: common.StringPtr(*we.RunId),
})

s.Logger.Info("Child Workflow Execution History: ")
s.printWorkflowHistory(s.domainName,
startedEvent.ChildWorkflowExecutionStartedEventAttributes.WorkflowExecution)
}
27 changes: 0 additions & 27 deletions host/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ GetHistoryLoop:
})
s.Nil(err)
history := historyResponse.History
common.PrettyPrintHistory(history, s.Logger)

lastEvent := history.Events[len(history.Events)-1]
if *lastEvent.EventType != workflow.EventTypeWorkflowExecutionTerminated {
Expand Down Expand Up @@ -1175,8 +1174,6 @@ func (s *integrationSuite) TestRateLimitBufferedEvents() {
s.Logger.Info("PollAndProcessDecisionTask", tag.Error(err))
s.Nil(err)

s.printWorkflowHistory(s.domainName, workflowExecution)

s.True(workflowComplete)
s.Equal(101, signalCount) // check that all 101 signals are received.
}
Expand Down Expand Up @@ -1736,14 +1733,6 @@ func (s *integrationSuite) TestChildWorkflowExecution() {
s.Equal([]byte("Child Done."), completedAttributes.Result)

s.Logger.Info("Parent Workflow Execution History: ")
s.printWorkflowHistory(s.domainName, &workflow.WorkflowExecution{
WorkflowId: common.StringPtr(parentID),
RunId: common.StringPtr(*we.RunId),
})

s.Logger.Info("Child Workflow Execution History: ")
s.printWorkflowHistory(s.domainName,
startedEvent.ChildWorkflowExecutionStartedEventAttributes.WorkflowExecution)
}

func (s *integrationSuite) TestCronChildWorkflowExecution() {
Expand Down Expand Up @@ -1997,7 +1986,6 @@ GetHistoryLoop:
})
s.Nil(err)
history := historyResponse.History
common.PrettyPrintHistory(history, s.Logger)

lastEvent := history.Events[len(history.Events)-1]
if *lastEvent.EventType != workflow.EventTypeWorkflowExecutionTimedOut {
Expand Down Expand Up @@ -2215,8 +2203,6 @@ func (s *integrationSuite) TestDecisionTaskFailed() {
s.True(workflowComplete)
s.Equal(16, signalCount)

s.printWorkflowHistory(s.domainName, workflowExecution)

events := s.getHistory(s.domainName, workflowExecution)
var lastEvent *workflow.HistoryEvent
var lastDecisionStartedEvent *workflow.HistoryEvent
Expand Down Expand Up @@ -2455,12 +2441,6 @@ func (s *integrationSuite) TestTransientDecisionTimeout() {
s.Logger.Info("PollAndProcessDecisionTask", tag.Error(err))
s.Nil(err)

// Print history after dropping decision
s.printWorkflowHistory(s.domainName, &workflow.WorkflowExecution{
WorkflowId: common.StringPtr(id),
RunId: common.StringPtr(we.GetRunId()),
})

// Now process signal and complete workflow execution
_, err = poller.PollAndProcessDecisionTaskWithAttempt(true, false, false, false, int64(1))
s.Logger.Info("PollAndProcessDecisionTask", tag.Error(err))
Expand Down Expand Up @@ -2649,7 +2629,6 @@ func (s *integrationSuite) TestRelayDecisionTimeout() {
}
// verify relay decision task timeout
s.True(decisionTaskTimeout)
s.printWorkflowHistory(s.domainName, workflowExecution)

// Now complete workflow
_, err = poller.PollAndProcessDecisionTaskWithAttempt(true, false, false, false, int64(1))
Expand Down Expand Up @@ -2772,8 +2751,6 @@ func (s *integrationSuite) TestTaskProcessingProtectionForRateLimitError() {
s.Logger.Info("pollAndProcessDecisionTask", tag.Error(err))
s.Nil(err)

s.printWorkflowHistory(s.domainName, workflowExecution)

s.True(workflowComplete)
s.Equal(102, signalCount)
}
Expand Down Expand Up @@ -2950,7 +2927,6 @@ WaitForStickyTimeoutLoop:
}
s.True(workflowComplete, "Workflow not complete")
s.Equal(2, failedDecisions, "Mismatched failed decision count")
s.printWorkflowHistory(s.domainName, workflowExecution)
}

func (s *integrationSuite) TestStickyTasklistResetThenTimeout() {
Expand Down Expand Up @@ -3119,7 +3095,6 @@ WaitForStickyTimeoutLoop:
}
s.True(workflowComplete, "Workflow not complete")
s.Equal(2, failedDecisions, "Mismatched failed decision count")
s.printWorkflowHistory(s.domainName, workflowExecution)
}

func (s *integrationSuite) TestBufferedEventsOutOfOrder() {
Expand Down Expand Up @@ -3269,8 +3244,6 @@ func (s *integrationSuite) TestBufferedEventsOutOfOrder() {
s.Equal(scheduleEvent.GetEventId(), completedEvent.ActivityTaskCompletedEventAttributes.GetScheduledEventId())
s.Equal(startedEvent.GetEventId(), completedEvent.ActivityTaskCompletedEventAttributes.GetStartedEventId())
s.True(workflowComplete)

s.printWorkflowHistory(s.domainName, workflowExecution)
}

type startFunc func() (*workflow.StartWorkflowExecutionResponse, error)
Expand Down
5 changes: 1 addition & 4 deletions host/signalworkflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ CheckHistoryLoopForSignalSent:
})
s.Nil(err)
history := historyResponse.History
common.PrettyPrintHistory(history, s.Logger)
//common.PrettyPrintHistory(history, s.Logger)

signalRequestedEvent := history.Events[len(history.Events)-2]
if *signalRequestedEvent.EventType != workflow.EventTypeExternalWorkflowExecutionSignaled {
Expand Down Expand Up @@ -771,7 +771,6 @@ CheckHistoryLoopForSignalSent:
})
s.Nil(err)
history := historyResponse.History
common.PrettyPrintHistory(history, s.Logger)

signalRequestedEvent := history.Events[len(history.Events)-2]
if *signalRequestedEvent.EventType != workflow.EventTypeExternalWorkflowExecutionSignaled {
Expand Down Expand Up @@ -911,7 +910,6 @@ CheckHistoryLoopForCancelSent:
})
s.Nil(err)
history := historyResponse.History
common.PrettyPrintHistory(history, s.Logger)

signalFailedEvent := history.Events[len(history.Events)-2]
if *signalFailedEvent.EventType != workflow.EventTypeSignalExternalWorkflowExecutionFailed {
Expand Down Expand Up @@ -1039,7 +1037,6 @@ CheckHistoryLoopForCancelSent:
})
s.Nil(err)
history := historyResponse.History
common.PrettyPrintHistory(history, s.Logger)

signalFailedEvent := history.Events[len(history.Events)-2]
if *signalFailedEvent.EventType != workflow.EventTypeSignalExternalWorkflowExecutionFailed {
Expand Down
1 change: 0 additions & 1 deletion hostxdc/integration_domain_failover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,6 @@ func (s *integrationClustersTestSuite) TestActivityHeartbeatFailover() {
})
s.Nil(err)
history := historyResponse.History
common.PrettyPrintHistory(history, s.logger)

activityRetryFound := false
for _, event := range history.Events {
Expand Down
2 changes: 0 additions & 2 deletions service/history/timerBuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ func (s *timerBuilderProcessorSuite) TestDecodeHistory() {

history := &workflow.History{}
history.Events = historyEvents

common.PrettyPrintHistory(history, s.logger)
}

func (s *timerBuilderProcessorSuite) TestDecodeKey() {
Expand Down

0 comments on commit a33c480

Please sign in to comment.