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 Jun 5, 2024
1 parent 5cf08ea commit 4a3678a
Showing 1 changed file with 12 additions and 3 deletions.
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 4a3678a

Please sign in to comment.