Skip to content

Commit ac6eee2

Browse files
committed
Add new big testcase
1 parent 5971533 commit ac6eee2

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ public void testSubstitutableExports03() throws BundleException, IOException {
10931093

10941094
List<ModuleWire> providedWiresF = wiringF.getProvidedModuleWires(PackageNamespace.PACKAGE_NAMESPACE);
10951095
assertEquals("Wrong number of provided wires: " + providedWiresF, 0, providedWiresF.size());
1096-
assertSucessfulWith(report, 3, 1, 1, 1);
1096+
assertSucessfulWith(report, 3, 1, 1, 1); // TODO why this got worse? Do we need to respect resolve order?
10971097
}
10981098

10991099
@Test
@@ -4391,6 +4391,46 @@ public void testSubstitutionPackageResolution() throws Exception {
43914391
assertSucessfulWith(result, 2, 2, 1, 0); // TODO why became this worse?
43924392
}
43934393

4394+
@Test
4395+
public void testLargeSet() throws Exception {
4396+
ResolutionReport result = resolveModuleDatabaseDump("big", TimeUnit.MINUTES.toSeconds(5));
4397+
assertSucessfulWith(result, 117, 344, 1, 172);
4398+
}
4399+
4400+
private ResolutionReport resolveModuleDatabaseDump(String testSetName, long batchTimeoutSeconds) throws Exception {
4401+
URL entry = getBundle().getEntry("/test_files/containerTests/" + testSetName + ".state");
4402+
assertNotNull("can't find test set: " + testSetName, entry);
4403+
int maxThreads = Math.max(Runtime.getRuntime().availableProcessors() - 1, 1);
4404+
BlockingQueue<Runnable> queue = new SynchronousQueue<>();
4405+
ThreadFactory threadFactory = r -> {
4406+
Thread t = new Thread(r, "Resolver thread - UNIT TEST"); //$NON-NLS-1$
4407+
t.setDaemon(true);
4408+
return t;
4409+
};
4410+
ScheduledExecutorService watchDog = Executors.newSingleThreadScheduledExecutor();
4411+
RejectedExecutionHandler rejectHandler = (r, exe) -> r.run();
4412+
ExecutorService executor = new ThreadPoolExecutor(0, maxThreads, 1, TimeUnit.SECONDS, queue, threadFactory,
4413+
rejectHandler);
4414+
ScheduledExecutorService timeoutExecutor = new ScheduledThreadPoolExecutor(1);
4415+
Map<String, String> configuration = new HashMap<>();
4416+
configuration.put(EquinoxConfiguration.PROP_RESOLVER_BATCH_TIMEOUT,
4417+
Long.toString(TimeUnit.SECONDS.toMillis(batchTimeoutSeconds)));
4418+
DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(false), configuration,
4419+
new DummyResolverHookFactory(), new DummyDebugOptions(Collections.emptyMap()));
4420+
adaptor.setResolverExecutor(executor);
4421+
adaptor.setTimeoutExecutor(timeoutExecutor);
4422+
try (DataInputStream stream = new DataInputStream(entry.openStream())) {
4423+
adaptor.getDatabase().load(stream);
4424+
}
4425+
ModuleContainer container = adaptor.getContainer();
4426+
AtomicBoolean timeout = new AtomicBoolean();
4427+
ScheduledFuture<?> watch = watchDog.schedule(() -> timeout.set(true), batchTimeoutSeconds, TimeUnit.SECONDS);
4428+
ResolutionReport report = container.resolve(container.getModules(), true);
4429+
watch.cancel(true);
4430+
assertFalse("Resolve operation timed out!", timeout.get());
4431+
return report;
4432+
}
4433+
43944434
private ResolutionReport resolveTestSet(String testSetName) throws Exception {
43954435
Enumeration<URL> entries = getBundle().findEntries("/test_files/containerTests/" + testSetName, "*.MF", false);
43964436
Map<Long, String> manifests = new TreeMap<>();
Binary file not shown.

0 commit comments

Comments
 (0)