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

[EmbeddedAnsible] TODO Cleanup #19276

Merged
merged 2 commits into from
Jun 25, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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