From: Julien HENRY Date: Thu, 26 Apr 2018 10:03:10 +0000 (+0200) Subject: Stop the container even if assertion failed X-Git-Tag: 7.5~1298 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7f484a398b0b93801a6cc7420a5003b4057138be;p=sonarqube.git Stop the container even if assertion failed This is to avoid other tests of the suite to fail, making it harder to spot the root cause --- diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java index af333c9683d..7afde4f1d06 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java @@ -90,47 +90,50 @@ public class ComputeEngineContainerImplTest { .start(new Props(properties)); MutablePicoContainer picoContainer = underTest.getComponentContainer().getPicoContainer(); - assertThat(picoContainer.getComponentAdapters()) - .hasSize( + try { + assertThat(picoContainer.getComponentAdapters()) + .hasSize( + CONTAINER_ITSELF + + 83 // level 4 + + 21 // content of QualityGateModule + + 6 // content of CeConfigurationModule + + 4 // content of CeQueueModule + + 4 // content of CeHttpModule + + 3 // content of CeTaskCommonsModule + + 4 // content of ProjectAnalysisTaskModule + + 7 // content of CeTaskProcessorModule + + 4 // content of ReportAnalysisFailureNotificationModule + + 3 // CeCleaningModule + its content + + 4 // WebhookModule + + 1 // CeDistributedInformation + ); + assertThat(picoContainer.getParent().getComponentAdapters()).hasSize( CONTAINER_ITSELF - + 83 // level 4 - + 21 // content of QualityGateModule - + 6 // content of CeConfigurationModule - + 4 // content of CeQueueModule - + 4 // content of CeHttpModule - + 3 // content of CeTaskCommonsModule - + 4 // content of ProjectAnalysisTaskModule - + 7 // content of CeTaskProcessorModule - + 4 // content of ReportAnalysisFailureNotificationModule - + 3 // CeCleaningModule + its content - + 4 // WebhookModule - + 1 // CeDistributedInformation - ); - assertThat(picoContainer.getParent().getComponentAdapters()).hasSize( - CONTAINER_ITSELF - + 7 // level 3 - ); - assertThat(picoContainer.getParent().getParent().getComponentAdapters()).hasSize( - CONTAINER_ITSELF - + 16 // MigrationConfigurationModule - + 17 // level 2 - ); - assertThat(picoContainer.getParent().getParent().getParent().getComponentAdapters()).hasSize( - COMPONENTS_IN_LEVEL_1_AT_CONSTRUCTION - + 26 // level 1 - + 53 // content of DaoModule - + 3 // content of EsModule - + 59 // content of CorePropertyDefinitions - + 1 // StopFlagContainer - ); - assertThat( - picoContainer.getComponentAdapters().stream() - .map(ComponentAdapter::getComponentImplementation) - .collect(Collectors.toList())).doesNotContain( - (Class) CeDistributedInformationImpl.class).contains( - (Class) StandaloneCeDistributedInformation.class); - assertThat(picoContainer.getParent().getParent().getParent().getParent()).isNull(); - underTest.stop(); + + 7 // level 3 + ); + assertThat(picoContainer.getParent().getParent().getComponentAdapters()).hasSize( + CONTAINER_ITSELF + + 16 // MigrationConfigurationModule + + 17 // level 2 + ); + assertThat(picoContainer.getParent().getParent().getParent().getComponentAdapters()).hasSize( + COMPONENTS_IN_LEVEL_1_AT_CONSTRUCTION + + 26 // level 1 + + 53 // content of DaoModule + + 3 // content of EsModule + + 59 // content of CorePropertyDefinitions + + 1 // StopFlagContainer + ); + assertThat( + picoContainer.getComponentAdapters().stream() + .map(ComponentAdapter::getComponentImplementation) + .collect(Collectors.toList())).doesNotContain( + (Class) CeDistributedInformationImpl.class).contains( + (Class) StandaloneCeDistributedInformation.class); + assertThat(picoContainer.getParent().getParent().getParent().getParent()).isNull(); + } finally { + underTest.stop(); + } assertThat(picoContainer.getLifecycleState().isStarted()).isFalse(); assertThat(picoContainer.getLifecycleState().isStopped()).isFalse();