summaryrefslogtreecommitdiffstats
path: root/server/sonar-process/src/test
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-01-08 15:51:06 +0100
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-01-13 13:42:43 +0100
commit255e54d582d02ab72d1b33f440656fb2d5ae9f8c (patch)
tree57c23abb47875009240b3e442801b58d8c3237ab /server/sonar-process/src/test
parent1d49769ae87ac8a2a553815bf2bfc9bf17a85f8f (diff)
downloadsonarqube-255e54d582d02ab72d1b33f440656fb2d5ae9f8c.tar.gz
sonarqube-255e54d582d02ab72d1b33f440656fb2d5ae9f8c.zip
SONAR-7168 fix stop failing during restart + restart WS call flood issue
stop triggered though shareMemory by Orchestrator did not work when a restart was under way be lifeCycle transition from RESTARTING to STOPPING wasn't allowed when flooding the restart WS, the restart never occured because the WS erased the shareMemory space of the WebServer when called called, erasing the stop signal sent by the main process
Diffstat (limited to 'server/sonar-process/src/test')
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/LifecycleTest.java33
1 files changed, 17 insertions, 16 deletions
diff --git a/server/sonar-process/src/test/java/org/sonar/process/LifecycleTest.java b/server/sonar-process/src/test/java/org/sonar/process/LifecycleTest.java
index fa9d925d159..6337fe60e74 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/LifecycleTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/LifecycleTest.java
@@ -23,6 +23,7 @@ import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.process.Lifecycle.State;
+import static org.sonar.process.Lifecycle.State.*;
public class LifecycleTest {
@@ -37,34 +38,34 @@ public class LifecycleTest {
// different state
Lifecycle stopping = new Lifecycle();
- stopping.tryToMoveTo(State.STARTING);
+ stopping.tryToMoveTo(STARTING);
assertThat(stopping).isNotEqualTo(init);
}
@Test
public void try_to_move_does_not_support_jumping_states() {
Lifecycle lifecycle = new Lifecycle();
- assertThat(lifecycle.getState()).isEqualTo(State.INIT);
+ assertThat(lifecycle.getState()).isEqualTo(INIT);
- assertThat(lifecycle.tryToMoveTo(State.STARTED)).isFalse();
- assertThat(lifecycle.getState()).isEqualTo(State.INIT);
+ assertThat(lifecycle.tryToMoveTo(STARTED)).isFalse();
+ assertThat(lifecycle.getState()).isEqualTo(INIT);
- assertThat(lifecycle.tryToMoveTo(State.STARTING)).isTrue();
- assertThat(lifecycle.getState()).isEqualTo(State.STARTING);
+ assertThat(lifecycle.tryToMoveTo(STARTING)).isTrue();
+ assertThat(lifecycle.getState()).isEqualTo(STARTING);
}
@Test
public void no_state_can_not_move_to_itself() {
- for (State state : State.values()) {
+ for (State state : values()) {
assertThat(newLifeCycle(state).tryToMoveTo(state)).isFalse();
}
}
@Test
public void can_move_to_STOPPING_from_any_state_but_STARTING_and_STARTED_only() {
- for (State state : State.values()) {
- boolean tryToMoveTo = newLifeCycle(state).tryToMoveTo(State.STOPPING);
- if (state == State.STARTING || state == State.STARTED) {
+ for (State state : values()) {
+ boolean tryToMoveTo = newLifeCycle(state).tryToMoveTo(STOPPING);
+ if (state == STARTING || state == STARTED || state == RESTARTING) {
assertThat(tryToMoveTo).describedAs("from state " + state).isTrue();
} else {
assertThat(tryToMoveTo).describedAs("from state " + state).isFalse();
@@ -74,7 +75,7 @@ public class LifecycleTest {
@Test
public void can_move_to_STARTING_from_RESTARTING() {
- assertThat(newLifeCycle(State.RESTARTING).tryToMoveTo(State.STARTING)).isTrue();
+ assertThat(newLifeCycle(RESTARTING).tryToMoveTo(STARTING)).isTrue();
}
private static Lifecycle newLifeCycle(State state) {
@@ -82,15 +83,15 @@ public class LifecycleTest {
case INIT:
return new Lifecycle();
case STARTING:
- return newLifeCycle(State.INIT, state);
+ return newLifeCycle(INIT, state);
case STARTED:
- return newLifeCycle(State.STARTING, state);
+ return newLifeCycle(STARTING, state);
case RESTARTING:
- return newLifeCycle(State.STARTED, state);
+ return newLifeCycle(STARTED, state);
case STOPPING:
- return newLifeCycle(State.STARTED, state);
+ return newLifeCycle(STARTED, state);
case STOPPED:
- return newLifeCycle(State.STOPPING, state);
+ return newLifeCycle(STOPPING, state);
default:
throw new IllegalArgumentException("Unsupported state " + state);
}