diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-11-28 10:28:32 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-12-20 11:10:08 +0100 |
commit | e6fea33be6dd9333abdd82444317a708804d2f85 (patch) | |
tree | d099ad55e5abb18d033c102a97c26ee1467c9cbd | |
parent | 527a13d12e2457845d2631e2615181f6173c13bc (diff) | |
download | sonarqube-e6fea33be6dd9333abdd82444317a708804d2f85.tar.gz sonarqube-e6fea33be6dd9333abdd82444317a708804d2f85.zip |
SONAR-10131 purge test files when purging project history
10 files changed, 469 insertions, 80 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentTreeQuery.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentTreeQuery.java index 6119f3cb9ae..a6099250007 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentTreeQuery.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentTreeQuery.java @@ -42,12 +42,15 @@ public class ComponentTreeQuery { // SONAR-7681 a public implementation of List must be used in MyBatis - potential concurrency exceptions otherwise @CheckForNull private final ArrayList<String> qualifiers; + @CheckForNull + private final ArrayList<String> scopes; private final String baseUuid; private final Strategy strategy; private ComponentTreeQuery(Builder builder) { this.nameOrKeyQuery = builder.nameOrKeyQuery; this.qualifiers = builder.qualifiers == null ? null : newArrayList(builder.qualifiers); + this.scopes = builder.scopes == null ? null : newArrayList(builder.scopes); this.baseUuid = builder.baseUuid; this.strategy = requireNonNull(builder.strategy); } @@ -58,6 +61,11 @@ public class ComponentTreeQuery { } @CheckForNull + public Collection<String> getScopes() { + return scopes; + } + + @CheckForNull public String getNameOrKeyQuery() { return nameOrKeyQuery; } @@ -98,6 +106,8 @@ public class ComponentTreeQuery { private String nameOrKeyQuery; @CheckForNull private Collection<String> qualifiers; + @CheckForNull + private Collection<String> scopes; private String baseUuid; private Strategy strategy; @@ -120,6 +130,11 @@ public class ComponentTreeQuery { return this; } + public Builder setScopes(Collection<String> scopes) { + this.scopes = scopes; + return this; + } + public Builder setBaseUuid(String uuid) { this.baseUuid = uuid; return this; diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeConfiguration.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeConfiguration.java index c9d903f883f..15fc642e842 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeConfiguration.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeConfiguration.java @@ -30,16 +30,19 @@ import org.sonar.api.resources.Scopes; import org.sonar.api.utils.System2; import org.sonar.core.config.PurgeConstants; +import static java.util.Arrays.asList; +import static java.util.Collections.singletonList; + public class PurgeConfiguration { private final IdUuidPair rootProjectIdUuid; - private final String[] scopesWithoutHistoricalData; + private final Collection<String> scopesWithoutHistoricalData; private final int maxAgeInDaysOfClosedIssues; private final Optional<Integer> maxAgeInDaysOfInactiveShortLivingBranches; private final System2 system2; private final Collection<String> disabledComponentUuids; - public PurgeConfiguration(IdUuidPair rootProjectId, String[] scopesWithoutHistoricalData, int maxAgeInDaysOfClosedIssues, + public PurgeConfiguration(IdUuidPair rootProjectId, Collection<String> scopesWithoutHistoricalData, int maxAgeInDaysOfClosedIssues, Optional<Integer> maxAgeInDaysOfInactiveShortLivingBranches, System2 system2, Collection<String> disabledComponentUuids) { this.rootProjectIdUuid = rootProjectId; this.scopesWithoutHistoricalData = scopesWithoutHistoricalData; @@ -50,11 +53,11 @@ public class PurgeConfiguration { } public static PurgeConfiguration newDefaultPurgeConfiguration(Configuration config, IdUuidPair idUuidPair, Collection<String> disabledComponentUuids) { - String[] scopes = new String[] {Scopes.FILE}; + Collection<String> scopesWithoutHistoricalData = singletonList(Scopes.FILE); if (config.getBoolean(PurgeConstants.PROPERTY_CLEAN_DIRECTORY).orElse(false)) { - scopes = new String[] {Scopes.DIRECTORY, Scopes.FILE}; + scopesWithoutHistoricalData = asList(Scopes.FILE, Scopes.DIRECTORY); } - return new PurgeConfiguration(idUuidPair, scopes, config.getInt(PurgeConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES).get(), + return new PurgeConfiguration(idUuidPair, scopesWithoutHistoricalData, config.getInt(PurgeConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES).get(), config.getInt(PurgeConstants.DAYS_BEFORE_DELETING_INACTIVE_SHORT_LIVING_BRANCHES), System2.INSTANCE, disabledComponentUuids); } @@ -62,7 +65,7 @@ public class PurgeConfiguration { return rootProjectIdUuid; } - public String[] scopesWithoutHistoricalData() { + public Collection<String> getScopesWithoutHistoricalData() { return scopesWithoutHistoricalData; } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java index de29166e268..05cb3aee82b 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java @@ -21,7 +21,6 @@ package org.sonar.db.purge; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Date; @@ -64,7 +63,7 @@ public class PurgeDao implements Dao { PurgeCommands commands = new PurgeCommands(session, mapper, profiler); String rootUuid = conf.rootProjectIdUuid().getUuid(); deleteAbortedAnalyses(rootUuid, commands); - deleteDataOfComponentsWithoutHistoricalData(session, rootUuid, conf.scopesWithoutHistoricalData(), commands); + deleteDataOfComponentsWithoutHistoricalData(session, rootUuid, conf.getScopesWithoutHistoricalData(), commands); purgeAnalyses(commands, rootUuid); purgeDisabledComponents(session, conf, listener); deleteOldClosedIssues(conf, mapper, listener); @@ -119,8 +118,8 @@ public class PurgeDao implements Dao { commands.deleteAnalyses(query); } - private void deleteDataOfComponentsWithoutHistoricalData(DbSession dbSession, String rootUuid, String[] scopesWithoutHistoricalData, PurgeCommands purgeCommands) { - if (scopesWithoutHistoricalData.length == 0) { + private void deleteDataOfComponentsWithoutHistoricalData(DbSession dbSession, String rootUuid, Collection<String> scopesWithoutHistoricalData, PurgeCommands purgeCommands) { + if (scopesWithoutHistoricalData.isEmpty()) { return; } @@ -134,7 +133,7 @@ public class PurgeDao implements Dao { dbSession, ComponentTreeQuery.builder() .setBaseUuid(rootUuid) - .setQualifiers(Arrays.asList(scopesWithoutHistoricalData)) + .setScopes(scopesWithoutHistoricalData) .setStrategy(Strategy.LEAVES) .build()) .stream().map(ComponentDto::uuid) diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml index 5d7e051032f..b22881f4b64 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml @@ -374,6 +374,12 @@ #{qualifier,jdbcType=VARCHAR} </foreach> </if> + <if test="query.scopes != null"> + and p.scope in + <foreach collection="query.scopes" item="scope" open="(" close=")" separator=","> + #{scope,jdbcType=VARCHAR} + </foreach> + </if> <if test="query.nameOrKeyQuery != null"> and ( p.kee = #{query.nameOrKeyQuery,jdbcType=VARCHAR} diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/MeasureMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/MeasureMapper.xml index 860b4e73f47..d29bcf17665 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/MeasureMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/MeasureMapper.xml @@ -121,7 +121,20 @@ and pm.person_id is null </otherwise> </choose> - <include refid="org.sonar.db.component.ComponentMapper.selectDescendantsFilters"/> + and p.enabled = ${_true} + <if test="query.qualifiers != null"> + and p.qualifier in + <foreach collection="query.qualifiers" item="qualifier" open="(" close=")" separator=","> + #{qualifier,jdbcType=VARCHAR} + </foreach> + </if> + <if test="query.nameOrKeyQuery != null"> + and ( + p.kee = #{query.nameOrKeyQuery,jdbcType=VARCHAR} + or + upper(p.name) like #{query.nameOrKeyUpperLikeQuery,jdbcType=VARCHAR} escape '/' + ) + </if> </sql> <select id="selectPastMeasuresOnSingleAnalysis" parameterType="map" resultType="org.sonar.db.measure.PastMeasureDto"> diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java index 140a3a0bfd3..dc110414f9f 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java @@ -34,6 +34,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.resources.Qualifiers; +import org.sonar.api.resources.Scopes; import org.sonar.api.utils.System2; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -1281,18 +1282,18 @@ public class ComponentDaoTest { } @Test - public void select_descendants_with_children_stragegy() { + public void select_descendants_with_children_strategy() { // project has 2 children: module and file 1. Other files are part of module. ComponentDto project = newPrivateProjectDto(db.organizations().insert(), PROJECT_UUID); db.components().insertProjectAndSnapshot(project); ComponentDto module = newModuleDto(MODULE_UUID, project); db.components().insertComponent(module); - ComponentDto file1 = newFileDto(project, null, FILE_1_UUID).setDbKey("file-key-1").setName("File One"); - db.components().insertComponent(file1); - ComponentDto file2 = newFileDto(module, null, FILE_2_UUID).setDbKey("file-key-2").setName("File Two"); - db.components().insertComponent(file2); - ComponentDto file3 = newFileDto(module, null, FILE_3_UUID).setDbKey("file-key-3").setName("File Three"); - db.components().insertComponent(file3); + ComponentDto fileInProject = newFileDto(project, null, FILE_1_UUID).setDbKey("file-key-1").setName("File One"); + db.components().insertComponent(fileInProject); + ComponentDto file1InModule = newFileDto(module, null, FILE_2_UUID).setDbKey("file-key-2").setName("File Two"); + db.components().insertComponent(file1InModule); + ComponentDto file2InModule = newFileDto(module, null, FILE_3_UUID).setDbKey("file-key-3").setName("File Three"); + db.components().insertComponent(file2InModule); db.commit(); // test children of root @@ -1344,6 +1345,16 @@ public class ComponentDaoTest { // test children of leaf component (file here), matching name query = newTreeQuery(FILE_1_UUID).setNameOrKeyQuery("Foo").build(); assertThat(underTest.selectDescendants(dbSession, query)).isEmpty(); + + // test filtering by scope + query = newTreeQuery(project.uuid()).setScopes(asList(Scopes.FILE)).build(); + assertThat(underTest.selectDescendants(dbSession, query)) + .extracting(ComponentDto::uuid) + .containsExactlyInAnyOrder(fileInProject.uuid()); + query = newTreeQuery(project.uuid()).setScopes(asList(Scopes.PROJECT)).build(); + assertThat(underTest.selectDescendants(dbSession, query)) + .extracting(ComponentDto::uuid) + .containsExactlyInAnyOrder(module.uuid()); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeConfigurationTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeConfigurationTest.java index a55713eb734..1e0dc38b671 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeConfigurationTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeConfigurationTest.java @@ -19,7 +19,6 @@ */ package org.sonar.db.purge; -import java.util.Collections; import java.util.Date; import java.util.Optional; import org.junit.Test; @@ -31,15 +30,16 @@ import org.sonar.api.utils.System2; import org.sonar.core.config.PurgeConstants; import org.sonar.core.config.PurgeProperties; +import static java.util.Collections.emptyList; import static org.assertj.core.api.Assertions.assertThat; public class PurgeConfigurationTest { @Test public void should_delete_all_closed_issues() { - PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 0, Optional.empty(), System2.INSTANCE, Collections.emptyList()); + PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), emptyList(), 0, Optional.empty(), System2.INSTANCE, emptyList()); assertThat(conf.maxLiveDateOfClosedIssues()).isNull(); - conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], -1, Optional.empty(), System2.INSTANCE, Collections.emptyList()); + conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), emptyList(), -1, Optional.empty(), System2.INSTANCE, emptyList()); assertThat(conf.maxLiveDateOfClosedIssues()).isNull(); } @@ -47,7 +47,7 @@ public class PurgeConfigurationTest { public void should_delete_only_old_closed_issues() { Date now = DateUtils.parseDate("2013-05-18"); - PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 30, Optional.empty(), System2.INSTANCE, Collections.emptyList()); + PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), emptyList(), 30, Optional.empty(), System2.INSTANCE, emptyList()); Date toDate = conf.maxLiveDateOfClosedIssues(now); assertThat(toDate.getYear()).isEqualTo(113);// =2013 @@ -57,7 +57,7 @@ public class PurgeConfigurationTest { @Test public void should_have_empty_branch_purge_date() { - PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 30, Optional.of(10), System2.INSTANCE, Collections.emptyList()); + PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), emptyList(), 30, Optional.of(10), System2.INSTANCE, emptyList()); assertThat(conf.maxLiveDateOfInactiveShortLivingBranches()).isNotEmpty(); long tenDaysAgo = DateUtils.addDays(new Date(System2.INSTANCE.now()), -10).getTime(); assertThat(conf.maxLiveDateOfInactiveShortLivingBranches().get().getTime()).isBetween(tenDaysAgo - 5000, tenDaysAgo + 5000); @@ -65,31 +65,32 @@ public class PurgeConfigurationTest { @Test public void should_calculate_branch_purge_date() { - PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 30, Optional.empty(), System2.INSTANCE, Collections.emptyList()); + PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), emptyList(), 30, Optional.empty(), System2.INSTANCE, emptyList()); assertThat(conf.maxLiveDateOfInactiveShortLivingBranches()).isEmpty(); } @Test - public void do_not_delete_directory_by_default() { + public void delete_files_but_not_directories_by_default() { MapSettings settings = new MapSettings(new PropertyDefinitions(PurgeProperties.all())); settings.setProperty(PurgeConstants.PROPERTY_CLEAN_DIRECTORY, false); settings.setProperty(PurgeConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES, 5); Date now = new Date(); - PurgeConfiguration underTest = PurgeConfiguration.newDefaultPurgeConfiguration(settings.asConfig(), new IdUuidPair(42L, "any-uuid"), Collections.emptyList()); + PurgeConfiguration underTest = PurgeConfiguration.newDefaultPurgeConfiguration(settings.asConfig(), new IdUuidPair(42L, "any-uuid"), emptyList()); - assertThat(underTest.scopesWithoutHistoricalData()).contains(Scopes.FILE) - .doesNotContain(Scopes.DIRECTORY); + assertThat(underTest.getScopesWithoutHistoricalData()) + .containsExactlyInAnyOrder(Scopes.FILE); assertThat(underTest.maxLiveDateOfClosedIssues(now)).isEqualTo(DateUtils.addDays(now, -5)); } @Test - public void delete_directory_if_in_settings() { + public void delete_directory_if_enabled_in_settings() { MapSettings settings = new MapSettings(new PropertyDefinitions(PurgeProperties.all())); settings.setProperty(PurgeConstants.PROPERTY_CLEAN_DIRECTORY, true); - PurgeConfiguration underTest = PurgeConfiguration.newDefaultPurgeConfiguration(settings.asConfig(), new IdUuidPair(42L, "any-uuid"), Collections.emptyList()); + PurgeConfiguration underTest = PurgeConfiguration.newDefaultPurgeConfiguration(settings.asConfig(), new IdUuidPair(42L, "any-uuid"), emptyList()); - assertThat(underTest.scopesWithoutHistoricalData()).contains(Scopes.DIRECTORY, Scopes.FILE); + assertThat(underTest.getScopesWithoutHistoricalData()) + .containsExactlyInAnyOrder(Scopes.DIRECTORY, Scopes.FILE); } } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java index e48f5c90b70..00be4cb27f6 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java @@ -54,6 +54,7 @@ import org.sonar.db.property.PropertyDto; import org.sonar.db.rule.RuleDefinitionDto; import static java.util.Arrays.asList; +import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; import static org.assertj.core.api.Assertions.assertThat; @@ -132,13 +133,13 @@ public class PurgeDaoTest { @Test public void shouldDeleteHistoricalDataOfDirectoriesAndFiles() { dbTester.prepareDbUnit(getClass(), "shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml"); - PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, "ABCD"), new String[] {Scopes.DIRECTORY, Scopes.FILE}, + PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, "PROJECT_UUID"), asList(Scopes.DIRECTORY, Scopes.FILE), 30, Optional.of(30), System2.INSTANCE, Collections.emptyList()); underTest.purge(dbSession, conf, PurgeListener.EMPTY, new PurgeProfiler()); dbSession.commit(); - dbTester.assertDbUnit(getClass(), "shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml", "projects", "snapshots"); + dbTester.assertDbUnit(getClass(), "shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml", "projects", "snapshots", "project_measures"); } @Test @@ -357,7 +358,7 @@ public class PurgeDaoTest { @Test public void should_delete_all_closed_issues() { dbTester.prepareDbUnit(getClass(), "should_delete_all_closed_issues.xml"); - PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, "1"), new String[0], + PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, "1"), emptyList(), 0, Optional.empty(), System2.INSTANCE, Collections.emptyList()); underTest.purge(dbSession, conf, PurgeListener.EMPTY, new PurgeProfiler()); dbSession.commit(); @@ -627,11 +628,11 @@ public class PurgeDaoTest { } private static PurgeConfiguration newConfigurationWith30Days() { - return new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, THE_PROJECT_UUID), new String[0], 30, Optional.of(30), System2.INSTANCE, Collections.emptyList()); + return new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, THE_PROJECT_UUID), emptyList(), 30, Optional.of(30), System2.INSTANCE, Collections.emptyList()); } private static PurgeConfiguration newConfigurationWith30Days(System2 system2, String rootProjectUuid, String... disabledComponentUuids) { - return new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, rootProjectUuid), new String[0], 30, Optional.of(30), system2, asList(disabledComponentUuids)); + return new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, rootProjectUuid), emptyList(), 30, Optional.of(30), system2, asList(disabledComponentUuids)); } } diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml index 3e6532b606a..e84a82ff99e 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml @@ -1,16 +1,10 @@ -<!-- - -What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6 (DIR/FIL) are deleted - ---> - <dataset> <!-- the project --> <projects organization_uuid="org1" - uuid="ABCD" + uuid="PROJECT_UUID" uuid_path="." - project_uuid="ABCD" + project_uuid="PROJECT_UUID" module_uuid="[null]" module_uuid_path="." main_branch_project_uuid="[null]" @@ -22,7 +16,6 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6 name="project" description="[null]" private="[false]" - tags="[null]" language="java" copy_component_uuid="[null]" developer_uuid="[null]" @@ -31,7 +24,8 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6 authorization_updated_at="[null]" id="1" enabled="[true]" - root_uuid="ABCD" + root_uuid="PROJECT_UUID" + tags="[null]" b_changed="[false]" b_copy_component_uuid="[null]" b_description="[null]" @@ -48,10 +42,10 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6 <!-- the directory --> <projects organization_uuid="org1" - uuid="EFGH" - uuid_path=".ABCD." - project_uuid="ABCD" - module_uuid="ABCD" + uuid="DIR_UUID" + uuid_path=".PROJECT_UUID." + project_uuid="PROJECT_UUID" + module_uuid="PROJECT_UUID" module_uuid_path="." main_branch_project_uuid="[null]" created_at="[null]" @@ -62,7 +56,6 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6 name="my/dir" description="[null]" private="[false]" - tags="[null]" language="java" copy_component_uuid="[null]" developer_uuid="[null]" @@ -71,7 +64,8 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6 authorization_updated_at="[null]" id="2" enabled="[true]" - root_uuid="ABCD" + root_uuid="PROJECT_UUID" + tags="[null]" b_changed="[false]" b_copy_component_uuid="[null]" b_description="[null]" @@ -88,11 +82,11 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6 <!-- the file --> <projects organization_uuid="org1" - uuid="GHIJ" - uuid_path=".ABCD.EFGH." - project_uuid="ABCD" - module_uuid="ABCD" - module_uuid_path=".ABCD." + uuid="FILE_UUID" + uuid_path=".PROJECT_UUID.DIR_UUID." + project_uuid="PROJECT_UUID" + module_uuid="PROJECT_UUID" + module_uuid_path=".PROJECT_UUID." main_branch_project_uuid="[null]" created_at="[null]" long_name="[null]" @@ -102,7 +96,6 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6 name="my/dir/File.java" description="[null]" private="[false]" - tags="[null]" language="java" copy_component_uuid="[null]" developer_uuid="[null]" @@ -111,7 +104,48 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6 authorization_updated_at="[null]" id="3" enabled="[true]" - root_uuid="ABCD" + root_uuid="PROJECT_UUID" + tags="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_uuid_path="[null]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> + + <!-- unit test file --> + <projects organization_uuid="org1" + uuid="TEST_FILE_UUID" + uuid_path=".PROJECT_UUID.DIR_UUID." + project_uuid="PROJECT_UUID" + module_uuid="PROJECT_UUID" + module_uuid_path=".PROJECT_UUID." + main_branch_project_uuid="[null]" + created_at="[null]" + long_name="[null]" + scope="FIL" + qualifier="UTS" + kee="project:my/dir/FileTest.java" + name="my/dir/FileTest.java" + description="[null]" + private="[false]" + language="java" + copy_component_uuid="[null]" + developer_uuid="[null]" + path="[null]" + deprecated_kee="[null]" + authorization_updated_at="[null]" + id="4" + enabled="[true]" + root_uuid="PROJECT_UUID" + tags="[null]" b_changed="[false]" b_copy_component_uuid="[null]" b_description="[null]" @@ -129,7 +163,7 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6 <!-- do not purge last snapshots --> <snapshots id="1" uuid="u1" - component_uuid="ABCD" + component_uuid="PROJECT_UUID" status="P" islast="[true]" purge_status="[null]" @@ -153,10 +187,75 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6 version="[null]" /> + <project_measures id="1" + analysis_uuid="u1" + metric_id="10" + value="[null]" + text_value="[null]" + measure_data="[null]" + variation_value_1="[null]" + variation_value_2="[null]" + variation_value_3="[null]" + variation_value_4="[null]" + variation_value_5="[null]" + alert_status="[null]" + alert_text="[null]" + person_id="[null]" + description="[null]" + component_uuid="PROJECT_UUID"/> + <project_measures id="2" + analysis_uuid="u1" + metric_id="10" + value="[null]" + text_value="[null]" + measure_data="[null]" + variation_value_1="[null]" + variation_value_2="[null]" + variation_value_3="[null]" + variation_value_4="[null]" + variation_value_5="[null]" + alert_status="[null]" + alert_text="[null]" + person_id="[null]" + description="[null]" + component_uuid="DIR_UUID"/> + <project_measures id="3" + analysis_uuid="u1" + metric_id="10" + value="[null]" + text_value="[null]" + measure_data="[null]" + variation_value_1="[null]" + variation_value_2="[null]" + variation_value_3="[null]" + variation_value_4="[null]" + variation_value_5="[null]" + alert_status="[null]" + alert_text="[null]" + person_id="[null]" + description="[null]" + component_uuid="FILE_UUID"/> + <project_measures id="4" + analysis_uuid="u1" + metric_id="10" + value="[null]" + text_value="[null]" + measure_data="[null]" + variation_value_1="[null]" + variation_value_2="[null]" + variation_value_3="[null]" + variation_value_4="[null]" + variation_value_5="[null]" + alert_status="[null]" + alert_text="[null]" + person_id="[null]" + description="[null]" + component_uuid="TEST_FILE_UUID"/> + <!-- snapshots to be purged --> <snapshots id="4" - uuid="u4" - component_uuid="ABCD" + uuid="u2" + component_uuid="PROJECT_UUID" status="P" islast="[false]" purge_status="1" @@ -180,4 +279,69 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6 version="[null]" /> + <project_measures id="5" + analysis_uuid="u2" + metric_id="10" + value="[null]" + text_value="[null]" + measure_data="[null]" + variation_value_1="[null]" + variation_value_2="[null]" + variation_value_3="[null]" + variation_value_4="[null]" + variation_value_5="[null]" + alert_status="[null]" + alert_text="[null]" + person_id="[null]" + description="[null]" + component_uuid="PROJECT_UUID"/> + <!--<project_measures id="6"--> + <!--analysis_uuid="u2"--> + <!--metric_id="10"--> + <!--value="[null]"--> + <!--text_value="[null]"--> + <!--measure_data="[null]"--> + <!--variation_value_1="[null]"--> + <!--variation_value_2="[null]"--> + <!--variation_value_3="[null]"--> + <!--variation_value_4="[null]"--> + <!--variation_value_5="[null]"--> + <!--alert_status="[null]"--> + <!--alert_text="[null]"--> + <!--person_id="[null]"--> + <!--description="[null]"--> + <!--component_uuid="DIR_UUID"/>--> + <!--<project_measures id="7"--> + <!--analysis_uuid="u2"--> + <!--metric_id="10"--> + <!--value="[null]"--> + <!--text_value="[null]"--> + <!--measure_data="[null]"--> + <!--variation_value_1="[null]"--> + <!--variation_value_2="[null]"--> + <!--variation_value_3="[null]"--> + <!--variation_value_4="[null]"--> + <!--variation_value_5="[null]"--> + <!--alert_status="[null]"--> + <!--alert_text="[null]"--> + <!--person_id="[null]"--> + <!--description="[null]"--> + <!--component_uuid="FILE_UUID"/>--> + <!--<project_measures id="8"--> + <!--analysis_uuid="u2"--> + <!--metric_id="10"--> + <!--value="[null]"--> + <!--text_value="[null]"--> + <!--measure_data="[null]"--> + <!--variation_value_1="[null]"--> + <!--variation_value_2="[null]"--> + <!--variation_value_3="[null]"--> + <!--variation_value_4="[null]"--> + <!--variation_value_5="[null]"--> + <!--alert_status="[null]"--> + <!--alert_text="[null]"--> + <!--person_id="[null]"--> + <!--description="[null]"--> + <!--component_uuid="TEST_FILE_UUID"/>--> + </dataset> diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml index c6f8da44917..ff62231bcb5 100644 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml +++ b/server/sonar-db-dao/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml @@ -2,9 +2,9 @@ <!-- the project --> <projects organization_uuid="org1" - uuid="ABCD" + uuid="PROJECT_UUID" uuid_path="." - project_uuid="ABCD" + project_uuid="PROJECT_UUID" module_uuid="[null]" module_uuid_path="." main_branch_project_uuid="[null]" @@ -24,8 +24,10 @@ authorization_updated_at="[null]" id="1" enabled="[true]" - root_uuid="ABCD" + root_uuid="PROJECT_UUID" + tags="[null]" b_changed="[false]" + b_copy_component_uuid="[null]" b_description="[null]" b_enabled="[false]" b_uuid_path="[null]" @@ -40,10 +42,10 @@ <!-- the directory --> <projects organization_uuid="org1" - uuid="EFGH" - uuid_path=".ABCD." - project_uuid="ABCD" - module_uuid="ABCD" + uuid="DIR_UUID" + uuid_path=".PROJECT_UUID." + project_uuid="PROJECT_UUID" + module_uuid="PROJECT_UUID" module_uuid_path="." main_branch_project_uuid="[null]" created_at="[null]" @@ -62,8 +64,10 @@ authorization_updated_at="[null]" id="2" enabled="[true]" - root_uuid="ABCD" + root_uuid="PROJECT_UUID" + tags="[null]" b_changed="[false]" + b_copy_component_uuid="[null]" b_description="[null]" b_enabled="[false]" b_uuid_path="[null]" @@ -78,11 +82,11 @@ <!-- the file --> <projects organization_uuid="org1" - uuid="GHIJ" - uuid_path=".ABCD.EFGH." - project_uuid="ABCD" - module_uuid="ABCD" - module_uuid_path=".ABCD." + uuid="FILE_UUID" + uuid_path=".PROJECT_UUID.DIR_UUID." + project_uuid="PROJECT_UUID" + module_uuid="PROJECT_UUID" + module_uuid_path=".PROJECT_UUID." main_branch_project_uuid="[null]" created_at="[null]" long_name="[null]" @@ -100,8 +104,50 @@ authorization_updated_at="[null]" id="3" enabled="[true]" - root_uuid="ABCD" + root_uuid="PROJECT_UUID" + tags="[null]" b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_uuid_path="[null]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> + + <!-- unit test file --> + <projects organization_uuid="org1" + uuid="TEST_FILE_UUID" + uuid_path=".PROJECT_UUID.DIR_UUID." + project_uuid="PROJECT_UUID" + module_uuid="PROJECT_UUID" + module_uuid_path=".PROJECT_UUID." + main_branch_project_uuid="[null]" + created_at="[null]" + long_name="[null]" + scope="FIL" + qualifier="UTS" + kee="project:my/dir/FileTest.java" + name="my/dir/FileTest.java" + description="[null]" + private="[false]" + language="java" + copy_component_uuid="[null]" + developer_uuid="[null]" + path="[null]" + deprecated_kee="[null]" + authorization_updated_at="[null]" + id="4" + enabled="[true]" + root_uuid="PROJECT_UUID" + tags="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" b_description="[null]" b_enabled="[false]" b_uuid_path="[null]" @@ -117,7 +163,7 @@ <!-- do not purge last snapshots --> <snapshots id="1" uuid="u1" - component_uuid="ABCD" + component_uuid="PROJECT_UUID" status="P" islast="[true]" purge_status="[null]" @@ -141,10 +187,75 @@ version="[null]" /> + <project_measures id="1" + analysis_uuid="u1" + metric_id="10" + value="[null]" + text_value="[null]" + measure_data="[null]" + variation_value_1="[null]" + variation_value_2="[null]" + variation_value_3="[null]" + variation_value_4="[null]" + variation_value_5="[null]" + alert_status="[null]" + alert_text="[null]" + person_id="[null]" + description="[null]" + component_uuid="PROJECT_UUID"/> + <project_measures id="2" + analysis_uuid="u1" + metric_id="10" + value="[null]" + text_value="[null]" + measure_data="[null]" + variation_value_1="[null]" + variation_value_2="[null]" + variation_value_3="[null]" + variation_value_4="[null]" + variation_value_5="[null]" + alert_status="[null]" + alert_text="[null]" + person_id="[null]" + description="[null]" + component_uuid="DIR_UUID"/> + <project_measures id="3" + analysis_uuid="u1" + metric_id="10" + value="[null]" + text_value="[null]" + measure_data="[null]" + variation_value_1="[null]" + variation_value_2="[null]" + variation_value_3="[null]" + variation_value_4="[null]" + variation_value_5="[null]" + alert_status="[null]" + alert_text="[null]" + person_id="[null]" + description="[null]" + component_uuid="FILE_UUID"/> + <project_measures id="4" + analysis_uuid="u1" + metric_id="10" + value="[null]" + text_value="[null]" + measure_data="[null]" + variation_value_1="[null]" + variation_value_2="[null]" + variation_value_3="[null]" + variation_value_4="[null]" + variation_value_5="[null]" + alert_status="[null]" + alert_text="[null]" + person_id="[null]" + description="[null]" + component_uuid="TEST_FILE_UUID"/> + <!-- snapshots to be purged --> <snapshots id="4" - uuid="u4" - component_uuid="ABCD" + uuid="u2" + component_uuid="PROJECT_UUID" status="P" islast="[false]" purge_status="[null]" @@ -168,4 +279,69 @@ version="[null]" /> + <project_measures id="5" + analysis_uuid="u2" + metric_id="10" + value="[null]" + text_value="[null]" + measure_data="[null]" + variation_value_1="[null]" + variation_value_2="[null]" + variation_value_3="[null]" + variation_value_4="[null]" + variation_value_5="[null]" + alert_status="[null]" + alert_text="[null]" + person_id="[null]" + description="[null]" + component_uuid="PROJECT_UUID"/> + <project_measures id="6" + analysis_uuid="u2" + metric_id="10" + value="[null]" + text_value="[null]" + measure_data="[null]" + variation_value_1="[null]" + variation_value_2="[null]" + variation_value_3="[null]" + variation_value_4="[null]" + variation_value_5="[null]" + alert_status="[null]" + alert_text="[null]" + person_id="[null]" + description="[null]" + component_uuid="DIR_UUID"/> + <project_measures id="7" + analysis_uuid="u2" + metric_id="10" + value="[null]" + text_value="[null]" + measure_data="[null]" + variation_value_1="[null]" + variation_value_2="[null]" + variation_value_3="[null]" + variation_value_4="[null]" + variation_value_5="[null]" + alert_status="[null]" + alert_text="[null]" + person_id="[null]" + description="[null]" + component_uuid="FILE_UUID"/> + <project_measures id="8" + analysis_uuid="u2" + metric_id="10" + value="[null]" + text_value="[null]" + measure_data="[null]" + variation_value_1="[null]" + variation_value_2="[null]" + variation_value_3="[null]" + variation_value_4="[null]" + variation_value_5="[null]" + alert_status="[null]" + alert_text="[null]" + person_id="[null]" + description="[null]" + component_uuid="TEST_FILE_UUID"/> + </dataset> |