36513 Commits

Author SHA1 Message Date
Dave Borowitz
edd57a21d6 Error Prone: Enable and fix OperatorPrecedence
Change-Id: I1c9e79a37cba650b1526793fc7997544bb99aafc
2020-02-17 09:00:16 +09:00
David Ostrovsky
17ef12713b GerritBaseTests: Activate test logging
Test logging is already activated in test derived from
AbstractDaemonTest. Extract the code to activate the test logging in
new TestLoggingactivator class and also activate the log for tests
derived from GerritBaseTests class.

Also document in dev-bazel.txt how to increase log level for tests from
IDE and from Bazel.

Also remove some superfluous white spaces from dev-bazel.txt.

Change-Id: I7641bfcffa35e36c0330dc9244ceafd8366159ca
2020-02-16 15:06:28 +01:00
David Ostrovsky
9fa32699a7 Revert "Enable optional DEBUG level logs for query tests"
This reverts commit c54e6b5bfd4644ba06292af6a2a961cecda7ab28.

Reason for revert: A similar feature to increase the logging level was
already added by: I00c203419db. Instead of adding a dedicated handling
of logging for query tests only, logging activation and configuration
should be generally extended to all tests derived from GerritBaseTests.

Change-Id: I7be6b13dcc74f5a108b5e32e4b0e7a8dec489963
2020-02-16 14:56:52 +01:00
Edwin Kempin
54a7c90065 Allow to control the Gerrit log level for running tests from system var
The log level for the 'com.google.gerrit' package when running tests can
now be controlled by the 'GERRIT_LOG_LEVEL' system variable.
Alternatively if the system variable is not set, the log level can be
also set by the 'gerrit.logLevel' system property. Allowed values are
DEBUG, INFO, WARN, ERROR, FATAL, OFF, TRACE and ALL (case-sensitive,
also see org.apache.log4j.Level).

If not set, or set to an invalid value, the default log level is INFO.
Once the CI server was adapted to set the system variable we may change
the default log level back to DEBUG so that debug logs are generated
when running tests locally (we had to lower the log level from DEBUG
to INFO because the log amount was too large for the CI server to
display, see Change I6b13ee504).

Bug: Issue 11953
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I00c203419dbdff568f51bbdcc2edeaf0b8fa7df8
2020-02-16 13:33:33 +01:00
David Ostrovsky
47f9ac4be3 Revert "Acceptance: set log threshold level for tests"
This reverts commit a73d761b8a6cbf1626e7daf83214ea94b5e18960.

Reason for revert: log level for tests was reduced to INFO per default
in I6b13ee50459.

Moreover, the search in: [1], reveals that there is no usages of this
annotation in gerrit core and plugins.

[1] https://cs.bazel.build/search?q=r%3Agerrit+LogThreshold

Change-Id: Ic3b1d7bb06bd5a49870ec2ff44982cdced150091
2020-02-16 13:33:25 +01:00
Edwin Kempin
bc37e832ec Reduce log level for tests to INFO
The amount of logs that is generated by running the tests is too large
to view it on the CI. Loading a build log in the browser takes so long
that it becomes unusable. This makes it difficult to find the reason for
a failed build/test on the CI.

As this is affecting daily development we need to resolve this quickly,
hence let's reduce the log level for tests to INFO for now.

Having debug logs available to investigate a test failure is good, but
debug logs for passing tests are not useful. Ideally the CI would just
hide debug logs of passing tests, but while the CI doesn't have this
capability we can only reduce the log level for now.

This also affects the log level for running tests locally.

Bug: Issue 11953
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I6b13ee50459bec18ef1c701fe30c992634ed26d5
2020-02-16 13:33:05 +01:00
David Ostrovsky
88483ed218 Bazel: Update time attribute of file entries in plugin artifact
Due to this Bazel issue: [1] non .class file entries are normalized in
singlejar Bazel utility. As the consequence even JavaScript and HTML
files have the timestamp: 2010-01-01 00:00. This makes it problematic
to refresh the plugin artifacts in browser because of the cache if a
new plugin version is deployed in Gerrit server.

To rectify, touch the content of the plugin artifact in stamp action.

The 'touch' command uses the system default timezone if none is
supplied. This makes zip files dependent on the timezone of the
generating machine.

Zip by default stores extended attributes (eg. ctime, atime) on Unix
systems. These can be further sources of non-determinism, so switch it
off with --no-extra.

