Skip to content

Commit 0527556

Browse files
authored
Project harness for Go (#340)
## What was changed Adds `go/harness/` package, effectively a port of the same Python harness (`python/harness`). `go/harness` supports the same harness semantics, structure, and API as the existing Python harness. The test suite (`project_test.go` and `worker_test.go`) similarly mimic the existing Python harness test suite. The Go worker uniquely supported additional flags for worker deployment versioning that were not available/used in other languages, that has correspondingly been added to the Go's worker harness. **Note**: in contrast to the harness in other languages, the Go harness is **not** a standalone Go module. There is significant coupling between the existing go worker code and Omes which would make this either a much larger change, or cause a lot of duplication. The plan is to use the existing `workers/go/go.mod` as a single source to manage dependencies between the harness and the tests that consume it (at least, until this is resolved) ## Why? - load testing ergonomics / DX - Language parity
1 parent 5694960 commit 0527556

29 files changed

Lines changed: 1242 additions & 227 deletions

cmd/clioptions/client.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,7 @@ func (c *ClientOptions) Dial(metrics *metrics.Metrics, logger *zap.SugaredLogger
111111
})
112112
}
113113

114-
dataConverter := converter.NewCompositeDataConverter(
115-
converter.NewNilPayloadConverter(),
116-
converter.NewByteSlicePayloadConverter(),
117-
&PassThroughPayloadConverter{},
118-
converter.NewProtoJSONPayloadConverter(),
119-
converter.NewProtoPayloadConverter(),
120-
converter.NewJSONPayloadConverter(),
121-
)
122-
clientOptions.DataConverter = dataConverter
114+
clientOptions.DataConverter = OmesDataConverter()
123115

