Skip to content
Browse files

Merge pull request #75 from mozilla/limit-replicates

added maximum allowed value for replicates
  • Loading branch information...
2 parents 1fca824 + d42a374 commit 205895d37cebea7f7eab1e2820a26e47e75dfe9c @jeads jeads committed
Showing with 27 additions and 12 deletions.
  1. +27 −12 datazilla/model/base.py
View
39 datazilla/model/base.py
@@ -440,7 +440,9 @@ class PerformanceTestModel(DatazillaModelBase):
# content types that every project will have
CONTENT_TYPES = ["perftest", "objectstore"]
-
+ # Total number of replicates allowed for a
+ # single test suite associated with a JSON object
+ REPLICATE_LIMIT = 5000
@classmethod
def create(cls, project, hosts=None, types=None, cron_batch=None):
@@ -1191,25 +1193,38 @@ def _set_test_aux_data(self, data, test_id, test_run_id):
def _set_test_values(self, data, test_id, test_run_id):
"""Insert test values to database for given test_id and test_run_id."""
+
+ total_replicates = 0
+
for page, values in data['results'].items():
page_id = self._get_or_create_page_id(page, test_id)
placeholders = []
for index, value in enumerate(values, 1):
- placeholders.append(
- (
- test_run_id,
- index,
- page_id,
- # TODO: Need to get the value id into the json
- 1,
- value,
+
+ total_replicates += 1
+
+ if total_replicates <= self.REPLICATE_LIMIT:
+
+ placeholders.append(
+ (
+ test_run_id,
+ index,
+ page_id,
+ # TODO: Need to get the value id into the json
+ 1,
+ value,
+ )
)
- )
- self._insert_data(
- 'set_test_values', placeholders, executemany=True)
+ else:
+ #Replicate limit reached
+ break
+
+ if placeholders:
+ self._insert_data(
+ 'set_test_values', placeholders, executemany=True)
def _get_or_create_aux_id(self, aux_data, test_id):

0 comments on commit 205895d

Please sign in to comment.
Something went wrong with that request. Please try again.