Skip to content

Commit

Permalink
[WFCORE-6750] Use setup tasks to reload the server to the right level
Browse files Browse the repository at this point in the history
  • Loading branch information
kabir committed Mar 20, 2024
1 parent 42a4797 commit 8c9603a
Showing 1 changed file with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -282,6 +282,18 @@ public List<String> 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 {
Expand Down

0 comments on commit 8c9603a

Please sign in to comment.