aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server-benchmarks/src
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-12-05 18:14:37 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-12-05 18:14:37 +0100
commit50cfbe42ac5173082c584b25b1a016b60573eaa7 (patch)
treebf0c74fbc79c315ead9e8db089f1dc707f1ac863 /server/sonar-server-benchmarks/src
parent93cbddb82426ce92d404ccbe427322882a7785c8 (diff)
downloadsonarqube-50cfbe42ac5173082c584b25b1a016b60573eaa7.tar.gz
sonarqube-50cfbe42ac5173082c584b25b1a016b60573eaa7.zip
Add assertions for SonarSource performancing box to sonar-server-benchmarks
Diffstat (limited to 'server/sonar-server-benchmarks/src')
-rw-r--r--server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/Benchmark.java (renamed from server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/BenchmarkAssertions.java)17
-rw-r--r--server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/IssueIndexBenchmarkTest.java13
2 files changed, 28 insertions, 2 deletions
diff --git a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/BenchmarkAssertions.java b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/Benchmark.java
index 33c616faf89..d8d7824e0ab 100644
--- a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/BenchmarkAssertions.java
+++ b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/Benchmark.java
@@ -19,7 +19,10 @@
*/
package org.sonar.server.benchmark;
-public class BenchmarkAssertions {
+import org.hamcrest.Matchers;
+import org.junit.rules.ErrorCollector;
+
+public class Benchmark extends ErrorCollector {
private static final boolean ENABLED = "true".equals(System.getProperty("enableBenchmarkAssertions"));
@@ -30,4 +33,16 @@ public class BenchmarkAssertions {
}
}
+ public void expectBetween(String label, long val, long min, long max) {
+ if (ENABLED) {
+ checkThat(label, val, Matchers.allOf(Matchers.greaterThan(min), Matchers.lessThan(max)));
+ }
+ }
+
+ public void expectLessThanOrEqualTo(String label, long val, long max) {
+ if (ENABLED) {
+ checkThat(label, val, Matchers.lessThan(max));
+ }
+ }
+
}
diff --git a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/IssueIndexBenchmarkTest.java b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/IssueIndexBenchmarkTest.java
index 771155528f5..e1bfbaf0be9 100644
--- a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/IssueIndexBenchmarkTest.java
+++ b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/IssueIndexBenchmarkTest.java
@@ -27,6 +27,7 @@ import com.google.common.collect.Maps;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.math.RandomUtils;
import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,6 +63,9 @@ public class IssueIndexBenchmarkTest {
@ClassRule
public static ServerTester tester = new ServerTester();
+ @Rule
+ public Benchmark benchmark = new Benchmark();
+
@Test
public void benchmark() throws Exception {
// initialization - feed issues/issueAuthorization with projects and hardcoded users
@@ -88,6 +92,9 @@ public class IssueIndexBenchmarkTest {
indexer.index(authorizations);
long period = System.currentTimeMillis() - start;
LOGGER.info(String.format("%d authorizations indexed in %d ms (%d docs/second)", PROJECTS, period, 1000 * PROJECTS / period));
+
+ // big range as absolute value is quite slow
+ benchmark.expectBetween("Time to index issue authorizations", period, 200L, 500L);
}
private void benchmarkIssueIndexing() {
@@ -103,7 +110,11 @@ public class IssueIndexBenchmarkTest {
timer.cancel();
long period = System.currentTimeMillis() - start;
LOGGER.info(String.format("%d issues indexed in %d ms (%d docs/second)", issues.count.get(), period, 1000 * issues.count.get() / period));
- LOGGER.info(String.format("Index disk: " + FileUtils.byteCountToDisplaySize(FileUtils.sizeOfDirectory(tester.getEsServerHolder().getHomeDir()))));
+ benchmark.expectBetween("Time to index issues", period, 350000L, 430000L);
+
+ long dirSize = FileUtils.sizeOfDirectory(tester.getEsServerHolder().getHomeDir());
+ LOGGER.info(String.format("ES disk: " + FileUtils.byteCountToDisplaySize(dirSize)));
+ benchmark.expectBetween("ES disk size (b)", dirSize, 385000000L, 395000000L);
}
private void benchmarkQueries() {