[1] https://github.com/bazelbuild/bazel/issues/10789

Bug: Issue 12349
Change-Id: Ifcb027f42c20f785f14e9933c061af27285e99c4
2020-02-15 09:57:20 +00:00
David Pursehouse
3c953acc7a Merge "Add Jetty connection metrics" into stable-2.16 2020-02-14 13:56:13 +00:00
Matthias Sohn
baa006bc47 Add Jetty connection metrics
Change-Id: I7ba60bda1629d069b32feb9d5eb1aa24dca5086c
2020-02-14 13:41:17 +01:00
Matthias Sohn
028a01d01e Add additional JGit WindowCache metrics
Adapt JGit metrics to new WindowCache metrics introduced in JGit 5.1.13:
- cache_used: replace use of deprecated method
- open_files: adapt type which changed from int to long

Add the following new metrics:
- avg_load_time
- eviction_count
- eviction_ratio
- hit_count
- hit_ratio
- load_failure_count
- load_failure_ratio
- load_success_count
- miss_count
- miss_ratio
- cache_used_per_repository, limited to the top 1000 repositories having
most data cached

Change-Id: I6d4c76a85943ea23d57d15d4f6bdeb91711a1a63
2020-02-14 13:38:59 +01:00
Matthias Sohn
79bec412a1 Update JGit to 5.1.13.202002110435-r
JGit 5.1.13.202002110435-r adds
- new WindowCache metrics
- and enables using strong references to reference cache pages in the
WindowCache. Set core.packedGitUseStrongRefs = true to enable using
strong references to reference packfile pages cached in the WindowCache.
If this option is set Java gc can no longer flush the WindowCache to
free memory if the used heap comes close to the maximum heap size. On
the other hand this provides more predictable performance.

Change-Id: I895369a8596dfc5adce76c65202ecf37e6a8386d
2020-02-14 13:38:59 +01:00
Matthias Sohn
32f2566275 BucketedCallback: fix prune() to remove unset sub-metrics from registry
BucketedCallback enables defining compound metrics having a set of
sub-metrics along a dimension. This is used e.g. in CallbackMetric1
where the additional type parameter F1 defines the type of this
dimension. For each of the values of this dimension present in the
current dataset of the compound metric BucketedCallback registers a
corresponding metric in DropWizard's metric registry which isn't aware
of the relationship between a compount metric in Gerrit and the
corresponding sub-metrics.

If another measurement yields a new metric dataset which no longer
contains some of the earlier registered sub-metrics doPrune() did remove
these stale sub-metrics from the "cells" collection but missed to remove
them from DropWizard's metric registry. This had the effect that such
stale metrics no longer present in the current dataset were still
reported via the used metrics reporter plugin albeit the underlying
monitoring dataset didn't contain that data anymore.

Fix this by removing the stale sub-metrics also from the DropWizard
metric registry.

Change-Id: I767530f57883379c976614705241cbd1d1597541
2020-02-14 13:38:59 +01:00
Youssef Elghareeb
e9ab0e6564 Merge "Modify draft ref updates commits to point to an empty parent" into stable-2.16 2020-02-14 11:53:14 +00:00
Youssef Elghareeb
4f77b29cb9 Modify draft ref updates commits to point to an empty parent
Draft comments refs are stored in the "All-Users" repo under a special
ref with the form refs/draft-comments/$change_id_short/$change/$user.

Previously, ref updates used fast forward updates for all operations
(add draft, delete draft, edit draft), and the new commit pointed to the
last commit of the ref. This behavior caused draft deletions to persist
in history.

In this change, the implementation of the change draft update is
modified so that new commits point to an empty parent list, causing
draft deletions to be garbage collected by git after a period of time.

Change-Id: Ifbb7ad2fe1b1370eac30feb3fe7b181cbb626257
2020-02-14 12:11:32 +01:00
David Pursehouse
03e0ff2a3e Merge "Fix Access when the only readable ref is a RegExp with a gerrit pattern" into stable-2.16 2020-02-13 22:14:35 +00:00
Guillaume Chauvel
80f75734e7 Fix Access when the only readable ref is a RegExp with a gerrit pattern
When no other ref than a RegExp with a gerrit username or shardeduserid
pattern, the permission is not properly validated and repository access
is denied.

With change Iedf3022f6c, calling shortestExample on regexp+parameters
refs produces a reference that won't match the username or the
shardeduserid.

