Skip to content

Commit

Permalink
Merge pull request #3696 from mzazrivec/fix_datepoints_in_container_d…
Browse files Browse the repository at this point in the history
…ashboard_charts

Container dashboard charts: send datapoints as full timestamps
  • Loading branch information
himdel authored Apr 6, 2018
2 parents c747bdd + 35f2268 commit 43e6773
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/services/container_dashboard_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def hourly_image_metrics
def daily_image_metrics
daily_image_metrics = Hash.new(0)
daily_metrics.each do |m|
day = m.timestamp.strftime("%Y-%m-%d")
day = m.timestamp.beginning_of_day.utc
daily_image_metrics[day] +=
m.stat_container_image_registration_rate if m.stat_container_image_registration_rate.present?
end
Expand Down
6 changes: 3 additions & 3 deletions app/services/container_service_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def daily_pod_metrics
daily_pod_delete_trend = Hash.new(0)

daily_metrics.each do |m|
date = m.timestamp.strftime("%Y-%m-%d")
date = m.timestamp.beginning_of_day.utc
fill_pod_metrics(m, date, daily_pod_create_trend, daily_pod_delete_trend)
end

Expand Down Expand Up @@ -122,7 +122,7 @@ def empty_network_trend_data
def daily_network_metrics
daily_network_metrics = Hash.new(0)
daily_metrics.each do |m|
day = m.timestamp.strftime("%Y-%m-%d")
day = m.timestamp.beginning_of_day.utc
daily_network_metrics[day] += m.net_usage_rate_average if m.net_usage_rate_average.present?
end

Expand Down Expand Up @@ -179,7 +179,7 @@ def daily_utilization
total_mem = Hash.new(0)

daily_metrics.each do |metric|
date = metric.timestamp.strftime("%Y-%m-%d")
date = metric.timestamp.beginning_of_day.utc
fill_utilization(metric, date, used_cpu, used_mem, total_cpu, total_mem)
end

Expand Down
18 changes: 9 additions & 9 deletions spec/services/container_dashboard_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
ems_openshift = FactoryGirl.create(:ems_openshift, :zone => @zone)
ems_kubernetes = FactoryGirl.create(:ems_kubernetes, :zone => @zone)

current_date = 7.days.ago
current_date = 7.days.ago.beginning_of_day.utc
old_date = 35.days.ago

current_metric_openshift = FactoryGirl.create(
Expand Down Expand Up @@ -75,13 +75,13 @@
:cpu => {
:used => 2,
:total => 2,
:xData => [current_date.strftime("%Y-%m-%d")],
:xData => [current_date],
:yData => [2]
},
:memory => {
:used => 1,
:total => 2,
:xData => [current_date.strftime("%Y-%m-%d")],
:xData => [current_date],
:yData => [1]
}
)
Expand All @@ -90,13 +90,13 @@
:cpu => {
:used => 3,
:total => 3,
:xData => [current_date.strftime("%Y-%m-%d")],
:xData => [current_date],
:yData => [3.0]
},
:memory => {
:used => 2,
:total => 3,
:xData => [current_date.strftime("%Y-%m-%d")],
:xData => [current_date],
:yData => [1.5]
}
)
Expand Down Expand Up @@ -314,8 +314,8 @@
ems_openshift = FactoryGirl.create(:ems_openshift, :zone => @zone)
ems_kubernetes = FactoryGirl.create(:ems_kubernetes, :zone => @zone)

previous_date = 8.days.ago
current_date = 7.days.ago
previous_date = 8.days.ago.beginning_of_day.utc
current_date = 7.days.ago.beginning_of_day.utc
old_date = 35.days.ago

previous_metric_openshift = FactoryGirl.create(
Expand Down Expand Up @@ -353,12 +353,12 @@
daily_network_trends_single_provider = described_class.new(ems_openshift.id, controller).network_metrics[:xy_data]

expect(daily_network_trends_single_provider).to eq(
:xData => [previous_date.strftime("%Y-%m-%d"), current_date.strftime("%Y-%m-%d")],
:xData => [previous_date, current_date],
:yData => [2000, 1000]
)

expect(daily_network_trends).to eq(
:xData => [previous_date.strftime("%Y-%m-%d"), current_date.strftime("%Y-%m-%d")],
:xData => [previous_date, current_date],
:yData => [2000, 2500]
)
end
Expand Down

0 comments on commit 43e6773

Please sign in to comment.