Skip to content

Commit

Permalink
Try diff route
Browse files Browse the repository at this point in the history
  • Loading branch information
hgreebe committed Aug 26, 2024
1 parent 1de4321 commit 0bc7618
Showing 1 changed file with 89 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,54 +80,78 @@ def self.configure(chef_run)
end
end

describe 'enroot:setup' do
# describe 'enroot:setup' do
# for_all_oses do |platform, version|
# context "on #{platform}#{version} when enroot not enabled" do
# cached(:chef_run) do
# stubs_for_resource('enroot') do |res|
# allow(res).to receive(:nvidia_enabled?).and_return(false)
# end
# runner = runner(platform: platform, version: version, step_into: ['enroot'])
# ConvergeEnroot.setup(runner)
# end
#
# it 'does not install enroot' do
# is_expected.not_to run_bash('Install enroot')
# end
# end
#
# context "on #{platform}#{version} when enroot enabled" do
# cached(:sources_dir) { 'sources_dir' }
# cached(:package_version) { '3.4.1' }
# cached(:arch_suffix) { 'enroot_arch' }
# cached(:enroot_url) do
# case platform
# when 'ubuntu'
# "https://github.com/NVIDIA/enroot/releases/download/v#{package_version}/enroot_#{package_version}-1_#{arch_suffix}.deb"
# else
# "https://github.com/NVIDIA/enroot/releases/download/v#{package_version}/enroot-#{package_version}-1.el8.#{arch_suffix}.rpm"
# end
# end
# cached(:chef_run) do
# stubs_for_resource('enroot') do |res|
# allow(res).to receive(:nvidia_enabled?).and_return(true)
# allow(res).to receive(:arch_suffix).and_return(arch_suffix)
# end
# runner = runner(platform: platform, version: version, step_into: ['enroot']) do |node|
# node.override['cluster']['sources_dir'] = sources_dir
# end
# ConvergeEnroot.setup(runner)
# end
#
# cached(:node) { chef_run.node }
#
# it 'sets up enroot' do
# is_expected.to setup_enroot('setup')
# end
#
#
# it 'installs enroot' do
# is_expected.to run_bash('Install enroot')
# .with(retries: 3)
# .with(retry_delay: 5)
# .with(user: 'root')
# end
# end
# end
# end

describe 'enroot:configure' do
for_all_oses do |platform, version|
context "on #{platform}#{version} when enroot not enabled" do
context "on #{platform}#{version} when enroot has been installed" do
cached(:chef_run) do
stubs_for_resource('enroot') do |res|
allow(res).to receive(:nvidia_enabled?).and_return(false)
end
allow_any_instance_of(Object).to receive(:enroot_installed?).and_return(true)
runner = runner(platform: platform, version: version, step_into: ['enroot'])
ConvergeEnroot.setup(runner)
end

it 'does not install enroot' do
is_expected.not_to run_bash('Install enroot')
end
end

context "on #{platform}#{version} when enroot enabled" do
cached(:sources_dir) { 'sources_dir' }
cached(:package_version) { '3.4.1' }
cached(:arch_suffix) { 'enroot_arch' }
cached(:enroot_url) do
case platform
when 'ubuntu'
"https://github.com/NVIDIA/enroot/releases/download/v#{package_version}/enroot_#{package_version}-1_#{arch_suffix}.deb"
else
"https://github.com/NVIDIA/enroot/releases/download/v#{package_version}/enroot-#{package_version}-1.el8.#{arch_suffix}.rpm"
end
end
cached(:chef_run) do
stubs_for_resource('enroot') do |res|
allow(res).to receive(:nvidia_enabled?).and_return(true)
allow(res).to receive(:arch_suffix).and_return(arch_suffix)
end
runner = runner(platform: platform, version: version, step_into: ['enroot']) do |node|
node.override['cluster']['sources_dir'] = sources_dir
end
ConvergeEnroot.setup(runner)
ConvergeEnroot.configure(runner)
end

cached(:node) { chef_run.node }

it 'sets up enroot' do
is_expected.to setup_enroot('setup')
it 'configures enroot' do
is_expected.to configure_enroot('configure')
end


it 'installs enroot' do
is_expected.to run_bash('Install enroot')
it 'run configure enroot script' do
is_expected.to run_bash('Configure enroot')
.with(retries: 3)
.with(retry_delay: 5)
.with(user: 'root')
Expand All @@ -136,26 +160,36 @@ def self.configure(chef_run)
end
end

describe 'enroot:configure' do
describe 'enroot:setup' do
for_all_oses do |platform, version|
context "on #{platform}#{version} when enroot has been installed" do
cached(:chef_run) do
allow_any_instance_of(Object).to receive(:enroot_installed?).and_return(true)
runner = runner(platform: platform, version: version, step_into: ['enroot'])
ConvergeEnroot.configure(runner)
context "on #{platform}#{version}" do
context "when enroot is not supported" do
cached(:chef_run) do
allow_any_instance_of(Object).to receive(:nvidia_enabled?).and_return(false)
runner = runner(platform: platform, version: version, step_into: ['enroot'])
ConvergeEnroot.setup(runner)
end

it "doesn't set up enroot" do
is_expected.not_to run_bash("Install enroot")
end
end

cached(:node) { chef_run.node }
# not_if { ::File.exist?("/opt/arm/armpl/#{armpl_version}") }
context "when enroot is supported" do
cached(:chef_run) do
runner = runner(platform: platform, version: version, step_into: ['enroot'])
allow_any_instance_of(Object).to receive(:enroot_installed?).and_return(true)
ConvergeEnroot.setup(runner)
end
cached(:node) { chef_run.node }

it 'sets up enroot' do
is_expected.to setup_enroot('setup')
is_expected.to run_bash("Install enroot")
end

it 'configures enroot' do
is_expected.to configure_enroot('configure')
end

it 'run configure enroot script' do
is_expected.to run_bash('Configure enroot')
.with(retries: 3)
.with(retry_delay: 5)
.with(user: 'root')
end
end
end
Expand Down

0 comments on commit 0bc7618

Please sign in to comment.