@@ -21,59 +21,14 @@ def self.update(chef_run)
2121script_dir = 'SCRIPT_DIR'
2222slurm_install_dir = 'SLURM_INSTALL_DIR'
2323block_sizes = '9,18'
24+ new_block_size = '1,2'
2425cluster_config = 'CONFIG_YAML'
2526cookbook_env = 'FAKE_COOKBOOK_PATH'
27+ force_configuration_extra_args = ' --force-configuration'
2628
2729describe 'block_topology:configure' do
28- for_all_oses do |platform , version |
29- context "on #{ platform } #{ version } " do
30- cached ( :chef_run ) do
31- runner = ChefSpec ::SoloRunner . new (
32- platform : platform ,
33- version : version ,
34- step_into : [ 'block_topology' ]
35- ) do |node |
36- node . override [ 'cluster' ] [ 'node_type' ] = 'HeadNode'
37- node . override [ 'cluster' ] [ 'scripts_dir' ] = script_dir
38- node . override [ 'cluster' ] [ 'slurm' ] [ 'install_dir' ] = slurm_install_dir
39- node . override [ 'cluster' ] [ 'p6egb200_block_sizes' ] = block_sizes
40- node . override [ 'cluster' ] [ 'cluster_config_path' ] = cluster_config
41- end
42- allow_any_instance_of ( Object ) . to receive ( :is_block_topology_supported ) . and_return ( true )
43- allow_any_instance_of ( Object ) . to receive ( :cookbook_virtualenv_path ) . and_return ( cookbook_env )
44- ConvergeBlockTopology . configure ( runner )
45- runner
46- end
47-
48- if platform == 'amazon' && version == '2'
49- it 'does not configures block_topology' do
50- expect ( chef_run ) . not_to create_template ( "#{ slurm_install_dir } /etc/slurm_parallelcluster_topology.conf" )
51- expect ( chef_run ) . not_to run_execute ( 'generate_topology_config' )
52- end
53- else
54- it 'creates the topology configuration template' do
55- expect ( chef_run ) . to create_template ( "#{ slurm_install_dir } /etc/slurm_parallelcluster_topology.conf" )
56- . with ( source : 'slurm/block_topology/slurm_parallelcluster_topology.conf.erb' )
57- . with ( user : 'root' )
58- . with ( group : 'root' )
59- . with ( mode : '0644' )
60- end
61-
62- it 'generates topology config when block sizes are present' do
63- expect ( chef_run ) . to run_execute ( 'generate_topology_config' )
64- . with ( command : "#{ cookbook_env } /bin/python #{ script_dir } /slurm/pcluster_topology_generator.py" \
65- " --output-file #{ slurm_install_dir } /etc/topology.conf" \
66- " --block-sizes #{ block_sizes } " \
67- " --input-file #{ cluster_config } " )
68- end
69- end
70- end
71- end
72- end
73-
74- describe 'block_topology:update' do
75- for_all_oses do |platform , version |
76- [ '--cleannup' , nil , "--block-sizes #{ block_sizes } " ] . each do |topo_command_args |
30+ [ 'false' , false , 'no' , 'true' , true , 'yes' ] . each do |force_configuration |
31+ for_all_oses do |platform , version |
7732 context "on #{ platform } #{ version } " do
7833 cached ( :chef_run ) do
7934 runner = ChefSpec ::SoloRunner . new (
@@ -86,18 +41,18 @@ def self.update(chef_run)
8641 node . override [ 'cluster' ] [ 'slurm' ] [ 'install_dir' ] = slurm_install_dir
8742 node . override [ 'cluster' ] [ 'p6egb200_block_sizes' ] = block_sizes
8843 node . override [ 'cluster' ] [ 'cluster_config_path' ] = cluster_config
44+ node . override [ 'cluster' ] [ 'slurm' ] [ 'block_topology' ] [ 'force_configuration' ] = force_configuration
8945 end
9046 allow_any_instance_of ( Object ) . to receive ( :is_block_topology_supported ) . and_return ( true )
91- allow_any_instance_of ( Object ) . to receive ( :topology_generator_command_args ) . and_return ( topo_command_args )
9247 allow_any_instance_of ( Object ) . to receive ( :cookbook_virtualenv_path ) . and_return ( cookbook_env )
93- ConvergeBlockTopology . update ( runner )
48+ ConvergeBlockTopology . configure ( runner )
9449 runner
9550 end
9651
9752 if platform == 'amazon' && version == '2'
9853 it 'does not configures block_topology' do
9954 expect ( chef_run ) . not_to create_template ( "#{ slurm_install_dir } /etc/slurm_parallelcluster_topology.conf" )
100- expect ( chef_run ) . not_to run_execute ( 'update or cleanup topology.conf ' )
55+ expect ( chef_run ) . not_to run_execute ( 'generate_topology_config ' )
10156 end
10257 else
10358 it 'creates the topology configuration template' do
@@ -107,13 +62,86 @@ def self.update(chef_run)
10762 . with ( group : 'root' )
10863 . with ( mode : '0644' )
10964 end
65+ command = "#{ cookbook_env } /bin/python #{ script_dir } /slurm/pcluster_topology_generator.py" \
66+ " --output-file #{ slurm_install_dir } /etc/topology.conf" \
67+ " --block-sizes #{ block_sizes } " \
68+ " --input-file #{ cluster_config } "
69+ command_to_exe = if [ 'true' , 'yes' , true ] . include? ( force_configuration )
70+ "#{ command } #{ force_configuration_extra_args } "
71+ else
72+ "#{ command } "
73+ end
74+ it 'generates topology config when block sizes are present' do
75+ expect ( chef_run ) . to run_execute ( 'generate_topology_config' )
76+ . with ( command : command_to_exe )
77+ end
78+ end
79+ end
80+ end
81+ end
82+ end
83+
84+ describe 'block_topology:update' do
85+ [ 'false' , false , 'no' , 'true' , true , 'yes' ] . each do |force_configuration |
86+ for_all_oses do |platform , version |
87+ [ '--cleannup' , nil , "--block-sizes #{ block_sizes } " ] . each do |topo_command_args |
88+ context "on #{ platform } #{ version } " do
89+ cached ( :chef_run ) do
90+ runner = ChefSpec ::SoloRunner . new (
91+ platform : platform ,
92+ version : version ,
93+ step_into : [ 'block_topology' ]
94+ ) do |node |
95+ node . override [ 'cluster' ] [ 'node_type' ] = 'HeadNode'
96+ node . override [ 'cluster' ] [ 'scripts_dir' ] = script_dir
97+ node . override [ 'cluster' ] [ 'slurm' ] [ 'install_dir' ] = slurm_install_dir
98+ node . override [ 'cluster' ] [ 'p6egb200_block_sizes' ] = block_sizes
99+ node . override [ 'cluster' ] [ 'cluster_config_path' ] = cluster_config
100+ node . override [ 'cluster' ] [ 'slurm' ] [ 'block_topology' ] [ 'force_configuration' ] = force_configuration
101+ end
102+ allow_any_instance_of ( Object ) . to receive ( :is_block_topology_supported ) . and_return ( true )
103+ allow_any_instance_of ( Object ) . to receive ( :topology_generator_command_args ) . and_return ( topo_command_args )
104+ allow_any_instance_of ( Object ) . to receive ( :cookbook_virtualenv_path ) . and_return ( cookbook_env )
105+ ConvergeBlockTopology . update ( runner )
106+ runner
107+ end
108+
109+ if platform == 'amazon' && version == '2'
110+ it 'does not configures block_topology' do
111+ expect ( chef_run ) . not_to create_template ( "#{ slurm_install_dir } /etc/slurm_parallelcluster_topology.conf" )
112+ expect ( chef_run ) . not_to run_execute ( 'update or cleanup topology.conf' )
113+ end
114+ else
115+ command = "#{ cookbook_env } /bin/python #{ script_dir } /slurm/pcluster_topology_generator.py" \
116+ " --output-file #{ slurm_install_dir } /etc/topology.conf" \
117+ " --input-file #{ cluster_config } " \
118+ "#{ topo_command_args } "
119+ command_to_exe = if [ 'true' , 'yes' , true ] . include? ( force_configuration )
120+ "#{ command } #{ force_configuration_extra_args } "
121+ else
122+ "#{ command } "
123+ end
124+
125+ it 'creates the topology configuration template' do
126+ expect ( chef_run ) . to create_template ( "#{ slurm_install_dir } /etc/slurm_parallelcluster_topology.conf" )
127+ . with ( source : 'slurm/block_topology/slurm_parallelcluster_topology.conf.erb' )
128+ . with ( user : 'root' )
129+ . with ( group : 'root' )
130+ . with ( mode : '0644' )
131+ end
132+
133+ if topo_command_args . nil?
134+ it 'update or cleanup topology.conf when block sizes are present' do
135+ expect ( chef_run ) . not_to run_execute ( 'update or cleanup topology.conf' )
136+ . with ( command : command_to_exe )
137+ end
138+ else
139+ it 'update or cleanup topology.conf when block sizes are present' do
140+ expect ( chef_run ) . to run_execute ( 'update or cleanup topology.conf' )
141+ . with ( command : command_to_exe )
142+ end
143+ end
110144
111- it 'update or cleanup topology.conf when block sizes are present' do
112- expect ( chef_run ) . to run_execute ( 'update or cleanup topology.conf' )
113- . with ( command : "#{ cookbook_env } /bin/python #{ script_dir } /slurm/pcluster_topology_generator.py" \
114- " --output-file #{ slurm_install_dir } /etc/topology.conf" \
115- " --input-file #{ cluster_config } " \
116- "#{ topo_command_args } " )
117145 end
118146 end
119147 end
@@ -127,24 +155,58 @@ def self.update(chef_run)
127155 cached ( :chef_run ) do
128156 runner ( platform : platform , version : version , step_into : [ 'block_topology' ] ) do |node |
129157 node . override [ 'cluster' ] [ 'p6egb200_block_sizes' ] = nil
158+ node . override [ 'cluster' ] [ 'slurm' ] [ 'install_dir' ] = slurm_install_dir
130159 end
131160 end
132161 cached ( :resource ) do
133162 ConvergeBlockTopology . update ( chef_run )
134163 chef_run . find_resource ( 'block_topology' , 'update' )
135164 end
136165
137- context "when queues are not updated and topolog.conf does not exists" do
166+ context "when capacity block is removed and topolog.conf does exists" do
167+ before do
168+ allow ( File ) . to receive ( :exist? ) . with ( "#{ slurm_install_dir } /etc/topology.conf" ) . and_return ( true )
169+ chef_run . node . override [ 'cluster' ] [ 'p6egb200_block_sizes' ] = nil
170+ end
171+
172+ it 'returns cleanup' do
173+ expect ( resource . topology_generator_command_args ) . to eq ( " --cleanup" )
174+ end
175+ end
176+
177+ context "when capacity block is not used and topolog.conf does not exists" do
138178 before do
139- allow_any_instance_of ( Object ) . to receive ( :are_queues_updated? ) . and_return ( false )
140179 allow ( File ) . to receive ( :exist? ) . with ( "#{ slurm_install_dir } /etc/topology.conf" ) . and_return ( false )
180+ chef_run . node . override [ 'cluster' ] [ 'p6egb200_block_sizes' ] = nil
141181 end
142182
143183 it 'it gives nil' do
144184 expect ( resource . topology_generator_command_args ) . to eq ( nil )
145185 end
146186 end
147187
188+ context "when capacity block is updated and topolog.conf does not exists" do
189+ before do
190+ allow ( File ) . to receive ( :exist? ) . with ( "#{ slurm_install_dir } /etc/topology.conf" ) . and_return ( false )
191+ chef_run . node . override [ 'cluster' ] [ 'p6egb200_block_sizes' ] = block_sizes
192+ end
193+
194+ it 'returns block-sizes argument' do
195+ expect ( resource . topology_generator_command_args ) . to eq ( " --block-sizes #{ block_sizes } " )
196+ end
197+ end
198+
199+ context "when capacity block is updated and topolog.conf does exists" do
200+ before do
201+ allow ( File ) . to receive ( :exist? ) . with ( "#{ slurm_install_dir } /etc/topology.conf" ) . and_return ( true )
202+ chef_run . node . override [ 'cluster' ] [ 'p6egb200_block_sizes' ] = new_block_size
203+ end
204+
205+ it 'returns block-sizes argument' do
206+ expect ( resource . topology_generator_command_args ) . to eq ( " --block-sizes #{ new_block_size } " )
207+ end
208+ end
209+
148210 context "when block sizes is not nil" do
149211 before do
150212 chef_run . node . override [ 'cluster' ] [ 'p6egb200_block_sizes' ] = block_sizes
0 commit comments