Inspec error when inrecipe search is used

#1

Hi.

I have a recipe in which I use an inline search for nodes with certain characteristics.
The search is done this way:

cluster_nodes=search(:node, "role:galera AND chef_environment:#{node.chef_environment} AND wsrep_cluster_name:#{wsrep_cluster_name}")

When I run kitchen verify I get the following error:

       ================================================================================
   Recipe Compile Error in /tmp/kitchen/cache/cookbooks/galera/recipes/default.rb
   ================================================================================

   Net::HTTPServerException
   ------------------------
   400 "Bad Request"

   Cookbook Trace:
   ---------------
     /tmp/kitchen/cache/cookbooks/galera/recipes/default.rb:31:in `from_file'

   Relevant File Content:
   ----------------------
   /tmp/kitchen/cache/cookbooks/galera/recipes/default.rb:

    24:  wsrep_cluster_name=node['wsrep_cluster_name']
    25:
    26:  data_dir=node['galera']['data_dir']
    27:
    28:  node_name=node['fqdn']
    29:  wsrep_node_address=node['ipaddress']
    30:
    31>> cluster_nodes=search(:node, "role:galera AND chef_environment:#{node.chef_environment} AND wsrep_cluster_name:#{wsrep_cluster_name}")

How should I write the tests so that line is ignored? Or is there something else should I do?
Thank you.
Gabriel

#2

Looks like your only issue - bad search request, add debug to check how it looks like in Kitchen:

Chef::Log.warn "role:galera AND chef_environment:#{node.chef_environment} AND wsrep_cluster_name:#{wsrep_cluster_name}"

cluster_nodes=...

pretty sure your wsrep_cluster_name is empty and search request is invalid.