307 Commits

Author SHA1 Message Date
Han-Wen Nienhuys
b0fb0a7a96 Remove 'final' from method signatures across gerrit.
Change-Id: I986a5507aa26ceb28305a7b08991e85238bde0e3
2017-06-14 09:18:42 +02:00
Alice Kober-Sotzek
03c48fc727 Merge "Add support for specifying the cherry-pick base commit" 2017-06-13 11:48:33 +00:00
Changcheng Xiao
e333258b94 Add support for specifying the cherry-pick base commit
This change extends the existing cherry-pick endpoints to allow
users to specify the base commit of the cherry-pick destination.

If the base commit represents a visible change revision on the
destination branch, the change status must be either 'New' or
'Merged'.

Alternatively, the base commit can be a merged commit on the
destination branch with no change associated with it.

Change-Id: I6721a2d88f4b73058dc1abf3e85c4184e46088c5
2017-06-13 12:57:15 +02:00
Edwin Kempin
5bd5e163f3 AbstractDaemonTest: Rename AccountCreator variable to 'accountCreator'
This frees the 'accounts' name so that it can be used for an instance of
the Accounts class in the follow-up change.

Change-Id: Icc3077b4848076a17d3a832f41307abe6de1d87e
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-06-09 16:10:37 +02:00
Edwin Kempin
9e1dc88e1e AccountCreator: Evict account from cache after adding it to group
The AccountState instance which is held in the account cache contains
the internal groups that the account is member of. Hence the account
needs to be evicted from the account cache when its group memberships
are modified.

Missing to evict the account from the cache leads to failures in
SuggestReviewersIT if SSH is disabled. If SSH is enabled another cache
eviction happens when the SSH key is added, and hence the tests succeed.

Change-Id: I600b7af263d0cd8dcd9c614809f34a0a9a19c895
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-06-08 18:35:21 +02:00
Alice Kober-Sotzek
cfb5a76489 Merge changes from topic 'ccs'
* changes:
  Preserve ReviewerState when reverting a change
  Persist CCs on Git push
2017-06-08 14:37:19 +00:00
Patrick Hiesel
8e6dafd7ba Persist CCs on Git push
Previously, we have sent an initial email to CCs added upon push, but
have not persisted them. This change adds logic and tests to do so.

CCs have native support in NoteDb and legacy support in ReviewDb where
they are added as reviewers instead. This mirrors what we do in
PostReviewers and PostReview.

Change-Id: I4177526707141ffe676a5e4db534aeb740b7d53f
2017-06-08 14:44:39 +02:00
Edwin Kempin
2d795a5769 Merge changes Iefc47c2d,I08d5c756,I1af02c75,Iebde73b6,I2d1b2e05, ...
* changes:
  AccountAccess: Remove unused methods
  Let AccountsUpdate take care to evict accounts from the account cache
  Let ExternalIdsUpdate take care to evict accounts from the account cache
  Do atomic account updates through AccountsUpdate class
  Update accounts through AccountsUpdate class
  Get accounts through Accounts class
  AllAccountsIndexer: Don't load all accounts, but get IDs from user branches
  Replace AccountAccess#firstNById(int) by looking at user refs
  Remove AccountAccess.anyAccounts and instead check if user branches exist
  Prevent creation of non-user branches in All-Users under refs/users/
  Disallow creation of user branches
2017-06-08 06:01:15 +00:00
David Pursehouse
2d643e63ee Merge branch 'stable-2.14'
* stable-2.14:
  Format Java files with google-java-format
  Allow to use AccountCache out of request scope

Change-Id: I016903aa6897c3a000334c7cc758d4caad483fd0
2017-06-08 11:07:54 +09:00
David Pursehouse
a85e8147b3 Format Java files with google-java-format
Change-Id: If362fdd79ef3ab6898c3e5bbf575793edfcf1fe6
2017-06-08 11:05:15 +09:00
Edwin Kempin
f36b3d7a75 Let AccountsUpdate take care to evict accounts from the account cache
Accounts need to be evicted from the account cache when they are
updated. Instead of leaving this responsibility to the caller let
AccountsUpdate take care of this. This is more convenient and ensures
that none of the callers forgets about it.

