Skip to content

Commit

Permalink
Fix more issues parsing Salt Master pillar data
Browse files Browse the repository at this point in the history
  • Loading branch information
meaksh committed Oct 3, 2024
1 parent 8720ad5 commit e84e2ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
18 changes: 4 additions & 14 deletions testsuite/features/step_definitions/salt_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -396,23 +396,13 @@
end

Then(/^the pillar data for "([^"]*)" should be empty on the Salt Master$/) do |key|
output = ''
repeat_until_timeout(timeout: DEFAULT_TIMEOUT, message: "Output has more than one line: #{output}", report_result: true) do
output, _code = salt_master_pillar_get(key)
break if output.split("\n").length == 1

sleep 1
end
output = salt_master_pillar_get(key)
raise "Output value is not empty: #{output}" unless output == ''
end

Then(/^the pillar data for "([^"]*)" should be "([^"]*)" on the Salt Master$/) do |key, value|
output, _code = salt_master_pillar_get(key)
if value == ''
raise "Output has more than one line: #{output}" unless output.split("\n").length == 1
else
raise "Output value wasn't found: #{output}" unless output.split("\n").length > 1
raise "Output value is different than #{value}: #{output}" unless output.split("\n")[1].strip == value
end
output = salt_master_pillar_get(key)
raise "Output value is different than #{value}: #{output}" unless output == value
end

Given(/^I try to download "([^"]*)" from channel "([^"]*)"$/) do |rpm, channel|
Expand Down
2 changes: 1 addition & 1 deletion testsuite/features/support/commonlib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ def pillar_get(key, minion)
def salt_master_pillar_get(key)
output, _code = get_target('server').run("salt-run salt.cmd pillar.items #{key}")
pillars = YAML.load(output)
pillars[key] || ''
pillars.key?(key) ? pillars[key] : ''
end

# Wait for an action to be completed, passing the action id and a timeout
Expand Down

0 comments on commit e84e2ef

Please sign in to comment.