Search in sources :

Example 1 with RetryHelper

use of com.google.gerrit.server.update.RetryHelper in project gerrit by GerritCodeReview.

the class AccountIT method failAfterRetryerGivesUp.

@Test
public void failAfterRetryerGivesUp() throws Exception {
    List<String> status = ImmutableList.of("foo", "bar", "baz");
    String fullName = "Foo";
    AtomicInteger bgCounter = new AtomicInteger(0);
    PersonIdent ident = serverIdent.get();
    AccountsUpdate update = new AccountsUpdate(repoManager, gitReferenceUpdated, Optional.empty(), allUsers, externalIds, metaDataUpdateInternalFactory, new RetryHelper(cfg, retryMetrics, null, null, null, exceptionHooks, r -> r.withStopStrategy(StopStrategies.stopAfterAttempt(status.size())).withBlockStrategy(noSleepBlockStrategy)), extIdNotesFactory, ident, ident, () -> {
        try {
            accountsUpdateProvider.get().update("Set Status", admin.id(), u -> u.setStatus(status.get(bgCounter.getAndAdd(1))));
        } catch (IOException | ConfigInvalidException | StorageException e) {
        // Ignore, the expected exception is asserted later
        }
    }, Runnables.doNothing());
    assertThat(bgCounter.get()).isEqualTo(0);
    AccountInfo accountInfo = gApi.accounts().id(admin.id().get()).get();
    assertThat(accountInfo.status).isNull();
    assertThat(accountInfo.name).isNotEqualTo(fullName);
    assertThrows(LockFailureException.class, () -> update.update("Set Full Name", admin.id(), u -> u.setFullName(fullName)));
    assertThat(bgCounter.get()).isEqualTo(status.size());
    Account updatedAccount = accounts.get(admin.id()).get().account();
    assertThat(updatedAccount.status()).isEqualTo(Iterables.getLast(status));
    assertThat(updatedAccount.fullName()).isEqualTo(admin.fullName());
    accountInfo = gApi.accounts().id(admin.id().get()).get();
    assertThat(accountInfo.status).isEqualTo(Iterables.getLast(status));
    assertThat(accountInfo.name).isEqualTo(admin.fullName());
}
Also used : ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException) ExternalIdKeyFactory(com.google.gerrit.server.account.externalids.ExternalIdKeyFactory) KeyPair(java.security.KeyPair) Arrays(java.util.Arrays) OBJ_BLOB(org.eclipse.jgit.lib.Constants.OBJ_BLOB) GlobalCapability(com.google.gerrit.common.data.GlobalCapability) CommentInfo(com.google.gerrit.extensions.common.CommentInfo) PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) TestAccount(com.google.gerrit.acceptance.TestAccount) TestProjectUpdate.deny(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.deny) REGISTERED_USERS(com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) RevWalk(org.eclipse.jgit.revwalk.RevWalk) Config(org.eclipse.jgit.lib.Config) TestKey(com.google.gerrit.gpg.testing.TestKey) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) FluentIterable(com.google.common.collect.FluentIterable) GpgKeyInfo(com.google.gerrit.extensions.common.GpgKeyInfo) Map(java.util.Map) RetryHelper(com.google.gerrit.server.update.RetryHelper) GroupOperations(com.google.gerrit.acceptance.testsuite.group.GroupOperations) TestProjectUpdate.allow(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allow) DeleteDraftCommentsInput(com.google.gerrit.extensions.api.accounts.DeleteDraftCommentsInput) DeletedDraftCommentInfo(com.google.gerrit.extensions.api.accounts.DeletedDraftCommentInfo) GitUtil.deleteRef(com.google.gerrit.acceptance.GitUtil.deleteRef) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) AccessSection(com.google.gerrit.entities.AccessSection) ConsistencyCheckInfo(com.google.gerrit.extensions.api.config.ConsistencyCheckInfo) Set(java.util.Set) RefUpdate(org.eclipse.jgit.lib.RefUpdate) PGPPublicKey(org.bouncycastle.openpgp.PGPPublicKey) TestKeys.validKeyWithoutExpiration(com.google.gerrit.gpg.testing.TestKeys.validKeyWithoutExpiration) BranchNameKey(com.google.gerrit.entities.BranchNameKey) ExternalIds(com.google.gerrit.server.account.externalids.ExternalIds) RequestScopeOperations(com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations) PersonIdent(org.eclipse.jgit.lib.PersonIdent) UseClockStep(com.google.gerrit.acceptance.UseClockStep) AccountProperties(com.google.gerrit.server.account.AccountProperties) Emails(com.google.gerrit.server.account.Emails) PushResult(org.eclipse.jgit.transport.PushResult) PluginSetContext(com.google.gerrit.server.plugincontext.PluginSetContext) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) GerritJUnit.assertThrows(com.google.gerrit.testing.GerritJUnit.assertThrows) GitUtil.fetch(com.google.gerrit.acceptance.GitUtil.fetch) Mockito.mock(org.mockito.Mockito.mock) EmailInfo(com.google.gerrit.extensions.common.EmailInfo) MetaDataUpdate(com.google.gerrit.server.git.meta.MetaDataUpdate) ClientProtocolException(org.apache.http.client.ClientProtocolException) Iterables(com.google.common.collect.Iterables) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) RevCommit(org.eclipse.jgit.revwalk.RevCommit) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UnprocessableEntityException(com.google.gerrit.extensions.restapi.UnprocessableEntityException) AccountOperations(com.google.gerrit.acceptance.testsuite.account.AccountOperations) Fingerprint(com.google.gerrit.gpg.Fingerprint) ArrayList(java.util.ArrayList) AccountInput(com.google.gerrit.extensions.api.accounts.AccountInput) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) TestKeys.validKeyWithExpiration(com.google.gerrit.gpg.testing.TestKeys.validKeyWithExpiration) Runnables(com.google.common.util.concurrent.Runnables) EmailInput(com.google.gerrit.extensions.api.accounts.EmailInput) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) Address(com.google.gerrit.entities.Address) ExtensionRegistry(com.google.gerrit.acceptance.ExtensionRegistry) Before(org.junit.Before) AccountGroup(com.google.gerrit.entities.AccountGroup) TreeWalk(org.eclipse.jgit.treewalk.TreeWalk) ProjectCache.illegalState(com.google.gerrit.server.project.ProjectCache.illegalState) TestRepository(org.eclipse.jgit.junit.TestRepository) Sequences(com.google.gerrit.server.notedb.Sequences) BaseEncoding(com.google.common.io.BaseEncoding) ValidationException(com.google.gerrit.server.validators.ValidationException) StorageException(com.google.gerrit.exceptions.StorageException) AccountActivationListener(com.google.gerrit.extensions.events.AccountActivationListener) IOException(java.io.IOException) Test(org.junit.Test) ANONYMOUS_USERS(com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS) StalenessChecker(com.google.gerrit.server.index.account.StalenessChecker) Correspondence(com.google.common.truth.Correspondence) BasicCookieStore(org.apache.http.impl.client.BasicCookieStore) AccountApi(com.google.gerrit.extensions.api.accounts.AccountApi) CacheBasedWebSession(com.google.gerrit.httpd.CacheBasedWebSession) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) ExternalIdNotes(com.google.gerrit.server.account.externalids.ExternalIdNotes) Project(com.google.gerrit.entities.Project) HttpResponse(org.apache.http.HttpResponse) ExternalId(com.google.gerrit.server.account.externalids.ExternalId) TimeUtil(com.google.gerrit.server.util.time.TimeUtil) HttpClientBuilder(org.apache.http.impl.client.HttpClientBuilder) AccountState(com.google.gerrit.server.account.AccountState) ObjectReader(org.eclipse.jgit.lib.ObjectReader) Repository(org.eclipse.jgit.lib.Repository) ObjectInserter(org.eclipse.jgit.lib.ObjectInserter) Date(java.util.Date) Inject(com.google.inject.Inject) REFS_GPG_KEYS(com.google.gerrit.gpg.PublicKeyStore.REFS_GPG_KEYS) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) AccountDetailInfo(com.google.gerrit.extensions.common.AccountDetailInfo) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) DEFAULT_LABEL(com.google.gerrit.server.StarredChangesUtil.DEFAULT_LABEL) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) ConsistencyProblemInfo(com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.ConsistencyProblemInfo) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CheckAccountsInput(com.google.gerrit.extensions.api.config.ConsistencyCheckInput.CheckAccountsInput) Locale(java.util.Locale) After(org.junit.After) RefNames(com.google.gerrit.entities.RefNames) AuthException(com.google.gerrit.extensions.restapi.AuthException) PGPPublicKeyRing(org.bouncycastle.openpgp.PGPPublicKeyRing) AtomicLongMap(com.google.common.util.concurrent.AtomicLongMap) Collectors.toSet(java.util.stream.Collectors.toSet) ImmutableSetMultimap(com.google.common.collect.ImmutableSetMultimap) ImmutableSet(com.google.common.collect.ImmutableSet) Truth.assertWithMessage(com.google.common.truth.Truth.assertWithMessage) SshSessionFactory(com.google.gerrit.acceptance.testsuite.request.SshSessionFactory) Account(com.google.gerrit.entities.Account) SCHEME_GPGKEY(com.google.gerrit.server.account.externalids.ExternalId.SCHEME_GPGKEY) AccountIndexedCounter(com.google.gerrit.acceptance.AccountIndexedCounter) Collectors(java.util.stream.Collectors) TestSshKeys(com.google.gerrit.acceptance.testsuite.account.TestSshKeys) GroupReference(com.google.gerrit.entities.GroupReference) List(java.util.List) Nullable(com.google.gerrit.common.Nullable) StopStrategies(com.github.rholder.retry.StopStrategies) HttpGet(org.apache.http.client.methods.HttpGet) Ref(org.eclipse.jgit.lib.Ref) ConfigSubject.assertThat(com.google.gerrit.truth.ConfigSubject.assertThat) Optional(java.util.Optional) AuthConfig(com.google.gerrit.server.config.AuthConfig) RefPattern(com.google.gerrit.server.project.RefPattern) AccountIndexer(com.google.gerrit.server.index.account.AccountIndexer) TestProjectUpdate.block(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.block) VersionedAuthorizedKeys(com.google.gerrit.server.account.VersionedAuthorizedKeys) DraftInput(com.google.gerrit.extensions.api.changes.DraftInput) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) PublicKeyStore(com.google.gerrit.gpg.PublicKeyStore) InternalAccountQuery(com.google.gerrit.server.query.account.InternalAccountQuery) SshKeyInfo(com.google.gerrit.extensions.common.SshKeyInfo) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) ConfigSuite(com.google.gerrit.testing.ConfigSuite) HashSet(java.util.HashSet) GitReferenceUpdatedListener(com.google.gerrit.extensions.events.GitReferenceUpdatedListener) GroupInfo(com.google.gerrit.extensions.common.GroupInfo) ImmutableList(com.google.common.collect.ImmutableList) UseSsh(com.google.gerrit.acceptance.UseSsh) ExceptionHook(com.google.gerrit.server.ExceptionHook) CommitBuilder(org.eclipse.jgit.lib.CommitBuilder) Objects.requireNonNull(java.util.Objects.requireNonNull) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ExternalIdFactory(com.google.gerrit.server.account.externalids.ExternalIdFactory) Change(com.google.gerrit.entities.Change) LockFailureException(com.google.gerrit.git.LockFailureException) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) ConsistencyCheckInput(com.google.gerrit.extensions.api.config.ConsistencyCheckInput) AccountActivationValidationListener(com.google.gerrit.server.validators.AccountActivationValidationListener) AccountsUpdate(com.google.gerrit.server.account.AccountsUpdate) TestProjectUpdate.allowCapability(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) Iterator(java.util.Iterator) Sandboxed(com.google.gerrit.acceptance.Sandboxed) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Permission(com.google.gerrit.entities.Permission) HttpServletResponse(javax.servlet.http.HttpServletResponse) Truth.assertThat(com.google.common.truth.Truth.assertThat) Mockito.verify(org.mockito.Mockito.verify) ObjectId(org.eclipse.jgit.lib.ObjectId) TransportException(org.eclipse.jgit.api.errors.TransportException) TestProjectUpdate.permissionKey(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.permissionKey) ArmoredOutputStream(org.bouncycastle.bcpg.ArmoredOutputStream) Collectors.toList(java.util.stream.Collectors.toList) Provider(com.google.inject.Provider) Message(com.google.gerrit.testing.FakeEmailSender.Message) ProjectOperations(com.google.gerrit.acceptance.testsuite.project.ProjectOperations) RemoteRefUpdate(org.eclipse.jgit.transport.RemoteRefUpdate) ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) ServerInitiated(com.google.gerrit.server.ServerInitiated) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) NullAwareCorrespondence(com.google.gerrit.truth.NullAwareCorrespondence) DuplicateExternalIdKeyException(com.google.gerrit.server.account.externalids.DuplicateExternalIdKeyException) Git(org.eclipse.jgit.api.Git) TestKeys.allValidKeys(com.google.gerrit.gpg.testing.TestKeys.allValidKeys) TestKeys.validKeyWithSecondUserId(com.google.gerrit.gpg.testing.TestKeys.validKeyWithSecondUserId) PushCertificateIdent(org.eclipse.jgit.transport.PushCertificateIdent) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Action(com.google.gerrit.entities.PermissionRule.Action) GitReferenceUpdated(com.google.gerrit.server.extensions.events.GitReferenceUpdated) TestAccount(com.google.gerrit.acceptance.TestAccount) Account(com.google.gerrit.entities.Account) RetryHelper(com.google.gerrit.server.update.RetryHelper) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) AccountsUpdate(com.google.gerrit.server.account.AccountsUpdate) PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) IOException(java.io.IOException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PersonIdent(org.eclipse.jgit.lib.PersonIdent) StorageException(com.google.gerrit.exceptions.StorageException) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 2 with RetryHelper

use of com.google.gerrit.server.update.RetryHelper in project gerrit by GerritCodeReview.

the class AccountIT method atomicReadMofifyWriteExternalIds.

@Test
public void atomicReadMofifyWriteExternalIds() throws Exception {
    projectOperations.allProjectsForUpdate().add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS)).update();
    Account.Id accountId = Account.id(seq.nextAccountId());
    ExternalId extIdA1 = externalIdFactory.create("foo", "A-1", accountId);
    accountsUpdateProvider.get().insert("Create Test Account", accountId, u -> u.addExternalId(extIdA1));
    AtomicInteger bgCounterA1 = new AtomicInteger(0);
    AtomicInteger bgCounterA2 = new AtomicInteger(0);
    PersonIdent ident = serverIdent.get();
    ExternalId extIdA2 = externalIdFactory.create("foo", "A-2", accountId);
    AccountsUpdate update = new AccountsUpdate(repoManager, gitReferenceUpdated, Optional.empty(), allUsers, externalIds, metaDataUpdateInternalFactory, new RetryHelper(cfg, retryMetrics, null, null, null, exceptionHooks, r -> r.withBlockStrategy(noSleepBlockStrategy)), extIdNotesFactory, ident, ident, Runnables.doNothing(), () -> {
        try {
            accountsUpdateProvider.get().update("Update External ID", accountId, u -> u.replaceExternalId(extIdA1, extIdA2));
        } catch (IOException | ConfigInvalidException | StorageException e) {
        // Ignore, the expected exception is asserted later
        }
    });
    assertThat(bgCounterA1.get()).isEqualTo(0);
    assertThat(bgCounterA2.get()).isEqualTo(0);
    assertThat(gApi.accounts().id(accountId.get()).getExternalIds().stream().map(i -> i.identity).collect(toSet())).containsExactly(extIdA1.key().get());
    ExternalId extIdB1 = externalIdFactory.create("foo", "B-1", accountId);
    ExternalId extIdB2 = externalIdFactory.create("foo", "B-2", accountId);
    Optional<AccountState> updatedAccount = update.update("Update External ID", accountId, (a, u) -> {
        if (a.externalIds().contains(extIdA1)) {
            bgCounterA1.getAndIncrement();
            u.replaceExternalId(extIdA1, extIdB1);
        }
        if (a.externalIds().contains(extIdA2)) {
            bgCounterA2.getAndIncrement();
            u.replaceExternalId(extIdA2, extIdB2);
        }
    });
    assertThat(bgCounterA1.get()).isEqualTo(1);
    assertThat(bgCounterA2.get()).isEqualTo(1);
    assertThat(updatedAccount).isPresent();
    assertThat(updatedAccount.get().externalIds()).containsExactly(extIdB2);
    assertThat(accounts.get(accountId).get().externalIds()).containsExactly(extIdB2);
    assertThat(gApi.accounts().id(accountId.get()).getExternalIds().stream().map(i -> i.identity).collect(toSet())).containsExactly(extIdB2.key().get());
}
Also used : ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException) ExternalIdKeyFactory(com.google.gerrit.server.account.externalids.ExternalIdKeyFactory) KeyPair(java.security.KeyPair) Arrays(java.util.Arrays) OBJ_BLOB(org.eclipse.jgit.lib.Constants.OBJ_BLOB) GlobalCapability(com.google.gerrit.common.data.GlobalCapability) CommentInfo(com.google.gerrit.extensions.common.CommentInfo) PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) TestAccount(com.google.gerrit.acceptance.TestAccount) TestProjectUpdate.deny(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.deny) REGISTERED_USERS(com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) RevWalk(org.eclipse.jgit.revwalk.RevWalk) Config(org.eclipse.jgit.lib.Config) TestKey(com.google.gerrit.gpg.testing.TestKey) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) FluentIterable(com.google.common.collect.FluentIterable) GpgKeyInfo(com.google.gerrit.extensions.common.GpgKeyInfo) Map(java.util.Map) RetryHelper(com.google.gerrit.server.update.RetryHelper) GroupOperations(com.google.gerrit.acceptance.testsuite.group.GroupOperations) TestProjectUpdate.allow(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allow) DeleteDraftCommentsInput(com.google.gerrit.extensions.api.accounts.DeleteDraftCommentsInput) DeletedDraftCommentInfo(com.google.gerrit.extensions.api.accounts.DeletedDraftCommentInfo) GitUtil.deleteRef(com.google.gerrit.acceptance.GitUtil.deleteRef) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) AccessSection(com.google.gerrit.entities.AccessSection) ConsistencyCheckInfo(com.google.gerrit.extensions.api.config.ConsistencyCheckInfo) Set(java.util.Set) RefUpdate(org.eclipse.jgit.lib.RefUpdate) PGPPublicKey(org.bouncycastle.openpgp.PGPPublicKey) TestKeys.validKeyWithoutExpiration(com.google.gerrit.gpg.testing.TestKeys.validKeyWithoutExpiration) BranchNameKey(com.google.gerrit.entities.BranchNameKey) ExternalIds(com.google.gerrit.server.account.externalids.ExternalIds) RequestScopeOperations(com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations) PersonIdent(org.eclipse.jgit.lib.PersonIdent) UseClockStep(com.google.gerrit.acceptance.UseClockStep) AccountProperties(com.google.gerrit.server.account.AccountProperties) Emails(com.google.gerrit.server.account.Emails) PushResult(org.eclipse.jgit.transport.PushResult) PluginSetContext(com.google.gerrit.server.plugincontext.PluginSetContext) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) GerritJUnit.assertThrows(com.google.gerrit.testing.GerritJUnit.assertThrows) GitUtil.fetch(com.google.gerrit.acceptance.GitUtil.fetch) Mockito.mock(org.mockito.Mockito.mock) EmailInfo(com.google.gerrit.extensions.common.EmailInfo) MetaDataUpdate(com.google.gerrit.server.git.meta.MetaDataUpdate) ClientProtocolException(org.apache.http.client.ClientProtocolException) Iterables(com.google.common.collect.Iterables) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) RevCommit(org.eclipse.jgit.revwalk.RevCommit) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UnprocessableEntityException(com.google.gerrit.extensions.restapi.UnprocessableEntityException) AccountOperations(com.google.gerrit.acceptance.testsuite.account.AccountOperations) Fingerprint(com.google.gerrit.gpg.Fingerprint) ArrayList(java.util.ArrayList) AccountInput(com.google.gerrit.extensions.api.accounts.AccountInput) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) TestKeys.validKeyWithExpiration(com.google.gerrit.gpg.testing.TestKeys.validKeyWithExpiration) Runnables(com.google.common.util.concurrent.Runnables) EmailInput(com.google.gerrit.extensions.api.accounts.EmailInput) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) Address(com.google.gerrit.entities.Address) ExtensionRegistry(com.google.gerrit.acceptance.ExtensionRegistry) Before(org.junit.Before) AccountGroup(com.google.gerrit.entities.AccountGroup) TreeWalk(org.eclipse.jgit.treewalk.TreeWalk) ProjectCache.illegalState(com.google.gerrit.server.project.ProjectCache.illegalState) TestRepository(org.eclipse.jgit.junit.TestRepository) Sequences(com.google.gerrit.server.notedb.Sequences) BaseEncoding(com.google.common.io.BaseEncoding) ValidationException(com.google.gerrit.server.validators.ValidationException) StorageException(com.google.gerrit.exceptions.StorageException) AccountActivationListener(com.google.gerrit.extensions.events.AccountActivationListener) IOException(java.io.IOException) Test(org.junit.Test) ANONYMOUS_USERS(com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS) StalenessChecker(com.google.gerrit.server.index.account.StalenessChecker) Correspondence(com.google.common.truth.Correspondence) BasicCookieStore(org.apache.http.impl.client.BasicCookieStore) AccountApi(com.google.gerrit.extensions.api.accounts.AccountApi) CacheBasedWebSession(com.google.gerrit.httpd.CacheBasedWebSession) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) ExternalIdNotes(com.google.gerrit.server.account.externalids.ExternalIdNotes) Project(com.google.gerrit.entities.Project) HttpResponse(org.apache.http.HttpResponse) ExternalId(com.google.gerrit.server.account.externalids.ExternalId) TimeUtil(com.google.gerrit.server.util.time.TimeUtil) HttpClientBuilder(org.apache.http.impl.client.HttpClientBuilder) AccountState(com.google.gerrit.server.account.AccountState) ObjectReader(org.eclipse.jgit.lib.ObjectReader) Repository(org.eclipse.jgit.lib.Repository) ObjectInserter(org.eclipse.jgit.lib.ObjectInserter) Date(java.util.Date) Inject(com.google.inject.Inject) REFS_GPG_KEYS(com.google.gerrit.gpg.PublicKeyStore.REFS_GPG_KEYS) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) AccountDetailInfo(com.google.gerrit.extensions.common.AccountDetailInfo) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) DEFAULT_LABEL(com.google.gerrit.server.StarredChangesUtil.DEFAULT_LABEL) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) ConsistencyProblemInfo(com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.ConsistencyProblemInfo) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CheckAccountsInput(com.google.gerrit.extensions.api.config.ConsistencyCheckInput.CheckAccountsInput) Locale(java.util.Locale) After(org.junit.After) RefNames(com.google.gerrit.entities.RefNames) AuthException(com.google.gerrit.extensions.restapi.AuthException) PGPPublicKeyRing(org.bouncycastle.openpgp.PGPPublicKeyRing) AtomicLongMap(com.google.common.util.concurrent.AtomicLongMap) Collectors.toSet(java.util.stream.Collectors.toSet) ImmutableSetMultimap(com.google.common.collect.ImmutableSetMultimap) ImmutableSet(com.google.common.collect.ImmutableSet) Truth.assertWithMessage(com.google.common.truth.Truth.assertWithMessage) SshSessionFactory(com.google.gerrit.acceptance.testsuite.request.SshSessionFactory) Account(com.google.gerrit.entities.Account) SCHEME_GPGKEY(com.google.gerrit.server.account.externalids.ExternalId.SCHEME_GPGKEY) AccountIndexedCounter(com.google.gerrit.acceptance.AccountIndexedCounter) Collectors(java.util.stream.Collectors) TestSshKeys(com.google.gerrit.acceptance.testsuite.account.TestSshKeys) GroupReference(com.google.gerrit.entities.GroupReference) List(java.util.List) Nullable(com.google.gerrit.common.Nullable) StopStrategies(com.github.rholder.retry.StopStrategies) HttpGet(org.apache.http.client.methods.HttpGet) Ref(org.eclipse.jgit.lib.Ref) ConfigSubject.assertThat(com.google.gerrit.truth.ConfigSubject.assertThat) Optional(java.util.Optional) AuthConfig(com.google.gerrit.server.config.AuthConfig) RefPattern(com.google.gerrit.server.project.RefPattern) AccountIndexer(com.google.gerrit.server.index.account.AccountIndexer) TestProjectUpdate.block(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.block) VersionedAuthorizedKeys(com.google.gerrit.server.account.VersionedAuthorizedKeys) DraftInput(com.google.gerrit.extensions.api.changes.DraftInput) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) PublicKeyStore(com.google.gerrit.gpg.PublicKeyStore) InternalAccountQuery(com.google.gerrit.server.query.account.InternalAccountQuery) SshKeyInfo(com.google.gerrit.extensions.common.SshKeyInfo) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) ConfigSuite(com.google.gerrit.testing.ConfigSuite) HashSet(java.util.HashSet) GitReferenceUpdatedListener(com.google.gerrit.extensions.events.GitReferenceUpdatedListener) GroupInfo(com.google.gerrit.extensions.common.GroupInfo) ImmutableList(com.google.common.collect.ImmutableList) UseSsh(com.google.gerrit.acceptance.UseSsh) ExceptionHook(com.google.gerrit.server.ExceptionHook) CommitBuilder(org.eclipse.jgit.lib.CommitBuilder) Objects.requireNonNull(java.util.Objects.requireNonNull) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ExternalIdFactory(com.google.gerrit.server.account.externalids.ExternalIdFactory) Change(com.google.gerrit.entities.Change) LockFailureException(com.google.gerrit.git.LockFailureException) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) ConsistencyCheckInput(com.google.gerrit.extensions.api.config.ConsistencyCheckInput) AccountActivationValidationListener(com.google.gerrit.server.validators.AccountActivationValidationListener) AccountsUpdate(com.google.gerrit.server.account.AccountsUpdate) TestProjectUpdate.allowCapability(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) Iterator(java.util.Iterator) Sandboxed(com.google.gerrit.acceptance.Sandboxed) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Permission(com.google.gerrit.entities.Permission) HttpServletResponse(javax.servlet.http.HttpServletResponse) Truth.assertThat(com.google.common.truth.Truth.assertThat) Mockito.verify(org.mockito.Mockito.verify) ObjectId(org.eclipse.jgit.lib.ObjectId) TransportException(org.eclipse.jgit.api.errors.TransportException) TestProjectUpdate.permissionKey(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.permissionKey) ArmoredOutputStream(org.bouncycastle.bcpg.ArmoredOutputStream) Collectors.toList(java.util.stream.Collectors.toList) Provider(com.google.inject.Provider) Message(com.google.gerrit.testing.FakeEmailSender.Message) ProjectOperations(com.google.gerrit.acceptance.testsuite.project.ProjectOperations) RemoteRefUpdate(org.eclipse.jgit.transport.RemoteRefUpdate) ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) ServerInitiated(com.google.gerrit.server.ServerInitiated) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) NullAwareCorrespondence(com.google.gerrit.truth.NullAwareCorrespondence) DuplicateExternalIdKeyException(com.google.gerrit.server.account.externalids.DuplicateExternalIdKeyException) Git(org.eclipse.jgit.api.Git) TestKeys.allValidKeys(com.google.gerrit.gpg.testing.TestKeys.allValidKeys) TestKeys.validKeyWithSecondUserId(com.google.gerrit.gpg.testing.TestKeys.validKeyWithSecondUserId) PushCertificateIdent(org.eclipse.jgit.transport.PushCertificateIdent) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Action(com.google.gerrit.entities.PermissionRule.Action) GitReferenceUpdated(com.google.gerrit.server.extensions.events.GitReferenceUpdated) TestAccount(com.google.gerrit.acceptance.TestAccount) Account(com.google.gerrit.entities.Account) RetryHelper(com.google.gerrit.server.update.RetryHelper) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) AccountsUpdate(com.google.gerrit.server.account.AccountsUpdate) ExternalId(com.google.gerrit.server.account.externalids.ExternalId) IOException(java.io.IOException) AccountState(com.google.gerrit.server.account.AccountState) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PersonIdent(org.eclipse.jgit.lib.PersonIdent) StorageException(com.google.gerrit.exceptions.StorageException) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 3 with RetryHelper