Accounts also need to be evicted from the account cache on creation,
since the account cache may hold an empty AccountState instance for that
account ID (if it was requested from the account cache before and was
found missing).

After updating accounts they also need to be reindexed, but this is
automatically done when accounts are evicted from the account cache.

Change-Id: I08d5c756eabd43c29bdc217e7b1c3d85ebf15197
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-06-07 16:35:51 +02:00
David Pursehouse
9552ec8226 Merge branch 'stable-2.14'
* stable-2.14:
  Introduce GlobalPluginConfig{s} annotations
  Clarify usage of @GerritConfig#value() and #values()
  Clarify usage of GerritConfig#name()
  GerritServer: Split annotation sanity check to a separate method

Change-Id: I8c7e145ec4ddacd049f7d908fd74dcf0046c677e
2017-06-06 09:37:41 +09:00
David Pursehouse
52e337f818 Introduce GlobalPluginConfig{s} annotations
GlobalPluginConfig and GlobalPluginConfigs can be used to annotate
test methods in plugin tests, to provide test configuration values
in $site/etc/plugin-name.config.

The annotations work in the same way as existing GerritConfig{s}, with
addition of "pluginName" parameter.

A limitation of these annotations is that they must be used together
with @UseLocalDisk, so that the plugin configuration files may be
written in the site's etc folder.

Change-Id: I11a66eac87bec5f849858d1a4f38d3f01976ff47
2017-06-05 11:51:33 +00:00
David Pursehouse
6e1131c763 Clarify usage of @GerritConfig#value() and #values()
If the value() is given, it takes precedence over values(), i.e.
values() is ignored if value() is specified.

Add Javadoc and a test to clarify this behavior.

Change-Id: I1bf8bd732f973a8d7106601d54680728ad1e0763
2017-06-03 15:25:43 +09:00
David Pursehouse
d2a95d21c0 Clarify usage of GerritConfig#name()
Add Javadoc to clarify that the name() parameter of the @GerritConfig
annotation can be used to specify settings like:

 [section]
   name = value

aswell as

 [section "subsection"]
   name = value

Also update the tests to use values that make this usage clearer, and
add extra tests to cover the subsection functionality.

Change-Id: Id06d811a26b0127c1bf0540514537b696c457a46
2017-06-03 15:11:52 +09:00
David Pursehouse
4a618f5d0b GerritServer: Split annotation sanity check to a separate method
Change-Id: Ie9ecdc29054093f5e29261d159177c02fc260b1b
2017-06-03 10:25:00 +09:00
David Pursehouse
1fec9396b3 Set version to 2.14.1-SNAPSHOT
The API includes some new classes since 2.14 and we need to be able
to build snapshot artifacts to test plugins that use the new classes.

Change-Id: Ifad31b93e5b5068c0d6952582f6882edc252e227
2017-05-26 11:20:43 +09:00
Han-Wen Nienhuys
ae0c04cf5c Standardize ordering of AbstractDaemonTest#block/deny/allow arguments
The new standard ordering is (project, ref, permission, [force], ID)

Change-Id: I20387e5349218322ecd8fd5529532d9a9ae57b0d
2017-05-18 15:55:52 +09:00
David Ostrovsky
946d6c3b14 Move prolog:common rule to gerrit-server root build file
Change-Id: Iacbff16b71d8464ccea6d2b631868e24a0605ec4
2017-05-18 06:17:11 +02:00
Dave Borowitz
2c5f910bc0 TestAccount: Build HTTP URL more robustly
* Use URIBuilder, which does proper escaping.
* Use toUriString to properly enclose IPv6 addresses in square brackets.

Change-Id: Ibc4b714010520b098cf8293ce60e1077add2102e
2017-05-16 17:30:41 -04:00
David Pursehouse
2ae3b327d6 Merge branch 'stable-2.14'
* stable-2.14:
  Update list of maintainers in pom.xml files

