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
74bb62c7
Commit
74bb62c7
authored
Feb 17, 2021
by
Tiffany Rea
Committed by
Dan Davison
Feb 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify test and add wait and retry logics
parent
7281c770
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
80 deletions
+42
-80
qa/qa/ee/page/merge_request/show.rb
qa/qa/ee/page/merge_request/show.rb
+4
-1
qa/qa/page/merge_request/show.rb
qa/qa/page/merge_request/show.rb
+9
-3
qa/qa/specs/features/ee/browser_ui/4_verify/pipelines_for_merged_results_and_merge_trains_spec.rb
...ify/pipelines_for_merged_results_and_merge_trains_spec.rb
+29
-76
No files found.
qa/qa/ee/page/merge_request/show.rb
View file @
74bb62c7
...
@@ -225,9 +225,12 @@ module QA
...
@@ -225,9 +225,12 @@ module QA
end
end
def
merge_via_merge_train
def
merge_via_merge_train
# Revisit after merge page re-architect is done https://gitlab.com/gitlab-org/gitlab/-/issues/300042
# To remove page refresh logic if possible
wait_until_ready_to_merge
wait_until_ready_to_merge
wait_until
{
!
find_element
(
:merge_button
).
has_text?
(
"when pipeline succeeds"
)
}
click_element
(
:merge_button
,
text:
"Start merge train"
)
click_element
(
:merge_button
)
finished_loading?
finished_loading?
end
end
...
...
qa/qa/page/merge_request/show.rb
View file @
74bb62c7
...
@@ -224,8 +224,7 @@ module QA
...
@@ -224,8 +224,7 @@ module QA
end
end
def
merge!
def
merge!
wait_until_ready_to_merge
try_to_merge!
click_element
(
:merge_button
)
finished_loading?
finished_loading?
raise
"Merge did not appear to be successful"
unless
merged?
raise
"Merge did not appear to be successful"
unless
merged?
...
@@ -237,7 +236,11 @@ module QA
...
@@ -237,7 +236,11 @@ module QA
end
end
def
merged?
def
merged?
has_element?
(
:merged_status_content
,
text:
'The changes were merged into'
,
wait:
60
)
# Revisit after merge page re-architect is done https://gitlab.com/gitlab-org/gitlab/-/issues/300042
# To remove page refresh logic if possible
retry_until
(
max_attempts:
3
,
reload:
true
)
do
has_element?
(
:merged_status_content
,
text:
'The changes were merged into'
,
wait:
20
)
end
end
end
# Check if the MR is able to be merged
# Check if the MR is able to be merged
...
@@ -280,7 +283,10 @@ module QA
...
@@ -280,7 +283,10 @@ module QA
end
end
def
try_to_merge!
def
try_to_merge!
# Revisit after merge page re-architect is done https://gitlab.com/gitlab-org/gitlab/-/issues/300042
# To remove page refresh logic if possible
wait_until_ready_to_merge
wait_until_ready_to_merge
wait_until
{
!
find_element
(
:merge_button
).
has_text?
(
"when pipeline succeeds"
)
}
click_element
(
:merge_button
)
click_element
(
:merge_button
)
end
end
...
...
qa/qa/specs/features/ee/browser_ui/4_verify/pipelines_for_merged_results_and_merge_trains_spec.rb
View file @
74bb62c7
# frozen_string_literal: true
# frozen_string_literal: true
require
'
securerandom
'
require
'
faker
'
module
QA
module
QA
RSpec
.
describe
'Verify'
,
:runner
do
RSpec
.
describe
'Verify'
,
:runner
do
describe
'Pipelines for merged results and merge trains'
do
describe
'Pipelines for merged results and merge trains'
do
let
(
:
group
)
{
Resource
::
Group
.
fabricate_via_api!
}
let
(
:
executor
)
{
"qa-runner-
#{
Faker
::
Alphanumeric
.
alphanumeric
(
8
)
}
"
}
let!
(
:runner
)
do
let!
(
:runner
)
do
Resource
::
Runner
.
fabricate_via_api!
do
|
runner
|
Resource
::
Runner
.
fabricate_via_api!
do
|
runner
|
runner
.
token
=
group
.
reload!
.
runners_token
runner
.
name
=
group
.
name
runner
.
tags
=
[
group
.
name
]
runner
.
project
=
project
runner
.
project
=
project
runner
.
name
=
executor
runner
.
tags
=
[
executor
]
end
end
end
end
let
(
:project
)
do
let
(
:project
)
do
Resource
::
Project
.
fabricate_via_api!
do
|
project
|
Resource
::
Project
.
fabricate_via_api!
do
|
project
|
project
.
name
=
'pipelines-for-merged-results-and-merge-trains'
project
.
name
=
'pipelines-for-merge-trains'
project
.
group
=
group
end
end
end
end
before
do
let!
(
:ci_file
)
do
Resource
::
Repository
::
Commit
.
fabricate_via_api!
do
|
commit
|
Resource
::
Repository
::
Commit
.
fabricate_via_api!
do
|
commit
|
commit
.
project
=
project
commit
.
project
=
project
commit
.
commit_message
=
'Add .gitlab-ci.yml'
commit
.
commit_message
=
'Add .gitlab-ci.yml'
...
@@ -31,29 +29,33 @@ module QA
...
@@ -31,29 +29,33 @@ module QA
[
[
{
{
file_path:
'.gitlab-ci.yml'
,
file_path:
'.gitlab-ci.yml'
,
content:
<<~
EOF
content:
<<~
YAML
test:
test:
tags: [
#{
group
.
name
}
]
tags: [
#{
executor
}
]
script: echo 'OK'
script: echo 'OK'
only:
only:
- merge_requests
- merge_requests
EOF
YAML
}
}
]
]
)
)
end
end
end
Flow
::
Login
.
sign_in
let
(
:merge_request
)
do
project
.
visit!
Resource
::
MergeRequest
.
fabricate_via_api!
do
|
merge_request
|
merge_request
.
project
=
project
Page
::
Project
::
Menu
.
perform
(
&
:go_to_general_settings
)
merge_request
.
description
=
Faker
::
Lorem
.
sentence
Page
::
Project
::
Settings
::
Main
.
perform
do
|
main
|
merge_request
.
target_new_branch
=
false
main
.
expand_merge_requests_settings
do
|
settings
|
merge_request
.
file_name
=
Faker
::
Lorem
.
word
settings
.
click_pipelines_for_merged_results_checkbox
merge_request
.
file_content
=
Faker
::
Lorem
.
sentence
settings
.
click_merge_trains_checkbox
settings
.
click_save_changes
end
end
end
end
before
do
Flow
::
Login
.
sign_in
project
.
visit!
Flow
::
MergeRequest
.
enable_merge_trains
end
end
after
do
after
do
...
@@ -61,77 +63,28 @@ module QA
...
@@ -61,77 +63,28 @@ module QA
end
end
it
'creates a pipeline with merged results'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/issues/562'
do
it
'creates a pipeline with merged results'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/issues/562'
do
branch_name
=
"merged-results-
#{
SecureRandom
.
hex
(
8
)
}
"
merge_request
.
visit!
# Create a branch that will be merged into the default branch
Resource
::
Repository
::
ProjectPush
.
fabricate!
do
|
project_push
|
project_push
.
project
=
project
project_push
.
new_branch
=
true
project_push
.
branch_name
=
branch_name
project_push
.
file_name
=
"file-
#{
SecureRandom
.
hex
(
8
)
}
.txt"
end
# Create a merge request to merge the branch we just created
Resource
::
MergeRequest
.
fabricate_via_api!
do
|
merge_request
|
merge_request
.
project
=
project
merge_request
.
source_branch
=
branch_name
merge_request
.
no_preparation
=
true
end
.
visit!
Page
::
MergeRequest
::
Show
.
perform
do
|
show
|
Page
::
MergeRequest
::
Show
.
perform
do
|
show
|
pipeline_passed
=
Support
::
Retrier
.
retry_until
(
max_attempts:
5
,
sleep_interval:
5
)
do
expect
(
show
).
to
have_pipeline_status
(
'passed'
),
'Expected the merge request pipeline to pass.'
show
.
has_pipeline_status?
(
/Merged result pipeline #\d+ passed/
)
end
expect
(
pipeline_passed
).
to
be_truthy
,
"Expected the merged result pipeline to pass."
# The default option is to merge via merge train,
# The default option is to merge via merge train,
# but that is covered by the 'merges via a merge train' test
# but that is covered by the 'merges via a merge train' test
show
.
skip_merge_train_and_merge_immediately
show
.
skip_merge_train_and_merge_immediately
end
merged
=
Page
::
MergeRequest
::
Show
.
perform
(
&
:merged?
)
expect
(
show
).
to
be_merged
,
"Expected content 'The changes were merged' but it did not appear."
expect
(
merged
).
to
be_truthy
,
"Expected content 'The changes were merged' but it did not appear."
end
end
it
'merges via a merge train'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/issues/561'
do
branch_name
=
"merge-train-
#{
SecureRandom
.
hex
(
8
)
}
"
# Create a branch that will be merged into the default branch
Resource
::
Repository
::
ProjectPush
.
fabricate!
do
|
project_push
|
project_push
.
project
=
project
project_push
.
new_branch
=
true
project_push
.
branch_name
=
branch_name
project_push
.
file_name
=
"file-
#{
SecureRandom
.
hex
(
8
)
}
.txt"
project_push
.
file_content
=
"merge me"
end
end
# Create a merge request to merge the branch we just created
it
'merges via a merge train'
,
testcase:
'https://gitlab.com/gitlab-org/quality/testcases/-/issues/561'
do
Resource
::
MergeRequest
.
fabricate_via_api!
do
|
merge_request
|
merge_request
.
visit!
merge_request
.
project
=
project
merge_request
.
source_branch
=
branch_name
merge_request
.
no_preparation
=
true
end
.
visit!
Page
::
MergeRequest
::
Show
.
perform
do
|
show
|
Page
::
MergeRequest
::
Show
.
perform
do
|
show
|
pipeline_passed
=
show
.
retry_until
(
max_attempts:
5
,
sleep_interval:
5
)
do
expect
(
show
).
to
have_pipeline_status
(
'passed'
),
'Expected the merge request pipeline to pass.'
show
.
has_pipeline_status?
(
/Merged result pipeline #\d+ passed/
)
end
expect
(
pipeline_passed
).
to
be_truthy
,
"Expected the merged result pipeline to pass."
show
.
merge_via_merge_train
show
.
merge_via_merge_train
# It's faster to refresh the page than to wait for the UI to
expect
(
show
).
to
be_merged
,
"Expected content 'The changes were merged' but it did not appear."
# automatically refresh, so we reload if the merge status
# doesn't update quickly.
merged
=
show
.
retry_until
(
max_attempts:
5
,
reload:
true
,
sleep_interval:
5
)
do
show
.
merged?
end
expect
(
merged
).
to
be_truthy
,
"Expected content 'The changes were merged' but it did not appear."
expect
(
show
).
to
have_pipeline_status
(
/Merge train pipeline #\d+ passed/
)
end
end
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