Files
tasks/chasm/lib/scheduler/helper_test.go
Lina JodoinandGitHub 4c140933cf [Scheduled Actions] CHASM Scheduler (#8255)
## What changed?
- Merge PR combining the previous PRs: #8164, #8165, #8166, #8167,
#8168, #8169

## Why?
- All of those PRs are interdependent and cannot be merged individually
cleanly. Sending a single merge commit PR to be merged to main.

## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [ ] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)

## Potential risks
- It's still disabled.
2025-09-02 19:50:45 +00:00

65 lines
1.6 KiB
Go

package scheduler_test
import (
"time"
schedulepb "go.temporal.io/api/schedule/v1"
workflowpb "go.temporal.io/api/workflow/v1"
"go.temporal.io/server/chasm/lib/scheduler"
"go.temporal.io/server/common/backoff"
"google.golang.org/protobuf/types/known/durationpb"
)
const (
namespace = "ns"
namespaceID = "ns-id"
scheduleID = "sched-id"
defaultInterval = 1 * time.Minute
defaultCatchupWindow = 5 * time.Minute
)
// defaultSchedule returns a protobuf definition for a schedule matching this
// package's other testing defaults.
func defaultSchedule() *schedulepb.Schedule {
return &schedulepb.Schedule{
Spec: &schedulepb.ScheduleSpec{
Interval: []*schedulepb.IntervalSpec{
{
Interval: durationpb.New(defaultInterval),
Phase: durationpb.New(0),
},
},
},
Action: &schedulepb.ScheduleAction{
Action: &schedulepb.ScheduleAction_StartWorkflow{
StartWorkflow: &workflowpb.NewWorkflowExecutionInfo{
WorkflowId: "scheduled-wf",
},
},
},
Policies: &schedulepb.SchedulePolicies{
CatchupWindow: durationpb.New(defaultCatchupWindow),
},
State: &schedulepb.ScheduleState{
Paused: false,
LimitedActions: false,
RemainingActions: 0,
},
}
}
func defaultConfig() *scheduler.Config {
return &scheduler.Config{
Tweakables: func(_ string) scheduler.Tweakables {
return scheduler.DefaultTweakables
},
ServiceCallTimeout: func() time.Duration {
return 5 * time.Second
},
RetryPolicy: func() backoff.RetryPolicy {
return backoff.NewExponentialRetryPolicy(1 * time.Second)
},
}
}