Skip to content

TestSuiteHelper: Include felix.scr if osgi.component is required#1970

Closed
sratz wants to merge 3 commits intoeclipse-pde:masterfrom
sratz:apitools-test-scr
Closed

TestSuiteHelper: Include felix.scr if osgi.component is required#1970
sratz wants to merge 3 commits intoeclipse-pde:masterfrom
sratz:apitools-test-scr

Conversation

@sratz
Copy link
Copy Markdown
Contributor

@sratz sratz commented Sep 18, 2025

Some test cases use 'org.eclipse.core.runtime' as dependency.

One of the runtime's dependencies (org.eclipse.core.contenttype) uses declarative services to provide a service component, but was missing the Require-Capability: header to require the osgi.extender=osgi.component.

In eclipse-platform/eclipse.platform#2162 this was corrected.

But as a result, for the resolution of org.eclipse.core.runtime to succeed, a OSGI extender provider must now strictly be present.

This cannot be auto-resolved as the PDE API tooling tests, as these tests are quite special and the bundles available in the resolver state are hand-picked by

TestSuiteHelper.addAllRequired(IApiBaseline, Set<String>, IApiComponent, List<IApiComponent>)

which currently does not support this kind of dependency.

To work around that, we check if we find a dependency on SCR and if so, add an implementation for it to the baseline fixture: org.apache.felix.scr and its dependencies.

See also: eclipse-equinox/equinox#1146

@sratz
Copy link
Copy Markdown
Contributor Author

sratz commented Sep 18, 2025

This works for me, but isn't very pretty.

@eclipse-pde-bot
Copy link
Copy Markdown
Contributor

eclipse-pde-bot commented Sep 18, 2025

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

apitools/org.eclipse.pde.api.tools.tests/META-INF/MANIFEST.MF
apitools/org.eclipse.pde.api.tools.tests/pom.xml
build/org.eclipse.pde.build.tests/META-INF/MANIFEST.MF
build/org.eclipse.pde.build.tests/pom.xml

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From 9072c5e73b4b2731ec21dfd71b78dd27e9becdf0 Mon Sep 17 00:00:00 2001
From: Eclipse PDE Bot <pde-bot@eclipse.org>
Date: Fri, 19 Sep 2025 14:06:55 +0000
Subject: [PATCH] Version bump(s) for 4.38 stream


diff --git a/apitools/org.eclipse.pde.api.tools.tests/META-INF/MANIFEST.MF b/apitools/org.eclipse.pde.api.tools.tests/META-INF/MANIFEST.MF
index 467c0a1e4a..44f7b5ef1e 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/META-INF/MANIFEST.MF
+++ b/apitools/org.eclipse.pde.api.tools.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %Bundle-Name
 Bundle-SymbolicName: org.eclipse.pde.api.tools.tests
-Bundle-Version: 1.4.200.qualifier
+Bundle-Version: 1.4.300.qualifier
 Bundle-Vendor: %Bundle-Vendor
 Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.pde.api.tools;bundle-version="1.0.600",
diff --git a/apitools/org.eclipse.pde.api.tools.tests/pom.xml b/apitools/org.eclipse.pde.api.tools.tests/pom.xml
index 143fb31ad0..dcc34f6ab4 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/pom.xml
+++ b/apitools/org.eclipse.pde.api.tools.tests/pom.xml
@@ -18,7 +18,7 @@
 		<relativePath>../../</relativePath>
 	</parent>
 	<artifactId>org.eclipse.pde.api.tools.tests</artifactId>
-	<version>1.4.200-SNAPSHOT</version>
+	<version>1.4.300-SNAPSHOT</version>
 	<packaging>eclipse-test-plugin</packaging>
 	<properties>
 		<defaultSigning-excludeInnerJars>true</defaultSigning-excludeInnerJars>
diff --git a/build/org.eclipse.pde.build.tests/META-INF/MANIFEST.MF b/build/org.eclipse.pde.build.tests/META-INF/MANIFEST.MF
index 551346175a..0f0dcf0410 100644
--- a/build/org.eclipse.pde.build.tests/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.pde.build.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: Tests Plug-in
 Bundle-SymbolicName: org.eclipse.pde.build.tests;singleton:=true
-Bundle-Version: 1.4.900.qualifier
+Bundle-Version: 1.4.1000.qualifier
 Bundle-Activator: org.eclipse.pde.build.tests.Activator
 Export-Package: org.eclipse.pde.build.internal.tests;x-internal:=true,
  org.eclipse.pde.build.internal.tests.ant;x-internal:=true,
diff --git a/build/org.eclipse.pde.build.tests/pom.xml b/build/org.eclipse.pde.build.tests/pom.xml
index a125f55714..a2c190539c 100644
--- a/build/org.eclipse.pde.build.tests/pom.xml
+++ b/build/org.eclipse.pde.build.tests/pom.xml
@@ -10,7 +10,7 @@
 		<version>4.38.0-SNAPSHOT</version>
 	</parent>
 	<artifactId>org.eclipse.pde.build.tests</artifactId>
-	<version>1.4.900-SNAPSHOT</version>
+	<version>1.4.1000-SNAPSHOT</version>
 	<packaging>eclipse-test-plugin</packaging>
 
 	<profiles>
