Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centralize dynamic config #543

Merged
merged 3 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ Publishing docker images of the features runner/suites is also supported. It may
[manually](https://github.com/temporalio/features/actions/workflows/all-docker-images.yaml),
but is also triggered by default on each push to main.

The dynamic configuration file located at `dockerfiles/dynamicconfig/docker.yaml` defines the dynamic configuration
settings needed for features to run, and should be used as part of or all of the dynamic config settings for any
external server not using the basic docker-compose setup.

## TODO

- Add support for replaying testing of all versions _inside_ each SDKs harness as part of the run
Expand Down
33 changes: 25 additions & 8 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"go.temporal.io/sdk/client"
"go.temporal.io/sdk/log"
"go.temporal.io/sdk/testsuite"
"gopkg.in/yaml.v3"
)

const (
Expand Down Expand Up @@ -200,17 +201,33 @@ func (r *Runner) Run(ctx context.Context, patterns []string) error {

// If the server is not set, start it ourselves
if r.config.Server == "" {
// Load up dynamic config values.
// Probably the CLI could support passing a dynamic config file as well, but it also likes to set some default
// values for certain things, so it's easier to just load the file here and pass those values explicitly.
cfgPath := filepath.Join(r.rootDir, "dockerfiles", "dynamicconfig", "docker.yaml")
yamlBytes, err := os.ReadFile(cfgPath)
var yamlValues map[string][]struct {
Constraints map[string]any
Value any
}
if err = yaml.Unmarshal(yamlBytes, &yamlValues); err != nil {
return fmt.Errorf("unable to decode dynamic config: %w", err)
}
dynamicConfigArgs := make([]string, 0, len(yamlValues))
for key, values := range yamlValues {
for _, value := range values {
asJsonStr, err := json.Marshal(value)
if err != nil {
return fmt.Errorf("unable to marshal dynamic config value %s: %w", key, err)
}
dynamicConfigArgs = append(dynamicConfigArgs, "--dynamic-config-value", fmt.Sprintf("%s=%s", key, asJsonStr))
}
}

server, err := testsuite.StartDevServer(ctx, testsuite.DevServerOptions{
// TODO(cretz): Configurable?
LogLevel: "error",
ClientOptions: &client.Options{Namespace: r.config.Namespace},
ExtraArgs: []string{
"--dynamic-config-value", "system.forceSearchAttributesCacheRefreshOnRead=true",
"--dynamic-config-value", "system.enableActivityEagerExecution=true",
"--dynamic-config-value", "system.enableEagerWorkflowStart=true",
"--dynamic-config-value", "frontend.enableUpdateWorkflowExecution=true",
"--dynamic-config-value", "frontend.enableUpdateWorkflowExecutionAsyncAccepted=true",
},
ExtraArgs: dynamicConfigArgs,
})
if err != nil {
return fmt.Errorf("failed starting devserver: %w", err)
Expand Down
9 changes: 9 additions & 0 deletions dockerfiles/dynamicconfig/docker.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
frontend.forceSearchAttributesCacheRefreshOnRead:
- value: true
constraints: {}
frontend.enableActivityEagerExecution:
- value: true
constraints: {}
frontend.enableEagerWorkflowStart:
- value: true
constraints: {}
frontend.enableUpdateWorkflowExecution:
- value: true
constraints: {}
Expand Down
Loading