use of com.google.gerrit.server.update.RetryHelper in project gerrit by GerritCodeReview.

the class AccountIT method retryOnLockFailure.

@Test
public void retryOnLockFailure() throws Exception {
    String status = "happy";
    String fullName = "Foo";
    AtomicBoolean doneBgUpdate = new AtomicBoolean(false);
    PersonIdent ident = serverIdent.get();
    AccountsUpdate update = new AccountsUpdate(repoManager, gitReferenceUpdated, Optional.empty(), allUsers, externalIds, metaDataUpdateInternalFactory, new RetryHelper(cfg, retryMetrics, null, null, null, exceptionHooks, r -> r.withBlockStrategy(noSleepBlockStrategy)), extIdNotesFactory, ident, ident, () -> {
        if (!doneBgUpdate.getAndSet(true)) {
            try {
                accountsUpdateProvider.get().update("Set Status", admin.id(), u -> u.setStatus(status));
            } catch (IOException | ConfigInvalidException | StorageException e) {
            // Ignore, the successful update of the account is asserted later
            }
        }
    }, Runnables.doNothing());
    assertThat(doneBgUpdate.get()).isFalse();
    AccountInfo accountInfo = gApi.accounts().id(admin.id().get()).get();
    assertThat(accountInfo.status).isNull();
    assertThat(accountInfo.name).isNotEqualTo(fullName);
    Optional<AccountState> updatedAccountState = update.update("Set Full Name", admin.id(), u -> u.setFullName(fullName));
    assertThat(doneBgUpdate.get()).isTrue();
    assertThat(updatedAccountState).isPresent();
    Account updatedAccount = updatedAccountState.get().account();
    assertThat(updatedAccount.status()).isEqualTo(status);
    assertThat(updatedAccount.fullName()).isEqualTo(fullName);
    accountInfo = gApi.accounts().id(admin.id().get()).get();
    assertThat(accountInfo.status).isEqualTo(status);
    assertThat(accountInfo.name).isEqualTo(fullName);
}
Also used : ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException) ExternalIdKeyFactory(com.google.gerrit.server.account.externalids.ExternalIdKeyFactory) KeyPair(java.security.KeyPair) Arrays(java.util.Arrays) OBJ_BLOB(org.eclipse.jgit.lib.Constants.OBJ_BLOB) GlobalCapability(com.google.gerrit.common.data.GlobalCapability) CommentInfo(com.google.gerrit.extensions.common.CommentInfo) PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) TestAccount(com.google.gerrit.acceptance.TestAccount) TestProjectUpdate.deny(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.deny) REGISTERED_USERS(com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) RevWalk(org.eclipse.jgit.revwalk.RevWalk) Config(org.eclipse.jgit.lib.Config) TestKey(com.google.gerrit.gpg.testing.TestKey) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) FluentIterable(com.google.common.collect.FluentIterable) GpgKeyInfo(com.google.gerrit.extensions.common.GpgKeyInfo) Map(java.util.Map) RetryHelper(com.google.gerrit.server.update.RetryHelper) GroupOperations(com.google.gerrit.acceptance.testsuite.group.GroupOperations) TestProjectUpdate.allow(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allow) DeleteDraftCommentsInput(com.google.gerrit.extensions.api.accounts.DeleteDraftCommentsInput) DeletedDraftCommentInfo(com.google.gerrit.extensions.api.accounts.DeletedDraftCommentInfo) GitUtil.deleteRef(com.google.gerrit.acceptance.GitUtil.deleteRef) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) AccessSection(com.google.gerrit.entities.AccessSection) ConsistencyCheckInfo(com.google.gerrit.extensions.api.config.ConsistencyCheckInfo) Set(java.util.Set) RefUpdate(org.eclipse.jgit.lib.RefUpdate) PGPPublicKey(org.bouncycastle.openpgp.PGPPublicKey) TestKeys.validKeyWithoutExpiration(com.google.gerrit.gpg.testing.TestKeys.validKeyWithoutExpiration) BranchNameKey(com.google.gerrit.entities.BranchNameKey) ExternalIds(com.google.gerrit.server.account.externalids.ExternalIds) RequestScopeOperations(com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations) PersonIdent(org.eclipse.jgit.lib.PersonIdent) UseClockStep(com.google.gerrit.acceptance.UseClockStep) AccountProperties(com.google.gerrit.server.account.AccountProperties) Emails(com.google.gerrit.server.account.Emails) PushResult(org.eclipse.jgit.transport.PushResult) PluginSetContext(com.google.gerrit.server.plugincontext.PluginSetContext) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) GerritJUnit.assertThrows(com.google.gerrit.testing.GerritJUnit.assertThrows) GitUtil.fetch(com.google.gerrit.acceptance.GitUtil.fetch) Mockito.mock(org.mockito.Mockito.mock) EmailInfo(com.google.gerrit.extensions.common.EmailInfo) MetaDataUpdate(com.google.gerrit.server.git.meta.MetaDataUpdate) ClientProtocolException(org.apache.http.client.ClientProtocolException) Iterables(com.google.common.collect.Iterables) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) RevCommit(org.eclipse.jgit.revwalk.RevCommit) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UnprocessableEntityException(com.google.gerrit.extensions.restapi.UnprocessableEntityException) AccountOperations(com.google.gerrit.acceptance.testsuite.account.AccountOperations) Fingerprint(com.google.gerrit.gpg.Fingerprint) ArrayList(java.util.ArrayList) AccountInput(com.google.gerrit.extensions.api.accounts.AccountInput) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) TestKeys.validKeyWithExpiration(com.google.gerrit.gpg.testing.TestKeys.validKeyWithExpiration) Runnables(com.google.common.util.concurrent.Runnables) EmailInput(com.google.gerrit.extensions.api.accounts.EmailInput) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) Address(com.google.gerrit.entities.Address) ExtensionRegistry(com.google.gerrit.acceptance.ExtensionRegistry) Before(org.junit.Before) AccountGroup(com.google.gerrit.entities.AccountGroup) TreeWalk(org.eclipse.jgit.treewalk.TreeWalk) ProjectCache.illegalState(com.google.gerrit.server.project.ProjectCache.illegalState) TestRepository(org.eclipse.jgit.junit.TestRepository) Sequences(com.google.gerrit.server.notedb.Sequences) BaseEncoding(com.google.common.io.BaseEncoding) ValidationException(com.google.gerrit.server.validators.ValidationException) StorageException(com.google.gerrit.exceptions.StorageException) AccountActivationListener(com.google.gerrit.extensions.events.AccountActivationListener) IOException(java.io.IOException) Test(org.junit.Test) ANONYMOUS_USERS(com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS) StalenessChecker(com.google.gerrit.server.index.account.StalenessChecker) Correspondence(com.google.common.truth.Correspondence) BasicCookieStore(org.apache.http.impl.client.BasicCookieStore) AccountApi(com.google.gerrit.extensions.api.accounts.AccountApi) CacheBasedWebSession(com.google.gerrit.httpd.CacheBasedWebSession) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) ExternalIdNotes(com.google.gerrit.server.account.externalids.ExternalIdNotes) Project(com.google.gerrit.entities.Project) HttpResponse(org.apache.http.HttpResponse) ExternalId(com.google.gerrit.server.account.externalids.ExternalId) TimeUtil(com.google.gerrit.server.util.time.TimeUtil) HttpClientBuilder(org.apache.http.impl.client.HttpClientBuilder) AccountState(com.google.gerrit.server.account.AccountState) ObjectReader(org.eclipse.jgit.lib.ObjectReader) Repository(org.eclipse.jgit.lib.Repository) ObjectInserter(org.eclipse.jgit.lib.ObjectInserter) Date(java.util.Date) Inject(com.google.inject.Inject) REFS_GPG_KEYS(com.google.gerrit.gpg.PublicKeyStore.REFS_GPG_KEYS) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) AccountDetailInfo(com.google.gerrit.extensions.common.AccountDetailInfo) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) DEFAULT_LABEL(com.google.gerrit.server.StarredChangesUtil.DEFAULT_LABEL) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) ConsistencyProblemInfo(com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.ConsistencyProblemInfo) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CheckAccountsInput(com.google.gerrit.extensions.api.config.ConsistencyCheckInput.CheckAccountsInput) Locale(java.util.Locale) After(org.junit.After) RefNames(com.google.gerrit.entities.RefNames) AuthException(com.google.gerrit.extensions.restapi.AuthException) PGPPublicKeyRing(org.bouncycastle.openpgp.PGPPublicKeyRing) AtomicLongMap(com.google.common.util.concurrent.AtomicLongMap) Collectors.toSet(java.util.stream.Collectors.toSet) ImmutableSetMultimap(com.google.common.collect.ImmutableSetMultimap) ImmutableSet(com.google.common.collect.ImmutableSet) Truth.assertWithMessage(com.google.common.truth.Truth.assertWithMessage) SshSessionFactory(com.google.gerrit.acceptance.testsuite.request.SshSessionFactory) Account(com.google.gerrit.entities.Account) SCHEME_GPGKEY(com.google.gerrit.server.account.externalids.ExternalId.SCHEME_GPGKEY) AccountIndexedCounter(com.google.gerrit.acceptance.AccountIndexedCounter) Collectors(java.util.stream.Collectors) TestSshKeys(com.google.gerrit.acceptance.testsuite.account.TestSshKeys) GroupReference(com.google.gerrit.entities.GroupReference) List(java.util.List) Nullable(com.google.gerrit.common.Nullable) StopStrategies(com.github.rholder.retry.StopStrategies) HttpGet(org.apache.http.client.methods.HttpGet) Ref(org.eclipse.jgit.lib.Ref) ConfigSubject.assertThat(com.google.gerrit.truth.ConfigSubject.assertThat) Optional(java.util.Optional) AuthConfig(com.google.gerrit.server.config.AuthConfig) RefPattern(com.google.gerrit.server.project.RefPattern) AccountIndexer(com.google.gerrit.server.index.account.AccountIndexer) TestProjectUpdate.block(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.block) VersionedAuthorizedKeys(com.google.gerrit.server.account.VersionedAuthorizedKeys) DraftInput(com.google.gerrit.extensions.api.changes.DraftInput) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) PublicKeyStore(com.google.gerrit.gpg.PublicKeyStore) InternalAccountQuery(com.google.gerrit.server.query.account.InternalAccountQuery) SshKeyInfo(com.google.gerrit.extensions.common.SshKeyInfo) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) ConfigSuite(com.google.gerrit.testing.ConfigSuite) HashSet(java.util.HashSet) GitReferenceUpdatedListener(com.google.gerrit.extensions.events.GitReferenceUpdatedListener) GroupInfo(com.google.gerrit.extensions.common.GroupInfo) ImmutableList(com.google.common.collect.ImmutableList) UseSsh(com.google.gerrit.acceptance.UseSsh) ExceptionHook(com.google.gerrit.server.ExceptionHook) CommitBuilder(org.eclipse.jgit.lib.CommitBuilder) Objects.requireNonNull(java.util.Objects.requireNonNull) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ExternalIdFactory(com.google.gerrit.server.account.externalids.ExternalIdFactory) Change(com.google.gerrit.entities.Change) LockFailureException(com.google.gerrit.git.LockFailureException) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) ConsistencyCheckInput(com.google.gerrit.extensions.api.config.ConsistencyCheckInput) AccountActivationValidationListener(com.google.gerrit.server.validators.AccountActivationValidationListener) AccountsUpdate(com.google.gerrit.server.account.AccountsUpdate) TestProjectUpdate.allowCapability(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) Iterator(java.util.Iterator) Sandboxed(com.google.gerrit.acceptance.Sandboxed) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Permission(com.google.gerrit.entities.Permission) HttpServletResponse(javax.servlet.http.HttpServletResponse) Truth.assertThat(com.google.common.truth.Truth.assertThat) Mockito.verify(org.mockito.Mockito.verify) ObjectId(org.eclipse.jgit.lib.ObjectId) TransportException(org.eclipse.jgit.api.errors.TransportException) TestProjectUpdate.permissionKey(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.permissionKey) ArmoredOutputStream(org.bouncycastle.bcpg.ArmoredOutputStream) Collectors.toList(java.util.stream.Collectors.toList) Provider(com.google.inject.Provider) Message(com.google.gerrit.testing.FakeEmailSender.Message) ProjectOperations(com.google.gerrit.acceptance.testsuite.project.ProjectOperations) RemoteRefUpdate(org.eclipse.jgit.transport.RemoteRefUpdate) ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) ServerInitiated(com.google.gerrit.server.ServerInitiated) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) NullAwareCorrespondence(com.google.gerrit.truth.NullAwareCorrespondence) DuplicateExternalIdKeyException(com.google.gerrit.server.account.externalids.DuplicateExternalIdKeyException) Git(org.eclipse.jgit.api.Git) TestKeys.allValidKeys(com.google.gerrit.gpg.testing.TestKeys.allValidKeys) TestKeys.validKeyWithSecondUserId(com.google.gerrit.gpg.testing.TestKeys.validKeyWithSecondUserId) PushCertificateIdent(org.eclipse.jgit.transport.PushCertificateIdent) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Action(com.google.gerrit.entities.PermissionRule.Action) GitReferenceUpdated(com.google.gerrit.server.extensions.events.GitReferenceUpdated) TestAccount(com.google.gerrit.acceptance.TestAccount) Account(com.google.gerrit.entities.Account) RetryHelper(com.google.gerrit.server.update.RetryHelper) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) AccountsUpdate(com.google.gerrit.server.account.AccountsUpdate) PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) IOException(java.io.IOException) AccountState(com.google.gerrit.server.account.AccountState) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) PersonIdent(org.eclipse.jgit.lib.PersonIdent) StorageException(com.google.gerrit.exceptions.StorageException) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 4 with RetryHelper

