diff options
author | Jacek <jacek.poreda@sonarsource.com> | 2020-12-17 10:22:36 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-12-22 20:09:38 +0000 |
commit | e42e2b18cdef809b793fe6f3b2d30f32dfb66674 (patch) | |
tree | eba459bbe1c05313177de99b32ddcbd3c46f24b4 /server/sonar-ce | |
parent | 82ed20a6d9aec68faf5bc99e78a25aba42c9fedb (diff) | |
download | sonarqube-e42e2b18cdef809b793fe6f3b2d30f32dfb66674.tar.gz sonarqube-e42e2b18cdef809b793fe6f3b2d30f32dfb66674.zip |
SONAR-13999 drop organization from CE steps
Diffstat (limited to 'server/sonar-ce')
6 files changed, 15 insertions, 61 deletions
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java index 73d6ff344fa..9bab389ae54 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java @@ -76,8 +76,8 @@ import org.sonar.core.platform.ComponentContainer; import org.sonar.core.platform.EditionProvider; import org.sonar.core.platform.Module; import org.sonar.core.platform.PlatformEditionProvider; -import org.sonar.core.platform.PluginClassloaderFactory; import org.sonar.core.platform.PluginClassLoader; +import org.sonar.core.platform.PluginClassloaderFactory; import org.sonar.core.util.UuidFactoryImpl; import org.sonar.db.DBSessionsImpl; import org.sonar.db.DaoModule; @@ -115,9 +115,7 @@ import org.sonar.server.metric.UnanalyzedLanguageMetrics; import org.sonar.server.notification.DefaultNotificationManager; import org.sonar.server.notification.NotificationService; import org.sonar.server.notification.email.EmailNotificationChannel; -import org.sonar.server.organization.BillingValidationsProxyImpl; import org.sonar.server.organization.DefaultOrganizationProviderImpl; -import org.sonar.server.organization.OrganizationFlagsImpl; import org.sonar.server.platform.OfficialDistribution; import org.sonar.server.platform.ServerFileSystemImpl; import org.sonar.server.platform.ServerImpl; @@ -355,15 +353,13 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer { UriReader.class, ServerImpl.class, DefaultOrganizationProviderImpl.class, - SynchronousAsyncExecution.class, - OrganizationFlagsImpl.class); + SynchronousAsyncExecution.class); } private static void populateLevel4(ComponentContainer container, Props props) { container.add( ResourceTypes.class, DefaultResourceTypes.get(), - BillingValidationsProxyImpl.class, // quality profile ActiveRuleIndexer.class, diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java index 279b2f60021..d70f5e887a9 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java @@ -47,7 +47,6 @@ import org.sonar.db.ce.CeQueueDao; import org.sonar.db.ce.CeQueueDto; import org.sonar.db.ce.CeTaskCharacteristicDto; import org.sonar.db.component.ComponentDto; -import org.sonar.server.organization.DefaultOrganizationProvider; import static com.google.common.base.Preconditions.checkArgument; import static java.lang.String.format; @@ -65,8 +64,8 @@ public class InternalCeQueueImpl extends CeQueueImpl implements InternalCeQueue private final ComputeEngineStatus computeEngineStatus; public InternalCeQueueImpl(System2 system2, DbClient dbClient, UuidFactory uuidFactory, CEQueueStatus queueStatus, - DefaultOrganizationProvider defaultOrganizationProvider, ComputeEngineStatus computeEngineStatus) { - super(system2, dbClient, uuidFactory, defaultOrganizationProvider); + ComputeEngineStatus computeEngineStatus) { + super(system2, dbClient, uuidFactory); this.dbClient = dbClient; this.queueStatus = queueStatus; this.computeEngineStatus = computeEngineStatus; diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListenerTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListenerTest.java index 8e02119265d..4aa86af1ea2 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListenerTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/notification/ReportAnalysisFailureNotificationExecutionListenerTest.java @@ -45,8 +45,6 @@ import org.sonar.db.ce.CeQueueDto; import org.sonar.db.ce.CeTaskTypes; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; -import org.sonar.db.organization.OrganizationDto; -import org.sonar.db.organization.OrganizationTesting; import org.sonar.server.notification.NotificationService; import static java.util.Collections.singleton; @@ -151,15 +149,14 @@ public class ReportAnalysisFailureNotificationExecutionListenerTest { @Test public void onEnd_fails_with_IAE_if_component_is_not_a_project() { when(ceTaskMock.getType()).thenReturn(CeTaskTypes.REPORT); - OrganizationDto organization = OrganizationTesting.newOrganizationDto(); ComponentDto project = dbTester.components().insertPrivateProject(); ComponentDto module = dbTester.components().insertComponent(newModuleDto(project)); ComponentDto directory = dbTester.components().insertComponent(newDirectory(module, randomAlphanumeric(12))); ComponentDto file = dbTester.components().insertComponent(ComponentTesting.newFileDto(project)); - ComponentDto view = dbTester.components().insertComponent(ComponentTesting.newView(organization)); + ComponentDto view = dbTester.components().insertComponent(ComponentTesting.newView()); ComponentDto subView = dbTester.components().insertComponent(ComponentTesting.newSubView(view)); ComponentDto projectCopy = dbTester.components().insertComponent(ComponentTesting.newProjectCopy(project, subView)); - ComponentDto application = dbTester.components().insertComponent(ComponentTesting.newApplication(organization)); + ComponentDto application = dbTester.components().insertComponent(ComponentTesting.newApplication()); Arrays.asList(module, directory, file, view, subView, projectCopy, application) .forEach(component -> { diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java index 2d37e9480e5..a9b82a87f75 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java @@ -47,10 +47,7 @@ import org.sonar.db.ce.CeQueueTesting; import org.sonar.db.ce.CeTaskTypes; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; -import org.sonar.db.organization.OrganizationDto; import org.sonar.db.user.UserDto; -import org.sonar.server.organization.DefaultOrganization; -import org.sonar.server.organization.DefaultOrganizationProvider; import static java.util.Arrays.asList; import static java.util.Collections.emptyMap; @@ -81,20 +78,11 @@ public class InternalCeQueueImplTest { private UuidFactory uuidFactory = UuidFactoryImpl.INSTANCE; private CEQueueStatus queueStatus = new CEQueueStatusImpl(db.getDbClient(), mock(System2.class)); - private DefaultOrganizationProvider defaultOrganizationProvider = mock(DefaultOrganizationProvider.class); private ComputeEngineStatus computeEngineStatus = mock(ComputeEngineStatus.class); - private InternalCeQueue underTest = new InternalCeQueueImpl(system2, db.getDbClient(), uuidFactory, queueStatus, defaultOrganizationProvider, computeEngineStatus); + private InternalCeQueue underTest = new InternalCeQueueImpl(system2, db.getDbClient(), uuidFactory, queueStatus, computeEngineStatus); @Before public void setUp() { - OrganizationDto defaultOrganization = db.getDefaultOrganization(); - when(defaultOrganizationProvider.get()).thenReturn(DefaultOrganization.newBuilder() - .setUuid(defaultOrganization.getUuid()) - .setKey(defaultOrganization.getKey()) - .setName(defaultOrganization.getName()) - .setCreatedAt(defaultOrganization.getCreatedAt()) - .setUpdatedAt(defaultOrganization.getUpdatedAt()) - .build()); when(computeEngineStatus.getStatus()).thenReturn(STARTED); } @@ -259,7 +247,7 @@ public class InternalCeQueueImplTest { db.getDbClient().ceQueueDao().deleteByUuid(db.getSession(), task.getUuid()); db.commit(); - InternalCeQueueImpl underTest = new InternalCeQueueImpl(system2, db.getDbClient(), null, queueStatus, null, null); + InternalCeQueueImpl underTest = new InternalCeQueueImpl(system2, db.getDbClient(), null, queueStatus, null); try { underTest.remove(task, CeActivityDto.Status.SUCCESS, null, null); @@ -276,7 +264,7 @@ public class InternalCeQueueImplTest { CeTask task = submit(CeTaskTypes.REPORT, newProjectDto("PROJECT_1")); db.getDbClient().ceQueueDao().deleteByUuid(db.getSession(), task.getUuid()); db.commit(); - InternalCeQueueImpl underTest = new InternalCeQueueImpl(system2, db.getDbClient(), null, queueStatusMock, null, null); + InternalCeQueueImpl underTest = new InternalCeQueueImpl(system2, db.getDbClient(), null, queueStatusMock, null); try { underTest.remove(task, CeActivityDto.Status.FAILED, null, null); @@ -293,7 +281,7 @@ public class InternalCeQueueImplTest { CeTask task = submit(CeTaskTypes.REPORT, newProjectDto("PROJECT_1")); db.executeUpdateSql("update ce_queue set status = 'PENDING', started_at = 123 where uuid = '" + task.getUuid() + "'"); db.commit(); - InternalCeQueueImpl underTest = new InternalCeQueueImpl(system2, db.getDbClient(), null, queueStatusMock, null, null); + InternalCeQueueImpl underTest = new InternalCeQueueImpl(system2, db.getDbClient(), null, queueStatusMock, null); underTest.cancelWornOuts(); @@ -325,7 +313,6 @@ public class InternalCeQueueImplTest { db.commit(); underTest.remove(new CeTask.Builder() - .setOrganizationUuid("foo") .setUuid("uuid") .setType("bar") .build(), CeActivityDto.Status.SUCCESS, null, null); @@ -623,11 +610,6 @@ public class InternalCeQueueImplTest { } private void verifyCeTask(CeTaskSubmit taskSubmit, CeTask task, @Nullable ComponentDto componentDto, @Nullable UserDto userDto) { - if (componentDto == null) { - assertThat(task.getOrganizationUuid()).isEqualTo(defaultOrganizationProvider.get().getUuid()); - } else { - assertThat(task.getOrganizationUuid()).isEqualTo(componentDto.getOrganizationUuid()); - } assertThat(task.getUuid()).isEqualTo(taskSubmit.getUuid()); assertThat(task.getType()).isEqualTo(taskSubmit.getType()); if (componentDto != null) { @@ -669,7 +651,7 @@ public class InternalCeQueueImplTest { } private ComponentDto newProjectDto(String uuid) { - return ComponentTesting.newPublicProjectDto(db.getDefaultOrganization(), uuid).setName("name_" + uuid).setDbKey("key_" + uuid); + return ComponentTesting.newPublicProjectDto(uuid).setName("name_" + uuid).setDbKey("key_" + uuid); } private CeTask submit(String reportType, ComponentDto componentDto) { @@ -698,9 +680,7 @@ public class InternalCeQueueImplTest { } private ComponentDto insertComponent(ComponentDto componentDto) { - db.getDbClient().componentDao().insert(session, componentDto); - session.commit(); - return componentDto; + return db.components().insertComponent(componentDto); } private CeQueueDto makeInProgress(CeQueueDto ceQueueDto, String workerUuid) { diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImplTest.java index 9929bf0e13b..be598e318a3 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImplTest.java @@ -109,7 +109,6 @@ public class CeTaskProcessorRepositoryImplTest { private static CeTask createCeTask(String ceTaskType, String key) { CeTask.Component component = new CeTask.Component("uuid_" + key, key, "name_" + key); return new CeTask.Builder() - .setOrganizationUuid("org1") .setType(ceTaskType) .setUuid("task_uuid_" + key) .setComponent(component) diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerImplTest.java index ddb5027720d..821e1dddcdc 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerImplTest.java @@ -19,7 +19,6 @@ */ package org.sonar.ce.taskprocessor; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -55,7 +54,6 @@ import org.sonar.db.ce.CeActivityDto; import org.sonar.db.ce.CeTaskTypes; import org.sonar.db.user.UserDto; import org.sonar.db.user.UserTesting; -import org.sonar.server.organization.BillingValidations; import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; import static org.assertj.core.api.Assertions.assertThat; @@ -64,10 +62,12 @@ import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNull; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; @@ -491,22 +491,6 @@ public class CeWorkerImplTest { } @Test - public void do_no_log_error_when_task_fails_with_BillingValidationsException() throws Exception { - CeTask ceTask = createCeTask(submitter); - when(queue.peek(anyString(), anyBoolean(), anyBoolean())).thenReturn(Optional.of(ceTask)); - taskProcessorRepository.setProcessorForTask(CeTaskTypes.REPORT, taskProcessor); - makeTaskProcessorFail(ceTask, new BillingValidations.BillingValidationsException("simulate MessageException thrown by TaskProcessor#process")); - - underTest.call(); - - List<String> logs = logTester.logs(LoggerLevel.INFO); - assertThat(logs).hasSize(2); - assertThat(logs.get(1)).contains(" | submitter=" + submitter.getLogin()); - assertThat(logs.get(1)).contains(String.format(" | submitter=%s | status=FAILED | time=", submitter.getLogin())); - assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty(); - } - - @Test public void log_error_when_task_was_successful_but_ending_state_can_not_be_persisted_to_db() throws Exception { CeTask ceTask = createCeTask(submitter); when(queue.peek(anyString(), anyBoolean(), anyBoolean())).thenReturn(Optional.of(ceTask)); @@ -772,7 +756,6 @@ public class CeWorkerImplTest { } CeTask.Component component = new CeTask.Component("PROJECT_1", null, null); return new CeTask.Builder() - .setOrganizationUuid("org1") .setUuid("TASK_1").setType(CeTaskTypes.REPORT) .setComponent(component) .setMainComponent(component) |