Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PROBLEMS CREATING AN SSH TUNNEL in Ruby

Posted on 2013-05-22
2
Medium Priority
?
508 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 24

Accepted Solution

by:
fridom earned 2000 total points
ID: 39265028
0
 

Author Closing Comment

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Article by: narshlob
If you've ever programmed in Ruby and have come across either a proc or a lambda, you might have been wondering what the difference is between the two and when you would use one over the other. This article will try to explain the difference between…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

715 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