Skip to content

Commit 934ab70

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 1801704 commit 934ab70

File tree

4 files changed

+187
-1
lines changed

4 files changed

+187
-1
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.Arrays;
2929
import java.util.HashSet;
3030
import java.util.List;
31+
import java.util.Optional;
3132
import java.util.Set;
3233

3334
import org.eclipse.core.commands.ExecutionException;
@@ -99,6 +100,7 @@ public class LTTngControlServiceTest {
99100
private static final String SCEN_GET_UST_PROVIDER1 = "GetUstProvider1";
100101
private static final String SCEN_GET_UST_PROVIDER2 = "GetUstProvider2";
101102
private static final String SCEN_GET_UST_PROVIDER3 = "GetUstProvider3";
103+
private static final String SCEN_GET_UST_PROVIDER4 = "GetUstProvider4";
102104
private static final String SCEN_LIST_WITH_NO_UST1 = "ListWithNoUst1";
103105
private static final String SCEN_LIST_WITH_NO_UST2 = "ListWithNoUst2";
104106
private static final String SCEN_LIST_WITH_NO_UST3 = "ListWithNoUst3";
@@ -746,6 +748,23 @@ public void testGetUstProvider3() {
746748
}
747749
}
748750

751+
@Test
752+
public void testUstProvider4() {
753+
try {
754+
fShell.setScenario(SCEN_GET_UST_PROVIDER4);
755+
List<IUstProviderInfo> providers = fService.getUstProvider();
756+
757+
assertNotNull(providers);
758+
assertEquals(2, providers.size());
759+
760+
// Verify that there are no logger ust provider
761+
Optional<IUstProviderInfo> optional = providers.stream().filter(provider -> provider.getLoggers().size() > 0).findFirst();
762+
assertTrue(optional.isEmpty());
763+
764+
} catch (ExecutionException e) {
765+
fail(e.toString());
766+
}
767+
}
749768

