Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334896 - [tools] Artifact mirror application: The ”-roots” parameter does not work and always downloads the whole artifact repository.
Summary: [tools] Artifact mirror application: The ”-roots” parameter does not work and...
Status: CLOSED WONTFIX
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: p2 (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows Vista
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: P2 Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2011-01-20 10:11 EST by Elena Yaneva CLA
Modified: 2019-07-29 15:42 EDT (History)
7 users (show)

See Also:


Attachments
test repository (7.44 KB, application/x-zip-compressed)
2011-01-20 10:11 EST, Elena Yaneva CLA
no flags Details
The removed check in getCompositeMetadataRepository() (1.00 KB, patch)
2011-01-20 10:13 EST, Elena Yaneva CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Elena Yaneva CLA 2011-01-20 10:11:53 EST
Created attachment 187192 [details]
test repository

Hello, 
Here is the use case:
I have a repository and I want to mirror it. From the repository I want  to get only an installable unit and all its dependencies, and not to download  the whole repository
For the purpose, I’m using  the “-roots”  parameter as an argument, in order to call the dependency resolution mechanism in the mirror application and to download only the root and all its dependencies.
The metadata mirroring works perfectly. However, in the artifact mirror case I found an issue:
 
The bug:
The ”-roots” parameter does not work and always downloads the whole artifact repository.
 
I debugged the case and the problem is that in the org.eclipse.equinox.p2.internal.repository.tools.MirrorApplication.initializeIUs() method, the queryResult variable does not get populated with correct result. It should return, in the example case, installable unit “FirstPlugin” with the version it found in the metadata repository.
 
The root cause:
And the root cause is that the metadata repository is not initialized.
The source repository (the one we want to mirror from) is not added as a child to the compositeMetadataRepository, because of a check.
The check is:
If medatada application: the source repository is added only to the compositeMetadataRepository
If artifact application: the source repository is added only to the compositeArtifactRepository
This is done in the getCompositeMetadataRepository() method of theorg.eclipse.equinox.p2.internal.repository.tool.AbstractApplication class.
 
Actually, the metadata repository has to be added in both cases, because the metadata is needed for the dependency resolution.
When I removed the check in getCompositeMetadataRepository(), everything worked perfectly and only the needed plugins were mirrored.

Steps to reproduce:
1. I'm attaching a test repository.
2. Call the mirror application like that:
-application org.eclipse.equinox.p2.artifact.repository.mirrorApplication -source file:C:/workspace/workspace_MirrorApplication/TestMirroringRepo
-destination file:C:/tmp/testRepo3 -roots FirstPlugin
3.The result is that all three plugins are downloaded: FirstPlugin, SecondPlugin and IndependantPlugin. When using the -roots param only FirstPlugin, SecondPlugin should be mirrored.

The test Plugins: 
FirstPlugin requires SecondPlugin 
IndependantPlugin is not required by FirstPlugin.

I'm attaching a patch as well.

Best Regards, 
Elena
Comment 1 Elena Yaneva CLA 2011-01-20 10:13:25 EST
Created attachment 187193 [details]
The removed check in getCompositeMetadataRepository()
Comment 2 DJ Houghton CLA 2011-01-21 16:19:34 EST
Thanks for the patch.
Applying the patch and running the tests produce several errors so I will have to determine if it is a problem with the patch or with the tests themselves.
Comment 3 DJ Houghton CLA 2011-01-21 17:10:24 EST
This is the first test that I am checking:

org.eclipse.equinox.p2.tests.mirror.NewMirrorApplicationArtifactTest.testIgnoreErrorsArgument
testIgnoreErrorsArgument(org.eclipse.equinox.p2.tests.mirror.NewMirrorApplicationArtifactTest)
junit.framework.AssertionFailedError: Verifying correct number of Keys expected:<2> but was:<0>

It has an interesting setup:
- artifact repository A with no actual JARs
- metadata repository A referring to artifact A
- artifact repository B with JAR for B

I think B is not being mirrored since the mirror operation is metadata-driven and we don't have any metadata for artifact B.
Comment 4 DJ Houghton CLA 2011-01-21 17:22:00 EST
The second test is expecting a failure because no metadata repository is specified in the test case, but since we changed the code to include all repos, we don't get the failure. 

junit.framework.AssertionFailedError: No exception thrown
	at junit.framework.Assert.fail(Assert.java:47)
	at org.eclipse.equinox.p2.tests.ant.MirrorTaskTest.testMirrorMetadataDestinationWithoutSource(MirrorTaskTest.java:194)
Comment 5 Pascal Rapicault CLA 2011-01-24 22:09:09 EST
I was reviewing the doc (http://help.eclipse.org/helios/topic/org.eclipse.platform.doc.isv/guide/p2_mirror.html) and it turns out that the -roots parameter is not meant to work since it is not supported :)

At this point we are adding a new functionality, which would explain why we are seeing all the tests failures. 

I looked at the code and though it appears the change is done at the simplest place, I think it will impact other code paths that will cause more repositories to be loaded and also try to load repos where there is not necessarily one.
A "better" patch (less impacting but more code changes) would be to change the behaviour of the mirroring app when it is run in artifact mode, and the -roots parameter is specified.
Additional comments on the patch:
- Make sure the code is formatted (the formatter settings are checked in the project)
- Create a test case for the pb
- Update the license header in the files you are changing
- Update the doc (in org.eclipse.platform.doc.user and doc.isv)

To be clear, if you want this to move forward, please provide a new patch :)
Comment 6 Thomas Watson CLA 2011-06-08 11:30:24 EDT
Move all 3.8 bugs to Juno.
Comment 7 Pascal Rapicault CLA 2011-06-10 21:49:28 EDT
Patch still welcome
Comment 8 Eclipse Genie CLA 2019-07-29 15:42:01 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.