From: Sébastien Lesaint Date: Thu, 25 Aug 2016 10:04:18 +0000 (+0200) Subject: SONAR-7911 don't clean SCANNER_CONTEXT in purge of analysis X-Git-Tag: 6.1-RC1~279 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=57207a315109aa1bb3150f87453f2c8a4db3f1e3;p=sonarqube.git SONAR-7911 don't clean SCANNER_CONTEXT in purge of analysis --- diff --git a/sonar-db/src/main/java/org/sonar/db/purge/PurgeCommands.java b/sonar-db/src/main/java/org/sonar/db/purge/PurgeCommands.java index 03c7abd8b8b..f77dfc2cdc8 100644 --- a/sonar-db/src/main/java/org/sonar/db/purge/PurgeCommands.java +++ b/sonar-db/src/main/java/org/sonar/db/purge/PurgeCommands.java @@ -166,11 +166,6 @@ class PurgeCommands { session.commit(); profiler.stop(); - profiler.start("deleteAnalyses (scanner_context)"); - analysisUuidsPartitions.forEach(purgeMapper::deleteScannerContexts); - session.commit(); - profiler.stop(); - profiler.start("deleteAnalyses (snapshots)"); analysisUuidsPartitions.forEach(purgeMapper::deleteAnalyses); session.commit(); diff --git a/sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java b/sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java index aef0971294b..91cb547e29f 100644 --- a/sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java @@ -38,8 +38,6 @@ public interface PurgeMapper { void deleteAnalysisEvents(@Param("analysisUuids") List analysisUuids); - void deleteScannerContexts(@Param("analysisUuids") List analysisUuids); - void deleteAnalysisMeasures(@Param("analysisUuids") List analysisUuids); void deleteSnapshotMeasures(@Param("analysisUuids") List analysisUuids); diff --git a/sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml b/sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml index 8bd1b400caf..fa9fd4b78c5 100644 --- a/sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml @@ -104,15 +104,6 @@ - - delete from scanner_context - where - analysis_uuid in - - #{analysisUuid} - - - delete from snapshots where diff --git a/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java b/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java index ee48762f5a2..e2869998727 100644 --- a/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java @@ -24,13 +24,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.Map; import org.junit.Rule; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.sonar.api.resources.Scopes; import org.sonar.api.utils.System2; -import org.sonar.core.util.CloseableIterator; import org.sonar.core.util.Uuids; import org.sonar.db.DbClient; import org.sonar.db.DbSession; @@ -40,7 +38,6 @@ import org.sonar.db.ce.CeQueueDto; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; -import static java.util.Collections.singleton; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -64,14 +61,11 @@ public class PurgeDaoTest { @Test public void shouldDeleteAbortedBuilds() { dbTester.prepareDbUnit(getClass(), "shouldDeleteAbortedBuilds.xml"); - insertScannerContext("u1", "bla!"); - insertScannerContext("u2", "blo!"); underTest.purge(dbSession, newConfigurationWith30Days(), PurgeListener.EMPTY, new PurgeProfiler()); dbSession.commit(); dbTester.assertDbUnit(getClass(), "shouldDeleteAbortedBuilds-result.xml", "snapshots"); - assertSingleScannerContext("u1"); } @Test @@ -108,12 +102,9 @@ public class PurgeDaoTest { @Test public void shouldDeleteAnalyses() { dbTester.prepareDbUnit(getClass(), "shouldDeleteAnalyses.xml"); - insertScannerContext("u1", "pop"); - insertScannerContext("u3", "pup"); underTest.deleteAnalyses(dbSession, new PurgeProfiler(), ImmutableList.of(new IdUuidPair(3, "u3"))); dbTester.assertDbUnit(getClass(), "shouldDeleteAnalyses-result.xml", "snapshots"); - assertSingleScannerContext("u1"); } @Test @@ -133,7 +124,6 @@ public class PurgeDaoTest { @Test public void delete_project_and_associated_data() { dbTester.prepareDbUnit(getClass(), "shouldDeleteProject.xml"); - insertScannerContext("u1", "ppppp"); underTest.deleteProject(dbSession, "A"); dbSession.commit(); @@ -143,7 +133,6 @@ public class PurgeDaoTest { assertThat(dbTester.countRowsOfTable("issues")).isZero(); assertThat(dbTester.countRowsOfTable("issue_changes")).isZero(); assertThat(dbTester.countRowsOfTable("file_sources")).isZero(); - assertThat(dbTester.countRowsOfTable("scanner_context")).isZero(); } @Test @@ -253,14 +242,4 @@ public class PurgeDaoTest { return new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, THE_PROJECT_UUID), new String[0], 30, system2, Arrays.asList(disabledComponentUuids)); } - private void insertScannerContext(String analysisUuid, String scannerContext) { - dbTester.getDbClient().ceScannerContextDao().insert(dbSession, analysisUuid, CloseableIterator.from(singleton(scannerContext).iterator())); - dbTester.commit(); - } - - private void assertSingleScannerContext(String expected) { - List> rows = dbTester.select("select analysis_uuid as \"analysisUuid\" from scanner_context"); - assertThat(rows).hasSize(1); - assertThat(rows.iterator().next().get("analysisUuid")).isEqualTo(expected); - } }