@@ -23,57 +23,11 @@ def self.update(chef_run)
23
23
block_sizes = '9,18'
24
24
cluster_config = 'CONFIG_YAML'
25
25
cookbook_env = 'FAKE_COOKBOOK_PATH'
26
+ force_configuration_extra_args = ' --force-configuration'
26
27
27
28
describe '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 |
77
31
context "on #{ platform } #{ version } " do
78
32
cached ( :chef_run ) do
79
33
runner = ChefSpec ::SoloRunner . new (
@@ -86,18 +40,18 @@ def self.update(chef_run)
86
40
node . override [ 'cluster' ] [ 'slurm' ] [ 'install_dir' ] = slurm_install_dir
87
41
node . override [ 'cluster' ] [ 'p6egb200_block_sizes' ] = block_sizes
88
42
node . override [ 'cluster' ] [ 'cluster_config_path' ] = cluster_config
43
+ node . override [ 'cluster' ] [ 'slurm' ] [ 'block_topology' ] [ 'force_configuration' ] = force_configuration
89
44
end
90
45
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 )
92
46
allow_any_instance_of ( Object ) . to receive ( :cookbook_virtualenv_path ) . and_return ( cookbook_env )
93
- ConvergeBlockTopology . update ( runner )
47
+ ConvergeBlockTopology . configure ( runner )
94
48
runner
95
49
end
96
50
97
51
if platform == 'amazon' && version == '2'
98
52
it 'does not configures block_topology' do
99
53
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 ' )
101
55
end
102
56
else
103
57
it 'creates the topology configuration template' do
@@ -107,13 +61,86 @@ def self.update(chef_run)
107
61
. with ( group : 'root' )
108
62
. with ( mode : '0644' )
109
63
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
+ command_to_exe = if [ 'true' , 'yes' , true ] . include? ( force_configuration )
69
+ "#{ command } #{ force_configuration_extra_args } "
70
+ else
71
+ "#{ 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
+ command_to_exe = if [ 'true' , 'yes' , true ] . include? ( force_configuration )
119
+ "#{ command } #{ force_configuration_extra_args } "
120
+ else
121
+ "#{ 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
131
+
132
+ if topo_command_args . nil?
133
+ it 'update or cleanup topology.conf when block sizes are present' do
134
+ expect ( chef_run ) . not_to run_execute ( 'update or cleanup topology.conf' )
135
+ . with ( command : command_to_exe )
136
+ end
137
+ else
138
+ it 'update or cleanup topology.conf when block sizes are present' do
139
+ expect ( chef_run ) . to run_execute ( 'update or cleanup topology.conf' )
140
+ . with ( command : command_to_exe )
141
+ end
142
+ end
110
143
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 } " )
117
144
end
118
145
end
119
146
end
0 commit comments