dae031a94071f46b57ff6d8a702f3e2cb74b1296
2 * Copyright (C) 2016, EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 package org
.lttng
.ust
.agent
.integration
.events
;
21 import static org
.junit
.jupiter
.api
.Assertions
.assertEquals
;
23 import java
.io
.IOException
;
24 import java
.util
.ArrayList
;
25 import java
.util
.Collections
;
26 import java
.util
.List
;
27 import java
.util
.stream
.Stream
;
29 import org
.junit
.jupiter
.api
.AfterEach
;
30 import org
.junit
.jupiter
.api
.BeforeEach
;
31 import org
.junit
.jupiter
.api
.extension
.ExtendWith
;
32 import org
.junit
.jupiter
.params
.ParameterizedTest
;
33 import org
.junit
.jupiter
.params
.provider
.Arguments
;
34 import org
.junit
.jupiter
.params
.provider
.MethodSource
;
35 import org
.lttng
.tools
.ILttngSession
;
36 import org
.lttng
.ust
.agent
.utils
.TestPrintExtension
;
39 * Base class testing the "lttng list" command when using loggers organized as a
42 * For example, if a "org.myapp" logger exists and has a LTTng handler attached,
43 * a "org.myapp.mycomponent" logger should show up in "lttng list", even if
44 * itself does not have a handler, because its parent's handler can catch the
45 * log events as UST tracepoints.
47 * @author Alexandre Montplaisir
49 @ExtendWith(TestPrintExtension
.class)
50 public abstract class LoggerHierachyListITBase
{
52 protected static final String PARENT_LOGGER
= "org.lttng";
53 protected static final String CHILD_LOGGER
= "org.lttng.mycomponent";
55 private ILttngSession session
;
57 // ------------------------------------------------------------------------
58 // Test parameter definition
59 // ------------------------------------------------------------------------
62 * Generator for the test parameters.
64 * Generates all possible combinations of the 4 constructor parameters,
65 * except "parentActive" is necessarily true when "hasHandler" is true for a
68 * @param parentLoggerActive
69 * Parent logger has been instantiated
70 * @param parentLoggerHasHandler
71 * Parent logger has a LTTng handler attached to it
72 * @param childLoggerActive
73 * Child logger has been instantiated
74 * @param childLoggerHasHandler
75 * Child logger has a LTTng handler attached to it
77 * @return The test parameters
79 protected static Stream
<Arguments
> provideArguments() {
82 * Kept the whole array for clarity, but some cases are commented out:
83 * it is impossible to attach an handler if the logger itself is not
87 Arguments
.of( Boolean
.TRUE
, Boolean
.TRUE
, Boolean
.TRUE
, Boolean
.TRUE
),
88 Arguments
.of( Boolean
.TRUE
, Boolean
.TRUE
, Boolean
.TRUE
, Boolean
.FALSE
),
89 // Arguments.of( Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, Boolean.TRUE ),
90 Arguments
.of( Boolean
.TRUE
, Boolean
.TRUE
, Boolean
.FALSE
, Boolean
.FALSE
),
92 Arguments
.of( Boolean
.TRUE
, Boolean
.FALSE
, Boolean
.TRUE
, Boolean
.TRUE
),
93 Arguments
.of( Boolean
.TRUE
, Boolean
.FALSE
, Boolean
.TRUE
, Boolean
.FALSE
),
94 // Arguments.of( Boolean.TRUE, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE ),
95 Arguments
.of( Boolean
.TRUE
, Boolean
.FALSE
, Boolean
.FALSE
, Boolean
.FALSE
),
97 // Arguments.of( Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE ),
98 // Arguments.of( Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE ),
99 // Arguments.of( Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, Boolean.TRUE ),
100 // Arguments.of( Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, Boolean.FALSE ),
102 Arguments
.of( Boolean
.FALSE
, Boolean
.FALSE
, Boolean
.TRUE
, Boolean
.TRUE
),
103 Arguments
.of( Boolean
.FALSE
, Boolean
.FALSE
, Boolean
.TRUE
, Boolean
.FALSE
),
104 // Arguments.of( Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE ),
105 Arguments
.of( Boolean
.FALSE
, Boolean
.FALSE
, Boolean
.FALSE
, Boolean
.FALSE
)
109 protected ILttngSession
getSession() {
113 // ------------------------------------------------------------------------
115 // ------------------------------------------------------------------------
121 public void testSetup() {
122 session
= ILttngSession
.createSession(null, getDomain());
126 * Common test teardown
129 public void testTeardown() {
133 // ------------------------------------------------------------------------
135 // ------------------------------------------------------------------------
137 protected abstract ILttngSession
.Domain
getDomain();
139 protected abstract void activateLoggers(boolean parentLoggerActive
,
140 boolean parentLoggerHasHandler
,
141 boolean childLoggerActive
,
142 boolean childLoggerHasHandler
) throws IOException
;
144 // ------------------------------------------------------------------------
146 // ------------------------------------------------------------------------
149 * Test the output of the "lttng list" command.
151 * @param parentLoggerActive
152 * Parent logger has been instantiated
153 * @param parentLoggerHasHandler
154 * Parent logger has a LTTng handler attached to it
155 * @param childLoggerActive
156 * Child logger has been instantiated
157 * @param childLoggerHasHandler
158 * Child logger has a LTTng handler attached to it
160 * @throws IOException
164 @MethodSource("provideArguments")
165 public void testList(boolean parentLoggerActive
,
166 boolean parentLoggerHasHandler
,
167 boolean childLoggerActive
,
168 boolean childLoggerHasHandler
) throws IOException
{
170 activateLoggers(parentLoggerActive
,
171 parentLoggerHasHandler
,
173 childLoggerHasHandler
);
175 List
<String
> enabledEvents
= session
.listEvents();
176 List
<String
> expectedEvents
= new ArrayList
<>();
178 /* Reminder: "hasHandler" implies "isActive" */
180 if (parentLoggerHasHandler
) {
181 expectedEvents
.add(PARENT_LOGGER
);
183 if (childLoggerHasHandler
||
184 (childLoggerActive
&& parentLoggerHasHandler
)) {
185 expectedEvents
.add(CHILD_LOGGER
);
188 Collections
.sort(enabledEvents
);
189 Collections
.sort(expectedEvents
);
190 assertEquals(expectedEvents
, enabledEvents
);
This page took 0.034744 seconds and 5 git commands to generate.