use of com.google.gerrit.server.update.RetryHelper in project gerrit by GerritCodeReview.

the class AccountIT method atomicReadMofifyWrite.

@Test
public void atomicReadMofifyWrite() throws Exception {
    gApi.accounts().id(admin.id().get()).setStatus("A-1");
    AtomicInteger bgCounterA1 = new AtomicInteger(0);
    AtomicInteger bgCounterA2 = new AtomicInteger(0);
    PersonIdent ident = serverIdent.get();
    AccountsUpdate update = new AccountsUpdate(repoManager, gitReferenceUpdated, Optional.empty(), allUsers, externalIds, metaDataUpdateInternalFactory, new RetryHelper(cfg, retryMetrics, null, null, null, exceptionHooks, r -> r.withBlockStrategy(noSleepBlockStrategy)), extIdNotesFactory, ident, ident, Runnables.doNothing(), () -> {
        try {
            accountsUpdateProvider.get().update("Set Status", admin.id(), u -> u.setStatus("A-2"));
        } catch (IOException | ConfigInvalidException | StorageException e) {
        // Ignore, the expected exception is asserted later
        }
    });
    assertThat(bgCounterA1.get()).isEqualTo(0);
    assertThat(bgCounterA2.get()).isEqualTo(0);
    assertThat(gApi.accounts().id(admin.id().get()).get().status).isEqualTo("A-1");
    Optional<AccountState> updatedAccountState = update.update("Set Status", admin.id(), (a, u) -> {
        if ("A-1".equals(a.account().status())) {
            bgCounterA1.getAndIncrement();
            u.setStatus("B-1");
        }
        if ("A-2".equals(a.account().status())) {
            bgCounterA2.getAndIncrement();
            u.setStatus("B-2");
        }
    });
    assertThat(bgCounterA1.get()).isEqualTo(1);
    assertThat(bgCounterA2.get()).isEqualTo(1);
    assertThat(updatedAccountState).isPresent();
    assertThat(updatedAccountState.get().account().status()).isEqualTo("B-2");
    assertThat(accounts.get(admin.id()).get().account().status()).isEqualTo("B-2");
    assertThat(gApi.accounts().id(admin.id().get()).get().status).isEqualTo("B-2");
}
Also used : ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException) ExternalIdKeyFactory(com.google.gerrit.server.account.externalids.ExternalIdKeyFactory) KeyPair(java.security.KeyPair) Arrays(java.util.Arrays) OBJ_BLOB(org.eclipse.jgit.lib.Constants.OBJ_BLOB) GlobalCapability(com.google.gerrit.common.data.GlobalCapability) CommentInfo(com.google.gerrit.extensions.common.CommentInfo) PublicKeyStore.keyToString(com.google.gerrit.gpg.PublicKeyStore.keyToString) TestAccount(com.google.gerrit.acceptance.TestAccount) TestProjectUpdate.deny(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.deny) REGISTERED_USERS(com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) RevWalk(org.eclipse.jgit.revwalk.RevWalk) Config(org.eclipse.jgit.lib.Config) TestKey(com.google.gerrit.gpg.testing.TestKey) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) FluentIterable(com.google.common.collect.FluentIterable) GpgKeyInfo(com.google.gerrit.extensions.common.GpgKeyInfo) Map(java.util.Map) RetryHelper(com.google.gerrit.server.update.RetryHelper) GroupOperations(com.google.gerrit.acceptance.testsuite.group.GroupOperations) TestProjectUpdate.allow(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allow) DeleteDraftCommentsInput(com.google.gerrit.extensions.api.accounts.DeleteDraftCommentsInput) DeletedDraftCommentInfo(com.google.gerrit.extensions.api.accounts.DeletedDraftCommentInfo) GitUtil.deleteRef(com.google.gerrit.acceptance.GitUtil.deleteRef) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) AccessSection(com.google.gerrit.entities.AccessSection) ConsistencyCheckInfo(com.google.gerrit.extensions.api.config.ConsistencyCheckInfo) Set(java.util.Set) RefUpdate(org.eclipse.jgit.lib.RefUpdate) PGPPublicKey(org.bouncycastle.openpgp.PGPPublicKey) TestKeys.validKeyWithoutExpiration(com.google.gerrit.gpg.testing.TestKeys.validKeyWithoutExpiration) BranchNameKey(com.google.gerrit.entities.BranchNameKey) ExternalIds(com.google.gerrit.server.account.externalids.ExternalIds) RequestScopeOperations(com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations) PersonIdent(org.eclipse.jgit.lib.PersonIdent) UseClockStep(com.google.gerrit.acceptance.UseClockStep) AccountProperties(com.google.gerrit.server.account.AccountProperties) Emails(com.google.gerrit.server.account.Emails) PushResult(org.eclipse.jgit.transport.PushResult) PluginSetContext(com.google.gerrit.server.plugincontext.PluginSetContext) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) GerritJUnit.assertThrows(com.google.gerrit.testing.GerritJUnit.assertThrows) GitUtil.fetch(com.google.gerrit.acceptance.GitUtil.fetch) Mockito.mock(org.mockito.Mockito.mock) EmailInfo(com.google.gerrit.extensions.common.EmailInfo) MetaDataUpdate(com.google.gerrit.server.git.meta.MetaDataUpdate) ClientProtocolException(org.apache.http.client.ClientProtocolException) Iterables(com.google.common.collect.Iterables) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) RevCommit(org.eclipse.jgit.revwalk.RevCommit) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UnprocessableEntityException(com.google.gerrit.extensions.restapi.UnprocessableEntityException) AccountOperations(com.google.gerrit.acceptance.testsuite.account.AccountOperations) Fingerprint(com.google.gerrit.gpg.Fingerprint) ArrayList(java.util.ArrayList) AccountInput(com.google.gerrit.extensions.api.accounts.AccountInput) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) TestKeys.validKeyWithExpiration(com.google.gerrit.gpg.testing.TestKeys.validKeyWithExpiration) Runnables(com.google.common.util.concurrent.Runnables) EmailInput(com.google.gerrit.extensions.api.accounts.EmailInput) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) Address(com.google.gerrit.entities.Address) ExtensionRegistry(com.google.gerrit.acceptance.ExtensionRegistry) Before(org.junit.Before) AccountGroup(com.google.gerrit.entities.AccountGroup) TreeWalk(org.eclipse.jgit.treewalk.TreeWalk) ProjectCache.illegalState(com.google.gerrit.server.project.ProjectCache.illegalState) TestRepository(org.eclipse.jgit.junit.TestRepository) Sequences(com.google.gerrit.server.notedb.Sequences) BaseEncoding(com.google.common.io.BaseEncoding) ValidationException(com.google.gerrit.server.validators.ValidationException) StorageException(com.google.gerrit.exceptions.StorageException) AccountActivationListener(com.google.gerrit.extensions.events.AccountActivationListener) IOException(java.io.IOException) Test(org.junit.Test) ANONYMOUS_USERS(com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS) StalenessChecker(com.google.gerrit.server.index.account.StalenessChecker) Correspondence(com.google.common.truth.Correspondence) BasicCookieStore(org.apache.http.impl.client.BasicCookieStore) AccountApi(com.google.gerrit.extensions.api.accounts.AccountApi) CacheBasedWebSession(com.google.gerrit.httpd.CacheBasedWebSession) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) ExternalIdNotes(com.google.gerrit.server.account.externalids.ExternalIdNotes) Project(com.google.gerrit.entities.Project) HttpResponse(org.apache.http.HttpResponse) ExternalId(com.google.gerrit.server.account.externalids.ExternalId) TimeUtil(com.google.gerrit.server.util.time.TimeUtil) HttpClientBuilder(org.apache.http.impl.client.HttpClientBuilder) AccountState(com.google.gerrit.server.account.AccountState) ObjectReader(org.eclipse.jgit.lib.ObjectReader) Repository(org.eclipse.jgit.lib.Repository) ObjectInserter(org.eclipse.jgit.lib.ObjectInserter) Date(java.util.Date) Inject(com.google.inject.Inject) REFS_GPG_KEYS(com.google.gerrit.gpg.PublicKeyStore.REFS_GPG_KEYS) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) AccountDetailInfo(com.google.gerrit.extensions.common.AccountDetailInfo) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) DEFAULT_LABEL(com.google.gerrit.server.StarredChangesUtil.DEFAULT_LABEL) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) ConsistencyProblemInfo(com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.ConsistencyProblemInfo) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CheckAccountsInput(com.google.gerrit.extensions.api.config.ConsistencyCheckInput.CheckAccountsInput) Locale(java.util.Locale) After(org.junit.After) RefNames(com.google.gerrit.entities.RefNames) AuthException(com.google.gerrit.extensions.restapi.AuthException) PGPPublicKeyRing(org.bouncycastle.openpgp.PGPPublicKeyRing) AtomicLongMap(com.google.common.util.concurrent.AtomicLongMap) Collectors.toSet(java.util.stream.Collectors.toSet) ImmutableSetMultimap(com.google.common.collect.ImmutableSetMultimap) ImmutableSet(com.google.common.collect.ImmutableSet) Truth.assertWithMessage(com.google.common.truth.Truth.assertWithMessage) SshSessionFactory(com.google.gerrit.acceptance.testsuite.request.SshSessionFactory) Account(com.google.gerrit.entities.Account) SCHEME_GPGKEY(com.google.gerrit.server.account.externalids.ExternalId.SCHEME_GPGKEY) AccountIndexedCounter(com.google.gerrit.acceptance.AccountIndexedCounter) Collectors(java.util.stream.Collectors) TestSshKeys(com.google.gerrit.acceptance.testsuite.account.TestSshKeys) GroupReference(com.google.gerrit.entities.GroupReference) List(java.util.List) Nullable(com.google.gerrit.common.Nullable) StopStrategies(com.github.rholder.retry.StopStrategies) HttpGet(org.apache.http.client.methods.HttpGet) Ref(org.eclipse.jgit.lib.Ref) ConfigSubject.assertThat(com.google.gerrit.truth.ConfigSubject.assertThat) Optional(java.util.Optional) AuthConfig(com.google.gerrit.server.config.AuthConfig) RefPattern(com.google.gerrit.server.project.RefPattern) AccountIndexer(com.google.gerrit.server.index.account.AccountIndexer) TestProjectUpdate.block(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.block) VersionedAuthorizedKeys(com.google.gerrit.server.account.VersionedAuthorizedKeys) DraftInput(com.google.gerrit.extensions.api.changes.DraftInput) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) PublicKeyStore(com.google.gerrit.gpg.PublicKeyStore) InternalAccountQuery(com.google.gerrit.server.query.account.InternalAccountQuery) SshKeyInfo(com.google.gerrit.extensions.common.SshKeyInfo) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) ConfigSuite(com.google.gerrit.testing.ConfigSuite) HashSet(java.util.HashSet) GitReferenceUpdatedListener(com.google.gerrit.extensions.events.GitReferenceUpdatedListener) GroupInfo(com.google.gerrit.extensions.common.GroupInfo) ImmutableList(com.google.common.collect.ImmutableList) UseSsh(com.google.gerrit.acceptance.UseSsh) ExceptionHook(com.google.gerrit.server.ExceptionHook) CommitBuilder(org.eclipse.jgit.lib.CommitBuilder) Objects.requireNonNull(java.util.Objects.requireNonNull) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ExternalIdFactory(com.google.gerrit.server.account.externalids.ExternalIdFactory) Change(com.google.gerrit.entities.Change) LockFailureException(com.google.gerrit.git.LockFailureException) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) ConsistencyCheckInput(com.google.gerrit.extensions.api.config.ConsistencyCheckInput) AccountActivationValidationListener(com.google.gerrit.server.validators.AccountActivationValidationListener) AccountsUpdate(com.google.gerrit.server.account.AccountsUpdate) TestProjectUpdate.allowCapability(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowCapability) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) Iterator(java.util.Iterator) Sandboxed(com.google.gerrit.acceptance.Sandboxed) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Permission(com.google.gerrit.entities.Permission) HttpServletResponse(javax.servlet.http.HttpServletResponse) Truth.assertThat(com.google.common.truth.Truth.assertThat) Mockito.verify(org.mockito.Mockito.verify) ObjectId(org.eclipse.jgit.lib.ObjectId) TransportException(org.eclipse.jgit.api.errors.TransportException) TestProjectUpdate.permissionKey(com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.permissionKey) ArmoredOutputStream(org.bouncycastle.bcpg.ArmoredOutputStream) Collectors.toList(java.util.stream.Collectors.toList) Provider(com.google.inject.Provider) Message(com.google.gerrit.testing.FakeEmailSender.Message) ProjectOperations(com.google.gerrit.acceptance.testsuite.project.ProjectOperations) RemoteRefUpdate(org.eclipse.jgit.transport.RemoteRefUpdate) ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) ServerInitiated(com.google.gerrit.server.ServerInitiated) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) NullAwareCorrespondence(com.google.gerrit.truth.NullAwareCorrespondence) DuplicateExternalIdKeyException(com.google.gerrit.server.account.externalids.DuplicateExternalIdKeyException) Git(org.eclipse.jgit.api.Git) TestKeys.allValidKeys(com.google.gerrit.gpg.testing.TestKeys.allValidKeys) TestKeys.validKeyWithSecondUserId(com.google.gerrit.gpg.testing.TestKeys.validKeyWithSecondUserId) PushCertificateIdent(org.eclipse.jgit.transport.PushCertificateIdent) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Action(com.google.gerrit.entities.PermissionRule.Action) GitReferenceUpdated(com.google.gerrit.server.extensions.events.GitReferenceUpdated) RetryHelper(com.google.gerrit.server.update.RetryHelper) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PersonIdent(org.eclipse.jgit.lib.PersonIdent) AccountsUpdate(com.google.gerrit.server.account.AccountsUpdate) IOException(java.io.IOException) AccountState(com.google.gerrit.server.account.AccountState) StorageException(com.google.gerrit.exceptions.StorageException) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 5 with RetryHelper

