Fix `EmailsOnPushWorker` spec
-
gitlab-ce/master
is red because of this spec:
1) EmailsOnPushWorker#perform when there are multiple recipients only generates the mail once
Failure/Error: expect(Premailer::Rails::CustomizedPremailer).to receive(:new).once.and_call_original
(Premailer::Rails::CustomizedPremailer (class)).new(*(any args))
expected: 1 time with any arguments
received: 0 times with any arguments
# ./spec/workers/emails_on_push_worker_spec.rb:66:in `block (4 levels) in <top (required)>'
Designs
- Show closed items
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
- Author Contributor
Notes while Investigating
- Can't reproduce locally.
rspec spec/workers/emails_on_push_spec.rb
andrspec spec/workers/*
both pass.
Retry failed build on
master
- Fails
On a single node
- Running
spec/workers
only. - All specs pass on CI.
- Interestingly, CI reports "36 examples", running it locally using
rspec <path>
reports "46 examples", and running it locally usingknapsack rspec
reports "36 examples"
On 5 nodes
- Running
spec/workers
only - All specs pass on CI
On 20 nodes
- Running
spec/workers
only - All specs pass on CI
On 20 nodes
- Run
knapsack rspec
without a file filter - The spec fails
Edited by Timothy Andrew - Can't reproduce locally.
- Contributor
I can reproduce locally by running:
bundle exec rspec spec/features/notes_on_merge_requests_spec.rb spec/models/merge_request_spec.rb spec/features/admin/admin_users_spec.rb spec/features/issues/award_emoji_spec.rb spec/models/commit_spec.rb spec/requests/api/builds_spec.rb spec/features/task_lists_spec.rb spec/lib/banzai/reference_parser/base_parser_spec.rb spec/features/tags/master_creates_tag_spec.rb spec/controllers/projects/branches_controller_spec.rb spec/workers/emails_on_push_worker_spec.rb spec/requests/api/fork_spec.rb spec/services/ci/register_build_service_spec.rb spec/workers/repository_check/single_repository_worker_spec.rb spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb spec/lib/gitlab/gfm/uploads_rewriter_spec.rb spec/models/key_spec.rb spec/helpers/application_helper_spec.rb spec/features/security/admin_access_spec.rb spec/features/issues/note_polling_spec.rb spec/models/project_services/asana_service_spec.rb spec/controllers/groups/milestones_controller_spec.rb spec/controllers/namespaces_controller_spec.rb spec/requests/api/session_spec.rb spec/controllers/projects/repositories_controller_spec.rb spec/lib/disable_email_interceptor_spec.rb spec/lib/banzai/reference_parser/label_parser_spec.rb spec/lib/banzai/reference_parser/milestone_parser_spec.rb spec/lib/gitlab/metrics/instrumentation_spec.rb spec/routing/project_routing_spec.rb spec/controllers/projects/commits_controller_spec.rb spec/models/project_services/buildkite_service_spec.rb spec/views/help/index.html.haml_spec.rb spec/lib/gitlab/sherlock/query_spec.rb spec/lib/gitlab/github_import/hook_formatter_spec.rb spec/helpers/runners_helper_spec.rb spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb spec/lib/json_web_token/token_spec.rb spec/lib/gitlab_spec.rb spec/lib/gitlab/metrics/subscribers/action_view_spec.rb
Which I think is basically what the worker is running. Is that right, @ayufan?
- Author Contributor
@ayufan @smcgivern: Narrowed it down to this, which fails locally:
spring rspec spec/workers/emails_on_push_worker_spec.rb spec/lib/disable_email_interceptor_spec.rb
(edit: Got to this by running
Set#intersection
on two sets of files, each from a different failing run on CI, and manually pruning that list)Edited by Timothy Andrew - Contributor
Looks like that other spec removes all interceptors (including premailer).
- Contributor
Changing that to do:
Mail.class_variable_get(:@@delivery_interceptors).delete(DisableEmailInterceptor)
Fixes it for me. @timothyandrew are you doing that or do you want me to?
- Author Contributor
@smcgivern: This fixes it for me as well.
I can wrap it up, since I started.
Do you have a preference between storing a list of interceptors and restoring it, v/s deleting a specific interceptor? - Contributor
I think we can use Mail API
Mail.register_interceptor(DisableEmailInterceptor) # and Mail.unregister_interceptor(DisableEmailInterceptor)
Edited by Paco Guzman - Author Contributor
@pacoguzman Great, I like that!
- Douwe Maan Status changed to closed by merge request !4582 (merged)
Status changed to closed by merge request !4582 (merged)
- Douwe Maan mentioned in commit e0f3e44b
mentioned in commit e0f3e44b
- Douwe Maan Mentioned in commit aebrow4/gitlab-development-kit@e0f3e44b
Mentioned in commit aebrow4/gitlab-development-kit@e0f3e44b