Skip to content

Commit

Permalink
Merge pull request #19276 from NickLaMuro/embedded_ansible_todo_cleanup
Browse files Browse the repository at this point in the history
[EmbeddedAnsible] TODO Cleanup
  • Loading branch information
Fryguy authored Jun 25, 2020
2 parents 86c4492 + 881d6c0 commit d31815c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@
expect(status.normalized_status).to eq(['failed', 'Stack creation failed'])
end

# TODO: remove or implement? Is canceling something we can handle?
#
# it 'parses Canceled' do
# status = described_class.new('Canceled', nil)
# expect(status.completed?).to be_truthy
# expect(status.succeeded?).to be_falsey
# expect(status.canceled?).to be_truthy
# expect(status.deleted?).to be_falsey
# expect(status.rolled_back?).to be_falsey
# expect(status.normalized_status).to eq(['create_canceled', 'Job launching was canceled'])
# end

it 'parses transient status' do
miq_task.state = MiqTask::STATE_ACTIVE
miq_task.status = MiqTask::STATUS_UNKNOWN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,53 +144,36 @@
end
end

# TODO: Punting for now need some more time to get this tested properly,
# but don't have the current mental capacity to figure the right way
# to set this up in a time crunch.

# describe "#raw_stdout" do
# subject { described_class.create_job(playbook, {}) }

# it "gets the standard output of the job" do
# expect(subject.raw_stdout("html")).to eq("<html><body>job stdout</body></html>")
# end

# it "catches errors from provider" do
# expect(connection.api.jobs).to receive(:find).and_raise("bad happened")
# expect { subject.raw_stdout("html") }.to raise_error(MiqException::MiqOrchestrationStatusError)
# end
# end
#
# describe "#raw_stdout_via_worker" do
# before do
# EvmSpecHelper.create_guid_miq_server_zone
# allow(described_class).to receive(:find).and_return(job)

# allow(MiqTask).to receive(:wait_for_taskid) do
# request = MiqQueue.find_by(:class_name => described_class.name)
# request.update(:state => MiqQueue::STATE_DEQUEUE)
# request.delivered(*request.deliver)
# end
# end

# it "gets stdout from the job" do
# expect(job).to receive(:raw_stdout).and_return("A stdout from the job")
# taskid = job.raw_stdout_via_worker("user")
# MiqTask.wait_for_taskid(taskid)
# expect(MiqTask.find(taskid)).to have_attributes(
# :task_results => "A stdout from the job",
# :status => "Ok"
# )
# end

# it "returns the error message" do
# expect(job).to receive(:raw_stdout).and_throw("Failed to get stdout from the job")
# taskid = job.raw_stdout_via_worker("user")
# MiqTask.wait_for_taskid(taskid)
# expect(MiqTask.find(taskid).message).to include("Failed to get stdout from the job")
# expect(MiqTask.find(taskid).status).to eq("Error")
# end
# end
describe "#raw_stdout_via_worker" do
before do
EvmSpecHelper.create_guid_miq_server_zone
allow(described_class).to receive(:find).and_return(job)

allow(MiqTask).to receive(:wait_for_taskid) do
request = MiqQueue.find_by(:class_name => described_class.name)
request.update(:state => MiqQueue::STATE_DEQUEUE)
request.delivered(*request.deliver)
end
end

it "gets stdout from the job" do
expect(job).to receive(:raw_stdout).and_return("A stdout from the job")
taskid = job.raw_stdout_via_worker("user")
MiqTask.wait_for_taskid(taskid)
expect(MiqTask.find(taskid)).to have_attributes(
:task_results => "A stdout from the job",
:status => "Ok"
)
end

it "returns the error message" do
expect(job).to receive(:raw_stdout).and_throw("Failed to get stdout from the job")
taskid = job.raw_stdout_via_worker("user")
MiqTask.wait_for_taskid(taskid)
expect(MiqTask.find(taskid).message).to include("Failed to get stdout from the job")
expect(MiqTask.find(taskid).status).to eq("Error")
end
end
end

context "when embedded_ansible role is disabled" do
Expand Down

0 comments on commit d31815c

Please sign in to comment.