Merge pull request #6123 from inspec/vasundhara/fix-windows-test-failure

Fix for error in the verify pipeline for Windows test
This commit is contained in:
Vasundhara Jagdale 2022-06-08 07:41:42 +00:00 committed by GitHub
commit 5e593dce2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 12 deletions

View file

@ -1,10 +1,11 @@
module Inspec::Resources module Inspec::Resources
class Lines class Lines
attr_reader :output attr_reader :output, :exit_status
def initialize(raw, desc) def initialize(raw, desc, exit_status)
@output = raw @output = raw
@desc = desc @desc = desc
@exit_status = exit_status
end end
def to_s def to_s
@ -40,7 +41,7 @@ module Inspec::Resources
if cmd.exit_status != 0 || out =~ /Unable to connect to any servers/ || out.downcase =~ /^error:.*/ if cmd.exit_status != 0 || out =~ /Unable to connect to any servers/ || out.downcase =~ /^error:.*/
raise Inspec::Exceptions::ResourceFailed, "Cassandra query with errors: #{out}" raise Inspec::Exceptions::ResourceFailed, "Cassandra query with errors: #{out}"
else else
Lines.new(cmd.stdout.strip, "Cassandra query: #{q}") Lines.new(cmd.stdout.strip, "Cassandra query: #{q}", cmd.exit_status)
end end
end end

View file

@ -1,10 +1,11 @@
module Inspec::Resources module Inspec::Resources
class Lines class Lines
attr_reader :output attr_reader :output, :exit_status
def initialize(raw, desc) def initialize(raw, desc, exit_status)
@output = raw @output = raw
@desc = desc @desc = desc
@exit_status = exit_status
end end
def to_s def to_s
@ -58,7 +59,7 @@ module Inspec::Resources
if cmd.exit_status != 0 || out =~ /Can't connect to IBM Db2 / || out.downcase =~ /^error:.*/ if cmd.exit_status != 0 || out =~ /Can't connect to IBM Db2 / || out.downcase =~ /^error:.*/
raise Inspec::Exceptions::ResourceFailed, "IBM Db2 connection error: #{out}" raise Inspec::Exceptions::ResourceFailed, "IBM Db2 connection error: #{out}"
else else
Lines.new(cmd.stdout.strip, "IBM Db2 Query: #{q}") Lines.new(cmd.stdout.strip, "IBM Db2 Query: #{q}", cmd.exit_status)
end end
end end

View file

@ -4,9 +4,10 @@ module Inspec::Resources
class Lines class Lines
attr_reader :params attr_reader :params
def initialize(raw, desc) def initialize(raw, desc, exit_status = nil)
@params = raw @params = raw
@desc = desc @desc = desc
@exit_status = exit_status
end end
def to_s def to_s

View file

@ -4,9 +4,9 @@ require "shellwords" unless defined?(Shellwords)
module Inspec::Resources module Inspec::Resources
class Lines class Lines
attr_reader :output attr_reader :output, :exit_status
def initialize(raw, desc) def initialize(raw, desc, exit_status)
@output = raw @output = raw
@desc = desc @desc = desc
end end
@ -58,9 +58,9 @@ module Inspec::Resources
if cmd.exit_status != 0 && ( out =~ /could not connect to/ || out =~ /password authentication failed/ ) && out.downcase =~ /error:/ if cmd.exit_status != 0 && ( out =~ /could not connect to/ || out =~ /password authentication failed/ ) && out.downcase =~ /error:/
raise Inspec::Exceptions::ResourceFailed, "PostgreSQL connection error: #{out}" raise Inspec::Exceptions::ResourceFailed, "PostgreSQL connection error: #{out}"
elsif cmd.exit_status != 0 && out.downcase =~ /error:/ elsif cmd.exit_status != 0 && out.downcase =~ /error:/
Lines.new(out, "PostgreSQL query with error: #{query}") Lines.new(out, "PostgreSQL query with error: #{query}", cmd.exit_status)
else else
Lines.new(cmd.stdout.strip, "PostgreSQL query: #{query}") Lines.new(cmd.stdout.strip, "PostgreSQL query: #{query}", cmd.exit_status)
end end
end end

View file

@ -1179,7 +1179,7 @@ describe "inspec exec" do
let(:cloud_profile) { cloud_path + "test-azure" } let(:cloud_profile) { cloud_path + "test-azure" }
let(:args) { "-t azure://" } let(:args) { "-t azure://" }
it "should fail to connect to azure due to lack of creds but not stacktrace" do it "should fail to connect to azure due to lack of creds but not stacktrace" do
_(run_result.stderr).must_equal "Tenant id cannot be nil\n" _(run_result.stderr).must_include "Tenant id cannot be nil\n"
end end
end end