Sha256: e6d207b04b53da6b4b3249f9987d9bcd4509d40b86dd8a4849caafc576171a07

Contents?: true

Size: 1.83 KB

Versions: 16

Compression:

Stored size: 1.83 KB

Contents

test_name 'C93827: facter fqdn should return the hostname when its a fully qualified domain name' do
  tag 'risk:high'
  require 'timeout'

  confine :except, :platform => 'windows'

  fqdn = 'foo.bar.example.org'
  fqdn_long = 'a23456789.b23456789.c23456789.d23456789.e23456789.f23456789.wxyz'

  agents.each do |agent|
    orig_hostname = on(agent, 'hostname').stdout.chomp

    teardown do
      step 'restore original hostname' do
        on(agent, "hostname #{orig_hostname}")
      end
    end

    step "set hostname as #{fqdn}" do
      on(agent, "hostname #{fqdn}")
      begin
        Timeout.timeout(20) do
          until on(agent, 'hostname').stdout =~ /#{fqdn}/
            sleep(0.25) # on Solaris 11 hostname returns before the hostname is updated
          end
        end
      rescue Timeout::Error
        raise "Failed to reset the hostname of the test machine to #{fqdn}"
      end
    end

    step 'validate facter uses hostname as the fqdn if its a fully qualified domain name' do
      on(agent, 'facter fqdn') do |facter_output|
        assert_equal(fqdn, facter_output.stdout.chomp, 'facter did not return the hostname set by the test')
      end
    end
  end

  step "long hostname as #{fqdn_long}" do
    on(agent, "hostname #{fqdn_long}")
    begin
      Timeout.timeout(20) do
        until on(agent, 'hostname').stdout =~ /#{fqdn_long}/
          sleep(0.25) # on Solaris 11 hostname returns before the hostname is updated
        end
      end
    rescue Timeout::Error
      raise "Failed to reset the hostname of the test machine to #{fqdn_long}"
    end
  end

  step 'validate facter uses hostname as the LONG fqdn if its a fully qualified domain name' do
    on(agent, 'facter fqdn') do |facter_output|
      assert_equal(fqdn_long, facter_output.stdout.chomp, 'facter did not return the hostname set by the test')
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
facter-4.0.29 acceptance/tests/ticket_1238_hostname_fqdn.rb
facter-4.0.28 acceptance/tests/ticket_1238_hostname_fqdn.rb
facter-3.12.2.cfacter.20181217 ext/facter/facter/acceptance/tests/ticket_1238_hostname_fqdn.rb
facter-3.12.1.cfacter.20181031 ext/facter/facter/acceptance/tests/ticket_1238_hostname_fqdn.rb
facter-3.11.6.cfacter.20181031 ext/facter/facter/acceptance/tests/ticket_1238_hostname_fqdn.rb
facter-3.12.1.cfacter.20181023 ext/facter/facter/acceptance/tests/ticket_1238_hostname_fqdn.rb
facter-3.11.5.cfacter.20181022 ext/facter/facter/acceptance/tests/ticket_1238_hostname_fqdn.rb
facter-3.12.0.cfacter.20181004 ext/facter/facter/acceptance/tests/ticket_1238_hostname_fqdn.rb
facter-3.12.0.cfacter.20181001 ext/facter/facter/acceptance/tests/ticket_1238_hostname_fqdn.rb
facter-3.12.0.cfacter.20180918 ext/facter/facter/acceptance/tests/ticket_1238_hostname_fqdn.rb
facter-3.11.4.cfacter.20180821 ext/facter/facter/acceptance/tests/ticket_1238_hostname_fqdn.rb
facter-3.11.3.cfacter.20180716 ext/facter/facter/acceptance/tests/ticket_1238_hostname_fqdn.rb
facter-3.11.2.cfacter.20180612 ext/facter/facter/acceptance/tests/ticket_1238_hostname_fqdn.rb
facter-3.11.2.cfacter.20180606 ext/facter/facter/acceptance/tests/ticket_1238_hostname_fqdn.rb
facter-3.11.0.cfacter.20180319 ext/facter/facter/acceptance/tests/ticket_1238_hostname_fqdn.rb
cfacter-3.11.0.rc.20180314 ext/facter/facter/acceptance/tests/ticket_1238_hostname_fqdn.rb