-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Administration.shutdownGracefully
- Loading branch information
Showing
12 changed files
with
251 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
testsuite/common/src/main/java/org/wildfly/extras/creaper/arquillian/Extension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.wildfly.extras.creaper.arquillian; | ||
|
||
import org.jboss.arquillian.container.spi.ServerKillProcessor; | ||
import org.jboss.arquillian.core.spi.LoadableExtension; | ||
|
||
public final class Extension implements LoadableExtension { | ||
@Override | ||
public void register(ExtensionBuilder builder) { | ||
builder.service(ServerKillProcessor.class, FakeServerKillProcessor.class); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...e/common/src/main/java/org/wildfly/extras/creaper/arquillian/FakeServerKillProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.wildfly.extras.creaper.arquillian; | ||
|
||
import org.jboss.arquillian.container.spi.Container; | ||
import org.jboss.arquillian.container.spi.ServerKillProcessor; | ||
|
||
final class FakeServerKillProcessor implements ServerKillProcessor { | ||
@Override | ||
public void kill(Container container) throws Exception { | ||
// does nothing, this is only to let Arquillian know that the server is gone | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...mmon/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.wildfly.extras.creaper.arquillian.Extension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
...e/src/test/java/org/wildfly/extras/creaper/core/online/operations/admin/ShutdownTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package org.wildfly.extras.creaper.core.online.operations.admin; | ||
|
||
import org.jboss.arquillian.container.test.api.ContainerController; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.arquillian.junit.InSequence; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.junit.After; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.junit.runner.RunWith; | ||
import org.wildfly.extras.creaper.core.ManagementClient; | ||
import org.wildfly.extras.creaper.core.ServerVersion; | ||
import org.wildfly.extras.creaper.core.online.OnlineManagementClient; | ||
import org.wildfly.extras.creaper.core.online.OnlineOptions; | ||
import org.wildfly.extras.creaper.test.ManualTests; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
@Category(ManualTests.class) | ||
@RunWith(Arquillian.class) | ||
public class ShutdownTest { | ||
private OnlineManagementClient client = ManagementClient.onlineLazy( | ||
OnlineOptions.standalone().localDefault().build()); | ||
private Administration admin = new Administration(client); | ||
|
||
@ArquillianResource | ||
private ContainerController controller; | ||
|
||
@Test | ||
@InSequence(1) | ||
public void startServer() { | ||
controller.start(ManualTests.ARQUILLIAN_CONTAINER); | ||
} | ||
|
||
@Test | ||
@InSequence(2) | ||
public void shutdown() throws Exception { | ||
assertTrue(controller.isStarted(ManualTests.ARQUILLIAN_CONTAINER)); | ||
|
||
admin.shutdown(); | ||
serverShutdown(); | ||
|
||
assertFalse(controller.isStarted(ManualTests.ARQUILLIAN_CONTAINER)); | ||
} | ||
|
||
@Test | ||
@InSequence(3) | ||
public void startServerAgain() throws Exception { | ||
controller.start(ManualTests.ARQUILLIAN_CONTAINER); | ||
client.reconnect(10); | ||
} | ||
|
||
@Test | ||
@InSequence(4) | ||
public void shutdownGracefully() throws Exception { | ||
if (client.version().lessThan(ServerVersion.VERSION_3_0_0)) { | ||
// graceful shutdown not supported | ||
return; | ||
} | ||
|
||
assertTrue(controller.isStarted(ManualTests.ARQUILLIAN_CONTAINER)); | ||
|
||
admin.shutdownGracefully(5); | ||
serverShutdown(); | ||
|
||
assertFalse(controller.isStarted(ManualTests.ARQUILLIAN_CONTAINER)); | ||
|
||
} | ||
|
||
@Test | ||
@InSequence(5) | ||
public void startServerYetAgain() throws Exception { | ||
startServerAgain(); | ||
} | ||
|
||
@Test | ||
@InSequence(6) | ||
public void shutdownGracefullyWithZeroTimeout() throws Exception { | ||
if (client.version().lessThan(ServerVersion.VERSION_3_0_0)) { | ||
// graceful shutdown not supported | ||
return; | ||
} | ||
|
||
assertTrue(controller.isStarted(ManualTests.ARQUILLIAN_CONTAINER)); | ||
|
||
admin.shutdownGracefully(0); | ||
serverShutdown(); | ||
|
||
assertFalse(controller.isStarted(ManualTests.ARQUILLIAN_CONTAINER)); | ||
} | ||
|
||
@Test | ||
@InSequence(7) | ||
public void stopServer() throws Exception { | ||
if (controller.isStarted(ManualTests.ARQUILLIAN_CONTAINER)) { | ||
controller.stop(ManualTests.ARQUILLIAN_CONTAINER); | ||
} | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
client.close(); | ||
} | ||
|
||
private void serverShutdown() throws Exception { | ||
// server shutdown takes a couple of millis, we have to wait for it | ||
// TODO how could Creaper wait for the server to shut down? polling the mgmt port? | ||
Thread.sleep(100); | ||
|
||
// this only lets Arquillian know that the server is gone (see FakeServerKillProcessor) | ||
controller.kill(ManualTests.ARQUILLIAN_CONTAINER); | ||
} | ||
} |