Skip to content

Commit 472c513

Browse files
authored
Ensure asg-latest-update is renewed with microsecond precision even in mysql (#4269)
1 parent 01e87c7 commit 472c513

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

app/models/runtime/asg_latest_update.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ class AsgTimestamp < Sequel::Model
88
def self.renew
99
old_update = AsgTimestamp.first
1010
if old_update
11-
old_update.update(last_update: Sequel::CURRENT_TIMESTAMP)
11+
old_update.update(last_update: Time.now.utc)
1212
else
13-
AsgTimestamp.create(last_update: Sequel::CURRENT_TIMESTAMP)
13+
AsgTimestamp.create(last_update: Time.now.utc)
1414
end
1515
end
1616

spec/unit/models/runtime/asg_latest_update_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ module VCAP::CloudController
99
expect(AsgLatestUpdate.last_update).to be > 1.minute.ago
1010
end
1111

12+
it 'upates with microsecond precision' do
13+
AsgLatestUpdate.renew
14+
last_update = AsgLatestUpdate.last_update
15+
AsgLatestUpdate.renew
16+
expect(AsgLatestUpdate.last_update).to be > last_update
17+
end
18+
1219
context 'when there is no previous update' do
1320
it 'creates an asgLatestUpdate' do
1421
last_update = AsgLatestUpdate.last_update

0 commit comments

Comments
 (0)