use of com.google.gerrit.server.update.RetryHelper in project gerrit by GerritCodeReview.

the class MergeOp method integrateIntoHistory.

private void integrateIntoHistory(ChangeSet cs, SubmissionExecutor submissionExecutor) throws RestApiException, UpdateException {
    checkArgument(!cs.furtherHiddenChanges(), "cannot integrate hidden changes into history");
    logger.atFine().log("Beginning merge attempt on %s", cs);
    Map<BranchNameKey, BranchBatch> toSubmit = new HashMap<>();
    ListMultimap<BranchNameKey, ChangeData> cbb;
    try {
        cbb = cs.changesByBranch();
    } catch (StorageException e) {
        throw new StorageException("Error reading changes to submit", e);
    }
    Set<BranchNameKey> branches = cbb.keySet();
    for (BranchNameKey branch : branches) {
        OpenRepo or = openRepo(branch.project());
        if (or != null) {
            toSubmit.put(branch, validateChangeList(or, cbb.get(branch)));
        }
    }
    // Done checks that don't involve running submit strategies.
    commitStatus.maybeFailVerbose();
    try {
        SubscriptionGraph subscriptionGraph = subscriptionGraphFactory.compute(branches, orm);
        SubmoduleCommits submoduleCommits = submoduleCommitsFactory.create(orm);
        UpdateOrderCalculator updateOrderCalculator = new UpdateOrderCalculator(subscriptionGraph);
        List<SubmitStrategy> strategies = getSubmitStrategies(toSubmit, updateOrderCalculator, submoduleCommits, subscriptionGraph, dryrun);
        this.allProjects = updateOrderCalculator.getProjectsInOrder();
        List<BatchUpdate> batchUpdates = orm.batchUpdates(allProjects);
        // Group batch updates by project
        Map<Project.NameKey, BatchUpdate> batchUpdatesByProject = batchUpdates.stream().collect(Collectors.toMap(b -> b.getProject(), Function.identity()));
        for (Map.Entry<Change.Id, ChangeData> entry : cs.changesById().entrySet()) {
            Project.NameKey project = entry.getValue().project();
            Change.Id changeId = entry.getKey();
            ChangeData cd = entry.getValue();
            batchUpdatesByProject.get(project).addOp(changeId, storeSubmitRequirementsOpFactory.create(cd.submitRequirementsIncludingLegacy().values(), cd));
        }
        try {
            submissionExecutor.setAdditionalBatchUpdateListeners(ImmutableList.of(new SubmitStrategyListener(submitInput, strategies, commitStatus)));
            submissionExecutor.execute(batchUpdates);
        } finally {
            // If the BatchUpdate fails it can be that merging some of the changes was actually
            // successful. This is why we must to collect the updated changes also when an
            // exception was thrown.
            strategies.forEach(s -> updatedChanges.putAll(s.getUpdatedChanges()));
            // Do not leave executed BatchUpdates in the OpenRepos
            if (!dryrun) {
                orm.resetUpdates(ImmutableSet.copyOf(this.allProjects));
            }
        }
    } catch (NoSuchProjectException e) {
        throw new ResourceNotFoundException(e.getMessage());
    } catch (IOException e) {
        throw new StorageException(e);
    } catch (SubmoduleConflictException e) {
        throw new IntegrationConflictException(e.getMessage(), e);
    } catch (UpdateException e) {
        if (e.getCause() instanceof LockFailureException) {
            // as to be unnoticeable, assuming RetryHelper is retrying sufficiently.
            throw e;
        }
        // inner IntegrationConflictException to a ResourceConflictException.
        if (e.getCause() instanceof IntegrationConflictException) {
            throw (IntegrationConflictException) e.getCause();
        }
        throw new MergeUpdateException(genericMergeError(cs), e);
    }
}
Also used : ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException) SuperprojectUpdateOnSubmission(com.google.gerrit.server.update.SuperprojectUpdateOnSubmission) ListMultimap(com.google.common.collect.ListMultimap) MultimapBuilder(com.google.common.collect.MultimapBuilder) InternalUser(com.google.gerrit.server.InternalUser) Inject(com.google.inject.Inject) SubmissionId(com.google.gerrit.entities.SubmissionId) UpdateException(com.google.gerrit.server.update.UpdateException) SubmitRequirementResult(com.google.gerrit.entities.SubmitRequirementResult) MergeUpdateException(com.google.gerrit.exceptions.MergeUpdateException) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) BatchUpdate(com.google.gerrit.server.update.BatchUpdate) SubmitInput(com.google.gerrit.extensions.api.changes.SubmitInput) Map(java.util.Map) AuthException(com.google.gerrit.extensions.restapi.AuthException) StoreSubmitRequirementsOp(com.google.gerrit.server.notedb.StoreSubmitRequirementsOp) RetryHelper(com.google.gerrit.server.update.RetryHelper) MergeTip(com.google.gerrit.server.git.MergeTip) Collectors.toSet(java.util.stream.Collectors.toSet) ImmutableSetMultimap(com.google.common.collect.ImmutableSetMultimap) ImmutableSet(com.google.common.collect.ImmutableSet) Status(com.google.gerrit.entities.Change.Status) ImmutableMap(com.google.common.collect.ImmutableMap) TraceContext(com.google.gerrit.server.logging.TraceContext) SubmitType(com.google.gerrit.extensions.client.SubmitType) Collection(java.util.Collection) Set(java.util.Set) Constants(org.eclipse.jgit.lib.Constants) CodeReviewCommit(com.google.gerrit.server.git.CodeReviewCommit) Instant(java.time.Instant) RetryListener(com.github.rholder.retry.RetryListener) SubmitRecord(com.google.gerrit.entities.SubmitRecord) Collectors(java.util.stream.Collectors) BranchNameKey(com.google.gerrit.entities.BranchNameKey) NotifyHandling(com.google.gerrit.extensions.api.changes.NotifyHandling) SubmitTypeRecord(com.google.gerrit.entities.SubmitTypeRecord) ChangeData(com.google.gerrit.server.query.change.ChangeData) List(java.util.List) Nullable(com.google.gerrit.common.Nullable) Ref(org.eclipse.jgit.lib.Ref) AutoValue(com.google.auto.value.AutoValue) InternalChangeQuery(com.google.gerrit.server.query.change.InternalChangeQuery) Optional(java.util.Optional) MoreObjects.firstNonNull(com.google.common.base.MoreObjects.firstNonNull) Counter0(com.google.gerrit.metrics.Counter0) MetricMaker(com.google.gerrit.metrics.MetricMaker) BatchUpdateOp(com.google.gerrit.server.update.BatchUpdateOp) FluentLogger(com.google.common.flogger.FluentLogger) Joiner(com.google.common.base.Joiner) ChangeMessagesUtil(com.google.gerrit.server.ChangeMessagesUtil) Singleton(com.google.inject.Singleton) PermissionBackendException(com.google.gerrit.server.permissions.PermissionBackendException) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) RevCommit(org.eclipse.jgit.revwalk.RevCommit) OpenRepo(com.google.gerrit.server.submit.MergeOpRepoManager.OpenRepo) IncorrectObjectTypeException(org.eclipse.jgit.errors.IncorrectObjectTypeException) HashMap(java.util.HashMap) Function(java.util.function.Function) SubmissionListener(com.google.gerrit.server.update.SubmissionListener) MergeValidators(com.google.gerrit.server.git.validators.MergeValidators) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ImmutableList(com.google.common.collect.ImmutableList) SubmissionExecutor(com.google.gerrit.server.update.SubmissionExecutor) Description(com.google.gerrit.metrics.Description) Objects.requireNonNull(java.util.Objects.requireNonNull) Change(com.google.gerrit.entities.Change) PatchSet(com.google.gerrit.entities.PatchSet) Comparator.comparing(java.util.Comparator.comparing) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) ChangeUtil(com.google.gerrit.server.ChangeUtil) LockFailureException(com.google.gerrit.git.LockFailureException) ChangeContext(com.google.gerrit.server.update.ChangeContext) MergeValidationException(com.google.gerrit.server.git.validators.MergeValidationException) LinkedHashSet(java.util.LinkedHashSet) SubmitRequirement(com.google.gerrit.entities.SubmitRequirement) NotifyResolver(com.google.gerrit.server.change.NotifyResolver) OpenBranch(com.google.gerrit.server.submit.MergeOpRepoManager.OpenBranch) StorageException(com.google.gerrit.exceptions.StorageException) Attempt(com.github.rholder.retry.Attempt) NoSuchProjectException(com.google.gerrit.server.project.NoSuchProjectException) ChangeNotes(com.google.gerrit.server.notedb.ChangeNotes) IOException(java.io.IOException) SubmitRuleOptions(com.google.gerrit.server.project.SubmitRuleOptions) SetMultimap(com.google.common.collect.SetMultimap) ObjectId(org.eclipse.jgit.lib.ObjectId) Provider(com.google.inject.Provider) ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) IdentifiedUser(com.google.gerrit.server.IdentifiedUser) Project(com.google.gerrit.entities.Project) TimeUtil(com.google.gerrit.server.util.time.TimeUtil) RequestId(com.google.gerrit.server.logging.RequestId) HashMap(java.util.HashMap) NoSuchProjectException(com.google.gerrit.server.project.NoSuchProjectException) BatchUpdate(com.google.gerrit.server.update.BatchUpdate) LockFailureException(com.google.gerrit.git.LockFailureException) BranchNameKey(com.google.gerrit.entities.BranchNameKey) UpdateException(com.google.gerrit.server.update.UpdateException) MergeUpdateException(com.google.gerrit.exceptions.MergeUpdateException) ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException) Change(com.google.gerrit.entities.Change) IOException(java.io.IOException) ChangeData(com.google.gerrit.server.query.change.ChangeData) BranchNameKey(com.google.gerrit.entities.BranchNameKey) MergeUpdateException(com.google.gerrit.exceptions.MergeUpdateException) Project(com.google.gerrit.entities.Project) OpenRepo(com.google.gerrit.server.submit.MergeOpRepoManager.OpenRepo) SubmissionId(com.google.gerrit.entities.SubmissionId) ObjectId(org.eclipse.jgit.lib.ObjectId) RequestId(com.google.gerrit.server.logging.RequestId) StorageException(com.google.gerrit.exceptions.StorageException) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)5 ImmutableSet (com.google.common.collect.ImmutableSet)5 ImmutableSetMultimap (com.google.common.collect.ImmutableSetMultimap)5 Nullable (com.google.gerrit.common.Nullable)5 StopStrategies (com.github.rholder.retry.StopStrategies)4 FluentIterable (com.google.common.collect.FluentIterable)4 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)3 Iterables (com.google.common.collect.Iterables)3 BaseEncoding (com.google.common.io.BaseEncoding)3 Correspondence (com.google.common.truth.Correspondence)3 Truth.assertThat (com.google.common.truth.Truth.assertThat)3 Truth.assertWithMessage (com.google.common.truth.Truth.assertWithMessage)3 Truth8.assertThat (com.google.common.truth.Truth8.assertThat)3 AtomicLongMap (com.google.common.util.concurrent.AtomicLongMap)3 Runnables (com.google.common.util.concurrent.Runnables)3 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)3 AccountIndexedCounter (com.google.gerrit.acceptance.AccountIndexedCounter)3 ExtensionRegistry (com.google.gerrit.acceptance.ExtensionRegistry)3 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)3 GitUtil.deleteRef (com.google.gerrit.acceptance.GitUtil.deleteRef)3