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
Boxiang Sun
gitlab-ce
Commits
53b5346d
Commit
53b5346d
authored
Sep 03, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix spec on egister_job_service_spec.rb
parent
50b9aeb4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
32 deletions
+32
-32
spec/services/ci/register_job_service_spec.rb
spec/services/ci/register_job_service_spec.rb
+32
-32
No files found.
spec/services/ci/register_job_service_spec.rb
View file @
53b5346d
...
...
@@ -4,7 +4,7 @@ module Ci
describe
RegisterJobService
do
let!
(
:project
)
{
FactoryGirl
.
create
:project
,
shared_runners_enabled:
false
}
let!
(
:pipeline
)
{
FactoryGirl
.
create
:ci_pipeline
,
project:
project
}
let!
(
:pending_
build
)
{
FactoryGirl
.
create
:ci_build
,
pipeline:
pipeline
}
let!
(
:pending_
job
)
{
FactoryGirl
.
create
:ci_build
,
pipeline:
pipeline
}
let!
(
:shared_runner
)
{
FactoryGirl
.
create
(
:ci_runner
,
is_shared:
true
)
}
let!
(
:specific_runner
)
{
FactoryGirl
.
create
(
:ci_runner
,
is_shared:
false
)
}
...
...
@@ -15,32 +15,32 @@ module Ci
describe
'#execute'
do
context
'runner follow tag list'
do
it
"picks build with the same tag"
do
pending_
build
.
tag_list
=
[
"linux"
]
pending_
build
.
save
pending_
job
.
tag_list
=
[
"linux"
]
pending_
job
.
save
specific_runner
.
tag_list
=
[
"linux"
]
expect
(
execute
(
specific_runner
)).
to
eq
(
pending_
build
)
expect
(
execute
(
specific_runner
)).
to
eq
(
pending_
job
)
end
it
"does not pick build with different tag"
do
pending_
build
.
tag_list
=
[
"linux"
]
pending_
build
.
save
pending_
job
.
tag_list
=
[
"linux"
]
pending_
job
.
save
specific_runner
.
tag_list
=
[
"win32"
]
expect
(
execute
(
specific_runner
)).
to
be_falsey
end
it
"picks build without tag"
do
expect
(
execute
(
specific_runner
)).
to
eq
(
pending_
build
)
expect
(
execute
(
specific_runner
)).
to
eq
(
pending_
job
)
end
it
"does not pick build with tag"
do
pending_
build
.
tag_list
=
[
"linux"
]
pending_
build
.
save
pending_
job
.
tag_list
=
[
"linux"
]
pending_
job
.
save
expect
(
execute
(
specific_runner
)).
to
be_falsey
end
it
"pick build without tag"
do
specific_runner
.
tag_list
=
[
"win32"
]
expect
(
execute
(
specific_runner
)).
to
eq
(
pending_
build
)
expect
(
execute
(
specific_runner
)).
to
eq
(
pending_
job
)
end
end
...
...
@@ -76,7 +76,7 @@ module Ci
let!
(
:pipeline2
)
{
create
:ci_pipeline
,
project:
project2
}
let!
(
:project3
)
{
create
:project
,
shared_runners_enabled:
true
}
let!
(
:pipeline3
)
{
create
:ci_pipeline
,
project:
project3
}
let!
(
:build1_project1
)
{
pending_
build
}
let!
(
:build1_project1
)
{
pending_
job
}
let!
(
:build2_project1
)
{
FactoryGirl
.
create
:ci_build
,
pipeline:
pipeline
}
let!
(
:build3_project1
)
{
FactoryGirl
.
create
:ci_build
,
pipeline:
pipeline
}
let!
(
:build1_project2
)
{
FactoryGirl
.
create
:ci_build
,
pipeline:
pipeline2
}
...
...
@@ -172,7 +172,7 @@ module Ci
context
'when first build is stalled'
do
before
do
pending_
build
.
lock_version
=
10
pending_
job
.
lock_version
=
10
end
subject
{
described_class
.
new
(
specific_runner
).
execute
}
...
...
@@ -182,7 +182,7 @@ module Ci
before
do
allow_any_instance_of
(
Ci
::
RegisterJobService
).
to
receive
(
:builds_for_specific_runner
)
.
and_return
([
pending_
build
,
other_build
])
.
and_return
([
pending_
job
,
other_build
])
end
it
"receives second build from the queue"
do
...
...
@@ -194,7 +194,7 @@ module Ci
context
'when single build is in queue'
do
before
do
allow_any_instance_of
(
Ci
::
RegisterJobService
).
to
receive
(
:builds_for_specific_runner
)
.
and_return
([
pending_
build
])
.
and_return
([
pending_
job
])
end
it
"does not receive any valid result"
do
...
...
@@ -219,30 +219,30 @@ module Ci
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:specific
)
}
context
'when a job is protected'
do
let!
(
:p
rotected
_job
)
{
create
(
:ci_build
,
:protected
,
pipeline:
pipeline
)
}
let!
(
:p
ending
_job
)
{
create
(
:ci_build
,
:protected
,
pipeline:
pipeline
)
}
it
'picks the
protected
job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
p
rotected
_job
)
it
'picks the job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
p
ending
_job
)
end
end
context
'when a job is unprotected'
do
let!
(
:
unprotected
_job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let!
(
:
pending
_job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
it
'picks the
unprotected
job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
unprotected
_job
)
it
'picks the job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
pending
_job
)
end
end
context
'when protected attribute of a job is nil'
do
let!
(
:
legacy
_job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let!
(
:
pending
_job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
before
do
legacy
_job
.
update_attribute
(
:protected
,
nil
)
pending
_job
.
update_attribute
(
:protected
,
nil
)
end
it
'picks the
legacy
job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
legacy
_job
)
it
'picks the job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
pending
_job
)
end
end
end
...
...
@@ -251,29 +251,29 @@ module Ci
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:ref_protected
,
:specific
)
}
context
'when a job is protected'
do
let!
(
:p
rotected
_job
)
{
create
(
:ci_build
,
:protected
,
pipeline:
pipeline
)
}
let!
(
:p
ending
_job
)
{
create
(
:ci_build
,
:protected
,
pipeline:
pipeline
)
}
it
'picks the
protected
job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
p
rotected
_job
)
it
'picks the job'
do
expect
(
execute
(
specific_runner
)).
to
eq
(
p
ending
_job
)
end
end
context
'when a job is unprotected'
do
let!
(
:
unprotected
_job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let!
(
:
pending
_job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
it
'does not pick the
unprotected
job'
do
it
'does not pick the job'
do
expect
(
execute
(
specific_runner
)).
to
be_nil
end
end
context
'when protected attribute of a job is nil'
do
let!
(
:
legacy
_job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let!
(
:
pending
_job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
before
do
legacy
_job
.
update_attribute
(
:protected
,
nil
)
pending
_job
.
update_attribute
(
:protected
,
nil
)
end
it
'does not pick the
legacy
job'
do
it
'does not pick the job'
do
expect
(
execute
(
specific_runner
)).
to
be_nil
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