Skip to content

Commit

Permalink
Add unit test for find_kernel_patch_version
Browse files Browse the repository at this point in the history
To load the Lustre resource and the functions defined on it,
we are using the `nothing` action.

This mechanism was already used to test for example:
- get_uuid on manage_ebs.rb
- dcv_supported? on dcv.rb

Signed-off-by: Enrico Usai <[email protected]>
  • Loading branch information
enrico-usai committed Nov 27, 2023
1 parent d5e5f9b commit 5ff8e1f
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ def self.setup(chef_run)
end
end
end

def self.nothing(chef_run)
chef_run.converge_dsl('aws-parallelcluster-environment') do
# This is a way to load the resource code and unit test function defined on it
lustre 'nothing' do
action :nothing
end
end
end
end

describe 'lustre:setup' do
Expand Down Expand Up @@ -263,6 +272,25 @@ def self.setup(chef_run)
end
end

describe 'lustre:find_kernel_patch_version' do
[%w(3.10.0-1127.8.2.el7.x86_64 1127), %w(4.18.0-477.13.1.el8_7.x86_64 477)].each do |kernel_version, expected_patch_version|
context "parsing #{kernel_version}" do
cached(:chef_run) do
runner = runner(platform: 'centos', version: '7', step_into: ['lustre']) do |node|
node.override['cluster']['kernel_release'] = kernel_version
end
Lustre.nothing(runner)
end
# Mechanism to retrieve resource and then unit test find_kernel_patch_version function
cached(:resource) { chef_run.find_resource('lustre', 'nothing') }

it "should retrieve #{expected_patch_version} patch version" do
expect(resource.find_kernel_patch_version).to eq(expected_patch_version)
end
end
end
end

describe 'lustre:find_centos_minor_version' do
context "centos version is not 7" do
cached(:chef_run) do
Expand Down

0 comments on commit 5ff8e1f

Please sign in to comment.