Sha256: b809355c5c3239a5a80b89013c25c6c9b8f95dbeabd9b0abf4ca1c2e3381405e

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

require_relative "test_helper"

class TestBGPPeer < Minitest::Unit::TestCase
  include Clusterfuck

  def setup
    @peer = BGPPeer.new(:peer)
    @peer2 = BGPPeer.new(:peer2)
    @cluster = Cluster.new(:test)
  end

  def test_assigned_random_asn_in_private_range
    assert_instance_of Fixnum, @peer.bgp_asn
    assert 65000 <= @peer.bgp_asn
  end

  def test_assigned_random_ipv4_ip_as_router_id
    assert_match(/\d+\.\d+\.\d+\.\d+/, @peer.bgp_router_id.to_s)
  end

  def test_assigned_successive_asns
    assert_equal @peer.bgp_asn + 1, @peer2.bgp_asn
  end

  def test_assigned_different_default_ips_as_router_id
    refute_equal @peer.bgp_router_id, @peer2.bgp_router_id
  end

  def test_bgp_neighbors_returns_direct_neighbours
    @cluster.connect(SubnetFactory.next, @peer, @peer2)

    assert_equal [@peer2], @peer.bgp_neighbors
    assert_equal [@peer], @peer2.bgp_neighbors
  end

  def test_bgp_neighbours_doesnt_include_non_bgp_peers
    @non_peer = Machine.new(:test)

    @cluster.connect(SubnetFactory.next, @peer2, @peer)
    @cluster.connect(SubnetFactory.next, @peer2, @non_peer)

    assert_equal [@peer2], @peer.bgp_neighbors
    assert_equal [@peer], @peer2.bgp_neighbors
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-clusterfuck-0.0.1 test/bgp_peer_test.rb