Skip to content

Commit

Permalink
Merge pull request #1835 from mhashizume/rhel-dnf
Browse files Browse the repository at this point in the history
Use DNF for Fedora, newer Enterprise Linux
  • Loading branch information
bastelfreak authored Nov 23, 2023
2 parents b637031 + 62bb5aa commit c70832d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 40 deletions.
8 changes: 4 additions & 4 deletions lib/beaker/host/unix/pkg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ def install_package(name, cmdline_args = '', version = nil, opts = {})
execute("zypper --non-interactive --gpg-auto-import-keys in #{name}", opts)
when /el-4/
@logger.debug("Package installation not supported on rhel4")
when /amazon-2023|fedora-(2[2-9]|3[0-9])/
when /amazon-2023|el-(8|9|1[0-9])|fedora/
name = "#{name}-#{version}" if version
execute("dnf -y #{cmdline_args} install #{name}", opts)
when /cisco|fedora|centos|redhat|eos|el-/
when /cisco|centos|redhat|eos|el-[1-7]-/
name = "#{name}-#{version}" if version
execute("yum -y #{cmdline_args} install #{name}", opts)
when /ubuntu|debian|cumulus|huaweios/
Expand Down Expand Up @@ -172,9 +172,9 @@ def uninstall_package(name, cmdline_args = '', opts = {})
execute("zypper --non-interactive rm #{name}", opts)
when /el-4/
@logger.debug("Package uninstallation not supported on rhel4")
when /amazon-2023|fedora-(2[2-9]|3[0-9])/
when /amazon-2023|el-(8|9|1[0-9])|fedora/
execute("dnf -y #{cmdline_args} remove #{name}", opts)
when /cisco|fedora|centos|redhat|eos|el-/
when /cisco|centos|redhat|eos|el-[1-7]-/
execute("yum -y #{cmdline_args} remove #{name}", opts)
when /ubuntu|debian|cumulus|huaweios/
execute("apt-get purge #{cmdline_args} -y #{name}", opts)
Expand Down
48 changes: 12 additions & 36 deletions spec/beaker/host/unix/pkg_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,24 +175,12 @@ def exec
end
end

(1..21).to_a.each do |fedora_release|
it "uses yum on fedora-#{fedora_release}" do
@opts = { 'platform' => "fedora-#{fedora_release}-is-me" }
pkg = 'fedora_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 be == "hello"
end
end

(22..39).to_a.each do |fedora_release|
it "uses dnf on fedora-#{fedora_release}" do
@opts = { 'platform' => "fedora-#{fedora_release}-is-me" }
pkg = 'fedora_package'
expect(Beaker::Command).to receive(:new).with("dnf -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 be == "hello"
end
it "uses dnf on fedora" do
@opts = { 'platform' => "fedora-is-me" }
pkg = 'fedora_package'
expect(Beaker::Command).to receive(:new).with("dnf -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 be == "hello"
end

it "uses dnf on amazon-2023" do
Expand Down Expand Up @@ -221,24 +209,12 @@ def exec
expect(instance.uninstall_package('pkg')).to be == "hello"
end

(1..21).to_a.each do |fedora_release|
it "uses yum on fedora-#{fedora_release}" do
@opts = { 'platform' => "fedora-#{fedora_release}-is-me" }
pkg = 'fedora_package'
expect(Beaker::Command).to receive(:new).with("yum -y remove #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
expect(instance.uninstall_package(pkg)).to be == "hello"
end
end

(22..39).to_a.each do |fedora_release|
it "uses dnf on fedora-#{fedora_release}" do
@opts = { 'platform' => "fedora-#{fedora_release}-is-me" }
pkg = 'fedora_package'
expect(Beaker::Command).to receive(:new).with("dnf -y remove #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
expect(instance.uninstall_package(pkg)).to be == "hello"
end
it "uses dnf on fedora" do
@opts = { 'platform' => "fedora-is-me" }
pkg = 'fedora_package'
expect(Beaker::Command).to receive(:new).with("dnf -y remove #{pkg}", [], { :prepend_cmds => nil, :cmdexe => false }).and_return('')
expect(instance).to receive(:exec).with('', {}).and_return(generate_result("hello", { :exit_code => 0 }))
expect(instance.uninstall_package(pkg)).to be == "hello"
end
end
end
Expand Down

0 comments on commit c70832d

Please sign in to comment.