-- 
2.51.0

Further information are available in Common Build Issues - Missing version increments.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Sep 18, 2025

Test Results

  324 files   -   441    324 suites   - 441   41m 13s ⏱️ - 12m 47s
  961 tests  - 2 650    928 ✅  - 2 625  30 💤  - 24  0 ❌  - 3  3 🔥 +2 
2 883 runs   - 7 950  2 783 ✅  - 7 875  91 💤  - 72  0 ❌  - 9  9 🔥 +6 

For more details on these errors, see this check.

Results for commit ad88220. ± Comparison against base commit 9213517.

This pull request removes 2650 tests.
org.eclipse.pde.api.tools.anttasks.tests.ApiToolingAnalysisAntTaskTests ‑ test1
org.eclipse.pde.api.tools.anttasks.tests.ApiToolingAnalysisAntTaskTests ‑ test2
org.eclipse.pde.api.tools.anttasks.tests.ApiToolingAnalysisAntTaskTests ‑ test3
org.eclipse.pde.api.tools.anttasks.tests.ApiToolingAnalysisAntTaskTests ‑ test4
org.eclipse.pde.api.tools.anttasks.tests.ApiToolingAnalysisAntTaskTests ‑ test5
org.eclipse.pde.api.tools.anttasks.tests.ApiToolingAnalysisAntTaskTests ‑ test6
org.eclipse.pde.api.tools.anttasks.tests.ApiToolingAnalysisAntTaskTests ‑ test7
org.eclipse.pde.api.tools.anttasks.tests.ApiToolingApiFreezeAntTaskTests ‑ test1
org.eclipse.pde.api.tools.anttasks.tests.ApiToolingApiFreezeAntTaskTests ‑ test2
org.eclipse.pde.api.tools.anttasks.tests.ApiToolingApiFreezeAntTaskTests ‑ test3
…

♻️ This comment has been updated with latest results.

public static void addAllRequired(IApiBaseline baseline, Set<String> done, IApiComponent component, List<IApiComponent> collection) throws CoreException {
IRequiredComponentDescription[] descriptions = component.getRequiredComponents();
if (component instanceof BundleComponent bc) {
for (BundleRequirement extenderRequirements : bc.getBundleDescription()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not tested it but

there is BundleDescription#getGenericRequires and we use it in P2 BundlesAction it should include the extender requirement.

The reverse is BundleDescription#getGenericCapabilities see BundlesAction so one could of course try to match those instead, so if there is a generic requires find a bundle that has a generic capability matching those.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but we do not have any pool of bundles available to query their capabilities here and match() them against the requirements.

That's the way these apitooling tests work:

They only load bundles of explicit names via getBundle(String) from a directory specified via -DrequiredBundles=... that this logic in addAllRequired() determines to load.

So I came up with this quick-and-dirty check.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They only load bundles of explicit names via getBundle(String) from a directory specified via -DrequiredBundles=... that this logic in addAllRequired() determines to load.

One might of course thing about reading all bundles from that directory and building an index...

At least it would get you the method GenericSpecification.getType() / getFilter() so a litte bit less parsing maybe...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed an improved algorithm that requires no parsing:

  • If we find an osgi.extender requirement
  • then try to load the felix.scr bundle and see if it's providing a capability for that requirement using the standard API
  • if it matches, add it + its dependencies

Some test cases use 'org.eclipse.core.runtime' as dependency.

One of the runtime's dependencies (org.eclipse.core.contenttype)
uses declarative services to provide a service component, but was
missing the Require-Capability: header to require the
osgi.extender=osgi.component.

In eclipse-platform/eclipse.platform#2162
this was corrected.

But as a result, for the resolution of org.eclipse.core.runtime
to succeed, a OSGI extender provider must now strictly be present.

This cannot be auto-resolved by the PDE API tooling tests, as
these tests are quite special and the bundles available in the
resolver state are hand-picked by

    TestSuiteHelper.addAllRequired(IApiBaseline, Set<String>, IApiComponent, List<IApiComponent>)

which currently does not support this kind of dependency.

To work around that, we check if we find a dependency on SCR
and if so, add an implementation for it to the baseline fixture:
org.apache.felix.scr and its dependencies.
Comment on lines +472 to +474
for (String bundleId : List.of("org.osgi.service.event", //$NON-NLS-1$
"org.osgi.service.component", "org.osgi.util.promise", //$NON-NLS-1$ //$NON-NLS-2$
"org.osgi.util.function")) { //$NON-NLS-1$
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just use the DependencyManager to compute all dependencies instead of hard-coding them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In principle, yes. In practice, no, as DependencyManager uses TargetPlatformHelper.getState() for the list of all available bundles. But here, in TestHelper, in this method we are in process of manually curating such a resolver state based on a directory passed in via -DrequiredBundles=.... So I don't see how we could do that easily.

@iloveeclipse
Copy link
Copy Markdown
Member

What is the current state here? I see PDE tests are still failing, contributions to PDE are affected.

@merks
Copy link
Copy Markdown
Contributor

merks commented Oct 3, 2025

I didn't know this PR was festering in the backlog and fixed this with a different hack:

#1977

@merks merks closed this Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants