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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
bf306df3
Commit
bf306df3
authored
Jun 23, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Time.now => Time.current
- Update usage - Update specs
parent
90051967
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
39 additions
and
39 deletions
+39
-39
app/workers/concerns/reenqueuer.rb
app/workers/concerns/reenqueuer.rb
+2
-2
app/workers/gitlab/jira_import/import_issue_worker.rb
app/workers/gitlab/jira_import/import_issue_worker.rb
+1
-1
app/workers/process_commit_worker.rb
app/workers/process_commit_worker.rb
+1
-1
app/workers/repository_check/batch_worker.rb
app/workers/repository_check/batch_worker.rb
+2
-2
app/workers/repository_check/single_repository_worker.rb
app/workers/repository_check/single_repository_worker.rb
+1
-1
ee/app/workers/geo/repository_shard_sync_worker.rb
ee/app/workers/geo/repository_shard_sync_worker.rb
+2
-2
ee/app/workers/geo/scheduler/scheduler_worker.rb
ee/app/workers/geo/scheduler/scheduler_worker.rb
+4
-4
ee/app/workers/update_all_mirrors_worker.rb
ee/app/workers/update_all_mirrors_worker.rb
+3
-3
ee/spec/workers/ci/batch_reset_minutes_worker_spec.rb
ee/spec/workers/ci/batch_reset_minutes_worker_spec.rb
+2
-2
ee/spec/workers/clear_shared_runners_minutes_worker_spec.rb
ee/spec/workers/clear_shared_runners_minutes_worker_spec.rb
+3
-3
spec/workers/cluster_update_app_worker_spec.rb
spec/workers/cluster_update_app_worker_spec.rb
+9
-9
spec/workers/expire_build_instance_artifacts_worker_spec.rb
spec/workers/expire_build_instance_artifacts_worker_spec.rb
+1
-1
spec/workers/pipeline_metrics_worker_spec.rb
spec/workers/pipeline_metrics_worker_spec.rb
+1
-1
spec/workers/pipeline_schedule_worker_spec.rb
spec/workers/pipeline_schedule_worker_spec.rb
+1
-1
spec/workers/process_commit_worker_spec.rb
spec/workers/process_commit_worker_spec.rb
+1
-1
spec/workers/repository_check/clear_worker_spec.rb
spec/workers/repository_check/clear_worker_spec.rb
+1
-1
spec/workers/repository_update_remote_mirror_worker_spec.rb
spec/workers/repository_update_remote_mirror_worker_spec.rb
+4
-4
No files found.
app/workers/concerns/reenqueuer.rb
View file @
bf306df3
...
@@ -73,7 +73,7 @@ module Reenqueuer
...
@@ -73,7 +73,7 @@ module Reenqueuer
# end
# end
#
#
def
ensure_minimum_duration
(
minimum_duration
)
def
ensure_minimum_duration
(
minimum_duration
)
start_time
=
Time
.
now
start_time
=
Time
.
current
result
=
yield
result
=
yield
...
@@ -95,7 +95,7 @@ module Reenqueuer
...
@@ -95,7 +95,7 @@ module Reenqueuer
end
end
def
elapsed_time
(
start_time
)
def
elapsed_time
(
start_time
)
Time
.
now
-
start_time
Time
.
current
-
start_time
end
end
end
end
end
end
app/workers/gitlab/jira_import/import_issue_worker.rb
View file @
bf306df3
...
@@ -62,7 +62,7 @@ module Gitlab
...
@@ -62,7 +62,7 @@ module Gitlab
end
end
def
build_label_attrs
(
issue_id
,
label_id
)
def
build_label_attrs
(
issue_id
,
label_id
)
time
=
Time
.
now
time
=
Time
.
current
{
{
label_id:
label_id
,
label_id:
label_id
,
target_id:
issue_id
,
target_id:
issue_id
,
...
...
app/workers/process_commit_worker.rb
View file @
bf306df3
...
@@ -80,7 +80,7 @@ class ProcessCommitWorker
...
@@ -80,7 +80,7 @@ class ProcessCommitWorker
# manually parse these values.
# manually parse these values.
hash
.
each
do
|
key
,
value
|
hash
.
each
do
|
key
,
value
|
if
key
.
to_s
.
end_with?
(
date_suffix
)
&&
value
.
is_a?
(
String
)
if
key
.
to_s
.
end_with?
(
date_suffix
)
&&
value
.
is_a?
(
String
)
hash
[
key
]
=
Time
.
parse
(
value
)
hash
[
key
]
=
Time
.
zone
.
parse
(
value
)
end
end
end
end
...
...
app/workers/repository_check/batch_worker.rb
View file @
bf306df3
...
@@ -34,7 +34,7 @@ module RepositoryCheck
...
@@ -34,7 +34,7 @@ module RepositoryCheck
end
end
def
perform_repository_checks
def
perform_repository_checks
start
=
Time
.
now
start
=
Time
.
current
# This loop will break after a little more than one hour ('a little
# This loop will break after a little more than one hour ('a little
# more' because `git fsck` may take a few minutes), or if it runs out of
# more' because `git fsck` may take a few minutes), or if it runs out of
...
@@ -42,7 +42,7 @@ module RepositoryCheck
...
@@ -42,7 +42,7 @@ module RepositoryCheck
# RepositoryCheckWorker each hour so that as long as there are repositories to
# RepositoryCheckWorker each hour so that as long as there are repositories to
# check, only one (or two) will be checked at a time.
# check, only one (or two) will be checked at a time.
project_ids
.
each
do
|
project_id
|
project_ids
.
each
do
|
project_id
|
break
if
Time
.
now
-
start
>=
RUN_TIME
break
if
Time
.
current
-
start
>=
RUN_TIME
next
unless
try_obtain_lease_for_project
(
project_id
)
next
unless
try_obtain_lease_for_project
(
project_id
)
...
...
app/workers/repository_check/single_repository_worker.rb
View file @
bf306df3
...
@@ -17,7 +17,7 @@ module RepositoryCheck
...
@@ -17,7 +17,7 @@ module RepositoryCheck
def
update_repository_check_status
(
project
,
healthy
)
def
update_repository_check_status
(
project
,
healthy
)
project
.
update_columns
(
project
.
update_columns
(
last_repository_check_failed:
!
healthy
,
last_repository_check_failed:
!
healthy
,
last_repository_check_at:
Time
.
now
last_repository_check_at:
Time
.
current
)
)
end
end
...
...
ee/app/workers/geo/repository_shard_sync_worker.rb
View file @
bf306df3
...
@@ -49,8 +49,8 @@ module Geo
...
@@ -49,8 +49,8 @@ module Geo
job_id
=
Geo
::
ProjectSyncWorker
.
perform_async
(
job_id
=
Geo
::
ProjectSyncWorker
.
perform_async
(
project_id
,
project_id
,
sync_repository:
registry
.
repository_sync_due?
(
Time
.
now
),
sync_repository:
registry
.
repository_sync_due?
(
Time
.
current
),
sync_wiki:
registry
.
wiki_sync_due?
(
Time
.
now
)
sync_wiki:
registry
.
wiki_sync_due?
(
Time
.
current
)
)
)
{
project_id:
project_id
,
job_id:
job_id
}
if
job_id
{
project_id:
project_id
,
job_id:
job_id
}
if
job_id
...
...
ee/app/workers/geo/scheduler/scheduler_worker.rb
View file @
bf306df3
...
@@ -30,7 +30,7 @@ module Geo
...
@@ -30,7 +30,7 @@ module Geo
# remaining jobs, excluding ones in progress.
# remaining jobs, excluding ones in progress.
# 5. Quit when we have scheduled all jobs or exceeded MAX_RUNTIME.
# 5. Quit when we have scheduled all jobs or exceeded MAX_RUNTIME.
def
perform
def
perform
@start_time
=
Time
.
now
.
utc
@start_time
=
Time
.
current
.
utc
@loops
=
0
@loops
=
0
# Prevent multiple Sidekiq workers from attempting to schedule jobs
# Prevent multiple Sidekiq workers from attempting to schedule jobs
...
@@ -65,7 +65,7 @@ module Geo
...
@@ -65,7 +65,7 @@ module Geo
log_error
(
err
.
message
)
log_error
(
err
.
message
)
raise
err
raise
err
ensure
ensure
duration
=
Time
.
now
.
utc
-
start_time
duration
=
Time
.
current
.
utc
-
start_time
log_info
(
'Finished scheduler'
,
total_loops:
loops
,
duration:
duration
,
reason:
reason
)
log_info
(
'Finished scheduler'
,
total_loops:
loops
,
duration:
duration
,
reason:
reason
)
end
end
end
end
...
@@ -108,7 +108,7 @@ module Geo
...
@@ -108,7 +108,7 @@ module Geo
end
end
def
over_time?
def
over_time?
(
Time
.
now
.
utc
-
start_time
)
>=
run_time
(
Time
.
current
.
utc
-
start_time
)
>=
run_time
end
end
def
should_apply_backoff?
def
should_apply_backoff?
...
@@ -198,7 +198,7 @@ module Geo
...
@@ -198,7 +198,7 @@ module Geo
def
node_enabled?
def
node_enabled?
# Only check every minute to avoid polling the DB excessively
# Only check every minute to avoid polling the DB excessively
unless
@last_enabled_check
.
present?
&&
@last_enabled_check
>
1
.
minute
.
ago
unless
@last_enabled_check
.
present?
&&
@last_enabled_check
>
1
.
minute
.
ago
@last_enabled_check
=
Time
.
now
@last_enabled_check
=
Time
.
current
clear_memoization
(
:current_node_enabled
)
clear_memoization
(
:current_node_enabled
)
end
end
...
...
ee/app/workers/update_all_mirrors_worker.rb
View file @
bf306df3
...
@@ -38,7 +38,7 @@ class UpdateAllMirrorsWorker # rubocop:disable Scalability/IdempotentWorker
...
@@ -38,7 +38,7 @@ class UpdateAllMirrorsWorker # rubocop:disable Scalability/IdempotentWorker
# Ignore mirrors that become due for scheduling once work begins, so we
# Ignore mirrors that become due for scheduling once work begins, so we
# can't end up in an infinite loop
# can't end up in an infinite loop
now
=
Time
.
now
now
=
Time
.
current
last
=
nil
last
=
nil
scheduled
=
0
scheduled
=
0
...
@@ -73,8 +73,8 @@ class UpdateAllMirrorsWorker # rubocop:disable Scalability/IdempotentWorker
...
@@ -73,8 +73,8 @@ class UpdateAllMirrorsWorker # rubocop:disable Scalability/IdempotentWorker
if
scheduled
>
0
if
scheduled
>
0
# Wait for all ProjectImportScheduleWorker jobs to complete
# Wait for all ProjectImportScheduleWorker jobs to complete
deadline
=
Time
.
now
+
SCHEDULE_WAIT_TIMEOUT
deadline
=
Time
.
current
+
SCHEDULE_WAIT_TIMEOUT
sleep
1
while
ProjectImportScheduleWorker
.
queue_size
>
0
&&
Time
.
now
<
deadline
sleep
1
while
ProjectImportScheduleWorker
.
queue_size
>
0
&&
Time
.
current
<
deadline
end
end
scheduled
scheduled
...
...
ee/spec/workers/ci/batch_reset_minutes_worker_spec.rb
View file @
bf306df3
...
@@ -11,7 +11,7 @@ RSpec.describe Ci::BatchResetMinutesWorker do
...
@@ -11,7 +11,7 @@ RSpec.describe Ci::BatchResetMinutesWorker do
id:
1
,
id:
1
,
shared_runners_minutes_limit:
100
,
shared_runners_minutes_limit:
100
,
extra_shared_runners_minutes_limit:
50
,
extra_shared_runners_minutes_limit:
50
,
last_ci_minutes_notification_at:
Time
.
now
,
last_ci_minutes_notification_at:
Time
.
current
,
last_ci_minutes_usage_notification_level:
30
)
last_ci_minutes_usage_notification_level:
30
)
end
end
...
@@ -20,7 +20,7 @@ RSpec.describe Ci::BatchResetMinutesWorker do
...
@@ -20,7 +20,7 @@ RSpec.describe Ci::BatchResetMinutesWorker do
id:
10
,
id:
10
,
shared_runners_minutes_limit:
100
,
shared_runners_minutes_limit:
100
,
extra_shared_runners_minutes_limit:
50
,
extra_shared_runners_minutes_limit:
50
,
last_ci_minutes_notification_at:
Time
.
now
,
last_ci_minutes_notification_at:
Time
.
current
,
last_ci_minutes_usage_notification_level:
30
)
last_ci_minutes_usage_notification_level:
30
)
end
end
...
...
ee/spec/workers/clear_shared_runners_minutes_worker_spec.rb
View file @
bf306df3
...
@@ -36,7 +36,7 @@ RSpec.describe ClearSharedRunnersMinutesWorker do
...
@@ -36,7 +36,7 @@ RSpec.describe ClearSharedRunnersMinutesWorker do
it
'resets timer'
do
it
'resets timer'
do
subject
subject
expect
(
statistics
.
reload
.
shared_runners_seconds_last_reset
).
to
be_like_time
(
Time
.
now
)
expect
(
statistics
.
reload
.
shared_runners_seconds_last_reset
).
to
be_like_time
(
Time
.
current
)
end
end
context
'when there are namespaces that were not reset after the reset steps'
do
context
'when there are namespaces that were not reset after the reset steps'
do
...
@@ -68,7 +68,7 @@ RSpec.describe ClearSharedRunnersMinutesWorker do
...
@@ -68,7 +68,7 @@ RSpec.describe ClearSharedRunnersMinutesWorker do
it
'resets timer'
do
it
'resets timer'
do
subject
subject
expect
(
statistics
.
reload
.
shared_runners_seconds_last_reset
).
to
be_like_time
(
Time
.
now
)
expect
(
statistics
.
reload
.
shared_runners_seconds_last_reset
).
to
be_like_time
(
Time
.
current
)
end
end
end
end
...
@@ -118,7 +118,7 @@ RSpec.describe ClearSharedRunnersMinutesWorker do
...
@@ -118,7 +118,7 @@ RSpec.describe ClearSharedRunnersMinutesWorker do
[
:last_ci_minutes_notification_at
,
:last_ci_minutes_usage_notification_level
].
each
do
|
attr
|
[
:last_ci_minutes_notification_at
,
:last_ci_minutes_usage_notification_level
].
each
do
|
attr
|
context
"when
#{
attr
}
is present"
do
context
"when
#{
attr
}
is present"
do
before
do
before
do
namespace
.
update_attribute
(
attr
,
Time
.
now
)
namespace
.
update_attribute
(
attr
,
Time
.
current
)
end
end
it
'nullifies the field'
do
it
'nullifies the field'
do
...
...
spec/workers/cluster_update_app_worker_spec.rb
View file @
bf306df3
...
@@ -12,7 +12,7 @@ describe ClusterUpdateAppWorker do
...
@@ -12,7 +12,7 @@ describe ClusterUpdateAppWorker do
subject
{
described_class
.
new
}
subject
{
described_class
.
new
}
around
do
|
example
|
around
do
|
example
|
Timecop
.
freeze
(
Time
.
now
)
{
example
.
run
}
Timecop
.
freeze
(
Time
.
current
)
{
example
.
run
}
end
end
before
do
before
do
...
@@ -22,11 +22,11 @@ describe ClusterUpdateAppWorker do
...
@@ -22,11 +22,11 @@ describe ClusterUpdateAppWorker do
describe
'#perform'
do
describe
'#perform'
do
context
'when the application last_update_started_at is higher than the time the job was scheduled in'
do
context
'when the application last_update_started_at is higher than the time the job was scheduled in'
do
it
'does nothing'
do
it
'does nothing'
do
application
=
create
(
:clusters_applications_prometheus
,
:updated
,
last_update_started_at:
Time
.
now
)
application
=
create
(
:clusters_applications_prometheus
,
:updated
,
last_update_started_at:
Time
.
current
)
expect
(
prometheus_update_service
).
not_to
receive
(
:execute
)
expect
(
prometheus_update_service
).
not_to
receive
(
:execute
)
expect
(
subject
.
perform
(
application
.
name
,
application
.
id
,
project
.
id
,
Time
.
now
-
5
.
minutes
)).
to
be_nil
expect
(
subject
.
perform
(
application
.
name
,
application
.
id
,
project
.
id
,
Time
.
current
-
5
.
minutes
)).
to
be_nil
end
end
end
end
...
@@ -34,7 +34,7 @@ describe ClusterUpdateAppWorker do
...
@@ -34,7 +34,7 @@ describe ClusterUpdateAppWorker do
it
'returns nil'
do
it
'returns nil'
do
application
=
create
(
:clusters_applications_prometheus
,
:updating
)
application
=
create
(
:clusters_applications_prometheus
,
:updating
)
expect
(
subject
.
perform
(
application
.
name
,
application
.
id
,
project
.
id
,
Time
.
now
)).
to
be_nil
expect
(
subject
.
perform
(
application
.
name
,
application
.
id
,
project
.
id
,
Time
.
current
)).
to
be_nil
end
end
end
end
...
@@ -43,7 +43,7 @@ describe ClusterUpdateAppWorker do
...
@@ -43,7 +43,7 @@ describe ClusterUpdateAppWorker do
expect
(
prometheus_update_service
).
to
receive
(
:execute
)
expect
(
prometheus_update_service
).
to
receive
(
:execute
)
subject
.
perform
(
application
.
name
,
application
.
id
,
project
.
id
,
Time
.
now
)
subject
.
perform
(
application
.
name
,
application
.
id
,
project
.
id
,
Time
.
current
)
end
end
context
'with exclusive lease'
do
context
'with exclusive lease'
do
...
@@ -60,7 +60,7 @@ describe ClusterUpdateAppWorker do
...
@@ -60,7 +60,7 @@ describe ClusterUpdateAppWorker do
it
'does not allow same app to be updated concurrently by same project'
do
it
'does not allow same app to be updated concurrently by same project'
do
expect
(
Clusters
::
Applications
::
PrometheusUpdateService
).
not_to
receive
(
:new
)
expect
(
Clusters
::
Applications
::
PrometheusUpdateService
).
not_to
receive
(
:new
)
subject
.
perform
(
application
.
name
,
application
.
id
,
project
.
id
,
Time
.
now
)
subject
.
perform
(
application
.
name
,
application
.
id
,
project
.
id
,
Time
.
current
)
end
end
it
'does not allow same app to be updated concurrently by different project'
,
:aggregate_failures
do
it
'does not allow same app to be updated concurrently by different project'
,
:aggregate_failures
do
...
@@ -68,7 +68,7 @@ describe ClusterUpdateAppWorker do
...
@@ -68,7 +68,7 @@ describe ClusterUpdateAppWorker do
expect
(
Clusters
::
Applications
::
PrometheusUpdateService
).
not_to
receive
(
:new
)
expect
(
Clusters
::
Applications
::
PrometheusUpdateService
).
not_to
receive
(
:new
)
subject
.
perform
(
application
.
name
,
application
.
id
,
project1
.
id
,
Time
.
now
)
subject
.
perform
(
application
.
name
,
application
.
id
,
project1
.
id
,
Time
.
current
)
end
end
it
'allows different app to be updated concurrently by same project'
do
it
'allows different app to be updated concurrently by same project'
do
...
@@ -80,7 +80,7 @@ describe ClusterUpdateAppWorker do
...
@@ -80,7 +80,7 @@ describe ClusterUpdateAppWorker do
expect
(
Clusters
::
Applications
::
PrometheusUpdateService
).
to
receive
(
:new
)
expect
(
Clusters
::
Applications
::
PrometheusUpdateService
).
to
receive
(
:new
)
.
with
(
application2
,
project
)
.
with
(
application2
,
project
)
subject
.
perform
(
application2
.
name
,
application2
.
id
,
project
.
id
,
Time
.
now
)
subject
.
perform
(
application2
.
name
,
application2
.
id
,
project
.
id
,
Time
.
current
)
end
end
it
'allows different app to be updated by different project'
,
:aggregate_failures
do
it
'allows different app to be updated by different project'
,
:aggregate_failures
do
...
@@ -94,7 +94,7 @@ describe ClusterUpdateAppWorker do
...
@@ -94,7 +94,7 @@ describe ClusterUpdateAppWorker do
expect
(
Clusters
::
Applications
::
PrometheusUpdateService
).
to
receive
(
:new
)
expect
(
Clusters
::
Applications
::
PrometheusUpdateService
).
to
receive
(
:new
)
.
with
(
application2
,
project2
)
.
with
(
application2
,
project2
)
subject
.
perform
(
application2
.
name
,
application2
.
id
,
project2
.
id
,
Time
.
now
)
subject
.
perform
(
application2
.
name
,
application2
.
id
,
project2
.
id
,
Time
.
current
)
end
end
end
end
end
end
...
...
spec/workers/expire_build_instance_artifacts_worker_spec.rb
View file @
bf306df3
...
@@ -32,7 +32,7 @@ describe ExpireBuildInstanceArtifactsWorker do
...
@@ -32,7 +32,7 @@ describe ExpireBuildInstanceArtifactsWorker do
context
'with not yet expired artifacts'
do
context
'with not yet expired artifacts'
do
let_it_be
(
:build
)
do
let_it_be
(
:build
)
do
create
(
:ci_build
,
:artifacts
,
artifacts_expire_at:
Time
.
now
+
7
.
days
)
create
(
:ci_build
,
:artifacts
,
artifacts_expire_at:
Time
.
current
+
7
.
days
)
end
end
it
'does not expire'
do
it
'does not expire'
do
...
...
spec/workers/pipeline_metrics_worker_spec.rb
View file @
bf306df3
...
@@ -18,7 +18,7 @@ describe PipelineMetricsWorker do
...
@@ -18,7 +18,7 @@ describe PipelineMetricsWorker do
ref:
'master'
,
ref:
'master'
,
sha:
project
.
repository
.
commit
(
'master'
).
id
,
sha:
project
.
repository
.
commit
(
'master'
).
id
,
started_at:
1
.
hour
.
ago
,
started_at:
1
.
hour
.
ago
,
finished_at:
Time
.
now
)
finished_at:
Time
.
current
)
end
end
let
(
:status
)
{
'pending'
}
let
(
:status
)
{
'pending'
}
...
...
spec/workers/pipeline_schedule_worker_spec.rb
View file @
bf306df3
...
@@ -33,7 +33,7 @@ describe PipelineScheduleWorker do
...
@@ -33,7 +33,7 @@ describe PipelineScheduleWorker do
expect
(
Ci
::
Pipeline
.
last
).
to
be_schedule
expect
(
Ci
::
Pipeline
.
last
).
to
be_schedule
pipeline_schedule
.
reload
pipeline_schedule
.
reload
expect
(
pipeline_schedule
.
next_run_at
).
to
be
>
Time
.
now
expect
(
pipeline_schedule
.
next_run_at
).
to
be
>
Time
.
current
expect
(
pipeline_schedule
).
to
eq
(
project
.
ci_pipelines
.
last
.
pipeline_schedule
)
expect
(
pipeline_schedule
).
to
eq
(
project
.
ci_pipelines
.
last
.
pipeline_schedule
)
expect
(
pipeline_schedule
).
to
be_active
expect
(
pipeline_schedule
).
to
be_active
end
end
...
...
spec/workers/process_commit_worker_spec.rb
View file @
bf306df3
...
@@ -200,7 +200,7 @@ describe ProcessCommitWorker do
...
@@ -200,7 +200,7 @@ describe ProcessCommitWorker do
it
'parses date strings into Time instances'
do
it
'parses date strings into Time instances'
do
commit
=
worker
.
build_commit
(
project
,
commit
=
worker
.
build_commit
(
project
,
id:
'123'
,
id:
'123'
,
authored_date:
Time
.
now
.
to_s
)
authored_date:
Time
.
current
.
to_s
)
expect
(
commit
.
authored_date
).
to
be_an_instance_of
(
Time
)
expect
(
commit
.
authored_date
).
to
be_an_instance_of
(
Time
)
end
end
...
...
spec/workers/repository_check/clear_worker_spec.rb
View file @
bf306df3
...
@@ -7,7 +7,7 @@ describe RepositoryCheck::ClearWorker do
...
@@ -7,7 +7,7 @@ describe RepositoryCheck::ClearWorker do
project
=
create
(
:project
)
project
=
create
(
:project
)
project
.
update_columns
(
project
.
update_columns
(
last_repository_check_failed:
true
,
last_repository_check_failed:
true
,
last_repository_check_at:
Time
.
now
last_repository_check_at:
Time
.
current
)
)
described_class
.
new
.
perform
described_class
.
new
.
perform
...
...
spec/workers/repository_update_remote_mirror_worker_spec.rb
View file @
bf306df3
...
@@ -6,10 +6,10 @@ describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_state do
...
@@ -6,10 +6,10 @@ describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_state do
subject
{
described_class
.
new
}
subject
{
described_class
.
new
}
let
(
:remote_mirror
)
{
create
(
:remote_mirror
)
}
let
(
:remote_mirror
)
{
create
(
:remote_mirror
)
}
let
(
:scheduled_time
)
{
Time
.
now
-
5
.
minutes
}
let
(
:scheduled_time
)
{
Time
.
current
-
5
.
minutes
}
around
do
|
example
|
around
do
|
example
|
Timecop
.
freeze
(
Time
.
now
)
{
example
.
run
}
Timecop
.
freeze
(
Time
.
current
)
{
example
.
run
}
end
end
def
expect_mirror_service_to_return
(
mirror
,
result
,
tries
=
0
)
def
expect_mirror_service_to_return
(
mirror
,
result
,
tries
=
0
)
...
@@ -26,7 +26,7 @@ describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_state do
...
@@ -26,7 +26,7 @@ describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_state do
end
end
it
'does not do anything if the mirror was already updated'
do
it
'does not do anything if the mirror was already updated'
do
remote_mirror
.
update
(
last_update_started_at:
Time
.
now
,
update_status: :finished
)
remote_mirror
.
update
(
last_update_started_at:
Time
.
current
,
update_status: :finished
)
expect
(
Projects
::
UpdateRemoteMirrorService
).
not_to
receive
(
:new
)
expect
(
Projects
::
UpdateRemoteMirrorService
).
not_to
receive
(
:new
)
...
@@ -48,7 +48,7 @@ describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_state do
...
@@ -48,7 +48,7 @@ describe RepositoryUpdateRemoteMirrorWorker, :clean_gitlab_redis_shared_state do
expect_next_instance_of
(
Projects
::
UpdateRemoteMirrorService
)
do
|
service
|
expect_next_instance_of
(
Projects
::
UpdateRemoteMirrorService
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
).
with
(
remote_mirror
,
1
).
and_raise
(
'Unexpected!'
)
expect
(
service
).
to
receive
(
:execute
).
with
(
remote_mirror
,
1
).
and_raise
(
'Unexpected!'
)
end
end
expect
{
subject
.
perform
(
remote_mirror
.
id
,
Time
.
now
,
1
)
}.
to
raise_error
(
'Unexpected!'
)
expect
{
subject
.
perform
(
remote_mirror
.
id
,
Time
.
current
,
1
)
}.
to
raise_error
(
'Unexpected!'
)
lease
=
Gitlab
::
ExclusiveLease
.
new
(
"
#{
described_class
.
name
}
:
#{
remote_mirror
.
id
}
"
,
timeout:
1
.
second
)
lease
=
Gitlab
::
ExclusiveLease
.
new
(
"
#{
described_class
.
name
}
:
#{
remote_mirror
.
id
}
"
,
timeout:
1
.
second
)
...
...
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