<commit_before>import nose.plugins.attrib
import time as _time
import subprocess
import sys
import redisdl
import unittest
import json
import os.path
from . import util
from . import big_data

@nose.plugins.attrib.attr('slow')
class RaceDeletingKeysTest(unittest.TestCase):
    def setUp(self):
        import redis
        self.r = redis.Redis()
        for key in self.r.keys('*'):
            self.r.delete(key)

    def test_delete_race(self):
        bd = big_data.BigData(self.r)
        count = bd.determine_key_count()
        # data is already inserted

        big_data_path = os.path.join(os.path.dirname(__file__), 'big_data.py')
        p = subprocess.Popen(
            [sys.executable, big_data_path, 'delete', str(count)],
            stdout=subprocess.PIPE,
        )

        _time.sleep(1)
        start = _time.time()
        dump = redisdl.dumps()
        finish = _time.time()

        out, err = p.communicate()
        delete_start, delete_finish = [int(time) for time in out.split(' ')]

        assert delete_start < start
        assert delete_finish > finish<commit_msg>Replace finish order requirement with a duration requirement<commit_after>import nose.plugins.attrib
import time as _time
import subprocess
import sys
import redisdl
import unittest
import json
import os.path
from . import util
from . import big_data

@nose.plugins.attrib.attr('slow')
class RaceDeletingKeysTest(unittest.TestCase):
    def setUp(self):
        import redis
        self.r = redis.Redis()
        for key in self.r.keys('*'):
            self.r.delete(key)

    def test_delete_race(self):
        bd = big_data.BigData(self.r)
        count = bd.determine_key_count()
        # data is already inserted

        big_data_path = os.path.join(os.path.dirname(__file__), 'big_data.py')
        p = subprocess.Popen(
            [sys.executable, big_data_path, 'delete', str(count)],
            stdout=subprocess.PIPE,
        )

        _time.sleep(1)
        start = _time.time()
        dump = redisdl.dumps()
        finish = _time.time()

        out, err = p.communicate()
        delete_start, delete_finish = [int(time) for time in out.split(' ')]

        assert delete_start < start
        assert finish > start + 5
        assert delete_finish > start + 5
{'fraction_non_alphanumeric': 0.10394736842105264, 'fraction_numerical': 0.0017543859649122807, 'mean_word_length': 2.4877675840978593, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1986704', 'n_tokens_mistral': 728, 'n_tokens_neox': 703, 'n_words': 173}