Skip to content

Commit

Permalink
Default workflow execution timeout (temporalio#307)
Browse files Browse the repository at this point in the history
* Added default and max value for workflowExecutionTimeout
  • Loading branch information
mfateev authored Apr 16, 2020
1 parent ef805bd commit 2e20173
Show file tree
Hide file tree
Showing 48 changed files with 335 additions and 304 deletions.
7 changes: 3 additions & 4 deletions common/archiver/filestore/historyArchiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
eventpb "go.temporal.io/temporal-proto/event"
"go.temporal.io/temporal-proto/serviceerror"
"go.uber.org/zap"

archiverproto "github.com/temporalio/temporal/.gen/proto/archiver"
"github.com/temporalio/temporal/common"
"github.com/temporalio/temporal/common/archiver"
"github.com/temporalio/temporal/common/log/loggerimpl"
"github.com/temporalio/temporal/common/service/config"
eventpb "go.temporal.io/temporal-proto/event"
"go.temporal.io/temporal-proto/serviceerror"
"go.uber.org/zap"
)

const (
Expand Down
10 changes: 5 additions & 5 deletions common/archiver/filestore/queryParser.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import (
"strings"
"time"

"github.com/temporalio/temporal/common"
"github.com/temporalio/temporal/common/convert"
"github.com/xwb1989/sqlparser"
executionpb "go.temporal.io/temporal-proto/execution"

"github.com/temporalio/temporal/common"
)

type (
Expand Down Expand Up @@ -149,7 +149,7 @@ func (p *queryParser) convertComparisonExpr(compExpr *sqlparser.ComparisonExpr,
parsedQuery.emptyResult = true
return nil
}
parsedQuery.workflowID = common.StringPtr(val)
parsedQuery.workflowID = convert.StringPtr(val)
case RunID:
val, err := extractStringValue(valStr)
if err != nil {
Expand All @@ -162,7 +162,7 @@ func (p *queryParser) convertComparisonExpr(compExpr *sqlparser.ComparisonExpr,
parsedQuery.emptyResult = true
return nil
}
parsedQuery.runID = common.StringPtr(val)
parsedQuery.runID = convert.StringPtr(val)
case WorkflowType:
val, err := extractStringValue(valStr)
if err != nil {
Expand All @@ -175,7 +175,7 @@ func (p *queryParser) convertComparisonExpr(compExpr *sqlparser.ComparisonExpr,
parsedQuery.emptyResult = true
return nil
}
parsedQuery.workflowTypeName = common.StringPtr(val)
parsedQuery.workflowTypeName = convert.StringPtr(val)
case ExecutionStatus:
val, err := extractStringValue(valStr)
if err != nil {
Expand Down
23 changes: 11 additions & 12 deletions common/archiver/filestore/queryParser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ import (

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/temporalio/temporal/common/convert"
executionpb "go.temporal.io/temporal-proto/execution"

"github.com/temporalio/temporal/common"
)

type queryParserSuite struct {
Expand Down Expand Up @@ -60,35 +59,35 @@ func (s *queryParserSuite) TestParseWorkflowID_RunID_WorkflowType() {
query: "WorkflowId = \"random workflowID\"",
expectErr: false,
parsedQuery: &parsedQuery{
workflowID: common.StringPtr("random workflowID"),
workflowID: convert.StringPtr("random workflowID"),
},
},
{
query: "WorkflowId = \"random workflowID\" and WorkflowId = \"random workflowID\"",
expectErr: false,
parsedQuery: &parsedQuery{
workflowID: common.StringPtr("random workflowID"),
workflowID: convert.StringPtr("random workflowID"),
},
},
{
query: "RunId = \"random runID\"",
expectErr: false,
parsedQuery: &parsedQuery{
runID: common.StringPtr("random runID"),
runID: convert.StringPtr("random runID"),
},
},
{
query: "WorkflowType = \"random typeName\"",
expectErr: false,
parsedQuery: &parsedQuery{
workflowTypeName: common.StringPtr("random typeName"),
workflowTypeName: convert.StringPtr("random typeName"),
},
},
{
query: "WorkflowId = 'random workflowID'",
expectErr: false,
parsedQuery: &parsedQuery{
workflowID: common.StringPtr("random workflowID"),
workflowID: convert.StringPtr("random workflowID"),
},
},
{
Expand All @@ -102,9 +101,9 @@ func (s *queryParserSuite) TestParseWorkflowID_RunID_WorkflowType() {
query: "WorkflowType = 'random typeName' and (WorkflowId = \"random workflowID\" and RunId='random runID')",
expectErr: false,
parsedQuery: &parsedQuery{
workflowID: common.StringPtr("random workflowID"),
runID: common.StringPtr("random runID"),
workflowTypeName: common.StringPtr("random typeName"),
workflowID: convert.StringPtr("random workflowID"),
runID: convert.StringPtr("random runID"),
workflowTypeName: convert.StringPtr("random typeName"),
},
},
{
Expand Down Expand Up @@ -290,7 +289,7 @@ func (s *queryParserSuite) TestParse() {
parsedQuery: &parsedQuery{
earliestCloseTime: 0,
latestCloseTime: 1546341071000000000,
workflowID: common.StringPtr("random workflowID"),
workflowID: convert.StringPtr("random workflowID"),
},
},
{
Expand All @@ -299,7 +298,7 @@ func (s *queryParserSuite) TestParse() {
parsedQuery: &parsedQuery{
earliestCloseTime: 2000,
latestCloseTime: 9999,
runID: common.StringPtr("random runID"),
runID: convert.StringPtr("random runID"),
status: toWorkflowExecutionStatusPtr(executionpb.WorkflowExecutionStatus_Failed),
},
},
Expand Down
21 changes: 10 additions & 11 deletions common/archiver/filestore/visibilityArchiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,15 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
commonpb "go.temporal.io/temporal-proto/common"
executionpb "go.temporal.io/temporal-proto/execution"
"go.uber.org/zap"

archiverproto "github.com/temporalio/temporal/.gen/proto/archiver"
"github.com/temporalio/temporal/common"
"github.com/temporalio/temporal/common/archiver"
"github.com/temporalio/temporal/common/codec"
"github.com/temporalio/temporal/common/convert"
"github.com/temporalio/temporal/common/log/loggerimpl"
"github.com/temporalio/temporal/common/service/config"
commonpb "go.temporal.io/temporal-proto/common"
executionpb "go.temporal.io/temporal-proto/execution"
"go.uber.org/zap"
)

const (
Expand Down Expand Up @@ -235,7 +234,7 @@ func (s *visibilityArchiverSuite) TestMatchQuery() {
query: &parsedQuery{
earliestCloseTime: int64(1000),
latestCloseTime: int64(12345),
workflowID: common.StringPtr("random workflowID"),
workflowID: convert.StringPtr("random workflowID"),
},
record: &archiverproto.ArchiveVisibilityRequest{
CloseTimestamp: int64(2000),
Expand All @@ -246,8 +245,8 @@ func (s *visibilityArchiverSuite) TestMatchQuery() {
query: &parsedQuery{
earliestCloseTime: int64(1000),
latestCloseTime: int64(12345),
workflowID: common.StringPtr("random workflowID"),
runID: common.StringPtr("random runID"),
workflowID: convert.StringPtr("random workflowID"),
runID: convert.StringPtr("random runID"),
},
record: &archiverproto.ArchiveVisibilityRequest{
CloseTimestamp: int64(12345),
Expand All @@ -261,7 +260,7 @@ func (s *visibilityArchiverSuite) TestMatchQuery() {
query: &parsedQuery{
earliestCloseTime: int64(1000),
latestCloseTime: int64(12345),
workflowTypeName: common.StringPtr("some random type name"),
workflowTypeName: convert.StringPtr("some random type name"),
},
record: &archiverproto.ArchiveVisibilityRequest{
CloseTimestamp: int64(12345),
Expand All @@ -272,7 +271,7 @@ func (s *visibilityArchiverSuite) TestMatchQuery() {
query: &parsedQuery{
earliestCloseTime: int64(1000),
latestCloseTime: int64(12345),
workflowTypeName: common.StringPtr("some random type name"),
workflowTypeName: convert.StringPtr("some random type name"),
status: toWorkflowExecutionStatusPtr(executionpb.WorkflowExecutionStatus_ContinuedAsNew),
},
record: &archiverproto.ArchiveVisibilityRequest{
Expand Down Expand Up @@ -408,7 +407,7 @@ func (s *visibilityArchiverSuite) TestQuery_Success_NoNextPageToken() {
mockParser.EXPECT().Parse(gomock.Any()).Return(&parsedQuery{
earliestCloseTime: int64(1),
latestCloseTime: int64(10001),
workflowID: common.StringPtr(testWorkflowID),
workflowID: convert.StringPtr(testWorkflowID),
}, nil)
visibilityArchiver.queryParser = mockParser
request := &archiver.QueryVisibilityRequest{
Expand Down
12 changes: 6 additions & 6 deletions common/archiver/gcloud/historyArchiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/uber-go/tally"
eventpb "go.temporal.io/temporal-proto/event"
"go.temporal.io/temporal-proto/serviceerror"
"go.uber.org/zap"

archiverproto "github.com/temporalio/temporal/.gen/proto/archiver"
"github.com/temporalio/temporal/common"
"github.com/temporalio/temporal/common/archiver"
"github.com/temporalio/temporal/common/archiver/gcloud/connector"
"github.com/temporalio/temporal/common/archiver/gcloud/connector/mocks"
"github.com/temporalio/temporal/common/convert"
"github.com/temporalio/temporal/common/log/loggerimpl"
"github.com/temporalio/temporal/common/metrics"
"github.com/uber-go/tally"
eventpb "go.temporal.io/temporal-proto/event"
"go.temporal.io/temporal-proto/serviceerror"
"go.uber.org/zap"
)

const (
Expand Down Expand Up @@ -467,7 +467,7 @@ func (h *historyArchiverSuite) TestGet_Success_UseProvidedVersion() {
WorkflowID: testWorkflowID,
RunID: testRunID,
PageSize: testPageSize,
CloseFailoverVersion: common.Int64Ptr(-25),
CloseFailoverVersion: convert.Int64Ptr(-25),
}

h.NoError(err)
Expand Down
11 changes: 5 additions & 6 deletions common/archiver/gcloud/queryParser.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ import (
"strconv"
"time"

"github.com/temporalio/temporal/common/convert"
"github.com/xwb1989/sqlparser"

"github.com/temporalio/temporal/common"
)

type (
Expand Down Expand Up @@ -161,7 +160,7 @@ func (p *queryParser) convertComparisonExpr(compExpr *sqlparser.ComparisonExpr,
parsedQuery.emptyResult = true
return nil
}
parsedQuery.workflowID = common.StringPtr(val)
parsedQuery.workflowID = convert.StringPtr(val)
case RunID:
val, err := extractStringValue(valStr)
if err != nil {
Expand All @@ -174,7 +173,7 @@ func (p *queryParser) convertComparisonExpr(compExpr *sqlparser.ComparisonExpr,
parsedQuery.emptyResult = true
return nil
}
parsedQuery.runID = common.StringPtr(val)
parsedQuery.runID = convert.StringPtr(val)
case CloseTime:
timestamp, err := convertToTimestamp(valStr)
if err != nil {
Expand Down Expand Up @@ -206,7 +205,7 @@ func (p *queryParser) convertComparisonExpr(compExpr *sqlparser.ComparisonExpr,
parsedQuery.emptyResult = true
return nil
}
parsedQuery.workflowType = common.StringPtr(val)
parsedQuery.workflowType = convert.StringPtr(val)
case SearchPrecision:
val, err := extractStringValue(valStr)
if err != nil {
Expand All @@ -226,7 +225,7 @@ func (p *queryParser) convertComparisonExpr(compExpr *sqlparser.ComparisonExpr,
default:
return fmt.Errorf("invalid value for %s: %s", SearchPrecision, val)
}
parsedQuery.searchPrecision = common.StringPtr(val)
parsedQuery.searchPrecision = convert.StringPtr(val)
default:
return fmt.Errorf("unknown filter name: %s", colNameStr)
}
Expand Down
21 changes: 10 additions & 11 deletions common/archiver/gcloud/visibilityArchiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/uber-go/tally"
executionpb "go.temporal.io/temporal-proto/execution"
"go.uber.org/zap"

archiverproto "github.com/temporalio/temporal/.gen/proto/archiver"
"github.com/temporalio/temporal/common"
"github.com/temporalio/temporal/common/archiver"
"github.com/temporalio/temporal/common/archiver/gcloud/connector/mocks"
"github.com/temporalio/temporal/common/convert"
"github.com/temporalio/temporal/common/log/loggerimpl"
"github.com/temporalio/temporal/common/metrics"
"github.com/uber-go/tally"
executionpb "go.temporal.io/temporal-proto/execution"
"go.uber.org/zap"
)

const (
Expand Down Expand Up @@ -267,9 +266,9 @@ func (s *visibilityArchiverSuite) TestQuery_Success_NoNextPageToken() {
mockParser.EXPECT().Parse(gomock.Any()).Return(&parsedQuery{
closeTime: int64(101),
searchPrecision: &dayPrecision,
workflowType: common.StringPtr("MobileOnlyWorkflow::processMobileOnly"),
workflowID: common.StringPtr(testWorkflowID),
runID: common.StringPtr(testRunID),
workflowType: convert.StringPtr("MobileOnlyWorkflow::processMobileOnly"),
workflowID: convert.StringPtr(testWorkflowID),
runID: convert.StringPtr(testRunID),
}, nil)
visibilityArchiver.queryParser = mockParser
request := &archiver.QueryVisibilityRequest{
Expand Down Expand Up @@ -310,9 +309,9 @@ func (s *visibilityArchiverSuite) TestQuery_Success_SmallPageSize() {
mockParser.EXPECT().Parse(gomock.Any()).Return(&parsedQuery{
closeTime: int64(101),
searchPrecision: &dayPrecision,
workflowType: common.StringPtr("MobileOnlyWorkflow::processMobileOnly"),
workflowID: common.StringPtr(testWorkflowID),
runID: common.StringPtr(testRunID),
workflowType: convert.StringPtr("MobileOnlyWorkflow::processMobileOnly"),
workflowID: convert.StringPtr(testWorkflowID),
runID: convert.StringPtr(testRunID),
}, nil).AnyTimes()
visibilityArchiver.queryParser = mockParser
request := &archiver.QueryVisibilityRequest{
Expand Down
14 changes: 7 additions & 7 deletions common/archiver/s3store/historyArchiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/uber-go/tally"
eventpb "go.temporal.io/temporal-proto/event"
"go.temporal.io/temporal-proto/serviceerror"
"go.uber.org/zap"

archiverproto "github.com/temporalio/temporal/.gen/proto/archiver"
"github.com/temporalio/temporal/common"
"github.com/temporalio/temporal/common/archiver"
"github.com/temporalio/temporal/common/archiver/s3store/mocks"
"github.com/temporalio/temporal/common/codec"
"github.com/temporalio/temporal/common/convert"
"github.com/temporalio/temporal/common/log"
"github.com/temporalio/temporal/common/log/loggerimpl"
"github.com/temporalio/temporal/common/metrics"
"github.com/uber-go/tally"
eventpb "go.temporal.io/temporal-proto/event"
"go.temporal.io/temporal-proto/serviceerror"
"go.uber.org/zap"
)

const (
Expand Down Expand Up @@ -176,7 +176,7 @@ func setupFsEmulation(s3cli *mocks.S3API) {
var nextContinuationToken *string
if len(objects) > start+maxKeys {
isTruncated = true
nextContinuationToken = common.StringPtr(fmt.Sprintf("%d", start+maxKeys))
nextContinuationToken = convert.StringPtr(fmt.Sprintf("%d", start+maxKeys))
objects = objects[start : start+maxKeys]
} else {
objects = objects[start:]
Expand All @@ -192,7 +192,7 @@ func setupFsEmulation(s3cli *mocks.S3API) {

if len(commonPrefixes) > start+maxKeys {
isTruncated = true
nextContinuationToken = common.StringPtr(fmt.Sprintf("%d", start+maxKeys))
nextContinuationToken = convert.StringPtr(fmt.Sprintf("%d", start+maxKeys))
commonPrefixes = commonPrefixes[start : start+maxKeys]
} else if len(commonPrefixes) > 0 {
commonPrefixes = commonPrefixes[start:]
Expand Down
Loading

0 comments on commit 2e20173

Please sign in to comment.