Skip to content

Commit

Permalink
Centralize dynamic config (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sushisource authored Oct 10, 2024
1 parent ac0ac87 commit a7698ed
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
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

0 comments on commit a7698ed

Please sign in to comment.