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

(POOLER-140) Ensure a VM is alive at checkout #329

Merged
merged 1 commit into from
Jul 17, 2019

Conversation

mattkirby
Copy link
Contributor

This commit duplicates the vm_ready? check to the API layer to allow for API to validate that a VM is alive at checkout. Without this change API relies upon the checks in pool_manager validating pools. This change should allow for additional insight into whether a machine is in a ready state and resopnding at checkout time.

Copy link
Contributor

@kevpl kevpl left a comment

Choose a reason for hiding this comment

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

seems fine to me.

my one question reading through is whether or not we can eliminate all the duplication of this line by putting it in a before :each or let statement:

allow_any_instance_of(Vmpooler::API::Helpers).to receive(:open_socket).and_return(socket)

@mattkirby
Copy link
Contributor Author

@kevpl I found that when the allow statement into a before(:each) block that it caused additional failures. I think this was because cases that were supposed to fail would show vm_ready? as true. I think it would be possible to reduce duplication by restructuring the tests to confine the before statements to where the addition is needed. It seemed like more work than what I ended up with though, so unless your preference is strong I think specifying the addition for each test works ok. Feel free to point out if I'm overcomplicating it though.

it 'returns a single VM' do
create_ready_vm 'pool1', 'abcdefghijklmnop'
create_ready_vm 'pool1', vmname
allow_any_instance_of(Vmpooler::API::Helpers).to receive(:open_socket).and_return(socket)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could not find a way to use allow to stub the return value of the open_socket method without using allow_any_instance_of. I suspect there's something I don't understand with where sinatra is loading the helpers, and that if I were to understand that better there is likely another way to get at this. I'm all for a cleaner solution, but after several days of banging my head against this I did not find one.

This commit duplicates the vm_ready? check to the API layer to allow for API to validate that a VM is alive at checkout. Without this change API relies upon the checks in pool_manager validating pools. This change should allow for additional insight into whether a machine is in a ready state and resopnding at checkout time.
@smcelmurry smcelmurry merged commit 4aad84a into puppetlabs:master Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants