Clean-up: consumer.hpp: coding style indentation fix
[lttng-tools.git] / tests / regression / tools / client / test_event_rule_listing.py
1 #!/usr/bin/env python3
2 #
3 # Copyright (C) 2023 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 #
5 # SPDX-License-Identifier: GPL-2.0-only
6
7 import pathlib
8 import sys
9 import os
10 from typing import Any, Callable, Type, Dict, Iterator
11 import random
12 import string
13 from collections.abc import Mapping
14
15 """
16 Test the listing of recording rules associated to a channel.
17 """
18
19 # Import in-tree test utils
20 test_utils_import_path = pathlib.Path(__file__).absolute().parents[3] / "utils"
21 sys.path.append(str(test_utils_import_path))
22
23 import lttngtest
24
25
26 def test_identical_recording_rules_except_log_level_rule_type(tap, test_env):
27 # type: (lttngtest.TapGenerator, lttngtest._Environment) -> None
28 tap.diagnostic(
29 "Test adding and listing event rules that differ only by their log level rule type"
30 )
31
32 client = lttngtest.LTTngClient(test_env, log=tap.diagnostic)
33
34 session = client.create_session()
35 channel = session.add_channel(lttngtest.TracingDomain.User)
36 session.start()
37
38 app = test_env.launch_wait_trace_test_application(100)
39
40 llr_exactly = lttngtest.LogLevelRuleExactly(lttngtest.UserLogLevel.DEBUG_LINE)
41 llr_as_severe_as = lttngtest.LogLevelRuleAsSevereAs(
42 lttngtest.UserLogLevel.DEBUG_LINE
43 )
44
45 recording_rule_log_at_level = lttngtest.UserTracepointEventRule(
46 "lttng*", None, llr_exactly, None
47 )
48 recording_rule_log_at_least_level = lttngtest.UserTracepointEventRule(
49 "lttng*", None, llr_as_severe_as, None
50 )
51 recording_rule_no_log_level = lttngtest.UserTracepointEventRule(
52 "lttng*", None, None, None
53 )
54
55 with tap.case("Adding a recording rule with an `exact` log level rule"):
56 channel.add_recording_rule(recording_rule_log_at_level)
57
58 with tap.case("Adding a recording rule with an `as severe as` log level rule"):
59 channel.add_recording_rule(recording_rule_log_at_least_level)
60
61 with tap.case(
62 "Adding a recording rule without a log level rule (all log levels enabled)"
63 ):
64 channel.add_recording_rule(recording_rule_no_log_level)
65
66 rule_match_count = 0
67 for rule in channel.recording_rules:
68 if (
69 rule != recording_rule_no_log_level
70 and rule != recording_rule_log_at_level
71 and rule != recording_rule_log_at_least_level
72 ):
73 continue
74
75 rule_match_count = rule_match_count + 1
76
77 tap.test(
78 rule_match_count == 3,
79 "Recording rules are added and listed",
80 )
81
82
83 tap = lttngtest.TapGenerator(4)
84 tap.diagnostic("Test the addition and listing of event rules associated to a channel")
85
86 with lttngtest.test_environment(with_sessiond=True, log=tap.diagnostic) as test_env:
87 test_identical_recording_rules_except_log_level_rule_type(tap, test_env)
88
89 sys.exit(0 if tap.is_successful else 1)
This page took 0.030288 seconds and 4 git commands to generate.