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 dashboard charts: send datapoints as full timestamps #3696

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/services/container_dashboard_service.rb
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
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
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