Solved

PROBLEMS CREATING AN SSH TUNNEL in Ruby

Posted on 2013-05-22
2
468 Views
Last Modified: 2013-06-26
Hello,
  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
    super
    @controller = AccountController.new    
    @pid = fork{ exec("ssh -N -L 8888:10.0.1.68:8080 test@test.test.com") } #this has to be open in a thread
    @gateway = Net::SSH::Gateway.new('test.test.com', 'deploy')             #this has to be created as well
    sleep(1) #sleep just a tad to let everything start up
  end

  def test_update_credit_card_info
    #test code here…
  end

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
  end

Open in new window


Any ideas?

Thanks,
Eric
0
Comment
Question by:clemcrock
2 Comments
 
LVL 24

Accepted Solution

by:
fridom earned 500 total points
ID: 39265028
0
 

Author Closing Comment

by:clemcrock
ID: 39279541
Thanks for all your help.   Love this site!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Ruby, Call or invoke a API DLL library is easily via Win32API class, win32-api gem or other gems. For general DLL API call, there are quite a few references, some good tips list below: http://www.rubytips.org/2008/05/13/accessing-windows-api-fro…
Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question