summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-04-04 16:00:40 +0000
committerGerrit Code Review <review@openstack.org>2016-04-04 16:00:40 +0000
commit90bf154929ead0a2f0d7769b25e7c2be0c0eddbd (patch)
tree93fd4cab748cf9a4493de3446727be36ea9ef26e
parent8a3b77413720419e8c9fc0da316b14dfb872954e (diff)
parente26d773fb7335f3c712004d5b38f1589becb5455 (diff)
Merge "Add ROLE: annotation"
-rw-r--r--doc/usage.rst16
-rw-r--r--lib/noop/manager/library.rb47
2 files changed, 54 insertions, 9 deletions
diff --git a/doc/usage.rst b/doc/usage.rst
index 6747c32..f6308c3 100644
--- a/doc/usage.rst
+++ b/doc/usage.rst
@@ -159,6 +159,13 @@ possible run combinations you can use the **RUN:** annotation.::
159It can be specified many times an all entered combinations will be added to the 159It can be specified many times an all entered combinations will be added to the
160list. 160list.
161 161
162You can use **ROLE** annotation to specify the list of node roles this
163spec should be running at. It will find the list of Hiera yaml files
164that have roles matching this list.::
165
166 # ROLE: controller
167 # ROLE: primary-controller
168
162There is also a way to use the reverse logic. You can specify the Hiera 169There is also a way to use the reverse logic. You can specify the Hiera
163and facts yaml files that you want to exclude from the list instead of 170and facts yaml files that you want to exclude from the list instead of
164providing the list of included files.:: 171providing the list of included files.::
@@ -171,6 +178,15 @@ you have used both include and exclude options, the exclude option will have
171the priority over the include option. If there are no included Hiera files 178the priority over the include option. If there are no included Hiera files
172the list of Hiera files will be generated from the node roles. 179the list of Hiera files will be generated from the node roles.
173 180
181Note, that all these options can be combined all together. It will mean
182to take all 'compute' yamls, add neut_vlan_l3ha.ceph.ceil-primary-controller
183and remove 'neut_vlan.compute.ssl' and then add master/master_centos7 run.::
184
185 # ROLE: compute
186 # HIERA: neut_vlan_l3ha.ceph.ceil-primary-controller.yaml
187 # RUN: master master_centos7
188 # SKIP_HIERA: neut_vlan.compute.ssl.yaml
189
174The final annotation **DISABLE_SPEC** allows you to temporarily disable the 190The final annotation **DISABLE_SPEC** allows you to temporarily disable the
175spec from being seen the framework. It can use useful if you want to turn off 191spec from being seen the framework. It can use useful if you want to turn off
176a spec with run problems and fix them later without breaking the tests.:: 192a spec with run problems and fix them later without breaking the tests.::
diff --git a/lib/noop/manager/library.rb b/lib/noop/manager/library.rb
index 5e6921f..99c0fbb 100644
--- a/lib/noop/manager/library.rb
+++ b/lib/noop/manager/library.rb
@@ -172,14 +172,7 @@ module Noop
172 return @assign_spec_to_hiera if @assign_spec_to_hiera 172 return @assign_spec_to_hiera if @assign_spec_to_hiera
173 @assign_spec_to_hiera = {} 173 @assign_spec_to_hiera = {}
174 assign_spec_to_roles.each do |file_name_spec, spec_roles_set| 174 assign_spec_to_roles.each do |file_name_spec, spec_roles_set|
175 if spec_roles_set.include? '*' 175 hiera_files = get_hiera_for_roles spec_roles_set
176 hiera_files = assign_hiera_to_roles.keys
177 else
178 hiera_files = assign_hiera_to_roles.select do |file_name_hiera, hiera_roles_set|
179 roles_intersection = hiera_roles_set & spec_roles_set
180 roles_intersection.any?
181 end.keys
182 end
183 @assign_spec_to_hiera[file_name_spec] = hiera_files if hiera_files.any? 176 @assign_spec_to_hiera[file_name_spec] = hiera_files if hiera_files.any?
184 end 177 end
185 @assign_spec_to_hiera 178 @assign_spec_to_hiera
@@ -231,10 +224,16 @@ module Noop
231 task_spec_metadata[:skip_facts] += get_list_of_yamls $1 224 task_spec_metadata[:skip_facts] += get_list_of_yamls $1
232 end 225 end
233 226
234 if line =~ /disable_spec/ 227 if line =~ /^\s*#\s*disable_spec/
235 task_spec_metadata[:disable] = true 228 task_spec_metadata[:disable] = true
236 end 229 end
237 230
231 if line =~ /^\s*#\s*role:\s*(.*)/
232 task_spec_metadata[:roles] = [] unless task_spec_metadata[:roles].is_a? Array
233 roles = line.split /\s*,\s*|\s+/
234 task_spec_metadata[:roles] += roles
235 end
236
238 if line =~ /^\s*#\s*run:\s*(.*)/ 237 if line =~ /^\s*#\s*run:\s*(.*)/
239 run_record = get_list_of_yamls $1 238 run_record = get_list_of_yamls $1
240 if run_record.length >= 2 239 if run_record.length >= 2
@@ -278,6 +277,13 @@ module Noop
278 file_name_spec = Noop::Utils.convert_to_path file_name_spec 277 file_name_spec = Noop::Utils.convert_to_path file_name_spec
279 metadata = spec_run_metadata.fetch file_name_spec, {} 278 metadata = spec_run_metadata.fetch file_name_spec, {}
280 metadata[:facts] = [Noop::Config.default_facts_file_name] unless metadata[:facts] 279 metadata[:facts] = [Noop::Config.default_facts_file_name] unless metadata[:facts]
280
281 if metadata[:roles]
282 metadata[:hiera] = [] unless metadata[:hiera]
283 metadata[:hiera] += get_hiera_for_roles metadata[:roles]
284 end
285
286 # the last default way to get hiera files list
281 metadata[:hiera] = assign_spec_to_hiera.fetch file_name_spec, [] unless metadata[:hiera] 287 metadata[:hiera] = assign_spec_to_hiera.fetch file_name_spec, [] unless metadata[:hiera]
282 288
283 runs = [] 289 runs = []
@@ -294,6 +300,29 @@ module Noop
294 runs 300 runs
295 end 301 end
296 302
303 # Get a list of Hiera YAML files which roles
304 # include the given set of roles
305 # @param roles [Array,Set,String]
306 # @return [Array]
307 def get_hiera_for_roles(*roles)
308 all_roles = Set.new
309 roles.flatten.each do |role|
310 if role.is_a? Set
311 all_roles += role
312 else
313 all_roles.add role
314 end
315 end
316 if all_roles.include? '*'
317 assign_hiera_to_roles.keys
318 else
319 assign_hiera_to_roles.select do |_file_name_hiera, hiera_roles_set|
320 roles_intersection = hiera_roles_set & all_roles
321 roles_intersection.any?
322 end.keys
323 end
324 end
325
297 # Check if the given element matches this filter 326 # Check if the given element matches this filter
298 # @param [Array<String>] 327 # @param [Array<String>]
299 def filter_is_matched?(filter, element) 328 def filter_is_matched?(filter, element)