go.uber.org/cadence@v1.2.9/internal/compatibility/testdata/common.go (about)

     1  // Copyright (c) 2021 Uber Technologies Inc.
     2  //
     3  // Permission is hereby granted, free of charge, to any person obtaining a copy
     4  // of this software and associated documentation files (the "Software"), to deal
     5  // in the Software without restriction, including without limitation the rights
     6  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     7  // copies of the Software, and to permit persons to whom the Software is
     8  // furnished to do so, subject to the following conditions:
     9  //
    10  // The above copyright notice and this permission notice shall be included in all
    11  // copies or substantial portions of the Software.
    12  //
    13  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    14  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    15  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    16  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    17  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    18  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    19  // SOFTWARE.
    20  
    21  package testdata
    22  
    23  import (
    24  	"time"
    25  
    26  	gogo "github.com/gogo/protobuf/types"
    27  
    28  	apiv1 "github.com/uber/cadence-idl/go/proto/api/v1"
    29  )
    30  
    31  const (
    32  	WorkflowID = "WorkflowID"
    33  	RunID      = "RunID"
    34  	RunID1     = "RunID1"
    35  	RunID2     = "RunID2"
    36  	RunID3     = "RunID3"
    37  
    38  	ActivityID = "ActivityID"
    39  	RequestID  = "RequestID"
    40  	TimerID    = "TimerID"
    41  
    42  	WorkflowTypeName     = "WorkflowTypeName"
    43  	ActivityTypeName     = "ActivityTypeName"
    44  	TaskListName         = "TaskListName"
    45  	MarkerName           = "MarkerName"
    46  	SignalName           = "SignalName"
    47  	QueryType            = "QueryType"
    48  	HostName             = "HostName"
    49  	Identity             = "Identity"
    50  	CronSchedule         = "CronSchedule"
    51  	Checksum             = "Checksum"
    52  	Reason               = "Reason"
    53  	Cause                = "Cause"
    54  	SecurityToken        = "SecurityToken"
    55  	VisibilityQuery      = "VisibilityQuery"
    56  	FeatureVersion       = "FeatureVersion"
    57  	ClientImpl           = "ClientImpl"
    58  	ClientLibraryVersion = "ClientLibraryVersion"
    59  	SupportedVersions    = "SupportedVersions"
    60  
    61  	Attempt           = 2
    62  	PageSize          = 10
    63  	HistoryLength     = 20
    64  	BacklogCountHint  = 30
    65  	AckLevel          = 1001
    66  	ReadLevel         = 1002
    67  	RatePerSecond     = 3.14
    68  	TaskID            = 444
    69  	ShardID           = 12345
    70  	MessageID1        = 50001
    71  	MessageID2        = 50002
    72  	EventStoreVersion = 333
    73  
    74  	EventID1 = int64(1)
    75  	EventID2 = int64(2)
    76  	EventID3 = int64(3)
    77  	EventID4 = int64(4)
    78  
    79  	Version1 = int64(11)
    80  	Version2 = int64(22)
    81  	Version3 = int64(33)
    82  )
    83  
    84  var (
    85  	ts            = time.Now()
    86  	Timestamp, _  = gogo.TimestampProto(ts)
    87  	Timestamp1, _ = gogo.TimestampProto(ts.Add(1 * time.Second))
    88  	Timestamp2, _ = gogo.TimestampProto(ts.Add(2 * time.Second))
    89  	Timestamp3, _ = gogo.TimestampProto(ts.Add(3 * time.Second))
    90  	Timestamp4, _ = gogo.TimestampProto(ts.Add(4 * time.Second))
    91  	Timestamp5, _ = gogo.TimestampProto(ts.Add(5 * time.Second))
    92  )
    93  
    94  var (
    95  	Duration1 = gogo.DurationProto(11 * time.Second)
    96  	Duration2 = gogo.DurationProto(12 * time.Second)
    97  	Duration3 = gogo.DurationProto(13 * time.Second)
    98  	Duration4 = gogo.DurationProto(14 * time.Second)
    99  )
   100  
   101  var (
   102  	Token1 = []byte{1, 0}
   103  	Token2 = []byte{2, 0}
   104  	Token3 = []byte{3, 0}
   105  )
   106  
   107  var (
   108  	Payload1 = apiv1.Payload{Data: []byte{10, 0}}
   109  	Payload2 = apiv1.Payload{Data: []byte{20, 0}}
   110  	Payload3 = apiv1.Payload{Data: []byte{30, 0}}
   111  )
   112  
   113  var (
   114  	ExecutionContext = []byte{110, 0}
   115  	Control          = []byte{120, 0}
   116  	NextPageToken    = []byte{130, 0}
   117  	TaskToken        = []byte{140, 0}
   118  	BranchToken      = []byte{150, 0}
   119  	QueryArgs        = &apiv1.Payload{Data: []byte{9, 9, 9}}
   120  )
   121  
   122  var (
   123  	FailureReason  = "FailureReason"
   124  	FailureDetails = []byte{190, 0}
   125  )
   126  
   127  var (
   128  	Failure = apiv1.Failure{
   129  		Reason:  FailureReason,
   130  		Details: FailureDetails,
   131  	}
   132  	WorkflowExecution = apiv1.WorkflowExecution{
   133  		WorkflowId: WorkflowID,
   134  		RunId:      RunID,
   135  	}
   136  	WorkflowType = apiv1.WorkflowType{
   137  		Name: WorkflowTypeName,
   138  	}
   139  	ActivityType = apiv1.ActivityType{
   140  		Name: ActivityTypeName,
   141  	}
   142  	TaskList = apiv1.TaskList{
   143  		Name: TaskListName,
   144  		Kind: apiv1.TaskListKind_TASK_LIST_KIND_NORMAL,
   145  	}
   146  	RetryPolicy = apiv1.RetryPolicy{
   147  		InitialInterval:          Duration1,
   148  		BackoffCoefficient:       1.1,
   149  		MaximumInterval:          Duration2,
   150  		MaximumAttempts:          3,
   151  		NonRetryableErrorReasons: []string{"a", "b"},
   152  		ExpirationInterval:       Duration3,
   153  	}
   154  	Header = apiv1.Header{
   155  		Fields: map[string]*apiv1.Payload{
   156  			"HeaderField1": &apiv1.Payload{Data: []byte{211, 0}},
   157  			"HeaderField2": &apiv1.Payload{Data: []byte{212, 0}},
   158  		},
   159  	}
   160  	Memo = apiv1.Memo{
   161  		Fields: map[string]*apiv1.Payload{
   162  			"MemoField1": &apiv1.Payload{Data: []byte{221, 0}},
   163  			"MemoField2": &apiv1.Payload{Data: []byte{222, 0}},
   164  		},
   165  	}
   166  	SearchAttributes = apiv1.SearchAttributes{
   167  		IndexedFields: map[string]*apiv1.Payload{
   168  			"IndexedField1": &apiv1.Payload{Data: []byte{231, 0}},
   169  			"IndexedField2": &apiv1.Payload{Data: []byte{232, 0}},
   170  		},
   171  	}
   172  	PayloadMap = map[string]*apiv1.Payload{
   173  		"Payload1": &Payload1,
   174  		"Payload2": &Payload2,
   175  	}
   176  	ResetPointInfo = apiv1.ResetPointInfo{
   177  		BinaryChecksum:           Checksum,
   178  		RunId:                    RunID1,
   179  		FirstDecisionCompletedId: EventID1,
   180  		CreatedTime:              Timestamp1,
   181  		ExpiringTime:             Timestamp2,
   182  		Resettable:               true,
   183  	}
   184  	ResetPointInfoArray = []*apiv1.ResetPointInfo{
   185  		&ResetPointInfo,
   186  	}
   187  	ResetPoints = apiv1.ResetPoints{
   188  		Points: ResetPointInfoArray,
   189  	}
   190  	DataBlob = apiv1.DataBlob{
   191  		EncodingType: EncodingType,
   192  		Data:         []byte{7, 7, 7},
   193  	}
   194  	DataBlobArray = []*apiv1.DataBlob{
   195  		&DataBlob,
   196  	}
   197  	StickyExecutionAttributes = apiv1.StickyExecutionAttributes{
   198  		WorkerTaskList:         &TaskList,
   199  		ScheduleToStartTimeout: Duration1,
   200  	}
   201  	ActivityLocalDispatchInfo = apiv1.ActivityLocalDispatchInfo{
   202  		ActivityId:                 ActivityID,
   203  		ScheduledTime:              Timestamp1,
   204  		StartedTime:                Timestamp2,
   205  		ScheduledTimeOfThisAttempt: Timestamp3,
   206  		TaskToken:                  TaskToken,
   207  	}
   208  	ActivityLocalDispatchInfoMap = map[string]*apiv1.ActivityLocalDispatchInfo{
   209  		ActivityID: &ActivityLocalDispatchInfo,
   210  	}
   211  	TaskListMetadata = apiv1.TaskListMetadata{
   212  		MaxTasksPerSecond: &gogo.DoubleValue{Value: RatePerSecond},
   213  	}
   214  	WorkerVersionInfo = apiv1.WorkerVersionInfo{
   215  		Impl:           ClientImpl,
   216  		FeatureVersion: FeatureVersion,
   217  	}
   218  	PollerInfo = apiv1.PollerInfo{
   219  		LastAccessTime: Timestamp1,
   220  		Identity:       Identity,
   221  		RatePerSecond:  RatePerSecond,
   222  	}
   223  	PollerInfoArray = []*apiv1.PollerInfo{
   224  		&PollerInfo,
   225  	}
   226  	TaskListStatus = apiv1.TaskListStatus{
   227  		BacklogCountHint: BacklogCountHint,
   228  		ReadLevel:        ReadLevel,
   229  		AckLevel:         AckLevel,
   230  		RatePerSecond:    RatePerSecond,
   231  		TaskIdBlock:      &TaskIDBlock,
   232  	}
   233  	TaskIDBlock = apiv1.TaskIDBlock{
   234  		StartId: 551,
   235  		EndId:   559,
   236  	}
   237  	TaskListPartitionMetadata = apiv1.TaskListPartitionMetadata{
   238  		Key:           "Key",
   239  		OwnerHostName: "HostName",
   240  	}
   241  	TaskListPartitionMetadataArray = []*apiv1.TaskListPartitionMetadata{
   242  		&TaskListPartitionMetadata,
   243  	}
   244  	SupportedClientVersions = apiv1.SupportedClientVersions{
   245  		GoSdk:   "GoSDK",
   246  		JavaSdk: "JavaSDK",
   247  	}
   248  	IndexedValueTypeMap = map[string]apiv1.IndexedValueType{
   249  		"IndexedValueType1": IndexedValueType,
   250  	}
   251  	ParentExecutionInfo = apiv1.ParentExecutionInfo{
   252  		DomainId:          DomainID,
   253  		DomainName:        DomainName,
   254  		WorkflowExecution: &WorkflowExecution,
   255  		InitiatedId:       EventID1,
   256  	}
   257  	WorkflowExecutionFilter = apiv1.WorkflowExecutionFilter{
   258  		WorkflowId: WorkflowID,
   259  		RunId:      RunID,
   260  	}
   261  	WorkflowTypeFilter = apiv1.WorkflowTypeFilter{
   262  		Name: WorkflowTypeName,
   263  	}
   264  	StartTimeFilter = apiv1.StartTimeFilter{
   265  		EarliestTime: Timestamp1,
   266  		LatestTime:   Timestamp2,
   267  	}
   268  	StatusFilter = apiv1.StatusFilter{
   269  		Status: WorkflowExecutionCloseStatus,
   270  	}
   271  	WorkflowExecutionInfo = apiv1.WorkflowExecutionInfo{
   272  		WorkflowExecution: &WorkflowExecution,
   273  		Type:              &WorkflowType,
   274  		StartTime:         Timestamp1,
   275  		CloseTime:         Timestamp2,
   276  		CloseStatus:       WorkflowExecutionCloseStatus,
   277  		HistoryLength:     HistoryLength,
   278  		ParentExecutionInfo: &apiv1.ParentExecutionInfo{
   279  			DomainId:          DomainID,
   280  			WorkflowExecution: &WorkflowExecution,
   281  		},
   282  		ExecutionTime:    Timestamp3,
   283  		Memo:             &Memo,
   284  		SearchAttributes: &SearchAttributes,
   285  		AutoResetPoints:  &ResetPoints,
   286  		TaskList:         TaskListName,
   287  	}
   288  	WorkflowExecutionInfoArray = []*apiv1.WorkflowExecutionInfo{&WorkflowExecutionInfo}
   289  
   290  	WorkflowQuery = apiv1.WorkflowQuery{
   291  		QueryType: QueryType,
   292  		QueryArgs: QueryArgs,
   293  	}
   294  	WorkflowQueryMap = map[string]*apiv1.WorkflowQuery{
   295  		"WorkflowQuery1": &WorkflowQuery,
   296  	}
   297  	WorkflowQueryResult = apiv1.WorkflowQueryResult{
   298  		ResultType:   QueryResultType,
   299  		Answer:       &Payload1,
   300  		ErrorMessage: ErrorMessage,
   301  	}
   302  	WorkflowQueryResultMap = map[string]*apiv1.WorkflowQueryResult{
   303  		"WorkflowQuery1": &WorkflowQueryResult,
   304  	}
   305  	QueryRejected = apiv1.QueryRejected{
   306  		CloseStatus: WorkflowExecutionCloseStatus,
   307  	}
   308  	WorkflowExecutionConfiguration = apiv1.WorkflowExecutionConfiguration{
   309  		TaskList:                     &TaskList,
   310  		ExecutionStartToCloseTimeout: Duration1,
   311  		TaskStartToCloseTimeout:      Duration2,
   312  	}
   313  	PendingActivityInfo = apiv1.PendingActivityInfo{
   314  		ActivityId:         ActivityID,
   315  		ActivityType:       &ActivityType,
   316  		State:              PendingActivityState,
   317  		HeartbeatDetails:   &Payload1,
   318  		LastHeartbeatTime:  Timestamp1,
   319  		LastStartedTime:    Timestamp2,
   320  		Attempt:            Attempt,
   321  		MaximumAttempts:    3,
   322  		ScheduledTime:      Timestamp3,
   323  		ExpirationTime:     Timestamp4,
   324  		LastFailure:        &Failure,
   325  		LastWorkerIdentity: Identity,
   326  	}
   327  	PendingActivityInfoArray = []*apiv1.PendingActivityInfo{
   328  		&PendingActivityInfo,
   329  	}
   330  	PendingChildExecutionInfo = apiv1.PendingChildExecutionInfo{
   331  		WorkflowExecution: &WorkflowExecution,
   332  		WorkflowTypeName:  WorkflowTypeName,
   333  		InitiatedId:       EventID1,
   334  		ParentClosePolicy: ParentClosePolicy,
   335  	}
   336  	PendingChildExecutionInfoArray = []*apiv1.PendingChildExecutionInfo{
   337  		&PendingChildExecutionInfo,
   338  	}
   339  	PendingDecisionInfo = apiv1.PendingDecisionInfo{
   340  		State:                 PendingDecisionState,
   341  		ScheduledTime:         Timestamp1,
   342  		StartedTime:           Timestamp2,
   343  		Attempt:               Attempt,
   344  		OriginalScheduledTime: Timestamp3,
   345  	}
   346  )