aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-process
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-09-19 22:12:00 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-09-26 23:49:38 +0200
commit50a29c569f8448a939877de1918ab3ff937366b8 (patch)
tree793a173461e17df5f3da0e01b1d54546972175c6 /server/sonar-process
parente66b868ad008967f65428a4e5400225600e9413e (diff)
downloadsonarqube-50a29c569f8448a939877de1918ab3ff937366b8.tar.gz
sonarqube-50a29c569f8448a939877de1918ab3ff937366b8.zip
SONAR-9802 complete system info page
Diffstat (limited to 'server/sonar-process')
-rw-r--r--server/sonar-process/pom.xml1
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/cluster/hz/DistributedAnswerTest.java55
2 files changed, 56 insertions, 0 deletions
diff --git a/server/sonar-process/pom.xml b/server/sonar-process/pom.xml
index 58adf12de38..00811e45e56 100644
--- a/server/sonar-process/pom.xml
+++ b/server/sonar-process/pom.xml
@@ -10,6 +10,7 @@
<artifactId>sonar-process</artifactId>
<name>SonarQube :: Process</name>
+ <description>Library shared by all kinds of server processes: main, web and compute engine</description>
<properties>
<sonar.exclusions>target/generated-sources/**/*</sonar.exclusions>
diff --git a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/DistributedAnswerTest.java b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/DistributedAnswerTest.java
index 6c9d8270a19..2cdf3d5dd75 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/DistributedAnswerTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/DistributedAnswerTest.java
@@ -21,7 +21,9 @@ package org.sonar.process.cluster.hz;
import com.hazelcast.core.Member;
import java.io.IOException;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -30,10 +32,22 @@ import static org.mockito.Mockito.when;
public class DistributedAnswerTest {
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
private Member member = newMember("member1");
private DistributedAnswer underTest = new DistributedAnswer();
@Test
+ public void getMembers_return_all_members() {
+ underTest.setAnswer(member, "foo");
+ underTest.setTimedOut(newMember("bar"));
+ underTest.setFailed(newMember("baz"), new IOException("BOOM"));
+
+ assertThat(underTest.getMembers()).hasSize(3);
+ }
+
+ @Test
public void test_call_with_unknown_member() {
assertThat(underTest.getAnswer(member)).isEmpty();
assertThat(underTest.hasTimedOut(member)).isFalse();
@@ -46,6 +60,7 @@ public class DistributedAnswerTest {
assertThat(underTest.getAnswer(member)).hasValue("foo");
assertThat(underTest.hasTimedOut(member)).isFalse();
+ assertThat(underTest.getFailed(member)).isEmpty();
}
@Test
@@ -54,6 +69,7 @@ public class DistributedAnswerTest {
assertThat(underTest.getAnswer(member)).isEmpty();
assertThat(underTest.hasTimedOut(member)).isTrue();
+ assertThat(underTest.getFailed(member)).isEmpty();
}
@Test
@@ -61,6 +77,8 @@ public class DistributedAnswerTest {
IOException e = new IOException();
underTest.setFailed(member, e);
+ assertThat(underTest.getAnswer(member)).isEmpty();
+ assertThat(underTest.hasTimedOut(member)).isFalse();
assertThat(underTest.getFailed(member)).hasValue(e);
}
@@ -76,9 +94,46 @@ public class DistributedAnswerTest {
assertThat(underTest.getFailed(member)).hasValue(exception);
}
+ @Test
+ public void propagateExceptions_does_nothing_if_no_members() {
+ // no errors
+ underTest.propagateExceptions();
+ }
+
+ @Test
+ public void propagateExceptions_does_nothing_if_no_errors() {
+ underTest.setAnswer(newMember("foo"), "bar");
+
+ // no errors
+ underTest.propagateExceptions();
+ }
+
+ @Test
+ public void propagateExceptions_throws_ISE_if_at_least_one_timeout() {
+ underTest.setAnswer(newMember("bar"), "baz");
+ underTest.setTimedOut(newMember("foo"));
+
+ expectedException.expect(IllegalStateException.class);
+ expectedException.expectMessage("Distributed cluster action timed out in cluster nodes foo");
+
+ underTest.propagateExceptions();
+ }
+
+ @Test
+ public void propagateExceptions_throws_ISE_if_at_least_one_failure() {
+ underTest.setAnswer(newMember("bar"), "baz");
+ underTest.setFailed(newMember("foo"), new IOException("BOOM"));
+
+ expectedException.expect(IllegalStateException.class);
+ expectedException.expectMessage("Distributed cluster action in cluster nodes foo (other nodes may have timed out)");
+
+ underTest.propagateExceptions();
+ }
+
private static Member newMember(String uuid) {
Member member = mock(Member.class);
when(member.getUuid()).thenReturn(uuid);
+ when(member.getStringAttribute(HazelcastMember.Attribute.NODE_NAME)).thenReturn(uuid);
return member;
}
}