From: Stephane Gamard Date: Mon, 4 Aug 2014 14:16:37 +0000 (+0200) Subject: Added introspections to monitor Tests failures. X-Git-Tag: 4.5-RC1~273 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a388f6ed1c091e4d6281daf2fa7023f25cae11b6;p=sonarqube.git Added introspections to monitor Tests failures. --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/ESNode.java b/server/sonar-server/src/main/java/org/sonar/server/search/ESNode.java index d10ccad680e..56b57009d28 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/ESNode.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/ESNode.java @@ -155,11 +155,30 @@ public class ESNode implements Startable { .put("cluster.name", "cluster-mem-" + NetworkUtils.getLocalAddress().getHostName()) .put("index.store.type", "memory") .put("index.store.fs.memory.enabled", "true") - .put("gateway.type", "none") +// .put("gateway.type", "none") .put("index.number_of_shards", "1") .put("index.number_of_replicas", "0") - .put("cluster.routing.schedule", "50ms") - .put("node.local", true); +// .put("cluster.routing.schedule", "50ms") + .put("node.local", true) + + .put("index.search.slowlog.threshold.query.warn", "10ms") + // Cannot use anything else but warn + .put("index.search.slowlog.threshold.query.info", "10ms") + .put("index.search.slowlog.threshold.query.debug", "10ms") + .put("index.search.slowlog.threshold.query.trace", "10ms") + + .put("index.search.slowlog.threshold.fetch.warn", "10ms") + // Cannot use anything else but warn + .put("index.search.slowlog.threshold.fetch.info", "10ms") + .put("index.search.slowlog.threshold.fetch.debug", "10ms") + .put("index.search.slowlog.threshold.fetch.trace", "10ms") + + .put("index.indexing.slowlog.threshold.index.warn", "10ms") + // Cannot use anything else but warn + .put("index.indexing.slowlog.threshold.index.info", "10ms") + .put("index.indexing.slowlog.threshold.index.debug", "10ms") + .put("index.indexing.slowlog.threshold.index.trace", "10ms"); + ; } private void initDataES(ImmutableSettings.Builder builder) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/IndexQueue.java b/server/sonar-server/src/main/java/org/sonar/server/search/IndexQueue.java index edb234c5e55..ebb7b07371a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/IndexQueue.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/IndexQueue.java @@ -46,7 +46,7 @@ public class IndexQueue extends LinkedBlockingQueue private static final int TIMEOUT = 30000; public IndexQueue() { - super(DEFAULT_QUEUE_SIZE); + super(IndexQueue.DEFAULT_QUEUE_SIZE); } @Override @@ -73,7 +73,7 @@ public class IndexQueue extends LinkedBlockingQueue action.setLatch(latch); try { indexTime = System.currentTimeMillis(); - this.offer(action, TIMEOUT, TimeUnit.SECONDS); + this.offer(action, TIMEOUT, TimeUnit.MILLISECONDS); if (!latch.await(TIMEOUT, TimeUnit.MILLISECONDS)) { throw new IllegalStateException("ES update could not be completed within: " + TIMEOUT + "ms"); } @@ -115,7 +115,7 @@ public class IndexQueue extends LinkedBlockingQueue indexTime = System.currentTimeMillis(); for (IndexAction action : itemActions) { action.setLatch(itemLatch); - this.offer(action, TIMEOUT, TimeUnit.SECONDS); + this.offer(action, TIMEOUT, TimeUnit.MILLISECONDS); types.add(action.getPayloadClass().getSimpleName()); bcount++; diff --git a/server/sonar-server/src/test/java/org/sonar/server/activity/ActivityBackendMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/activity/ActivityBackendMediumTest.java index c20b68b8ddd..18748f2295e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/activity/ActivityBackendMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/activity/ActivityBackendMediumTest.java @@ -23,51 +23,38 @@ package org.sonar.server.activity; import com.google.common.collect.ImmutableMap; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.collect.Iterables; -import org.junit.After; -import org.junit.Before; -import org.junit.ClassRule; import org.junit.Test; import org.sonar.core.activity.Activity; import org.sonar.core.activity.ActivityLog; -import org.sonar.core.persistence.DbSession; import org.sonar.server.activity.db.ActivityDao; import org.sonar.server.activity.index.ActivityIndex; import org.sonar.server.activity.index.ActivityQuery; -import org.sonar.server.db.DbClient; import org.sonar.server.search.QueryOptions; import org.sonar.server.search.Result; -import org.sonar.server.tester.ServerTester; +import java.lang.management.ManagementFactory; +import java.lang.management.MemoryMXBean; import java.util.Iterator; import java.util.Map; import static org.fest.assertions.Assertions.assertThat; -public class ActivityBackendMediumTest { +public class ActivityBackendMediumTest extends SearchMediumTest { - @ClassRule - public static ServerTester tester = new ServerTester(); ActivityService service = tester.get(ActivityService.class); ActivityDao dao = tester.get(ActivityDao.class); ActivityIndex index = tester.get(ActivityIndex.class); - DbClient db; - DbSession dbSession; - - @Before - public void before() { - tester.clearDbAndIndexes(); - db = tester.get(DbClient.class); - dbSession = tester.get(DbClient.class).openSession(false); - } - - @After - public void after() { - dbSession.close(); - } @Test public void insert_find_text_log() throws InterruptedException { + + + System.out.println("tester = " + ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage()); + MemoryMXBean mem = ManagementFactory.getMemoryMXBean(); + System.out.println("mem.getNonHeapMemoryUsage() = " + mem.getNonHeapMemoryUsage()); + System.out.println("mem.getHeapMemoryUsage() = " + mem.getHeapMemoryUsage()); + final String testValue = "hello world"; service.write(dbSession, Activity.Type.QPROFILE, testValue); dbSession.commit(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/activity/SearchMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/activity/SearchMediumTest.java new file mode 100644 index 00000000000..2dba3d0426c --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/activity/SearchMediumTest.java @@ -0,0 +1,42 @@ +package org.sonar.server.activity; + +import org.junit.After; +import org.junit.Before; +import org.junit.ClassRule; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.sonar.core.persistence.DbSession; +import org.sonar.server.db.DbClient; +import org.sonar.server.tester.ServerTester; + +import java.lang.management.ManagementFactory; + +public abstract class SearchMediumTest { + + + private static Logger LOGGER = LoggerFactory.getLogger(SearchMediumTest.class); + + @ClassRule + public static ServerTester tester = new ServerTester(); + + protected DbClient db; + protected DbSession dbSession; + + @Before + public void before() { + tester.clearDbAndIndexes(); + db = tester.get(DbClient.class); + dbSession = tester.get(DbClient.class).openSession(false); + + ManagementFactory.getMemoryMXBean(); + LOGGER.info("* Environment ({})", ManagementFactory.getOperatingSystemMXBean().getName()); + LOGGER.info("* heap:\t{}", ManagementFactory.getMemoryMXBean().getHeapMemoryUsage()); + LOGGER.info("* load:\t{}", ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage()); + } + + @After + public void after() { + dbSession.close(); + } + +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleBackendMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleBackendMediumTest.java index 3537e1ccaf8..e1a2ed3cdce 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleBackendMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleBackendMediumTest.java @@ -21,27 +21,23 @@ package org.sonar.server.qualityprofile; import com.google.common.collect.ImmutableList; import com.google.common.collect.Multimap; -import org.junit.After; import org.junit.Before; -import org.junit.ClassRule; import org.junit.Test; import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.RuleStatus; import org.sonar.api.rule.Severity; import org.sonar.api.server.debt.DebtRemediationFunction; -import org.sonar.core.persistence.DbSession; import org.sonar.core.qualityprofile.db.ActiveRuleDto; import org.sonar.core.qualityprofile.db.ActiveRuleParamDto; import org.sonar.core.qualityprofile.db.QualityProfileDto; import org.sonar.core.rule.RuleDto; import org.sonar.core.rule.RuleParamDto; -import org.sonar.server.db.DbClient; +import org.sonar.server.activity.SearchMediumTest; import org.sonar.server.platform.Platform; import org.sonar.server.qualityprofile.index.ActiveRuleIndex; import org.sonar.server.qualityprofile.index.ActiveRuleNormalizer; import org.sonar.server.rule.RuleTesting; import org.sonar.server.search.FacetValue; -import org.sonar.server.tester.ServerTester; import java.util.Collection; import java.util.Date; @@ -50,28 +46,15 @@ import java.util.Map; import static org.fest.assertions.Assertions.assertThat; -public class ActiveRuleBackendMediumTest { +public class ActiveRuleBackendMediumTest extends SearchMediumTest { - @ClassRule - public static ServerTester tester = new ServerTester(); - - DbClient db; - DbSession dbSession; ActiveRuleIndex index; @Before public void before() { - tester.clearDbAndIndexes(); - db = tester.get(DbClient.class); - dbSession = db.openSession(false); index = tester.get(ActiveRuleIndex.class); } - @After - public void after() throws Exception { - dbSession.close(); - } - @Test public void synchronize_index() throws Exception { diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java index 66a3ba6ab0b..11c2fdf71d4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java @@ -24,20 +24,16 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import org.apache.commons.lang.time.DateUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.ClassRule; import org.junit.Test; import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.RuleStatus; import org.sonar.api.rule.Severity; -import org.sonar.core.persistence.DbSession; import org.sonar.core.qualityprofile.db.ActiveRuleDto; import org.sonar.core.qualityprofile.db.QualityProfileDto; import org.sonar.core.rule.RuleDto; import org.sonar.core.rule.RuleParamDto; import org.sonar.core.technicaldebt.db.CharacteristicDto; -import org.sonar.server.db.DbClient; +import org.sonar.server.activity.SearchMediumTest; import org.sonar.server.debt.DebtTesting; import org.sonar.server.qualityprofile.ActiveRule; import org.sonar.server.qualityprofile.QProfileTesting; @@ -47,7 +43,6 @@ import org.sonar.server.rule.db.RuleDao; import org.sonar.server.search.FacetValue; import org.sonar.server.search.QueryOptions; import org.sonar.server.search.Result; -import org.sonar.server.tester.ServerTester; import javax.annotation.Nullable; import java.util.Arrays; @@ -63,27 +58,12 @@ import static com.google.common.collect.Lists.newArrayList; import static org.fest.assertions.Assertions.assertThat; import static org.fest.assertions.Fail.fail; -public class RuleIndexMediumTest { +public class RuleIndexMediumTest extends SearchMediumTest { - @ClassRule - public static ServerTester tester = new ServerTester(); RuleDao dao = tester.get(RuleDao.class); RuleIndex index = tester.get(RuleIndex.class); - DbClient db; - DbSession dbSession; - @Before - public void before() { - tester.clearDbAndIndexes(); - db = tester.get(DbClient.class); - dbSession = db.openSession(false); - } - - @After - public void after() { - dbSession.close(); - } @Test public void getByKey() throws InterruptedException {