Make tests safer to run in parallel by changing the Redis key namespace #6283
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