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
6ebe081b
Commit
6ebe081b
authored
Aug 31, 2021
by
Andrejs Cunskis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test stats formatter for test health metrics collection
parent
f6a238fc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
qa/qa/support/formatters/test_stats_formatter.rb
qa/qa/support/formatters/test_stats_formatter.rb
+57
-0
qa/spec/spec_helper.rb
qa/spec/spec_helper.rb
+1
-0
No files found.
qa/qa/support/formatters/test_stats_formatter.rb
0 → 100644
View file @
6ebe081b
# frozen_string_literal: true
module
QA
module
Support
module
Formatters
class
TestStatsFormatter
<
RSpec
::
Core
::
Formatters
::
BaseFormatter
STATS_DIR
=
'tmp/test-stats'
RSpec
::
Core
::
Formatters
.
register
(
self
,
:start
,
:stop
)
# Start test run
#
# @param [RSpec::Core::Notifications::StartNotification] _notification
# @return [void]
def
start
(
_notification
)
FileUtils
.
mkdir_p
(
STATS_DIR
)
end
# Finish test execution
#
# @param [RSpec::Core::Notifications::ExamplesNotification] notification
# @return [void]
def
stop
(
notification
)
File
.
open
(
File
.
join
(
STATS_DIR
,
"test-stats-
#{
SecureRandom
.
uuid
}
.json"
),
'w'
)
do
|
file
|
specs
=
notification
.
examples
.
map
{
|
example
|
test_stats
(
example
)
}
file
.
write
(
specs
.
to_json
)
end
end
private
# Get test stats
#
# @param [RSpec::Core::Example] example
# @return [Hash]
def
test_stats
(
example
)
{
id:
example
.
id
,
name:
example
.
full_description
,
status:
example
.
execution_result
.
status
,
reliable:
example
.
metadata
.
key?
(
:reliable
),
quarantined:
example
.
metadata
.
key?
(
:quarantined
),
run_time:
example
.
execution_result
.
run_time
,
attempts:
example
.
metadata
[
:retry_attempts
],
# use allure job name since it is already present and indicates what type of run it is
# example: staging-full, staging-sanity etc.
run_type:
ENV
[
'ALLURE_JOB_NAME'
]
}
end
end
end
end
end
qa/spec/spec_helper.rb
View file @
6ebe081b
...
...
@@ -27,6 +27,7 @@ RSpec.configure do |config|
config
.
add_formatter
QA
::
Support
::
Formatters
::
ContextFormatter
config
.
add_formatter
QA
::
Support
::
Formatters
::
QuarantineFormatter
config
.
add_formatter
QA
::
Support
::
Formatters
::
TestStatsFormatter
if
QA
::
Runtime
::
Env
.
running_in_ci?
config
.
before
do
|
example
|
QA
::
Runtime
::
Logger
.
debug
(
"
\n
Starting test:
#{
example
.
full_description
}
\n
"
)
...
...
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