Skip to content

Commit 0e414ed

Browse files
authored
fix monitoring url (#10044)
1 parent 67e9445 commit 0e414ed

File tree

2 files changed

+54
-13
lines changed

2 files changed

+54
-13
lines changed

ydb/tests/olap/lib/allure_utils.py

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from ydb.tests.olap.lib.results_processor import ResultsProcessor
55
from urllib.parse import urlencode
66
from datetime import datetime
7+
from copy import deepcopy
78

89

910
def allure_test_description(
@@ -21,29 +22,46 @@ def _pretty_str(s):
2122
allure.dynamic.title(f'{suite}.{test}')
2223
for body, name, type in attachments:
2324
allure.attach(body, name, type)
24-
test_info = YdbCluster.get_cluster_info()
25+
test_info = deepcopy(YdbCluster.get_cluster_info())
2526
if test_info['name'].startswith('ydb-k8s'):
2627
core_link = f"https://coredumps.n.yandex-team.ru/index?itype=kikimr&host_list={test_info['nodes_wilcard']}&show_fixed=True"
2728
else:
2829
core_link = f"https://kikimr-cores.n.yandex-team.ru/show?server={test_info['nodes_wilcard']}%2A"
29-
monitoring_cluster = (
30-
YdbCluster.monitoring_cluster if YdbCluster.monitoring_cluster is not None else test_info['name']
31-
)
30+
del test_info['nodes_wilcard']
3231
test_info.update(addition_table_strings)
32+
monitoring_start = int((start_time) * 1000)
33+
monitoring_end = int((end_time) * 1000)
34+
# monitoring does not show intervals less 1 minute.
35+
monitoring_addition = 60000 - (monitoring_end - monitoring_start)
36+
if monitoring_addition > 0:
37+
monitoring_start -= monitoring_addition
38+
monitoring_end += monitoring_addition
39+
40+
service_url = YdbCluster._get_service_url()
41+
42+
def _get_monitoring_link(monitoring: YdbCluster.MonitoringUrl):
43+
return f"<a target='_blank' href='{monitoring.url.format(
44+
database='/' + test_info['database'],
45+
start_time=monitoring_start,
46+
end_time=monitoring_end
47+
)}'>{monitoring.caption}</a>"
48+
49+
monitoring = ', '.join([
50+
_get_monitoring_link(monitoring)
51+
for monitoring in YdbCluster.get_monitoring_urls()
52+
])
53+
3354
test_info.update(
3455
{
3556
'table_path': YdbCluster.tables_path,
36-
'monitoring': (
37-
f"<a target='_blank' href='https://monitoring.yandex-team.ru/projects/kikimr/dashboards/mone0310v4dbc6kui89v?"
38-
f"p.cluster={monitoring_cluster}&p.database=/{test_info['database']}&from={int(start_time * 1000)}&to={int(end_time * 1000)}'>link</a>"
39-
),
57+
'monitoring': monitoring,
4058
'coredumps': f"<a target='_blank' href='{core_link}'>link</a>",
4159
'db_admin': (
42-
f"<a target='_blank' href='{test_info['service_url']}/monitoring/tenant?"
60+
f"<a target='_blank' href='{service_url}/monitoring/tenant?"
4361
f"schema=/{test_info['database']}/{YdbCluster.tables_path}&tenantPage=query"
44-
f"&diagnosticsTab=nodes&name=/{test_info['database']}'>link</a>"
62+
f"&diagnosticsTab=nodes&name=/{test_info['database']}'>{service_url}</a>"
4563
),
46-
'timestamp': datetime.now().strftime('%c'),
64+
'time': f"{datetime.fromtimestamp(start_time).strftime('%a %d %b %y %H:%M:%S')} - {datetime.fromtimestamp(end_time).strftime('%H:%M:%S')}",
4765
}
4866
)
4967
if ResultsProcessor.send_results:

ydb/tests/olap/lib/ydb_cluster.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,37 @@
1313

1414

1515
class YdbCluster:
16+
class MonitoringUrl:
17+
def __init__(self, url: str, caption: str = 'link') -> None:
18+
self.url = url
19+
if self.url.find('://') < 0:
20+
self.url = f'https://{self.url}'
21+
self.caption = caption
22+
1623
_ydb_driver = None
1724
_results_driver = None
1825
_cluster_info = None
1926
ydb_endpoint = get_external_param('ydb-endpoint', 'grpc://ydb-olap-testing-vla-0002.search.yandex.net:2135')
2027
ydb_database = get_external_param('ydb-db', 'olap-testing/kikimr/testing/acceptance-2').lstrip('/')
2128
tables_path = get_external_param('tables-path', 'olap_yatests')
22-
monitoring_cluster = get_external_param('monitoring_cluster', 'olap_testing_vla')
29+
_monitoring_urls: list[YdbCluster.MonitoringUrl] = None
30+
31+
@classmethod
32+
def get_monitoring_urls(cls) -> list[YdbCluster.MonitoringUrl]:
33+
def _process_url(url: str) -> YdbCluster.MonitoringUrl:
34+
spl = url.split('::', 2)
35+
if len(spl) == 1:
36+
return YdbCluster.MonitoringUrl(spl[0])
37+
return YdbCluster.MonitoringUrl(spl[1], spl[0])
38+
if cls._monitoring_urls is None:
39+
cls._monitoring_urls = [
40+
_process_url(url)
41+
for url in get_external_param('monitoring_urls', (
42+
'monitoring.yandex-team.ru/projects/kikimr/dashboards/mone0310v4dbc6kui89v?'
43+
'p.cluster=olap_testing_vla&p.database=/{database}&from={start_time}&to={end_time}')
44+
).split(',')
45+
]
46+
return cls._monitoring_urls
2347

2448
@classmethod
2549
def _get_service_url(cls):
@@ -66,7 +90,6 @@ def get_cluster_info(cls):
6690
'version': version,
6791
'name': cluster_name,
6892
'nodes_wilcard': nodes_wilcard,
69-
'service_url': cls._get_service_url(),
7093
}
7194
return deepcopy(cls._cluster_info)
7295

0 commit comments

Comments
 (0)