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
30bc983c
Commit
30bc983c
authored
Dec 08, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test for both ci_disable_validates_dependencies true/false
parent
85151ff6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
129 additions
and
78 deletions
+129
-78
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+64
-44
spec/services/ci/register_job_service_spec.rb
spec/services/ci/register_job_service_spec.rb
+65
-34
No files found.
spec/models/ci/build_spec.rb
View file @
30bc983c
...
@@ -1869,71 +1869,91 @@ describe Ci::Build do
...
@@ -1869,71 +1869,91 @@ describe Ci::Build do
end
end
describe
'state transition: any => [:running]'
do
describe
'state transition: any => [:running]'
do
before
do
shared_examples
'validation is active'
do
stub_feature_flags
(
ci_disable_validates_dependencies:
true
)
context
'when depended job has not been completed yet'
do
end
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:running
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
let
(
:build
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
stage_idx:
1
,
options:
options
)
}
it
{
expect
{
job
.
run!
}.
to
raise_error
(
Ci
::
Build
::
MissingDependenciesError
)
}
end
context
'when "dependencies" keyword is not defin
ed'
do
context
'when artifacts of depended job has been expir
ed'
do
let
(
:options
)
{
{}
}
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
:expired
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
it
{
expect
{
build
.
run!
}.
not_to
raise_error
}
it
{
expect
{
job
.
run!
}.
to
raise_error
(
Ci
::
Build
::
MissingDependenciesError
)
}
end
end
context
'when "dependencies" keyword is empty
'
do
context
'when artifacts of depended job has been erased
'
do
let
(
:options
)
{
{
dependencies:
[]
}
}
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
,
erased_at:
1
.
minute
.
ago
)
}
it
{
expect
{
build
.
run!
}.
not_to
raise_error
}
before
do
pre_stage_job
.
erase
end
it
{
expect
{
job
.
run!
}.
to
raise_error
(
Ci
::
Build
::
MissingDependenciesError
)
}
end
end
end
context
'when "dependencies" keyword is specified'
do
shared_examples
'validation is not active'
do
let
(
:options
)
{
{
dependencies:
[
'test'
]
}
}
context
'when depended job has not been completed yet'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:running
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
context
'when a depended job exists'
do
it
{
expect
{
job
.
run!
}.
not_to
raise_error
}
context
'when depended job has artifacts'
do
end
let!
(
:pre_stage_job
)
do
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
,
options:
{
artifacts:
{
paths:
[
'binaries/'
]
}
}
)
end
it
{
expect
{
build
.
run!
}.
not_to
raise_error
}
context
'when artifacts of depended job has been expired'
do
end
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
:expired
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
it
{
expect
{
job
.
run!
}.
not_to
raise_error
}
end
context
'when depended job does not have artifacts
'
do
context
'when artifacts of depended job has been erased
'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
,
erased_at:
1
.
minute
.
ago
)
}
it
{
expect
{
build
.
run!
}.
not_to
raise_error
}
before
do
pre_stage_job
.
erase
end
end
context
'when depended job has not been completed yet'
do
it
{
expect
{
job
.
run!
}.
not_to
raise_error
}
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:running
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
end
end
it
{
expect
{
build
.
run!
}.
to
raise_error
(
Ci
::
Build
::
MissingDependenciesError
)
}
let!
(
:job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
stage_idx:
1
,
options:
options
)
}
end
context
'when artifacts of depended job has been expired'
do
context
'when validates for dependencies is enabled'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
:expired
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
before
do
stub_feature_flags
(
ci_disable_validates_dependencies:
false
)
end
it
{
expect
{
build
.
run!
}.
to
raise_error
(
Ci
::
Build
::
MissingDependenciesError
)
}
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
end
context
'when artifacts of depended job has been eras
ed'
do
context
'when "dependencies" keyword is not defin
ed'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
,
erased_at:
1
.
minute
.
ago
)
}
let
(
:options
)
{
{}
}
before
do
it
{
expect
{
job
.
run!
}.
not_to
raise_error
}
pre_stage_job
.
erase
end
end
it
{
expect
{
build
.
run!
}.
to
raise_error
(
Ci
::
Build
::
MissingDependenciesError
)
}
context
'when "dependencies" keyword is empty'
do
end
let
(
:options
)
{
{
dependencies:
[]
}
}
it
{
expect
{
job
.
run!
}.
not_to
raise_error
}
end
context
'when "dependencies" keyword is specified'
do
let
(
:options
)
{
{
dependencies:
[
'test'
]
}
}
it_behaves_like
'validation is active'
end
end
end
end
context
'when validates for dependencies is disabled'
do
let
(
:options
)
{
{
dependencies:
[
'test'
]
}
}
before
do
stub_feature_flags
(
ci_disable_validates_dependencies:
true
)
end
it_behaves_like
'validation is not active'
end
end
end
describe
'state transition when build fails'
do
describe
'state transition when build fails'
do
...
...
spec/services/ci/register_job_service_spec.rb
View file @
30bc983c
...
@@ -277,54 +277,85 @@ module Ci
...
@@ -277,54 +277,85 @@ module Ci
end
end
context
'when "dependencies" keyword is specified'
do
context
'when "dependencies" keyword is specified'
do
before
do
shared_examples
'not pick'
do
stub_feature_flags
(
ci_disable_validates_dependencies:
false
)
it
'does not pick the build and drops the build'
do
expect
(
subject
).
to
be_nil
expect
(
pending_job
.
reload
).
to
be_failed
expect
(
pending_job
).
to
be_missing_dependency_failure
end
end
end
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
name:
job_name
,
stage_idx:
0
)
}
shared_examples
'validation is active'
do
context
'when depended job has not been completed yet'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:running
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
it_behaves_like
'not pick'
end
context
'when artifacts of depended job has been expired'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
:expired
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
it_behaves_like
'not pick'
end
context
'when artifacts of depended job has been erased'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
,
erased_at:
1
.
minute
.
ago
)
}
before
do
pre_stage_job
.
erase
end
let!
(
:pending_job
)
do
it_behaves_like
'not pick'
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
stage_idx:
1
,
options:
{
dependencies:
[
'spec'
]
}
)
end
end
end
let
(
:picked_job
)
{
execute
(
specific_runner
)
}
shared_examples
'validation is not active'
do
context
'when depended job has not been completed yet'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:running
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
context
'when a depended job exists'
do
it
{
expect
(
subject
).
to
eq
(
pending_job
)
}
let
(
:job_name
)
{
'spec'
}
end
context
'when artifacts of depended job has been expired'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
:expired
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
it
"picks the build"
do
it
{
expect
(
subject
).
to
eq
(
pending_job
)
}
expect
(
picked_job
).
to
eq
(
pending_job
)
end
end
context
'when "artifacts" keyword is specified on depended job'
do
context
'when artifacts of depended job has been erased'
do
let!
(
:pre_stage_job
)
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
,
erased_at:
1
.
minute
.
ago
)
}
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
,
name:
job_name
,
stage_idx:
0
,
options:
{
artifacts:
{
paths:
[
'binaries/'
]
}
}
)
end
context
'when artifacts of depended job has existsed'
do
before
do
it
"picks the build"
do
pre_stage_job
.
erase
expect
(
picked_job
).
to
eq
(
pending_job
)
end
end
end
context
'when artifacts of depended job has not existsed'
do
it
{
expect
(
subject
).
to
eq
(
pending_job
)
}
before
do
end
pre_stage_job
.
erase
end
end
it
'does not pick the build and drops the build'
do
before
do
expect
(
picked_job
).
to
be_nil
stub_feature_flags
(
ci_disable_validates_dependencies:
false
)
expect
(
pending_job
.
reload
).
to
be_failed
end
expect
(
pending_job
).
to
be_missing_dependency_failure
end
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
end
let!
(
:pending_job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
stage_idx:
1
,
options:
{
dependencies:
[
'test'
]
}
)
}
subject
{
execute
(
specific_runner
)
}
context
'when validates for dependencies is enabled'
do
before
do
stub_feature_flags
(
ci_disable_validates_dependencies:
false
)
end
end
it_behaves_like
'validation is active'
end
context
'when validates for dependencies is disabled'
do
before
do
stub_feature_flags
(
ci_disable_validates_dependencies:
true
)
end
it_behaves_like
'validation is not active'
end
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