Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def generate_topology_config_file( # noqa: C901
Generate topology.conf

# This file is automatically generated by pcluster
BlockName=block1 Nodes=queue-1-st-compute-resource-0-[1-9] #### 9 nodes
BlockName=block2 Nodes=queue-1-st-compute-resource-0-[1-18] #### 18 nodes
BlockName=block1 Nodes=queue-1-st-compute-resource-0-[1-9] #### 9 nodes Capacity Block 1
BlockName=block2 Nodes=queue-1-st-compute-resource-0-[1-18] #### 18 nodes Capacity Block 2
BlockSizes=9,18
"""
if block_sizes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def is_block_topology_supported?
end

def topology_generator_command_args
if node['cluster']['p6egb200_block_sizes'].nil? && are_queues_updated? && ::File.exist?("#{node['cluster']['slurm']['install_dir']}/etc/topology.conf")
if node['cluster']['p6egb200_block_sizes'].nil? && ::File.exist?("#{node['cluster']['slurm']['install_dir']}/etc/topology.conf")
# If topology.conf exist and Capacity Block is removed, we cleanup
" --cleanup"
elsif !node['cluster']['p6egb200_block_sizes'].nil?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def self.update(chef_run)
script_dir = 'SCRIPT_DIR'
slurm_install_dir = 'SLURM_INSTALL_DIR'
block_sizes = '9,18'
new_block_size = '1,2'
cluster_config = 'CONFIG_YAML'
cookbook_env = 'FAKE_COOKBOOK_PATH'
force_configuration_extra_args = ' --force-configuration'
Expand Down Expand Up @@ -162,9 +163,8 @@ def self.update(chef_run)
chef_run.find_resource('block_topology', 'update')
end

context "when queues are updated and topolog.conf does exists" do
context "when capacity block is removed and topolog.conf does exists" do
before do
allow_any_instance_of(Object).to receive(:are_queues_updated?).and_return(true)
allow(File).to receive(:exist?).with("#{slurm_install_dir}/etc/topology.conf").and_return(true)
chef_run.node.override['cluster']['p6egb200_block_sizes'] = nil
end
Expand All @@ -174,20 +174,19 @@ def self.update(chef_run)
end
end

context "when queues are not updated and topolog.conf does not exists" do
context "when capacity block is not used and topolog.conf does not exists" do
before do
allow_any_instance_of(Object).to receive(:are_queues_updated?).and_return(false)
allow(File).to receive(:exist?).with("#{slurm_install_dir}/etc/topology.conf").and_return(false)
chef_run.node.override['cluster']['p6egb200_block_sizes'] = nil
end

it 'it gives nil' do
expect(resource.topology_generator_command_args).to eq(nil)
end
end

context "when queues are updated and topolog.conf does not exists" do
context "when capacity block is updated and topolog.conf does not exists" do
before do
allow_any_instance_of(Object).to receive(:are_queues_updated?).and_return(true)
allow(File).to receive(:exist?).with("#{slurm_install_dir}/etc/topology.conf").and_return(false)
chef_run.node.override['cluster']['p6egb200_block_sizes'] = block_sizes
end
Expand All @@ -197,6 +196,17 @@ def self.update(chef_run)
end
end

context "when capacity block is updated and topolog.conf does exists" do
before do
allow(File).to receive(:exist?).with("#{slurm_install_dir}/etc/topology.conf").and_return(true)
chef_run.node.override['cluster']['p6egb200_block_sizes'] = new_block_size
end

it 'returns block-sizes argument' do
expect(resource.topology_generator_command_args).to eq(" --block-sizes #{new_block_size}")
end
end

context "when block sizes is not nil" do
before do
chef_run.node.override['cluster']['p6egb200_block_sizes'] = block_sizes
Expand Down
Loading