Bug 185247 - JUnit tests for recursive symlinks
Summary: JUnit tests for recursive symlinks
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.10 M3   Edit
Assignee: Simeon Andreev CLA
QA Contact:
URL:
Whiteboard:
Keywords: test
Depends on:
Blocks: 232426 537449
  Show dependency tree
 
Reported: 2007-05-02 18:14 EDT by John Arthorne CLA
Modified: 2018-11-23 06:13 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2007-05-02 18:14:15 EDT
Build: I20070501-0010

The fix for bug 105554 adds handling for recursive symlink structures. We should add JUnit tests for these cases to ensure correctness and avoid regressions.
Comment 1 Martin Oberhuber CLA 2007-05-03 08:19:34 EDT
Note that from the test projects attached to bug 105554 comment 40 the test4_udev project is not under EPL and thus cannot be committed to CVS. 

For a first cut, this test case should be ignored. In the longer term, it might make sense developing a test project that has the same properties (very long link loop, fast growth in breadth during the loop).
Comment 2 Andrey Loskutov CLA 2018-07-30 08:57:31 EDT
We need those tests as precondition for the *working* algorithm for recursive symlinks detection (non working algorithm was developed in bug 105554), which allows users to see they (non recursive) links, see bug 537449.
Comment 3 Eclipse Genie CLA 2018-07-30 10:10:53 EDT
New Gerrit change created: https://git.eclipse.org/r/126784
Comment 4 Simeon Andreev CLA 2018-08-13 04:17:22 EDT
I am not able to add the test cases from bug 105554, since the Hudson job will try to archive the test case projects. This fails with an OOM, which comes from no idea where.

I've updated the review with some basic test cases, that are simple to understand. The test case which has two recursive symlinks will refresh forever, if the method  UnifiedTree.isRecursiveLink() is changed to always return false. So I think the tests still capture the essence of the test cases attached in bug 105554, as far as recursive symlinks are concerned.
Comment 5 Andrey Loskutov CLA 2018-08-13 04:20:28 EDT
(In reply to Simeon Andreev from comment #4)
> I am not able to add the test cases from bug 105554, since the Hudson job
> will try to archive the test case projects. This fails with an OOM, which
> comes from no idea where.

Not sure if I understand that. Test case projects are checked into git or created on the fly? In later case, they should be deleted on teardown, so that Hudson is not failing. In former case, they should be changed to be created & deleted on the fly, for the same reason.

> I've updated the review with some basic test cases, that are simple to
> understand. The test case which has two recursive symlinks will refresh
> forever, if the method  UnifiedTree.isRecursiveLink() is changed to always
> return false. So I think the tests still capture the essence of the test
> cases attached in bug 105554, as far as recursive symlinks are concerned.

Good.
Comment 6 Simeon Andreev CLA 2018-08-13 04:34:19 EDT
Some more info on the endless refresh due to recursive symlinks.

Without the fix for bug 105554, not any type of recursive symlinks will cause an endless loop in UnifiedTree (at least not under Linux).

A simple loop, such as myLink -> ../ will lead to an ever expanding file system path created by the tree. At some point, lstat will be called for a resource with such a path. lstat will return an error code, which will result in no FileInfo for the resource and the endless loop will break.

The "endless loop" is instead seen if there are two (or more) recursive symlinks, which both point to the same ancestor directory. The tree which Eclipse will try to build then grows exponentially. The depth is bounded by the path length at which lstat will return an error code, but reaching this depth still takes "forever".

(In reply to Andrey Loskutov from comment #5)
> (In reply to Simeon Andreev from comment #4)
> > I am not able to add the test cases from bug 105554, since the Hudson job
> > will try to archive the test case projects. This fails with an OOM, which
> > comes from no idea where.
> 
> Not sure if I understand that. Test case projects are checked into git or
> created on the fly? In later case, they should be deleted on teardown, so
> that Hudson is not failing. In former case, they should be changed to be
> created & deleted on the fly, for the same reason.

I initially added the test cases attached to bug 105554 in the resources/ folder of the test plug-in (i.e. check in git). I'm not going to go over 100+ files and create the same structure on-the-fly with source code; this is a waste of time in my opinion.
Comment 7 Andrey Loskutov CLA 2018-08-13 04:45:14 EDT
(In reply to Simeon Andreev from comment #6)
> I initially added the test cases attached to bug 105554 in the resources/
> folder of the test plug-in (i.e. check in git). I'm not going to go over
> 100+ files and create the same structure on-the-fly with source code; this
> is a waste of time in my opinion.

It depends. If we add "known bad" filesystem examples, we must be aware that not all parts of the tooling could support that.

If the test infrastructure doesn't work with recursive links, we have to use a different approach.

I think it should be easy to create a tar.gz or zip file out of your "resources" folder and use that for tests. Also please note, that Windows may not allow to create links for a "default" user without admin rights, if I remember it right, there was some limitation earlier, so probably tests need to be done on Mac/Linux only.
Comment 8 Simeon Andreev CLA 2018-08-13 04:54:24 EDT
(In reply to Andrey Loskutov from comment #7)
> I think it should be easy to create a tar.gz or zip file out of your
> "resources" folder and use that for tests. Also please note, that Windows
> may not allow to create links for a "default" user without admin rights, if
> I remember it right, there was some limitation earlier, so probably tests
> need to be done on Mac/Linux only.

I already do this in our own product tests. However I do the unpacking with unzip --symlinks. I've not been able to unpack the symlinks with JRE API so far.
Comment 9 Andrey Loskutov CLA 2018-08-13 05:10:03 EDT
(In reply to Simeon Andreev from comment #8)
> (In reply to Andrey Loskutov from comment #7)
> > I think it should be easy to create a tar.gz or zip file out of your
> > "resources" folder and use that for tests. Also please note, that Windows
> > may not allow to create links for a "default" user without admin rights, if
> > I remember it right, there was some limitation earlier, so probably tests
> > need to be done on Mac/Linux only.
> 
> I already do this in our own product tests. However I do the unpacking with
> unzip --symlinks. I've not been able to unpack the symlinks with JRE API so
> far.

A-ha. Lett assume we will use unzip and ignore Windows, I hope unzip is available on Mac too?
Comment 11 Andrey Loskutov CLA 2018-10-17 05:16:26 EDT
Simeon, please close tomorrow after SDK tests run (if there will be no surprises).
Comment 12 Alexander Kurtakov CLA 2018-11-23 06:13:27 EST
Mark as resolved.