Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PROBLEMS CREATING AN SSH TUNNEL

Status
Not open for further replies.

c73mr0ck

Programmer
Oct 25, 2012
11
US

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:

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

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

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

Any ideas?

Thanks,
Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top