Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

[WFLY-1324] BZ 961523 Add testing of slave Host Controller join to Default... #4487

Closed
wants to merge 1 commit into from

3 participants

 Brian Stansberry WildFly CI Kabir Khan
 Brian Stansberry
Owner

...ConfigSmokeTestCase

WildFly CI
Collaborator

Triggering build using a merge of 40ae377 on branch master:
Private: http://lightning.mw.lab.eng.bos.redhat.com/jenkins/job/wildfly-param-pull/

WildFly CI
Collaborator

Build 7030 is now running using a merge of 40ae377 on branch master:
Private: http://lightning.mw.lab.eng.bos.redhat.com/jenkins/job/wildfly-param-pull/7030

WildFly CI
Collaborator
Kabir Khan
Owner
kabir commented

Retest this please!

WildFly CI
Collaborator

Triggering build using a merge of 40ae377 on branch master:
Private: http://lightning.mw.lab.eng.bos.redhat.com/jenkins/job/wildfly-param-pull/

WildFly CI
Collaborator

Build 7044 is now running using a merge of 40ae377 on branch master:
Private: http://lightning.mw.lab.eng.bos.redhat.com/jenkins/job/wildfly-param-pull/7044

WildFly CI
Collaborator
Kabir Khan kabir closed this
Kabir Khan
Owner
kabir commented

Merged

 Brian Stansberry bstansberry deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

May 09, 2013
 Brian Stansberry bstansberry WFLY-1324 BZ 961523 Add testing of slave Host Controller join to Defa…
