def test_inc_dec_get_counter(self): """ RSE COUNTER (CORE): Increase, decrease and get counter """ rse_id = get_rse_id(rse='MOCK', **self.vo) rse_update(once=True) rse_counter.del_counter(rse_id=rse_id) rse_counter.add_counter(rse_id=rse_id) cnt = rse_counter.get_counter(rse_id=rse_id) del cnt['updated_at'] assert_equal(cnt, {'files': 0, 'bytes': 0}) count, sum = 0, 0 for i in range(10): rse_counter.increase(rse_id=rse_id, files=1, bytes=2.147e+9) rse_update(once=True) count += 1 sum += 2.147e+9 cnt = rse_counter.get_counter(rse_id=rse_id) del cnt['updated_at'] assert_equal(cnt, {'files': count, 'bytes': sum}) for i in range(4): rse_counter.decrease(rse_id=rse_id, files=1, bytes=2.147e+9) rse_update(once=True) count -= 1 sum -= 2.147e+9 cnt = rse_counter.get_counter(rse_id=rse_id) del cnt['updated_at'] assert_equal(cnt, {'files': count, 'bytes': sum}) for i in range(5): rse_counter.increase(rse_id=rse_id, files=1, bytes=2.147e+9) rse_update(once=True) count += 1 sum += 2.147e+9 cnt = rse_counter.get_counter(rse_id=rse_id) del cnt['updated_at'] assert_equal(cnt, {'files': count, 'bytes': sum}) for i in range(8): rse_counter.decrease(rse_id=rse_id, files=1, bytes=2.147e+9) rse_update(once=True) count -= 1 sum -= 2.147e+9 cnt = rse_counter.get_counter(rse_id=rse_id) del cnt['updated_at'] assert_equal(cnt, {'files': count, 'bytes': sum})
def test_inc_dec_get_counter(self): """ RSE COUNTER (CORE): Increase, decrease and get counter """ rse_id = get_rse('MOCK').id rse_update(once=True) rse_counter.del_counter(rse_id=rse_id) rse_counter.add_counter(rse_id=rse_id) cnt = rse_counter.get_counter(rse_id=rse_id) del cnt['updated_at'] assert_equal(cnt, {'files': 0, 'bytes': 0}) count, sum = 0, 0 for i in xrange(10): rse_counter.increase(rse_id=rse_id, files=1, bytes=2.147e+9) rse_update(once=True) count += 1 sum += 2.147e+9 cnt = rse_counter.get_counter(rse_id=rse_id) del cnt['updated_at'] assert_equal(cnt, {'files': count, 'bytes': sum}) for i in xrange(4): rse_counter.decrease(rse_id=rse_id, files=1, bytes=2.147e+9) rse_update(once=True) count -= 1 sum -= 2.147e+9 cnt = rse_counter.get_counter(rse_id=rse_id) del cnt['updated_at'] assert_equal(cnt, {'files': count, 'bytes': sum}) for i in xrange(5): rse_counter.increase(rse_id=rse_id, files=1, bytes=2.147e+9) rse_update(once=True) count += 1 sum += 2.147e+9 cnt = rse_counter.get_counter(rse_id=rse_id) del cnt['updated_at'] assert_equal(cnt, {'files': count, 'bytes': sum}) for i in xrange(8): rse_counter.decrease(rse_id=rse_id, files=1, bytes=2.147e+9) rse_update(once=True) count -= 1 sum -= 2.147e+9 cnt = rse_counter.get_counter(rse_id=rse_id) del cnt['updated_at'] assert_equal(cnt, {'files': count, 'bytes': sum})