Skip to content

Commit

Permalink
[fix]Add mock munge key logic in compute setup recipe during kitchen …
Browse files Browse the repository at this point in the history
…tests

Fix Kitchen tests on compute nodes caused by not existed Munge Key

Change the mocked munge key content to a correct binary as we do in the config and update logic
  • Loading branch information
hehe7318 authored Oct 12, 2023
1 parent 02fa532 commit 3f6c7e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions cookbooks/aws-parallelcluster-slurm/libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ def setup_munge_key(shared_dir)
end

def setup_munge_compute_node
if kitchen_test?
# FIXME: Mock munge key in shared directory.
include_recipe 'aws-parallelcluster-slurm::mock_munge_key'
end
setup_munge_key(node['cluster']['shared_dir'])
enable_munge_service
end
Expand Down
15 changes: 11 additions & 4 deletions cookbooks/aws-parallelcluster-slurm/recipes/test/mock_munge_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@
mode '0700'
end

file "#{munge_dir}/.munge.key" do
content 'munge-key'
owner node['cluster']['munge']['user']
group node['cluster']['munge']['group']
bash "mock_munge_key" do
user 'root'
group 'root'
code <<-MOCK_KEY
set -e
munge_directory=#{munge_dir}
encoded_key='lWXJDxgGhJxIVqLdbaycUICm12u0gHtcDFslGGxJlyLoVIQJFuskDfkK8wjvQfhT5pkeyuxA+vjgg9R+E+ftPVTsVLHaf4bx3RmEfe30bZo79Yg+GhTRJRzV401/VaTlVEGFwMcJhmVKrXX/MbfnIdMwWNgCL8swUELbFOI4CG0='
decoded_key=$(echo $encoded_key | base64 -d)
echo "${decoded_key}" > ${munge_directory}/.munge.key
chmod 0600 ${munge_directory}/.munge.key
MOCK_KEY
end
end

0 comments on commit 3f6c7e6

Please sign in to comment.