Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 343152 - Make OSGi test runtime usable as "Running Platform" target platform
Summary: Make OSGi test runtime usable as "Running Platform" target platform
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Tycho (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 367118 (view as bug list)
Depends on: 386988
Blocks:
  Show dependency tree
 
Reported: 2011-04-18 09:07 EDT by Mickael Istria CLA
Modified: 2021-04-28 16:55 EDT (History)
14 users (show)

See Also:


Attachments
Example failing test plugin (1.63 MB, application/x-sdlc)
2011-04-18 14:28 EDT, Mickael Istria CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mickael Istria CLA 2011-04-18 09:07:08 EDT
And then plugins project in the test workspace (-data parameter) do not compile.

This is very annoying for projects that generate plugin code in their test.

To reproduce:
Create a Test Case that generates in the workspace a dummy bundle with a dependency to org.eclipse.core.runtime for instance; and assert it builds well.

The issue is due to the fact that the default target platform when running test is set to ${eclipse_home}, which is empty with maven-osgi-test-plugin launcher. Instead, the maven-osgi-test-plugin could create a target platform (Windows>Preference>PDE>Target Platform) that is made of the bundles of the running instance.

See also:
http://dev.eclipse.org/mhonarc/lists/tycho-user/msg00059.html
http://software.2206966.n2.nabble.com/Eclipse-UI-Tests-with-maven-osgi-test-plugin-td6036492.html
Comment 1 Mickael Istria CLA 2011-04-18 09:19:03 EDT
Fixing this bug in Tycho would be a workaround for PDE bug #343156
Comment 2 Curtis Windatt CLA 2011-04-18 10:52:22 EDT
Why is ${eclipse_home} empty when launching?  When launching from PDE the ${eclipse_home} variable is set which allows the target to work correctly.
Comment 3 Igor Fedorenko CLA 2011-04-18 11:17:01 EDT
To be clear, this is *NOT* a bug in tycho. Equinox is quite flexible about framework installation layout (see http://help.eclipse.org/helios/topic/org.eclipse.platform.doc.isv/reference/misc/runtime-options.html) and p2 extends this even further (see http://wiki.eclipse.org/Equinox_p2_Getting_Started). 

Tycho creates perfectly valid installation layout, which works for vast majority of test projects and is optimized to reduce file copy. If PDE or other thirdpart tools make assumptions about installation layout, this does not mean there is a bug in Tycho. It also means that all Tycho users must not pay (in terms of slower execution time and higher disk usage) for limitations of thirdparty tools only used by some Tycho users.

With this in mind, any patch submitted to implement this enhancement must satisfy the following requirements

* by default, test runtime uses all bundles by reference, nothing is copied beyond what is absolutely necessary (I can only think of framework extensions bundles atm)
* by default, test runtime only relies on equinox to discover and load bundles. so no p2 simpleconfigurator, old-style update manager or anything like that *by default*.
* alternative test runtime layouts must be configurable in pom.xml via maven-osgi-test-plugin configration parameter and implementation should be extensible enough to allow several alternative layouts, eg, fully fleshed-out eclipse folder with plugins/ and features/ directories, fully fleshed-out p2-enabled installed, p2-install with Maven local repository as bundle pool, etc.
** idealy, alternative layouts should be pluggable via maven build extensions, but this is not a hard requirement.
Comment 4 Mickael Istria CLA 2011-04-18 14:28:41 EDT
Created attachment 193516 [details]
Example failing test plugin

This is a sample failing project that creates a new bundle and intents to build it in order to ensure classpath is OK.
It works well with manual tests, but it fails with Tycho (because of the deficient target platform).
Comment 5 Tobias Oberlies CLA 2011-04-19 07:15:01 EDT
Here is what I understood: You are requesting that the OSGi runtime used to execute the eclipse-test-plugin tests has a layout that is compatible with the "Running Platform" target platform configuration in the PDE.

I agree with Igor that I'd rather see the necessary changes for this on the PDE side: OSGi offers very strong introspection capabilities, and the "Running Platform" target platform should use this mechanism rather than making assumptions on file system layout.

Nevertheless, if you want to provide a quality patch that creates a test runtime installation with the p2 director, I'd be willing to answer questions.
Comment 6 Mickael Istria CLA 2011-04-19 07:32:36 EDT
I agree that the issue comes from PDE. But apparently, getting this fixed in PDE is not possible.

Then I am currently more thinking about a workaround to have tests defining and using the right target platform. I'll first try to add the magic in tests, and then I'll see whether this can be an optional behavior of maven-osgi-test-plugin (for example having a <generatePDETargetPlatform>true</generatePDETargetPlatform>).

But we are still far from here, and I'll hopefully find a pragmatic way to get GMF-Tooling tests working. I'll use this bug to track the progress I made on this topic.
Comment 7 Igor Fedorenko CLA 2011-04-19 08:58:08 EDT
I think this would be a good enhancement to Tycho regardless of PDE. If my tests require full blown p2 enabled install for whatever reason, I should be able to run them with tycho. So if somebody contributes a quality patch, I'll be happy to review and apply it.
Comment 8 Tobias Oberlies CLA 2011-05-04 04:11:54 EDT
Changed title from "maven-osgi-test-plugin starts an instance with target platform set to ${eclipse_home} which is empty" to "Make OSGi test runtime usable as "Running Platform" target platform" to reflect what is actually requested here.
Comment 9 Mickael Istria CLA 2011-05-04 12:19:26 EDT
You can see here some "hacky" code I added to the beginning of the test suite to generate and activate a target platform that is identical to the instance running the tests:

http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.gmp/org.eclipse.gmf.tooling/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java?root=Modeling_Project&r1=1.104&r2=1.105


This is a bit ugly (reads activated bundle and add their parents folder to the target platform). It could maybe be improved, but I fear it will be difficult to do so while PDE won't provide a IBundleContainer that contains a single bundle to define target platforms.

This workaround seems to work for GMF Tooling.
Comment 10 Tobias Oberlies CLA 2011-05-05 03:42:24 EDT
(In reply to comment #9)
> You can see here some "hacky" code I added to the beginning of the test suite to
> generate and activate a target platform that is identical to the instance
> running the tests:
Actually, this doesn't look bad. The can't see any reason why the PDE shouldn't set up the "Running Platform" target platform in exactly the same way.
Comment 11 Mickael Istria CLA 2011-07-08 10:23:53 EDT
Based on comments of bug #343156, I tried to get Tycho generate a bundles.info instead of listing bundles in config.ini.

I added the unit test here: https://github.com/mickaelistria/sonatype-tycho/commit/ab3c329a2c0a6451c2cee737659309d1ce820a7f
And the tentative fix here: https://github.com/mickaelistria/sonatype-tycho/commit/10f542702f3821ca6b8a1a1538ffb0aae172ba78

That did not help, the PDE target platform is still wrong.
Comment 12 Igor Fedorenko CLA 2011-12-19 14:24:26 EST
*** Bug 367118 has been marked as a duplicate of this bug. ***
Comment 13 Jan Sievers CLA 2013-05-23 07:56:20 EDT
(In reply to comment #9)
> This workaround seems to work for GMF Tooling.

workaround

Utils.setTargetPlatform() 

from GMF is now in git and reported to work, see
http://dev.eclipse.org/mhonarc/lists/tycho-user/msg04391.html
Comment 14 Martha-Lucia Cadavid CLA 2013-05-23 07:58:48 EDT
New location of workaround source code example:
http://git.eclipse.org/c/gmf-tooling/org.eclipse.gmf-tooling.git/tree/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests
Comment 15 Jan Sievers CLA 2013-10-21 03:15:49 EDT
(In reply to Igor Fedorenko from comment #7)
> I think this would be a good enhancement to Tycho regardless of PDE. If my
> tests require full blown p2 enabled install for whatever reason, I should be
> able to run them with tycho.

test runtime provisioned by p2 has been implemented now (see bug 386988)
can we close this one?
Comment 16 Mickael Istria CLA 2013-10-21 07:22:22 EDT
I think there is nothing better that can be done on Tycho-side to handle this issue.
It seems fine that tests creating PDE projects have to configure a target platform, and it is more a default behaviour to change in PDE buyg 343156 .
I guess it can be closed as INVALID.
Comment 17 Tobias Oberlies CLA 2013-10-21 07:40:33 EDT
(In reply to comment #16)
> It seems fine that tests creating PDE projects have to configure a target
> platform
This may be a solution, but using a complete product installation as test runtime (see bug 386988) should also work. In the latter case, the test code would not need to configure the PDE target platform, but the PDE default ${eclipse.home} should work out of the box.

Note however that creating the complete product installation for the test run may be slower than having the test code configure the PDE. This is up the to users to decide.

In any case, this enhancement has been implemented (and hence this bug is resolved as FIXED).