Skip to content

Commit

Permalink
Fix ArchiveExecutionTask key type (#3720)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSnowden committed Dec 16, 2022
1 parent 728f6ce commit 5a4e0a9
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion service/history/tasks/archive_execution_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type (
)

func (a *ArchiveExecutionTask) GetKey() Key {
return NewImmediateKey(a.TaskID)
return NewKey(a.VisibilityTimestamp, a.TaskID)
}

func (a *ArchiveExecutionTask) GetTaskID() int64 {
Expand Down
54 changes: 54 additions & 0 deletions service/history/tasks/archive_execution_task_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// The MIT License
//
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
//
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package tasks

import (
"testing"
"time"

"github.com/stretchr/testify/assert"

enumsspb "go.temporal.io/server/api/enums/v1"
"go.temporal.io/server/common/definition"
)

func TestArchiveExecutionTask(t *testing.T) {
workflowKey := definition.NewWorkflowKey("namespace", "workflowID", "runID")
visibilityTimestamp := time.Now()
taskID := int64(123)
version := int64(456)
task := &ArchiveExecutionTask{
WorkflowKey: workflowKey,
VisibilityTimestamp: visibilityTimestamp,
TaskID: taskID,
Version: version,
}
assert.Equal(t, NewKey(visibilityTimestamp, taskID), task.GetKey())
assert.Equal(t, taskID, task.GetTaskID())
assert.Equal(t, visibilityTimestamp, task.GetVisibilityTime())
assert.Equal(t, version, task.GetVersion())
assert.Equal(t, CategoryArchival, task.GetCategory())
assert.Equal(t, enumsspb.TASK_TYPE_ARCHIVAL_ARCHIVE_EXECUTION, task.GetType())
}

0 comments on commit 5a4e0a9

Please sign in to comment.