-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
250 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
171 changes: 171 additions & 0 deletions
171
cookbooks/aws-parallelcluster-platform/spec/unit/resources/enroot_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
require 'spec_helper' | ||
|
||
package_version = '3.4.1' | ||
class ConvergeEnroot | ||
def self.setup(chef_run) | ||
chef_run.converge_dsl('aws-parallelcluster-platform') do | ||
enroot 'setup' do | ||
action :setup | ||
end | ||
end | ||
end | ||
|
||
def self.configure(chef_run) | ||
chef_run.converge_dsl('aws-parallelcluster-platform') do | ||
enroot 'configure' do | ||
action :configure | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe 'enroot:package_version' do | ||
for_all_oses do |platform, version| | ||
context "on #{platform}#{version}" 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 | ||
cached(:resource) do | ||
chef_run.find_resource('enroot', 'setup') | ||
end | ||
|
||
it 'returns the expected enroot version' do | ||
expected_enroot_version = "3.4.1" | ||
expect(resource.package_version).to eq(expected_enroot_version) | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe 'enroot:arch_suffix' do | ||
for_all_oses do |platform, version| | ||
context "on #{platform}#{version} - arm" 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 | ||
cached(:resource) do | ||
chef_run.find_resource('enroot', 'setup') | ||
end | ||
|
||
context 'on arm instance' do | ||
cached(:expected_arch) do | ||
case platform | ||
when 'amazon', 'redhat', 'rocky' | ||
'aarch64' | ||
else | ||
'arm64' | ||
end | ||
end | ||
|
||
it 'returns arch value for arm architecture' do | ||
allow_any_instance_of(Object).to receive(:arm_instance?).and_return(true) | ||
expect(resource.arch_suffix).to eq(expected_arch) | ||
end | ||
end | ||
|
||
context 'not on arm instance' do | ||
cached(:expected_arch) do | ||
platform == 'ubuntu' ? 'amd64' : 'x86_64' | ||
end | ||
|
||
it 'returns arch value for arm architecture' do | ||
allow_any_instance_of(Object).to receive(:arm_instance?).and_return(false) | ||
expect(resource.arch_suffix).to eq(expected_arch) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe 'enroot:setup' do | ||
for_all_oses do |platform, version| | ||
context "on #{platform}#{version}" do | ||
let(:chef_run) do | ||
runner(platform: platform, version: version, step_into: ['enroot']) do |node| | ||
node.override['cluster']['enroot']['version'] = package_version | ||
end | ||
end | ||
|
||
context 'when nvidia is enabled' do | ||
before do | ||
stubs_for_provider('enroot') do |resource| | ||
allow(resource).to receive(:nvidia_enabled?).and_return(true) | ||
end | ||
end | ||
|
||
context 'and enroot is installed' do | ||
before do | ||
ConvergeEnroot.setup(chef_run) | ||
end | ||
|
||
it 'installs Enroot' do | ||
is_expected.to run_bash('Install enroot') | ||
end | ||
end | ||
end | ||
|
||
context 'when nvidia is not enabled' do | ||
before do | ||
stubs_for_provider('enroot') do |resource| | ||
allow(resource).to receive(:nvidia_enabled?).and_return(false) | ||
end | ||
end | ||
|
||
context 'and enroot is installed' do | ||
before do | ||
ConvergeEnroot.setup(chef_run) | ||
end | ||
|
||
it 'does not install Enroot' do | ||
is_expected.not_to run_bash('Install enroot') | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe 'enroot:configure' do | ||
for_all_oses do |platform, version| | ||
context "on #{platform}#{version}" do | ||
let(:chef_run) do | ||
runner(platform: platform, version: version, step_into: ['enroot']) | ||
end | ||
|
||
context 'when enroot is installed' do | ||
before do | ||
stubs_for_provider('enroot') do |resource| | ||
allow(resource).to receive(:enroot_installed).and_return(true) | ||
end | ||
ConvergeEnroot.configure(chef_run) | ||
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 | ||
|
||
context 'when enroot is not installed' do | ||
before do | ||
stubs_for_provider('enroot') do |resource| | ||
allow(resource).to receive(:enroot_installed).and_return(false) | ||
end | ||
ConvergeEnroot.configure(chef_run) | ||
end | ||
|
||
it 'does not run configure enroot script' do | ||
is_expected.not_to run_bash('Configure enroot') | ||
.with(retries: 3) | ||
.with(retry_delay: 5) | ||
.with(user: 'root') | ||
end | ||
end | ||
end | ||
end | ||
end |
47 changes: 47 additions & 0 deletions
47
cookbooks/aws-parallelcluster-platform/test/controls/enroot_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright:: 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). | ||
# You may not use this file except in compliance with the License. A copy of the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "LICENSE.txt" file accompanying this file. | ||
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied. | ||
# See the License for the specific language governing permissions and limitations under the License. | ||
|
||
control 'tag:install_expected_version_of_enroot_installed' do | ||
only_if { !os_properties.on_docker? && ['yes', true].include?(node['cluster']['nvidia']['enabled']) } | ||
|
||
expected_enroot_version = node['cluster']['enroot']['version'] | ||
|
||
describe "gdrcopy version is expected to be #{expected_enroot_version}" do | ||
subject { command('enroot version').stdout.strip() } | ||
it { should eq expected_enroot_version } | ||
end | ||
end | ||
|
||
control 'tag:config_enroot_enabled_on_graphic_instances' do | ||
only_if { !os_properties.on_docker? && ['yes', true].include?(node['cluster']['nvidia']['enabled']) } | ||
|
||
describe directory('/usr/bin/enroot') do | ||
it { should exist } | ||
its('owner') { should eq 'root' } | ||
its('group') { should eq 'root' } | ||
end | ||
|
||
describe file("/opt/parallelcluster/shared/enroot") do | ||
it { should exist } | ||
its('mode') { should cmp '1777' } | ||
its('owner') { should eq 'root' } | ||
its('group') { should eq 'root' } | ||
end unless os_properties.redhat_on_docker? | ||
end | ||
|
||
control 'tag:config_enroot_disabled_on_non_graphic_instances' do | ||
only_if { !os_properties.on_docker? && !['yes', true].include?(node['cluster']['nvidia']['enabled']) } | ||
|
||
describe 'enroot service should be disabled' do | ||
subject { command("enroot version") } | ||
its('exit_status') { should eq 127 } | ||
end | ||
end |
21 changes: 21 additions & 0 deletions
21
cookbooks/aws-parallelcluster-slurm/test/controls/pyxis_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright:: 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). | ||
# You may not use this file except in compliance with the License. A copy of the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "LICENSE.txt" file accompanying this file. | ||
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied. | ||
# See the License for the specific language governing permissions and limitations under the License. | ||
|
||
control 'tag:install_pyxis_installed' do | ||
title 'Checks Pyxis has been installed' | ||
|
||
describe file("/opt/slurm/etc/plugstack.conf.d/pyxis.conf") do | ||
it { should exist } | ||
its('mode') { should cmp '0755' } | ||
its('owner') { should eq 'root' } | ||
its('group') { should eq 'root' } | ||
end unless os_properties.redhat_on_docker? | ||
end |