124116
client, err := client.Dial(clientOptions)
125117
if err != nil {
@@ -129,6 +121,17 @@ func (c *ClientOptions) Dial(metrics *metrics.Metrics, logger *zap.SugaredLogger
129121
return client, nil
130122
}
131123

124+
func OmesDataConverter() converter.DataConverter {
125+
return converter.NewCompositeDataConverter(
126+
converter.NewNilPayloadConverter(),
127+
converter.NewByteSlicePayloadConverter(),
128+
&PassThroughPayloadConverter{},
129+
converter.NewProtoJSONPayloadConverter(),
130+
converter.NewProtoPayloadConverter(),
131+
converter.NewJSONPayloadConverter(),
132+
)
133+
}
134+
132135
// FlagSet adds the relevant flags to populate the options struct and returns a pflag.FlagSet.
133136
func (c *ClientOptions) FlagSet() *pflag.FlagSet {
134137
if c.fs != nil {

cmd/clioptions/worker.go

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,38 @@ type WorkerOptions struct {
1919
WorkerActivitiesPerSecond float64
2020
ErrOnUnimplemented bool
2121

22-
fs *pflag.FlagSet
22+
fs *pflag.FlagSet
23+
usedPrefix string
2324
}
2425

2526
// FlagSet adds the relevant flags to populate the options struct and returns a pflag.FlagSet.
2627
func (m *WorkerOptions) FlagSet() *pflag.FlagSet {
28+
return m.FlagSetWithPrefix("worker-")
29+
}
30+
31+
// FlagSetWithPrefix adds worker flags using the provided prefix. The stock
32+
// OMES CLI keeps the historic "worker-" prefix, while the Go harness mirrors
33+
// the Python harness worker flags without that prefix.
34+
func (m *WorkerOptions) FlagSetWithPrefix(prefix string) *pflag.FlagSet {
2735
if m.fs != nil {
36+
if prefix != m.usedPrefix {
37+
panic("prefix mismatch")
38+
}
2839
return m.fs
2940
}
41+
m.usedPrefix = prefix
3042
m.fs = pflag.NewFlagSet("worker_options", pflag.ExitOnError)
3143
m.fs.StringVar(&m.BuildID, "build-id", "", "DEPRECATED: Build ID for legacy Build-ID-based worker versioning. Temporal Server will soon stop supporting the Rules-Based Versioning APIs that back this flag - use --deployment-name and --deployment-build-id instead. Mutually exclusive with --deployment-name")
3244
m.fs.StringVar(&m.DeploymentName, "deployment-name", "", "Worker Deployment name. When set, enables Worker Deployment Versioning and must be combined with --deployment-build-id")
3345
m.fs.StringVar(&m.DeploymentBuildID, "deployment-build-id", "", "Build ID within the Worker Deployment. Required when --deployment-name is set")
3446
m.fs.StringVar(&m.DefaultVersioningBehavior, "default-versioning-behavior", "", "Default versioning behavior for workflows that don't set one at registration. One of: pinned, auto-upgrade. Defaults to auto-upgrade when --deployment-name is set")
35-
m.fs.IntVar(&m.MaxConcurrentActivityPollers, "worker-max-concurrent-activity-pollers", 0, "Max concurrent activity pollers")
36-
m.fs.IntVar(&m.MaxConcurrentWorkflowPollers, "worker-max-concurrent-workflow-pollers", 0, "Max concurrent workflow pollers")
37-
m.fs.IntVar(&m.MaxConcurrentActivities, "worker-max-concurrent-activities", 0, "Max concurrent activities")
38-
m.fs.IntVar(&m.MaxConcurrentWorkflowTasks, "worker-max-concurrent-workflow-tasks", 0, "Max concurrent workflow tasks")
39-
m.fs.IntVar(&m.ActivityPollerAutoscaleMax, "worker-activity-poller-autoscale-max", 0, "Max for activity poller autoscaling (overrides max-concurrent-activity-pollers")
40-
m.fs.IntVar(&m.WorkflowPollerAutoscaleMax, "worker-workflow-poller-autoscale-max", 0, "Max for workflow poller autoscaling (overrides max-concurrent-workflow-pollers")
41-
m.fs.Float64Var(&m.WorkerActivitiesPerSecond, "worker-activities-per-second", 0, "Per-worker activity rate limit")
42-
m.fs.BoolVar(&m.ErrOnUnimplemented, "worker-err-on-unimplemented", false, "Fail on unimplemented actions (currently this only applies to concurrent client actions)")
47+
m.fs.IntVar(&m.MaxConcurrentActivityPollers, prefix+"max-concurrent-activity-pollers", 0, "Max concurrent activity pollers")
48+
m.fs.IntVar(&m.MaxConcurrentWorkflowPollers, prefix+"max-concurrent-workflow-pollers", 0, "Max concurrent workflow pollers")
49+
m.fs.IntVar(&m.MaxConcurrentActivities, prefix+"max-concurrent-activities", 0, "Max concurrent activities")
50+
m.fs.IntVar(&m.MaxConcurrentWorkflowTasks, prefix+"max-concurrent-workflow-tasks", 0, "Max concurrent workflow tasks")
51+
m.fs.IntVar(&m.ActivityPollerAutoscaleMax, prefix+"activity-poller-autoscale-max", 0, "Max for activity poller autoscaling (overrides max-concurrent-activity-pollers")
52+
m.fs.IntVar(&m.WorkflowPollerAutoscaleMax, prefix+"workflow-poller-autoscale-max", 0, "Max for workflow poller autoscaling (overrides max-concurrent-workflow-pollers")
53+
m.fs.Float64Var(&m.WorkerActivitiesPerSecond, prefix+"activities-per-second", 0, "Per-worker activity rate limit")
54+
m.fs.BoolVar(&m.ErrOnUnimplemented, prefix+"err-on-unimplemented", false, "Fail on unimplemented actions (currently this only applies to concurrent client actions)")
4355
return m.fs
4456
}

dockerfiles/dotnet.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ COPY loadgen ./loadgen
2828
COPY scenarios ./scenarios
2929
COPY metrics ./metrics
3030
COPY workers/*.go ./workers/
31-
COPY workers/go/projects/harness/api ./workers/go/projects/harness/api
31+
COPY workers/go/harness/api ./workers/go/harness/api
3232
COPY workers/proto/harness ./workers/proto/harness
3333
COPY go.mod go.sum ./
3434

dockerfiles/go.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ COPY loadgen ./loadgen
1010
COPY scenarios ./scenarios
1111
COPY metrics ./metrics
1212
COPY workers/*.go ./workers/
13-
COPY workers/go/projects/harness/api ./workers/go/projects/harness/api
13+
COPY workers/go/harness/api ./workers/go/harness/api
1414
COPY go.mod go.sum ./
1515

1616
# Build the CLI

dockerfiles/java.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ COPY loadgen ./loadgen
2121
COPY metrics ./metrics
2222
COPY scenarios ./scenarios
2323
COPY workers/*.go ./workers/
24-
COPY workers/go/projects/harness/api ./workers/go/projects/harness/api
24+
COPY workers/go/harness/api ./workers/go/harness/api
2525
COPY go.mod go.sum ./
2626

2727
# Build the CLI

dockerfiles/python.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ COPY loadgen ./loadgen
3131
COPY scenarios ./scenarios
3232
COPY metrics ./metrics
3333
COPY workers/*.go ./workers/
34-
COPY workers/go/projects/harness/api ./workers/go/projects/harness/api
34+
COPY workers/go/harness/api ./workers/go/harness/api
3535
COPY go.mod go.sum ./
3636

3737
# Build the CLI

dockerfiles/ruby.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ COPY loadgen ./loadgen
1515
COPY scenarios ./scenarios
1616
COPY metrics ./metrics
1717
COPY workers/*.go ./workers/
18-
COPY workers/go/projects/harness/api ./workers/go/projects/harness/api
18+
COPY workers/go/harness/api ./workers/go/harness/api
1919
COPY go.mod go.sum ./
2020

2121
# Build the CLI

dockerfiles/typescript.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ COPY loadgen ./loadgen
2626
COPY scenarios ./scenarios
2727
COPY metrics ./metrics
2828
COPY workers/*.go ./workers/
29-
COPY workers/go/projects/harness/api ./workers/go/projects/harness/api
29+
COPY workers/go/harness/api ./workers/go/harness/api
3030
COPY go.mod go.sum ./
3131

3232
# Build the CLI

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/spf13/pflag v1.0.5
1414
github.com/stretchr/testify v1.11.1
1515
github.com/temporalio/features v0.0.0-20260331150122-757294c2a9e9
16-
github.com/temporalio/omes/workers/go/projects/harness/api v0.0.0-00010101000000-000000000000
16+
github.com/temporalio/omes/workers/go/harness/api v0.0.0-00010101000000-000000000000
1717
go.temporal.io/api v1.62.7
1818
go.temporal.io/sdk v1.42.0
1919
go.uber.org/zap v1.27.0
@@ -71,5 +71,5 @@ require (
7171
replace (
7272
github.com/temporalio/features/features => github.com/temporalio/features/features v0.0.0-20260324215619-e5868d9ba03f
7373
github.com/temporalio/features/harness/go => github.com/temporalio/features/harness/go v0.0.0-20260324215619-e5868d9ba03f
74-
github.com/temporalio/omes/workers/go/projects/harness/api => ./workers/go/projects/harness/api
74+
github.com/temporalio/omes/workers/go/harness/api => ./workers/go/harness/api
7575
)

scenarios/project/handle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"time"
88

99
"github.com/temporalio/omes/loadgen"
10-
api "github.com/temporalio/omes/workers/go/projects/harness/api"
10+
api "github.com/temporalio/omes/workers/go/harness/api"
1111
"google.golang.org/grpc"
1212
"google.golang.org/grpc/credentials/insecure"
1313
)

0 commit comments

Comments
 (0)