@@ -23,57 +23,11 @@ def self.update(chef_run)
2323block_sizes = '9,18'
2424cluster_config = 'CONFIG_YAML'
2525cookbook_env = 'FAKE_COOKBOOK_PATH'
26+ force_configuration_extra_args = ' --force-configuration'
2627
2728describe '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 |
29+ [ 'false' , false , 'no' , 'true' , true , 'yes' ] . each do |force_configuration |
30+ for_all_oses do |platform , version |
7731 context "on #{ platform } #{ version } " do
7832 cached ( :chef_run ) do
7933 runner = ChefSpec ::SoloRunner . new (
@@ -86,18 +40,18 @@ def self.update(chef_run)
8640 node . override [ 'cluster' ] [ 'slurm' ] [ 'install_dir' ] = slurm_install_dir
8741 node . override [ 'cluster' ] [ 'p6egb200_block_sizes' ] = block_sizes
8842 node . override [ 'cluster' ] [ 'cluster_config_path' ] = cluster_config
43+ node . override [ 'cluster' ] [ 'slurm' ] [ 'block_topology' ] [ 'force_configuration' ] = force_configuration
8944 end
9045 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 )
9246 allow_any_instance_of ( Object ) . to receive ( :cookbook_virtualenv_path ) . and_return ( cookbook_env )
93- ConvergeBlockTopology . update ( runner )
47+ ConvergeBlockTopology . configure ( runner )
9448 runner
9549 end
9650
9751 if platform == 'amazon' && version == '2'
9852 it 'does not configures block_topology' do
9953 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 ' )
54+ expect ( chef_run ) . not_to run_execute ( 'generate_topology_config ' )
10155 end
10256 else
10357 it 'creates the topology configuration template' do
@@ -107,13 +61,78 @@ def self.update(chef_run)
10761 . with ( group : 'root' )
10862 . with ( mode : '0644' )
10963 end
64+ 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+ if [ 'true' , 'yes' , true ] . include? ( force_configuration )
69+ command_to_exe = "#{ command } #{ force_configuration_extra_args } "
70+ else
71+ command_to_exe = "#{ command } "
72+ end
73+ it 'generates topology config when block sizes are present' do
74+ expect ( chef_run ) . to run_execute ( 'generate_topology_config' )
75+ . with ( command : command_to_exe )
76+ end
77+ end
78+ end
79+ end
80+ end
81+ end
82+
83+ describe 'block_topology:update' do
84+ [ 'false' , false , 'no' , 'true' , true , 'yes' ] . each do |force_configuration |
85+ for_all_oses do |platform , version |
86+ [ '--cleannup' , nil , "--block-sizes #{ block_sizes } " ] . each do |topo_command_args |
87+ context "on #{ platform } #{ version } " do
88+ cached ( :chef_run ) do
89+ runner = ChefSpec ::SoloRunner . new (
90+ platform : platform ,
91+ version : version ,
92+ step_into : [ 'block_topology' ]
93+ ) do |node |
94+ node . override [ 'cluster' ] [ 'node_type' ] = 'HeadNode'
95+ node . override [ 'cluster' ] [ 'scripts_dir' ] = script_dir
96+ node . override [ 'cluster' ] [ 'slurm' ] [ 'install_dir' ] = slurm_install_dir
97+ node . override [ 'cluster' ] [ 'p6egb200_block_sizes' ] = block_sizes
98+ node . override [ 'cluster' ] [ 'cluster_config_path' ] = cluster_config
99+ node . override [ 'cluster' ] [ 'slurm' ] [ 'block_topology' ] [ 'force_configuration' ] = force_configuration
100+ end
101+ allow_any_instance_of ( Object ) . to receive ( :is_block_topology_supported ) . and_return ( true )
102+ allow_any_instance_of ( Object ) . to receive ( :topology_generator_command_args ) . and_return ( topo_command_args )
103+ allow_any_instance_of ( Object ) . to receive ( :cookbook_virtualenv_path ) . and_return ( cookbook_env )
104+ ConvergeBlockTopology . update ( runner )
105+ runner
106+ end
107+
108+ if platform == 'amazon' && version == '2'
109+ it 'does not configures block_topology' do
110+ expect ( chef_run ) . not_to create_template ( "#{ slurm_install_dir } /etc/slurm_parallelcluster_topology.conf" )
111+ expect ( chef_run ) . not_to run_execute ( 'update or cleanup topology.conf' )
112+ end
113+ else
114+ command = "#{ cookbook_env } /bin/python #{ script_dir } /slurm/pcluster_topology_generator.py" \
115+ " --output-file #{ slurm_install_dir } /etc/topology.conf" \
116+ " --input-file #{ cluster_config } " \
117+ "#{ topo_command_args } "
118+ if [ 'true' , 'yes' , true ] . include? ( force_configuration )
119+ command_to_exe = "#{ command } #{ force_configuration_extra_args } "
120+ else
121+ command_to_exe = "#{ command } "
122+ end
123+
124+ it 'creates the topology configuration template' do
125+ expect ( chef_run ) . to create_template ( "#{ slurm_install_dir } /etc/slurm_parallelcluster_topology.conf" )
126+ . with ( source : 'slurm/block_topology/slurm_parallelcluster_topology.conf.erb' )
127+ . with ( user : 'root' )
128+ . with ( group : 'root' )
129+ . with ( mode : '0644' )
130+ end
110131
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 } " )
132+ it 'update or cleanup topology.conf when block sizes are present' do
133+ expect ( chef_run ) . to run_execute ( 'update or cleanup topology.conf' )
134+ . with ( command : command_to_exe )
135+ end
117136 end
118137 end
119138 end
0 commit comments