Skip to content

Commit 73302e9

Browse files
committed
test: Make tests independent from iproute package
Signed-off-by: Ferenc Géczi <[email protected]>
1 parent 1f3456b commit 73302e9

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

.circleci/config.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,6 @@ executors:
187187
docker:
188188
- image: cimg/ruby:3.3-node
189189
commands:
190-
setup_iproute2:
191-
steps:
192-
- run:
193-
name: Install iproute2
194-
command: |
195-
sudo apt-get update
196-
sudo apt-get install iproute2
197190
setup:
198191
steps:
199192
- run:
@@ -296,7 +289,6 @@ jobs:
296289
executor: << parameters.stack >>
297290
steps:
298291
- checkout
299-
- setup_iproute2
300292
- setup
301293
- run_tests
302294
test_apprisal:

test/backend/host_agent_test.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,27 @@
66
class HostAgentTest < Minitest::Test
77
def test_spawn_background_thread
88
ENV['INSTANA_TEST'] = nil
9-
::Instana.config[:agent_host] = '10.10.10.10'
9+
agent_host = '10.10.10.10'
10+
::Instana.config[:agent_host] = agent_host
1011

11-
if File.exist?('/sbin/ip')
12-
addr = `/sbin/ip route | awk '/default/ { print $3 }'`.strip
12+
if File.exist?('/proc/net/route')
13+
default_gateway_hex = lambda {
14+
File.open('/proc/net/route', 'r') do |file|
15+
file.each_line do |line|
16+
columns = line.split("\t")
17+
if columns[1] == '00000000' && columns[1] == columns[7]
18+
return columns[2]
19+
end
20+
end
21+
end
22+
}.call
23+
24+
addr = default_gateway_hex.scan(/.{2}/).map(&:hex).reverse.join('.')
1325
stub_request(:get, "http://#{addr}:42699/")
1426
.to_timeout
1527
end
1628

17-
stub_request(:get, "http://10.10.10.10:42699/")
29+
stub_request(:get, "http://#{agent_host}:42699/")
1830
.to_timeout.times(3).then
1931
.to_return(status: 200, body: "", headers: {})
2032

0 commit comments

Comments
 (0)