Bug 331213 - [scp] Provide UI-less scp IFileService in org.eclipse.rse.services.ssh
Summary: [scp] Provide UI-less scp IFileService in org.eclipse.rse.services.ssh
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.4 RC3   Edit
Assignee: Anna Dushistova CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: helpwanted
Depends on: 213438
Blocks:
  Show dependency tree
 
Reported: 2010-11-26 10:22 EST by Martin Oberhuber CLA
Modified: 2012-06-13 14:38 EDT (History)
5 users (show)

See Also:
mober.at+eclipse: pmc_approved+
nikita_shulga: pmc_approved+


Attachments
The refactoring with plugin version updates (68.20 KB, patch)
2010-12-15 12:12 EST, Anna Dushistova CLA
no flags Details | Diff
Added versions update for affected plugins and features (72.66 KB, patch)
2010-12-15 15:47 EST, Anna Dushistova CLA
mober.at+eclipse: review+
Details | Diff
Patch for step 2 (36.31 KB, patch)
2011-12-01 19:45 EST, Anna Dushistova CLA
mober.at+eclipse: review+
Details | Diff
Patch with version updates to 0.2.0 for scp and 3.2.0 for services.ssh (11.38 KB, patch)
2012-01-31 07:08 EST, Martin Oberhuber CLA
no flags Details | Diff
Unit test for scp file subsystem (9.43 KB, patch)
2012-02-01 10:50 EST, Anna Dushistova CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Oberhuber CLA 2010-11-26 10:22:32 EST
We should refactor the core UI-less scp IFileService implementation, such that it can be used in server-side environments without RSE.

This should be easy, by just 
1.) moving the 3 core classes into a new package inside services.ssh
2.) exporting that package as x-friends:=subsystems.files.scp
3.) Requiring services.ssh with the new version in subsystems.files.scp

The drawback of doing so would be that the scp plugin requires the new (3.3) version of RSE, whereas today it might also work with the older (3.2 or even 3.1) version of TM.

What do others think, should we move forward with the refactoring or wait?
Comment 1 Anna Dushistova CLA 2010-11-30 11:14:36 EST
For us it doesn't matter, we are fine with doing refactoring now.
Comment 2 Anna Dushistova CLA 2010-12-14 16:44:01 EST
Martin, can we move services.ssh to the 1.5?
It's 1.4 now.
Comment 3 Martin Oberhuber CLA 2010-12-15 06:02:20 EST
What value do we get from moving to 1.5 ?
Comment 4 Anna Dushistova CLA 2010-12-15 08:40:57 EST
I just thought maybe it's time. :)
Our SCP classes that we need to move to services depend on 1.5 methods. We can fix them of course.
Comment 5 Martin Oberhuber CLA 2010-12-15 09:46:38 EST
I'd like to follow the Eclipse Platform's way here: only upgrade the Bundle-RequiredExecutionEnvironment when there is a clear benefit in doing so.

Much of Eclipse Platform (including core.resources) is 1.5 now; but I think that all the dependencies on the Services layer are still 1.4 or below, and there must be good reason for changing this.

That being said, if you have any good reasons why you chose 1.5 in SCP I'll consider change.
Comment 6 Anna Dushistova CLA 2010-12-15 12:12:05 EST
Created attachment 185244 [details]
The refactoring with plugin version updates

Martin, Nikita, could you please review the patch?
Thanks!
Comment 7 Martin Oberhuber CLA 2010-12-15 12:24:03 EST
Patch looks good to me as a first cut. 

In a second step, you might want to unify some functionality, e.g. there could be a single implementation of ScpFileUtils#concat() . Also, ScpFileUtils#escapePath() looks to me like it won't properly escape the " character and $ character -- we have different implementations of escapePath() in RSE which are more adequate for UNIX.

I can't remember whether the files.scp package re-uses anything from the files package and thus it's required to be a sub-package of files. I could also see a files package and scpfiles package reside in parallel. But I don't have a strong opinion on that, and files.scp might just be fine.
Comment 8 Martin Oberhuber CLA 2010-12-15 12:24:32 EST
PS to be clear about the 2nd step, I suggest committing the first step before making the second step changes in a separate patch.
Comment 9 Martin Oberhuber CLA 2010-12-15 12:26:29 EST
PPS on version ranges, I'm not yet entirely sure whether we want a 4.0.0) upper limit or 3.2.0) upper limit. At any rate, any MANIFEST.MF that you touched must up its micro version by 100 (unless it was uped in the 3.3 Stream already, you'll need to check what the version was like in R3_2_0). Corresponding features must also up their version number accordingly.
Comment 10 Anna Dushistova CLA 2010-12-15 15:47:57 EST
Created attachment 185266 [details]
Added versions update for affected plugins and features
Comment 11 Martin Oberhuber CLA 2010-12-15 18:12:17 EST
The terminals feature should go to 1.0.200.qualifier instead of 1.0.201.
What about the ssh feature? It should get a minor version uprev since services.ssh gets a minor version uprev.

The rse.tests bundle and feature should go to 3.3 I think -- tests don't provide any API, so rather than using the "API Rules" for version update I'd suggest always using the major.minor version of the main TM Release which is 3.3 now. I think that I did the same on the rse.sdk and rse.runtime features which should show the "overall product version".
Comment 12 Nikita Shulga CLA 2010-12-15 23:38:28 EST
Patch looks OK to me.
Comment 13 Anna Dushistova CLA 2010-12-16 12:25:09 EST
I checked in the patch. Martin, do you want to create additional bugs for the step 2, or can we continue here?
Comment 14 Anna Dushistova CLA 2011-12-01 13:22:55 EST
Martin,
did you mean we need to replace ScpFileUtils#escapePath() with org.eclipse.rse.core.model.SystemEscapeCharHelper#getStringForFileName() method?

