Make tests safer to run in parallel by changing the Redis key namespace#6283
Merged
cognifloyd merged 7 commits intomasterfrom Nov 29, 2024
Merged
Make tests safer to run in parallel by changing the Redis key namespace#6283cognifloyd merged 7 commits intomasterfrom
cognifloyd merged 7 commits intomasterfrom
Conversation
This will make it safer to run tests in parallel as the tests will have separate service registration and coordination locks. To do that, this adds a namespace= query param to the redis url that includes the slot number that pants creates to allow tests to run in parallel more safely. The namespace is used by the tooz library's redis driver as a prefix for all the redis keys. Thus, multiple tests can use the same redis database without clobbering each other's keys.
These changes were already made for MongoDB and RabbitMQ rules. This removes a TODO comment and slightly refactors to follow the same convention.
amanda11
approved these changes
Nov 24, 2024
nzlosh
approved these changes
Nov 28, 2024
This fixes CircleCI. webtest bumped their dep on waitress to a version that is not available to all of our interpreters. Pylons/webtest@090c5b2 The lockfile has a version locked version that does not have this issue. The pin was already copied to test-requirements.txt, so this just copies it to the other requirements files as well. This is not a significant issue because webtest is only required by st2tests.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR's commits were extracted from #6273 where I'm working on getting pants+pytest to run integration tests.
When running tests in parallel, the keys stored in redis for one test can mess up the expected redis keys needed by a different test. The community edition of redis has 16 logical databases, but if someone has more cores than that or uses pants remote test execution (with a default of 128 possible remote executors running in parallel), then 16 is not enough.
It turns out, the tooz redis driver already has a config option to support this:
namespace. By default, the tooz driver uses_toozas the key namespace. We can change that by passing anamespacequery param in[coordination].url.So, I updated the tests config to change the namespace using the pants-provided
ST2TESTS_PARLLEL_SLOTenv var here (building on theST2TESTS_REDIS_*env vars added in #6245):st2/st2tests/st2tests/config.py
Lines 160 to 168 in c394a52
I updated
tools/launchdev.shto respectST2_*env vars (the oslo_config env vars added in #6277) and theST2TESTS_*env vars (This builds on the refactor from #6276 to make it simpler to update the command used to run each service):st2/tools/launchdev.sh
Lines 137 to 146 in c394a52
The redis namespace for
tools/launchdev.shis defined inst2.dev.confhere:st2/conf/st2.dev.conf
Line 90 in c394a52
I updated
pants-plugins/uses_servicesto use the new env vars as well, following the patterns established in #6278.pants.tomldid not need any additional vars, since it already has theST2TESTS_REDIS_*env vars:st2/pants.toml
Lines 251 to 256 in c394a52
I did, however, add
ST2_SYSTEM_USER__USERto[tests].extra_env_varsinpants.tomlhere:st2/pants.toml
Lines 240 to 243 in c394a52