Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always download files even if verifier fails #1916

Merged
merged 1 commit into from Oct 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 10 additions & 7 deletions lib/kitchen/verifier/base.rb
Expand Up @@ -73,14 +73,17 @@ def call(state)
conn.upload(sandbox_dirs, config[:root_path])
debug("Transfer complete")
conn.execute(prepare_command)
conn.execute(run_command)

info("Downloading files from #{instance.to_str}")
config[:downloads].to_h.each do |remotes, local|
debug("Downloading #{Array(remotes).join(", ")} to #{local}")
conn.download(remotes, local)

begin
conn.execute(run_command)
ensure
info("Downloading files from #{instance.to_str}")
config[:downloads].to_h.each do |remotes, local|
debug("Downloading #{Array(remotes).join(", ")} to #{local}")
conn.download(remotes, local)
end
debug("Download complete")
end
debug("Download complete")
end
rescue Kitchen::Transport::TransportFailed => ex
raise ActionFailed, ex.message
Expand Down
16 changes: 16 additions & 0 deletions spec/kitchen/verifier/base_spec.rb
Expand Up @@ -250,6 +250,22 @@ class Dodgy < Kitchen::Verifier::Base
cmd
end

it "downloads files when run fails" do
connection.expects(:download).with(
["/tmp/kitchen/nodes", "/tmp/kitchen/data_bags"],
"./test/fixtures"
)

connection.expects(:download).with("/remote", "/local")

connection.expects(:execute).with("run").raises

begin
cmd
rescue
end
end

it "raises an ActionFailed on transfer when TransportFailed is raised" do
connection.stubs(:upload)
.raises(Kitchen::Transport::TransportFailed.new("dang"))
Expand Down