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.209.6 test/backend/host_agent_lookup_test.rb
instana-1.209.5 test/backend/host_agent_lookup_test.rb
instana-1.209.4 test/backend/host_agent_lookup_test.rb
instana-1.209.3 test/backend/host_agent_lookup_test.rb
instana-1.209.2 test/backend/host_agent_lookup_test.rb
instana-1.209.1 test/backend/host_agent_lookup_test.rb
instana-1.209.0.pre3 test/backend/host_agent_lookup_test.rb
instana-1.209.0.pre2 test/backend/host_agent_lookup_test.rb
instana-1.209.0.pre1 test/backend/host_agent_lookup_test.rb
instana-1.208.0 test/backend/host_agent_lookup_test.rb
instana-1.207.0 test/backend/host_agent_lookup_test.rb
instana-1.206.0 test/backend/host_agent_lookup_test.rb
instana-1.205.0 test/backend/host_agent_lookup_test.rb
instana-1.204.0 test/backend/host_agent_lookup_test.rb
instana-1.204.0.pre3 test/backend/host_agent_lookup_test.rb
instana-1.204.0.pre2 test/backend/host_agent_lookup_test.rb
instana-1.204.0.pre1 test/backend/host_agent_lookup_test.rb
instana-1.203.2 test/backend/host_agent_lookup_test.rb
instana-1.203.1 test/backend/host_agent_lookup_test.rb
instana-1.203.0 test/backend/host_agent_lookup_test.rb