forked from wildfly/wildfly
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request wildfly#17849 from kabir/WFLY-19286-reload-stabili…
…ty-level-tasks [WFLY-19286] Add ServerSetupTasks to reload server to a desired stabi…
- Loading branch information
Showing
6 changed files
with
431 additions
and
0 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
...src/test/java/org/jboss/as/test/smoke/stability/AbstractStabilityServerSetupTaskTest.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,67 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.jboss.as.test.smoke.stability; | ||
|
||
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CORE_SERVICE; | ||
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.STABILITY; | ||
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SYSTEM_PROPERTY; | ||
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE; | ||
import static org.jboss.as.server.controller.descriptions.ServerDescriptionConstants.SERVER_ENVIRONMENT; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.jboss.as.arquillian.container.ManagementClient; | ||
import org.jboss.as.controller.PathAddress; | ||
import org.jboss.as.controller.operations.common.Util; | ||
import org.jboss.as.test.integration.management.ManagementOperations; | ||
import org.jboss.as.version.Stability; | ||
import org.jboss.dmr.ModelNode; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public abstract class AbstractStabilityServerSetupTaskTest { | ||
private final Stability desiredStability; | ||
|
||
@ArquillianResource | ||
private ManagementClient managementClient; | ||
|
||
public AbstractStabilityServerSetupTaskTest(Stability desiredStability) { | ||
this.desiredStability = desiredStability; | ||
} | ||
|
||
@Deployment | ||
public static JavaArchive createDeployment() { | ||
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "stability-test.jar"); | ||
jar.add(EmptyAsset.INSTANCE, "dummy.txt"); | ||
return jar; | ||
} | ||
|
||
|
||
@Test | ||
public void testStabilityMatchesSetupTask() throws Exception { | ||
ModelNode op = Util.getReadAttributeOperation(PathAddress.pathAddress(CORE_SERVICE, SERVER_ENVIRONMENT), STABILITY); | ||
ModelNode result = ManagementOperations.executeOperation(managementClient.getControllerClient(), op); | ||
Stability stability = Stability.fromString(result.asString()); | ||
Assert.assertEquals(desiredStability, stability); | ||
} | ||
|
||
@Test | ||
public void testSystemPropertyWasSetByDoSetupCalls() throws Exception { | ||
ModelNode read = Util.getReadAttributeOperation(PathAddress.pathAddress(SYSTEM_PROPERTY, AbstractStabilityServerSetupTaskTest.class.getName()), VALUE); | ||
ModelNode result = ManagementOperations.executeOperation(managementClient.getControllerClient(), read); | ||
Assert.assertEquals(this.getClass().getName(), result.asString()); | ||
} | ||
|
||
|
||
protected static <T extends AbstractStabilityServerSetupTaskTest> void addSystemProperty(ManagementClient client, Class<T> clazz) throws Exception { | ||
ModelNode add = Util.createAddOperation(PathAddress.pathAddress(SYSTEM_PROPERTY, AbstractStabilityServerSetupTaskTest.class.getName())); | ||
add.get(VALUE).set(clazz.getName()); | ||
ManagementOperations.executeOperation(client.getControllerClient(), add); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...rc/test/java/org/jboss/as/test/smoke/stability/StabilityCommunityServerSetupTestCase.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,35 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.jboss.as.test.smoke.stability; | ||
|
||
import org.jboss.arquillian.container.test.api.RunAsClient; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.as.arquillian.api.ServerSetup; | ||
import org.jboss.as.arquillian.container.ManagementClient; | ||
import org.jboss.as.version.Stability; | ||
import org.junit.runner.RunWith; | ||
import org.wildfly.test.stabilitylevel.StabilityServerSetupSnapshotRestoreTasks; | ||
|
||
@ServerSetup(StabilityCommunityServerSetupTestCase.CommunityStabilitySetupTask.class) | ||
@RunWith(Arquillian.class) | ||
@RunAsClient | ||
public class StabilityCommunityServerSetupTestCase extends AbstractStabilityServerSetupTaskTest { | ||
public StabilityCommunityServerSetupTestCase() { | ||
super(Stability.COMMUNITY); | ||
} | ||
|
||
|
||
public static class CommunityStabilitySetupTask extends StabilityServerSetupSnapshotRestoreTasks.Community { | ||
@Override | ||
protected void doSetup(ManagementClient managementClient) throws Exception { | ||
// Not really needed since the resulting written xml will be of a higher stability level | ||
// than the server. Still we are doing it for experimental preview, so it doesn't hurt to | ||
// do the same here. | ||
AbstractStabilityServerSetupTaskTest.addSystemProperty(managementClient, StabilityCommunityServerSetupTestCase.class); | ||
} | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
.../src/test/java/org/jboss/as/test/smoke/stability/StabilityDefaultServerSetupTestCase.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,33 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.jboss.as.test.smoke.stability; | ||
|
||
import org.jboss.arquillian.container.test.api.RunAsClient; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.as.arquillian.api.ServerSetup; | ||
import org.jboss.as.arquillian.container.ManagementClient; | ||
import org.jboss.as.version.Stability; | ||
import org.junit.runner.RunWith; | ||
import org.wildfly.test.stabilitylevel.StabilityServerSetupSnapshotRestoreTasks; | ||
|
||
@ServerSetup(StabilityDefaultServerSetupTestCase.DefaultStabilitySetupTask.class) | ||
@RunWith(Arquillian.class) | ||
@RunAsClient | ||
public class StabilityDefaultServerSetupTestCase extends AbstractStabilityServerSetupTaskTest { | ||
public StabilityDefaultServerSetupTestCase() { | ||
super(Stability.DEFAULT); | ||
} | ||
|
||
public static class DefaultStabilitySetupTask extends StabilityServerSetupSnapshotRestoreTasks.Default { | ||
@Override | ||
protected void doSetup(ManagementClient managementClient) throws Exception { | ||
// Not really needed since the resulting written xml will be of a higher stability level | ||
// than the server. Still we are doing it for experimental preview, so it doesn't hurt to | ||
// do the same here. | ||
AbstractStabilityServerSetupTaskTest.addSystemProperty(managementClient, StabilityDefaultServerSetupTestCase.class); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...test/java/org/jboss/as/test/smoke/stability/StabilityExperimentalServerSetupTestCase.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,34 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.jboss.as.test.smoke.stability; | ||
|
||
import org.jboss.arquillian.container.test.api.RunAsClient; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.as.arquillian.api.ServerSetup; | ||
import org.jboss.as.arquillian.container.ManagementClient; | ||
import org.jboss.as.version.Stability; | ||
import org.junit.runner.RunWith; | ||
import org.wildfly.test.stabilitylevel.StabilityServerSetupSnapshotRestoreTasks; | ||
|
||
@ServerSetup(StabilityExperimentalServerSetupTestCase.ExperimentalStabilitySetupTask.class) | ||
@RunWith(Arquillian.class) | ||
@RunAsClient | ||
public class StabilityExperimentalServerSetupTestCase extends AbstractStabilityServerSetupTaskTest { | ||
public StabilityExperimentalServerSetupTestCase() { | ||
super(Stability.EXPERIMENTAL); | ||
} | ||
|
||
|
||
public static class ExperimentalStabilitySetupTask extends StabilityServerSetupSnapshotRestoreTasks.Experimental { | ||
@Override | ||
protected void doSetup(ManagementClient managementClient) throws Exception { | ||
// Write a system property so the model ges stored with a lower stability level. | ||
// This is to make sure we can reload back to the higher level from the snapshot | ||
AbstractStabilityServerSetupTaskTest.addSystemProperty(managementClient, StabilityExperimentalServerSetupTestCase.class); | ||
} | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
.../src/test/java/org/jboss/as/test/smoke/stability/StabilityPreviewServerSetupTestCase.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,34 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.jboss.as.test.smoke.stability; | ||
|
||
import org.jboss.arquillian.container.test.api.RunAsClient; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.as.arquillian.api.ServerSetup; | ||
import org.jboss.as.arquillian.container.ManagementClient; | ||
import org.jboss.as.version.Stability; | ||
import org.junit.runner.RunWith; | ||
import org.wildfly.test.stabilitylevel.StabilityServerSetupSnapshotRestoreTasks; | ||
|
||
@ServerSetup(StabilityPreviewServerSetupTestCase.PreviewStabilitySetupTask.class) | ||
@RunWith(Arquillian.class) | ||
@RunAsClient | ||
public class StabilityPreviewServerSetupTestCase extends AbstractStabilityServerSetupTaskTest { | ||
public StabilityPreviewServerSetupTestCase() { | ||
super(Stability.PREVIEW); | ||
} | ||
|
||
|
||
public static class PreviewStabilitySetupTask extends StabilityServerSetupSnapshotRestoreTasks.Preview { | ||
@Override | ||
protected void doSetup(ManagementClient managementClient) throws Exception { | ||
// Write a system property so the model ges stored with a lower stability level. | ||
// This is to make sure we can reload back to the higher level from the snapshot | ||
AbstractStabilityServerSetupTaskTest.addSystemProperty(managementClient, StabilityPreviewServerSetupTestCase.class); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.