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-6972] The standard configuration files used for testsuite/domain should not include community namespaces. #6207

Merged
merged 2 commits into from
Oct 2, 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 @@ -52,14 +52,16 @@ public static void setupDomain() throws Exception {
public void testDomainReadConfigAsXmlFile() throws Exception {
DomainClient domainClient = domainPrimaryLifecycleUtil.getDomainClient();
ModelNode request = new ModelNode();
request.get(OP).set("read-config-as-xml-file");
request.get(OP).set("write-config");
request.get(OP_ADDR).setEmptyList();
domainClient.execute(request);
String expectedXml = loadXMLConfigurationFile( new File(domainPrimaryLifecycleUtil.getConfiguration().getDomainDirectory()).toPath().resolve("configuration").resolve("testing-domain-standard.xml"));

request = new ModelNode();
request.get(OP).set("read-config-as-xml-file");
request.get(OP_ADDR).setEmptyList();
OperationResponse opResponse = domainClient.executeOperation(Operation.Factory.create(request), OperationMessageHandler.DISCARD);
String xml = validateOperationResponse(opResponse);
String expectedXml = loadXMLConfigurationFile(Paths.get(domainPrimaryLifecycleUtil.getConfiguration().getDomainConfigFile()));
Path expected = new File("target", "expected-domain.xml").toPath();
Files.write(expected, Collections.singletonList(expectedXml));
Path result = new File("target", "result-domain.xml").toPath();
Files.write(result, Collections.singletonList(xml));
Assert.assertEquals(expectedXml, xml);
Expand All @@ -69,9 +71,12 @@ public void testDomainReadConfigAsXmlFile() throws Exception {
public void testDomainReadConfigAsXmlFileWithCli() throws Exception {
WildFlyManagedConfiguration config = domainPrimaryLifecycleUtil.getConfiguration();
try (CLIWrapper cli = new CLIWrapper(config.getHostControllerManagementAddress(), config.getHostControllerManagementPort(), true)) {
cli.sendLine(":write-config");

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 expectedXmlPath = Paths.get(domainPrimaryLifecycleUtil.getConfiguration().getDomainDirectory()).resolve("configuration").resolve("testing-domain-standard.xml");
String expectedXml = loadXMLConfigurationFile(expectedXmlPath);
Path expected = new File("target", "expected-domain.xml").toPath();
Files.write(expected, Collections.singletonList(expectedXml));
Assert.assertEquals(expectedXml, Files.readString(result));
Expand All @@ -81,25 +86,37 @@ public void testDomainReadConfigAsXmlFileWithCli() throws Exception {

@Test
public void testHostReadConfigAsXmlFile() throws Exception {

DomainClient domainClient = domainPrimaryLifecycleUtil.getDomainClient();
ModelNode request = new ModelNode();
request.get(OP).set("read-config-as-xml-file");
request.get(OP).set("write-config");
request.get(OP_ADDR).setEmptyList().add(HOST, "primary");
domainClient.execute(request);
Path expectedXmlPath = Paths.get(domainPrimaryLifecycleUtil.getConfiguration().getDomainDirectory()).resolve("configuration").resolve("testing-host-primary.xml");
String expectedXml = loadXMLConfigurationFile(expectedXmlPath);

request = new ModelNode();
request.get(OP).set("read-config-as-xml-file");
request.get(OP_ADDR).setEmptyList().add(HOST, "primary");
OperationResponse opResponse = domainClient.executeOperation(Operation.Factory.create(request), OperationMessageHandler.DISCARD);
String xml = validateOperationResponse(opResponse);
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.xml").toPath();
Files.write(result, Collections.singletonList(xml));
Assert.assertEquals(expectedXml, xml);

request = new ModelNode();
request.get(OP).set("write-config");
request.get(OP_ADDR).setEmptyList().add(HOST, "secondary");
domainClient.execute(request);
expectedXmlPath = Paths.get(domainSecondaryLifecycleUtil.getConfiguration().getDomainDirectory()).resolve("configuration").resolve("testing-host-secondary.xml");
expectedXml = loadXMLConfigurationFile(expectedXmlPath);

request = new ModelNode();
request.get(OP).set("read-config-as-xml-file");
request.get(OP_ADDR).setEmptyList().add(HOST, "secondary");
opResponse = domainClient.executeOperation(Operation.Factory.create(request), OperationMessageHandler.DISCARD);
xml = validateOperationResponse(opResponse);
expectedXml = loadXMLHostConfigurationFile(Paths.get(domainSecondaryLifecycleUtil.getConfiguration().getHostConfigFile()), "secondary");
expected = new File("target", "expected-secondary.xml").toPath();
Files.write(expected, Collections.singletonList(expectedXml));
result = new File("target", "result-secondary.xml").toPath();
Expand All @@ -111,20 +128,20 @@ public void testHostReadConfigAsXmlFile() throws Exception {
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));
cli.sendLine("/host=primary/:write-config");
Path expectedXmlPath = Paths.get(domainPrimaryLifecycleUtil.getConfiguration().getDomainDirectory()).resolve("configuration").resolve("testing-host-primary.xml");
String expectedXml = loadXMLConfigurationFile(expectedXmlPath);
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)) {
cli.sendLine("/host=secondary/:write-config");
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));
Path expectedXmlPath = Paths.get(domainSecondaryLifecycleUtil.getConfiguration().getDomainDirectory()).resolve("configuration").resolve("testing-host-secondary.xml");
String expectedXml = loadXMLConfigurationFile(expectedXmlPath);
Assert.assertEquals(expectedXml, Files.readString(result));
cli.quit();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class ManagementReadXmlTestCase {

@BeforeClass
public static void setupDomain() throws Exception {
DomainTestSuite.stopSupport();
testSupport = DomainTestSuite.createSupport(ManagementReadXmlTestCase.class.getSimpleName());
domainPrimaryLifecycleUtil = testSupport.getDomainPrimaryLifecycleUtil();
domainSecondaryLifecycleUtil = testSupport.getDomainSecondaryLifecycleUtil();
Expand Down Expand Up @@ -150,15 +151,20 @@ private static void prepareExpectedServerConfiguration(String server, boolean pr

@Test
public void testDomainReadConfigAsXml() throws Exception {

DomainClient domainClient = domainPrimaryLifecycleUtil.getDomainClient();
ModelNode request = new ModelNode();
request.get(OP).set("read-config-as-xml");
request.get(OP).set("write-config");
request.get(OP_ADDR).setEmptyList();

DomainClient domainClient = domainPrimaryLifecycleUtil.getDomainClient();
ModelNode response = domainClient.execute(request);
validateResponse(response, true);
Path expectedXmlPath = Paths.get(domainPrimaryLifecycleUtil.getConfiguration().getDomainDirectory()).resolve("configuration").resolve("testing-domain-standard.xml");

request = new ModelNode();
request.get(OP).set("read-config-as-xml");
request.get(OP_ADDR).setEmptyList();
response = domainClient.execute(request);
String xml = validateResponse(response, true).asString().replace('\'', '\"');
String expectedXml = loadXMLConfigurationFile(Paths.get(domainPrimaryLifecycleUtil.getConfiguration().getDomainConfigFile()));
String expectedXml = loadXMLConfigurationFile(expectedXmlPath);
Assert.assertEquals(expectedXml, xml);
}

Expand All @@ -167,18 +173,33 @@ public void testHostReadConfigAsXml() throws Exception {

DomainClient domainClient = domainPrimaryLifecycleUtil.getDomainClient();
ModelNode request = new ModelNode();
request.get(OP).set("read-config-as-xml");
request.get(OP).set("write-config");
request.get(OP_ADDR).setEmptyList().add(HOST, "primary");

ModelNode response = domainClient.execute(request);
validateResponse(response, true);
Path expectedXmlPath = Paths.get(domainPrimaryLifecycleUtil.getConfiguration().getDomainDirectory()).resolve("configuration").resolve("testing-host-primary.xml");

request = new ModelNode();
request.get(OP).set("read-config-as-xml");
request.get(OP_ADDR).setEmptyList().add(HOST, "primary");
response = domainClient.execute(request);
String xml = validateResponse(response, true).asString().replace('\'', '\"');
String expectedXml = loadXMLHostConfigurationFile(Paths.get(domainPrimaryLifecycleUtil.getConfiguration().getHostConfigFile()), "primary");
String expectedXml = loadXMLConfigurationFile(expectedXmlPath);
Assert.assertEquals(expectedXml, xml);

request = new ModelNode();
request.get(OP_ADDR).setEmptyList().add(HOST, "secondary");
request.get(OP).set("write-config");
response = domainClient.execute(request);
validateResponse(response, true);
expectedXmlPath = Paths.get(domainSecondaryLifecycleUtil.getConfiguration().getDomainDirectory()).resolve("configuration").resolve("testing-host-secondary.xml");

request = new ModelNode();
request.get(OP).set("read-config-as-xml");
request.get(OP_ADDR).setEmptyList().add(HOST, "secondary");
response = domainClient.execute(request);
xml = validateResponse(response, true).asString().replace('\'', '\"');
expectedXml = loadXMLHostConfigurationFile(Paths.get(domainSecondaryLifecycleUtil.getConfiguration().getHostConfigFile()), "secondary");
expectedXml = loadXMLConfigurationFile(expectedXmlPath);
Assert.assertEquals(expectedXml, xml);
}

Expand Down Expand Up @@ -231,10 +252,4 @@ protected static String loadXMLConfigurationFile(Path file) throws Exception {
.trim();
}
}

protected static String loadXMLHostConfigurationFile(Path file, String hostName) throws Exception {
return loadXMLConfigurationFile(file)
.replace(hostName + "\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"", hostName + "\"")
.trim();
}
}
2 changes: 1 addition & 1 deletion testsuite/domain/src/test/resources/base-server-config.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<server xmlns="urn:jboss:domain:community:20.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:jboss:domain:community:20.0 wildfly-config_community_20_0.xsd">
<server xmlns="urn:jboss:domain:20.0">
<extensions>
<extension module="org.jboss.as.jmx"/>
<extension module="org.jboss.as.logging"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
~ SPDX-License-Identifier: Apache-2.0
-->

<domain xmlns="urn:jboss:domain:community:20.0">
<domain xmlns="urn:jboss:domain:20.0">

<extensions>
<extension module="org.jboss.as.jmx"/>
Expand Down Expand Up @@ -81,7 +81,7 @@
</root-logger>
</subsystem>
<subsystem xmlns="urn:jboss:domain:core-management:1.0"/>
<subsystem xmlns="urn:wildfly:elytron:community:18.0" final-providers="combined-providers" disallowed-providers="OracleUcrypto">
<subsystem xmlns="urn:wildfly:elytron:18.0" final-providers="combined-providers" disallowed-providers="OracleUcrypto">
<providers>
<aggregate-providers name="combined-providers">
<providers name="elytron"/>
Expand Down Expand Up @@ -219,7 +219,7 @@
</handlers>
</root-logger>
</subsystem>
<subsystem xmlns="urn:wildfly:elytron:community:18.0" final-providers="combined-providers" disallowed-providers="OracleUcrypto">
<subsystem xmlns="urn:wildfly:elytron:18.0" final-providers="combined-providers" disallowed-providers="OracleUcrypto">
<providers>
<aggregate-providers name="combined-providers">
<providers name="elytron"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
~ SPDX-License-Identifier: Apache-2.0
-->

<host xmlns="urn:jboss:domain:community:20.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:domain:community:20.0 wildfly-config_community_20_0.xsd"
<host xmlns="urn:jboss:domain:20.0"
name="primary" organization="core-primary">

<extensions>
Expand Down Expand Up @@ -135,7 +133,7 @@

<profile>
<subsystem xmlns="urn:jboss:domain:core-management:1.0"/>
<subsystem xmlns="urn:wildfly:elytron:community:18.0" final-providers="combined-providers" disallowed-providers="OracleUcrypto">
<subsystem xmlns="urn:wildfly:elytron:18.0" final-providers="combined-providers" disallowed-providers="OracleUcrypto">
<providers>
<aggregate-providers name="combined-providers">
<providers name="elytron"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
~ SPDX-License-Identifier: Apache-2.0
-->

<host xmlns="urn:jboss:domain:community:20.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:domain:community:20.0 wildfly-config_community_20_0.xsd"
name="secondary">
<host xmlns="urn:jboss:domain:20.0" name="secondary">

<extensions>
<extension module="org.jboss.as.jmx"/>
Expand Down Expand Up @@ -116,7 +113,7 @@


<profile>
<subsystem xmlns="urn:wildfly:elytron:community:18.0" final-providers="combined-providers" disallowed-providers="OracleUcrypto">
<subsystem xmlns="urn:wildfly:elytron:18.0" final-providers="combined-providers" disallowed-providers="OracleUcrypto">
<authentication-client>
<!-- corresponding secret: <secret value="c2xhdmVfdXMzcl9wYXNzd29yZA==" /> -->
<authentication-configuration name="secondaryHostAConfiguration" authentication-name="secondary" realm="ManagementRealm" sasl-mechanism-selector="DIGEST-MD5">
Expand Down
Loading