aboutsummaryrefslogtreecommitdiffstats
path: root/it
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2016-05-03 16:44:22 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-05-04 15:49:19 +0200
commitfea13c08b836024fdaa859cb91a33966d3a4d6b8 (patch)
tree4035d0129d1c67f33e84e4e1778ab9b4638fe826 /it
parent4f15edb013085ec08fe3721f0a5307d99685868a (diff)
downloadsonarqube-fea13c08b836024fdaa859cb91a33966d3a4d6b8.tar.gz
sonarqube-fea13c08b836024fdaa859cb91a33966d3a4d6b8.zip
SONAR-7108 Delete Issues from index when purging old issues
Purge from index was already working when property 'sonar.dbcleaner.daysBeforeDeletingClosedIssues' was not equal to 0. Now it's working whatever the value is.
Diffstat (limited to 'it')
-rw-r--r--it/it-tests/src/test/java/it/issue/IssuePurgeTest.java64
1 files changed, 57 insertions, 7 deletions
diff --git a/it/it-tests/src/test/java/it/issue/IssuePurgeTest.java b/it/it-tests/src/test/java/it/issue/IssuePurgeTest.java
index 8a361c23570..2dd92f72995 100644
--- a/it/it-tests/src/test/java/it/issue/IssuePurgeTest.java
+++ b/it/it-tests/src/test/java/it/issue/IssuePurgeTest.java
@@ -20,13 +20,13 @@
package it.issue;
import java.util.List;
-import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.sonar.wsclient.issue.Issue;
import org.sonar.wsclient.issue.IssueQuery;
+import org.sonar.wsclient.issue.Issues;
import util.ProjectAnalysis;
import util.ProjectAnalysisRule;
import util.QaOnly;
@@ -67,8 +67,8 @@ public class IssuePurgeTest extends AbstractIssueTest {
.run();
// All the issues are open
- List<Issue> issues = searchIssues();
- for (Issue issue : issues) {
+ List<Issue> issuesList = searchIssues();
+ for (Issue issue : issuesList) {
assertThat(issue.resolution()).isNull();
}
@@ -80,9 +80,9 @@ public class IssuePurgeTest extends AbstractIssueTest {
"sonar.dynamicAnalysis", "false",
"sonar.projectDate", "2014-10-15")
.run();
- issues = searchIssues();
- assertThat(issues).isNotEmpty();
- for (Issue issue : issues) {
+ issuesList = searchIssues();
+ assertThat(issuesList).isNotEmpty();
+ for (Issue issue : issuesList) {
assertThat(issue.resolution()).isNotNull();
assertThat(issue.status()).isEqualTo("CLOSED");
}
@@ -95,7 +95,57 @@ public class IssuePurgeTest extends AbstractIssueTest {
"sonar.dynamicAnalysis", "false",
"sonar.projectDate", "2014-10-20")
.run();
- Assertions.assertThat(searchIssues(IssueQuery.create())).isEmpty();
+ Issues issues = issueClient().find(IssueQuery.create());
+ assertThat(issues.list()).isEmpty();
+ assertThat(issues.paging().total()).isZero();
+ }
+
+ /**
+ * SONAR-7108
+ */
+ @Test
+ public void purge_old_closed_issues_when_zero_closed_issues_wanted() throws Exception {
+ projectAnalysisRule.setServerProperty("sonar.dbcleaner.daysBeforeDeletingClosedIssues", "5000");
+
+ // Generate some issues
+ xooSampleAnalysis.withProperties(
+ "sonar.dynamicAnalysis", "false",
+ "sonar.projectDate", "2014-10-01")
+ .run();
+
+ // All the issues are open
+ List<Issue> issueList = searchIssues();
+ for (Issue issue : issueList) {
+ assertThat(issue.resolution()).isNull();
+ }
+
+ // Second scan with empty profile -> all issues are resolved and closed
+ // -> Not deleted because less than 5000 days long
+ xooSampleAnalysis
+ .withXooEmptyProfile()
+ .withProperties(
+ "sonar.dynamicAnalysis", "false",
+ "sonar.projectDate", "2014-10-15")
+ .run();
+ issueList = searchIssues();
+ assertThat(issueList).isNotEmpty();
+ for (Issue issue : issueList) {
+ assertThat(issue.resolution()).isNotNull();
+ assertThat(issue.status()).isEqualTo("CLOSED");
+ }
+
+ // Third scan -> closed issues are deleted
+ projectAnalysisRule.setServerProperty("sonar.dbcleaner.daysBeforeDeletingClosedIssues", "0");
+
+ xooSampleAnalysis.withXooEmptyProfile()
+ .withProperties(
+ "sonar.dynamicAnalysis", "false",
+ "sonar.projectDate", "2014-10-20")
+ .run();
+
+ Issues issues = issueClient().find(IssueQuery.create());
+ assertThat(issues.list()).isEmpty();
+ assertThat(issues.paging().total()).isZero();
}
/**