Merge "Disable cache for cmd testcases"

This commit is contained in:
Jenkins 2015-10-22 22:25:07 +00:00 committed by Gerrit Code Review
commit 81b07b548e
4 changed files with 21 additions and 3 deletions

View File

@ -24,10 +24,12 @@ class Cache(object):
def __init__(self, cachedir):
cache_dir = self._get_cache_dir(cachedir)
filename = os.path.join(cache_dir, 'cache.dbm')
LOG.debug('Using cache: %s' % filename)
self.region = make_region().configure(
'dogpile.cache.dbm',
arguments={
'filename': os.path.join(cache_dir, 'cache.dbm')
'filename': filename,
}
)

View File

@ -15,12 +15,15 @@
import hashlib
import io
import json
import logging
import yaml
from slugify import slugify
from grafana_dashboards.schema.dashboard import Dashboard
LOG = logging.getLogger(__name__)
class YamlParser(object):
@ -31,8 +34,10 @@ class YamlParser(object):
data = self.data.get('dashboard', {}).get(slug, None)
md5 = None
if data:
content = json.dumps(data)
# Sort json keys to help our md5 hash are constant.
content = json.dumps(data, sort_keys=True)
md5 = hashlib.md5(content.encode('utf-8')).hexdigest()
LOG.debug('Dashboard %s: %s' % (slug, md5))
return data, md5

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import os
import sys
import fixtures
@ -22,6 +23,8 @@ from tests.base import TestCase
class TestCase(TestCase):
configfile = os.path.join(
os.path.dirname(__file__), 'fixtures/cmd/grafyaml.conf')
def shell(self, argstr, exitcodes=(0,)):
orig = sys.stdout
@ -29,7 +32,10 @@ class TestCase(TestCase):
try:
sys.stdout = six.StringIO()
sys.stderr = six.StringIO()
argv = ['grafana-dashboards']
argv = [
'grafana-dashboards',
'--config-file=%s' % self.configfile,
]
argv += argstr.split()
self.useFixture(fixtures.MonkeyPatch('sys.argv', argv))
cmd.main()

5
tests/fixtures/cmd/grafyaml.conf vendored Normal file
View File

@ -0,0 +1,5 @@
[grafana]
url = http://grafana.example.org
[cache]
enabled = false