.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) {
private static final int TIMEOUT = 30000;
public IndexQueue() {
- super(DEFAULT_QUEUE_SIZE);
+ super(IndexQueue.DEFAULT_QUEUE_SIZE);
}
@Override
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");
}
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++;
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();
--- /dev/null
+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();
+ }
+
+}
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;
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 {
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;
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;
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 {