Project

General

Profile

Bug #19087

UINotificationsHostsBuildCompletedTest failures with MySQL on Rails 5.0

Added by Dominic Cleal over 1 year ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Tests
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

The notifications host built test fails most of the time with a MySQL database under Rails 5.0:

Failure:
UINotificationsHostsBuildCompletedTest#test_0002_multiple build events should update current build notification [test/unit/ui_notifications/hosts/build_completed_test.rb:12]:
"Notification.where(:subject => host).count" didn't change by 1.
Expected: 1
  Actual: 0

The cause is similar to #19085, where the precision of timestamp fields is being relied upon for the test, and the default one-second precision of a timestamp field under MySQL is affecting it. The timestamp field getters in Rails 5.0 now return the same precision as the underlying field, causing the failure.

The test first marks an already-built host as built, puts it back into build mode and then marks it built, checking that a notification is generated on the second built event.

Hostext::UINotifications#just_provisioned? uses previous_changes['installed_at'] (i.e. a change in the installed_at timestamp) to test if the host has been provisioned. When the granularity of the timestamp is to the second, this test usually fails as it runs within one second.

This would technically be an issue in the live application as well as the test, but sub-second rebuilds are unlikely to occur in practice.


Related issues

Blocks Foreman - Feature #19050: Add support for running under Ruby on Rails 5.0Closed2017-03-28

Associated revisions

Revision 26c7d10a (diff)
Added by Dominic Cleal over 1 year ago

fixes #19087 - create host built notification from Host#built

Comparing the host's installed_at timestamp is unreliable on MySQL
databases, as the timestamp field has a limited granularity. Under Rails
5 in a sub-second test, this field will not be changed.

Instead, extend Host#built to create notifications as the original
method is also used to send e-mail notifications and update the
installed_at field.

History

#1 Updated by Dominic Cleal over 1 year ago

  • Blocks Feature #19050: Add support for running under Ruby on Rails 5.0 added

#2 Updated by The Foreman Bot over 1 year ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/4424 added

#3 Updated by The Foreman Bot over 1 year ago

  • Pull request https://github.com/theforeman/foreman/pull/4422 added

#4 Updated by Dominic Cleal over 1 year ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#5 Updated by Dominic Cleal over 1 year ago

  • Pull request deleted (https://github.com/theforeman/foreman/pull/4422)

#6 Updated by Marek Hulán about 1 year ago

  • Legacy Backlogs Release (now unused) set to 240

Also available in: Atom PDF