Skip to content

Commit 214039d

Browse files
authored
Fix flaky tests related to AsgLatestUpdate (#4021)
1 parent 2ae7c7e commit 214039d

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed

spec/unit/actions/security_group_apply_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ module VCAP::CloudController
3030
end
3131

3232
it 'updates the latest security group update table' do
33+
last_update = AsgLatestUpdate.last_update
3334
subject.apply_running(security_group, message, visible_space_guids:, all_spaces_visible:)
34-
expect(AsgLatestUpdate.last_update).to be > 1.second.ago
35+
expect(AsgLatestUpdate.last_update).to be > last_update
3536
end
3637
end
3738

@@ -112,8 +113,9 @@ module VCAP::CloudController
112113
end
113114

114115
it 'updates the latest security group update table' do
116+
last_update = AsgLatestUpdate.last_update
115117
subject.apply_staging(security_group, message, visible_space_guids:, all_spaces_visible:)
116-
expect(AsgLatestUpdate.last_update).to be > 1.second.ago
118+
expect(AsgLatestUpdate.last_update).to be > last_update
117119
end
118120
end
119121

spec/unit/actions/security_group_create_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ module VCAP::CloudController
3434
end
3535

3636
it 'updates the latest security group update table' do
37+
last_update = AsgLatestUpdate.last_update
3738
subject.create(message)
38-
expect(AsgLatestUpdate.last_update).to be > 1.second.ago
39+
expect(AsgLatestUpdate.last_update).to be > last_update
3940
end
4041
end
4142

spec/unit/actions/security_group_delete_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ module VCAP::CloudController
3030
end
3131

3232
it 'updates the latest security group update table' do
33+
last_update = AsgLatestUpdate.last_update
3334
security_group_delete.delete([security_group])
34-
expect(AsgLatestUpdate.last_update).to be > 1.second.ago
35+
expect(AsgLatestUpdate.last_update).to be > last_update
3536
end
3637

3738
it 'deletes associated staging spaces roles' do

spec/unit/actions/security_group_unapply_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ module VCAP::CloudController
2323
end
2424

2525
it 'updates the latest security group update table' do
26+
last_update = AsgLatestUpdate.last_update
2627
subject.unapply_running(security_group, space)
27-
expect(AsgLatestUpdate.last_update).to be > 1.second.ago
28+
expect(AsgLatestUpdate.last_update).to be > last_update
2829
end
2930
end
3031

@@ -63,8 +64,9 @@ module VCAP::CloudController
6364
end
6465

6566
it 'updates the latest security group update table' do
67+
last_update = AsgLatestUpdate.last_update
6668
subject.unapply_staging(security_group, space)
67-
expect(AsgLatestUpdate.last_update).to be > 1.second.ago
69+
expect(AsgLatestUpdate.last_update).to be > last_update
6870
end
6971
end
7072

spec/unit/actions/security_group_update_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ module VCAP::CloudController
3939
end
4040

4141
it 'updates the latest security group update table' do
42+
last_update = AsgLatestUpdate.last_update
4243
SecurityGroupUpdate.update(security_group, update_message)
43-
expect(AsgLatestUpdate.last_update).to be > 1.second.ago
44+
expect(AsgLatestUpdate.last_update).to be > last_update
4445
end
4546
end
4647

spec/unit/models/runtime/asg_latest_update_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ module VCAP::CloudController
1111

1212
context 'when there is no previous update' do
1313
it 'creates an asgLatestUpdate' do
14+
last_update = AsgLatestUpdate.last_update
1415
AsgLatestUpdate.renew
15-
expect(AsgLatestUpdate.last_update).to be > 1.second.ago
16+
expect(AsgLatestUpdate.last_update).to be > last_update
1617
end
1718
end
1819
end

0 commit comments

Comments
 (0)