Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFCORE-2876]: Runtime-failure-causes-rollback does not seem to have effect when configured in model #2487

Merged
merged 1 commit into from
Jun 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public void execute(final OperationContext context, final ModelNode operation) t
final boolean autoDeployXml = AUTO_DEPLOY_XML.resolveModelAttribute(context, operation).asBoolean();
final long deploymentTimeout = DEPLOYMENT_TIMEOUT.resolveModelAttribute(context, operation).asLong();
final int scanInterval = SCAN_INTERVAL.resolveModelAttribute(context, operation).asInt();
final boolean rollback = RUNTIME_FAILURE_CAUSES_ROLLBACK.resolveModelAttribute(context, operation).asBoolean();

final ScheduledExecutorService scheduledExecutorService = createScannerExecutorService();

Expand All @@ -130,6 +131,7 @@ public void execute(final OperationContext context, final ModelNode operation) t
bootTimeScanner.setAutoDeployXMLContent(autoDeployXml);
bootTimeScanner.setDeploymentTimeout(deploymentTimeout);
bootTimeScanner.setScanInterval(scanInterval);
bootTimeScanner.setRuntimeFailureCausesRollback(rollback);
} else {
bootTimeScanner = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,9 @@ private class UndeployScanRunnable implements Runnable {

@Override
public void run() {
forcedUndeployScan();
if(rollbackOnRuntimeFailure) {
forcedUndeployScan();
}
processStateService.removePropertyChangeListener(propertyChangeListener);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ private void makeOneLog() throws IOException {
public void beforeTest() throws Exception {
Files.deleteIfExists(FILE);
// Start the server
container.start();
container.startInAdminMode();
final ModelControllerClient client = container.getClient().getControllerClient();

final CompositeOperationBuilder compositeOp = CompositeOperationBuilder.create();
CompositeOperationBuilder compositeOp = CompositeOperationBuilder.create();

configureUser(client, compositeOp);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@
*/
public abstract class AbstractDeploymentUnitTestCase {

protected void addDeploymentScanner(int scanInterval) throws Exception {
protected void addDeploymentScanner(int scanInterval, boolean rollback) throws Exception {
ModelNode addOp = Util.createAddOperation(PathAddress.pathAddress(PathElement.pathElement(EXTENSION, "org.jboss.as.deployment-scanner")));
ModelNode result = executeOperation(addOp);
assertEquals("Unexpected outcome of adding the test deployment scanner extension: " + addOp, ModelDescriptionConstants.SUCCESS, result.get(OUTCOME).asString());
addOp = Util.createAddOperation(PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, "deployment-scanner")));
result = executeOperation(addOp);
assertEquals("Unexpected outcome of adding the test deployment scanner subsystem: " + addOp, ModelDescriptionConstants.SUCCESS, result.get(OUTCOME).asString());
// add deployment scanner
final ModelNode op = getAddDeploymentScannerOp(scanInterval);
final ModelNode op = getAddDeploymentScannerOp(scanInterval, rollback);
result = executeOperation(op);
assertEquals("Unexpected outcome of adding the test deployment scanner: " + op, ModelDescriptionConstants.SUCCESS, result.get(OUTCOME).asString());
}
Expand Down Expand Up @@ -101,9 +101,10 @@ protected void removeDeploymentScanner() throws Exception {

protected abstract File getDeployDir();

protected ModelNode getAddDeploymentScannerOp(int scanInterval) {
protected ModelNode getAddDeploymentScannerOp(int scanInterval, boolean rollback) {
final ModelNode op = Util.createAddOperation(getTestDeploymentScannerResourcePath());
op.get("scan-interval").set(scanInterval);
op.get("runtime-failure-causes-rollback").set(rollback);
op.get("path").set(getDeployDir().getAbsolutePath());
return op;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void testStartup() throws Exception {
createDeployment(deploymentOne, "org.jboss.modules");

// Add a new de
addDeploymentScanner(1000);
addDeploymentScanner(1000, false);
try {
// Wait until deployed ...
long timeout = System.currentTimeMillis() + TimeoutUtil.adjust(30000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void testStartup() throws Exception {

createDeployment(deploymentOne, "org.jboss.modules");
createDeployment(deploymentTwo, "non.existing.dependency");
addDeploymentScanner(0);
addDeploymentScanner(0, false);
try {
// Wait until deployed ...
long timeout = System.currentTimeMillis() + TIMEOUT;
Expand All @@ -130,10 +130,13 @@ public void testStartup() throws Exception {
Assert.assertEquals("OK", deploymentState(DEPLOYMENT_ONE));
Assert.assertTrue(exists(DEPLOYMENT_TWO));
Assert.assertEquals("FAILED", deploymentState(DEPLOYMENT_TWO));

Assert.assertTrue(Files.exists(oneDeployed));
Assert.assertTrue(Files.exists(twoFailed));

ModelNode rollBackOnBoot = Util.getWriteAttributeOperation(PathAddress.parseCLIStyleAddress("/subsystem=deployment-scanner/scanner=testScanner"), "runtime-failure-causes-rollback", true);
ModelNode result = executeOperation(rollBackOnBoot);
assertEquals("Unexpected outcome of rollbacking the test deployment scanner: " + rollBackOnBoot, ModelDescriptionConstants.SUCCESS, result.get(OUTCOME).asString());

// Restart ...
client.close();
container.stop();
Expand All @@ -156,9 +159,9 @@ public void testStartup() throws Exception {
while (exists(DEPLOYMENT_TWO) && System.currentTimeMillis() < timeout) {
Thread.sleep(10);
}
Assert.assertFalse("Deployment two shouldn't exist at " + TIME_FORMATTER.format(LocalDateTime.now()), exists(DEPLOYMENT_TWO));
Assert.assertFalse("Deployment two should exist at " + TIME_FORMATTER.format(LocalDateTime.now()), exists(DEPLOYMENT_TWO));
ModelNode disableScanner = Util.getWriteAttributeOperation(PathAddress.parseCLIStyleAddress("/subsystem=deployment-scanner/scanner=testScanner"), "scan-interval", 300000);
ModelNode result = executeOperation(disableScanner);
result = executeOperation(disableScanner);
assertEquals("Unexpected outcome of disabling the test deployment scanner: " + disableScanner, ModelDescriptionConstants.SUCCESS, result.get(OUTCOME).asString());

final ModelNode undeployOp = Util.getEmptyOperation(DeploymentUndeployHandler.OPERATION_NAME, DEPLOYMENT_ONE.toModelNode());
Expand Down Expand Up @@ -210,7 +213,7 @@ public void testFailedDeploymentWithPersistentDeployment() throws Exception {

// deploy an invalid file-system deployment

addDeploymentScanner(0);
addDeploymentScanner(0, true);
try {
container.stop();
createDeployment(deployDir.resolve(JAR_TWO), "not.existing.dependency");
Expand Down Expand Up @@ -247,7 +250,7 @@ public void testReplaceDeploymentWithPersistentDeployment() throws Exception {
client = TestSuiteEnvironment.getModelControllerClient();
try {
final PathAddress persistentDeploymentAddress = PathAddress.pathAddress(DEPLOYMENT, JAR_ONE);
addDeploymentScanner(0);
addDeploymentScanner(0, true);
try {
// deploy an file-system deployment
container.stop();
Expand Down Expand Up @@ -286,7 +289,7 @@ public void testFailedFileSystemDeploymentDuringBoot() throws Exception {
try {
client = TestSuiteEnvironment.getModelControllerClient();

addDeploymentScanner(0);
addDeploymentScanner(0, true);
try {
container.stop();

Expand All @@ -311,7 +314,7 @@ public void testFailedDeploymentWithCorrectDeploymentDuringBoot() throws Excepti
try {
client = TestSuiteEnvironment.getModelControllerClient();

addDeploymentScanner(0);
addDeploymentScanner(0, true);
try {
container.stop();

Expand Down