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
824af79d
Commit
824af79d
authored
Feb 28, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix rake task to use corrrect SQL
parent
91117452
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
5 deletions
+59
-5
lib/tasks/gitlab/traces.rake
lib/tasks/gitlab/traces.rake
+4
-5
spec/tasks/gitlab/traces_rake_spec.rb
spec/tasks/gitlab/traces_rake_spec.rb
+55
-0
No files found.
lib/tasks/gitlab/traces.rake
View file @
824af79d
...
...
@@ -8,17 +8,16 @@ namespace :gitlab do
logger
=
Logger
.
new
(
STDOUT
)
logger
.
info
(
'Archiving legacy traces'
)
Ci
::
Build
.
joins
(
'RIGHT JOIN ci_job_artifacts ON ci_job_artifacts.job_id = ci_builds.id'
)
.
finished
.
where
(
'ci_job_artifacts.file_type <> 3'
)
.
group
(
'ci_builds.id'
)
Ci
::
Build
.
finished
.
where
(
'NOT EXISTS (?)'
,
Ci
::
JobArtifact
.
select
(
1
).
trace
.
where
(
'ci_builds.id = ci_job_artifacts.job_id'
))
.
order
(
id: :asc
)
.
find_in_batches
(
batch_size:
1000
)
do
|
jobs
|
job_ids
=
jobs
.
map
{
|
job
|
[
job
.
id
]
}
ArchiveLegacyTraceWorker
.
bulk_perform_async
(
job_ids
)
logger
.
info
(
"Scheduled
#{
job_ids
.
count
}
jobs. From
#{
job_ids
.
min
}
#{
job_ids
.
max
}
"
)
logger
.
info
(
"Scheduled
#{
job_ids
.
count
}
jobs. From
#{
job_ids
.
min
}
to
#{
job_ids
.
max
}
"
)
end
end
end
...
...
spec/tasks/gitlab/traces_rake_spec.rb
0 → 100644
View file @
824af79d
require
'rake_helper'
describe
'gitlab:traces rake tasks'
do
before
do
Rake
.
application
.
rake_require
'tasks/gitlab/traces'
end
shared_examples
'passes the job id to worker'
do
it
do
expect
(
ArchiveLegacyTraceWorker
).
to
receive
(
:bulk_perform_async
).
with
([[
job
.
id
]])
run_rake_task
(
'gitlab:traces:archive'
)
end
end
shared_examples
'does not pass the job id to worker'
do
it
do
expect
(
ArchiveLegacyTraceWorker
).
not_to
receive
(
:bulk_perform_async
)
run_rake_task
(
'gitlab:traces:archive'
)
end
end
context
'when trace file stored in default path'
do
let!
(
:job
)
{
create
(
:ci_build
,
:success
,
:trace_live
)
}
it_behaves_like
'passes the job id to worker'
end
context
'when trace is stored in database'
do
let!
(
:job
)
{
create
(
:ci_build
,
:success
)
}
before
do
job
.
update_column
(
:trace
,
'trace in db'
)
end
it_behaves_like
'passes the job id to worker'
end
context
'when job has trace artifact'
do
let!
(
:job
)
{
create
(
:ci_build
,
:success
)
}
before
do
create
(
:ci_job_artifact
,
:trace
,
job:
job
)
end
it_behaves_like
'does not pass the job id to worker'
end
context
'when job is not finished yet'
do
let!
(
:build
)
{
create
(
:ci_build
,
:running
,
:trace_live
)
}
it_behaves_like
'does not pass the job id to worker'
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