Esempio n. 1
0
 def test_dimensions_search_sizing_14_1(self):
     dimensions = {str(k): '01234567890123456789' for k in xrange(14)}
     items = tuple(
         sorted(
             task_to_run._hash_dimensions(utils.encode_to_json(i))
             for i in task_to_run._powerset(dimensions)))
     self.assertEqual(16384, len(items))
Esempio n. 2
0
 def test_dimensions_search_sizing_7_4(self):
     # Likely maximum permitted; 7 keys of 4 items each.
     dimensions = {str(k): ["01234567890123456789" * i for i in xrange(1, 4)] for k in xrange(7)}
     items = tuple(
         sorted(task_to_run._hash_dimensions(utils.encode_to_json(i)) for i in task_to_run._powerset(dimensions))
     )
     self.assertEqual(16384, len(items))
Esempio n. 3
0
 def test_dimensions_search_sizing_1_20(self):
   # Multi-value dimensions must *always* be prefered to split variables. They
   # are much quicker to search.
   dimensions = {'0': ['01234567890123456789' * i for i in xrange(1, 20)]}
   items = tuple(sorted(
       task_to_run._hash_dimensions(utils.encode_to_json(i))
       for i in task_to_run._powerset(dimensions)))
   self.assertEqual(20, len(items))
Esempio n. 4
0
 def test_hash_dimensions(self):
   dimensions = 'this is not json'
   as_hex = hashlib.md5(dimensions).digest()[:4].encode('hex')
   actual = task_to_run._hash_dimensions(dimensions)
   # It is exactly the same bytes reversed (little endian). It's positive even
   # with bit 31 set because python stores it internally as a int64.
   self.assertEqual('711d0bf1', as_hex)
   self.assertEqual(0xf10b1d71, actual)
Esempio n. 5
0
 def test_hash_dimensions(self):
     dimensions = 'this is not json'
     as_hex = hashlib.md5(dimensions).digest()[:4].encode('hex')
     actual = task_to_run._hash_dimensions(dimensions)
     # It is exactly the same bytes reversed (little endian). It's positive even
     # with bit 31 set because python stores it internally as a int64.
     self.assertEqual('711d0bf1', as_hex)
     self.assertEqual(0xf10b1d71, actual)
Esempio n. 6
0
 def test_dimensions_search_sizing_1_20(self):
   # Multi-value dimensions must *always* be prefered to split variables. They
   # are much quicker to search.
   dimensions = {'0': ['01234567890123456789' * i for i in xrange(1, 20)]}
   items = tuple(sorted(
       task_to_run._hash_dimensions(utils.encode_to_json(i))
       for i in task_to_run._powerset(dimensions)))
   self.assertEqual(20, len(items))
Esempio n. 7
0
 def test_dimensions_search_sizing_7_4(self):
   # Likely maximum permitted; 7 keys of 4 items each.
   dimensions = {
     str(k): ['01234567890123456789' * i for i in xrange(1, 4)]
     for k in xrange(7)
   }
   items = tuple(sorted(
       task_to_run._hash_dimensions(utils.encode_to_json(i))
       for i in task_to_run._powerset(dimensions)))
   self.assertEqual(16384, len(items))
Esempio n. 8
0
def _hash_dimensions(dimensions):
  return task_to_run._hash_dimensions(utils.encode_to_json(dimensions))
Esempio n. 9
0
 def test_dimensions_search_sizing_14_1(self):
   dimensions = {str(k): '01234567890123456789' for k in xrange(14)}
   items = tuple(sorted(
       task_to_run._hash_dimensions(utils.encode_to_json(i))
       for i in task_to_run._powerset(dimensions)))
   self.assertEqual(16384, len(items))
Esempio n. 10
0
def _hash_dimensions(dimensions):
    return task_to_run._hash_dimensions(utils.encode_to_json(dimensions))