…ultConfigSmokeTestCase
40ae377
This page is out of date. Refresh to see the latest.
168 testsuite/domain/src/test/java/org/jboss/as/test/integration/domain/BuildConfigurationTestBase.java
@@ -22,14 +22,6 @@
22 22
23 23 package org.jboss.as.test.integration.domain;
24 24
25   -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
26   -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
27   -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OUTCOME;
28   -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_RESOURCE_DESCRIPTION_OPERATION;
29   -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RECURSIVE;
30   -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESULT;
31   -import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUCCESS;
32   -
33 25 import java.io.BufferedReader;
34 26 import java.io.BufferedWriter;
35 27 import java.io.Closeable;
@@ -38,78 +30,52 @@
38 30 import java.io.FileReader;
39 31 import java.io.FileWriter;
40 32 import java.io.IOException;
41   -import java.net.URL;
42   -import java.net.URLConnection;
43 33 import java.util.ArrayList;
44 34 import java.util.List;
45 35
46   -import org.junit.Assert;
47   -import org.jboss.as.controller.PathAddress;
48   -import org.jboss.as.controller.PathElement;
49   -import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
50   -import org.jboss.as.controller.registry.AttributeAccess;
51   -import org.jboss.as.test.integration.domain.management.util.DomainLifecycleUtil;
52 36 import org.jboss.as.test.integration.domain.management.util.JBossAsManagedConfiguration;
53 37 import org.jboss.as.test.integration.domain.management.util.JBossAsManagedConfigurationParameters;
54 38 import org.jboss.as.test.shared.TestSuiteEnvironment;
55   -import org.jboss.dmr.ModelNode;
56   -import org.jboss.dmr.Property;
57   -import org.junit.Test;
58 39
59 40 /**
60   - * Test validating the configuration starts and can accept a simple web request.
  41 + * Base class for tests that use the standard AS configuration files.
61 42 *
62 43 * @author Emanuel Muckenhuber
  44 + * @author Brian Stansberry (c) 2013 Red Hat Inc.
63 45 */
64 46 public abstract class BuildConfigurationTestBase {
65 47
66 48 static final String masterAddress = System.getProperty("jboss.test.host.master.address", "localhost");
67   - static final File CONFIG_DIR = new File("target/jbossas/domain/configuration/");
68 49
69   - @Test
70   - public void test() throws Exception {
71   - final JBossAsManagedConfiguration config = createConfiguration(getDomainConfigFile(), getHostConfigFile(), getClass().getSimpleName());
72   - final DomainLifecycleUtil utils = new DomainLifecycleUtil(config);
73   - utils.start(); // Start
74   - try {
75   - URLConnection connection = new URL("http://" + TestSuiteEnvironment.formatPossibleIpv6Address(masterAddress) + ":8080").openConnection();
76   - connection.connect();
  50 + static final File CONFIG_DIR = new File("target/jbossas/domain/configuration/");
77 51
78   - if (Boolean.getBoolean("expression.audit")) {
79   - writeExpressionAudit(utils);
80   - }
81   - } finally {
82   - utils.stop(); // Stop
83   - }
  52 + static JBossAsManagedConfiguration createConfiguration(final String domainXmlName, final String hostXmlName, final String testConfiguration) {
  53 + return createConfiguration(domainXmlName, hostXmlName, testConfiguration, "master", masterAddress, 9999);
84 54 }
85 55
86   - protected abstract String getDomainConfigFile();
87   -
88   - protected abstract String getHostConfigFile();
89   -
90   -
91   - static JBossAsManagedConfiguration createConfiguration(final String domainXmlName, final String hostXmlName, final String testConfiguration) {
92   - final File output = new File("target" + File.separator + "domains" + File.separator + testConfiguration);
  56 + static JBossAsManagedConfiguration createConfiguration(final String domainXmlName, final String hostXmlName,
  57 + final String testConfiguration, final String hostName,
  58 + final String hostAddress, final int hostPort) {
93 59 final JBossAsManagedConfiguration configuration = new JBossAsManagedConfiguration(JBossAsManagedConfigurationParameters.STANDARD);
94 60
95   - configuration.setHostControllerManagementAddress(masterAddress);
96   - configuration.setHostCommandLineProperties("-Djboss.test.host.master.address=" + masterAddress);
97   - configuration.setDomainConfigFile(hackReplaceProperty(new File(CONFIG_DIR, domainXmlName)).getAbsolutePath());
98   - configuration.setHostConfigFile(hackReplaceInterfaces(new File(CONFIG_DIR, hostXmlName)).getAbsolutePath());
  61 + configuration.setHostControllerManagementAddress(hostAddress);
  62 + configuration.setHostControllerManagementPort(hostPort);
  63 + configuration.setHostCommandLineProperties("-Djboss.domain.master.address=" + masterAddress +
  64 + " -Djboss.management.native.port=" + hostPort);
  65 + configuration.setDomainConfigFile(hackFixDomainConfig(new File(CONFIG_DIR, domainXmlName)).getAbsolutePath());
  66 + configuration.setHostConfigFile(hackFixHostConfig(new File(CONFIG_DIR, hostXmlName), hostName, hostAddress).getAbsolutePath());
99 67
100   - configuration.setHostName("master"); // TODO this shouldn't be needed
  68 + configuration.setHostName(hostName); // TODO this shouldn't be needed
101 69
  70 + final File output = new File("target" + File.separator + "domains" + File.separator + testConfiguration + File.separator + hostName);
102 71 new File(output, "configuration").mkdirs(); // TODO this should not be necessary
103 72 configuration.setDomainDirectory(output.getAbsolutePath());
104 73
105   - System.out.println(configuration.getDomainConfigFile());
106   - System.out.println(configuration.getHostConfigFile());
107 74 return configuration;
108 75
109 76 }
110 77
111   - //HACK to make the interfaces settable - I could not do it in xsl since it was replacing the system property
112   - static File hackReplaceInterfaces(File hostConfigFile) {
  78 + private static File hackFixHostConfig(File hostConfigFile, String hostName, String hostAddress) {
113 79 final File file;
114 80 final BufferedWriter writer;
115 81 try {
@@ -124,27 +90,38 @@ static File hackReplaceInterfaces(File hostConfigFile) {
124 90 try {
125 91 String line = reader.readLine();
126 92 while (line != null) {
127   - int start = line.indexOf("<inet-address value=\"");
128   - if (start >= 0) {
  93 + int start = line.indexOf("<host");
  94 + if (start >= 0 && !line.contains(" name=")) {
129 95 StringBuilder sb = new StringBuilder();
130   - sb.append(line.substring(0, start));
131   - sb.append("<inet-address value=\"" + masterAddress + "\"/>");
  96 + sb.append("<host name=\"");
  97 + sb.append(hostName);
  98 + sb.append('"');
  99 + sb.append(line.substring(start + 5));
132 100 writer.write(sb.toString());
133 101 } else {
134   - start = line.indexOf("<option value=\"");
  102 + start = line.indexOf("<inet-address value=\"");
135 103 if (start >= 0) {
136 104 StringBuilder sb = new StringBuilder();
137   - sb.append(line.substring(0, start));
138   - List<String> opts = new ArrayList<String>();
139   - TestSuiteEnvironment.getIpv6Args(opts);
140   - for (String opt : opts) {
141   - sb.append("<option value=\"" + opt + "\"/>");
142   - }
143   -
  105 + sb.append(line.substring(0, start))
  106 + .append("<inet-address value=\"")
  107 + .append(hostAddress)
  108 + .append("\"/>");
144 109 writer.write(sb.toString());
145 110 } else {
146   - start = line.indexOf("java.net.preferIPv4Stack");
147   - if (start < 0) {
  111 + start = line.indexOf("<option value=\"");
  112 + if (start >= 0) {
  113 + StringBuilder sb = new StringBuilder();
  114 + sb.append(line.substring(0, start));
  115 + List<String> opts = new ArrayList<String>();
  116 + TestSuiteEnvironment.getIpv6Args(opts);
  117 + for (String opt : opts) {
  118 + sb.append("<option value=\"")
  119 + .append(opt)
  120 + .append("\"/>");
  121 + }
  122 +
  123 + writer.write(sb.toString());
  124 + } else if (!line.contains("java.net.preferIPv4Stack")){
148 125 writer.write(line);
149 126 }
150 127 }
@@ -164,8 +141,7 @@ static File hackReplaceInterfaces(File hostConfigFile) {
164 141 return file;
165 142 }
166 143
167   - //HACK to make the interfaces settable - I could not do it in xsl since it was replacing the system property
168   - static File hackReplaceProperty(File hostConfigFile) {
  144 + static File hackFixDomainConfig(File hostConfigFile) {
169 145 final File file;
170 146 final BufferedWriter writer;
171 147 try {
@@ -205,62 +181,4 @@ static void safeClose(Closeable c) {
205 181 } catch (Exception ignore) {
206 182 }
207 183 }
208   -
209   - private void writeExpressionAudit(final DomainLifecycleUtil utils) throws IOException {
210   -
211   - final ModelNode operation = new ModelNode();
212   - operation.get(OP).set(READ_RESOURCE_DESCRIPTION_OPERATION);
213   - operation.get(OP_ADDR).setEmptyList();
214   - operation.get(RECURSIVE).set(true);
215   -
216   - final ModelNode result = utils.getDomainClient().execute(operation);
217   - Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
218   - Assert.assertTrue(result.hasDefined(RESULT));
219   -
220   - PathAddress pa = PathAddress.EMPTY_ADDRESS;
221   - writeExpressionAudit(pa, result.get(RESULT));
222   - }
223   -
224   - private static void writeExpressionAudit(PathAddress pa, ModelNode resourceDescription) {
225   - String paString = getPaString(pa);
226   - if (resourceDescription.hasDefined(ModelDescriptionConstants.ATTRIBUTES)) {
227   - for (Property property : resourceDescription.get(ModelDescriptionConstants.ATTRIBUTES).asPropertyList()) {
228   - ModelNode attrdesc = property.getValue();
229   - if (!attrdesc.hasDefined(ModelDescriptionConstants.STORAGE) ||
230   - AttributeAccess.Storage.CONFIGURATION.name().toLowerCase().equals(attrdesc.get(ModelDescriptionConstants.STORAGE).asString().toLowerCase())) {
231   - StringBuilder sb = new StringBuilder(paString);
232   - sb.append(",").append(property.getName());
233   - sb.append(",").append(attrdesc.get(ModelDescriptionConstants.TYPE).asString());
234   - sb.append(",").append(attrdesc.get(ModelDescriptionConstants.EXPRESSIONS_ALLOWED).asBoolean(false));
235   - sb.append(",").append(attrdesc.get(ModelDescriptionConstants.DESCRIPTION).asString());
236   - System.out.println(sb.toString());
237   - }
238   - }
239   - }
240   -
241   - if (resourceDescription.hasDefined(ModelDescriptionConstants.CHILDREN)) {
242   - for (Property childTypeProp : resourceDescription.get(ModelDescriptionConstants.CHILDREN).asPropertyList()) {
243   - String childType = childTypeProp.getName();
244   - ModelNode childTypeDesc = childTypeProp.getValue();
245   - if (childTypeDesc.hasDefined(ModelDescriptionConstants.MODEL_DESCRIPTION)) {
246   - for (Property childInstanceProp : childTypeDesc.get(ModelDescriptionConstants.MODEL_DESCRIPTION).asPropertyList()) {
247   - PathAddress childAddress = pa.append(childType, childInstanceProp.getName());
248   - writeExpressionAudit(childAddress, childInstanceProp.getValue());
249   - }
250   - }
251   - }
252   - }
253   -
254   - }
255   -
256   - private static String getPaString(PathAddress pa) {
257   - if (pa.size() == 0) {
258   - return "/";
259   - }
260   - StringBuilder sb = new StringBuilder();
261   - for (PathElement pe : pa) {
262   - sb.append("/").append(pe.getKey()).append("=").append(pe.getValue());
263   - }
264   - return sb.toString();
265   - }
266 184 }
130 testsuite/domain/src/test/java/org/jboss/as/test/integration/domain/DefaultConfigSmokeTestCase.java
@@ -22,19 +22,135 @@
22 22
23 23 package org.jboss.as.test.integration.domain;
24 24
  25 +import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
  26 +import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
  27 +import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OUTCOME;
  28 +import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_RESOURCE_DESCRIPTION_OPERATION;
  29 +import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RECURSIVE;
  30 +import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESULT;
  31 +import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUCCESS;
  32 +
  33 +import java.io.IOException;
  34 +import java.net.URL;
  35 +import java.net.URLConnection;
  36 +
  37 +import junit.framework.Assert;
  38 +import org.jboss.as.controller.PathAddress;
  39 +import org.jboss.as.controller.PathElement;
  40 +import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
  41 +import org.jboss.as.controller.registry.AttributeAccess;
  42 +import org.jboss.as.test.integration.domain.management.util.DomainLifecycleUtil;
  43 +import org.jboss.as.test.integration.domain.management.util.JBossAsManagedConfiguration;
  44 +import org.jboss.as.test.shared.TestSuiteEnvironment;
  45 +import org.jboss.dmr.ModelNode;
  46 +import org.jboss.dmr.Property;
  47 +import org.junit.Test;
  48 +
25 49 /**
26 50 * Ensures the default domain.xml and host.xml start.
27 51 *
28   - * @author Brian Stansberry (c) 2011 Red Hat Inc.
  52 + * @author Brian Stansberry (c) 2013 Red Hat Inc.
29 53 */
30 54 public class DefaultConfigSmokeTestCase extends BuildConfigurationTestBase {
31   - @Override
32   - protected String getDomainConfigFile() {
33   - return "domain.xml";
  55 +
  56 +
  57 + public static final String slaveAddress = System.getProperty("jboss.test.host.slave.address", "127.0.0.1");
  58 +
  59 + @Test
  60 + public void testStandardHost() throws Exception {
  61 + final JBossAsManagedConfiguration config = createConfiguration("domain.xml", "host.xml", getClass().getSimpleName());
  62 + final DomainLifecycleUtil utils = new DomainLifecycleUtil(config);
  63 + try {
  64 + utils.start();
  65 + // Double-check server status by confirming server-one can accept a web request to the root
  66 + URLConnection connection = new URL("http://" + TestSuiteEnvironment.formatPossibleIpv6Address(masterAddress) + ":8080").openConnection();
  67 + connection.connect();
  68 +
  69 + if (Boolean.getBoolean("expression.audit")) {
  70 + writeExpressionAudit(utils);
  71 + }
  72 + } finally {
  73 + utils.stop(); // Stop
  74 + }
  75 + }
  76 +
  77 + @Test
  78 + public void testMasterAndSlave() throws Exception {
  79 + final JBossAsManagedConfiguration masterConfig = createConfiguration("domain.xml", "host-master.xml", getClass().getSimpleName());
  80 + final DomainLifecycleUtil masterUtils = new DomainLifecycleUtil(masterConfig);
  81 + final JBossAsManagedConfiguration slaveConfig = createConfiguration("domain.xml", "host-slave.xml", getClass().getSimpleName(),
  82 + "slave", slaveAddress, 19999);
  83 + final DomainLifecycleUtil slaveUtils = new DomainLifecycleUtil(slaveConfig);
  84 + try {
  85 + masterUtils.start();
  86 + slaveUtils.start();
  87 + // Double-check server status by confirming server-one can accept a web request to the root
  88 + URLConnection connection = new URL("http://" + TestSuiteEnvironment.formatPossibleIpv6Address(slaveAddress) + ":8080").openConnection();
  89 + connection.connect();
  90 + } finally {
  91 + try {
  92 + slaveUtils.stop();
  93 + } finally {
  94 + masterUtils.stop();
  95 + }
  96 + }
  97 + }
  98 +
  99 + private void writeExpressionAudit(final DomainLifecycleUtil utils) throws IOException {
  100 +
  101 + final ModelNode operation = new ModelNode();
  102 + operation.get(OP).set(READ_RESOURCE_DESCRIPTION_OPERATION);
  103 + operation.get(OP_ADDR).setEmptyList();
  104 + operation.get(RECURSIVE).set(true);
  105 +
  106 + final ModelNode result = utils.getDomainClient().execute(operation);
  107 + Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
  108 + Assert.assertTrue(result.hasDefined(RESULT));
  109 +
  110 + PathAddress pa = PathAddress.EMPTY_ADDRESS;
  111 + writeExpressionAudit(pa, result.get(RESULT));
  112 + }
  113 +
  114 + private static void writeExpressionAudit(PathAddress pa, ModelNode resourceDescription) {
  115 + String paString = getPaString(pa);
  116 + if (resourceDescription.hasDefined(ModelDescriptionConstants.ATTRIBUTES)) {
  117 + for (Property property : resourceDescription.get(ModelDescriptionConstants.ATTRIBUTES).asPropertyList()) {
  118 + ModelNode attrdesc = property.getValue();
  119 + if (!attrdesc.hasDefined(ModelDescriptionConstants.STORAGE) ||
  120 + AttributeAccess.Storage.CONFIGURATION.name().toLowerCase().equals(attrdesc.get(ModelDescriptionConstants.STORAGE).asString().toLowerCase())) {
  121 + StringBuilder sb = new StringBuilder(paString);
  122 + sb.append(",").append(property.getName());
  123 + sb.append(",").append(attrdesc.get(ModelDescriptionConstants.TYPE).asString());
  124 + sb.append(",").append(attrdesc.get(ModelDescriptionConstants.EXPRESSIONS_ALLOWED).asBoolean(false));
  125 + sb.append(",").append(attrdesc.get(ModelDescriptionConstants.DESCRIPTION).asString());
  126 + System.out.println(sb.toString());
  127 + }
  128 + }
  129 + }
  130 +
  131 + if (resourceDescription.hasDefined(ModelDescriptionConstants.CHILDREN)) {
  132 + for (Property childTypeProp : resourceDescription.get(ModelDescriptionConstants.CHILDREN).asPropertyList()) {
  133 + String childType = childTypeProp.getName();
  134 + ModelNode childTypeDesc = childTypeProp.getValue();
  135 + if (childTypeDesc.hasDefined(ModelDescriptionConstants.MODEL_DESCRIPTION)) {
  136 + for (Property childInstanceProp : childTypeDesc.get(ModelDescriptionConstants.MODEL_DESCRIPTION).asPropertyList()) {
  137 + PathAddress childAddress = pa.append(childType, childInstanceProp.getName());
  138 + writeExpressionAudit(childAddress, childInstanceProp.getValue());
  139 + }
  140 + }
  141 + }
  142 + }
  143 +
34 144 }
35 145
36   - @Override
37   - protected String getHostConfigFile() {
38   - return "host.xml";
  146 + private static String getPaString(PathAddress pa) {
  147 + if (pa.size() == 0) {
  148 + return "/";
  149 + }
  150 + StringBuilder sb = new StringBuilder();
  151 + for (PathElement pe : pa) {
  152 + sb.append("/").append(pe.getKey()).append("=").append(pe.getValue());
  153 + }
  154 + return sb.toString();
39 155 }
40 156 }
12 testsuite/domain/src/test/java/org/jboss/as/test/integration/domain/ExpressionSupportSmokeTestCase.java
@@ -151,19 +151,9 @@ public void test() throws Exception {
151 151 validateExpectedValues(PathAddress.EMPTY_ADDRESS, expectedValues, "master");
152 152 }
153 153
154   - @Override
155   - protected String getDomainConfigFile() {
156   - return "domain.xml";
157   - }
158   -
159   - @Override
160   - protected String getHostConfigFile() {
161   - return "host.xml";
162   - }
163   -
164 154 @Before
165 155 public void setUp() throws IOException {
166   - final JBossAsManagedConfiguration config = createConfiguration(getDomainConfigFile(), getHostConfigFile(), getClass().getSimpleName());
  156 + final JBossAsManagedConfiguration config = createConfiguration("domain.xml", "host.xml", getClass().getSimpleName());
167 157 config.setAdminOnly(true);
168 158
169 159 // Trigger the servers to fail on boot if there are runtime errors

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.