Skip to content

Commit

Permalink
Merge pull request #907 from rohankhanna/issue/906/assert-statement-u…
Browse files Browse the repository at this point in the history
…sed-outside-of-tests

Fixes #906 (BAN-B101) Assert statement used outside of tests
  • Loading branch information
deniszh committed Oct 24, 2020
2 parents da07fcc + c55758d commit 607f6f7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion lib/carbon/hashing.py
Expand Up @@ -89,7 +89,6 @@ def remove_node(self, key):
self.ring_len = len(self.ring)

def get_node(self, key):
assert self.ring
position = self.compute_ring_position(key)
search_entry = (position, ())
index = bisect.bisect_left(self.ring, search_entry) % self.ring_len
Expand Down
6 changes: 4 additions & 2 deletions lib/carbon/storage.py
Expand Up @@ -136,10 +136,12 @@ def loadAggregationSchemas():
try:
if xFilesFactor is not None:
xFilesFactor = float(xFilesFactor)
assert 0 <= xFilesFactor <= 1
if not 0 <= xFilesFactor <= 1:
raise AssertionError("xFilesFactor value out of [0,1] bounds")
if aggregationMethod is not None:
if state.database is not None:
assert aggregationMethod in state.database.aggregationMethods
if aggregationMethod not in state.database.aggregationMethods:
raise AssertionError("aggregationMethod not found in state.database.aggregationMethods")
except ValueError:
log.msg("Invalid schemas found in %s." % section)
continue
Expand Down
3 changes: 2 additions & 1 deletion lib/carbon/tests/benchmark_routers.py
Expand Up @@ -73,7 +73,8 @@ def benchmark_router(router):
def router_getDestinations():
router.__count += 1
dst = list(router.getDestinations('foo.%d' % router.__count))
assert(len(dst) != 0)
if len(dst) == 0:
raise AssertionError("No Router destinations found!")

n = 100000
t = timeit.timeit(router_getDestinations, number=n)
Expand Down

0 comments on commit 607f6f7

Please sign in to comment.