mirror of
https://github.com/ansible/awx.git
synced 2026-02-28 08:18:43 -03:30
Clear cache between tests or when license is updated.
This commit is contained in:
@@ -18,6 +18,7 @@ from collections import OrderedDict
|
||||
# Django
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.cache import cache
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.exceptions import FieldError
|
||||
from django.db.models import Q, Count
|
||||
@@ -263,6 +264,8 @@ class ApiV1ConfigView(APIView):
|
||||
if license_data['valid_key']:
|
||||
tower_settings.LICENSE = data_actual
|
||||
tower_settings.TOWER_URL_BASE = "{}://{}".format(request.scheme, request.get_host())
|
||||
# Clear cache when license is updated.
|
||||
cache.clear()
|
||||
return Response(license_data)
|
||||
|
||||
return Response({"error": "Invalid license"}, status=status.HTTP_400_BAD_REQUEST)
|
||||
@@ -282,6 +285,8 @@ class ApiV1ConfigView(APIView):
|
||||
break
|
||||
|
||||
TowerSettings.objects.filter(key="LICENSE").delete()
|
||||
# Clear cache when license is updated.
|
||||
cache.clear()
|
||||
|
||||
# Only stop mongod if license removal succeeded
|
||||
if has_error is None:
|
||||
|
||||
@@ -24,6 +24,7 @@ import yaml
|
||||
import django.test
|
||||
from django.conf import settings, UserSettingsHolder
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.cache import cache
|
||||
from django.test.client import Client
|
||||
from django.test.utils import override_settings
|
||||
from django.utils.encoding import force_text
|
||||
@@ -152,6 +153,7 @@ class BaseTestMixin(QueueTestMixin, MockCommonlySlowTestMixin):
|
||||
'LOCATION': 'unittests'
|
||||
}
|
||||
}
|
||||
cache.clear()
|
||||
self._start_time = time.time()
|
||||
|
||||
def tearDown(self):
|
||||
@@ -195,6 +197,7 @@ class BaseTestMixin(QueueTestMixin, MockCommonlySlowTestMixin):
|
||||
writer.write_file(license_path)
|
||||
self._temp_paths.append(license_path)
|
||||
os.environ['AWX_LICENSE_FILE'] = license_path
|
||||
cache.clear()
|
||||
|
||||
def create_basic_license_file(self, instance_count=100, license_date=int(time.time() + 3600)):
|
||||
writer = LicenseWriter(
|
||||
@@ -209,6 +212,7 @@ class BaseTestMixin(QueueTestMixin, MockCommonlySlowTestMixin):
|
||||
writer.write_file(license_path)
|
||||
self._temp_paths.append(license_path)
|
||||
os.environ['AWX_LICENSE_FILE'] = license_path
|
||||
cache.clear()
|
||||
|
||||
def create_expired_license_file(self, instance_count=1000, grace_period=False):
|
||||
license_date = time.time() - 1
|
||||
|
||||
Reference in New Issue
Block a user