summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Daniel2013-11-04 06:59:31 (EST)
committerKrzysztof Daniel2013-11-04 07:36:11 (EST)
commit8c9187a7cdfca9ae0c93566c5f383a6c7e6137bf (patch)
treef2fd663987b688750e5f0333ff83c2b0f9cb952a
parent8273ad8faf1fa387f043a47d0ad8ca0df2d356b7 (diff)
downloadrt.equinox.p2-8c9187a7cdfca9ae0c93566c5f383a6c7e6137bf.zip
rt.equinox.p2-8c9187a7cdfca9ae0c93566c5f383a6c7e6137bf.tar.gz
rt.equinox.p2-8c9187a7cdfca9ae0c93566c5f383a6c7e6137bf.tar.bz2
bug 420260: org.eclipse.equinox.p2.tests take 1.5h longer on the Mac I20131105-0800refs/changes/21/18021/1
This is a temporary instrumentation to gather thread dumps when a test takes longer than 60 seconds. Change-Id: I242857ccdd600d954e539e656a3fb0e0613f747d Signed-off-by: Krzysztof Daniel <kdaniel@redhat.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestTimeoutDump.java53
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java3
7 files changed, 70 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestTimeoutDump.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestTimeoutDump.java
new file mode 100644
index 0000000..6ee32cd
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestTimeoutDump.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2013 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation, Markus Keller - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.p2.tests;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+import junit.framework.TestCase;
+
+public class TestTimeoutDump {
+ static String fgName;
+ static int fgTimeoutSeconds;
+ static Thread fgTimer;
+
+ public static void setUp(TestCase testCase, int timeoutSeconds) {
+ fgName = testCase.getClass().getName() + "#" + testCase.getName();
+ fgTimeoutSeconds = timeoutSeconds;
+ fgTimer = new Thread() {
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(fgTimeoutSeconds * 1000);
+ } catch (InterruptedException e) {
+ fgTimer = null;
+ return;
+ }
+ System.err.println("Thread dump " + fgName + " at " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z", Locale.US).format(new Date()) + ":");
+ Map<Thread, StackTraceElement[]> s = Thread.getAllStackTraces();
+ for (Map.Entry<Thread, StackTraceElement[]> entry : s.entrySet()) {
+ String name = entry.getKey().getName();
+ StackTraceElement[] stack = entry.getValue();
+ Exception exception = new Exception(name);
+ exception.setStackTrace(stack);
+ exception.printStackTrace();
+ }
+ System.err.flush();
+ fgTimer = null;
+ }
+ };
+ fgTimer.start();
+ }
+
+ public static void tearDown() {
+ if (fgTimer != null) {
+ fgTimer.interrupt();
+ }
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java
index 0e329b7..cd4c954 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java
@@ -52,6 +52,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
protected void tearDown() throws Exception {
super.tearDown();
+ TestTimeoutDump.tearDown();
//repository location is not used by all tests
if (repositoryURI != null) {
getArtifactRepositoryManager().removeRepository(repositoryURI);
@@ -63,6 +64,11 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
}
}
+ protected void setUp() throws Exception {
+ TestTimeoutDump.setUp(this, 60);
+ super.setUp();
+ }
+
public void testCompressedRepositoryCreation() {
//create a compressed repo
createRepo(true);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java
index e01be13..2a447dd 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java
@@ -588,7 +588,7 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest {
public void testNonLocalRepo() {
PrintStream out = System.out;
try {
- System.setOut(new PrintStream(new StringBufferStream()));
+ // System.setOut(new PrintStream(new StringBufferStream()));
URI location = new URI("http://foo.org/in/memory");
URI childOne = new URI("http://foo.org/in/memory/one");
URI childTwo = new URI("http://foo.org/in/memory/two");
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java
index 23806ad..dc66b68 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java
@@ -48,6 +48,7 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest {
* @see org.eclipse.equinox.p2.tests.AbstractProvisioningTest#setUp()
*/
protected void setUp() throws Exception {
+ TestTimeoutDump.setUp(this, 60);
super.setUp();
//load all the repositories
sourceRepoLocation = getTestData("0.0", "/testData/mirror/mirrorSourceRepo1 with space");
@@ -74,6 +75,7 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest {
//delete the destination location (no left over files for the next test)
delete(destRepoLocation);
super.tearDown();
+ TestTimeoutDump.tearDown();
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java
index 8b6e3ba..ef61158 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java
@@ -24,6 +24,7 @@ import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+import org.eclipse.equinox.p2.tests.TestTimeoutDump;
/**
* Test API of the basic mirror application functionality's implementation.
@@ -39,6 +40,7 @@ public class MetadataMirrorApplicationTest extends AbstractProvisioningTest {
* @see org.eclipse.equinox.p2.tests.AbstractProvisioningTest#setUp()
*/
protected void setUp() throws Exception {
+ TestTimeoutDump.setUp(this, 60);
super.setUp();
//load all the repositories
sourceRepoLocation = getTestData("0.0", "/testData/mirror/mirrorSourceRepo1 with space");
@@ -65,6 +67,7 @@ public class MetadataMirrorApplicationTest extends AbstractProvisioningTest {
//delete the destination location (no left over files for the next test)
delete(destRepoLocation);
super.tearDown();
+ TestTimeoutDump.tearDown();
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java
index 624373c..1fdd137 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java
@@ -50,6 +50,7 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest {
* @see org.eclipse.equinox.p2.tests.AbstractProvisioningTest#setUp()
*/
protected void setUp() throws Exception {
+ TestTimeoutDump.setUp(this, 60);
super.setUp();
//load all the repositories
sourceRepoLocation = getTestData("0.0", "/testData/mirror/mirrorSourceRepo1 with space");
@@ -75,6 +76,7 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest {
//delete the destination location (no left over files for the next test)
delete(destRepoLocation);
super.tearDown();
+ TestTimeoutDump.tearDown();
}
private StringBuffer basicRunMirrorApplication(String message, URI source, URI destination, Boolean append, Boolean formatDestination, String destName) throws Exception {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java
index 29a1837..5a923a1 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java
@@ -26,6 +26,7 @@ import org.eclipse.equinox.p2.repository.IRepositoryReference;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+import org.eclipse.equinox.p2.tests.TestTimeoutDump;
import org.eclipse.osgi.util.NLS;
/*
@@ -45,6 +46,7 @@ public class NewMirrorApplicationMetadataTest extends AbstractProvisioningTest {
* @see org.eclipse.equinox.p2.tests.AbstractProvisioningTest#setUp()
*/
protected void setUp() throws Exception {
+ TestTimeoutDump.setUp(this, 60);
super.setUp();
//load all the repositories
sourceRepoLocation = getTestData("0.0", "/testData/mirror/mirrorSourceRepo1 with space");
@@ -73,6 +75,7 @@ public class NewMirrorApplicationMetadataTest extends AbstractProvisioningTest {
//delete the destination location (no left over files for the next test)
delete(destRepoLocation);
super.tearDown();
+ TestTimeoutDump.tearDown();
}
/**