750769
@Test
751770
public void testGetKernelProviderNoUst1() {

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

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,168 @@ lttng --mi xml list -p
12691269
</command>
12701270
</COMMAND_OUTPUT>
12711271
</SCENARIO>
1272+
1273+
1274+
####################################################################
1275+
# Scenario: Test "lttng list -u -f" with missing logger agents
1276+
####################################################################
1277+
<SCENARIO>
1278+
GetUstProvider4
1279+
<COMMAND_INPUT>
1280+
lttng --mi xml list -u -f
1281+
</COMMAND_INPUT>
1282+
<COMMAND_RESULT>
1283+
0
1284+
</COMMAND_RESULT>
1285+
<COMMAND_OUTPUT>
1286+
<?xml version="1.0" encoding="UTF-8"?>
1287+
<command>
1288+
<name>list</name>
1289+
<output>
1290+
<domains>
1291+
<domain>
1292+
<type>UST</type>
1293+
<buffer_type>PER_PID</buffer_type>
1294+
<pids>
1295+
<pid>
1296+
<id>9379</id>
1297+
<name>/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello</name>
1298+
<events>
1299+
<event>
1300+
<name>ust_tests_hello:tptest_sighandler</name>
1301+
<type>TRACEPOINT</type>
1302+
<enabled>true</enabled>
1303+
<filter>false</filter>
1304+
<loglevel>TRACE_DEBUG_MODULE</loglevel>
1305+
<loglevel_type>ALL</loglevel_type>
1306+
<exclusion>false</exclusion>
1307+
<event_fields/>
1308+
</event>
1309+
<event>
1310+
<name>ust_tests_hello:tptest</name>
1311+
<type>TRACEPOINT</type>
1312+
<enabled>true</enabled>
1313+
<filter>false</filter>
1314+
<loglevel>TRACE_INFO</loglevel>
1315+
<loglevel_type>ALL</loglevel_type>
1316+
<exclusion>false</exclusion>
1317+
<event_fields>
1318+
<event_field>
1319+
<name>doublefield</name>
1320+
<type>FLOAT</type>
1321+
<nowrite>0</nowrite>
1322+
</event_field>
1323+
<event_field>
1324+
<name>floatfield</name>
1325+
<type>FLOAT</type>
1326+
<nowrite>0</nowrite>
1327+
</event_field>
1328+
<event_field>
1329+
<name>stringfield</name>
1330+
<type>STRING</type>
1331+
<nowrite>0</nowrite>
1332+
</event_field>
1333+
</event_fields>
1334+
</event>
1335+
</events>
1336+
</pid>
1337+
<pid>
1338+
<id>4852</id>
1339+
<name>/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello</name>
1340+
<events>
1341+
<event>
1342+
<name>ust_tests_hello:tptest_sighandler</name>
1343+
<type>TRACEPOINT</type>
1344+
<enabled>true</enabled>
1345+
<filter>false</filter>
1346+
<loglevel>TRACE_WARNING</loglevel>
1347+
<loglevel_type>ALL</loglevel_type>
1348+
<exclusion>false</exclusion>
1349+
<event_fields/>
1350+
</event>
1351+
<event>
1352+
<name>ust_tests_hello:tptest</name>
1353+
<type>TRACEPOINT</type>
1354+
<enabled>true</enabled>
1355+
<filter>false</filter>
1356+
<loglevel>TRACE_DEBUG_FUNCTION</loglevel>
1357+
<loglevel_type>ALL</loglevel_type>
1358+
<exclusion>false</exclusion>
1359+
<event_fields>
1360+
<event_field>
1361+
<name>doublefield</name>
1362+
<type>FLOAT</type>
1363+
<nowrite>0</nowrite>
1364+
</event_field>
1365+
<event_field>
1366+
<name>floatfield</name>
1367+
<type>FLOAT</type>
1368+
<nowrite>0</nowrite>
1369+
</event_field>
1370+
<event_field>
1371+
<name>stringfield</name>
1372+
<type>STRING</type>
1373+
<nowrite>0</nowrite>
1374+
</event_field>
1375+
</event_fields>
1376+
</event>
1377+
</events>
1378+
</pid>
1379+
</pids>
1380+
</domain>
1381+
</domains>
1382+
</output>
1383+
</command>
1384+
</COMMAND_OUTPUT>
1385+
<COMMAND_INPUT>
1386+
lttng --mi xml list -j
1387+
</COMMAND_INPUT>
1388+
<COMMAND_RESULT>
1389+
1
1390+
</COMMAND_RESULT>
1391+
<COMMAND_OUTPUT>
1392+
<?xml version="1.0" encoding="UTF-8"?>
1393+
<command>
1394+
<name>list</name>
1395+
<output/>
1396+
</command>
1397+
<COMMAND_ERROR_OUTPUT>
1398+
Error: Unable to list jul events: Session daemon agent tracing is disabled
1399+
</COMMAND_ERROR_OUTPUT>
1400+
</COMMAND_OUTPUT>
1401+
<COMMAND_INPUT>
1402+
lttng --mi xml list -l
1403+
</COMMAND_INPUT>
1404+
<COMMAND_RESULT>
1405+
1
1406+
</COMMAND_RESULT>
1407+
<COMMAND_OUTPUT>
1408+
<?xml version="1.0" encoding="UTF-8"?>
1409+
<command>
1410+
<name>list</name>
1411+
<output/>
1412+
</command>
1413+
<COMMAND_ERROR_OUTPUT>
1414+
Error: Unable to list log4j events: Session daemon agent tracing is disabled
1415+
</COMMAND_ERROR_OUTPUT>
1416+
</COMMAND_OUTPUT>
1417+
<COMMAND_INPUT>
1418+
lttng --mi xml list -p
1419+
</COMMAND_INPUT>
1420+
<COMMAND_RESULT>
1421+
1
1422+
</COMMAND_RESULT>
1423+
<COMMAND_OUTPUT>
1424+
<?xml version="1.0" encoding="UTF-8"?>
1425+
<command>
1426+
<name>list</name>
1427+
<output/>
1428+
</command>
1429+
<COMMAND_ERROR_OUTPUT>
1430+
Error: Unable to list python events: Session daemon agent tracing is disabled
1431+
</COMMAND_ERROR_OUTPUT>
1432+
</COMMAND_OUTPUT>
1433+
</SCENARIO>
12721434
####################################################################
12731435
# Scenario: Test "lttng create <session>
12741436
####################################################################

lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ public interface LTTngControlServiceConstants {
513513
/**
514514
* Pattern to match error line if no ust tracer is available or installed.
515515
*/
516-
Pattern LIST_UST_NO_UST_PROVIDER_PATTERN = Pattern.compile(".*Unable\\s*to\\s*list\\s*UST\\s*event.*"); //$NON-NLS-1$
516+
Pattern LIST_UST_NO_UST_PROVIDER_PATTERN = Pattern.compile(".*Unable\\s*to\\s*list\\s*(.*)\\s*event.*"); //$NON-NLS-1$
517517
/**
518518
* Pattern to match for list snapshot information (lttng snapshot list-output)
519519
*/

lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,11 @@ private void getUstProviderLoggers(List<IUstProviderInfo> allProviders, TraceDom
11411141
ICommandResult result = executeCommand(command, monitor, false);
11421142

11431143
if (isError(result)) {
1144+
// Ignore the following case (example jul):
1145+
// Error: Unable to list jul events: Session daemon agent tracing is disabled
1146+
if (ignoredPattern(result.getErrorOutput(), LTTngControlServiceConstants.LIST_UST_NO_UST_PROVIDER_PATTERN)) {
1147+
return;
1148+
}
11441149
throw new ExecutionException(Messages.TraceControl_CommandError + command.toString());
11451150
}
11461151

0 commit comments

Comments
 (0)