Or is there any other method I should use?
Comment 15 Anna Dushistova CLA 2011-12-01 19:45:40 EST
Created attachment 207821 [details]
Patch for step 2

Martin, could you please review?
Comment 16 Anna Dushistova CLA 2012-01-25 08:48:34 EST
I checked in the patch for step 2. Is there anything else needed in this bug?
Comment 17 Martin Oberhuber CLA 2012-01-31 07:08:51 EST
Created attachment 210306 [details]
Patch with version updates to 0.2.0 for scp and 3.2.0 for services.ssh

Patches look good - given that this is new functionality for scp (being available in a UI-less environment), I decided to uprev the plugins as well as the feature by a minor increment.

In Juno, we now have the scp feature and plugin at 0.2.0 and services.ssh at 3.2.0

Also added the minimum version dependency on subsystems.scp, upreved the update site URL in the feature, and fixed the "Copyright-to-year" that's visible in the features and branding plugins.

I think we can consider this done, but I'd like somebody to test whether the actually desired effect is there (ie is it possible to have a UI-less service with SCP now). Do we have any unittest for this ?
Comment 18 Anna Dushistova CLA 2012-01-31 10:07:31 EST
(In reply to comment #17)
> I think we can consider this done, but I'd like somebody to test whether the
> actually desired effect is there (ie is it possible to have a UI-less service
> with SCP now). Do we have any unittest for this ?

I don't think we have it. Will copying something be a sufficient unit test? I can try to add something like this.
Comment 19 Martin Oberhuber CLA 2012-01-31 10:34:45 EST
Sure. Anything that uses _any_ functionality from SCP would do.
Comment 20 Anna Dushistova CLA 2012-02-01 10:50:38 EST
Created attachment 210378 [details]
Unit test for scp file subsystem

Martin, will something like this do?
Comment 21 Martin Oberhuber CLA 2012-02-01 11:28:34 EST
That kind of test is great and you should definitely add it (plus we could look at doing the RSEFileStoreTest to use scp connectivity in addition to local, ssh, ftp, dstore).

But that still wouldn't check that the ScpFileService can be used without any UI dependencies. I can't remember the exact history of this, but I think the desire was to be able and directly use the ScpFileService for transferring files (without the subsystem layer). 

I'm not sure what the idea was regarding how to get hold of the ScpFileService instance (would one just instantiate it although it's not API or would we have some clever trick using adapters to get to it). But that doesn't matter for a Unittest since a real unittest operates on as small a component as possible. I'd think that you could write a plain Unittest (not PDE Plugin test) which just instantiates the ScpFileService and exercises the methods to do some stuff like login, and transfer a file.
Comment 22 Anna Dushistova CLA 2012-02-09 17:53:47 EST
(In reply to comment #21)
> That kind of test is great and you should definitely add it (plus we could look
> at doing the RSEFileStoreTest to use scp connectivity in addition to local,
> ssh, ftp, dstore).
> 
> But that still wouldn't check that the ScpFileService can be used without any
> UI dependencies. I can't remember the exact history of this, but I think the
> desire was to be able and directly use the ScpFileService for transferring
> files (without the subsystem layer). 
> 
> I'm not sure what the idea was regarding how to get hold of the ScpFileService
> instance (would one just instantiate it although it's not API or would we have
> some clever trick using adapters to get to it). But that doesn't matter for a
> Unittest since a real unittest operates on as small a component as possible.
> I'd think that you could write a plain Unittest (not PDE Plugin test) which
> just instantiates the ScpFileService and exercises the methods to do some stuff
> like login, and transfer a file.

How do I get an IHost in this case?
I'd need to read it from properties, which will require PDE, won't it?
Comment 23 Martin Oberhuber CLA 2012-02-09 21:52:47 EST
I don't think you need an IHost.

Your Unittest could directly instanciate your ScpFileService. All you need is a minimal ISshSessionProvider. The session could be hardcoded to the local host.

ScpFileService fs = new ScpFileService(new ISshSessionProvider() {
  public String getControlEncoding() {return "iso-8859-1";}
  public void handleSessionLost() {}
  public Session getSession() {
    //copy some code from SshConnectorService#createSession() to here
  }
});

This is just for a Unittest so it doesn't need to be pretty .. fine to have a mock object for the ISshSessionProvider.
Comment 24 Anna Dushistova CLA 2012-02-10 14:44:13 EST
(In reply to comment #23)
> I don't think you need an IHost.
> 
> Your Unittest could directly instanciate your ScpFileService. All you need is a
> minimal ISshSessionProvider. The session could be hardcoded to the local host.
> 
> ScpFileService fs = new ScpFileService(new ISshSessionProvider() {
>   public String getControlEncoding() {return "iso-8859-1";}
>   public void handleSessionLost() {}
>   public Session getSession() {
>     //copy some code from SshConnectorService#createSession() to here
>   }
> });
> 
> This is just for a Unittest so it doesn't need to be pretty .. fine to have a
> mock object for the ISshSessionProvider.

I am going to need the access to IJSchService to initialize the Session:
session = service.createSession(hostname, port, username);

It's usually done by tracker.getService().
Is this acceptable?
I don't know how to access it in a different way...
Comment 25 Anna Dushistova CLA 2012-05-09 13:56:58 EDT
Only unit test is left to mark this as done.
Comment 26 Martin Oberhuber CLA 2012-06-12 16:06:28 EDT
Anna, for cleanup I suggest marking this done and creating a new bug (against 3.4.1 ?) for the unittest.
Comment 27 Anna Dushistova CLA 2012-06-13 14:38:08 EDT
Created bug 382536.