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
8aea268f
Commit
8aea268f
authored
Jul 18, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
dcec1415
0d9fb8d4
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
167 additions
and
64 deletions
+167
-64
.gitlab/ci/review.gitlab-ci.yml
.gitlab/ci/review.gitlab-ci.yml
+32
-1
lib/api/commits.rb
lib/api/commits.rb
+1
-1
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+1
-1
lib/gitlab/usage_data_counters/redis_counter.rb
lib/gitlab/usage_data_counters/redis_counter.rb
+2
-6
lib/gitlab/usage_data_counters/web_ide_counter.rb
lib/gitlab/usage_data_counters/web_ide_counter.rb
+21
-0
qa/Gemfile
qa/Gemfile
+1
-0
qa/Gemfile.lock
qa/Gemfile.lock
+3
-0
scripts/merge-html-reports
scripts/merge-html-reports
+84
-0
spec/lib/gitlab/usage_data_counters/redis_counter_spec.rb
spec/lib/gitlab/usage_data_counters/redis_counter_spec.rb
+0
-54
spec/lib/gitlab/usage_data_counters/web_ide_counter_spec.rb
spec/lib/gitlab/usage_data_counters/web_ide_counter_spec.rb
+21
-0
spec/requests/api/commits_spec.rb
spec/requests/api/commits_spec.rb
+1
-1
No files found.
.gitlab/ci/review.gitlab-ci.yml
View file @
8aea268f
...
...
@@ -174,7 +174,38 @@ review-qa-all:
script
:
-
export KNAPSACK_REPORT_PATH=knapsack/${CI_PROJECT_NAME}/review-qa-all_master_report.json
-
export KNAPSACK_TEST_FILE_PATTERN=qa/specs/features/**/*_spec.rb
-
gitlab-qa Test::Instance::Any "${QA_IMAGE}" "${CI_ENVIRONMENT_URL}"
-
gitlab-qa Test::Instance::Any "${QA_IMAGE}" "${CI_ENVIRONMENT_URL}" -- --format RspecJunitFormatter --out tmp/rspec-${CI_JOB_ID}.xml --format html --out tmp/rspec.htm --color --format documentation
parallel-spec-reports
:
extends
:
.dedicated-runner
dependencies
:
-
review-qa-all
image
:
ruby:2.6-alpine
services
:
[]
before_script
:
[]
variables
:
SETUP_DB
:
"
false"
NEW_PARALLEL_SPECS_REPORT
:
qa/report-new.html
BASE_ARTIFACT_URL
:
"
${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/file/qa/"
stage
:
post-test
allow_failure
:
true
when
:
manual
retry
:
0
artifacts
:
when
:
always
paths
:
-
qa/report-new.html
-
qa/gitlab-qa-run-*
reports
:
junit
:
qa/gitlab-qa-run-*/**/rspec-*.xml
script
:
-
apk add --update build-base libxml2-dev libxslt-dev && rm -rf /var/cache/apk/*
-
gem install nokogiri
-
cd qa/gitlab-qa-run-*/gitlab-*
-
ARTIFACT_DIRS=$(pwd |rev| awk -F / '{print $1,$2}' | rev | sed s_\ _/_)
-
cd ../../..
-
'
[[
-f
$NEW_PARALLEL_SPECS_REPORT
]]
||
echo
"{}"
>
${NEW_PARALLEL_SPECS_REPORT}'
-
scripts/merge-html-reports ${NEW_PARALLEL_SPECS_REPORT} ${BASE_ARTIFACT_URL}${ARTIFACT_DIRS} qa/gitlab-qa-run-*/**/rspec.htm
.review-performance-base
:
&review-performance-base
<<
:
*review-qa-base
...
...
lib/api/commits.rb
View file @
8aea268f
...
...
@@ -126,7 +126,7 @@ module API
if
result
[
:status
]
==
:success
commit_detail
=
user_project
.
repository
.
commit
(
result
[
:result
])
Gitlab
::
UsageDataCounters
::
WebIdeCo
mmitsCounter
.
increme
nt
if
find_user_from_warden
Gitlab
::
UsageDataCounters
::
WebIdeCo
unter
.
increment_commits_cou
nt
if
find_user_from_warden
present
commit_detail
,
with:
Entities
::
CommitDetail
,
stats:
params
[
:stats
]
else
...
...
lib/gitlab/usage_data.rb
View file @
8aea268f
...
...
@@ -130,7 +130,7 @@ module Gitlab
def
usage_counters
{
web_ide_commits:
Gitlab
::
UsageDataCounters
::
WebIdeCo
mmitsCounter
.
total
_count
web_ide_commits:
Gitlab
::
UsageDataCounters
::
WebIdeCo
unter
.
total_commits
_count
}
end
...
...
lib/gitlab/usage_data_counters/redis_counter.rb
View file @
8aea268f
...
...
@@ -3,17 +3,13 @@
module
Gitlab
module
UsageDataCounters
module
RedisCounter
def
increment
def
increment
(
redis_counter_key
)
Gitlab
::
Redis
::
SharedState
.
with
{
|
redis
|
redis
.
incr
(
redis_counter_key
)
}
end
def
total_count
def
total_count
(
redis_counter_key
)
Gitlab
::
Redis
::
SharedState
.
with
{
|
redis
|
redis
.
get
(
redis_counter_key
).
to_i
}
end
def
redis_counter_key
raise
NotImplementedError
end
end
end
end
lib/gitlab/usage_data_counters/web_ide_co
mmits_co
unter.rb
→
lib/gitlab/usage_data_counters/web_ide_counter.rb
View file @
8aea268f
...
...
@@ -2,11 +2,19 @@
module
Gitlab
module
UsageDataCounters
class
WebIdeCo
mmitsCo
unter
class
WebIdeCounter
extend
RedisCounter
def
self
.
redis_counter_key
'WEB_IDE_COMMITS_COUNT'
COMMITS_COUNT_KEY
=
'WEB_IDE_COMMITS_COUNT'
class
<<
self
def
increment_commits_count
increment
(
COMMITS_COUNT_KEY
)
end
def
total_commits_count
total_count
(
COMMITS_COUNT_KEY
)
end
end
end
end
...
...
qa/Gemfile
View file @
8aea268f
...
...
@@ -10,6 +10,7 @@ gem 'selenium-webdriver', '~> 3.12'
gem
'airborne'
,
'~> 0.2.13'
gem
'nokogiri'
,
'~> 1.10.3'
gem
'rspec-retry'
,
'~> 0.6.1'
gem
'rspec_junit_formatter'
,
'~> 0.4.1'
gem
'faker'
,
'~> 1.6'
,
'>= 1.6.6'
gem
'knapsack'
,
'~> 1.17'
gem
'parallel_tests'
,
'~> 2.29'
qa/Gemfile.lock
View file @
8aea268f
...
...
@@ -87,6 +87,8 @@ GEM
rspec-retry (0.6.1)
rspec-core (> 3.3)
rspec-support (3.7.0)
rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0)
rubyzip (1.2.2)
selenium-webdriver (3.141.0)
childprocess (~> 0.5)
...
...
@@ -116,6 +118,7 @@ DEPENDENCIES
rake (~> 12.3.0)
rspec (~> 3.7)
rspec-retry (~> 0.6.1)
rspec_junit_formatter (~> 0.4.1)
selenium-webdriver (~> 3.12)
BUNDLED WITH
...
...
scripts/merge-html-reports
0 → 100755
View file @
8aea268f
#!/usr/bin/env ruby
require
'nokogiri'
main_report_file
=
ARGV
.
shift
unless
main_report_file
puts
'usage: merge-html-reports <main-report> <base-artifact-url> [parallel reports...]'
exit
1
end
base_artifact_url
=
ARGV
.
shift
unless
base_artifact_url
puts
'usage: merge-html-reports <main-report> <base-artifact-url> [parallel reports...]'
exit
1
end
# Create the base report with empty body tag
new_report
=
Nokogiri
::
HTML
.
parse
(
File
.
read
(
ARGV
[
0
]))
new_report
.
at_css
(
'body'
).
remove
empty_body
=
Nokogiri
::
XML
::
Node
.
new
(
'body'
,
new_report
)
new_report
.
at_css
(
'head'
).
add_next_sibling
(
empty_body
)
ARGV
.
each
do
|
report_file
|
report
=
Nokogiri
::
HTML
.
parse
(
File
.
read
(
report_file
))
report
.
css
(
'a'
).
each
do
|
link
|
link_suffix
=
link
[
'href'
].
slice
(
19
..-
1
)
link
[
'href'
]
=
base_artifact_url
+
link_suffix
end
header
=
report
.
css
(
'div #rspec-header'
)
tests
=
report
.
css
(
'dt[id^="example_group_"]'
)
tests
.
each
do
|
test
|
title
=
test
.
parent
group
=
title
.
parent
script
=
title
.
css
(
'script'
)
if
script
.
inner_html
.
include?
'makeYellow'
test
.
remove_class
(
'passed'
)
test
.
add_class
(
'not_implemented'
)
group
.
remove_class
(
'passed'
)
group
.
add_class
(
'not_implemented'
)
header
.
add_class
(
'not_implemented'
)
script
.
remove
test
.
next_sibling
.
remove
test
.
next_sibling
.
remove
elsif
script
.
inner_html
.
include?
'makeRed'
test
.
remove_class
(
'passed'
)
test
.
add_class
(
'failed'
)
group
.
remove_class
(
'passed'
)
group
.
add_class
(
'failed'
)
header
.
add_class
(
'failed'
)
script
.
remove
test
.
next_sibling
.
remove
test
.
next_sibling
.
remove
end
end
duration
=
report
.
at_css
(
'p#duration'
)
totals
=
report
.
at_css
(
'p#totals'
)
duration_script
=
report
.
css
(
'div.results script'
)[
-
2
]
totals_script
=
report
.
css
(
'div.results script'
)[
-
1
]
duration_text
=
duration_script
.
text
.
slice
(
49
..-
3
)
totals_text
=
totals_script
.
text
.
slice
(
47
..-
3
)
duration
.
inner_html
=
duration_text
totals
.
inner_html
=
totals_text
duration_script
.
remove
totals_script
.
remove
# Add the new result after the last one to keep the test order
new_report
.
css
(
'body'
)[
-
1
].
add_next_sibling
(
report
.
at_css
(
'body'
))
end
File
.
write
(
main_report_file
,
new_report
)
spec/lib/gitlab/usage_data_counters/redis_counter_spec.rb
deleted
100644 → 0
View file @
dcec1415
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
UsageDataCounters
::
RedisCounter
,
:clean_gitlab_redis_shared_state
do
context
'when redis_key is not defined'
do
subject
do
Class
.
new
.
extend
(
described_class
)
end
describe
'.increment'
do
it
'raises a NotImplementedError exception'
do
expect
{
subject
.
increment
}.
to
raise_error
(
NotImplementedError
)
end
end
describe
'.total_count'
do
it
'raises a NotImplementedError exception'
do
expect
{
subject
.
total_count
}.
to
raise_error
(
NotImplementedError
)
end
end
end
context
'when redis_key is defined'
do
subject
do
counter_module
=
described_class
Class
.
new
do
extend
counter_module
def
self
.
redis_counter_key
'foo_redis_key'
end
end
end
describe
'.increment'
do
it
'increments the web ide commits counter by 1'
do
expect
do
subject
.
increment
end
.
to
change
{
subject
.
total_count
}.
from
(
0
).
to
(
1
)
end
end
describe
'.total_count'
do
it
'returns the total amount of web ide commits'
do
subject
.
increment
subject
.
increment
expect
(
subject
.
total_count
).
to
eq
(
2
)
end
end
end
end
spec/lib/gitlab/usage_data_counters/web_ide_counter_spec.rb
0 → 100644
View file @
8aea268f
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
UsageDataCounters
::
WebIdeCounter
,
:clean_gitlab_redis_shared_state
do
describe
'.increment_commits_count'
do
it
'increments the web ide commits counter by 1'
do
expect
do
described_class
.
increment_commits_count
end
.
to
change
{
described_class
.
total_commits_count
}.
by
(
1
)
end
end
describe
'.total_commits_count'
do
it
'returns the total amount of web ide commits'
do
2
.
times
{
described_class
.
increment_commits_count
}
expect
(
described_class
.
total_commits_count
).
to
eq
(
2
)
end
end
end
spec/requests/api/commits_spec.rb
View file @
8aea268f
...
...
@@ -281,7 +281,7 @@ describe API::Commits do
end
it
'does not increment the usage counters using access token authentication'
do
expect
(
::
Gitlab
::
UsageDataCounters
::
WebIdeCo
mmitsCounter
).
not_to
receive
(
:increme
nt
)
expect
(
::
Gitlab
::
UsageDataCounters
::
WebIdeCo
unter
).
not_to
receive
(
:increment_commits_cou
nt
)
post
api
(
url
,
user
),
params:
valid_c_params
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