ClickHouse/tests/integration/test_startup_scripts_execution_state/test.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.2 KiB
Python
Raw Normal View History

2024-11-29 17:45:55 +00:00
import random
import string
import time
2024-11-29 17:53:59 +00:00
from enum import Enum
2024-11-29 17:45:55 +00:00
import pytest
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
good = cluster.add_instance(
"good",
2024-11-29 17:53:59 +00:00
main_configs=["config/users.xml", "config/good_script.xml"],
2024-11-29 17:45:55 +00:00
stay_alive=True,
)
bad = cluster.add_instance(
"bad",
2024-11-29 17:53:59 +00:00
main_configs=["config/users.xml", "config/bad_script.xml"],
2024-11-29 17:45:55 +00:00
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
2024-11-29 17:53:59 +00:00
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
)