For a reference like : ^refs/heads/users/${username}/.+
we will have the following:
'refs/heads/users/user1/my_branch' vs
'refs/heads/users/_PLACEHOLDER_/my_branch'

When we remove shortestExample, we have to modify Regexp and
ExpandParameters to skip the regexp start anchor caracter when comparing
against the prefix, or to compare regexps themselves.

Bug: Issue 3340
Change-Id: Id6a890a91c5d6d954dab74694c2d3fd53c15897c
2020-02-13 22:13:45 +00:00
Marco Miller
daf865d398 Merge "Fix refPattern when using username/shardeduserid pattern with regexp" into stable-2.16 2020-02-13 18:51:58 +00:00
Marco Miller
58b8f03671 Merge "Enable optional DEBUG level logs for query tests" into stable-2.16 2020-02-13 18:39:33 +00:00
Guillaume Chauvel
1b4b264adf Fix refPattern when using username/shardeduserid pattern with regexp
The special regexp caracters ('{', '}') from gerrit pattern are causing
an exception. As ${username} and ${shardeduserid} are only meaningful to
gerrit, we substitute them for placeholders.

Unlike what is done in RefPatternMatcher.ExpandParameters, the
placeholder does not contain ':' but '_' to be correctly evaluated by
Repository.isValidRefName later on.

Bug: Issue 3340
Change-Id: Iedf3022f6ce3068f7e9534f224cf05bb99b0f970
2020-02-13 10:39:33 +09:00
David Pursehouse
9a5141f0ad Consistently declare 'throws Exception' from @Test annotated methods
Change-Id: I1948607db496d0a9b8d933c1a870ecc97434dd13
2020-02-13 08:53:44 +09:00
Hamza Kaced
c54e6b5bfd Enable optional DEBUG level logs for query tests
Allow optionally enabling DEBUG level logs for Lucene and Elasticsearch
query tests. It occurs in the form of a command passed to the JVM before
tests start. Tests will only emit INFO level logs if not enabled.

Enable rootLogger default INFO log level after tests conclude.

Add missing log4j-config rule which includes log4j.properties in BUILD
files.

Update online Gerrit documentation to explain how to optionally enable
DEBUG log level for these specific tests.

Bug: Issue 10498
Change-Id: I75492de1c5ef8721ae745266e36b8cbfb0b67682
2020-02-12 11:58:05 -05:00
Edwin Kempin
d3f5bccb39 Merge "ProjectCacheImpl: Don't log cause when project is not found" into stable-2.16 2020-02-12 15:26:35 +00:00
David Pursehouse
3005e188c8 ProjectCacheImpl: Don't log cause when project is not found
This occurs very frequently and the cause is always the same, so
logging with the stack trace spams the logs making it difficult
to find stack traces that are caused by real issues.

Change-Id: I6acc32937ee647337337f99309947b0d414dffad
Signed-off-by: David Pursehouse <dpursehouse@collab.net>
2020-02-12 19:49:35 +09:00
Eryk Szymanski
936ed535a1 VersionedMetaData: Add debug log when saving metadata
Change-Id: I4ad514018bc54c99c48e6e9b6f2000ed61313f49
2020-02-12 19:48:59 +09:00
Tao Zhou
5a7a364ff2 Update web-component-tester to 6.5.1
This will fix the build failure as the sinon.js dependency issue
fixed in upstream (wct 6.5.1)

Change-Id: I871f08e59dcfc0717888aa9f0ade82fc3edc851d
2020-02-12 08:42:20 +01:00
Marco Miller
f386aa3de2 Add support for Elasticsearch version 7.6.*
- Upgrade elasticsearch-rest-client to 7.6.0.
- Add V7_6 to the version manager, and use this in all the V7 tests.
- Use the 7.6.0 image from blacktop in the test container; based on [1].
- Triggered by watching releases [2], which links to the release notes.

[1] https://github.com/blacktop/docker-elasticsearch-alpine/pull/27
[2] https://github.com/elastic/elasticsearch/releases/tag/v7.6.0