Change-Id: I59270a205415a040312e36f89a66c665953d5908
2017-05-15 16:42:35 +09:00
David Pursehouse
3c0899307e Update list of maintainers in pom.xml files
Change-Id: I9bc103431c674b892d696490e7638a2a2f4ac408
2017-05-15 16:27:18 +09:00
Edwin Kempin
276b8a897f Migrate external IDs to NoteDb (part 3)
This is the third part of migrating external IDs from ReviewDb to
NoteDb.

This change:
* changes the code to always read external IDs from NoteDb (the
  user.readExternalIdsFromGit configuration parameter is removed)
* bumps the database schema version
* deletes the database table for external IDs

Pushing to the refs/meta/external-ids branch is still prevented by a
commit validator. Since all external IDs are now in NoteDb only we
could allow pushing to refs/meta/external-ids. However we would still
like to do validation of the branch content and reject invalid content
(e.g. invalid Git config files, usage of non-existing account IDs
etc.) and such a validator is not implemented yet (but can be
implemented in a follow-up change).

Change-Id: Id9e5574a1d8d82f4f48fbb0b6dadc0e27d138a28
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-05-10 08:51:44 +02:00
Patrick Hiesel
38667d4f51 Add parent parameter to GetContent
PolyGerrit has a hard time showing the diff view for binary files like
images. To get the base, it has to request it separately using the
parent commit SHA1, which is expensive.

This commit adds a 'parent' parameter to GetContent in the same way that
it is done for DownloadContent. This way, PolyGerrit can use the same
endpoint and avoid expensive permission checks since users who can see a
change are also allowed to see the base commit.

Change-Id: Id6b4d0ea994282d9b4942f9ec1a8f4071a1064b1
2017-05-05 15:43:44 +02:00
Dave Borowitz
0a1cd17adb Pull BatchUpdate.Factory field up into AbstractDaemonTest
Change-Id: Ie3c0d314b7edd01e3710acdf452c96dc8e94cc90
2017-05-02 16:25:20 -04:00
Dave Borowitz
94d4cbdfba AbstractDaemonTest: Reorder fields
* Remove extra blank lines, which is allowed by google-java-format.
* Separate protected from private members and injected from non-.
* Sort lexicographically within groups.

Change-Id: I4e9a192126247b70a43261c70cfa146bb9abc75c
2017-05-02 16:25:20 -04:00
Dave Borowitz
ca1f55056b AbstractDaemonTest: Use a RuleChain for dependent Rules
beforeTest assumes that the tempSiteDir has already been created.
Unfortunately, rule evaluation order is arbitrary, depending on runtime
field iteration order. We have been lucky for a long time that
tempSiteDir always got initialized first.

Use a RuleChain instead to express this dependency explicitly.

Change-Id: Ib82071fa3feff3d51cf58f6c61df0ec02ec54a6f
2017-05-02 16:19:55 -04:00
Logan Hanks
2ed5792dd4 Block submission if work in progress
Change-Id: I1139416eefc427ff625ad2224f849530727adf39
2017-04-28 15:25:21 +02:00
David Pursehouse
03453bef90 Set version to 2.14
Change-Id: I5694579a543454322717a1d129e34d4140100479
2017-04-26 15:55:55 +02:00
Dave Borowitz
ecd4831c73 TestNotesMigration: Initialize from env during constructor
I want to use TestNotesMigration from within InMemoryRepository at the
time the schema is created. The previous approach of calling setFromEnv
from AbstractDaemonTest#beforeTest was too late for this usage. There is
no way to move it earlier in AbstractDaemonTest, because we don't have
the TestNotesMigration until it's injected, which is after the schema is
created.

Instead, move initialization into the TestNotesMigration constructor, so
we never use an uninitialized instance. Keep the setFromEnv
functionality, but call it resetFromEnv. Call it after tests in case
tests have modified the values during tests.

