]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7911 don't clean SCANNER_CONTEXT in purge of analysis
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 25 Aug 2016 10:04:18 +0000 (12:04 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 29 Aug 2016 07:48:28 +0000 (09:48 +0200)
sonar-db/src/main/java/org/sonar/db/purge/PurgeCommands.java
sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java
sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml
sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java

index 03c7abd8b8bebc7a32668004920f898278d93712..f77dfc2cdc83d83240aafefaddbc6c599a1789c0 100644 (file)
@@ -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();
index aef0971294b3a9f222240592ce04fd7d4d389c8f..91cb547e29f848b1e355a261e3c72cb612d18eed 100644 (file)
@@ -38,8 +38,6 @@ public interface PurgeMapper {
 
   void deleteAnalysisEvents(@Param("analysisUuids") List<String> analysisUuids);
 
-  void deleteScannerContexts(@Param("analysisUuids") List<String> analysisUuids);
-
   void deleteAnalysisMeasures(@Param("analysisUuids") List<String> analysisUuids);
 
   void deleteSnapshotMeasures(@Param("analysisUuids") List<String> analysisUuids);
index 8bd1b400caf7a4f6eb6b96e2e3038f134a5e6720..fa9fd4b78c5147d5627cdb036667562fe45d4106 100644 (file)
       </foreach>
   </delete>
 
-  <delete id="deleteScannerContexts" parameterType="map">
-    delete from scanner_context
-    where
-      analysis_uuid in
-      <foreach collection="analysisUuids" open="(" close=")" item="analysisUuid" separator=",">
-        #{analysisUuid}
-      </foreach>
-  </delete>
-
   <delete id="deleteAnalyses" parameterType="map">
     delete from snapshots
     where
index ee48762f5a25a798e9cb1e874eb00c465ef5f0c3..e286999872746de93ec32d467277d96b719a4a09 100644 (file)
@@ -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<Map<String, Object>> rows = dbTester.select("select analysis_uuid as \"analysisUuid\" from scanner_context");
-    assertThat(rows).hasSize(1);
-    assertThat(rows.iterator().next().get("analysisUuid")).isEqualTo(expected);
-  }
 }