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
5520e3eb
Commit
5520e3eb
authored
Jan 22, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce nesting and simplify CI/CD end-to-end tests
parent
ca4db9d2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
24 deletions
+56
-24
qa/qa/factory/resource/runner.rb
qa/qa/factory/resource/runner.rb
+3
-18
qa/qa/service/runner.rb
qa/qa/service/runner.rb
+3
-3
qa/qa/specs/features/project/pipelines_spec.rb
qa/qa/specs/features/project/pipelines_spec.rb
+50
-2
qa/spec/factory/base_spec.rb
qa/spec/factory/base_spec.rb
+0
-1
No files found.
qa/qa/factory/resource/runner.rb
View file @
5520e3eb
...
@@ -15,36 +15,21 @@ module QA
...
@@ -15,36 +15,21 @@ module QA
@name
||
"qa-runner-
#{
SecureRandom
.
hex
(
4
)
}
"
@name
||
"qa-runner-
#{
SecureRandom
.
hex
(
4
)
}
"
end
end
def
perform
(
&
block
)
@block
||=
block
end
def
fabricate!
def
fabricate!
project
.
visit!
project
.
visit!
Page
::
Menu
::
Side
.
act
{
click_ci_cd_settings
}
Page
::
Menu
::
Side
.
act
{
click_ci_cd_settings
}
Service
::
Runner
.
perform
do
|
runner
|
Service
::
Runner
.
new
(
name
).
tap
do
|
runner
|
Page
::
Project
::
Settings
::
CICD
.
perform
do
|
settings
|
Page
::
Project
::
Settings
::
CICD
.
perform
do
|
settings
|
settings
.
expand_runners_settings
do
|
runners
|
settings
.
expand_runners_settings
do
|
runners
|
runner
.
pull
runner
.
pull
runner
.
name
=
name
runner
.
token
=
runners
.
registration_token
runner
.
token
=
runners
.
registration_token
runner
.
address
=
runners
.
coordinator_address
runner
.
address
=
runners
.
coordinator_address
runner
.
tags
=
%w[qa test]
runner
.
tags
=
%w[qa test]
runner
.
register!
runner
.
register!
end
# TODO, wait for runner to register using non-blocking method.
sleep
5
##
# TODO, refactor to support non-blocking wait time until
# GitLab Runner sucessfully registers itself.
#
sleep
5
settings
.
refresh
settings
.
expand_runners_settings
do
|
runners
|
perform
&
.
call
(
runners
,
runner
)
runner
.
remove!
end
end
end
end
end
end
...
...
qa/qa/service/runner.rb
View file @
5520e3eb
...
@@ -6,11 +6,11 @@ module QA
...
@@ -6,11 +6,11 @@ module QA
include
Scenario
::
Actable
include
Scenario
::
Actable
include
Service
::
Shellout
include
Service
::
Shellout
attr_accessor
:token
,
:address
,
:tags
,
:image
,
:name
attr_accessor
:token
,
:address
,
:tags
,
:image
def
initialize
def
initialize
(
name
)
@image
=
'gitlab/gitlab-runner:alpine'
@image
=
'gitlab/gitlab-runner:alpine'
@name
=
"qa-runner-
#{
SecureRandom
.
hex
(
4
)
}
"
@name
=
name
||
"qa-runner-
#{
SecureRandom
.
hex
(
4
)
}
"
end
end
def
pull
def
pull
...
...
qa/qa/specs/features/project/pipelines_spec.rb
View file @
5520e3eb
module
QA
module
QA
feature
'CI/CD Pipelines'
,
:core
,
:docker
do
feature
'CI/CD Pipelines'
,
:core
,
:docker
do
let
(
:executor
)
{
"qa-runner-
#{
Time
.
now
.
to_i
}
"
}
after
do
Service
::
Runner
.
new
(
executor
).
remove!
end
scenario
'user registers a new specific runner'
do
scenario
'user registers a new specific runner'
do
Runtime
::
Browser
.
visit
(
:gitlab
,
Page
::
Main
::
Login
)
Runtime
::
Browser
.
visit
(
:gitlab
,
Page
::
Main
::
Login
)
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
Factory
::
Resource
::
Runner
.
fabricate!
do
|
runner
|
Factory
::
Resource
::
Runner
.
fabricate!
do
|
runner
|
runner
.
perform
do
|
page
,
runner
|
runner
.
name
=
executor
expect
(
page
).
to
have_content
(
runner
.
name
)
end
Page
::
Project
::
Settings
::
CICD
.
perform
do
|
settings
|
settings
.
expand_runners_settings
do
|
page
|
expect
(
page
).
to
have_content
(
runner
)
expect
(
page
).
to
have_online_runner
expect
(
page
).
to
have_online_runner
end
end
end
end
end
end
scenario
'users creates a new pipeline'
do
Runtime
::
Browser
.
visit
(
:gitlab
,
Page
::
Main
::
Login
)
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
project
=
Factory
::
Resource
::
Project
.
fabricate!
do
|
project
|
project
.
name
=
'project-with-pipelines'
project
.
description
=
'Project with CI/CD Pipelines.'
end
Factory
::
Resource
::
Runner
.
fabricate!
do
|
runner
|
runner
.
project
=
project
runner
.
name
=
executor
end
Factory
::
Repository
::
Push
.
fabricate!
do
|
push
|
push
.
project
=
project
push
.
file_name
=
'.gitlab-ci.yml'
push
.
commit_message
=
'Add .gitlab-ci.yml'
push
.
file_content
=
<<~
EOF
echo-success-test:
script: echo 'OK'
echo-failure-test:
script:
- echo 'FAILURE'
- exit 1
echo-artifacts-test:
script: echo "CONTENTS" > my-artifacts/artifact.txt
artifacts:
paths:
- my-artifacts/
EOF
end
Page
::
Project
::
Show
.
act
{
wait_for_push
}
end
end
end
end
end
qa/spec/factory/base_spec.rb
View file @
5520e3eb
...
@@ -19,7 +19,6 @@ describe QA::Factory::Base do
...
@@ -19,7 +19,6 @@ describe QA::Factory::Base do
it
'returns fabrication product'
do
it
'returns fabrication product'
do
allow
(
subject
).
to
receive
(
:new
).
and_return
(
factory
)
allow
(
subject
).
to
receive
(
:new
).
and_return
(
factory
)
allow
(
factory
).
to
receive
(
:fabricate!
).
and_return
(
'something'
)
result
=
subject
.
fabricate!
(
'something'
)
result
=
subject
.
fabricate!
(
'something'
)
...
...
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