lttng: Fix intermittent MemoryUsageViewTest failure
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Mon, 14 Mar 2016 01:16:11 +0000 (21:16 -0400)
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Mon, 14 Mar 2016 15:32:47 +0000 (11:32 -0400)
It is possible that a thread gets added to the memory usage chart
before the process name is determined. Once the process name is
determined, a new series is added to the chart but the old one is not
deleted. Not only this fails the test because the chart contains too
many series, but it shows the wrong information to the user.

To reproduce the issue, you can add a Thread.sleep(5000) in
UstMemoryStateProvider around line 222, before the process name gets
added to the state system.

Change-Id: I95631758e0fdffbc094a3adb923b7019841a4a60
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/68312
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
lttng/org.eclipse.tracecompass.lttng2.ust.ui/src/org/eclipse/tracecompass/internal/lttng2/ust/ui/views/memusage/MemoryUsageViewer.java

index 425124b0be11f1042259278f171559a58fdb6f9c..ff3cf944a9216c8b088fcd33273f0f2298b24add 100644 (file)
@@ -113,17 +113,23 @@ public class MemoryUsageViewer extends TmfCommonXLineChartViewer {
                     fYValues.put(quark, new double[xvalues.length]);
                     fMemoryQuarks.put(quark, ss.getQuarkRelative(quark, UstMemoryStrings.UST_MEMORY_MEMORY_ATTRIBUTE));
                     int procNameQuark = ss.getQuarkRelative(quark, UstMemoryStrings.UST_MEMORY_PROCNAME_ATTRIBUTE);
+                    String oldSeriesName = fSeriesName.get(quark);
+                    String seriesName = null;
                     try {
                         ITmfStateValue procnameValue = ss.querySingleState(start, procNameQuark).getStateValue();
                         String procname = ""; //$NON-NLS-1$
                         if (!procnameValue.isNull()) {
                             procname = procnameValue.unboxStr();
                         }
-                        String seriesName = procname + ' ' + '(' + ss.getAttributeName(quark) + ')';
-                        fSeriesName.put(quark, seriesName.trim());
+                        seriesName = (procname + ' ' + '(' + ss.getAttributeName(quark) + ')').trim();
                     } catch (TimeRangeException e) {
-                        fSeriesName.put(quark, '(' + ss.getAttributeName(quark) + ')');
+                        seriesName = '(' + ss.getAttributeName(quark) + ')';
                     }
+
+                    if (oldSeriesName != null && !oldSeriesName.equals(seriesName)) {
+                        deleteSeries(oldSeriesName);
+                    }
+                    fSeriesName.put(quark, seriesName);
                 }
 
                 /*
This page took 0.026 seconds and 5 git commands to generate.