perf(scheduler): harden jobs for scalable execution
This commit is contained in:
@@ -9,6 +9,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
opsdomain "github.com/geo-platform/tenant-api/internal/ops/domain"
|
||||
internalscheduler "github.com/geo-platform/tenant-api/internal/scheduler"
|
||||
)
|
||||
|
||||
func TestSchedulerHTTPAddrDefaultsToLoopback(t *testing.T) {
|
||||
@@ -56,6 +59,48 @@ func TestSchedulerMetricsAuthMiddleware(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMonitoringDailyRunOptionsUsesJobBatchSize(t *testing.T) {
|
||||
batchSize := 88
|
||||
got := monitoringDailyRunOptions(internalscheduler.JobRunContext{
|
||||
Job: &opsdomain.SchedulerJob{BatchSize: &batchSize},
|
||||
Config: map[string]any{
|
||||
"max_materialize_per_run": 999,
|
||||
"max_materialize_per_plan": 12,
|
||||
"max_materialize_per_brand": 4,
|
||||
},
|
||||
})
|
||||
|
||||
if got.MaxMaterializePerRun != 88 {
|
||||
t.Fatalf("MaxMaterializePerRun = %d, want 88", got.MaxMaterializePerRun)
|
||||
}
|
||||
if got.MaxMaterializePerPlan != 12 || got.MaxMaterializePerBrand != 4 {
|
||||
t.Fatalf("unexpected plan/brand options: %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerationStateCheckRunOptionsUsesOpsConfig(t *testing.T) {
|
||||
batchSize := 50
|
||||
got := generationStateCheckRunOptions(internalscheduler.JobRunContext{
|
||||
Job: &opsdomain.SchedulerJob{
|
||||
BatchSize: &batchSize,
|
||||
TimeoutSeconds: 7,
|
||||
},
|
||||
Config: map[string]any{
|
||||
"lookback": "2h",
|
||||
},
|
||||
})
|
||||
|
||||
if got.BatchSize != 50 {
|
||||
t.Fatalf("BatchSize = %d, want 50", got.BatchSize)
|
||||
}
|
||||
if got.Timeout != 7*time.Second {
|
||||
t.Fatalf("Timeout = %s, want 7s", got.Timeout)
|
||||
}
|
||||
if got.Lookback != 2*time.Hour {
|
||||
t.Fatalf("Lookback = %s, want 2h", got.Lookback)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStartSchedulerWorkerWaitsForRunToReturn(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
Reference in New Issue
Block a user