Skip to content

Commit 5620a52

Browse files
committed
Add spec test to cover the deletion of the cluster id state
1 parent e0cc721 commit 5620a52

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require 'spec_helper'
2+
3+
describe 'aws-parallelcluster-slurm::clear_slurm_accounting' do
4+
for_all_oses do |platform, version|
5+
context "on #{platform}#{version}" do
6+
cached(:chef_run) do
7+
runner = runner(platform: platform, version: version) do |node|
8+
mock_file_exists("/var/spool/slurm.state/clustername", true)
9+
node.override['cluster']['slurmdbd_service_enabled'] = true
10+
end
11+
runner.converge(described_recipe)
12+
end
13+
cached(:node) { chef_run.node }
14+
15+
it 'stops the slurm database daemon' do
16+
is_expected.to disable_service("slurmdbd")
17+
end
18+
19+
it 'deletes the Slurm database password update script' do
20+
is_expected.to delete_file("#{node['cluster']['scripts_dir']}/slurm/update_slurm_database_password.sh")
21+
end
22+
23+
it 'Removes existing cluster name state file' do
24+
is_expected.to run_bash("Remove existing cluster name state file")
25+
end
26+
end
27+
end
28+
end

cookbooks/aws-parallelcluster-slurm/spec/unit/recipes/config_slurm_accounting_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
allow_any_instance_of(Object).to receive(:are_mount_or_unmount_required?).and_return(false)
1111
allow_any_instance_of(Object).to receive(:dig).and_return(true)
1212
RSpec::Mocks.configuration.allow_message_expectations_on_nil = true
13+
mock_file_exists("/var/spool/slurm.state/clustername", true)
1314
node.override['cluster']['slurmdbd_service_enabled'] = enable_service
1415
end
1516
runner.converge(described_recipe)
@@ -70,6 +71,9 @@
7071
)
7172
end
7273
if enable_service == "true"
74+
it 'Removes existing cluster name state file' do
75+
is_expected.to run_bash("Remove existing cluster name state file")
76+
end
7377
it 'starts the slurm database daemon' do
7478
is_expected.to enable_service("slurmdbd")
7579
is_expected.to start_service("slurmdbd")

0 commit comments

Comments
 (0)