Loading tests/integration/data/test_replication.py +19 −13 Changes for tests/integration/data/test_replication.py: 19 added lines, 13 removed lines. Original line number Diff line number Diff line import os import pytest from harness.logger import logger import os @pytest.mark.parametrize("client_fixture", ["gkfs_client"]) def test_replication_block_usage(test_workspace, gkfs_daemon, client_fixture, request): Loading @@ -11,7 +11,9 @@ def test_replication_block_usage(test_workspace, gkfs_daemon, client_fixture, re # Get the appropriate client fixture client = request.getfixturevalue(client_fixture) # Enable replication: 1 replica means 2 copies total (primary + 1 replica) # Client.run() starts a fresh gkfs.io process for every command and merges # this environment into the process environment before preload startup. # Setting it after fixture construction is therefore intentional. client._env['LIBGKFS_NUM_REPL'] = '1' # Verify initial state Loading @@ -25,7 +27,7 @@ def test_replication_block_usage(test_workspace, gkfs_daemon, client_fixture, re # Write ample data to ensure we consume multiple chunks # 1MB write, chunk size 512KB -> 2 chunks. # With replication=1, we expect 4 chunks used. chunk_write_size = 100 * 1024 chunk_write_size = 128 * 1024 total_write_len = 1 * 1024 * 1024 ret = client.open(file_path, os.O_CREAT | os.O_WRONLY) Loading @@ -34,25 +36,29 @@ def test_replication_block_usage(test_workspace, gkfs_daemon, client_fixture, re buf = b'R' * chunk_write_size written = 0 while written < total_write_len: ret = client.write(file_path, buf, chunk_write_size, 1) # 1 for append ret = client.write(file_path, buf, chunk_write_size, 1) # O_APPEND assert ret.retval == chunk_write_size written += chunk_write_size ret = client.stat(file_path) assert ret.retval == 0 assert ret.statbuf.st_size == total_write_len ret = client.read(file_path, total_write_len) assert ret.retval == total_write_len assert ret.buf == b'R' * total_write_len # Verify updated state ret = client.statfs(gkfs_daemon.mountdir) assert ret.retval == 0 consumed_blocks = initial_free - ret.statfsbuf.f_bfree expected_chunks_primary = total_write_len // chunk_size # We expect roughly double usage expected_chunks_total = expected_chunks_primary * 2 logger.info(f"Consumed blocks: {consumed_blocks}, Expected approx: {expected_chunks_total}") # Allow for some variance due to block alignment etc, but it should be significantly more than primary only # Disabled as parallelism may affect the value # assert consumed_blocks >= expected_chunks_total logger.info( "Consumed filesystem blocks: %s (filesystem block size: %s)", consumed_blocks, chunk_size, ) # Clean up client.unlink(file_path) Loading
tests/integration/data/test_replication.py +19 −13 Changes for tests/integration/data/test_replication.py: 19 added lines, 13 removed lines. Original line number Diff line number Diff line import os import pytest from harness.logger import logger import os @pytest.mark.parametrize("client_fixture", ["gkfs_client"]) def test_replication_block_usage(test_workspace, gkfs_daemon, client_fixture, request): Loading @@ -11,7 +11,9 @@ def test_replication_block_usage(test_workspace, gkfs_daemon, client_fixture, re # Get the appropriate client fixture client = request.getfixturevalue(client_fixture) # Enable replication: 1 replica means 2 copies total (primary + 1 replica) # Client.run() starts a fresh gkfs.io process for every command and merges # this environment into the process environment before preload startup. # Setting it after fixture construction is therefore intentional. client._env['LIBGKFS_NUM_REPL'] = '1' # Verify initial state Loading @@ -25,7 +27,7 @@ def test_replication_block_usage(test_workspace, gkfs_daemon, client_fixture, re # Write ample data to ensure we consume multiple chunks # 1MB write, chunk size 512KB -> 2 chunks. # With replication=1, we expect 4 chunks used. chunk_write_size = 100 * 1024 chunk_write_size = 128 * 1024 total_write_len = 1 * 1024 * 1024 ret = client.open(file_path, os.O_CREAT | os.O_WRONLY) Loading @@ -34,25 +36,29 @@ def test_replication_block_usage(test_workspace, gkfs_daemon, client_fixture, re buf = b'R' * chunk_write_size written = 0 while written < total_write_len: ret = client.write(file_path, buf, chunk_write_size, 1) # 1 for append ret = client.write(file_path, buf, chunk_write_size, 1) # O_APPEND assert ret.retval == chunk_write_size written += chunk_write_size ret = client.stat(file_path) assert ret.retval == 0 assert ret.statbuf.st_size == total_write_len ret = client.read(file_path, total_write_len) assert ret.retval == total_write_len assert ret.buf == b'R' * total_write_len # Verify updated state ret = client.statfs(gkfs_daemon.mountdir) assert ret.retval == 0 consumed_blocks = initial_free - ret.statfsbuf.f_bfree expected_chunks_primary = total_write_len // chunk_size # We expect roughly double usage expected_chunks_total = expected_chunks_primary * 2 logger.info(f"Consumed blocks: {consumed_blocks}, Expected approx: {expected_chunks_total}") # Allow for some variance due to block alignment etc, but it should be significantly more than primary only # Disabled as parallelism may affect the value # assert consumed_blocks >= expected_chunks_total logger.info( "Consumed filesystem blocks: %s (filesystem block size: %s)", consumed_blocks, chunk_size, ) # Clean up client.unlink(file_path)