From: Tuukka Lehtonen Date: Fri, 30 Aug 2019 06:53:56 +0000 (+0300) Subject: Log test name before and after execution with timeout and exec time X-Git-Tag: v1.43.0~136^2~86 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=f93d655be757bc3ccea8f2733a00eab1bd065351;p=simantics%2Fplatform.git Log test name before and after execution with timeout and exec time gitlab #367 Change-Id: I3ff6b1da4e773987bfc1d83fee9cef3f302a3d5e --- diff --git a/bundles/org.simantics.db.testing/src/org/simantics/db/testing/base/SCLScriptTestBase.java b/bundles/org.simantics.db.testing/src/org/simantics/db/testing/base/SCLScriptTestBase.java index 1ea9e6a54..459be8d4a 100644 --- a/bundles/org.simantics.db.testing/src/org/simantics/db/testing/base/SCLScriptTestBase.java +++ b/bundles/org.simantics.db.testing/src/org/simantics/db/testing/base/SCLScriptTestBase.java @@ -81,8 +81,10 @@ public class SCLScriptTestBase extends FreshDatabaseTest { String testName = resolveTestName(); TestRunnable runnable = testRunnables.get(testName); + long start = System.nanoTime(); if (timeout > -1) { + LOGGER.info("Running test {} with a timeout of {} seconds", testName, timeout); //$NON-NLS-1$ Timer timer = new Timer(); timer.schedule(new TimerTask() { @@ -104,14 +106,19 @@ public class SCLScriptTestBase extends FreshDatabaseTest { }, timeout*1000); try { runnable.run(); + long end = System.nanoTime(); + LOGGER.info("Completed test {} execution in {} seconds", testName, String.format("%.3f", (end-start)*1e-9)); //$NON-NLS-1$ } catch (Exception e) { LOGGER.error("Failed to run test {} runnable {}", testName, runnable, e); } finally { timer.cancel(); } } else { + LOGGER.info("Running test {} without timeout", testName); //$NON-NLS-1$ try { runnable.run(); + long end = System.nanoTime(); + LOGGER.info("Completed test {} execution in {} seconds", testName, String.format("%.3f", (end-start)*1e-9)); //$NON-NLS-1$ } catch (Exception e) { LOGGER.error("Failed to run test {} runnable {}", testName, runnable, e); } diff --git a/bundles/org.simantics.db.testing/src/org/simantics/db/testing/cases/FreshDatabaseTest.java b/bundles/org.simantics.db.testing/src/org/simantics/db/testing/cases/FreshDatabaseTest.java index 53ddfb04f..9ad9faf77 100644 --- a/bundles/org.simantics.db.testing/src/org/simantics/db/testing/cases/FreshDatabaseTest.java +++ b/bundles/org.simantics.db.testing/src/org/simantics/db/testing/cases/FreshDatabaseTest.java @@ -1,4 +1,3 @@ -package org.simantics.db.testing.cases; /******************************************************************************* * Copyright (c) 2007, 2010 Association for Decentralized Information Management * in Industry THTH ry. @@ -10,7 +9,7 @@ package org.simantics.db.testing.cases; * Contributors: * VTT Technical Research Centre of Finland - initial API and implementation *******************************************************************************/ - +package org.simantics.db.testing.cases; import org.junit.After; import org.junit.Before; @@ -25,7 +24,6 @@ import org.simantics.db.testing.common.Tests; public class FreshDatabaseTest extends TestBase { public void configure(TestSettings settings) { - } @Before diff --git a/bundles/org.simantics.db.testing/src/org/simantics/db/testing/cases/FreshWorkspaceTest.java b/bundles/org.simantics.db.testing/src/org/simantics/db/testing/cases/FreshWorkspaceTest.java index 0de078564..bc4681550 100644 --- a/bundles/org.simantics.db.testing/src/org/simantics/db/testing/cases/FreshWorkspaceTest.java +++ b/bundles/org.simantics.db.testing/src/org/simantics/db/testing/cases/FreshWorkspaceTest.java @@ -8,23 +8,22 @@ import org.simantics.db.testing.common.Tests; import org.simantics.db.testing.impl.Configuration; public class FreshWorkspaceTest extends TestBase { - + public void configure(TestSettings settins) { } - + @Before public void setUp() throws Exception { - TestBase.printStart(this); configure(TestSettings.getInstanceUnsafe()); state = Tests.freshWorkspace(Configuration.get().coreDir, initialWorkspaceFiles); super.setUp(); } - - @After - public void tearDown() throws Exception { - - Tests.shutdown(state); - super.tearDown(); - } + + @After + public void tearDown() throws Exception { + Tests.shutdown(state); + super.tearDown(); + } + } diff --git a/bundles/org.simantics.db.testing/src/org/simantics/db/testing/common/TestBase.java b/bundles/org.simantics.db.testing/src/org/simantics/db/testing/common/TestBase.java index 73e6ff8f1..d08caea4c 100644 --- a/bundles/org.simantics.db.testing/src/org/simantics/db/testing/common/TestBase.java +++ b/bundles/org.simantics.db.testing/src/org/simantics/db/testing/common/TestBase.java @@ -58,7 +58,7 @@ public abstract class TestBase { static boolean printStart = true; public static final ArrayList initialWorkspaceFiles = FileUtils.createFileFilter(Platform.getLocation().toFile(), null); public static void printStart(Object t) { - if(printStart) LOGGER.info("Test is {}", t.getClass().getName()); + if(printStart) LOGGER.info("Test class is {}", t.getClass().getName()); } protected static void setPrintStart(boolean value) { printStart = value; diff --git a/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java b/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java index 7839ce70d..c0a85cd1a 100644 --- a/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java +++ b/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java @@ -678,10 +678,11 @@ public class SimanticsPlatform implements LifecycleListener { } public void resetDatabase(IProgressMonitor monitor) throws PlatformException { + // TODO: fix this to use Path APIs File dbLocation = Platform.getLocation().append("db").toFile(); if(!dbLocation.exists()) return; try { // Load driver - Driver driver = Manager.getDriver("procore"); + Driver driver = Manager.getDriver("acorn"); Management management = driver.getManagement(dbLocation.getAbsolutePath(), null); management.delete(); } catch (DatabaseException e) {