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

Container project dashboard - add missing dataAvailable #7185

Merged
merged 2 commits into from
Jul 8, 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
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