Support global progress for tasks

Calculate progress for cluster using simple formula

    100 * all_tasks_finished / all_tasks_total

It will works with custom graph too.

Change-Id: Iaea07ec19d80d5f344c8ecf434f771da7a608157
Closes-Bug: #1623937
This commit is contained in:
Vladimir Sharshov (warpc) 2016-09-19 15:04:08 +03:00
parent c11a24c052
commit 11ec66899e
2 changed files with 29 additions and 7 deletions

View File

@ -72,7 +72,7 @@ module Astute
) if task.failed?
end
@ctx.report('nodes' => [node_status])
@ctx.report('nodes' => [node_status], 'progress' => cluster_progress)
end
private
@ -106,6 +106,14 @@ module Astute
end
end
def cluster_progress
if cluster.tasks_total_count != 0
100 * cluster.tasks_finished_count / cluster.tasks_total_count
else
100
end
end
def select_task_engine(data)
noop_prefix = noop_run? && not_noop_type?(data) ? "Noop" : ""
task_class_name = noop_prefix + data['type'].split('_').collect(&:capitalize).join

View File

@ -100,7 +100,8 @@ describe Astute::TaskNode do
'deployment_graph_task_name' => 'openstack-haproxy-mysqld',
'task_status' => 'running',
'summary' => {}
}])
}],
'progress' => 0)
task_node.run(task)
end
@ -327,7 +328,8 @@ describe Astute::TaskNode do
'deployment_graph_task_name' => task.name,
'summary' => {},
'task_status' => 'successful',
'progress' => 100}]
'progress' => 100}],
'progress' => 100
})
task_node.poll
end
@ -356,7 +358,8 @@ describe Astute::TaskNode do
'status' => 'ready',
'summary' => {},
'task_status' => 'skipped',
'progress' => 100}]
'progress' => 100}],
'progress' => 100
})
task_node.poll
end
@ -374,7 +377,8 @@ describe Astute::TaskNode do
'deployment_graph_task_name' => task.name,
'summary' => {},
'task_status' => 'skipped',
'progress' => 50}]
'progress' => 50}],
'progress' => 50
})
task_node.poll
end
@ -388,6 +392,14 @@ describe Astute::TaskNode do
Astute::Puppet.any_instance.expects(:status).returns(:failed)
ctx.expects(:report).with(
'nodes' => [{
'uid' => 'node_id',
'progress' => 0,
'deployment_graph_task_name' => 'test-task',
'task_status' => 'running',
'summary' => {}}],
'progress' => 0)
task_node.run(task)
ctx.expects(:report).with({
'nodes' => [{
@ -398,7 +410,8 @@ describe Astute::TaskNode do
'task_status' => 'failed',
'error_type' => 'deploy',
'error_msg' => "Task #{task.name} failed on node node_id",
'progress' => 100}]
'progress' => 100}],
'progress' => 100
})
task_node.poll
end
@ -416,7 +429,8 @@ describe Astute::TaskNode do
'deployment_graph_task_name' => task.name,
'summary' => {},
'task_status' => 'successful',
'progress' => 50}]
'progress' => 50}],
'progress' => 50
})
task_node.poll
end