From c4b6f609328e8becb4460a2b0b6c60a15d9c45dd Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Mon, 3 Jun 2024 15:30:39 -0700 Subject: [PATCH] Add Amazon 2 Copies Amazon 7 to 2, as the former is an implementation detail and the latter is the actual OS version: https://aws.amazon.com/amazon-linux-2 --- lib/beaker/host/unix/pkg.rb | 4 ++-- spec/beaker/host/unix/pkg_spec.rb | 12 ++++++++++-- spec/helpers.rb | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/beaker/host/unix/pkg.rb b/lib/beaker/host/unix/pkg.rb index 3b10728f9..a41605ed5 100644 --- a/lib/beaker/host/unix/pkg.rb +++ b/lib/beaker/host/unix/pkg.rb @@ -85,7 +85,7 @@ def install_package(name, cmdline_args = '', version = nil, opts = {}) when /amazon-2023|el-(8|9|1[0-9])|fedora/ name = "#{name}-#{version}" if version execute("dnf -y #{cmdline_args} install #{name}", opts) - when /amazon-7|centos|redhat|el-[1-7]-/ + when /amazon-(2|7)|centos|redhat|el-[1-7]-/ name = "#{name}-#{version}" if version execute("yum -y #{cmdline_args} install #{name}", opts) when /ubuntu|debian/ @@ -167,7 +167,7 @@ def uninstall_package(name, cmdline_args = '', opts = {}) execute("zypper --non-interactive rm #{name}", opts) when /amazon-2023|el-(8|9|1[0-9])|fedora/ execute("dnf -y #{cmdline_args} remove #{name}", opts) - when /amazon-7|centos|redhat|el-[1-7]-/ + when /amazon-(2|7)|centos|redhat|el-[1-7]-/ execute("yum -y #{cmdline_args} remove #{name}", opts) when /ubuntu|debian/ execute("apt-get purge #{cmdline_args} -y #{name}", opts) diff --git a/spec/beaker/host/unix/pkg_spec.rb b/spec/beaker/host/unix/pkg_spec.rb index 7a05a1a12..c20c8069a 100644 --- a/spec/beaker/host/unix/pkg_spec.rb +++ b/spec/beaker/host/unix/pkg_spec.rb @@ -161,7 +161,7 @@ def exec expect(instance.install_package(pkg)).to eq "hello" end - it "uses yum on amazon linux 2" do + it "uses yum on misnamed amazon linux 7" do @opts = { 'platform' => "amazon-7-is-me" } pkg = 'amazon_package' expect(Beaker::Command).to receive(:new).with("yum -y install #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('') @@ -169,6 +169,14 @@ def exec expect(instance.install_package(pkg)).to eq "hello" end + it "uses yum on amazon linux 2" do + @opts = { 'platform' => "amazon-2-is-me" } + pkg = 'amazon_package' + expect(Beaker::Command).to receive(:new).with("yum -y install #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('') + expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 })) + expect(instance.install_package(pkg)).to eq "hello" + end + it "uses pacman on archlinux" do @opts = { 'platform' => 'archlinux-is-me' } pkg = 'archlinux_package' @@ -281,7 +289,7 @@ def exec it 'Amazon Linux 2 uses yum' do @platform = platform - @version = '7' + @version = '2' package_file = 'test_123.yay' expect(instance).to receive(:execute).with(/^yum.*#{package_file}$/) instance.install_local_package(package_file) diff --git a/spec/helpers.rb b/spec/helpers.rb index b6d918582..af4b33cdc 100644 --- a/spec/helpers.rb +++ b/spec/helpers.rb @@ -124,6 +124,7 @@ module PlatformHelpers REDHATPLATFORMS = %w[ amazon-2023 + amazon-2 fedora el- centos