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
Jérome Perrin
gitlab-ce
Commits
2c1f7cca
Commit
2c1f7cca
authored
Sep 28, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix register_build_service tests
parent
6abca128
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
8 deletions
+11
-8
app/models/ci/runner.rb
app/models/ci/runner.rb
+4
-0
app/services/ci/register_build_service.rb
app/services/ci/register_build_service.rb
+3
-3
spec/services/ci/register_build_service_spec.rb
spec/services/ci/register_build_service_spec.rb
+4
-5
No files found.
app/models/ci/runner.rb
View file @
2c1f7cca
...
@@ -41,6 +41,10 @@ module Ci
...
@@ -41,6 +41,10 @@ module Ci
query:
"%
#{
query
.
try
(
:downcase
)
}
%"
)
query:
"%
#{
query
.
try
(
:downcase
)
}
%"
)
end
end
def
gl_projects_ids
projects
.
select
(
:gitlab_id
)
end
def
set_default_values
def
set_default_values
self
.
token
=
SecureRandom
.
hex
(
15
)
if
self
.
token
.
blank?
self
.
token
=
SecureRandom
.
hex
(
15
)
if
self
.
token
.
blank?
end
end
...
...
app/services/ci/register_build_service.rb
View file @
2c1f7cca
...
@@ -8,10 +8,10 @@ module Ci
...
@@ -8,10 +8,10 @@ module Ci
builds
=
builds
=
if
current_runner
.
shared?
if
current_runner
.
shared?
# don't run projects which have not enables shared runners
# don't run projects which have not enables shared runners
builds
.
includes
(
:project
).
where
(
ci_projects:
{
shared_runners_enabled:
true
})
builds
.
joins
(
commit:
{
gl_project: :gitlab_ci_project
}).
where
(
ci_projects:
{
shared_runners_enabled:
true
})
else
else
# do run projects which are only assigned to this runner
# do run projects which are only assigned to this runner
builds
.
where
(
project_id:
current_runner
.
projects
)
builds
.
joins
(
:commit
).
where
(
ci_commits:
{
gl_project_id:
current_runner
.
gl_projects_ids
}
)
end
end
builds
=
builds
.
order
(
'created_at ASC'
)
builds
=
builds
.
order
(
'created_at ASC'
)
...
@@ -19,7 +19,7 @@ module Ci
...
@@ -19,7 +19,7 @@ module Ci
build
=
builds
.
find
do
|
build
|
build
=
builds
.
find
do
|
build
|
(
build
.
tag_list
-
current_runner
.
tag_list
).
empty?
(
build
.
tag_list
-
current_runner
.
tag_list
).
empty?
end
end
if
build
if
build
# In case when 2 runners try to assign the same build, second runner will be declined
# In case when 2 runners try to assign the same build, second runner will be declined
...
...
spec/services/ci/register_build_service_spec.rb
View file @
2c1f7cca
...
@@ -3,15 +3,15 @@ require 'spec_helper'
...
@@ -3,15 +3,15 @@ require 'spec_helper'
module
Ci
module
Ci
describe
RegisterBuildService
do
describe
RegisterBuildService
do
let!
(
:service
)
{
RegisterBuildService
.
new
}
let!
(
:service
)
{
RegisterBuildService
.
new
}
let!
(
:project
)
{
FactoryGirl
.
create
:ci_project
}
let!
(
:gl_project
)
{
FactoryGirl
.
create
:empty_project
}
let!
(
:gl_project
)
{
FactoryGirl
.
create
:empty_project
,
gitlab_ci_project:
project
}
let!
(
:commit
)
{
FactoryGirl
.
create
:ci_commit
,
gl_project:
gl_project
}
let!
(
:commit
)
{
FactoryGirl
.
create
:ci_commit
,
gl_project:
gl_project
}
let!
(
:pending_build
)
{
FactoryGirl
.
create
:ci_build
,
commit:
commit
}
let!
(
:pending_build
)
{
FactoryGirl
.
create
:ci_build
,
commit:
commit
}
let!
(
:shared_runner
)
{
FactoryGirl
.
create
(
:ci_runner
,
is_shared:
true
)
}
let!
(
:shared_runner
)
{
FactoryGirl
.
create
(
:ci_runner
,
is_shared:
true
)
}
let!
(
:specific_runner
)
{
FactoryGirl
.
create
(
:ci_runner
,
is_shared:
false
)
}
let!
(
:specific_runner
)
{
FactoryGirl
.
create
(
:ci_runner
,
is_shared:
false
)
}
before
do
before
do
specific_runner
.
assign_to
(
project
)
gl_project
.
ensure_ci_project
specific_runner
.
assign_to
(
gl_project
.
gitlab_ci_project
)
end
end
describe
:execute
do
describe
:execute
do
...
@@ -48,8 +48,7 @@ module Ci
...
@@ -48,8 +48,7 @@ module Ci
context
'allow shared runners'
do
context
'allow shared runners'
do
before
do
before
do
project
.
shared_runners_enabled
=
true
gl_project
.
gitlab_ci_project
.
update
(
shared_runners_enabled:
true
)
project
.
save
end
end
context
'shared runner'
do
context
'shared runner'
do
...
...
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