Files
tasks/tests/testcore/matching_behavior.go
zeekay fcafe5dde5 refactor: rename temporal/→tasks/, temporaltest/→tasktests/; drop compat suite
- mv temporal/ tasks/ (internal server runtime)
- mv temporaltest/ tasktests/ (embedded boot harness)
- rm tests/ except tests/testutils (compat suite — 3.7 MB; testutils
  retained: certs/TLS/IO helpers used by real unit tests)
- rm test scaffolding pinned to deleted compat:
  - common/persistence/{cassandra/test.go,sql/test_sql_persistence.go}
  - tools/common/schema/test/{dbtest,setuptest,updatetest}.go
  - tools/cassandra/cqlclient_tests.go
- rewrite imports: github.com/hanzoai/tasks/{temporal,temporaltest}
  → github.com/hanzoai/tasks/{tasks,tasktests}

cmd/tasksd builds clean. embedded-sqlite boots and serves /healthz, /_/tasks/,
/v1/tasks/namespaces (verified locally on :7243).

Residual surface (tracked in #51, not in scope here): 722 production files
still import go.temporal.io/* (api/*, sdk/*) and 151 import
google.golang.org/grpc — the temporal-fork's internal service mesh. Removing
those is the multi-week ZAP-only cascade.
2026-04-26 13:55:38 -07:00

92 lines
2.6 KiB
Go

package testcore
import (
"go.temporal.io/server/common/dynamicconfig"
"go.temporal.io/server/common/testing/testhooks"
)
// MatchingBehavior describes a test scenario for matching service behavior.
type MatchingBehavior struct {
ForceTaskForward bool
ForcePollForward bool
ForceAsync bool
}
type hookInjector interface {
InjectHook(hook testhooks.Hook) (cleanup func())
}
// Name returns a descriptive name for this behavior combination.
func (b MatchingBehavior) Name() string {
name := "NoTaskForward"
if b.ForceTaskForward {
name = "ForceTaskForward"
}
if b.ForcePollForward {
name += "ForcePollForward"
} else {
name += "NoPollForward"
}
if b.ForceAsync {
name += "ForceAsync"
} else {
name += "AllowSync"
}
return name
}
// Options returns the TestOptions to configure matching behavior.
func (b MatchingBehavior) Options() []TestOption {
opts := []TestOption{
WithDynamicConfig(dynamicconfig.MatchingForwarderMaxChildrenPerNode, 3),
}
if b.ForceTaskForward || b.ForcePollForward {
opts = append(opts,
WithDynamicConfig(dynamicconfig.MatchingNumTaskqueueReadPartitions, 13),
WithDynamicConfig(dynamicconfig.MatchingNumTaskqueueWritePartitions, 13),
)
} else {
opts = append(opts,
WithDynamicConfig(dynamicconfig.MatchingNumTaskqueueReadPartitions, 1),
WithDynamicConfig(dynamicconfig.MatchingNumTaskqueueWritePartitions, 1),
)
}
return opts
}
// InjectHooks injects the test hooks for this matching behavior.
func (b MatchingBehavior) InjectHooks(env hookInjector) {
if b.ForceTaskForward {
env.InjectHook(testhooks.NewHook(testhooks.MatchingLBForceWritePartition, 11))
} else {
env.InjectHook(testhooks.NewHook(testhooks.MatchingLBForceWritePartition, 0))
}
if b.ForcePollForward {
env.InjectHook(testhooks.NewHook(testhooks.MatchingLBForceReadPartition, 5))
} else {
env.InjectHook(testhooks.NewHook(testhooks.MatchingLBForceReadPartition, 0))
}
if b.ForceAsync {
env.InjectHook(testhooks.NewHook(testhooks.MatchingDisableSyncMatch, true))
} else {
env.InjectHook(testhooks.NewHook(testhooks.MatchingDisableSyncMatch, false))
}
}
// AllMatchingBehaviors returns all 8 combinations of matching behaviors for testing.
func AllMatchingBehaviors() []MatchingBehavior {
var behaviors []MatchingBehavior
for _, forcePollForward := range []bool{false, true} {
for _, forceTaskForward := range []bool{false, true} {
for _, forceAsync := range []bool{false, true} {
behaviors = append(behaviors, MatchingBehavior{
ForceTaskForward: forceTaskForward,
ForcePollForward: forcePollForward,
ForceAsync: forceAsync,
})
}
}
}
return behaviors
}