spec/unit/plugins/linux/platform_spec.rb in ohai-14.2.0 vs spec/unit/plugins/linux/platform_spec.rb in ohai-14.3.0
- old
+ new
@@ -179,20 +179,20 @@
context "on cumulus" do
let(:have_cumulus_dir) { true }
let(:cumulus_release_content) do
- <<-OS_RELEASE
-NAME="Cumulus Linux"
-VERSION_ID=3.1.2
-VERSION="Cumulus Linux 3.1.2"
-PRETTY_NAME="Cumulus Linux"
-ID=cumulus-linux
-ID_LIKE=debian
-CPE_NAME=cpe:/o:cumulusnetworks:cumulus_linux:3.1.2
-HOME_URL="http://www.cumulusnetworks.com/"
-SUPPORT_URL="http://support.cumulusnetworks.com/"
+ <<~OS_RELEASE
+ NAME="Cumulus Linux"
+ VERSION_ID=3.1.2
+ VERSION="Cumulus Linux 3.1.2"
+ PRETTY_NAME="Cumulus Linux"
+ ID=cumulus-linux
+ ID_LIKE=debian
+ CPE_NAME=cpe:/o:cumulusnetworks:cumulus_linux:3.1.2
+ HOME_URL="http://www.cumulusnetworks.com/"
+ SUPPORT_URL="http://support.cumulusnetworks.com/"
OS_RELEASE
end
before(:each) do
@@ -456,28 +456,44 @@
expect(@plugin[:platform]).to eq("clearos")
expect(@plugin[:platform_family]).to eq("rhel")
expect(@plugin[:platform_version].to_f).to eq(7.3)
end
+ it "should read the platform as amazon and version as 2 on the RC release" do
+ expect(File).to receive(:read).with("/etc/redhat-release").and_return("Amazon Linux release 2 (2017.12) LTS Release Candidate")
+ @plugin.run
+ expect(@plugin[:platform]).to eq("amazon")
+ expect(@plugin[:platform_family]).to eq("amazon")
+ expect(@plugin[:platform_version].to_f).to eq(2)
+ end
+
+ it "should read the platform as amazon and version as 2 on the final release" do
+ expect(File).to receive(:read).with("/etc/redhat-release").and_return("Amazon Linux 2")
+ @plugin.run
+ expect(@plugin[:platform]).to eq("amazon")
+ expect(@plugin[:platform_family]).to eq("amazon")
+ expect(@plugin[:platform_version].to_f).to eq(2)
+ end
+
# https://github.com/chef/ohai/issues/560
# Issue is seen on EL7, so that's what we're testing.
context "on versions that have /etc/os-release" do
let(:have_os_release) { true }
let(:os_release_content) do
- <<-OS_RELEASE
-NAME="CentOS Linux"
-VERSION="7 (Core)"
-ID="centos"
-ID_LIKE="rhel fedora"
-VERSION_ID="7"
-PRETTY_NAME="CentOS Linux 7 (Core)"
-ANSI_COLOR="0;31"
-CPE_NAME="cpe:/o:centos:centos:7"
-HOME_URL="https://www.centos.org/"
-BUG_REPORT_URL="https://bugs.centos.org/"
+ <<~OS_RELEASE
+ NAME="CentOS Linux"
+ VERSION="7 (Core)"
+ ID="centos"
+ ID_LIKE="rhel fedora"
+ VERSION_ID="7"
+ PRETTY_NAME="CentOS Linux 7 (Core)"
+ ANSI_COLOR="0;31"
+ CPE_NAME="cpe:/o:centos:centos:7"
+ HOME_URL="https://www.centos.org/"
+ BUG_REPORT_URL="https://bugs.centos.org/"
OS_RELEASE
end
before do
@@ -496,44 +512,44 @@
context "on 'guestshell' with /etc/os-release and overrides for Cisco Nexus" do
let(:have_os_release) { true }
let(:os_release_content) do
- <<-OS_RELEASE
-NAME="CentOS Linux"
-VERSION="7 (Core)"
-ID="centos"
-ID_LIKE="rhel fedora"
-VERSION_ID="7"
-PRETTY_NAME="CentOS Linux 7 (Core)"
-ANSI_COLOR="0;31"
-CPE_NAME="cpe:/o:centos:centos:7"
-HOME_URL="https://www.centos.org/"
-BUG_REPORT_URL="https://bugs.centos.org/"
+ <<~OS_RELEASE
+ NAME="CentOS Linux"
+ VERSION="7 (Core)"
+ ID="centos"
+ ID_LIKE="rhel fedora"
+ VERSION_ID="7"
+ PRETTY_NAME="CentOS Linux 7 (Core)"
+ ANSI_COLOR="0;31"
+ CPE_NAME="cpe:/o:centos:centos:7"
+ HOME_URL="https://www.centos.org/"
+ BUG_REPORT_URL="https://bugs.centos.org/"
-CENTOS_MANTISBT_PROJECT="CentOS-7"
-CENTOS_MANTISBT_PROJECT_VERSION="7"
-REDHAT_SUPPORT_PRODUCT="centos"
-REDHAT_SUPPORT_PRODUCT_VERSION="7"
+ CENTOS_MANTISBT_PROJECT="CentOS-7"
+ CENTOS_MANTISBT_PROJECT_VERSION="7"
+ REDHAT_SUPPORT_PRODUCT="centos"
+ REDHAT_SUPPORT_PRODUCT_VERSION="7"
-CISCO_RELEASE_INFO=/etc/shared/os-release
+ CISCO_RELEASE_INFO=/etc/shared/os-release
OS_RELEASE
end
let(:have_cisco_release) { true }
let(:cisco_release_content) do
- <<-CISCO_RELEASE
-ID=nexus
-ID_LIKE=wrlinux
-NAME=Nexus
-VERSION="7.0(3)I2(0.475E.6)"
-VERSION_ID="7.0(3)I2"
-PRETTY_NAME="Nexus 7.0(3)I2"
-HOME_URL=http://www.cisco.com
-BUILD_ID=6
-CISCO_RELEASE_INFO=/etc/os-release
+ <<~CISCO_RELEASE
+ ID=nexus
+ ID_LIKE=wrlinux
+ NAME=Nexus
+ VERSION="7.0(3)I2(0.475E.6)"
+ VERSION_ID="7.0(3)I2"
+ PRETTY_NAME="Nexus 7.0(3)I2"
+ HOME_URL=http://www.cisco.com
+ BUILD_ID=6
+ CISCO_RELEASE_INFO=/etc/os-release
CISCO_RELEASE
end
before do
expect(File).to receive(:read).at_least(:once).with("/etc/os-release").and_return(os_release_content)
@@ -690,18 +706,18 @@
let(:have_suse_release) { false }
let(:have_os_release) { true }
let(:os_release_content) do
- <<-OS_RELEASE
-VERSION="15"
-VERSION_ID="15"
-PRETTY_NAME="SUSE Linux Enterprise Server 15"
-ID="sles"
-ID_LIKE="suse"
-ANSI_COLOR="0;32"
-CPE_NAME="cpe:/o:suse:sles:15"
+ <<~OS_RELEASE
+ VERSION="15"
+ VERSION_ID="15"
+ PRETTY_NAME="SUSE Linux Enterprise Server 15"
+ ID="sles"
+ ID_LIKE="suse"
+ ANSI_COLOR="0;32"
+ CPE_NAME="cpe:/o:suse:sles:15"
OS_RELEASE
end
before do
@@ -943,20 +959,20 @@
end
describe "on clearlinux" do
let(:have_usr_lib_os_release) { true }
let(:usr_lib_os_release_content) do
- <<-CLEARLINUX_RELEASE
-NAME="Clear Linux Software for Intel Architecture"
-VERSION=1
-ID=clear-linux-os
-VERSION_ID=16140
-PRETTY_NAME="Clear Linux OS for Intel Architecture"
-ANSI_COLOR="1;35"
-HOME_URL="https://clearlinux.org"
-SUPPORT_URL="https://clearlinux.org"
-BUG_REPORT_URL="mailto:dev@lists.clearlinux.org"
-PRIVACY_POLICY_URL="http://www.intel.com/privacy"
+ <<~CLEARLINUX_RELEASE
+ NAME="Clear Linux Software for Intel Architecture"
+ VERSION=1
+ ID=clear-linux-os
+ VERSION_ID=16140
+ PRETTY_NAME="Clear Linux OS for Intel Architecture"
+ ANSI_COLOR="1;35"
+ HOME_URL="https://clearlinux.org"
+ SUPPORT_URL="https://clearlinux.org"
+ BUG_REPORT_URL="mailto:dev@lists.clearlinux.org"
+ PRIVACY_POLICY_URL="http://www.intel.com/privacy"
CLEARLINUX_RELEASE
end
before do
expect(File).to receive(:read).with("/usr/lib/os-release").and_return(usr_lib_os_release_content)