Fix flapping tests test_s3_zero_copy_replication, test_s3_zero_copy_on_hybrid_storage

This commit is contained in:
Anton Ivashkin 2021-04-16 13:23:38 +03:00
parent b5cbbce314
commit dc442b90d0
2 changed files with 14 additions and 12 deletions

View File

@ -26,6 +26,7 @@
<disk>s31</disk> <disk>s31</disk>
</external> </external>
</volumes> </volumes>
<move_factor>0.0</move_factor>
</hybrid> </hybrid>
</policies> </policies>
</storage_configuration> </storage_configuration>

View File

@ -36,6 +36,15 @@ def get_large_objects_count(cluster, size=100):
return counter return counter
def wait_for_large_objects_count(cluster, expected, size=100, timeout=30):
while timeout > 0:
if get_large_objects_count(cluster, size) == expected:
return
timeout -= 1
time.sleep(1)
assert get_large_objects_count(cluster, size) == expected
@pytest.mark.parametrize( @pytest.mark.parametrize(
"policy", ["s3"] "policy", ["s3"]
) )
@ -67,23 +76,15 @@ def test_s3_zero_copy_replication(cluster, policy):
assert node1.query("SELECT * FROM s3_test order by id FORMAT Values") == "(0,'data'),(1,'data'),(2,'data'),(3,'data')" assert node1.query("SELECT * FROM s3_test order by id FORMAT Values") == "(0,'data'),(1,'data'),(2,'data'),(3,'data')"
# Based on version 20.x - two parts # Based on version 20.x - two parts
assert get_large_objects_count(cluster) == 2 wait_for_large_objects_count(cluster, 2)
node1.query("OPTIMIZE TABLE s3_test") node1.query("OPTIMIZE TABLE s3_test")
time.sleep(1)
# Based on version 20.x - after merge, two old parts and one merged # Based on version 20.x - after merge, two old parts and one merged
assert get_large_objects_count(cluster) == 3 wait_for_large_objects_count(cluster, 3)
# Based on version 20.x - after cleanup - only one merged part # Based on version 20.x - after cleanup - only one merged part
countdown = 60 wait_for_large_objects_count(cluster, 1, timeout=60)
while countdown > 0:
if get_large_objects_count(cluster) == 1:
break
time.sleep(1)
countdown -= 1
assert get_large_objects_count(cluster) == 1
node1.query("DROP TABLE IF EXISTS s3_test NO DELAY") node1.query("DROP TABLE IF EXISTS s3_test NO DELAY")
node2.query("DROP TABLE IF EXISTS s3_test NO DELAY") node2.query("DROP TABLE IF EXISTS s3_test NO DELAY")
@ -127,7 +128,7 @@ def test_s3_zero_copy_on_hybrid_storage(cluster):
assert node2.query("SELECT partition_id,disk_name FROM system.parts WHERE table='hybrid_test' FORMAT Values") == "('all','s31')" assert node2.query("SELECT partition_id,disk_name FROM system.parts WHERE table='hybrid_test' FORMAT Values") == "('all','s31')"
# Check that after moving partition on node2 no new obects on s3 # Check that after moving partition on node2 no new obects on s3
assert get_large_objects_count(cluster, 0) == s3_objects wait_for_large_objects_count(cluster, s3_objects, size=0)
assert node1.query("SELECT * FROM hybrid_test ORDER BY id FORMAT Values") == "(0,'data'),(1,'data')" assert node1.query("SELECT * FROM hybrid_test ORDER BY id FORMAT Values") == "(0,'data'),(1,'data')"
assert node2.query("SELECT * FROM hybrid_test ORDER BY id FORMAT Values") == "(0,'data'),(1,'data')" assert node2.query("SELECT * FROM hybrid_test ORDER BY id FORMAT Values") == "(0,'data'),(1,'data')"