From efa4443c8f5fa610aac03e2181cd9d111fddebbf Mon Sep 17 00:00:00 2001 From: Darran Lofthouse Date: Fri, 30 Aug 2024 14:17:31 +0100 Subject: [PATCH 1/2] [WFCORE-6972] The standard configuration files used for testsuite/domain should not include community namespaces. The use of namespaces for lower stability levels should be reserved for stability level specific tests. --- .../src/test/resources/domain-configs/domain-standard.xml | 4 ++-- .../domain/src/test/resources/host-configs/host-primary.xml | 2 +- .../domain/src/test/resources/host-configs/host-secondary.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/testsuite/domain/src/test/resources/domain-configs/domain-standard.xml b/testsuite/domain/src/test/resources/domain-configs/domain-standard.xml index 5e61b7ad500..aaf5e631358 100644 --- a/testsuite/domain/src/test/resources/domain-configs/domain-standard.xml +++ b/testsuite/domain/src/test/resources/domain-configs/domain-standard.xml @@ -81,7 +81,7 @@ - + @@ -219,7 +219,7 @@ - + diff --git a/testsuite/domain/src/test/resources/host-configs/host-primary.xml b/testsuite/domain/src/test/resources/host-configs/host-primary.xml index 71c9c005dc3..746ecea1feb 100644 --- a/testsuite/domain/src/test/resources/host-configs/host-primary.xml +++ b/testsuite/domain/src/test/resources/host-configs/host-primary.xml @@ -135,7 +135,7 @@ - + diff --git a/testsuite/domain/src/test/resources/host-configs/host-secondary.xml b/testsuite/domain/src/test/resources/host-configs/host-secondary.xml index 02c8df4c052..a91c65fab92 100644 --- a/testsuite/domain/src/test/resources/host-configs/host-secondary.xml +++ b/testsuite/domain/src/test/resources/host-configs/host-secondary.xml @@ -116,7 +116,7 @@ - + From 7b82390c0a903e65b1ed69f39165d38cb55baa75 Mon Sep 17 00:00:00 2001 From: Emmanuel Hugonnet Date: Tue, 1 Oct 2024 17:35:35 +0200 Subject: [PATCH 2/2] [WFCORE-6972]: Fixing the tests to support community schemas Signed-off-by: Emmanuel Hugonnet --- .../ManagementReadXmlAsFileTestCase.java | 47 +++++++++++++------ .../suites/ManagementReadXmlTestCase.java | 45 ++++++++++++------ .../src/test/resources/base-server-config.xml | 2 +- .../domain-configs/domain-standard.xml | 2 +- .../resources/host-configs/host-primary.xml | 4 +- .../resources/host-configs/host-secondary.xml | 5 +- 6 files changed, 66 insertions(+), 39 deletions(-) diff --git a/testsuite/domain/src/test/java/org/jboss/as/test/integration/domain/suites/ManagementReadXmlAsFileTestCase.java b/testsuite/domain/src/test/java/org/jboss/as/test/integration/domain/suites/ManagementReadXmlAsFileTestCase.java index 660674c56df..a1eca4b28fc 100644 --- a/testsuite/domain/src/test/java/org/jboss/as/test/integration/domain/suites/ManagementReadXmlAsFileTestCase.java +++ b/testsuite/domain/src/test/java/org/jboss/as/test/integration/domain/suites/ManagementReadXmlAsFileTestCase.java @@ -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); @@ -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)); @@ -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(); @@ -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(); } diff --git a/testsuite/domain/src/test/java/org/jboss/as/test/integration/domain/suites/ManagementReadXmlTestCase.java b/testsuite/domain/src/test/java/org/jboss/as/test/integration/domain/suites/ManagementReadXmlTestCase.java index 7cca5945d92..61a97ca1ca0 100644 --- a/testsuite/domain/src/test/java/org/jboss/as/test/integration/domain/suites/ManagementReadXmlTestCase.java +++ b/testsuite/domain/src/test/java/org/jboss/as/test/integration/domain/suites/ManagementReadXmlTestCase.java @@ -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(); @@ -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); } @@ -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); } @@ -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(); - } } diff --git a/testsuite/domain/src/test/resources/base-server-config.xml b/testsuite/domain/src/test/resources/base-server-config.xml index 11a3ef525d9..92e5c488d0f 100644 --- a/testsuite/domain/src/test/resources/base-server-config.xml +++ b/testsuite/domain/src/test/resources/base-server-config.xml @@ -1,6 +1,6 @@ - + diff --git a/testsuite/domain/src/test/resources/domain-configs/domain-standard.xml b/testsuite/domain/src/test/resources/domain-configs/domain-standard.xml index aaf5e631358..a125e5ea97d 100644 --- a/testsuite/domain/src/test/resources/domain-configs/domain-standard.xml +++ b/testsuite/domain/src/test/resources/domain-configs/domain-standard.xml @@ -4,7 +4,7 @@ ~ SPDX-License-Identifier: Apache-2.0 --> - + diff --git a/testsuite/domain/src/test/resources/host-configs/host-primary.xml b/testsuite/domain/src/test/resources/host-configs/host-primary.xml index 746ecea1feb..ca7fc58af4a 100644 --- a/testsuite/domain/src/test/resources/host-configs/host-primary.xml +++ b/testsuite/domain/src/test/resources/host-configs/host-primary.xml @@ -4,9 +4,7 @@ ~ SPDX-License-Identifier: Apache-2.0 --> - diff --git a/testsuite/domain/src/test/resources/host-configs/host-secondary.xml b/testsuite/domain/src/test/resources/host-configs/host-secondary.xml index a91c65fab92..2fb7e1da186 100644 --- a/testsuite/domain/src/test/resources/host-configs/host-secondary.xml +++ b/testsuite/domain/src/test/resources/host-configs/host-secondary.xml @@ -4,10 +4,7 @@ ~ SPDX-License-Identifier: Apache-2.0 --> - +