From 4a3678a69b9c00f98884de2385a4a3ae09b140b2 Mon Sep 17 00:00:00 2001 From: Yeray Borges Date: Mon, 13 May 2024 17:15:07 +0100 Subject: [PATCH] [WFCORE-6815] Verify the domain reloaded to the original stability when the Snapshoft is closed --- .../org/wildfly/test/snapshot/DomainSnapshot.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/testsuite/shared/src/main/java/org/wildfly/test/snapshot/DomainSnapshot.java b/testsuite/shared/src/main/java/org/wildfly/test/snapshot/DomainSnapshot.java index 2ea76461a8d..a69b36acf3f 100644 --- a/testsuite/shared/src/main/java/org/wildfly/test/snapshot/DomainSnapshot.java +++ b/testsuite/shared/src/main/java/org/wildfly/test/snapshot/DomainSnapshot.java @@ -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 { /** @@ -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); } } }; @@ -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);