OpenStack Identity (Keystone)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cache.py 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Licensed under the Apache License, Version 2.0 (the "License");
  2. # you may not use this file except in compliance with the License.
  3. # You may obtain a copy of the License at
  4. #
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. #
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS,
  9. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  10. # implied.
  11. # See the License for the specific language governing permissions and
  12. # limitations under the License.
  13. import fixtures
  14. from keystone import catalog
  15. from keystone.common import cache
  16. from keystone import revoke
  17. CACHE_REGIONS = (cache.CACHE_REGION, catalog.COMPUTED_CATALOG_REGION,
  18. revoke.REVOKE_REGION)
  19. class Cache(fixtures.Fixture):
  20. """A fixture for setting up the cache between test cases.
  21. This will also tear down an existing cache if one is already configured.
  22. """
  23. def setUp(self):
  24. super(Cache, self).setUp()
  25. # NOTE(dstanek): We must remove the existing cache backend in the
  26. # setUp instead of the tearDown because it defaults to a no-op cache
  27. # and we want the configure call below to create the correct backend.
  28. # NOTE(morganfainberg): The only way to reconfigure the CacheRegion
  29. # object on each setUp() call is to remove the .backend property.
  30. for region in CACHE_REGIONS:
  31. if region.is_configured:
  32. del region.backend
  33. # ensure the cache region instance is setup
  34. cache.configure_cache(region=region)