Skip to content

Commit a6eb70c

Browse files
committed
lttng.control: Fix listing UST domains if there are no logger agents
Don't fail if logger agents are not available (e.g. JUL). [Fixed] listing UST domains if there are no logger agents Fixes #192 Signed-off-by: Bernd Hufmann <[email protected]>
1 parent 71a804f commit a6eb70c

File tree

7 files changed

+508
-7
lines changed

7 files changed

+508
-7
lines changed

lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceMiTest.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**********************************************************************
2-
* Copyright (c) 2014 Ericsson
2+
* Copyright (c) 2014, 2024 Ericsson
33
*
44
* All rights reserved. This program and the accompanying materials are
55
* made available under the terms of the Eclipse Public License 2.0 which
@@ -21,6 +21,7 @@
2121

2222
import java.util.ArrayList;
2323
import java.util.List;
24+
import java.util.Optional;
2425

2526
import org.eclipse.core.commands.ExecutionException;
2627
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -30,6 +31,7 @@
3031
import org.eclipse.tracecompass.internal.lttng2.control.core.model.IEventInfo;
3132
import org.eclipse.tracecompass.internal.lttng2.control.core.model.ILoggerInfo;
3233
import org.eclipse.tracecompass.internal.lttng2.control.core.model.ISessionInfo;
34+
import org.eclipse.tracecompass.internal.lttng2.control.core.model.IUstProviderInfo;
3335
import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType;
3436
import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceChannelOutputType;
3537
import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType;
@@ -60,6 +62,7 @@ public class LTTngControlServiceMiTest extends LTTngControlServiceTest {
6062
private static final String SCEN_ENABLING_JUL_LOGGERS = "EnableJulLoggers";
6163
private static final String SCEN_ENABLING_LOG4J_LOGGERS = "EnableLog4jLoggers";
6264
private static final String SCEN_ENABLING_PYTHON_LOGGERS = "EnablePythonLoggers";
65+
private static final String SCEN_GET_UST_PROVIDER4 = "GetUstProvider4";
6366

6467
@Override
6568
protected ILttngControlService getControlService() {
@@ -463,4 +466,23 @@ public void testEnablePythonLoggers() {
463466
fail(e.toString());
464467
}
465468
}
469+
470+
@Test
471+
@Override
472+
public void testUstProvider4() {
473+
try {
474+
fShell.setScenario(SCEN_GET_UST_PROVIDER4);
475+
List<IUstProviderInfo> providers = fService.getUstProvider();
476+
477+
assertNotNull(providers);
478+
assertEquals(2, providers.size());
479+
480+
// Verify that there are no logger ust provider
481+
Optional<IUstProviderInfo> optional = providers.stream().filter(provider -> provider.getLoggers().size() > 0).findFirst();
482+
assertTrue(optional.isEmpty());
483+
484+
} catch (ExecutionException e) {
485+
fail(e.toString());
486+
}
487+
}
466488
}

lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**********************************************************************
2-
* Copyright (c) 2012, 2015 Ericsson
2+
* Copyright (c) 2012, 2024 Ericsson
33
*
44
* All rights reserved. This program and the accompanying materials are
55
* made available under the terms of the Eclipse Public License 2.0 which
@@ -746,6 +746,10 @@ public void testGetUstProvider3() {
746746
}
747747
}
748748

749+
@Test
750+
public void testUstProvider4() {
751+
// Nothing to do because loggers are only supported with MI.
752+
}
749753

