Skip to content

Commit

Permalink
[WFCORE-6815] Verify the domain reloaded to the original stability wh…
Browse files Browse the repository at this point in the history
…en the Snapshoft is closed
  • Loading branch information
yersan committed May 13, 2024
1 parent 15f6f13 commit df96d5c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.HOST;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.HOST_CONFIG;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RELOAD;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RELOAD_ENHANCED;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESTART_SERVERS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.STABILITY;
import static org.jboss.as.test.integration.domain.management.util.DomainTestSupport.safeClose;
Expand Down Expand Up @@ -499,15 +501,15 @@ public void reloadAdminOnly(String host, Long timeout) throws IOException, Inter
private void reload(String host, Boolean adminOnly, Boolean restartServers, Boolean waitForServers, Long timeout, Stability stability, String hostConfig, String domainConfig) throws IOException, InterruptedException, TimeoutException {
ModelNode op = new ModelNode();
op.get(ADDRESS).add(HOST, host);
op.get(OP).set("reload");
op.get(OP).set(RELOAD);
if (adminOnly != null) {
op.get(ADMIN_ONLY).set(adminOnly);
}
if (restartServers != null) {
op.get(RESTART_SERVERS).set(restartServers);
}
if (stability != null) {
op.get(OP).set("reload-enhanced");
op.get(OP).set(RELOAD_ENHANCED);
op.get(STABILITY).set(stability.toString());
}
if (hostConfig != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.jboss.as.test.integration.management.util.MgmtOperationException;
import org.jboss.as.version.Stability;
import org.jboss.dmr.ModelNode;
import org.junit.Assert;

public class DomainSnapshot {
/**
Expand Down Expand Up @@ -69,6 +70,9 @@ public static AutoCloseable takeSnapshot(DomainTestSupport testSupport) {
public void close() throws Exception {
for (Snapshot snapshot : snapShots) {
snapshot.lifecycleUtil.reload(snapshot.hostName, snapshot.stability, snapshot.hostConfig, snapshot.domainConfig);
PathAddress hostAddress = PathAddress.pathAddress(HOST, snapshot.hostName);
Stability reloadedStability = getStability(hostAddress, snapshot.lifecycleUtil.getDomainClient());
Assert.assertSame(reloadedStability, snapshot.stability);
}
}
};
Expand All @@ -84,13 +88,18 @@ private static Snapshot takeHostSnapShot(PathAddress hostAddress, DomainLifecycl
String hostConfig = result.asString();
Path relHostConfigPath = findSnapShotRelativePath(hostConfig, configuration);

ModelNode op = Util.getReadAttributeOperation(hostAddress.append(PathAddress.pathAddress(CORE_SERVICE, HOST_ENVIRONMENT)), STABILITY);
result = DomainTestUtils.executeForResult(op, client);
Stability stability = Stability.fromString(result.asString());
Stability stability = getStability(hostAddress, client);

return new Snapshot(relDomainConfigPath, relHostConfigPath.toString(), stability, lifecycleUtil);
}

private static Stability getStability(PathAddress hostAddress, DomainClient client) throws IOException, MgmtOperationException {
ModelNode result;
ModelNode op = Util.getReadAttributeOperation(hostAddress.append(PathAddress.pathAddress(CORE_SERVICE, HOST_ENVIRONMENT)), STABILITY);
result = DomainTestUtils.executeForResult(op, client);
return Stability.fromString(result.asString());
}

private static Path findSnapShotRelativePath(String absPath, WildFlyManagedConfiguration configuration) {
Path primaryConfigDir = Paths.get(configuration.getDomainDirectory()).resolve("configuration");
Path absDomainConfigPath = Paths.get(absPath);
Expand Down

0 comments on commit df96d5c

Please sign in to comment.