Skip to content

Commit

Permalink
Fix inconsistent dialog input for Workflows
Browse files Browse the repository at this point in the history
Workflows run for a dynamic dialog have their dialog_values nested
under a top-level `{:dialog => {}} ` key, workflows run as a Service
Template Entrypoint should have the same format.
  • Loading branch information
agrare committed Aug 28, 2024
1 parent 4b49d30 commit bce09e7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/miq_request_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def valid_states
end

def workflow_inputs
dialog_values
{:dialog => dialog_values}
end

def dialog_values
Expand Down
32 changes: 31 additions & 1 deletion spec/models/service_template_provision_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def service_resource_id(index, scaling_max)

configuration_script = ConfigurationScript.find(@task_0.options[:configuration_script_id])

expect(configuration_script).to have_attributes(:manager => automation_manager, :run_by_userid => @admin.userid, :status => "pending")
expect(configuration_script).to have_attributes(:manager => automation_manager, :run_by_userid => @admin.userid, :status => "pending", :context => hash_including("Execution" => hash_including("Input" => {"dialog" => {}})))
expect(MiqQueue.first).to have_attributes(
:instance_id => configuration_script.id,
:class_name => configuration_script.type,
Expand All @@ -151,6 +151,36 @@ def service_resource_id(index, scaling_max)
:args => [hash_including(:object_type => "ServiceTemplateProvisionTask", :object_id => @task_0.id)]
)
end

context "with dialog_values" do
let(:dialog_values) { {"foo" => "bar"} }

it "creates a configuration_script instance" do
zone = FactoryBot.create(:zone, :name => "special")
automation_manager = FactoryBot.create(:ems_workflows_automation, :zone => zone)
payload = FactoryBot.create(:embedded_workflow, :manager => automation_manager)
@task_0.source = FactoryBot.create(
:service_template_generic,
:name => "Provision",
:resource_actions => [
FactoryBot.create(:resource_action, :action => "Provision", :configuration_script_payload => payload)
]
)

@task_0.update(
:options => {
:dialog => dialog_values,
:configuration_script_payload_id => payload.id
}
)

@task_0.deliver_queue

configuration_script = ConfigurationScript.find(@task_0.options[:configuration_script_id])

expect(configuration_script.context).to include("Execution" => hash_including("Input" => {"dialog" => dialog_values}))
end
end
end

context "with a configuration_script_payload in options" do
Expand Down

0 comments on commit bce09e7

Please sign in to comment.