750754
@Test
751755
public void testGetKernelProviderNoUst1() {

lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMi3Test.cfg

Lines changed: 155 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
####################################################################
2-
# Copyright (c) 2014, 2016 Ericsson
2+
# Copyright (c) 2014, 2024 Ericsson
33
#
44
# All rights reserved. This program and the accompanying materials are
55
# made available under the terms of the Eclipse Public License 2.0 which
@@ -1334,6 +1334,160 @@ lttng --mi xml list -p
13341334
</command>
13351335
</COMMAND_OUTPUT>
13361336
</SCENARIO>
1337+
1338+
####################################################################
1339+
# Scenario: Test "lttng list -u -f" with missing logger agents
1340+
####################################################################
1341+
<SCENARIO>
1342+
GetUstProvider4
1343+
<COMMAND_INPUT>
1344+
lttng --mi xml list -u -f
1345+
</COMMAND_INPUT>
1346+
<COMMAND_RESULT>
1347+
0
1348+
</COMMAND_RESULT>
1349+
<COMMAND_OUTPUT>
1350+
<?xml version="1.0" encoding="UTF-8"?>
1351+
<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0">
1352+
<name>list</name>
1353+
<output>
1354+
<domains>
1355+
<domain>
1356+
<type>UST</type>
1357+
<buffer_type>PER_PID</buffer_type>
1358+
<pids>
1359+
<pid>
1360+
<id>9379</id>
1361+
<name>/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello</name>
1362+
<events>
1363+
<event>
1364+
<name>ust_tests_hello:tptest_sighandler</name>
1365+
<type>TRACEPOINT</type>
1366+
<enabled>true</enabled>
1367+
<loglevel>TRACE_DEBUG_MODULE</loglevel>
1368+
<loglevel_type>ALL</loglevel_type>
1369+
<event_fields/>
1370+
</event>
1371+
<event>
1372+
<name>ust_tests_hello:tptest</name>
1373+
<type>TRACEPOINT</type>
1374+
<enabled>true</enabled>
1375+
<loglevel>TRACE_INFO</loglevel>
1376+
<loglevel_type>ALL</loglevel_type>
1377+
<event_fields>
1378+
<event_field>
1379+
<name>doublefield</name>
1380+
<type>FLOAT</type>
1381+
<nowrite>0</nowrite>
1382+
</event_field>
1383+
<event_field>
1384+
<name>floatfield</name>
1385+
<type>FLOAT</type>
1386+
<nowrite>0</nowrite>
1387+
</event_field>
1388+
<event_field>
1389+
<name>stringfield</name>
1390+
<type>STRING</type>
1391+
<nowrite>0</nowrite>
1392+
</event_field>
1393+
</event_fields>
1394+
</event>
1395+
</events>
1396+
</pid>
1397+
<pid>
1398+
<id>4852</id>
1399+
<name>/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello</name>
1400+
<events>
1401+
<event>
1402+
<name>ust_tests_hello:tptest_sighandler</name>
1403+
<type>TRACEPOINT</type>
1404+
<enabled>true</enabled>
1405+
<loglevel>TRACE_WARNING</loglevel>
1406+
<loglevel_type>ALL</loglevel_type>
1407+
<event_fields/>
1408+
</event>
1409+
<event>
1410+
<name>ust_tests_hello:tptest</name>
1411+
<type>TRACEPOINT</type>
1412+
<enabled>true</enabled>
1413+
<loglevel>TRACE_DEBUG_FUNCTION</loglevel>
1414+
<loglevel_type>ALL</loglevel_type>
1415+
<event_fields>
1416+
<event_field>
1417+
<name>doublefield</name>
1418+
<type>FLOAT</type>
1419+
<nowrite>0</nowrite>
1420+
</event_field>
1421+
<event_field>
1422+
<name>floatfield</name>
1423+
<type>FLOAT</type>
1424+
<nowrite>0</nowrite>
1425+
</event_field>
1426+
<event_field>
1427+
<name>stringfield</name>
1428+
<type>STRING</type>
1429+
<nowrite>0</nowrite>
1430+
</event_field>
1431+
</event_fields>
1432+
</event>
1433+
</events>
1434+
</pid>
1435+
</pids>
1436+
</domain>
1437+
</domains>
1438+
</output>
1439+
</command>
1440+
</COMMAND_OUTPUT>
1441+
<COMMAND_INPUT>
1442+
lttng --mi xml list -j
1443+
</COMMAND_INPUT>
1444+
<COMMAND_RESULT>
1445+
1
1446+
</COMMAND_RESULT>
1447+
<COMMAND_OUTPUT>
1448+
<?xml version="1.0" encoding="UTF-8"?>
1449+
<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0">
1450+
<name>list</name>
1451+
<output/>
1452+
</command>
1453+
<COMMAND_ERROR_OUTPUT>
1454+
Error: Unable to list jul events: Session daemon agent tracing is disabled
1455+
</COMMAND_ERROR_OUTPUT>
1456+
</COMMAND_OUTPUT>
1457+
<COMMAND_INPUT>
1458+
lttng --mi xml list -l
1459+
</COMMAND_INPUT>
1460+
<COMMAND_RESULT>
1461+
1
1462+
</COMMAND_RESULT>
1463+
<COMMAND_OUTPUT>
1464+
<?xml version="1.0" encoding="UTF-8"?>
1465+
<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0">
1466+
<name>list</name>
1467+
<output/>
1468+
</command>
1469+
<COMMAND_ERROR_OUTPUT>
1470+
Error: Unable to list log4j events: Session daemon agent tracing is disabled
1471+
</COMMAND_ERROR_OUTPUT>
1472+
</COMMAND_OUTPUT>
1473+
<COMMAND_INPUT>
1474+
lttng --mi xml list -p
1475+
</COMMAND_INPUT>
1476+
<COMMAND_RESULT>
1477+
1
1478+
</COMMAND_RESULT>
1479+
<COMMAND_OUTPUT>
1480+
<?xml version="1.0" encoding="UTF-8"?>
1481+
<command xmlns="http://lttng.org/xml/ns/lttng-mi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lttng.org/xml/ns/lttng-mi http://lttng.org/xml/schemas/lttng-mi/3/lttng-mi-3.0.xsd" schemaVersion="3.0">
1482+
<name>list</name>
1483+
<output/>
1484+
</command>
1485+
<COMMAND_ERROR_OUTPUT>
1486+
Error: Unable to list python events: Session daemon agent tracing is disabled
1487+
</COMMAND_ERROR_OUTPUT>
1488+
</COMMAND_OUTPUT>
1489+
</SCENARIO>
1490+
13371491
####################################################################
13381492
# Scenario: Test "lttng create <session>
13391493
####################################################################

0 commit comments

Comments
 (0)