mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.
## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
190 lines
5.3 KiB
Go
190 lines
5.3 KiB
Go
package tests
|
|
|
|
import (
|
|
"math/rand"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/stretchr/testify/suite"
|
|
"go.temporal.io/server/common/persistence/sql/sqlplugin"
|
|
"go.temporal.io/server/common/primitives"
|
|
"go.temporal.io/server/common/shuffle"
|
|
)
|
|
|
|
type (
|
|
historyExecutionBufferSuite struct {
|
|
suite.Suite
|
|
*require.Assertions
|
|
|
|
store sqlplugin.HistoryExecutionBuffer
|
|
}
|
|
)
|
|
|
|
const (
|
|
testHistoryExecutionBufferEncoding = "random encoding"
|
|
)
|
|
|
|
var (
|
|
testHistoryExecutionBufferData = []byte("random history execution buffer data")
|
|
)
|
|
|
|
func NewHistoryExecutionBufferSuite(
|
|
t *testing.T,
|
|
store sqlplugin.HistoryExecutionBuffer,
|
|
) *historyExecutionBufferSuite {
|
|
return &historyExecutionBufferSuite{
|
|
Assertions: require.New(t),
|
|
store: store,
|
|
}
|
|
}
|
|
|
|
func (s *historyExecutionBufferSuite) SetupSuite() {
|
|
|
|
}
|
|
|
|
func (s *historyExecutionBufferSuite) TearDownSuite() {
|
|
|
|
}
|
|
|
|
func (s *historyExecutionBufferSuite) SetupTest() {
|
|
s.Assertions = require.New(s.T())
|
|
}
|
|
|
|
func (s *historyExecutionBufferSuite) TearDownTest() {
|
|
|
|
}
|
|
|
|
func (s *historyExecutionBufferSuite) TestInsert_Single() {
|
|
shardID := rand.Int31()
|
|
namespaceID := primitives.NewUUID()
|
|
workflowID := shuffle.String(testHistoryExecutionWorkflowID)
|
|
runID := primitives.NewUUID()
|
|
|
|
buffer := s.newRandomExecutionBufferRow(shardID, namespaceID, workflowID, runID)
|
|
result, err := s.store.InsertIntoBufferedEvents(newExecutionContext(), []sqlplugin.BufferedEventsRow{buffer})
|
|
s.NoError(err)
|
|
rowsAffected, err := result.RowsAffected()
|
|
s.NoError(err)
|
|
s.Equal(1, int(rowsAffected))
|
|
}
|
|
|
|
func (s *historyExecutionBufferSuite) TestInsert_Multiple() {
|
|
shardID := rand.Int31()
|
|
namespaceID := primitives.NewUUID()
|
|
workflowID := shuffle.String(testHistoryExecutionWorkflowID)
|
|
runID := primitives.NewUUID()
|
|
|
|
buffer1 := s.newRandomExecutionBufferRow(shardID, namespaceID, workflowID, runID)
|
|
buffer2 := s.newRandomExecutionBufferRow(shardID, namespaceID, workflowID, runID)
|
|
result, err := s.store.InsertIntoBufferedEvents(newExecutionContext(), []sqlplugin.BufferedEventsRow{buffer1, buffer2})
|
|
s.NoError(err)
|
|
rowsAffected, err := result.RowsAffected()
|
|
s.NoError(err)
|
|
s.Equal(2, int(rowsAffected))
|
|
}
|
|
|
|
func (s *historyExecutionBufferSuite) TestInsertSelect() {
|
|
numBufferedEvents := 20
|
|
|
|
shardID := rand.Int31()
|
|
namespaceID := primitives.NewUUID()
|
|
workflowID := shuffle.String(testHistoryExecutionWorkflowID)
|
|
runID := primitives.NewUUID()
|
|
|
|
var buffers []sqlplugin.BufferedEventsRow
|
|
for i := 0; i < numBufferedEvents; i++ {
|
|
buffer := s.newRandomExecutionBufferRow(shardID, namespaceID, workflowID, runID)
|
|
buffers = append(buffers, buffer)
|
|
}
|
|
result, err := s.store.InsertIntoBufferedEvents(newExecutionContext(), buffers)
|
|
s.NoError(err)
|
|
rowsAffected, err := result.RowsAffected()
|
|
s.NoError(err)
|
|
s.Equal(numBufferedEvents, int(rowsAffected))
|
|
|
|
filter := sqlplugin.BufferedEventsFilter{
|
|
ShardID: shardID,
|
|
NamespaceID: namespaceID,
|
|
WorkflowID: workflowID,
|
|
RunID: runID,
|
|
}
|
|
rows, err := s.store.SelectFromBufferedEvents(newExecutionContext(), filter)
|
|
s.NoError(err)
|
|
s.Equal(buffers, rows)
|
|
}
|
|
|
|
func (s *historyExecutionBufferSuite) TestDeleteSelect() {
|
|
shardID := rand.Int31()
|
|
namespaceID := primitives.NewUUID()
|
|
workflowID := shuffle.String(testHistoryExecutionWorkflowID)
|
|
runID := primitives.NewUUID()
|
|
|
|
filter := sqlplugin.BufferedEventsFilter{
|
|
ShardID: shardID,
|
|
NamespaceID: namespaceID,
|
|
WorkflowID: workflowID,
|
|
RunID: runID,
|
|
}
|
|
result, err := s.store.DeleteFromBufferedEvents(newExecutionContext(), filter)
|
|
s.NoError(err)
|
|
rowsAffected, err := result.RowsAffected()
|
|
s.NoError(err)
|
|
s.Equal(0, int(rowsAffected))
|
|
|
|
rows, err := s.store.SelectFromBufferedEvents(newExecutionContext(), filter)
|
|
s.NoError(err)
|
|
s.Equal([]sqlplugin.BufferedEventsRow(nil), rows)
|
|
}
|
|
|
|
func (s *historyExecutionBufferSuite) TestInsertDelete() {
|
|
numBufferedEvents := 20
|
|
|
|
shardID := rand.Int31()
|
|
namespaceID := primitives.NewUUID()
|
|
workflowID := shuffle.String(testHistoryExecutionWorkflowID)
|
|
runID := primitives.NewUUID()
|
|
|
|
var buffers []sqlplugin.BufferedEventsRow
|
|
for i := 0; i < numBufferedEvents; i++ {
|
|
buffer := s.newRandomExecutionBufferRow(shardID, namespaceID, workflowID, runID)
|
|
buffers = append(buffers, buffer)
|
|
}
|
|
result, err := s.store.InsertIntoBufferedEvents(newExecutionContext(), buffers)
|
|
s.NoError(err)
|
|
rowsAffected, err := result.RowsAffected()
|
|
s.NoError(err)
|
|
s.Equal(numBufferedEvents, int(rowsAffected))
|
|
|
|
filter := sqlplugin.BufferedEventsFilter{
|
|
ShardID: shardID,
|
|
NamespaceID: namespaceID,
|
|
WorkflowID: workflowID,
|
|
RunID: runID,
|
|
}
|
|
result, err = s.store.DeleteFromBufferedEvents(newExecutionContext(), filter)
|
|
s.NoError(err)
|
|
rowsAffected, err = result.RowsAffected()
|
|
s.NoError(err)
|
|
s.Equal(numBufferedEvents, int(rowsAffected))
|
|
|
|
rows, err := s.store.SelectFromBufferedEvents(newExecutionContext(), filter)
|
|
s.NoError(err)
|
|
s.Equal([]sqlplugin.BufferedEventsRow(nil), rows)
|
|
}
|
|
|
|
func (s *historyExecutionBufferSuite) newRandomExecutionBufferRow(
|
|
shardID int32,
|
|
namespaceID primitives.UUID,
|
|
workflowID string,
|
|
runID primitives.UUID,
|
|
) sqlplugin.BufferedEventsRow {
|
|
return sqlplugin.BufferedEventsRow{
|
|
ShardID: shardID,
|
|
NamespaceID: namespaceID,
|
|
WorkflowID: workflowID,
|
|
RunID: runID,
|
|
Data: shuffle.Bytes(testHistoryExecutionBufferData),
|
|
DataEncoding: testHistoryExecutionBufferEncoding,
|
|
}
|
|
}
|