better test

This commit is contained in:
Michael Stetsyuk 2024-11-29 17:45:55 +00:00
parent 997171a00e
commit b512997e50
7 changed files with 85 additions and 2 deletions

View File

@ -0,0 +1,10 @@
<clickhouse>
<startup_scripts>
<scripts>
<query>SELECT 42;</query>
</scripts>
<scripts>
<query>SELECT * FROM non_existent_table;</query>
</scripts>
</startup_scripts>
</clickhouse>

View File

@ -0,0 +1,11 @@
<clickhouse>
<startup_scripts>
<scripts>
<condition>SELECT 0;</condition>
<query>SELECT * FROM non_existent_table;</query>
</scripts>
<scripts>
<query>SELECT 42;</query>
</scripts>
</startup_scripts>
</clickhouse>

View File

@ -0,0 +1,8 @@
<clickhouse>
<users>
<default>
<profile>default</profile>
<no_password></no_password>
</default>
</users>
</clickhouse>

View File

@ -0,0 +1,56 @@
from enum import Enum
import random
import string
import time
import pytest
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
good = cluster.add_instance(
"good",
main_configs=[
"config/users.xml",
"config/good_script.xml"
],
stay_alive=True,
)
bad = cluster.add_instance(
"bad",
main_configs=[
"config/users.xml",
"config/bad_script.xml"
],
stay_alive=True,
)
@pytest.fixture(scope="module")
def start_cluster():
try:
cluster.start()
yield cluster
finally:
cluster.shutdown()
def test_startup_execution_state(start_cluster):
"""
Making sure that the StartupScriptsExecutionState metric is set correctly.
"""
STATE_SUCCESS = 1
STATE_FAILURE = 2
assert int(
good.query(
"SELECT value FROM system.metrics WHERE metric = 'StartupScriptsExecutionState'"
).strip()
) == STATE_SUCCESS
assert int(
bad.query(
"SELECT value FROM system.metrics WHERE metric = 'StartupScriptsExecutionState'"
).strip()
) == STATE_FAILURE

View File

@ -1 +0,0 @@
SELECT value FROM system.metrics WHERE metric = 'StartupScriptsExecutionState'