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
c97ff908
Commit
c97ff908
authored
Nov 16, 2020
by
Jan Provaznik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test reports to usage ping
Adds usage ping data about requirement test reports.
parent
13a73325
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
11 deletions
+45
-11
ee/app/models/requirements_management/test_report.rb
ee/app/models/requirements_management/test_report.rb
+2
-0
ee/changelogs/unreleased/requirements-track2.yml
ee/changelogs/unreleased/requirements-track2.yml
+5
-0
ee/lib/ee/gitlab/usage_data.rb
ee/lib/ee/gitlab/usage_data.rb
+4
-1
ee/spec/lib/ee/gitlab/usage_data_spec.rb
ee/spec/lib/ee/gitlab/usage_data_spec.rb
+13
-3
ee/spec/models/requirements_management/test_report_spec.rb
ee/spec/models/requirements_management/test_report_spec.rb
+20
-7
rubocop/rubocop-usage-data.yml
rubocop/rubocop-usage-data.yml
+1
-0
No files found.
ee/app/models/requirements_management/test_report.rb
View file @
c97ff908
...
...
@@ -13,6 +13,8 @@ module RequirementsManagement
enum
state:
{
passed:
1
,
failed:
2
}
scope
:without_build
,
->
{
where
(
build_id:
nil
)
}
scope
:with_build
,
->
{
where
.
not
(
build_id:
nil
)
}
scope
:for_user_build
,
->
(
user_id
,
build_id
)
{
where
(
author_id:
user_id
,
build_id:
build_id
)
}
class
<<
self
...
...
ee/changelogs/unreleased/requirements-track2.yml
0 → 100644
View file @
c97ff908
---
title
:
Added usage ping statistics about created requirement test reports
merge_request
:
47809
author
:
type
:
added
ee/lib/ee/gitlab/usage_data.rb
View file @
c97ff908
...
...
@@ -105,7 +105,10 @@ module EE
return
{}
unless
::
License
.
feature_available?
(
:requirements
)
{
requirements_created:
count
(
RequirementsManagement
::
Requirement
)
requirements_created:
count
(
RequirementsManagement
::
Requirement
),
requirement_test_reports_manual:
count
(
RequirementsManagement
::
TestReport
.
without_build
),
requirement_test_reports_ci:
count
(
RequirementsManagement
::
TestReport
.
with_build
),
requirements_with_test_report:
distinct_count
(
RequirementsManagement
::
TestReport
,
:requirement_id
)
}
end
...
...
ee/spec/lib/ee/gitlab/usage_data_spec.rb
View file @
c97ff908
...
...
@@ -189,6 +189,13 @@ RSpec.describe Gitlab::UsageData do
describe
'.requirements_counts'
do
subject
{
described_class
.
requirements_counts
}
let_it_be
(
:requirement1
)
{
create
(
:requirement
)
}
let_it_be
(
:requirement2
)
{
create
(
:requirement
)
}
let_it_be
(
:requirement3
)
{
create
(
:requirement
)
}
let_it_be
(
:test_report1
)
{
create
(
:test_report
,
requirement:
requirement1
)
}
let_it_be
(
:test_report2
)
{
create
(
:test_report
,
requirement:
requirement2
,
build:
nil
)
}
let_it_be
(
:test_report3
)
{
create
(
:test_report
,
requirement:
requirement1
)
}
context
'when requirements are disabled'
do
it
'returns empty hash'
do
stub_licensed_features
(
requirements:
false
)
...
...
@@ -201,9 +208,12 @@ RSpec.describe Gitlab::UsageData do
it
'returns created requirements count'
do
stub_licensed_features
(
requirements:
true
)
create_list
(
:requirement
,
2
)
expect
(
subject
).
to
eq
({
requirements_created:
2
})
expect
(
subject
).
to
eq
({
requirements_created:
3
,
requirement_test_reports_manual:
1
,
requirement_test_reports_ci:
2
,
requirements_with_test_report:
2
})
end
end
end
...
...
ee/spec/models/requirements_management/test_report_spec.rb
View file @
c97ff908
...
...
@@ -19,17 +19,30 @@ RSpec.describe RequirementsManagement::TestReport do
end
describe
'scopes'
do
describe
'for_user_build'
do
it
"returns only test reports matching build's user and pipeline"
do
user
=
create
(
:user
)
build
=
create
(
:ci_build
)
report1
=
create
(
:test_report
,
author:
user
,
build:
build
)
create
(
:test_report
,
author:
user
)
create
(
:test_report
,
build:
build
)
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:build
)
{
create
(
:ci_build
)
}
let_it_be
(
:report1
)
{
create
(
:test_report
,
author:
user
,
build:
build
)
}
let_it_be
(
:report2
)
{
create
(
:test_report
,
author:
user
)
}
let_it_be
(
:report3
)
{
create
(
:test_report
,
build:
build
)
}
let_it_be
(
:report4
)
{
create
(
:test_report
,
build:
nil
)
}
describe
'.for_user_build'
do
it
"returns only test reports matching build's user and pipeline"
do
expect
(
described_class
.
for_user_build
(
user
.
id
,
build
.
id
)).
to
match_array
([
report1
])
end
end
describe
'.with_build'
do
it
'returns only test reports which reference a CI build'
do
expect
(
described_class
.
with_build
).
to
match_array
([
report1
,
report2
,
report3
])
end
end
describe
'.without_build'
do
it
'returns only test reports which do not refer any CI build'
do
expect
(
described_class
.
without_build
).
to
match_array
([
report4
])
end
end
end
describe
'.persist_requirement_reports'
do
...
...
rubocop/rubocop-usage-data.yml
View file @
c97ff908
...
...
@@ -51,3 +51,4 @@ UsageData/DistinctCountByLargeForeignKey:
-
'
project_id'
-
'
user_id'
-
'
resource_owner_id'
-
'
requirement_id'
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