From 8c9603a7ec45eec9d74155202e1fc4b2007d41bd Mon Sep 17 00:00:00 2001 From: Kabir Khan Date: Thu, 14 Mar 2024 17:26:37 +0000 Subject: [PATCH] [WFCORE-6750] Use setup tasks to reload the server to the right level --- .../UnstableApiAnnotationScannerTestCase.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/testsuite/unstable-api-annotation/tests/src/test/java/org/wildfly/core/test/unstable/api/annotation/reporter/UnstableApiAnnotationScannerTestCase.java b/testsuite/unstable-api-annotation/tests/src/test/java/org/wildfly/core/test/unstable/api/annotation/reporter/UnstableApiAnnotationScannerTestCase.java index 64a7c3c6b26..7751582582e 100644 --- a/testsuite/unstable-api-annotation/tests/src/test/java/org/wildfly/core/test/unstable/api/annotation/reporter/UnstableApiAnnotationScannerTestCase.java +++ b/testsuite/unstable-api-annotation/tests/src/test/java/org/wildfly/core/test/unstable/api/annotation/reporter/UnstableApiAnnotationScannerTestCase.java @@ -51,6 +51,7 @@ import org.wildfly.core.testrunner.WildFlyRunner; import org.wildfly.extension.core.management.CoreManagementExtension; import org.wildfly.extension.core.management.UnstableApiAnnotationResourceDefinition; +import org.wildfly.test.stability.StabilityServerSetupSnapshotRestoreTasks; import java.io.InputStream; import java.nio.file.Files; @@ -68,7 +69,7 @@ import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SYSTEM_PROPERTY; @RunWith(WildFlyRunner.class) -@ServerSetup({UnstableApiAnnotationScannerTestCase.SystemPropertyServerSetupTask.class}) +@ServerSetup({UnstableApiAnnotationScannerTestCase.AddUnstableApiAnnotationResourceSetupTask.class, UnstableApiAnnotationScannerTestCase.SystemPropertyServerSetupTask.class}) public class UnstableApiAnnotationScannerTestCase { @Inject @@ -151,10 +152,11 @@ public void testDeploymentError() throws Exception{ PathAddress address = PathAddress.pathAddress(CoreManagementExtension.SUBSYSTEM_PATH) .append(UnstableApiAnnotationResourceDefinition.PATH); - ModelNode addOp = Util.createAddOperation(address, Collections.singletonMap("fail-on-error", new ModelNode(true))); - addOp.get(UnstableApiAnnotationResourceDefinition.LEVEL.getName()).set("ERROR"); + ModelNode writeAttributeOp = Util.getWriteAttributeOperation(address, + UnstableApiAnnotationResourceDefinition.LEVEL.getName(), + UnstableApiAnnotationResourceDefinition.UnstableApiAnnotationLevel.ERROR.toString()); try { - ManagementOperations.executeOperation(mcc, addOp); + ManagementOperations.executeOperation(mcc, writeAttributeOp); ServerReload.executeReloadAndWaitForCompletion(mcc, false); boolean deployed = false; @@ -176,12 +178,10 @@ public void testDeploymentError() throws Exception{ } finally { - ManagementOperations.executeOperation(mcc, Util.createRemoveOperation(address)); + ManagementOperations.executeOperation(mcc, Util.getUndefineAttributeOperation(address, UnstableApiAnnotationResourceDefinition.LEVEL.getName())); ServerReload.executeReloadAndWaitForCompletion(mcc, false); } - - LogDiffer logDiffer = new LogDiffer(); logDiffer.takeSnapshot(); // Deploy a deployment with unstable annotations @@ -282,6 +282,18 @@ public List getNewLogEntries() { } + public static class AddUnstableApiAnnotationResourceSetupTask extends StabilityServerSetupSnapshotRestoreTasks.Preview { + @Override + public void doSetup(ManagementClient managementClient) throws Exception { + PathAddress address = PathAddress.pathAddress(CoreManagementExtension.SUBSYSTEM_PATH) + .append(UnstableApiAnnotationResourceDefinition.PATH); + ModelNode addOp = Util.createAddOperation(address); + ManagementOperations.executeOperation(managementClient.getControllerClient(), addOp); + ServerReload.executeReloadAndWaitForCompletion(managementClient.getControllerClient()); + } + } + + public static class SystemPropertyServerSetupTask implements ServerSetupTask { @Override public void setup(ManagementClient managementClient) throws Exception {