I'm writing a series of test that test credit cart transactions and our card service relies on communicating to a sabrix server through an ssh tunnel.
I've created something that works but I have to admit, it doesn't make sense because I'm using a combination of a unix exec call and Net::SSH::Gateway.
In order for the ssh tunnel work with the tests to to work they HAVE to work in conjunction to each other.  I'm ok with it but it seems like 1 out of 10 times, the tests will fail because the ssh tunnel isn't open for some reason.   I've tried about every solution out there but can't seem to get anything else to work.    Here's the code:

  def setup
    @controller =    
    @pid = fork{ exec("ssh -N -L 8888:") } #this has to be open in a thread
    @gateway ='', 'deploy')             #this has to be created as well
    sleep(1) #sleep just a tad to let everything start up

  def test_update_credit_card_info
    #test code here…

Open in new window

And in my teardown method, I'm killing the ssh tunnel like this:

  def teardown
    system("kill -9 #{@pid}") #kill by pid
    @gateway.shutdown!		#kill the Net::SSH::Gateway instance

Open in new window

Any ideas?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
clemcrockAuthor Commented:
Thanks for all your help.   Love this site!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.