PageRenderTime 25ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/spec/models/candlepin_consumer_spec.rb

https://github.com/mbacovsky/katello
Ruby | 82 lines | 62 code | 9 blank | 11 comment | 2 complexity | fa30f5cc169d3ddc7aeb8d8e39d57f3b MD5 | raw file
Possible License(s): GPL-2.0
  1. #
  2. # Copyright 2014 Red Hat, Inc.
  3. #
  4. # This software is licensed to you under the GNU General Public
  5. # License as published by the Free Software Foundation; either version
  6. # 2 of the License (GPLv2) or (at your option) any later version.
  7. # There is NO WARRANTY for this software, express or implied,
  8. # including the implied warranties of MERCHANTABILITY,
  9. # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
  10. # have received a copy of GPLv2 along with this software; if not, see
  11. # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
  12. require 'katello_test_helper'
  13. module Katello
  14. describe Glue::Candlepin::Consumer do
  15. include OrchestrationHelper
  16. let(:facts) {
  17. {
  18. "net.interface.eth2.broadcast" => "123.123.123.123",
  19. "net.interface.eth2.ipv4_address" => "192.168.127.5",
  20. "net.interface.eth2.netmask" => "255.255.255.0",
  21. "net.interface.eth2.ipv6_address.link" => "fe80::1a03:73ff:fe44:6d94",
  22. "net.interface.eth0.broadcast" => "123.123.123.123",
  23. "net.interface.eth0.ipv4_address" => "192.168.127.4",
  24. "net.interface.eth0.netmask" => "255.255.255.0",
  25. "net.interface.eth0.ipv6_address.link" => "fe80::2a03:73ff:fe44:6d94",
  26. "net.interface.em1.broadcast" => "123.123.123.123",
  27. "net.interface.em1.ipv4_address" => "192.168.1.6",
  28. "net.interface.em1.netmask" => "255.255.255.0",
  29. "net.interface.em1.ipv6_address.link" => "fc80::2a03:73ff:fe44:6d94"
  30. }
  31. }
  32. let(:system_name) { 'testing' }
  33. let(:cp_type) { 'system' }
  34. let(:uuid) { '1234' }
  35. let(:description) { 'description' }
  36. before(:each) do
  37. @system = System.new(:name => system_name,
  38. :cp_type => cp_type,
  39. :facts => facts,
  40. :description => description,
  41. :uuid => uuid,
  42. :serviceLevel => nil)
  43. end
  44. describe "the system has a lot of interfaces" do
  45. it "should have three interfaces" do
  46. @system.interfaces.size.must_equal(3)
  47. end
  48. it "should have an invalid interface" do
  49. @system.facts["net.interface.em2.ipv4_address"] = nil
  50. @system.interfaces.size.must_equal(3)
  51. end
  52. it "should have an extra interface" do
  53. @system.facts["net.interface.eth4.ipv4_address"] = '192.168.1.121'
  54. @system.interfaces.size.must_equal(4)
  55. end
  56. it "should have correct interface mappings" do
  57. @system.facts["net.interface.eth4.ipv4_address"] = '192.168.1.121'
  58. @system.interfaces.each do |i|
  59. if i[:name] == 'eth4'
  60. i[:addr].must_equal('192.168.1.121')
  61. end
  62. end
  63. end
  64. it "should not flip out about multiple facts" do
  65. @system.facts["net.interface.eth4.ipv4_address"] = '192.168.1.121'
  66. @system.facts["net.interface.eth4.ipv4_address"] = '192.168.1.125'
  67. @system.facts["net.interface.eth4.ipv4_address"] = '192.168.1.123'
  68. @system.facts["net.interface.eth4.ipv4_address"] = '192.168.1.122'
  69. @system.interfaces.size.must_equal(4)
  70. end
  71. end
  72. end
  73. end