Skip to content

Commit

Permalink
[WFCORE-6773] Read the permitted stability levels from the server rat…
Browse files Browse the repository at this point in the history
…her than using a hardcoded set
  • Loading branch information
kabir committed Apr 8, 2024
1 parent bbff9b0 commit e25b2ba
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.wildfly.core.testrunner.ServerSetupTask;
import org.wildfly.test.snapshot.ServerSnapshot;

import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CORE_SERVICE;
Expand Down Expand Up @@ -52,7 +52,7 @@ public StabilityServerSetupSnapshotRestoreTasks(Stability desiredStability) {
@Override
public final void setup(ManagementClient managementClient) throws Exception {
// Make sure the desired stability level is one of the ones supported by the server
Set<Stability> supportedStabilityLevels = getSupportedStabilityLevels();
Set<Stability> supportedStabilityLevels = getSupportedStabilityLevels(managementClient);
Assume.assumeTrue(
String.format("%s is not a supported stability level", desiredStability, supportedStabilityLevels),
supportedStabilityLevels.contains(desiredStability));
Expand Down Expand Up @@ -110,10 +110,14 @@ private Stability getReloadEnhancedOperationStabilityLevel(ManagementClient mana
return Stability.fromString(stability);

}
private Set<Stability> getSupportedStabilityLevels() {
// TODO WFCORE-6731 - see https://github.com/wildfly/wildfly-core/pull/5895#discussion_r1520489808
// This information will be available in a management operation, For now just return a hardcoded set
return EnumSet.allOf(Stability.class);
private Set<Stability> getSupportedStabilityLevels(ManagementClient managementClient) throws Exception {
ModelNode op = Util.getReadAttributeOperation(PathAddress.pathAddress(CORE_SERVICE, SERVER_ENVIRONMENT), "permissible-stability-levels");
ModelNode result = ManagementOperations.executeOperation(managementClient.getControllerClient(), op);
Set<Stability> set = new HashSet<>();
for (ModelNode mn : result.asList()) {
set.add(Stability.fromString(mn.asString()));
}
return set;
}

private Stability reloadToDesiredStability(ModelControllerClient client, Stability stability) throws Exception {
Expand Down

0 comments on commit e25b2ba

Please sign in to comment.