Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileDepotFtp: FTP.nlst cannot distinguish empty from non-existent dir #9127

Merged
merged 2 commits into from
Jun 15, 2017

Conversation

isimluk
Copy link
Member

@isimluk isimluk commented Jun 3, 2016

Create directory structure by descending down

https://bugzilla.redhat.com/show_bug.cgi?id=1341502

The problem is that we cannot rely on fpt.nlst to give exception when
file is not available. With vsftpd 3.0.2-14.fc23 and Ruby-2.2.0 Net::FTP
I get behaviour like the following

    ftp.nlst('/')
    => ["/incoming", "/pub"]
    ftp.nlst('/incomming')
    => []
    ftp.nlst('/non-existent')
    => []

@miq-bot add_label darga/no, bug, core

@isimluk
Copy link
Member Author

isimluk commented Jun 3, 2016

/cc @jrafanie You may want to take a look. As you have touched this code in past (#1603, #1677, ...)

I came to conclusion that we need to build statefull mock objects (vsftpd, iis, and perhaps more) to avoid further breakages.

@isimluk
Copy link
Member Author

isimluk commented Jun 3, 2016

My theory, why we haven't seen this before is that we tested the previous bugs with either non existent directories or with non-empty. The new bug is about seeing the empty directory.

@@ -93,12 +93,15 @@ def file_exists?(file_or_directory)
private

def create_directory_structure(directory_path)
Pathname.new(directory_path).descend do |path|
Copy link
Member

Choose a reason for hiding this comment

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

@isimluk I had explicit reasons for using descend.

See #1603

If this works on iis, or any of the many varieties of ftp servers, I'm ok with it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see. The new code drills down the directory structure by mkdir A; chdir A the same way. So the IIS's inability to create directories like mkdir -p should not be a problem. However, I will try to get some IIS for testing.

Copy link
Member

Choose a reason for hiding this comment

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

@isimluk Please ask around and let me know if you can't get access for testing. Also, if you have ideas on how to capture this behavior so we can automate tests to avoid regression, I'd love to hear any ideas.

I'm fine with the change but would want some sanity checks on various ftps. Maybe @jcarter12 can DM you some information to test against the ftp they use for anonymous access.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, if you have ideas on how to capture this behavior so we can automate tests
to avoid regression, I'd love to hear any ideas.

I think the approach I had taken in the second commit of this PR can really help us in that regard.

Copy link
Member

Choose a reason for hiding this comment

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

Looks good to me. I'd like an examples for iis and anonymous ftp that @jcarter12 before merge though. We've changed things for other ftps in the past and I feel like this might cause a regression without confirmation.

Copy link
Member

Choose a reason for hiding this comment

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

Looks good to me too. Will advise QE on testing in the BZ.

@isimluk
Copy link
Member Author

isimluk commented Jun 7, 2016

Meh, I referenced wrong bz first time. I have amended pr with the right bz now (https://bugzilla.redhat.com/show_bug.cgi?id=1341502) 😢

https://bugzilla.redhat.com/show_bug.cgi?id=1341502

The problem is that we cannot rely on fpt.nlst to give exception when
file is not available. With vsftpd 3.0.2-14.fc23 and Ruby-2.2.0 Net::FTP
I get behaviour like the following

    ftp.nlst('/')
    => ["/incoming", "/pub"]
    ftp.nlst('/incomming')
    => []
    ftp.nlst('/non-existent')
    => []
I feel we need some better mocking then just rspec's double. There are
differences between various ftp servers and we keep touching
FileDepotFtp code as we see saw these differences comming.

The tests based on rspec's double are not the useful in this case
as they need to be rewritten each time we change the code logic. At that
point we may re-introduce bugs for certain ftp servers.

Let's build the knowledge about specific servers behavior in the spec.

https://bugzilla.redhat.com/show_bug.cgi?id=1341502
@gtanzillo gtanzillo added the wip label Jun 14, 2016
@chessbyte chessbyte changed the title FileDepotFtp: FTP.nlst cannot distinguish empty from non-existent dir [WIP] FileDepotFtp: FTP.nlst cannot distinguish empty from non-existent dir Jun 17, 2016
@miq-bot
Copy link
Member

miq-bot commented Oct 1, 2016

Checked commits isimluk/manageiq@f40f36a~...f87471a with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
2 files checked, 12 offenses detected

spec/models/file_depot_ftp_spec.rb

@gtanzillo gtanzillo closed this Jun 6, 2017
@gtanzillo gtanzillo reopened this Jun 6, 2017
@isimluk isimluk changed the title [WIP] FileDepotFtp: FTP.nlst cannot distinguish empty from non-existent dir FileDepotFtp: FTP.nlst cannot distinguish empty from non-existent dir Jun 7, 2017
@isimluk isimluk removed the wip label Jun 7, 2017
Copy link
Member

@gtanzillo gtanzillo left a comment

Choose a reason for hiding this comment

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

👍

@gtanzillo gtanzillo added this to the Sprint 63 Ending Jun 19, 2017 milestone Jun 15, 2017
@gtanzillo gtanzillo merged commit 471de63 into ManageIQ:master Jun 15, 2017
@isimluk
Copy link
Member Author

isimluk commented Jun 16, 2017

Thanks!

@isimluk isimluk deleted the rhbz#1341502 branch June 16, 2017 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants