Make ruff happy

This commit is contained in:
Konstantin Knizhnik
2024-03-14 18:05:30 +02:00
parent 57a4119a7b
commit 5a8e8baf9f

View File

@@ -1,12 +1,15 @@
import os
import time
import pytest
from fixtures.log_helper import log
from fixtures.neon_fixtures import NeonEnv, PgBin
#
# Test branching, when a transaction is in prepared state
# Test image layer compression and log compression ratio
#
@pytest.mark.timeout(1000)
def test_compression(neon_simple_env: NeonEnv, pg_bin: PgBin):
env = neon_simple_env
@@ -17,7 +20,7 @@ def test_compression(neon_simple_env: NeonEnv, pg_bin: PgBin):
delta_total_size = 0
image_total_size = 0
for filename in os.listdir(timeline_path):
if filename.startswith("00000") and not filename.endswith(".___temp"):
if filename.startswith("00000") and not filename.endswith(".___temp"):
size = os.path.getsize(timeline_path + filename)
pos = filename.find("__")
if pos >= 0:
@@ -36,18 +39,18 @@ def test_compression(neon_simple_env: NeonEnv, pg_bin: PgBin):
"compaction_target_size": f"{1024 ** 2}",
"compaction_period": "1 s",
"compaction_threshold": "1",
"image_layer_compression": "\"LZ4\"",
"image_layer_compression": '"LZ4"',
}
)
endpoint = env.endpoints.create_start("main", tenant_id=tenant)
connstr = endpoint.connstr()
log.info(f"Start a pgbench workload on pg {connstr}")
pg_bin.run_capture(["pgbench", "-i", f"-s50", connstr])
pg_bin.run_capture(["pgbench", "-c10", f"-T25", "-Mprepared", connstr])
pg_bin.run_capture(["pgbench", "-i", "-s50", connstr])
pg_bin.run_capture(["pgbench", "-c10", "-T25", "-Mprepared", connstr])
time.sleep(5) # wait sometime to let background tasks completed at PS
compressed_image_size = calculate_layers_size(tenant,timeline)
time.sleep(5) # wait sometime to let background tasks completed at PS
compressed_image_size = calculate_layers_size(tenant, timeline)
tenant, timeline = env.neon_cli.create_tenant(
conf={
@@ -56,16 +59,16 @@ def test_compression(neon_simple_env: NeonEnv, pg_bin: PgBin):
"compaction_target_size": f"{1024 ** 2}",
"compaction_period": "1 s",
"compaction_threshold": "1",
"image_layer_compression": "\"NoCompression\"",
"image_layer_compression": '"NoCompression"',
}
)
endpoint = env.endpoints.create_start("main", tenant_id=tenant)
connstr = endpoint.connstr()
log.info(f"Start a pgbench workload on pg {connstr}")
pg_bin.run_capture(["pgbench", "-i", f"-s50", connstr])
pg_bin.run_capture(["pgbench", "-c10", f"-T25", "-Mprepared", connstr])
pg_bin.run_capture(["pgbench", "-i", "-s50", connstr])
pg_bin.run_capture(["pgbench", "-c10", "-T25", "-Mprepared", connstr])
time.sleep(5) # wait sometime to let background tasks completed at PS
raw_image_size = calculate_layers_size(tenant,timeline)
time.sleep(5) # wait sometime to let background tasks completed at PS
raw_image_size = calculate_layers_size(tenant, timeline)
log.info(f"Compression ratio: {raw_image_size/compressed_image_size}")