Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFCORE-6960]: Promote Simple config export for a server as an attachment from COMMUNITY to DEFAULT. #6147

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.UUID;

import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
Expand All @@ -18,7 +19,6 @@
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.descriptions.common.ControllerResolver;
import org.jboss.as.controller.persistence.ConfigurationPersister;
import org.jboss.as.version.Stability;
import org.jboss.dmr.ModelType;

/**
Expand All @@ -36,7 +36,6 @@ public class XmlFileMarshallingHandler extends AbstractXmlMarshallingHandler {
.setReplyParameters(new SimpleAttributeDefinitionBuilder(UUID, ModelType.STRING, false).build())
.setReadOnly()
.setRuntimeOnly()
.setStability(Stability.COMMUNITY)
.build();

public XmlFileMarshallingHandler(final ConfigurationPersister configPersister) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
HostSuspendResumeTestCase.class,
SyncModelOperationTestCase.class,
ManagementReadXmlTestCase.class,
ManagementReadXmlAsFileTestCase.class,
HostReloadProxyTestCase.class,
AuditLogTestCase.class,
ReloadWithConfigTestCase.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/

package org.jboss.as.test.integration.domain.suites;


import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.HOST;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
Expand All @@ -25,47 +23,33 @@
import java.nio.file.Paths;
import java.util.Collections;


import org.apache.commons.io.IOUtils;
import org.jboss.as.controller.client.Operation;
import org.jboss.as.controller.client.OperationMessageHandler;
import org.jboss.as.controller.client.OperationResponse;
import org.jboss.as.controller.client.helpers.domain.DomainClient;
import org.jboss.as.version.Stability;
import org.jboss.as.test.integration.domain.management.util.WildFlyManagedConfiguration;
import org.jboss.as.test.integration.management.util.CLIWrapper;
import org.jboss.dmr.ModelNode;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.wildfly.test.stability.StabilityDomainSetupSnapshotRestoreTasks;

/**
* Test of various read-config-as-xml-file against the domain controller.
*
* @author Emmanuel Hugonnet (c) 2022 Red Hat, Inc.
*/
public class ManagementReadXmlCommunityTestCase extends ManagementReadXmlTestCase{
static StabilityDomainSetupSnapshotRestoreTasks tasks;
public class ManagementReadXmlAsFileTestCase extends ManagementReadXmlTestCase {
ehsavoie marked this conversation as resolved.
Show resolved Hide resolved

@BeforeClass
public static void setupDomain() throws Exception {
testSupport = DomainTestSuite.createSupport(ManagementReadXmlCommunityTestCase.class.getSimpleName());
tasks = new StabilityDomainSetupSnapshotRestoreTasks(Stability.COMMUNITY, testSupport);
tasks.setup();
ManagementReadXmlTestCase.setupDomain();
}

@AfterClass
public static void tearDownDomain() throws Exception {
if (tasks != null) {
tasks.tearDown();
}
ManagementReadXmlTestCase.tearDownDomain();
testSupport = DomainTestSuite.createSupport(ManagementReadXmlAsFileTestCase.class.getSimpleName());
}

@Test
public void testDomainReadConfigAsXmlFile() throws Exception {

DomainClient domainClient = domainPrimaryLifecycleUtil.getDomainClient();
ModelNode request = new ModelNode();
request.get(OP).set("read-config-as-xml-file");
Expand All @@ -81,6 +65,20 @@ public void testDomainReadConfigAsXmlFile() throws Exception {
Assert.assertEquals(expectedXml, xml);
}

@Test
public void testDomainReadConfigAsXmlFileWithCli() throws Exception {
WildFlyManagedConfiguration config = domainPrimaryLifecycleUtil.getConfiguration();
try (CLIWrapper cli = new CLIWrapper(config.getHostControllerManagementAddress(), config.getHostControllerManagementPort(), true)) {
Path result = new File("target", "result-domain-cli.xml").toPath();
cli.sendLine("attachment save --operation=:read-config-as-xml-file --file=" + result.toString());
String expectedXml = loadXMLConfigurationFile(Paths.get(domainPrimaryLifecycleUtil.getConfiguration().getDomainConfigFile()));
Path expected = new File("target", "expected-domain.xml").toPath();
Files.write(expected, Collections.singletonList(expectedXml));
Assert.assertEquals(expectedXml, Files.readString(result));
cli.quit();
}
}

@Test
public void testHostReadConfigAsXmlFile() throws Exception {

Expand Down Expand Up @@ -109,6 +107,29 @@ public void testHostReadConfigAsXmlFile() throws Exception {
Assert.assertEquals(expectedXml, xml);
}

@Test
public void testHostReadConfigAsXmlFileWithCli() throws Exception {
WildFlyManagedConfiguration config = domainPrimaryLifecycleUtil.getConfiguration();
try (CLIWrapper cli = new CLIWrapper(config.getHostControllerManagementAddress(), config.getHostControllerManagementPort(), true)) {
String expectedXml = loadXMLHostConfigurationFile(Paths.get(domainPrimaryLifecycleUtil.getConfiguration().getHostConfigFile()), "primary");
Path expected = new File("target", "expected-primary.xml").toPath();
Files.write(expected, Collections.singletonList(expectedXml));
Path result = new File("target", "result-primary-cli.xml").toPath();
cli.sendLine("attachment save --operation=/host=primary/:read-config-as-xml-file --file=" + result.toString());
Assert.assertEquals(expectedXml, Files.readString(result));
cli.quit();
}
try (CLIWrapper cli = new CLIWrapper(config.getHostControllerManagementAddress(), config.getHostControllerManagementPort(), true)) {
Path result = new File("target", "result-secondary-cli.xml").toPath();
cli.sendLine("attachment save --operation=/host=secondary/:read-config-as-xml-file --file=" + result.toString());
String expectedXml = loadXMLHostConfigurationFile(Paths.get(domainSecondaryLifecycleUtil.getConfiguration().getHostConfigFile()), "secondary");
Path expected = new File("target", "expected-secondary.xml").toPath();
Files.write(expected, Collections.singletonList(expectedXml));
Assert.assertEquals(expectedXml, Files.readString(result));
cli.quit();
}
}

@Test
public void testServerReadConfigAsXmlFile() throws Exception {

Expand Down Expand Up @@ -139,6 +160,26 @@ public void testServerReadConfigAsXmlFile() throws Exception {
Assert.assertEquals(expectedXml, xml);
}

@Test
public void testServerReadConfigAsXmlFileWithCli() throws Exception {
WildFlyManagedConfiguration config = domainPrimaryLifecycleUtil.getConfiguration();
try (CLIWrapper cli = new CLIWrapper(config.getHostControllerManagementAddress(), config.getHostControllerManagementPort(), true)) {
Path result = new File("target", "result-main-one-cli.xml").toPath();
cli.sendLine("attachment save --operation=/host=primary/server=main-one:read-config-as-xml-file --file=" + result.toString());
Path expected = new File("target").toPath().resolve("test-classes").resolve("expected-main-one.xml");
String expectedXml = readFileAsString(expected).replaceAll(System.lineSeparator(), "\n");
Files.write(new File("target", "expected-main-one.xml").toPath(), Collections.singletonList(expectedXml));
Assert.assertEquals(expectedXml, Files.readString(result));

result = new File("target", "result-main-three-cli.xml").toPath();
cli.sendLine("attachment save --operation=/host=secondary/server=main-three:read-config-as-xml-file --file=" + result.toString());
expected = new File("target").toPath().resolve("test-classes").resolve("expected-main-three.xml");
expectedXml = readFileAsString(expected).replaceAll(System.lineSeparator(), "\n");
Files.write(new File("target", "expected-main-one.xml").toPath(), Collections.singletonList(expectedXml));
Assert.assertEquals(expectedXml, Files.readString(result));
}
}

private static String validateOperationResponse(OperationResponse response) throws IOException {
Assert.assertEquals(1, response.getInputStreams().size());
Assert.assertEquals(SUCCESS, response.getResponseNode().require(OUTCOME).asString());
Expand Down
Loading