Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2017-09-15 15:58:56 +0000
committerThomas Watson2017-09-18 17:06:07 +0000
commit8b01d0872e3d87aadadd398fc67dbdee2f880759 (patch)
tree9982d8ddcc3d7d286d22d245bd1dd9ecb39097f3
parent6f59ecfcd9585d5a5712883a05efef2a8d057296 (diff)
downloadrt.equinox.framework-8b01d0872e3d87aadadd398fc67dbdee2f880759.tar.gz
rt.equinox.framework-8b01d0872e3d87aadadd398fc67dbdee2f880759.tar.xz
rt.equinox.framework-8b01d0872e3d87aadadd398fc67dbdee2f880759.zip
Bug 522313 - Add TestcaseI20170918-2000
This testcase is very heavy. In order to reproduce on my local machine I had to install 40000 bundles in parallel over 500 threads This heavy load also exposed an issue with the bundle file closer because the single thread closing bundles would backup pending removals which ultimately lead to too many files being opened at the same time. A workaround was added to add delays when the pending closures got "too high" to allow the closer thread to catch up. The build machines cannot handle this test, diabled by default. Change-Id: Id157bee4e11f02753e6d7927ee2183519f74c3a9 Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rwxr-xr-xbundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java78
1 files changed, 77 insertions, 1 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
index 198a5f612..1df9950fa 100755
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java
@@ -15,7 +15,7 @@ import java.net.*;
import java.security.Permission;
import java.security.PrivilegedAction;
import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.jar.*;
import javax.net.SocketFactory;
@@ -3187,4 +3187,80 @@ public class SystemBundleTests extends AbstractBundleTests {
Assert.assertEquals("Wrong number of capabilities", capCount1, capCount2);
}
+
+ // Disabled because the test is too much for the build machines
+ public void disable_testBundleIDLock() {
+ File config = OSGiTestsActivator.getContext().getDataFile(getName()); //$NON-NLS-1$
+ Map<String, Object> configuration = new HashMap<String, Object>();
+ configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
+
+ final Equinox equinox = new Equinox(configuration);
+ try {
+ equinox.init();
+ } catch (BundleException e) {
+ fail("Unexpected exception in init()", e); //$NON-NLS-1$
+ }
+ // should be in the STARTING state
+ assertEquals("Wrong state for SystemBundle", Bundle.STARTING, equinox.getState()); //$NON-NLS-1$
+ final BundleContext systemContext = equinox.getBundleContext();
+ assertNotNull("System context is null", systemContext); //$NON-NLS-1$
+ try {
+ equinox.start();
+ } catch (BundleException e) {
+ fail("Failed to start the framework", e); //$NON-NLS-1$
+ }
+ assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, equinox.getState()); //$NON-NLS-1$
+
+ final int numBundles = 40000;
+ final File[] testBundles;
+ try {
+ testBundles = createBundles(new File(config, "bundles"), numBundles); //$NON-NLS-1$
+ } catch (IOException e) {
+ fail("Unexpected error creating budnles", e); //$NON-NLS-1$
+ throw new RuntimeException();
+ }
+
+ ExecutorService executor = Executors.newFixedThreadPool(500);
+ final List<Throwable> errors = new CopyOnWriteArrayList<Throwable>();
+ try {
+ for (int i = 0; i < testBundles.length; i++) {
+ final File testBundleFile = testBundles[i];
+ executor.execute(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ systemContext.installBundle("file:///" + testBundleFile.getAbsolutePath());
+ } catch (BundleException e) {
+ e.printStackTrace();
+ errors.add(e);
+ }
+ }
+ });
+
+ }
+ } finally {
+ executor.shutdown();
+ try {
+ executor.awaitTermination(600, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ fail("Interrupted.", e);
+ }
+ }
+
+ Assert.assertEquals("Errors found.", Collections.emptyList(), errors);
+ Assert.assertEquals("Wrong number of bundles.", numBundles + 1, systemContext.getBundles().length);
+ try {
+ equinox.stop();
+ } catch (BundleException e) {
+ fail("Unexpected erorr stopping framework", e); //$NON-NLS-1$
+ }
+ try {
+ equinox.waitForStop(10000);
+ } catch (InterruptedException e) {
+ fail("Unexpected interrupted exception", e); //$NON-NLS-1$
+ }
+ assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$
+ }
+
}

Back to the top