Change-Id: I63e6c396b8c159b4ebdfe9817518f239fd62928c
2020-02-12 12:02:02 +09:00
Matthias Sohn
73b8fd117c Write upload-pack metrics to sshd log
In order to enable detailed performance and problem analysis add
upload-pack metrics to the sshd log. The log format for upload-pack log
records is now enhanced to:
- timestamp
- session id
- thread name
- user name
- account id
- message
- command wait time
- command execution time
- time negotiating
- time searching for reuse
- time searching for sizes
- time counting
- time compressing
- time writing
- total time in UploadPack
- bitmap index misses (-1 means no bitmap index available)
- total deltas
- total objects
- total bytes transferred
- client agent

If statistics aren't available e.g. since an exception occurred they are
logged as -1.

Change-Id: I4ec08579cedfeb6a30eb41d2e2a110f4f8eee8fa
2020-02-12 00:34:34 +01:00
David Pursehouse
a13052bad8 Clarify documentation of container.javaOptions
The option may be specified multiple times, but this is not explicitly
clear in the documentation.

Change-Id: I33a6030b00a24f578c79cdd369bff246fd4470b0
2020-02-10 14:35:35 +09:00
David Pursehouse
a70a60cf1f Fix formatting of container.javaOptions section
Change-Id: I9e35dfc5b57bed862443e12fbeeb1e173e101bcd
2020-02-10 14:35:30 +09:00
David Ostrovsky
59ed05a6ed Run polylint tests with bazelisk if available
Change-Id: I342cfef83f812268f95dfb2cb30c52d63a31e622
2020-02-08 19:01:56 +01:00
David Pursehouse
f40935296e Bump required Bazel version to 2.1.0
Change-Id: Ic8662bd6f5a54a155a2ef07c1ea6c2b7371383b0
2020-02-08 10:55:06 +09:00
David Pursehouse
0e9fd39dc7 Bazel: Sort error prone check settings alphabetically
Change-Id: I044749d213e5a2b0b1a6c55c55515aa944e145ff
2020-02-07 13:21:56 +09:00
David Pursehouse
cd4e1d3fee Merge changes I6dd2035d,I6b6710d1,I43c5d7c6 into stable-2.16
* changes:
  Fix method name to register custom event types in plugins
  Don't send mails on publish change edits for WIP changes
  PatchSetInserter: allow to set "sendEmail" bit
2020-02-04 23:13:32 +00:00
David Ostrovsky
5edf70ec11 Fix method name to register custom event types in plugins
Change-Id: I6dd2035de403e3d6ce1d7c78634a3a0ffd8feff1
2020-02-04 22:58:29 +01:00
David Ostrovsky
b88351bc93 Don't send mails on publish change edits for WIP changes
Bug: Issue 10397
Change-Id: I6b6710d17138f277ac118924355311d192710f5c
2020-02-04 22:36:10 +01:00
Changcheng Xiao
47d74d2173 PatchSetInserter: allow to set "sendEmail" bit
With this new "sendEmail" bit, we will have more control
for whether emails are going to be sent out after a new
patch set is added. This is useful for avoiding duplicate
emails, e.g merge (already have an email to notify a change
is merged, no need to have another email to say a new patch
set is uploaded).

Change-Id: I43c5d7c6560316d5a6034dc8e711f7e87b7af932
2020-02-04 22:36:07 +01:00
Luca Milanesio
903e586b13 Set version to 2.16.17-SNAPSHOT
Change-Id: I0de189351cf696c14127f303bfbdcfcb9efe87c3
2020-02-04 16:27:38 +00:00
Luca Milanesio
dd780721ab Set version to 2.16.16
Change-Id: I3d0d1c1e89dd6bc2030056ab8a4ce09189403a06
v2.16.16
2020-02-04 16:01:59 +00:00
Saša Živkov
d4ba7fb691 Merge changes from topic "motd" into stable-2.16
* changes:
  Document MessageOfTheDay extension
  Add UI element to display messages of the day
  Add MessageOfTheDay-entries to ServerInfo
2020-02-03 14:15:54 +00:00
Sven Selberg
15753c282e Tests: Use helper method for config change
Use enableCreateNewChangeForAllNotInTarget() from AbstractDaemonTest
instead of duplicating the code.

