tmf: Fix intermittent failure in ProjectExplorerTraceActionsTest
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Wed, 29 Jun 2016 20:19:27 +0000 (16:19 -0400)
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Thu, 14 Jul 2016 17:04:47 +0000 (13:04 -0400)
To reproduce the issue:

In TmfTraceElement.delete, add a Thread.sleep(5000); right after the
syncExec that calls closeEditors.

Run ProjectExplorerTraceActionsTest.test4_05Delete then
test4_09BringToTop (you can create a new test method and call them in
that order).

The problem is that the delete test waits until the delete dialog and
the editor are closed but there is no guarantee that the file will
actually be deleted right away. While the file is still there, it is
possible that the next test will start and begin the process of
opening the same existing trace. But then the file gets deleted and
the trace doesn't validate properly (or other exceptions depending on
the timing of when the trace gets deleted).

We should make sure that the file is deleted before proceeding.

Bug: 497035
Change-Id: I33d0b45732bdde6061112736f2f1f7e46d55864e
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/76249
Reviewed-by: Hudson CI
Reviewed-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Tested-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/projectexplorer/ProjectExplorerTraceActionsTest.java

index 9365b2fa26c305bcf2d9d6a78ee8e99185f6b058..5b2dec22cd102cc886d02e41ae2252df380532e6 100644 (file)
@@ -24,6 +24,7 @@ import java.util.stream.Collectors;
 import org.apache.log4j.ConsoleAppender;
 import org.apache.log4j.Logger;
 import org.apache.log4j.SimpleLayout;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.jdt.annotation.NonNull;
@@ -254,6 +255,7 @@ public class ProjectExplorerTraceActionsTest {
         shell.bot().button("Yes").click();
         fBot.waitUntil(Conditions.shellCloses(shell));
         fBot.waitWhile(new ConditionHelpers.ActiveEventsEditor(fBot, null));
+        fBot.waitUntil(new TraceDeletedCondition());
     }
 
     /**
@@ -302,6 +304,7 @@ public class ProjectExplorerTraceActionsTest {
         shell.bot().button("Yes").click();
         fBot.waitUntil(Conditions.shellCloses(shell));
         fBot.waitWhile(new ConditionHelpers.ActiveEventsEditor(fBot, null));
+        fBot.waitUntil(new TraceDeletedCondition());
     }
 
     /**
@@ -412,4 +415,16 @@ public class ProjectExplorerTraceActionsTest {
         assertTrue(view.bot().tree().hasItems());
         view.bot().tree().cell(0, 1).equals(Long.toString(NB_EVENTS));
     }
+
+    private final class TraceDeletedCondition extends DefaultCondition {
+        @Override
+        public boolean test() throws Exception {
+            return ResourcesPlugin.getWorkspace().getRoot().getProject(TRACE_PROJECT_NAME).findMember(new Path("Traces/" + TRACE_NAME)) == null;
+        }
+
+        @Override
+        public String getFailureMessage() {
+            return TRACE_NAME + " was not deleted successfully.";
+        }
+    }
 }
This page took 0.025309 seconds and 5 git commands to generate.