Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

Commit

Permalink
Merge pull request #191 from iksaif/master
Browse files Browse the repository at this point in the history
cassandra: better error when globing many directories
  • Loading branch information
iksaif authored Nov 28, 2016
2 parents b30dad3 + fdb06e1 commit 7c2031f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions biggraphite/drivers/cassandra.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,8 +936,8 @@ def _extract_results(query_results):
n_metrics += 1
if n_metrics > self.max_metrics_per_pattern:
raise TooManyMetrics(
"Query yields more than %d results" %
(self.max_metrics_per_pattern)
"Query %s on %s yields more than %d results" %
(glob, table, self.max_metrics_per_pattern)
)
yield result[0]

Expand Down
11 changes: 11 additions & 0 deletions tests/test_cassandra.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,17 @@ def assert_find(glob, expected_matches):
self.accessor.drop_all_metrics()
assert_find("*", [])

def test_glob_too_many_directories(self):
for name in "a", "a.b", "x.y.z":
metric = bg_test_utils.make_metric(name)
self.accessor.create_metric(metric)

old_value = self.accessor.max_metrics_per_pattern
self.accessor.max_metrics_per_pattern = 1
with self.assertRaises(bg_cassandra.TooManyMetrics):
list(self.accessor.glob_directory_names('**'))
self.accessor.max_metrics_per_pattern = old_value

def test_create_metrics(self):
meta_dict = {
"aggregator": bg_accessor.Aggregator.last,
Expand Down

0 comments on commit 7c2031f

Please sign in to comment.