Change-Id: Ic2fe137533a7b6ad33fc1705947473766730bf56
2020-02-03 11:49:13 +01:00
David Pursehouse
97331cc168 Merge "Generate Change-Ids randomly instead of computing them from commit content and timestamp" into stable-2.16 2020-02-03 01:59:16 +00:00
Edwin Kempin
79138831e5 Generate Change-Ids randomly instead of computing them from commit content and timestamp
If Change-Ids are computed from the commit content and timestamp it can
happen that 2 changes get the same Change-Id. E.g. this can happen if
the Create Change REST endpoint is used to create empty changes in
parallel. In this case the base commit, the commit content (empty) and
the commit timestamp are the same, so that the same Change-Id is
computed for several changes. This also means that the commit message
and hence the commit SHA1 can be identical between the changes. If in a
follow-up steps identical change edits are published in parallel on
these changes you can even get non-empty changes for the same commit
SHA1. Having multiple changes for the same commit SHA1 (and with the
same target branch) is an inconsistency in Gerrit that Gerrit cannot
deal well with (e.g. this causes issues during submit).

To prevent such duplicate Change-Ids we are now randomly generating
Change-Ids. This means 2 parallel Create Changes requests will use
different Change-Ids even if the commit content and timestamp is the
same. A new test does parallel calls to Create Change REST endpoint and
verifies that commit SHA1's of the created changes differ (they differ
because in the commit message we have different Change-Ids now). When
the Change-Ids were computed from the commit content and timestamp this
test failed.

Also cherry-pick Change-Id: I9de36332 for keeping the secure random
generation out of the GWT-related code and minimise the conflicts
with the merge upstream.

Bug: Issue 12246
Co-authored-by: Luca Milanesio <luca.milanesio@gmail.com>
Change-Id: Ie4f01e5a32b1efca58f8b443ff046623f0e5f188
(cherry picked from commit 73163490b75a8d39aaa2eb60ba2de0cb27f6ba70)
2020-02-02 22:47:20 +00:00
David Ostrovsky
11bce058a0 Highlight WORKSPACE as python
Change-Id: I2f46d6de7989f3951fcea49475c52ea216b25c94
2020-02-02 10:30:18 +01:00
David Ostrovsky
827c929cd5 Highlight BUILD.bazel as python
Bazel supports both BUILD and BUILD.bazel files and in this issue: [1]
there is a discussion to prefer BUILD.bazel over BUILD naming
convention. Detect BUILD.bazel files as Python code in addition to
BUILD files.

[1] https://github.com/bazelbuild/bazel/issues/4517

Change-Id: Iabc719b914fcd08ef6e73c314f09f924540c3794
2020-02-02 10:25:53 +01:00
Matthias Sohn
db1e78649e Move documentation for Jetty metrics to a separate section
Change-Id: Ibdb1516b091c81203c282384dbe8aa2276c838ff
2020-01-31 14:17:10 +01:00
David Pursehouse
c733e8aa38 Merge "Improve Jetty thread pool metrics" into stable-2.16 2020-01-31 12:58:49 +00:00
David Pursehouse
3b569a3fcb Merge "NoteDbMigrator: Totally skip migration for orphan changes" into stable-2.16 2020-01-31 10:15:04 +00:00
Thomas Draebing
cfff720610 Document MessageOfTheDay extension
Change-Id: I99894e9d9b0376e11ac47796cee4c9e2e0c9be5a
2020-01-31 10:45:23 +01:00
Matthias Sohn
ae4a73b87c Improve Jetty thread pool metrics
Follow-up change for be4184f7 which missed documentation. Also names of
newly added metrics didn't align with existing metrics for REST API.

- add documentation for the jetty metrics
- improve descriptions of the jetty metrics
- rename jetty thread pool metrics from httpd/jetty/* to
  http/server/jetty/* in order to align metric names with already
  existing REST API metrics

Change-Id: I1d4eabec91749f28d09df7d2d29606b133fefc4d
2020-01-31 10:42:21 +01:00
Thomas Draebing
1fbf53df60 Add UI element to display messages of the day
This change adds an UI element that displays messages registered with
the MessageOfTheDay extension point. The messages will be displayed
below the main navigation header. This functionality was already part
of the GWT-UI, but was never migrated to the new UI.

The messages can be dismissed by a button click, that will create a
cookie that will prevent the message from being displayed again until
the redisplay time configured with the message.

The content of the message can be HTML. Depending on where the message-
content is coming from, this might be harmful. In case of the
messageoftheday plugin, the message is added as a config from the Gerrit
server site, which can probably be considered save. However, in a future
change rendering HTML should be made configurable and switched off by
default. Text should then be rendered using `gr-formatted-text`.

Change-Id: I2cbbcbcd49734b645701b9fac62a016a269d37f2
2020-01-31 10:14:27 +01:00