Skip to content

Commit 4f18801

Browse files
committed
[Test] Add spec test to cover libjwt installation.
Signed-off-by: Giacomo Marciani <[email protected]>
1 parent 0cfb8e1 commit 4f18801

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# frozen_string_literal: true
2+
3+
# Copyright:: 2024 Amazon.com, Inc. and its affiliates. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the
6+
# License. A copy of the License is located at
7+
#
8+
# http://aws.amazon.com/apache2.0/
9+
#
10+
# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
11+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
require 'spec_helper'
15+
16+
describe 'aws-parallelcluster-slurm::install_jwt' do
17+
for_all_oses do |platform, version|
18+
context "on #{platform}#{version}" do
19+
cached(:cluster_artifacts_s3_url) { 'https://REGION-aws-parallelcluster.s3.REGION.AWS_DOMAIN' }
20+
cached(:cluster_sources_dir) { '/path/to/cluster/sources/dir' }
21+
cached(:jwt_version) { '1.17.0' }
22+
cached(:jwt_checksum) { '617778f9687682220abf9b7daacbe72bab7c2985479f8bee4db9648bd2440687' }
23+
24+
cached(:chef_run) do
25+
runner = runner(platform: platform, version: version) do |node|
26+
RSpec::Mocks.configuration.allow_message_expectations_on_nil = true
27+
28+
node.override['cluster']['artifacts_s3_url'] = cluster_artifacts_s3_url
29+
node.override['cluster']['sources_dir'] = cluster_sources_dir
30+
end
31+
allow_any_instance_of(Object).to receive(:nvidia_enabled?).and_return(true)
32+
runner.converge(described_recipe)
33+
end
34+
35+
it 'downloads libjwt' do
36+
is_expected.to create_if_missing_remote_file("#{cluster_sources_dir}/libjwt-#{jwt_version}.tar.gz").with(
37+
source: "#{cluster_artifacts_s3_url}/dependencies/jwt/v#{jwt_version}.tar.gz",
38+
mode: '0644',
39+
retries: 3,
40+
retry_delay: 5,
41+
checksum: jwt_checksum
42+
)
43+
end
44+
45+
it 'installs libjwt' do
46+
is_expected.to run_bash('libjwt').with(
47+
user: 'root',
48+
group: 'root',
49+
code: <<-CODE
50+
set -e
51+
tar xf #{"#{cluster_sources_dir}/libjwt-#{jwt_version}.tar.gz"} --no-same-owner
52+
cd libjwt-#{jwt_version}
53+
autoreconf --force --install
54+
./configure --prefix=/opt/libjwt
55+
CORES=$(grep processor /proc/cpuinfo | wc -l)
56+
make -j $CORES
57+
sudo make install
58+
CODE
59+
)
60+
end
61+
end
62+
end
63+
end

0 commit comments

Comments
 (0)