Sha256: 2c4e35aa5e09943ad1b3cfc8b22f9bba5348aed3eacf1504b3a620e27eb07be9

Contents?: true

Size: 1.83 KB

Versions: 57

Compression:

Stored size: 1.83 KB

Contents

# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2021

require 'test_helper'

class HostAgentLookupTest < Minitest::Test
  def test_lookup
    stub_request(:get, "http://10.10.10.10:42699/")
      .to_return(status: 200)

    subject = Instana::Backend::HostAgentLookup.new('10.10.10.10', 42699)
    client = subject.call

    assert client
    assert client.send_request('GET', '/').ok?
  end

  def test_lookup_no_agent
    stub_request(:get, "http://10.10.10.10:42699/")
      .to_timeout

    subject = Instana::Backend::HostAgentLookup.new('10.10.10.10', 42699)

    client = FakeFS.with_fresh do
      FakeFS::FileSystem.clone('test/support/ecs', '/proc')

      subject.call
    end

    assert_nil client
  end

  def test_lookup_agent_error
    stub_request(:get, "http://10.10.10.10:42699/")
      .to_return(status: 500)

    subject = Instana::Backend::HostAgentLookup.new('10.10.10.10', 42699)

    client = FakeFS.with_fresh do
      FakeFS::FileSystem.clone('test/support/ecs', '/proc')

      subject.call
    end

    assert_nil client
  end

  def test_lookup_with_gateway
    stub_request(:get, "http://10.10.10.10:42699/")
      .to_timeout
    stub_request(:get, "http://172.18.0.1:42699/")
      .to_return(status: 200)

    subject = Instana::Backend::HostAgentLookup.new('10.10.10.10', 42699)

    client = FakeFS do
      FakeFS::FileSystem.clone('test/support/proc', '/proc')
      subject.call
    end

    assert client
    assert client.send_request('GET', '/').ok?
  end

  def test_lookup_with_gateway_no_destination
    stub_request(:get, "http://10.10.10.10:42699/")
      .to_timeout

    subject = Instana::Backend::HostAgentLookup.new('10.10.10.10', 42699, destination: '11111111')

    client = FakeFS do
      FakeFS::FileSystem.clone('test/support/proc', '/proc')
      subject.call
    end

    assert_nil client
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
instana-1.217.1 test/backend/host_agent_lookup_test.rb
instana-1.217.0 test/backend/host_agent_lookup_test.rb
instana-1.216.0 test/backend/host_agent_lookup_test.rb
instana-1.215.1 test/backend/host_agent_lookup_test.rb
instana-1.215.0 test/backend/host_agent_lookup_test.rb
instana-1.214.4 test/backend/host_agent_lookup_test.rb
instana-1.214.3 test/backend/host_agent_lookup_test.rb
instana-1.214.2 test/backend/host_agent_lookup_test.rb
instana-1.214.1 test/backend/host_agent_lookup_test.rb
instana-1.214.0 test/backend/host_agent_lookup_test.rb
instana-1.213.3 test/backend/host_agent_lookup_test.rb
instana-1.213.2 test/backend/host_agent_lookup_test.rb
instana-1.213.1 test/backend/host_agent_lookup_test.rb
instana-1.213.0 test/backend/host_agent_lookup_test.rb
instana-1.212.0 test/backend/host_agent_lookup_test.rb
instana-1.211.0 test/backend/host_agent_lookup_test.rb
instana-1.210.1 test/backend/host_agent_lookup_test.rb
instana-1.210.0 test/backend/host_agent_lookup_test.rb
instana-1.209.8 test/backend/host_agent_lookup_test.rb
instana-1.209.7 test/backend/host_agent_lookup_test.rb