Skip to content

Commit

Permalink
Merge pull request ManageIQ#7185 from himdel/container-project-dashboard
Browse files Browse the repository at this point in the history
Container project dashboard - add missing dataAvailable
  • Loading branch information
h-kataria authored Jul 8, 2020
2 parents 0401439 + 030d7c1 commit b21c7d9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/services/container_service_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def hourly_pod_metrics
def create_delete_data(create_trend, delete_trend)
if create_trend.any?
{
:dataAvailable => true,
:xData => create_trend.keys,
:yCreated => create_trend.values.map(&:round),
:yDeleted => delete_trend.values.map(&:round)
Expand All @@ -71,6 +72,7 @@ def utilization_data(used_cpu, total_cpu, used_mem, total_mem)
def trend_data(trend)
if trend.any?
{
:dataAvailable => true,
:xData => trend.keys,
:yData => trend.values.map { |value| (value || 0).round }
}
Expand Down Expand Up @@ -154,6 +156,7 @@ def realtime_utilization

if used_cpu.any?
{
:dataAvailable => true,
:interval_name => "realtime",
:xy_data => utilization_data(used_cpu, total_cpu, used_mem, total_mem)
}
Expand All @@ -173,6 +176,7 @@ def hourly_utilization

if used_cpu.any?
{
:dataAvailable => true,
:interval_name => "hourly",
:xy_data => utilization_data(used_cpu, total_cpu, used_mem, total_mem)
}
Expand All @@ -192,6 +196,7 @@ def daily_utilization

if used_cpu.any?
{
:dataAvailable => true,
:interval_name => "daily",
:xy_data => utilization_data(used_cpu, total_cpu, used_mem, total_mem)
}
Expand Down
2 changes: 2 additions & 0 deletions app/services/dashboard_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def format_utilization_data(used_cpu, used_mem, total_cpu, total_mem)

def format_cpu(used, total)
{
:dataAvailable => true,
:used => cpu_num(used.values.last).round(display_precision),
:total => cpu_num(total.values.last).round(0),
:xData => used.keys,
Expand All @@ -29,6 +30,7 @@ def cpu_num(val)

def format_memory(used, total)
{
:dataAvailable => true,
:used => mem_num(used.values.last).round(display_precision),
:total => mem_num(total.values.last).round(0),
:xData => used.keys,
Expand Down
11 changes: 9 additions & 2 deletions spec/services/container_dashboard_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@

expect(node_utilization_single_provider).to eq(
:cpu => {
:dataAvailable => true,
:used => 2,
:total => 2,
:xData => [current_date],
:yData => [2]
},
:memory => {
:dataAvailable => true,
:used => 1,
:total => 2,
:xData => [current_date],
Expand All @@ -92,12 +94,14 @@

expect(node_utilization_all_providers).to eq(
:cpu => {
:dataAvailable => true,
:used => 3,
:total => 3,
:xData => [current_date],
:yData => [3.0]
},
:memory => {
:dataAvailable => true,
:used => 2,
:total => 3,
:xData => [current_date],
Expand Down Expand Up @@ -382,11 +386,13 @@
daily_network_trends_single_provider = described_class.new(ems_openshift.id, controller).network_metrics[:xy_data]

expect(daily_network_trends_single_provider).to eq(
:dataAvailable => true,
:xData => [previous_date, current_date],
:yData => [2000, 1000]
)

expect(daily_network_trends).to eq(
:dataAvailable => true,
:xData => [previous_date, current_date],
:yData => [2000, 2500]
)
Expand Down Expand Up @@ -443,15 +449,16 @@
ems_kubernetes.metric_rollups << nil_fields_metric.dup

hourly_network_trends = described_class.new(nil, controller).network_metrics[:xy_data]
hourly_network_trends_single_provider =
described_class.new(ems_openshift.id, controller).network_metrics[:xy_data]
hourly_network_trends_single_provider = described_class.new(ems_openshift.id, controller).network_metrics[:xy_data]

expect(hourly_network_trends_single_provider).to eq(
:dataAvailable => true,
:xData => [previous_date.beginning_of_hour.utc, current_date.beginning_of_hour.utc],
:yData => [2000, 1000]
)

expect(hourly_network_trends).to eq(
:dataAvailable => true,
:xData => [previous_date.beginning_of_hour.utc, current_date.beginning_of_hour.utc],
:yData => [2000, 2500]
)
Expand Down

0 comments on commit b21c7d9

Please sign in to comment.