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

azure-sdk-for-ruby tests hanging in Ruby v2.0.0, v2.1.5, v2.2.0, v2.3.0 #276

Closed
floehopper opened this issue Oct 27, 2016 · 5 comments
Closed

Comments

@floehopper
Copy link
Member

This was originally reported by @sarangan12 in #272 (comment). However, I'm not convinced it's the same problem as was originally reported in #272, because in this case I can use ctrl-C to abort the tests. In #272, I had to use ctrl-Z and manually kill the process.

It doesn't look as if the code which caused the build failures exists any more, but I think I've been able to reproduce the problem as follows:

  • rbenv local 2.3.0
  • git clone git@github.com:Azure/azure-sdk-for-ruby.git
  • git checkout b1314c7b0c6ece809d979dc6d83abf0d62af3419
  • Change the mocha dependency in azure.gemspec to ~> 1.0
  • bundle install
$ bundle exec ruby -Itest test/unit/virtual_machine_management/virtual_machine_management_service_test.rb -v --seed 4895
Run options: -v --seed 4895

# Running:

Azure::VirtualMachineManagement::VirtualMachineManagementService::#get_virtual_machine#test_0001_return nil if virtual machine and cloud server does not exist  = 0.01 s = .
Azure::VirtualMachineManagement::VirtualMachineManagementService::#get_virtual_machine#test_0003_return virtual machine instance if virtual machine name and cloud server name are valid  = 0.00 s = .
Azure::VirtualMachineManagement::VirtualMachineManagementService::#get_virtual_machine#test_0002_return nil if virtual machine or cloud server does not exist  = 0.00 s = .
Azure::VirtualMachineManagement::VirtualMachineManagementService::#get_image#test_0002_errors if the virtual machine image does not exist = 0.01 s = .

# The tests hang here, but I can use ctrl-C to abort.
@floehopper
Copy link
Member Author

A simpler way to get an appropriate version of the azure-sdk-for-ruby code to reproduce the problem is to checkout the asm branch rather than the specific commit SHA that I suggested in my previous comment.

@floehopper
Copy link
Member Author

I used GDB to generate a Ruby backtrace at the point where the tests were hanging. The test is hanging in the subject block on line 21.

The problem seems to be related to line 413 of the test where all the private instance methods of the subject class, Azure::VirtualMachineManagementService are made public.

I can stop the tests from hanging by any one of the following:

  • Only make the get_image method public - this seems to be sufficient to pass the test
  • Only make the private instance methods of the class itself public, i.e. not its ancestors (by calling private_instance_methods(false))
  • Defining an initialize method on the subject class which just calls super

Although the test should not be hanging, line 413 of the test seems like a really dangerous thing to do, because it makes all of the private methods public for all tests after that point. This is because the class is effectively a global variable and so you are not protected by the tests creating a new instance each time.

@sarangan12: I will continue to investigate why the test is hanging, but in the meantime, I'd suggest you work around the problem by using one of my suggestions above.

@floehopper
Copy link
Member Author

floehopper commented Oct 27, 2016

I've now narrowed the problem down to the simplest scenario:

module Foo
end

class Bar
  prepend Foo

  public :initialize
end

p Bar.new # => hangs

I have created a Ruby bug report for the issue.

I'm not sure that there is much we can do in Mocha other than reverting back to not using a prepended module for stubbing. @chrisroos: Do you have any thoughts?

@floehopper
Copy link
Member Author

The bug in Ruby has been fixed and released in Ruby v2.4.0 and back-ported & released in Ruby v2.3.3.

floehopper added a commit that referenced this issue Jan 11, 2017
@floehopper
Copy link
Member Author

floehopper commented Jan 11, 2017

I've added a known issue to the Mocha README. I don't think there's anything else to do here, so I'm going to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant