Skip to content

GitLab

  • Menu
    • Projects Groups Snippets
      Help
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Issues
  • #7223

Closed
Open
Created 10 years ago by Administrator@rootOwner
  • New issue

  • Report abuse

  • New issue

  • Report abuse

Travis builds fail unnecessarily because of too tight timing constraints in specs.

Closed

Travis builds fail unnecessarily because of too tight timing constraints in specs.

Created by: jhund

The spec below fails on Travis because it expects two events to happen at the same second. This expectation is valid in a production system, however not on Travis where things can be a lot slower.

Notice that the expected and received value differ by 1 second. This is probably caused by delays in ActiveRecord callbacks running on a slow CI server.

Failures:
  1) Project last_activity methods last_activity_date returns the creation date of the project's last event if present
     Failure/Error: project.last_activity_at.to_i.should == last_event.created_at.to_i
       expected: 1403898527
            got: 1403898526 (using ==)
     # ./spec/models/project_spec.rb:118:in `block (4 levels) in <top (required)>'

To fix it, I propose to make the time comparison less stringent and allow a difference of up to 1 second.

Also I believe that this particular spec has a logic error. It's titled to test project.last_activity_date, however in the test it references project.last_activity_at instead.

The code under test:

def last_activity_date
  last_activity_at || updated_at
end

I'd be happy to submit a pull request that changes

it 'returns the creation date of the project\'s last event if present' do
  last_activity_event = create(:event, project: project)
  project.last_activity_at.to_i.should == last_event.created_at.to_i
end

to

it 'returns the creation date of the project\'s last event if present' do
  last_activity_event = create(:event, project: project)
  (project.last_activity_date - last_event.created_at).to_i.abs.should < 2
end

I checked and didn't find any other instances in model specs were times were cast to integer for comparison.

This bug makes my pull request fail, so I'm highly motivated to fix this. I'm happy to prepare a pull request if this is something you'd like to address.

Linked issues
0


  • Administrator
    Administrator @root · 10 years ago
    Owner

    Created by: axilleas

    @jhund please do. Refining tests is always encouraged. You can ping @jvanbaarsen or @dblessing in your PR and they will review it as soon as they have some free time.

    By Administrator on 2014-06-28T14:32:36 (imported from GitLab project)

  • Administrator
    Administrator @root · 10 years ago
    Owner

    Created by: Razer6

    We do not use Travis anymore. Long live semaphore!

    By Administrator on 2014-10-08T09:49:29 (imported from GitLab project)

  • You're only seeing other activity in the feed. To add a comment, switch to one of the following options.
Please register or sign in to reply
0 Assignees
None
Assign to
Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Due date
None
None
0
Labels
None
Assign labels
  • No matching results
  • Manage project labels
Confidentiality
Not confidential
Not confidential

You are going to turn on confidentiality. Only team members with at least Reporter access will be able to see and leave comments on the issue.

Lock issue
Unlocked
1
1 participant
user avatar
Reference: gpt/large_projects/gitlabhq1#7223

Menu

Projects Groups Snippets
Help