Пример #1
0
async def test_cache_watch_does_shrink(flowmachine_connect):
    """
    Test that the cache watcher will shrink cache tables.
    """
    dl = daily_location("2016-01-01").store().result()
    assert dl.is_stored
    assert get_size_of_cache(flowmachine_connect) > 0
    await watch_and_shrink_cache(
        flowdb_connection=flowmachine_connect,
        pool=Query.thread_pool_executor,
        sleep_time=0,
        loop=False,
        protected_period=-1,
        size_threshold=1,
    )
    assert not dl.is_stored
    assert get_size_of_cache(flowmachine_connect) == 0
Пример #2
0
def test_size_of_table(flowmachine_connect):
    """
    Test that table size is reported correctly.
    """
    dl = daily_location("2016-01-01").store().result()

    total_cache_size = get_size_of_cache(flowmachine_connect)
    table_size = get_size_of_table(flowmachine_connect, dl.table_name, "cache")
    assert total_cache_size == table_size
Пример #3
0
def test_shrink_to_size_does_nothing_when_cache_ok(flowmachine_connect):
    """
    Test that shrink_below_size doesn't remove anything if cache size is within limit.
    """
    dl = daily_location("2016-01-01").store().result()
    removed_queries = shrink_below_size(flowmachine_connect,
                                        get_size_of_cache(flowmachine_connect))
    assert 0 == len(removed_queries)
    assert dl.is_stored
Пример #4
0
def test_shrink_to_size_removes_queries(flowmachine_connect):
    """
    Test that shrink_below_size removes queries when cache limit is breached.
    """
    dl = daily_location("2016-01-01").store().result()
    removed_queries = shrink_below_size(
        flowmachine_connect,
        get_size_of_cache(flowmachine_connect) - 1)
    assert 1 == len(removed_queries)
    assert not dl.is_stored