lttng: Do not rebuild the SS in every single state system test
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Sat, 8 Nov 2014 08:48:41 +0000 (09:48 +0100)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 10 Nov 2014 16:34:28 +0000 (11:34 -0500)
At some point we changed the state system tests to rebuild the whole
thing in the @Before, because at that point AssumeTrue() inside a
@BeforeClass did not work very well. Unfortunately this made running
the tests much longer.

Instead, really build the analysis/state system once per test class,
but only keep the AssumeTrue() in the main @Before that is ran every
test. That check will test a static boolean set by the @BeforeClass.

tl;dr Make the state system tests ~20 times faster.

Change-Id: I96a137e0d2ec871f92efe586ba6456aca0a61129
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/36184
Tested-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/stateprovider/PartialStateSystemTest.java
org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java
org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/stateprovider/StateSystemInMemoryTest.java
org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/stateprovider/StateSystemTest.java

index 8656bb4b747bf94b5e14119691d3667666f53d72..96638db28a5aed9a03fc44de4aa992a1200e2c3f 100644 (file)
@@ -21,7 +21,6 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
-import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
 import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
 import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
@@ -29,7 +28,8 @@ import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModul
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
-import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 /**
@@ -41,11 +41,20 @@ public class PartialStateSystemTest extends StateSystemTest {
 
     private static final @NonNull String TEST_FILE_NAME = "test-partial";
 
-    private File stateFile;
-    private TestLttngKernelAnalysisModule module;
+    private static File stateFile;
+    private static TestLttngKernelAnalysisModule module;
+
+    /**
+     * Test class setup
+     */
+    @BeforeClass
+    public static void initialize() {
+        if (!testTrace.exists()) {
+            traceIsPresent = false;
+            return;
+        }
+        traceIsPresent = true;
 
-    @Override
-    protected ITmfStateSystem initialize() {
         stateFile = new File(TmfTraceManager.getSupplementaryFileDir(testTrace.getTrace()) + TEST_FILE_NAME);
         if (stateFile.exists()) {
             stateFile.delete();
@@ -59,20 +68,26 @@ public class PartialStateSystemTest extends StateSystemTest {
         }
         module.schedule();
         assertTrue(module.waitForCompletion());
-        return module.getStateSystem();
+
+        fixture = module.getStateSystem();
     }
 
     /**
      * Class clean-up
      */
-    @After
-    public void cleanup() {
+    @AfterClass
+    public static void cleanup() {
         if (module != null) {
             module.dispose();
         }
         if (stateFile != null) {
             stateFile.delete();
         }
+        if (fixture != null) {
+            fixture.dispose();
+        }
+        module = null;
+        fixture = null;
     }
 
     /**
index 8b42822df7e71221e65333e6b8607de7aff9a636..65f66c3fa362fca302aa6605c6e5d71c9de2d3d4 100644 (file)
@@ -31,7 +31,8 @@ import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModul
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
-import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 /**
@@ -45,12 +46,21 @@ public class StateSystemFullHistoryTest extends StateSystemTest {
     private static final @NonNull String TEST_FILE_NAME = "test.ht";
     private static final @NonNull String BENCHMARK_FILE_NAME = "test.benchmark.ht";
 
-    private File stateFile;
-    private File stateFileBenchmark;
-    private TestLttngKernelAnalysisModule module;
+    private static File stateFile;
+    private static File stateFileBenchmark;
+    private static TestLttngKernelAnalysisModule module;
+
+    /**
+     * Test class setup
+     */
+    @BeforeClass
+    public static void initialize() {
+        if (!testTrace.exists()) {
+            traceIsPresent = false;
+            return;
+        }
+        traceIsPresent = true;
 
-    @Override
-    protected ITmfStateSystem initialize() {
         stateFile = createStateFile(TEST_FILE_NAME);
         stateFileBenchmark = createStateFile(BENCHMARK_FILE_NAME);
 
@@ -62,14 +72,15 @@ public class StateSystemFullHistoryTest extends StateSystemTest {
         }
         module.schedule();
         assertTrue(module.waitForCompletion());
-        return module.getStateSystem();
+
+        fixture = module.getStateSystem();
     }
 
     /**
      * Clean-up
      */
-    @After
-    public void cleanup() {
+    @AfterClass
+    public static void cleanup() {
         if (module != null) {
             module.dispose();
         }
@@ -79,6 +90,11 @@ public class StateSystemFullHistoryTest extends StateSystemTest {
         if (stateFileBenchmark != null) {
             stateFileBenchmark.delete();
         }
+        if (fixture != null) {
+            fixture.dispose();
+        }
+        module = null;
+        fixture = null;
     }
 
     // ------------------------------------------------------------------------
index 808519683cabe3055dcaa70a32469877c60c9508..0fe08395794f2d69497ba187301ac55d3fc1f33c 100644 (file)
@@ -17,13 +17,13 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import org.eclipse.tracecompass.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
-import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
 import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
 import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
-import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
 
 /**
  * State system tests using the in-memory back-end.
@@ -32,10 +32,19 @@ import org.junit.After;
  */
 public class StateSystemInMemoryTest extends StateSystemTest {
 
-    private TestLttngKernelAnalysisModule module;
+    private static TestLttngKernelAnalysisModule module;
+
+    /**
+     * Test class setup
+     */
+    @BeforeClass
+    public static void initialize() {
+        if (!testTrace.exists()) {
+            traceIsPresent = false;
+            return;
+        }
+        traceIsPresent = true;
 
-    @Override
-    protected ITmfStateSystem initialize() {
         module = new TestLttngKernelAnalysisModule();
         try {
             module.setTrace(testTrace.getTrace());
@@ -44,17 +53,23 @@ public class StateSystemInMemoryTest extends StateSystemTest {
         }
         module.schedule();
         assertTrue(module.waitForCompletion());
-        return module.getStateSystem();
+
+        fixture = module.getStateSystem();
     }
 
     /**
      * Class cleanup
      */
-    @After
-    public void cleanup() {
+    @AfterClass
+    public static void cleanup() {
         if (module != null) {
             module.dispose();
         }
+        if (fixture != null) {
+            fixture.dispose();
+        }
+        module = null;
+        fixture = null;
     }
 
     private static class TestLttngKernelAnalysisModule extends TmfStateSystemAnalysisModule {
index ae7ab0fff0727daeddcb9da4f46cf546082acd9f..06b8fb0e1d55b80db4e49694286b74f167f02886 100644 (file)
@@ -30,7 +30,6 @@ import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
 import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
 import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -65,29 +64,19 @@ public abstract class StateSystemTest {
     /** Number of nanoseconds in one second */
     private static final long NANOSECS_PER_SEC = 1000000000L;
 
-    private ITmfStateSystem fixture;
-
+    protected static ITmfStateSystem fixture;
+    protected static boolean traceIsPresent = false;
 
     /**
-     * Class set-up
+     * Test set-up
      */
     @Before
     public void setUp() {
-        assumeTrue(testTrace.exists());
-        fixture = this.initialize();
+        assumeTrue(traceIsPresent);
+        /* Subclasses should set-up 'fixture' */
         assertNotNull(fixture);
     }
 
-    protected abstract ITmfStateSystem initialize();
-
-    @After
-    public void tearDown() {
-        if (fixture != null) {
-            fixture.dispose();
-        }
-        fixture = null;
-    }
-
     @Test
     public void testFullQuery1() {
         List<ITmfStateInterval> list;
This page took 0.029326 seconds and 5 git commands to generate.