Change-Id: Ib7cdcd97792edf4d278cdaea735a4fbedfd49ca3
2017-04-25 06:26:36 -04:00
Patrick Hiesel
e8bf91efaf Release 2.14-rc1
Change-Id: I85790145f2114b4ab9801a78fddc201e59766a8e
2017-04-24 16:03:54 +02:00
David Pursehouse
0450fde6ac Merge branch 'stable-2.14'
* stable-2.14:
  Add new Polygerrit maintainers to developers list in pom.xml files

Change-Id: I7f3e251081493b87e31075b1a1fa4779f8de1c4b
2017-04-22 06:33:24 +02:00
David Pursehouse
c211c0f9fa Add new Polygerrit maintainers to developers list in pom.xml files
Change-Id: I67bce6cb15e416f213633519bc1274a0aefddf35
2017-04-21 22:22:44 +02:00
Edwin Kempin
c9c54da9e1 Create a user branch for every account
Make sure that for every account a user branch exists that has an
initial empty commit with the registration date as commit time. The
commit timestamp of the first commit on a user branch will be used as
registration timestamp when accounts are stored in NoteDb.

When an account is created create the user branch with an initial
empty commit that has the registration date as commit time.

For existing accounts add a schema migration that:

- creates the user branch with an initial empty commit that has the
  registration date as commit time if the user branch doesn't exist yet
