Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Make tests independent from iproute package #393

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,6 @@ executors:
docker:
- image: cimg/ruby:3.3-node
commands:
setup_iproute2:
steps:
- run:
name: Install iproute2
command: |
sudo apt-get update
sudo apt-get install iproute2
setup:
steps:
- run:
Expand Down Expand Up @@ -296,7 +289,6 @@ jobs:
executor: << parameters.stack >>
steps:
- checkout
- setup_iproute2
- setup
- run_tests
test_apprisal:
Expand Down
20 changes: 16 additions & 4 deletions test/backend/host_agent_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@
class HostAgentTest < Minitest::Test
def test_spawn_background_thread
ENV['INSTANA_TEST'] = nil
::Instana.config[:agent_host] = '10.10.10.10'
agent_host = '10.10.10.10'
::Instana.config[:agent_host] = agent_host

if File.exist?('/sbin/ip')
addr = `/sbin/ip route | awk '/default/ { print $3 }'`.strip
if File.exist?('/proc/net/route')
default_gateway_hex = lambda {
File.open('/proc/net/route', 'r') do |file|
file.each_line do |line|
columns = line.split("\t")
if columns[1] == '00000000' && columns[1] == columns[7]
return columns[2]
end
end
end
}.call

addr = default_gateway_hex.scan(/.{2}/).map(&:hex).reverse.join('.')
stub_request(:get, "http://#{addr}:42699/")
.to_timeout
end

stub_request(:get, "http://10.10.10.10:42699/")
stub_request(:get, "http://#{agent_host}:42699/")
.to_timeout.times(3).then
.to_return(status: 200, body: "", headers: {})

Expand Down
Loading