-
Notifications
You must be signed in to change notification settings - Fork 871
Destroy replaced configs on ET_TASK #13491
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
Merged
+151
−2
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
tests/gold_tests/config_processor/config_destroy_thread.test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| ''' | ||
| Verify that a replaced config is destroyed on an ET_TASK thread. | ||
| ''' | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import os | ||
|
|
||
| Test.Summary = ''' | ||
| Verify that a replaced config is destroyed on an ET_TASK thread. | ||
| ''' | ||
|
|
||
| # ConfigProcessor::set() waits CONFIG_PROCESSOR_RELEASE_SECS before it releases the config that it | ||
| # replaced. That timeout is a compile time constant of 60 seconds, so this test needs more than a | ||
| # minute of wall clock and does not run in CI. Comment out the next line to run it. | ||
| Test.SkipIf(Condition.true("Test takes over 60 seconds to run.")) | ||
|
|
||
| Test.ContinueOnFail = True | ||
|
|
||
| ts = Test.MakeATSProcess("ts") | ||
|
|
||
| ts.Disk.records_config.update({ | ||
| 'proxy.config.diags.debug.enabled': 1, | ||
| 'proxy.config.diags.debug.tags': 'config', | ||
| }) | ||
|
|
||
| ts.Disk.remap_config.AddLine('map / http://127.0.0.1:8080') | ||
|
|
||
| config_dir = ts.Variables.CONFIGDIR | ||
|
|
||
| # Two replacements, reached two different ways. Touching parent.config replaces ParentConfigParams | ||
| # through the reload framework, which runs on ET_TASK. Changing an HTTP record replaces | ||
| # HttpConfigParams from a network thread, which is the case this test is really about. Neither old | ||
| # config is referenced once the test stops sending traffic, so both reach a zero reference count and | ||
| # are destroyed when the release timeout expires. | ||
| tr = Test.AddTestRun("Mark parent.config for reload") | ||
| tr.Processes.Default.StartBefore(ts) | ||
| tr.Processes.Default.Command = f"sleep 3 && touch {os.path.join(config_dir, 'parent.config')} && sleep 1" | ||
| tr.Processes.Default.ReturnCode = 0 | ||
| tr.StillRunningAfter = ts | ||
|
|
||
| Test.AddConfigReload(ts, expect="any", token="config_destroy_thread") | ||
|
|
||
| tr = Test.AddTestRun("Replace the HTTP config from a network thread") | ||
| tr.DelayStart = 3 | ||
| tr.Processes.Default.Env = ts.Env | ||
| tr.Processes.Default.Command = "traffic_ctl config set proxy.config.http.response_server_str probe && sleep 3" | ||
| tr.Processes.Default.ReturnCode = 0 | ||
| tr.StillRunningAfter = ts | ||
|
|
||
| tr = Test.AddTestRun("Wait for the release timeout to expire") | ||
| tr.DelayStart = 3 | ||
| tr.Processes.Default.Command = "sleep 80" | ||
| tr.Processes.Default.ReturnCode = 0 | ||
| tr.TimeOut = 150 | ||
| tr.StillRunningAfter = ts | ||
|
|
||
| # The releaser runs on ET_TASK, so it destroys the replaced config there. | ||
| ts.Disk.traffic_out.Content = Testers.ContainsExpression( | ||
| r"Destroyed config \d+ in \d+ ns on thread \[ET_TASK", "a replaced config should be destroyed on a task thread") | ||
|
|
||
| # Destroying a config on a network thread is the regression this test guards against. | ||
| ts.Disk.traffic_out.Content += Testers.ExcludesExpression( | ||
| r"Destroyed config \d+ in \d+ ns on thread \[ET_NET", "no config should be destroyed on a network thread") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.