Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
4e5a9838
Commit
4e5a9838
authored
Mar 01, 2019
by
João Cunha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor subbed_worker calls
- Creates a support/helper file and moves all the duplication defs into it
parent
04496085
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
49 additions
and
76 deletions
+49
-76
spec/migrations/migrate_cluster_configure_worker_sidekiq_queue_spec.rb
...ns/migrate_cluster_configure_worker_sidekiq_queue_spec.rb
+10
-16
spec/migrations/migrate_create_trace_artifact_sidekiq_queue_spec.rb
...tions/migrate_create_trace_artifact_sidekiq_queue_spec.rb
+9
-15
spec/migrations/migrate_object_storage_upload_sidekiq_queue_spec.rb
...tions/migrate_object_storage_upload_sidekiq_queue_spec.rb
+3
-9
spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb
spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb
+7
-13
spec/migrations/migrate_storage_migrator_sidekiq_queue_spec.rb
...migrations/migrate_storage_migrator_sidekiq_queue_spec.rb
+3
-9
spec/migrations/migrate_update_head_pipeline_for_merge_request_sidekiq_queue_spec.rb
...ate_head_pipeline_for_merge_request_sidekiq_queue_spec.rb
+8
-14
spec/support/helpers/stub_worker.rb
spec/support/helpers/stub_worker.rb
+9
-0
No files found.
spec/migrations/migrate_cluster_configure_worker_sidekiq_queue_spec.rb
View file @
4e5a9838
...
...
@@ -3,12 +3,13 @@ require Rails.root.join('db', 'post_migrate', '20181219145520_migrate_cluster_co
describe
MigrateClusterConfigureWorkerSidekiqQueue
,
:sidekiq
,
:redis
do
include
Gitlab
::
Database
::
MigrationHelpers
include
StubWorker
context
'when there are jobs in the queue'
do
it
'correctly migrates queue when migrating up'
do
Sidekiq
::
Testing
.
disable!
do
stub
bed
_worker
(
queue:
'gcp_cluster:cluster_platform_configure'
).
perform_async
(
'Something'
,
[
1
])
stub
bed
_worker
(
queue:
'gcp_cluster:cluster_configure'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'gcp_cluster:cluster_platform_configure'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'gcp_cluster:cluster_configure'
).
perform_async
(
'Something'
,
[
1
])
described_class
.
new
.
up
...
...
@@ -19,12 +20,12 @@ describe MigrateClusterConfigureWorkerSidekiqQueue, :sidekiq, :redis do
it
'does not affect other queues under the same namespace'
do
Sidekiq
::
Testing
.
disable!
do
stub
bed
_worker
(
queue:
'gcp_cluster:cluster_install_app'
).
perform_async
(
'Something'
,
[
1
])
stub
bed
_worker
(
queue:
'gcp_cluster:cluster_provision'
).
perform_async
(
'Something'
,
[
1
])
stub
bed
_worker
(
queue:
'gcp_cluster:cluster_wait_for_app_installation'
).
perform_async
(
'Something'
,
[
1
])
stub
bed
_worker
(
queue:
'gcp_cluster:wait_for_cluster_creation'
).
perform_async
(
'Something'
,
[
1
])
stub
bed
_worker
(
queue:
'gcp_cluster:cluster_wait_for_ingress_ip_address'
).
perform_async
(
'Something'
,
[
1
])
stub
bed
_worker
(
queue:
'gcp_cluster:cluster_project_configure'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'gcp_cluster:cluster_install_app'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'gcp_cluster:cluster_provision'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'gcp_cluster:cluster_wait_for_app_installation'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'gcp_cluster:wait_for_cluster_creation'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'gcp_cluster:cluster_wait_for_ingress_ip_address'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'gcp_cluster:cluster_project_configure'
).
perform_async
(
'Something'
,
[
1
])
described_class
.
new
.
up
...
...
@@ -39,7 +40,7 @@ describe MigrateClusterConfigureWorkerSidekiqQueue, :sidekiq, :redis do
it
'correctly migrates queue when migrating down'
do
Sidekiq
::
Testing
.
disable!
do
stub
bed
_worker
(
queue:
'gcp_cluster:cluster_configure'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'gcp_cluster:cluster_configure'
).
perform_async
(
'Something'
,
[
1
])
described_class
.
new
.
down
...
...
@@ -58,11 +59,4 @@ describe MigrateClusterConfigureWorkerSidekiqQueue, :sidekiq, :redis do
expect
{
described_class
.
new
.
down
}.
not_to
raise_error
end
end
def
stubbed_worker
(
queue
:)
Class
.
new
do
include
Sidekiq
::
Worker
sidekiq_options
queue:
queue
end
end
end
spec/migrations/migrate_create_trace_artifact_sidekiq_queue_spec.rb
View file @
4e5a9838
...
...
@@ -3,12 +3,13 @@ require Rails.root.join('db', 'post_migrate', '20180306074045_migrate_create_tra
describe
MigrateCreateTraceArtifactSidekiqQueue
,
:sidekiq
,
:redis
do
include
Gitlab
::
Database
::
MigrationHelpers
include
StubWorker
context
'when there are jobs in the queues'
do
it
'correctly migrates queue when migrating up'
do
Sidekiq
::
Testing
.
disable!
do
stub
bed
_worker
(
queue:
'pipeline_default:create_trace_artifact'
).
perform_async
(
'Something'
,
[
1
])
stub
bed
_worker
(
queue:
'pipeline_background:archive_trace'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'pipeline_default:create_trace_artifact'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'pipeline_background:archive_trace'
).
perform_async
(
'Something'
,
[
1
])
described_class
.
new
.
up
...
...
@@ -19,11 +20,11 @@ describe MigrateCreateTraceArtifactSidekiqQueue, :sidekiq, :redis do
it
'does not affect other queues under the same namespace'
do
Sidekiq
::
Testing
.
disable!
do
stub
bed
_worker
(
queue:
'pipeline_default:build_coverage'
).
perform_async
(
'Something'
,
[
1
])
stub
bed
_worker
(
queue:
'pipeline_default:build_trace_sections'
).
perform_async
(
'Something'
,
[
1
])
stub
bed
_worker
(
queue:
'pipeline_default:pipeline_metrics'
).
perform_async
(
'Something'
,
[
1
])
stub
bed
_worker
(
queue:
'pipeline_default:pipeline_notification'
).
perform_async
(
'Something'
,
[
1
])
stub
bed
_worker
(
queue:
'pipeline_default:update_head_pipeline_for_merge_request'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'pipeline_default:build_coverage'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'pipeline_default:build_trace_sections'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'pipeline_default:pipeline_metrics'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'pipeline_default:pipeline_notification'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'pipeline_default:update_head_pipeline_for_merge_request'
).
perform_async
(
'Something'
,
[
1
])
described_class
.
new
.
up
...
...
@@ -37,7 +38,7 @@ describe MigrateCreateTraceArtifactSidekiqQueue, :sidekiq, :redis do
it
'correctly migrates queue when migrating down'
do
Sidekiq
::
Testing
.
disable!
do
stub
bed
_worker
(
queue:
'pipeline_background:archive_trace'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'pipeline_background:archive_trace'
).
perform_async
(
'Something'
,
[
1
])
described_class
.
new
.
down
...
...
@@ -56,11 +57,4 @@ describe MigrateCreateTraceArtifactSidekiqQueue, :sidekiq, :redis do
expect
{
described_class
.
new
.
down
}.
not_to
raise_error
end
end
def
stubbed_worker
(
queue
:)
Class
.
new
do
include
Sidekiq
::
Worker
sidekiq_options
queue:
queue
end
end
end
spec/migrations/migrate_object_storage_upload_sidekiq_queue_spec.rb
View file @
4e5a9838
...
...
@@ -3,12 +3,13 @@ require Rails.root.join('db', 'post_migrate', '20180603190921_migrate_object_sto
describe
MigrateObjectStorageUploadSidekiqQueue
,
:sidekiq
,
:redis
do
include
Gitlab
::
Database
::
MigrationHelpers
include
StubWorker
context
'when there are jobs in the queue'
do
it
'correctly migrates queue when migrating up'
do
Sidekiq
::
Testing
.
disable!
do
stub
bed
_worker
(
queue:
'object_storage_upload'
).
perform_async
(
'Something'
,
[
1
])
stub
bed
_worker
(
queue:
'object_storage:object_storage_background_move'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'object_storage_upload'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'object_storage:object_storage_background_move'
).
perform_async
(
'Something'
,
[
1
])
described_class
.
new
.
up
...
...
@@ -23,11 +24,4 @@ describe MigrateObjectStorageUploadSidekiqQueue, :sidekiq, :redis do
expect
{
described_class
.
new
.
up
}.
not_to
raise_error
end
end
def
stubbed_worker
(
queue
:)
Class
.
new
do
include
Sidekiq
::
Worker
sidekiq_options
queue:
queue
end
end
end
spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb
View file @
4e5a9838
...
...
@@ -3,12 +3,13 @@ require Rails.root.join('db', 'post_migrate', '20170822101017_migrate_pipeline_s
describe
MigratePipelineSidekiqQueues
,
:sidekiq
,
:redis
do
include
Gitlab
::
Database
::
MigrationHelpers
include
StubWorker
context
'when there are jobs in the queues'
do
it
'correctly migrates queue when migrating up'
do
Sidekiq
::
Testing
.
disable!
do
stub
bed
_worker
(
queue: :pipeline
).
perform_async
(
'Something'
,
[
1
])
stub
bed
_worker
(
queue: :build
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue: :pipeline
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue: :build
).
perform_async
(
'Something'
,
[
1
])
described_class
.
new
.
up
...
...
@@ -20,10 +21,10 @@ describe MigratePipelineSidekiqQueues, :sidekiq, :redis do
it
'correctly migrates queue when migrating down'
do
Sidekiq
::
Testing
.
disable!
do
stub
bed
_worker
(
queue: :pipeline_default
).
perform_async
(
'Class'
,
[
1
])
stub
bed
_worker
(
queue: :pipeline_processing
).
perform_async
(
'Class'
,
[
2
])
stub
bed
_worker
(
queue: :pipeline_hooks
).
perform_async
(
'Class'
,
[
3
])
stub
bed
_worker
(
queue: :pipeline_cache
).
perform_async
(
'Class'
,
[
4
])
stub_worker
(
queue: :pipeline_default
).
perform_async
(
'Class'
,
[
1
])
stub_worker
(
queue: :pipeline_processing
).
perform_async
(
'Class'
,
[
2
])
stub_worker
(
queue: :pipeline_hooks
).
perform_async
(
'Class'
,
[
3
])
stub_worker
(
queue: :pipeline_cache
).
perform_async
(
'Class'
,
[
4
])
described_class
.
new
.
down
...
...
@@ -45,11 +46,4 @@ describe MigratePipelineSidekiqQueues, :sidekiq, :redis do
expect
{
described_class
.
new
.
down
}.
not_to
raise_error
end
end
def
stubbed_worker
(
queue
:)
Class
.
new
do
include
Sidekiq
::
Worker
sidekiq_options
queue:
queue
end
end
end
spec/migrations/migrate_storage_migrator_sidekiq_queue_spec.rb
View file @
4e5a9838
...
...
@@ -3,11 +3,12 @@ require Rails.root.join('db', 'post_migrate', '20190124200344_migrate_storage_mi
describe
MigrateStorageMigratorSidekiqQueue
,
:sidekiq
,
:redis
do
include
Gitlab
::
Database
::
MigrationHelpers
include
StubWorker
context
'when there are jobs in the queues'
do
it
'correctly migrates queue when migrating up'
do
Sidekiq
::
Testing
.
disable!
do
stub
bed
_worker
(
queue: :storage_migrator
).
perform_async
(
1
,
5
)
stub_worker
(
queue: :storage_migrator
).
perform_async
(
1
,
5
)
described_class
.
new
.
up
...
...
@@ -18,7 +19,7 @@ describe MigrateStorageMigratorSidekiqQueue, :sidekiq, :redis do
it
'correctly migrates queue when migrating down'
do
Sidekiq
::
Testing
.
disable!
do
stub
bed
_worker
(
queue: :'hashed_storage:hashed_storage_migrator'
).
perform_async
(
1
,
5
)
stub_worker
(
queue: :'hashed_storage:hashed_storage_migrator'
).
perform_async
(
1
,
5
)
described_class
.
new
.
down
...
...
@@ -37,11 +38,4 @@ describe MigrateStorageMigratorSidekiqQueue, :sidekiq, :redis do
expect
{
described_class
.
new
.
down
}.
not_to
raise_error
end
end
def
stubbed_worker
(
queue
:)
Class
.
new
do
include
Sidekiq
::
Worker
sidekiq_options
queue:
queue
end
end
end
spec/migrations/migrate_update_head_pipeline_for_merge_request_sidekiq_queue_spec.rb
View file @
4e5a9838
...
...
@@ -3,12 +3,13 @@ require Rails.root.join('db', 'post_migrate', '20180307012445_migrate_update_hea
describe
MigrateUpdateHeadPipelineForMergeRequestSidekiqQueue
,
:sidekiq
,
:redis
do
include
Gitlab
::
Database
::
MigrationHelpers
include
StubWorker
context
'when there are jobs in the queues'
do
it
'correctly migrates queue when migrating up'
do
Sidekiq
::
Testing
.
disable!
do
stub
bed
_worker
(
queue:
'pipeline_default:update_head_pipeline_for_merge_request'
).
perform_async
(
'Something'
,
[
1
])
stub
bed
_worker
(
queue:
'pipeline_processing:update_head_pipeline_for_merge_request'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'pipeline_default:update_head_pipeline_for_merge_request'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'pipeline_processing:update_head_pipeline_for_merge_request'
).
perform_async
(
'Something'
,
[
1
])
described_class
.
new
.
up
...
...
@@ -19,10 +20,10 @@ describe MigrateUpdateHeadPipelineForMergeRequestSidekiqQueue, :sidekiq, :redis
it
'does not affect other queues under the same namespace'
do
Sidekiq
::
Testing
.
disable!
do
stub
bed
_worker
(
queue:
'pipeline_default:build_coverage'
).
perform_async
(
'Something'
,
[
1
])
stub
bed
_worker
(
queue:
'pipeline_default:build_trace_sections'
).
perform_async
(
'Something'
,
[
1
])
stub
bed
_worker
(
queue:
'pipeline_default:pipeline_metrics'
).
perform_async
(
'Something'
,
[
1
])
stub
bed
_worker
(
queue:
'pipeline_default:pipeline_notification'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'pipeline_default:build_coverage'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'pipeline_default:build_trace_sections'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'pipeline_default:pipeline_metrics'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'pipeline_default:pipeline_notification'
).
perform_async
(
'Something'
,
[
1
])
described_class
.
new
.
up
...
...
@@ -35,7 +36,7 @@ describe MigrateUpdateHeadPipelineForMergeRequestSidekiqQueue, :sidekiq, :redis
it
'correctly migrates queue when migrating down'
do
Sidekiq
::
Testing
.
disable!
do
stub
bed
_worker
(
queue:
'pipeline_processing:update_head_pipeline_for_merge_request'
).
perform_async
(
'Something'
,
[
1
])
stub_worker
(
queue:
'pipeline_processing:update_head_pipeline_for_merge_request'
).
perform_async
(
'Something'
,
[
1
])
described_class
.
new
.
down
...
...
@@ -54,11 +55,4 @@ describe MigrateUpdateHeadPipelineForMergeRequestSidekiqQueue, :sidekiq, :redis
expect
{
described_class
.
new
.
down
}.
not_to
raise_error
end
end
def
stubbed_worker
(
queue
:)
Class
.
new
do
include
Sidekiq
::
Worker
sidekiq_options
queue:
queue
end
end
end
spec/support/helpers/stub_worker.rb
0 → 100644
View file @
4e5a9838
# Inspired by https://github.com/ljkbennett/stub_env/blob/master/lib/stub_env/helpers.rb
module
StubWorker
def
stub_worker
(
queue
:)
Class
.
new
do
include
Sidekiq
::
Worker
sidekiq_options
queue:
queue
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment