From 36a821270be0b7fedd3ad626ace8e7f05424da4b Mon Sep 17 00:00:00 2001 From: Konstantin Knizhnik Date: Sat, 23 Sep 2023 18:30:36 +0300 Subject: [PATCH] Change local_file_cache.py test to rename directory rather than unlinking file --- pgxn/neon/file_cache.c | 5 ++--- test_runner/regress/test_local_file_cache.py | 9 ++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pgxn/neon/file_cache.c b/pgxn/neon/file_cache.c index 13cd1ba238..de8cf87a55 100644 --- a/pgxn/neon/file_cache.c +++ b/pgxn/neon/file_cache.c @@ -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) { /* diff --git a/test_runner/regress/test_local_file_cache.py b/test_runner/regress/test_local_file_cache.py index f2a37b57ee..9bc9fd45d4 100644 --- a/test_runner/regress/test_local_file_cache.py +++ b/test_runner/regress/test_local_file_cache.py @@ -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()