<commit_before>start_server {tags "del"} {
    # control evict manually
    r config set debug-evict-keys 0

    test {delete hot key} {
        r psetex foo 100 bar
        assert_match {*keys=1,evicts=0*} [r info keyspace]
        r del foo
        assert_equal [r dbsize] 0
    }

    test {delete cold key} {
        r psetex foo 100 bar
        r evict foo
        wait_for_condition 50 100 {
            [string match {*keys=0,evicts=1*} [r info keyspace]]
        } else {
            fail "evict key failed."
        }
        r del foo
        assert_equal [r dbsize] 0
    }

    test {del expired hot key} {
        r debug set-active-expire 0
        r psetex foo 100 bar
        after 100
        assert_equal [r dbsize] 1
        assert_match {*keys=1,evicts=0*} [r info keyspace] 
        assert_equal [r del foo] 0
        assert_equal [r dbsize] 0
        r debug set-active-expire 1
    }

    test {del expired cold key} {
        r debug set-active-expire 0
        r psetex foo 100 bar
        r evict foo
        after 100
        assert_equal [r dbsize] 1
        assert_match {*keys=0,evicts=1*} [r info keyspace] 
        assert_equal [r del foo] 0
        assert_equal [r dbsize] 0
        r debug set-active-expire 1
    }
}
<commit_msg>fix: wait a bit to get stable dbsize result.<commit_after>start_server {tags "del"} {
    # control evict manually
    r config set debug-evict-keys 0

    test {delete hot key} {
        r psetex foo 100 bar
        assert_match {*keys=1,evicts=0*} [r info keyspace]
        r del foo
        after 110
        assert_equal [r dbsize] 0
    }

    test {delete cold key} {
        r psetex foo 100 bar
        r evict foo
        wait_for_condition 50 100 {
            [string match {*keys=0,evicts=1*} [r info keyspace]]
        } else {
            fail "evict key failed."
        }
        r del foo
        after 100
        assert_equal [r dbsize] 0
    }

    test {del expired hot key} {
        r debug set-active-expire 0
        r psetex foo 100 bar
        after 110
        assert_equal [r dbsize] 1
        assert_match {*keys=1,evicts=0*} [r info keyspace] 
        assert_equal [r del foo] 0
        after 100
        assert_equal [r dbsize] 0
        r debug set-active-expire 1
    }

    test {del expired cold key} {
        r debug set-active-expire 0
        r psetex foo 100 bar
        r evict foo
        after 100
        assert_equal [r dbsize] 1
        assert_match {*keys=0,evicts=1*} [r info keyspace] 
        assert_equal [r del foo] 0
        after 100
        assert_equal [r dbsize] 0
        r debug set-active-expire 1
    }
}

{'fraction_non_alphanumeric': 0.07449638920562524, 'fraction_numerical': 0.03800836183960471, 'mean_word_length': 1.69120654396728, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3591030', 'n_tokens_mistral': 931, 'n_tokens_neox': 851, 'n_words': 304}