- rewrites the user branch if it already exists and inserts an initial
  empty commit with the registration date as commit time (if such a
  commit doesn't exist yet).

Change-Id: I81491a253350a43f094fdfcb32298efde0cb086a
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-04-19 17:18:15 +02:00
Dave Borowitz
3396e57b52 Disable ReindexAfterRefUpdate in tests
This functionality causes a race during tests that may cause flaky
failures. Specifically, in the case of
ChangeIT#abandonAndRestoreAllowedWithPermission:

1. ACL grant on the main thread (A) modifies refs/meta/config, which
   triggers ReindexAfterRefUpdate, which kicks off a background task
   (thread B) to search for and reindex affected changes.
2. B reads change from primary storage, observes that it is open, and
   constructs a document.
3. A abandons the change, saves the result in primary storage.
4. A indexes the change, deleting it from the open index and adding it
   to the closed index.
5. B indexes the document it constructed in (2), adding it to the open
   index.
6. A attempts to look up the change, finds it in both the open and
   closed indexes, and explodes.

Turning off auto-reindexing causes tests to pass.

The race still exists in running servers, although in practice the
inconsistent cases are fleeting and the index should usually end up in a
consistent state. More details and reflections are in the bug.

Bug: Issue 5944
Change-Id: Ifca5a1065852db38a562755b652fad3de3672816
2017-04-17 17:01:49 -04:00
David Pursehouse
d11fadd64d AbstractDaemonTest: Format with google-java-format
Change-Id: I33b577f742f91958068118d1545480d446bc9297
2017-04-14 08:20:54 +09:00
Changcheng Xiao
9a3b435080 Move repository registration out of AbstractDaemonTest#cloneProject
By moving out the repository registration, we can get the registered URI
which can be used to connect to the repository for both fetch and push.

This makes it possible to clone a remote repository to another remote
repository in the integration test and both of them are managed by
GitRepositoryManager.

Change-Id: Ic941ae184249bb9521da52350ae45b24cfe5f8c9
2017-04-13 15:33:01 +02:00
Dave Borowitz
63f9ee8e36 Merge "Update code refs and NoteDb meta refs in one batch" 2017-04-12 18:50:06 +00:00
Dave Borowitz
18349b9a19 Update code refs and NoteDb meta refs in one batch
Within NoteDbBatchUpdate, always use the revwalk, inserter, and
commands from the single RepoView associated with the update. All
BatchUpdateOp#updateChange implementations have been converted to
inspect the limited kinds of repo state exposed by RepoView, so they
will see the results of updateRepo even though the ref updates have not
been executed yet.

One complication comes from the fact that NoteDbUpdateManager really
wants to control execution of the BatchRefUpdates via its own execute
method. We have to make sure the execute method is deferred until after
updateRepo has been called. This requires expanding the previous
ChangeResults returned by executeChangeUps into something a little more
beefy.

Change-Id: Ia5b34bae93630f6d4dbeddb4ad5ce725ba5c6147
2017-04-12 11:38:03 -04:00
David Pursehouse
1f26b86cf4 Merge branch 'stable-2.14'
* stable-2.14:
  PushOneCommit: Use simple counter for Change-Id

Change-Id: Ifeda7c20dc12aa65f42534cfa15d3975ab6c2235
2017-04-12 16:45:35 +09:00
Dave Borowitz
ca7069f766 PushOneCommit: Use simple counter for Change-Id
Using a simple counter makes it clearer that the generated Change-Ids
are guaranteed to be unique.

Change-Id: I0154bb05ea1969a2684b247ce1661d65591526ad
2017-04-12 16:06:54 +09:00
David Pursehouse
05e558972c Merge branch 'stable-2.14'
* stable-2.14:
  Add new maintainers to developers section in pom.xml files
  Update Version to 2.14-rc0

Change-Id: Ib620c5f49ec5dee1a838c082f74b785689edba71
2017-04-12 09:44:54 +09:00
David Ostrovsky
6100054dbd Add new maintainers to developers section in pom.xml files
Change-Id: I2f6133a27e6f3a036f82442d5fcdc5a1b6c35f9a
2017-04-11 21:13:05 +02:00
Patrick Hiesel
ee94d108fe Update Version to 2.14-rc0
Change-Id: Ibafb67dcf186a6ec68f39009074cc210877979e5
2017-04-11 15:12:36 +02:00
Edwin Kempin
74ddf290a3 Add an AccountsUpdate class to update accounts from a single class
As a first step AccountsUpdate is only responsible for creating new
accounts. Additional functionality to update accounts will be added
later.

This is another step towards migrating accounts from ReviewDb to NoteDb.
In the end all code that needs to update accounts should use
AccountsUpdate. AccountsUpdate can then take care to update the accounts
in ReviewDb and NoteDb.

Change-Id: I77e3a664e23bfa579da7da7c1e86823e7ad905eb
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-04-07 08:20:56 +02:00
Edwin Kempin
6702433385 Let all tests use AccountCreator to create accounts
For this the AccountCreator must support creating accounts without
username.

This reduces the number of places where accounts are created, which is a
preparation step for migrating the accounts to NoteDb

Change-Id: If67aaf2d713b7599e27ba087ac2f83cc99e23376
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-04-06 15:35:47 +02:00
David Pursehouse
83e66ea953 Merge branch 'stable-2.14'
* stable-2.14:
  Prevents 2x stop() calls during IntegrationTest
  Add missing documentation of assignee related search operators
  Rename StartStopDeamonIT to StartStopDaemonIT
  Add integration test to check for thread leaks in sandboxed Daemon tests
  Fix intopic predicate with regex

Change-Id: Icea87f9bed4711ee2744e5d2a0127b50297df046
2017-04-05 16:42:13 +09:00
Luca Milanesio
0bee4f97ce Prevents 2x stop() calls during IntegrationTest
It seems that NoteDB does not manage gracefully the double
invocations of the GerritServer.stop and throws a NPE.

However, that is really a corner case that never happens in
real life; setting the server instance to null prevents
multiple close() invocations on the same server object.

Change-Id: I34da521830ca4caa935c2968c567cc5f4daca44d
2017-04-05 07:39:48 +01:00
Luca Milanesio
5b42a126ef Add integration test to check for thread leaks in sandboxed Daemon tests
Change-Id: Iaebf022608a56618f06550568ac283f0c0ab7f0e
2017-04-05 08:58:09 +09:00
David Ostrovsky
bfa7a2f0a7 Callable: Replace classes with lambda expression
In Java 8 Callable is functional interface and can be replaced with
lambda expressions.

Change-Id: I32907f32c9dc3f394da64f22c384e8f3c33670d4
2017-04-01 21:47:49 +02:00