Change local_file_cache.py test to rename directory rather than unlinking file

This commit is contained in:
Konstantin Knizhnik
2023-09-23 18:30:36 +03:00
parent d9d1413383
commit 36a821270b
2 changed files with 10 additions and 4 deletions

View File

@@ -103,7 +103,7 @@ static int lfc_shrinking_factor; /* power of two by which local cache size wil
#define LFC_ENABLED() (lfc_ctl->limit != 0)
void FileCacheMonitorMain(Datum main_arg);
extern void PGDLLEXPORT FileCacheMonitorMain(Datum main_arg);
/*
* Local file cache is mandatory and Neon can work without it.
@@ -133,7 +133,6 @@ lfc_disable(char const* op)
while ((entry = hash_seq_search(&status)) != NULL)
{
hash_search(lfc_hash, &entry->key, HASH_REMOVE, NULL);
memset(entry->bitmap, 0, sizeof entry->bitmap);
}
lfc_ctl->generation += 1;
lfc_ctl->size = 0;
@@ -286,7 +285,7 @@ lfc_change_limit_hook(int newval, void *extra)
* disk space with maximal possible disk write speed (1Gb/sec). But not larger than 1 second.
* Calling statvfs each second should not add any noticeable overhead.
*/
void
PGDLLEXPORT void
FileCacheMonitorMain(Datum main_arg)
{
/*

View File

@@ -10,12 +10,18 @@ from fixtures.utils import query_scalar
def test_local_file_cache_unlink(neon_simple_env: NeonEnv):
env = neon_simple_env
cache_dir = os.path.join(env.repo_dir, "file_cache")
os.mkdir(cache_dir)
env.neon_cli.create_branch("test_local_file_cache_unlink", "empty")
endpoint = env.endpoints.create_start(
"test_local_file_cache_unlink",
config_lines=[
"shared_buffers='1MB'",
f"neon.file_cache_path='{cache_dir}/file.cache'",
"neon.max_file_cache_size='64MB'",
"neon.file_cache_size_limit='10MB'",
],
@@ -60,7 +66,8 @@ def test_local_file_cache_unlink(neon_simple_env: NeonEnv):
time.sleep(5)
os.unlink(os.path.join(endpoint.pg_data_dir_path(), "file.cache"))
new_cache_dir = os.path.join(env.repo_dir, "file_cache_new")
os.rename(cache_dir, new_cache_dir)
for thread in threads:
thread.join()