2024-02-12 20:41:46 +00:00
import pytest
from helpers . cluster import ClickHouseCluster
cluster = ClickHouseCluster ( __file__ )
instance = cluster . add_instance ( " instance " , with_zookeeper = True )
@pytest.fixture ( scope = " module " , autouse = True )
def start_cluster ( ) :
try :
cluster . start ( )
yield cluster
finally :
cluster . shutdown ( )
def test_insert_exception_over_http ( start_cluster ) :
2024-02-12 20:55:20 +00:00
instance . query ( " DROP TABLE IF EXISTS tt SYNC " )
instance . query (
" CREATE TABLE tt (KeyID UInt32) Engine = ReplicatedMergeTree( ' /test_insert_exception_over_http/tt ' , ' r1 ' ) ORDER BY (KeyID) "
)
instance . query (
" SYSTEM ENABLE FAILPOINT execute_query_calling_empty_set_result_func_on_exception "
)
assert True == instance . http_query_and_get_error (
2024-02-13 22:19:27 +00:00
" insert into tt settings insert_keeper_max_retries=0, insert_keeper_fault_injection_probability=1.0, log_comment= ' 02988_66a57d6f-d1cc-4693-8bf4-206848edab87 ' values (1), (2), (3), (4), (5) " ,
method = " POST " ,
2024-02-12 20:55:20 +00:00
) . startswith ( " 500 Internal Server Error " )
2024-02-12 20:41:46 +00:00
assert " 0 \n " == instance . query ( " select count() from tt " )
2024-02-13 22:06:00 +00:00
2024-02-12 20:41:46 +00:00
instance . query ( " SYSTEM FLUSH LOGS " )
2024-02-13 22:06:00 +00:00
assert " 1 \n " == instance . query (
2024-02-13 22:19:27 +00:00
" select count() from system.query_log where log_comment = ' 02988_66a57d6f-d1cc-4693-8bf4-206848edab87 ' and current_database = currentDatabase() and event_date >= yesterday() and type = ' QueryStart ' "
)
2024-02-13 22:06:00 +00:00
assert " 1 \n " == instance . query (
2024-02-13 22:19:27 +00:00
" select count() from system.query_log where log_comment = ' 02988_66a57d6f-d1cc-4693-8bf4-206848edab87 ' and current_database = currentDatabase() and event_date >= yesterday() and type = ' ExceptionWhileProcessing ' "
)
2024-02-12 20:41:46 +00:00
instance . query ( " DROP TABLE tt SYNC " )