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

Refactor: arrange and document dynamic config usages in functional tests #7096

Merged
merged 5 commits into from
Jan 17, 2025

Conversation

alexshtin
Copy link
Member

@alexshtin alexshtin commented Jan 16, 2025

What changed?

  • Consolidated all global DCs in one file with clear name for easy discovery.
  • Documented how to override DCs properly.
  • Cleaned up duplicated configs.

Why?

Quality of life for function test writers.

How did you test it?

Run.

Potential risks

No risks.

Documentation

No.

Is hotfix candidate?

No.

@@ -140,16 +140,6 @@ type (
HistoryConfig struct {
NumHistoryShards int32
NumHistoryHosts int

// TODO (alex): Remove all this limits and replace them with consts in sizelimit_tests.go
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed.

@alexshtin alexshtin changed the title Refactor: arrange dynamic config usages in functional tests Refactor: arrange and document dynamic config usages in functional tests Jan 17, 2025
@alexshtin alexshtin marked this pull request as ready for review January 17, 2025 00:17
@alexshtin alexshtin requested a review from a team as a code owner January 17, 2025 00:17
@alexshtin alexshtin requested a review from stephanos January 17, 2025 00:18
Comment on lines 35 to 49
// Functional tests don't use dynamic config files. All settings get their default values
// defined in common/dynamicconfig/constants.go.
// There are 4 ways to override a setting:
// 1. Globally using this file. Every test suite creates a new test cluster using this overrides.
// 2. Per test suite using FunctionalTestBase.SetupSuiteWithCluster() and WithDynamicConfigOverrides() option.
// 3. Per test using FunctionalTestBase.OverrideDynamicConfig() method.
// 4. Per specific cluster per test (if test has more than one cluster) using TestCluster.OverrideDynamicConfig() method.
//
// NOTE1: settings which are not really dynamic (requires server restart to take effect) can't be overridden on test level,
// i.e., must be overridden globally (1) or per test suite (2).
// NOTE2: per test overrides change value for the cluster, therefore, it affects not only specific test, but
// all tests for this suite. Automatic cleanup reverts previous value and tests don't affect each other.
// But it means that tests in the same suite can be run in parallel.This is not a problem because testify
// doesn't allow parallel execution of tests in the same suite anyway. If one day, it will be allowed,
// unique namespaces with overrides per namespace should be used for tests which require different settings.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main idea of this PR: describe how to override DC and consolidate all global overrides in one file with clear name (for easy discovery).

Copy link
Contributor

@stephanos stephanos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

tests/testcore/dynamic_config_overrides.go Outdated Show resolved Hide resolved
tests/testcore/dynamic_config_overrides.go Outdated Show resolved Hide resolved
alexshtin and others added 2 commits January 16, 2025 19:13
Fix English.

Co-authored-by: Stephan Behnke <stephanos@users.noreply.github.com>
Co-authored-by: Stephan Behnke <stephanos@users.noreply.github.com>
@alexshtin alexshtin enabled auto-merge (squash) January 17, 2025 03:14
@alexshtin alexshtin merged commit 38903d3 into temporalio:main Jan 17, 2025
49 checks passed
@alexshtin alexshtin deleted the refactor/func-test-dc branch January 17, 2025 04:46
stephanos added a commit to stephanos/temporal that referenced this pull request Jan 17, 2025
…sts (temporalio#7096)

## What changed?
<!-- Describe what has changed in this PR -->
- Consolidated all global DCs in one file with clear name for easy
discovery.
- Documented how to override DCs properly. 
- Cleaned up duplicated configs.

## Why?
<!-- Tell your future self why have you made these changes -->
Quality of life for function test writers.

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
Run.

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
No risks.

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->
No.

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
No.

---------

Co-authored-by: Stephan Behnke <stephanos@users.noreply.github.com>
Copy link
Member

@dnr dnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This is so much better already. There's more to clean up but this is a good step.

s.OverrideDynamicConfig(dynamicconfig.ActivityAPIsEnabled, true)
s.tv = testvars.New(s.T()).WithTaskQueue(s.TaskQueue()).WithNamespaceName(s.Namespace())
func TestActivityApiPauseClientTestSuite(t *testing.T) {
s := new(ActivityApiPauseClientTestSuite)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also add t.Parallel() to all suites where it doesn't break things?

@@ -262,13 +226,12 @@ func newTemporal(t *testing.T, params *TemporalParams) *TemporalImpl {
hostsByProtocolByService: params.HostsByProtocolByService,
}

for k, v := range staticOverrides {
for k, v := range dynamicConfigOverrides {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like it should be possible to merge the "global test overrides" and the ones from "params" (the per-suite ones?) earlier so that this code here is just one loop. Did you consider that?

Like maybe change https://github.com/temporalio/temporal/pull/7096/files#diff-b77e5f4402c434c0f9f4a58cbe72c7fa38e280e235f5d6c393b370301355cd3eR211 to s.testClusterConfig.DynamicConfigOverrides = maps.Clone(dynamicConfigOverrides)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants