envato / ami-spec

Acceptance testing your AMIs
MIT License
49 stars 15 forks source link

Question about adding helper gems to serverspec runtime #34

Closed sherzberg closed 6 years ago

sherzberg commented 6 years ago

I would like to use rspec-wait for testing things that take a while to complete in our ami. We have some long running boot processes that we need to ensure complete successfully and the serverspec tests are run too soon after the instance is booted and the ssh connection is successful.

I have tried adding a Gemfile in the root of the --specs but that doesn't seem to work as well as our projects main Gemfile but neither seem to get the rspec-wait gem loaded at serverspec run time.

Any ideas?

patrobinson commented 6 years ago

I'm not familiar with rspec-wait or how it works. I don't know if it will help, since serverspec I think tries to establish an SSH connection before the tests run.

Have you tried the --wait-for-rc flag? This waits for init.d to finish the boot process before proceeding.

sherzberg commented 6 years ago

I just tried the --wait-for-rc flag but I don't think that will help our situation because the boot time processes take a while to get to a stable state. It appears the wait for rc might not take that into account because our boot time processes are technically started, just not complete with what they need to do and what we are wanting to test for.

Should adding helper gems to the projects Gemfile work though in the serverspec run? The error we get is this:

NoMethodError
  undefined method 'wait_for' for Rspec::ExampleGroups.....
patrobinson commented 6 years ago

Have you tried requiring rspec-wait in your spec_helper?

sherzberg commented 6 years ago

Yes, I get the same thing with rspec-wait in the spec_helper. I've found some conflicting info on proper supported versions of serverspec with rspec-wait, so I'm going to try and push up some examples after I try some more things.

sherzberg commented 6 years ago

I did some more testing and found that my original issues were probably due to rspec-wait. I was able to get rspec-retry installed properly during the ami-spec run. Just looks like there is a version issue with rspec-wait or similar. If needed, I will go to them for resolution.

Thanks for your quick responses @patrobinson!