From 3d0c4688f37eaceda7546fb2ea5fcba4059205ed Mon Sep 17 00:00:00 2001 From: Duncan Grant Date: Thu, 27 Nov 2014 09:34:58 +0000 Subject: [PATCH 01/18] wip --- .../example_yaml/appserver-configured.yaml | 1 + software/webapp/pom.xml | 1 + .../entity/webapp/jboss/WildflyDriver.java | 30 ++ .../entity/webapp/jboss/WildflyServer.java | 104 ++++ .../webapp/jboss/WildflyServerImpl.java | 189 +++++++ .../entity/webapp/jboss/WildflySshDriver.java | 274 ++++++++++ .../entity/webapp/jboss/jboss7-standalone.xml | 2 +- .../webapp/jboss/wildfly-standalone.xml | 492 ++++++++++++++++++ 8 files changed, 1092 insertions(+), 1 deletion(-) create mode 100644 software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyDriver.java create mode 100644 software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServer.java create mode 100644 software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServerImpl.java create mode 100644 software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflySshDriver.java create mode 100644 software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/wildfly-standalone.xml diff --git a/docs/guide/yaml/example_yaml/appserver-configured.yaml b/docs/guide/yaml/example_yaml/appserver-configured.yaml index 04ec858c8a..cd4f10201b 100644 --- a/docs/guide/yaml/example_yaml/appserver-configured.yaml +++ b/docs/guide/yaml/example_yaml/appserver-configured.yaml @@ -1,4 +1,5 @@ name: appserver-configured +location: localhost services: - type: brooklyn.entity.webapp.jboss.JBoss7Server war: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war diff --git a/software/webapp/pom.xml b/software/webapp/pom.xml index 08598144ad..605f97ebce 100644 --- a/software/webapp/pom.xml +++ b/software/webapp/pom.xml @@ -47,6 +47,7 @@ perspective of the Brooklyn/Apache contribution. --> src/main/resources/brooklyn/entity/webapp/jboss/jboss7-standalone.xml + src/main/resources/brooklyn/entity/webapp/jboss/wildfly-standalone.xml src/main/resources/brooklyn/entity/webapp/jetty/jetty-brooklyn.xml diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyDriver.java new file mode 100644 index 0000000000..ad9bbe374b --- /dev/null +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyDriver.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package brooklyn.entity.webapp.jboss; + +import brooklyn.entity.webapp.JavaWebAppDriver; + +public interface WildflyDriver extends JavaWebAppDriver{ + + /** + * The path to the keystore file on the AS7 server machine. + * Result is undefined if SSL is not enabled/configured. + */ + public String getSslKeystoreFile(); +} diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServer.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServer.java new file mode 100644 index 0000000000..8cc4b029d1 --- /dev/null +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServer.java @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package brooklyn.entity.webapp.jboss; + +import brooklyn.catalog.Catalog; +import brooklyn.config.ConfigKey; +import brooklyn.entity.basic.ConfigKeys; +import brooklyn.entity.basic.SoftwareProcess; +import brooklyn.entity.proxying.ImplementedBy; +import brooklyn.entity.trait.HasShortName; +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess; +import brooklyn.event.AttributeSensor; +import brooklyn.event.basic.BasicAttributeSensorAndConfigKey; +import brooklyn.event.basic.BasicAttributeSensorAndConfigKey.StringAttributeSensorAndConfigKey; +import brooklyn.event.basic.PortAttributeSensorAndConfigKey; +import brooklyn.event.basic.Sensors; +import brooklyn.util.flags.SetFromFlag; +import brooklyn.util.javalang.JavaClassNames; + +@Catalog(name="Wildfly Application Server", description="Wildfly: an open source Java application server from JBoss", iconUrl="classpath:///jboss-logo.png") +@ImplementedBy(WildflyServerImpl.class) +public interface WildflyServer extends JavaWebAppSoftwareProcess, HasShortName { + + @SetFromFlag("version") + ConfigKey SUGGESTED_VERSION = + ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION, "8.2.0.Final"); + // note: 7.1.2.Final fixes many bugs but is not available for download, + // see https://community.jboss.org/thread/197780 + // 7.2.0.Final should be out during Q3 2012 + + @SetFromFlag("downloadUrl") + BasicAttributeSensorAndConfigKey DOWNLOAD_URL = new StringAttributeSensorAndConfigKey( + SoftwareProcess.DOWNLOAD_URL, "http://download.jboss.org/wildfly/${version}/wildfly-${version}.tar.gz"); + + @SetFromFlag("bindAddress") + BasicAttributeSensorAndConfigKey BIND_ADDRESS = + new StringAttributeSensorAndConfigKey("jboss.bind.address", + "Address of interface JBoss should listen on, defaulting 0.0.0.0 (but could set e.g. to attributeWhenReady(HOSTNAME)", + "0.0.0.0"); + + @SetFromFlag("managementHttpPort") + PortAttributeSensorAndConfigKey MANAGEMENT_HTTP_PORT = + new PortAttributeSensorAndConfigKey("webapp.jboss.managementHttpPort", "Management port", "9990+"); + + @SetFromFlag("managementHttpsPort") + PortAttributeSensorAndConfigKey MANAGEMENT_HTTPS_PORT = + new PortAttributeSensorAndConfigKey("webapp.jboss.managementHttpsPort", "Management port", "9443+"); + + @SetFromFlag("managementNativePort") + PortAttributeSensorAndConfigKey MANAGEMENT_NATIVE_PORT = + new PortAttributeSensorAndConfigKey("webapp.jboss.managementNativePort", "Management native port", "10999+"); + + /** + * Port increments are the standard way to run multiple instances of AS7 on the same machine. + */ + @SetFromFlag("portIncrement") + ConfigKey PORT_INCREMENT = + ConfigKeys.newConfigKey("webapp.jboss.portIncrement", "Port increment for all ports in config file", 0); + + @SetFromFlag("deploymentTimeout") + ConfigKey DEPLOYMENT_TIMEOUT = + ConfigKeys.newConfigKey("webapp.jboss.deploymentTimeout", "Deployment timeout, in seconds", 600); + + ConfigKey TEMPLATE_CONFIGURATION_URL = ConfigKeys.newConfigKey( + "webapp.jboss.templateConfigurationUrl", "Template file (in freemarker format) for the standalone.xml file", + JavaClassNames.resolveClasspathUrl(WildflyServer.class, "wildfly-standalone.xml")); + + @SetFromFlag("managementUser") + ConfigKey MANAGEMENT_USER = ConfigKeys.newConfigKey("webapp.jboss.managementUser", + "A user to be placed in the management realm. Brooklyn will use this user to poll sensors", + "brooklyn"); + + @SetFromFlag("managementPassword") + ConfigKey MANAGEMENT_PASSWORD = + ConfigKeys.newStringConfigKey("webapp.jboss.managementPassword", "Password for MANAGEMENT_USER."); + + AttributeSensor MANAGEMENT_URL = + Sensors.newStringSensor("webapp.jboss.managementUrl", "URL where management endpoint is available"); + + AttributeSensor MANAGEMENT_STATUS = + Sensors.newIntegerSensor("webapp.jboss.managementStatus", "HTTP response code for the management server"); + + AttributeSensor MANAGEMENT_URL_UP = + Sensors.newBooleanSensor("webapp.jboss.managementUp", "Management server is responding with OK"); + + public static final AttributeSensor PID_FILE = Sensors.newStringSensor( "jboss.pid.file", "PID file"); + +} diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServerImpl.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServerImpl.java new file mode 100644 index 0000000000..6793a2a506 --- /dev/null +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServerImpl.java @@ -0,0 +1,189 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package brooklyn.entity.webapp.jboss; + +import brooklyn.config.render.RendererHints; +import brooklyn.enricher.Enrichers; +import brooklyn.entity.Entity; +import brooklyn.entity.basic.Attributes; +import brooklyn.entity.webapp.JavaWebAppSoftwareProcessImpl; +import brooklyn.event.feed.http.HttpFeed; +import brooklyn.event.feed.http.HttpPollConfig; +import brooklyn.event.feed.http.HttpValueFunctions; +import brooklyn.location.access.BrooklynAccessUtils; +import brooklyn.util.guava.Functionals; +import com.google.common.base.Functions; +import com.google.common.collect.ImmutableMap; +import com.google.common.net.HostAndPort; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Map; + +public class WildflyServerImpl extends JavaWebAppSoftwareProcessImpl implements WildflyServer { + + public static final Logger log = LoggerFactory.getLogger(WildflyServerImpl.class); + + private volatile HttpFeed httpFeed; + + public WildflyServerImpl(){ + super(); + } + + public WildflyServerImpl(@SuppressWarnings("rawtypes") Map flags){ + this(flags, null); + } + + public WildflyServerImpl(@SuppressWarnings("rawtypes") Map flags, Entity parent) { + super(flags, parent); + } + + @Override + public Class getDriverInterface() { + return WildflyDriver.class; + } + + @Override + public WildflyDriver getDriver() { + return (WildflyDriver) super.getDriver(); + } + + static { + RendererHints.register(MANAGEMENT_URL, RendererHints.namedActionWithUrl()); + } + + @Override + protected void connectSensors() { + super.connectSensors(); + + HostAndPort hp = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, + getAttribute(MANAGEMENT_HTTP_PORT) + getConfig(PORT_INCREMENT)); + + String managementUri = String.format("http://%s:%s/management/subsystem/web/connector/http/read-resource", + hp.getHostText(), hp.getPort()); + setAttribute(MANAGEMENT_URL, managementUri); + log.debug("JBoss sensors for "+this+" reading from "+managementUri); + Map includeRuntimeUriVars = ImmutableMap.of("include-runtime","true"); + + httpFeed = HttpFeed.builder() + .entity(this) + .period(200) + .baseUri(managementUri) + .credentials(getConfig(MANAGEMENT_USER), getConfig(MANAGEMENT_PASSWORD)) + .poll(new HttpPollConfig(MANAGEMENT_STATUS) + .onSuccess(HttpValueFunctions.responseCode())) + .poll(new HttpPollConfig(MANAGEMENT_URL_UP) + .onSuccess(HttpValueFunctions.responseCodeEquals(200)) + .onFailureOrException(Functions.constant(false))) + .poll(new HttpPollConfig(REQUEST_COUNT) + .vars(includeRuntimeUriVars) + .onSuccess(HttpValueFunctions.jsonContents("requestCount", Integer.class))) + .poll(new HttpPollConfig(ERROR_COUNT) + .vars(includeRuntimeUriVars) + .onSuccess(HttpValueFunctions.jsonContents("errorCount", Integer.class))) + .poll(new HttpPollConfig(TOTAL_PROCESSING_TIME) + .vars(includeRuntimeUriVars) + .onSuccess(HttpValueFunctions.jsonContents("processingTime", Integer.class))) + .poll(new HttpPollConfig(MAX_PROCESSING_TIME) + .vars(includeRuntimeUriVars) + .onSuccess(HttpValueFunctions.jsonContents("maxTime", Integer.class))) + .poll(new HttpPollConfig(BYTES_RECEIVED) + .vars(includeRuntimeUriVars) + // jboss seems to report 0 even if it has received lots of requests; dunno why. + .onSuccess(HttpValueFunctions.jsonContents("bytesReceived", Long.class))) + .poll(new HttpPollConfig(BYTES_SENT) + .vars(includeRuntimeUriVars) + .onSuccess(HttpValueFunctions.jsonContents("bytesSent", Long.class))) + .build(); + + connectServiceUp(); + } + + protected void connectServiceUp() { + connectServiceUpIsRunning(); + + addEnricher(Enrichers.builder().updatingMap(Attributes.SERVICE_NOT_UP_INDICATORS) + .from(MANAGEMENT_URL_UP) + .computing(Functionals.ifNotEquals(true).value("Management URL not reachable") ) + .build()); + } + + protected void disconnectServiceUp() { + disconnectServiceUpIsRunning(); + } + + @Override + protected void disconnectSensors() { + super.disconnectSensors(); + + if (httpFeed != null) httpFeed.stop(); + disconnectServiceUp(); + } + + public int getManagementHttpsPort() { + return getAttribute(MANAGEMENT_HTTPS_PORT); + } + + public int getManagementHttpPort() { + return getAttribute(MANAGEMENT_HTTP_PORT); + } + + public int getManagementNativePort() { + return getAttribute(MANAGEMENT_NATIVE_PORT); + } + + public int getPortOffset() { + return getConfig(PORT_INCREMENT); + } + + public boolean isWelcomeRootEnabled() { + return false; + } + + public String getBindAddress() { + return getConfig(BIND_ADDRESS); + } + + public String getManagementBindAddress() { + return getConfig(BIND_ADDRESS); + } + + public String getUnsecureBindAddress() { + return getConfig(BIND_ADDRESS); + } + + // If empty-string, disables Management security (!) by excluding the security-realm attribute + public String getHttpManagementInterfaceSecurityRealm() { + return ""; + } + + public int getDeploymentTimeoutSecs() { + return getConfig(DEPLOYMENT_TIMEOUT); + } + + /** Path of the keystore file on the AS7 server */ + public String getHttpsSslKeystoreFile() { + return getDriver().getSslKeystoreFile(); + } + + @Override + public String getShortName() { + return "Wildfly8"; + } +} diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflySshDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflySshDriver.java new file mode 100644 index 0000000000..9205d64f0f --- /dev/null +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflySshDriver.java @@ -0,0 +1,274 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package brooklyn.entity.webapp.jboss; + +import brooklyn.entity.basic.Entities; +import brooklyn.entity.basic.SoftwareProcess; +import brooklyn.entity.webapp.JavaWebAppSshDriver; +import brooklyn.location.basic.SshMachineLocation; +import brooklyn.util.collections.MutableList; +import brooklyn.util.collections.MutableMap; +import brooklyn.util.net.Networking; +import brooklyn.util.os.Os; +import brooklyn.util.ssh.BashCommands; +import brooklyn.util.text.Strings; +import com.google.common.base.Charsets; +import com.google.common.base.Preconditions; +import com.google.common.hash.Hashing; +import com.google.common.io.BaseEncoding; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.InputStream; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import static java.lang.String.format; + +public class WildflySshDriver extends JavaWebAppSshDriver implements WildflyDriver { + + private static final Logger LOG = LoggerFactory.getLogger(WildflySshDriver.class); + + // TODO more configurability of config files, java memory, etc + + public static final String SERVER_TYPE = "standalone"; + public static final String CONFIG_FILE = "standalone-brooklyn.xml"; + public static final String KEYSTORE_FILE = ".keystore"; + public static final String MANAGEMENT_REALM = "ManagementRealm"; + + public WildflySshDriver(WildflyServerImpl entity, SshMachineLocation machine) { + super(entity, machine); + } + + @Override + public WildflyServerImpl getEntity() { + return (WildflyServerImpl) super.getEntity(); + } + + @Override + public String getSslKeystoreFile() { + return Os.mergePathsUnix(getRunDir(), SERVER_TYPE, "configuration", KEYSTORE_FILE); + } + + protected String getTemplateConfigurationUrl() { + return entity.getConfig(WildflyServer.TEMPLATE_CONFIGURATION_URL); + } + + @Override + protected String getLogFileLocation() { + return Os.mergePathsUnix(getRunDir(), SERVER_TYPE, "log/server.log"); + } + + @Override + protected String getDeploySubdir() { + return Os.mergePathsUnix(SERVER_TYPE, "deployments"); + } + + private Integer getManagementHttpPort() { + return entity.getAttribute(WildflyServer.MANAGEMENT_HTTP_PORT); + } + + private Integer getManagementHttpsPort() { + return entity.getAttribute(WildflyServer.MANAGEMENT_HTTPS_PORT); + } + + private Integer getManagementNativePort() { + return entity.getAttribute(WildflyServer.MANAGEMENT_NATIVE_PORT); + } + + private String getManagementUsername() { + return entity.getConfig(WildflyServer.MANAGEMENT_USER); + } + + private String getManagementPassword() { + return entity.getConfig(WildflyServer.MANAGEMENT_PASSWORD); + } + + @Override + public void preInstall() { + resolver = Entities.newDownloader(this); + setExpandedInstallDir(Os.mergePaths(getInstallDir(), resolver.getUnpackedDirectoryName(format("wildfly-%s", getVersion())))); + } + + @Override + public void install() { + List urls = resolver.getTargets(); + String saveAs = resolver.getFilename(); + + List commands = new LinkedList(); + commands.addAll(BashCommands.commandsToDownloadUrlsAs(urls, saveAs)); + commands.add(BashCommands.INSTALL_TAR); + commands.add("tar xzfv " + saveAs); + + newScript(INSTALLING) + // don't set vars yet -- it resolves dependencies (e.g. DB) which we don't want until we start + .environmentVariablesReset() + .body.append(commands) + .execute(); + } + + /** + * AS7 config notes and TODOs: + * We're using the http management interface on port managementPort + * We're not using any JMX. + * - AS 7 simply doesn't boot with Sun JMX enabled (https://issues.jboss.org/browse/JBAS-7427) + * - 7.1 onwards uses Remoting 3, which we haven't configured + * - We have generic support for jmxmp, which one could configure + * We're completely disabling security on the management interface. + * - In the future we probably want to use the as7/bin/add-user.sh script using config keys for user and password + * - Or we could create our own security realm and use that. + * We disable the root welcome page, since we can't deploy our own root otherwise + * We bind all interfaces to entity.hostname, rather than 127.0.0.1. + */ + @Override + public void customize() { + // Check that a password was set for the management user + Preconditions.checkState(Strings.isNonBlank(getManagementUsername()), "User for management realm required"); + String managementPassword = getManagementPassword(); + if (Strings.isBlank(managementPassword)) { + LOG.debug(this+" has no password specified for "+WildflyServer.MANAGEMENT_PASSWORD.getName()+"; using a random string"); + entity.setConfig(WildflyServer.MANAGEMENT_PASSWORD, Strings.makeRandomId(8)); + } + String hashedPassword = hashPassword(getManagementUsername(), getManagementPassword(), MANAGEMENT_REALM); + + // Check that ports are all configured + Map ports = MutableMap.builder() + .put("managementHttpPort", getManagementHttpPort()) + .put("managementHttpsPort", getManagementHttpsPort()) + .put("managementNativePort", getManagementNativePort()) + .build(); + if (isProtocolEnabled("HTTP")) { + ports.put("httpPort", getHttpPort()); + } + if (isProtocolEnabled("HTTPS")) { + ports.put("httpsPort", getHttpsPort()); + } + Networking.checkPortsValid(ports); + + // Check hostname is defined + String hostname = entity.getAttribute(SoftwareProcess.HOSTNAME); + Preconditions.checkNotNull(hostname, "AS 7 entity must set hostname otherwise server will only be visible on localhost"); + + // Copy the install files to the run-dir and add the management user + newScript(CUSTOMIZING) + // don't set vars yet -- it resolves dependencies (e.g. DB) which we don't want until we start + .environmentVariablesReset() + .body.append( + format("cp -r %s/%s . || exit $!", getExpandedInstallDir(), SERVER_TYPE), + format("echo -e '\n%s=%s' >> %s/%s/configuration/mgmt-users.properties", + getManagementUsername(), hashedPassword, getRunDir(), SERVER_TYPE) + ) + .execute(); + + // Copy the keystore across, if there is one + if (isProtocolEnabled("HTTPS")) { + String keystoreUrl = Preconditions.checkNotNull(getSslKeystoreUrl(), "keystore URL must be specified if using HTTPS for "+entity); + String destinationSslKeystoreFile = getSslKeystoreFile(); + InputStream keystoreStream = resource.getResourceFromUrl(keystoreUrl); + getMachine().copyTo(keystoreStream, destinationSslKeystoreFile); + } + + // Copy the configuration file across + String destinationConfigFile = Os.mergePathsUnix(getRunDir(), SERVER_TYPE, "configuration", CONFIG_FILE); + copyTemplate(getTemplateConfigurationUrl(), destinationConfigFile); + + // Copy the initial wars to the deploys directory + getEntity().deployInitialWars(); + } + + @Override + public void launch() { + entity.setAttribute(WildflyServer.PID_FILE, Os.mergePathsUnix(getRunDir(), PID_FILENAME)); + + // We wait for evidence of JBoss running because, using + // brooklyn.ssh.config.tool.class=brooklyn.util.internal.ssh.cli.SshCliTool, + // we saw the ssh session return before the JBoss process was fully running + // so the process failed to start. + newScript(MutableMap.of(USE_PID_FILE, false), LAUNCHING) + .body.append( + "export LAUNCH_JBOSS_IN_BACKGROUND=true", + format("export JBOSS_HOME=%s", getExpandedInstallDir()), + format("export JBOSS_PIDFILE=%s/%s", getRunDir(), PID_FILENAME), + format("%s/bin/%s.sh ", getExpandedInstallDir(), SERVER_TYPE) + + format("--server-config %s ", CONFIG_FILE) + + format("-Djboss.server.base.dir=%s/%s ", getRunDir(), SERVER_TYPE) + + format("\"-Djboss.server.base.url=file://%s/%s\" ", getRunDir(), SERVER_TYPE) + + "-Djava.net.preferIPv4Stack=true " + + "-Djava.net.preferIPv6Addresses=false " + + format(" >> %s/console 2>&1 getCustomJavaConfigOptions() { + return MutableList.builder() + .addAll(super.getCustomJavaConfigOptions()) + .add("-Xms200m") + .add("-Xmx800m") + .add("-XX:MaxPermSize=400m") + .build(); + } + + /** + * Creates a hash of a username, password and security realm that is suitable for use + * with AS7 and Wildfire. + *

+ * Although AS7 has an add-user.sh script it is unsuitable for use in + * non-interactive modes. (See AS7-5061 for details.) Versions 7.1.2+ (EAP) accept + * a --silent flag. When this entity is updated past 7.1.1 we should + * probably use that instead. + *

+ * This method mirrors AS7 and Wildfire's method of hashing user's passwords. Refer + * to its class UsernamePasswordHashUtil.generateHashedURP for their + * implementation. + * + * @see AS7-5061 + * @see + * UsernamePasswordHashUtil.generateHashedURP + * @return HEX(MD5(username ':' realm ':' password)) + */ + public static String hashPassword(String username, String password, String realm) { + String concat = username + ":" + realm + ":" + password; + byte[] hashed = Hashing.md5().hashString(concat, Charsets.UTF_8).asBytes(); + return BaseEncoding.base16().lowerCase().encode(hashed); + } +} diff --git a/software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/jboss7-standalone.xml b/software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/jboss7-standalone.xml index 1e0f6c1a57..947027400a 100644 --- a/software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/jboss7-standalone.xml +++ b/software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/jboss7-standalone.xml @@ -288,7 +288,7 @@ diff --git a/software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/wildfly-standalone.xml b/software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/wildfly-standalone.xml new file mode 100644 index 0000000000..b262ef150b --- /dev/null +++ b/software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/wildfly-standalone.xml @@ -0,0 +1,492 @@ +[#ftl] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE + h2 + + sa + sa + + + + + org.h2.jdbcx.JdbcDataSource + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 102400 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jms.queue.DLQ + jms.queue.ExpiryQueue + 10485760 + 2097152 + 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 51e22e201d9a420d0308b3b78b0ccf6c38de9f80 Mon Sep 17 00:00:00 2001 From: Mike Zaccardo Date: Thu, 30 Apr 2015 12:50:21 -0400 Subject: [PATCH 02/18] Update management URI for undertow and remove requests for unsupported metrics --- .../webapp/jboss/WildflyServerImpl.java | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServerImpl.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServerImpl.java index 6793a2a506..793160af00 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServerImpl.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServerImpl.java @@ -29,7 +29,6 @@ import brooklyn.location.access.BrooklynAccessUtils; import brooklyn.util.guava.Functionals; import com.google.common.base.Functions; -import com.google.common.collect.ImmutableMap; import com.google.common.net.HostAndPort; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,11 +74,12 @@ protected void connectSensors() { HostAndPort hp = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, getAttribute(MANAGEMENT_HTTP_PORT) + getConfig(PORT_INCREMENT)); - String managementUri = String.format("http://%s:%s/management/subsystem/web/connector/http/read-resource", + String managementUri = String.format("http://%s:%s/management/subsystem/undertow/server/default-server/http-listener/default", hp.getHostText(), hp.getPort()); setAttribute(MANAGEMENT_URL, managementUri); log.debug("JBoss sensors for "+this+" reading from "+managementUri); - Map includeRuntimeUriVars = ImmutableMap.of("include-runtime","true"); + +// Map includeRuntimeUriVars = ImmutableMap.of("include-runtime","true"); httpFeed = HttpFeed.builder() .entity(this) @@ -91,25 +91,32 @@ protected void connectSensors() { .poll(new HttpPollConfig(MANAGEMENT_URL_UP) .onSuccess(HttpValueFunctions.responseCodeEquals(200)) .onFailureOrException(Functions.constant(false))) - .poll(new HttpPollConfig(REQUEST_COUNT) - .vars(includeRuntimeUriVars) - .onSuccess(HttpValueFunctions.jsonContents("requestCount", Integer.class))) - .poll(new HttpPollConfig(ERROR_COUNT) - .vars(includeRuntimeUriVars) - .onSuccess(HttpValueFunctions.jsonContents("errorCount", Integer.class))) - .poll(new HttpPollConfig(TOTAL_PROCESSING_TIME) - .vars(includeRuntimeUriVars) - .onSuccess(HttpValueFunctions.jsonContents("processingTime", Integer.class))) - .poll(new HttpPollConfig(MAX_PROCESSING_TIME) - .vars(includeRuntimeUriVars) - .onSuccess(HttpValueFunctions.jsonContents("maxTime", Integer.class))) - .poll(new HttpPollConfig(BYTES_RECEIVED) - .vars(includeRuntimeUriVars) - // jboss seems to report 0 even if it has received lots of requests; dunno why. - .onSuccess(HttpValueFunctions.jsonContents("bytesReceived", Long.class))) - .poll(new HttpPollConfig(BYTES_SENT) - .vars(includeRuntimeUriVars) - .onSuccess(HttpValueFunctions.jsonContents("bytesSent", Long.class))) + /* + * TODO Re-enable these metrics once they are supported by Wildfly. + * + * See: https://issues.jboss.org/browse/WFLY-3835 + */ + +// .poll(new HttpPollConfig(REQUEST_COUNT) +// .vars(includeRuntimeUriVars) +// .onSuccess(HttpValueFunctions.jsonContents("requestCount", Integer.class))) +// .poll(new HttpPollConfig(ERROR_COUNT) +// .vars(includeRuntimeUriVars) +// .onSuccess(HttpValueFunctions.jsonContents("errorCount", Integer.class))) +// .poll(new HttpPollConfig(TOTAL_PROCESSING_TIME) +// .vars(includeRuntimeUriVars) +// .onSuccess(HttpValueFunctions.jsonContents("processingTime", Integer.class))) +// .poll(new HttpPollConfig(MAX_PROCESSING_TIME) +// .vars(includeRuntimeUriVars) +// .onSuccess(HttpValueFunctions.jsonContents("maxTime", Integer.class))) +// .poll(new HttpPollConfig(BYTES_RECEIVED) +// .vars(includeRuntimeUriVars) +// // jboss seems to report 0 even if it has received lots of requests; dunno why. +// .onSuccess(HttpValueFunctions.jsonContents("bytesReceived", Long.class))) +// .poll(new HttpPollConfig(BYTES_SENT) +// .vars(includeRuntimeUriVars) +// .onSuccess(HttpValueFunctions.jsonContents("bytesSent", Long.class))) + .build(); connectServiceUp(); From 128f082a4dde68759429e95a247e483710b8e355 Mon Sep 17 00:00:00 2001 From: Mike Zaccardo Date: Thu, 30 Apr 2015 12:51:40 -0400 Subject: [PATCH 03/18] Enable undertow statistics and remove old web config --- .../webapp/jboss/wildfly-standalone.xml | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/wildfly-standalone.xml b/software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/wildfly-standalone.xml index b262ef150b..01a1341df9 100644 --- a/software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/wildfly-standalone.xml +++ b/software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/wildfly-standalone.xml @@ -413,7 +413,7 @@ - + @@ -433,29 +433,6 @@ - - - - - - - - - - - - - - - - - - - - - - - From d395ef934c07ced191c1f15a58865140df76c341 Mon Sep 17 00:00:00 2001 From: Mike Zaccardo Date: Thu, 30 Apr 2015 13:17:20 -0400 Subject: [PATCH 04/18] Fix class name and remove unused imports --- .../entity/webapp/WebAppLiveIntegrationTest.groovy | 11 +++++++---- .../DynamicWebAppClusterRebindIntegrationTest.java | 4 +--- .../webapp/jboss/JBoss6ServerAwsEc2LiveTest.java | 5 +---- .../JBoss6ServerNonInheritingIntegrationTest.java | 4 +--- .../webapp/jboss/JBoss7ServerAwsEc2LiveTest.java | 5 +---- .../webapp/jboss/JBoss7ServerDockerLiveTest.java | 11 +++++------ ...st.java => JBoss7ServerGoogleComputeLiveTest.java} | 7 ++----- 7 files changed, 18 insertions(+), 29 deletions(-) rename software/webapp/src/test/java/brooklyn/entity/webapp/jboss/{Jboss7ServerGoogleComputeLiveTest.java => JBoss7ServerGoogleComputeLiveTest.java} (95%) diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy b/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy index 6fee1506d8..90f9e6121d 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy @@ -35,13 +35,15 @@ import org.testng.annotations.Test import brooklyn.config.BrooklynProperties import brooklyn.entity.Application -import brooklyn.entity.basic.SoftwareProcess import brooklyn.entity.basic.Entities +import brooklyn.entity.basic.SoftwareProcess import brooklyn.entity.trait.Startable import brooklyn.entity.webapp.jboss.JBoss6Server import brooklyn.entity.webapp.jboss.JBoss6ServerImpl import brooklyn.entity.webapp.jboss.JBoss7Server import brooklyn.entity.webapp.jboss.JBoss7ServerImpl +import brooklyn.entity.webapp.jboss.WildflyServer +import brooklyn.entity.webapp.jboss.WildflyServerImpl import brooklyn.entity.webapp.tomcat.TomcatServer import brooklyn.entity.webapp.tomcat.TomcatServerImpl import brooklyn.location.Location @@ -78,10 +80,11 @@ public class WebAppLiveIntegrationTest { */ @DataProvider(name = "basicEntities") public Object[][] basicEntities() { - TomcatServer tomcat = new TomcatServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT) - JBoss6Server jboss6 = new JBoss6ServerImpl(parent:application, portIncrement:PORT_INCREMENT, jmxPort:DEFAULT_JMX_PORT) +// TomcatServer tomcat = new TomcatServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT) +// JBoss6Server jboss6 = new JBoss6ServerImpl(parent:application, portIncrement:PORT_INCREMENT, jmxPort:DEFAULT_JMX_PORT) JBoss7Server jboss7 = new JBoss7ServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT) - return [ [ tomcat ], [ jboss6 ], [ jboss7 ] ] + WildflyServer wildfly8 = new WildflyServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT) + return [ [ jboss7 ], [ wildfly8 ] ] } private File getResource(String path) { diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/DynamicWebAppClusterRebindIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/DynamicWebAppClusterRebindIntegrationTest.java index c1624d9c15..846a0b14ab 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/DynamicWebAppClusterRebindIntegrationTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/DynamicWebAppClusterRebindIntegrationTest.java @@ -24,13 +24,11 @@ import static org.testng.Assert.assertEquals; import java.io.File; -import java.net.URL; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import brooklyn.test.TestResourceUnavailableException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.AfterMethod; @@ -45,9 +43,9 @@ import brooklyn.entity.webapp.DynamicWebAppCluster; import brooklyn.location.basic.LocalhostMachineProvisioningLocation; import brooklyn.management.internal.LocalManagementContext; +import brooklyn.test.TestResourceUnavailableException; import brooklyn.test.WebAppMonitor; import brooklyn.test.entity.TestApplication; -import brooklyn.util.collections.MutableMap; import com.google.common.base.Predicates; import com.google.common.collect.ImmutableList; diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java index fe53ef4c32..1230d1b1a8 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java @@ -18,12 +18,8 @@ */ package brooklyn.entity.webapp.jboss; -import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertNotNull; -import java.net.URL; - -import brooklyn.test.TestResourceUnavailableException; import org.testng.annotations.Test; import brooklyn.entity.AbstractEc2LiveTest; @@ -31,6 +27,7 @@ import brooklyn.location.Location; import brooklyn.test.Asserts; import brooklyn.test.HttpTestUtils; +import brooklyn.test.TestResourceUnavailableException; import com.google.common.collect.ImmutableList; diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerNonInheritingIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerNonInheritingIntegrationTest.java index c3f5e5e0e0..b21f39a68a 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerNonInheritingIntegrationTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerNonInheritingIntegrationTest.java @@ -21,9 +21,6 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; -import java.net.URL; - -import brooklyn.test.TestResourceUnavailableException; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -33,6 +30,7 @@ import brooklyn.location.basic.LocalhostMachineProvisioningLocation; import brooklyn.test.Asserts; import brooklyn.test.HttpTestUtils; +import brooklyn.test.TestResourceUnavailableException; import com.google.common.collect.ImmutableList; diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerAwsEc2LiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerAwsEc2LiveTest.java index 60db294311..73fb1b5770 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerAwsEc2LiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerAwsEc2LiveTest.java @@ -18,12 +18,8 @@ */ package brooklyn.entity.webapp.jboss; -import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertNotNull; -import java.net.URL; - -import brooklyn.test.TestResourceUnavailableException; import org.testng.annotations.Test; import brooklyn.entity.AbstractEc2LiveTest; @@ -31,6 +27,7 @@ import brooklyn.location.Location; import brooklyn.test.Asserts; import brooklyn.test.HttpTestUtils; +import brooklyn.test.TestResourceUnavailableException; import com.google.common.collect.ImmutableList; diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerDockerLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerDockerLiveTest.java index 69eca5f4f2..eb44475524 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerDockerLiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerDockerLiveTest.java @@ -18,19 +18,18 @@ */ package brooklyn.entity.webapp.jboss; +import static org.testng.Assert.assertNotNull; + +import org.testng.annotations.Test; + import brooklyn.entity.proxying.EntitySpec; import brooklyn.entity.software.AbstractDockerLiveTest; import brooklyn.location.Location; import brooklyn.test.Asserts; import brooklyn.test.HttpTestUtils; import brooklyn.test.TestResourceUnavailableException; -import com.google.common.collect.ImmutableList; -import org.testng.annotations.Test; - -import java.net.URL; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.testng.Assert.assertNotNull; +import com.google.common.collect.ImmutableList; /** * A simple test of installing+running on Docker, using various OS distros and versions. diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Jboss7ServerGoogleComputeLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerGoogleComputeLiveTest.java similarity index 95% rename from software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Jboss7ServerGoogleComputeLiveTest.java rename to software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerGoogleComputeLiveTest.java index e067c59bb9..4963b15f38 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Jboss7ServerGoogleComputeLiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerGoogleComputeLiveTest.java @@ -18,12 +18,8 @@ */ package brooklyn.entity.webapp.jboss; -import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertNotNull; -import java.net.URL; - -import brooklyn.test.TestResourceUnavailableException; import org.testng.annotations.Test; import brooklyn.entity.AbstractGoogleComputeLiveTest; @@ -31,13 +27,14 @@ import brooklyn.location.Location; import brooklyn.test.Asserts; import brooklyn.test.HttpTestUtils; +import brooklyn.test.TestResourceUnavailableException; import com.google.common.collect.ImmutableList; /** * A simple test of installing+running on AWS-EC2, using various OS distros and versions. */ -public class Jboss7ServerGoogleComputeLiveTest extends AbstractGoogleComputeLiveTest { +public class JBoss7ServerGoogleComputeLiveTest extends AbstractGoogleComputeLiveTest { public String getTestWar() { TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war"); From 4ee9e8a050cc8fa0aef538146443fdc8f6df18e7 Mon Sep 17 00:00:00 2001 From: Mike Zaccardo Date: Thu, 30 Apr 2015 13:32:54 -0400 Subject: [PATCH 05/18] Extract password hashing method to parent class and some cleanup --- .../entity/webapp/JavaWebAppSshDriver.java | 27 +++++++++++++++++++ .../entity/webapp/jboss/JBoss7SshDriver.java | 24 ----------------- .../entity/webapp/jboss/WildflyServer.java | 3 --- .../entity/webapp/jboss/WildflySshDriver.java | 24 ----------------- ...est.java => JBossPasswordHashingTest.java} | 18 +++++++------ 5 files changed, 37 insertions(+), 59 deletions(-) rename software/webapp/src/test/java/brooklyn/entity/webapp/jboss/{JBoss7PasswordHashingTest.java => JBossPasswordHashingTest.java} (74%) diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSshDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSshDriver.java index da2af62f52..58dd9498b5 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSshDriver.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSshDriver.java @@ -31,7 +31,10 @@ import brooklyn.util.task.Tasks; import brooklyn.util.task.ssh.SshTasks; +import com.google.common.base.Charsets; import com.google.common.collect.ImmutableList; +import com.google.common.hash.Hashing; +import com.google.common.io.BaseEncoding; public abstract class JavaWebAppSshDriver extends JavaSoftwareProcessSshDriver implements JavaWebAppDriver { @@ -197,4 +200,28 @@ public void undeploy(String targetName) { public FilenameToWebContextMapper getFilenameContextMapper() { return new FilenameToWebContextMapper(); } + + /** + * Creates a hash of a username, password and security realm that is suitable for use + * with AS7 and Wildfly 8. + *

+ * Although AS7 has an add-user.sh script it is unsuitable for use in + * non-interactive modes. (See AS7-5061 for details.) Versions 7.1.2+ (EAP) accept + * a --silent flag. When this entity is updated past 7.1.1 we should + * probably use that instead. + *

+ * This method mirrors AS7 and Wildfly 8's method of hashing user's passwords. Refer + * to its class UsernamePasswordHashUtil.generateHashedURP for their + * implementation. + * + * @see AS7-5061 + * @see + * UsernamePasswordHashUtil.generateHashedURP + * @return HEX(MD5(username ':' realm ':' password)) + */ + public static String hashPassword(String username, String password, String realm) { + String concat = username + ":" + realm + ":" + password; + byte[] hashed = Hashing.md5().hashString(concat, Charsets.UTF_8).asBytes(); + return BaseEncoding.base16().lowerCase().encode(hashed); + } } diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7SshDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7SshDriver.java index 316cf6d3c3..b18649448c 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7SshDriver.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7SshDriver.java @@ -249,28 +249,4 @@ protected List getCustomJavaConfigOptions() { .add("-XX:MaxPermSize=400m") .build(); } - - /** - * Creates a hash of a username, password and security realm that is suitable for use - * with AS7 and Wildfire. - *

- * Although AS7 has an add-user.sh script it is unsuitable for use in - * non-interactive modes. (See AS7-5061 for details.) Versions 7.1.2+ (EAP) accept - * a --silent flag. When this entity is updated past 7.1.1 we should - * probably use that instead. - *

- * This method mirrors AS7 and Wildfire's method of hashing user's passwords. Refer - * to its class UsernamePasswordHashUtil.generateHashedURP for their - * implementation. - * - * @see AS7-5061 - * @see - * UsernamePasswordHashUtil.generateHashedURP - * @return HEX(MD5(username ':' realm ':' password)) - */ - public static String hashPassword(String username, String password, String realm) { - String concat = username + ":" + realm + ":" + password; - byte[] hashed = Hashing.md5().hashString(concat, Charsets.UTF_8).asBytes(); - return BaseEncoding.base16().lowerCase().encode(hashed); - } } diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServer.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServer.java index 8cc4b029d1..4087e7a334 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServer.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServer.java @@ -40,9 +40,6 @@ public interface WildflyServer extends JavaWebAppSoftwareProcess, HasShortName { @SetFromFlag("version") ConfigKey SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION, "8.2.0.Final"); - // note: 7.1.2.Final fixes many bugs but is not available for download, - // see https://community.jboss.org/thread/197780 - // 7.2.0.Final should be out during Q3 2012 @SetFromFlag("downloadUrl") BasicAttributeSensorAndConfigKey DOWNLOAD_URL = new StringAttributeSensorAndConfigKey( diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflySshDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflySshDriver.java index 9205d64f0f..a458af9ac7 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflySshDriver.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflySshDriver.java @@ -247,28 +247,4 @@ protected List getCustomJavaConfigOptions() { .add("-XX:MaxPermSize=400m") .build(); } - - /** - * Creates a hash of a username, password and security realm that is suitable for use - * with AS7 and Wildfire. - *

- * Although AS7 has an add-user.sh script it is unsuitable for use in - * non-interactive modes. (See AS7-5061 for details.) Versions 7.1.2+ (EAP) accept - * a --silent flag. When this entity is updated past 7.1.1 we should - * probably use that instead. - *

- * This method mirrors AS7 and Wildfire's method of hashing user's passwords. Refer - * to its class UsernamePasswordHashUtil.generateHashedURP for their - * implementation. - * - * @see AS7-5061 - * @see - * UsernamePasswordHashUtil.generateHashedURP - * @return HEX(MD5(username ':' realm ':' password)) - */ - public static String hashPassword(String username, String password, String realm) { - String concat = username + ":" + realm + ":" + password; - byte[] hashed = Hashing.md5().hashString(concat, Charsets.UTF_8).asBytes(); - return BaseEncoding.base16().lowerCase().encode(hashed); - } } diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7PasswordHashingTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossPasswordHashingTest.java similarity index 74% rename from software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7PasswordHashingTest.java rename to software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossPasswordHashingTest.java index d77b706f30..94b8fe357a 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7PasswordHashingTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossPasswordHashingTest.java @@ -18,42 +18,44 @@ */ package brooklyn.entity.webapp.jboss; +import static org.testng.Assert.assertEquals; + import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; +import brooklyn.entity.webapp.JavaWebAppSshDriver; /** * Expected values in tests were generated by AS7's add-user.sh script and copied here. */ -public class JBoss7PasswordHashingTest { +public class JBossPasswordHashingTest { @Test public void testPasswordForManagementRealm() { assertEquals( - JBoss7SshDriver.hashPassword("username", "password", "ManagementRealm"), + JavaWebAppSshDriver.hashPassword("username", "password", "ManagementRealm"), "8959126dd54df47f694cd762a51a1a6f"); assertEquals( - JBoss7SshDriver.hashPassword("test", "123", "ManagementRealm"), + JavaWebAppSshDriver.hashPassword("test", "123", "ManagementRealm"), "090d846d31185e54a5e8811a2ccb43ee"); } @Test public void testPasswordForApplicationRealm() { assertEquals( - JBoss7SshDriver.hashPassword("username", "password", "ApplicationRealm"), + JavaWebAppSshDriver.hashPassword("username", "password", "ApplicationRealm"), "888a0504c559a34b1c3e919dcec6d941"); assertEquals( - JBoss7SshDriver.hashPassword("test", "321", "ApplicationRealm"), + JavaWebAppSshDriver.hashPassword("test", "321", "ApplicationRealm"), "a0fdaa45e2d509ac2d390ff6820e2a10"); } @Test public void testPasswordForCustomRealm() { assertEquals( - JBoss7SshDriver.hashPassword("abcdef", "ghijkl", "BrooklynRealm"), + JavaWebAppSshDriver.hashPassword("abcdef", "ghijkl", "BrooklynRealm"), "a65be1ba2eb88b9b9edc6a2a7105af72"); assertEquals( - JBoss7SshDriver.hashPassword("username", "password", "BrooklynRealm"), + JavaWebAppSshDriver.hashPassword("username", "password", "BrooklynRealm"), "161124b73591a1483330f496311b0692"); } From 93ed13600570c2eb58c35c85483d83a65f606c69 Mon Sep 17 00:00:00 2001 From: Mike Zaccardo Date: Thu, 30 Apr 2015 16:56:13 -0400 Subject: [PATCH 06/18] Add Wildfly to WebAppLiveIntegrationTest --- .../brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy b/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy index 90f9e6121d..6b21ad0969 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy @@ -80,11 +80,11 @@ public class WebAppLiveIntegrationTest { */ @DataProvider(name = "basicEntities") public Object[][] basicEntities() { -// TomcatServer tomcat = new TomcatServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT) -// JBoss6Server jboss6 = new JBoss6ServerImpl(parent:application, portIncrement:PORT_INCREMENT, jmxPort:DEFAULT_JMX_PORT) + TomcatServer tomcat = new TomcatServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT) + JBoss6Server jboss6 = new JBoss6ServerImpl(parent:application, portIncrement:PORT_INCREMENT, jmxPort:DEFAULT_JMX_PORT) JBoss7Server jboss7 = new JBoss7ServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT) WildflyServer wildfly8 = new WildflyServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT) - return [ [ jboss7 ], [ wildfly8 ] ] + return [ [ tomcat ], [ jboss6 ], [ jboss7 ], [ wildfly8 ] ] } private File getResource(String path) { From 8f614ca75719c419fbd4675ce48f41f47e2bdbbf Mon Sep 17 00:00:00 2001 From: Mike Zaccardo Date: Thu, 30 Apr 2015 17:45:29 -0400 Subject: [PATCH 07/18] Add Wildfly 8 to multi-version test --- ...ssServersMultiVersionWebAppFixtureIntegrationTest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServersMultiVersionWebAppFixtureIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServersMultiVersionWebAppFixtureIntegrationTest.java index cf576c3b00..30c3cf530d 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServersMultiVersionWebAppFixtureIntegrationTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServersMultiVersionWebAppFixtureIntegrationTest.java @@ -45,10 +45,14 @@ public Object[][] basicEntities() { JBoss7Server jboss7 = jboss7App.createAndManageChild(EntitySpec.create(JBoss7Server.class) .configure(JBoss7Server.HTTP_PORT, PortRanges.fromString(DEFAULT_HTTP_PORT))); + TestApplication wildfly8App = newTestApplication(); + WildflyServer wildfly8 = wildfly8App.createAndManageChild(EntitySpec.create(WildflyServer.class) + .configure(WildflyServer.HTTP_PORT, PortRanges.fromString(DEFAULT_HTTP_PORT))); + return new JavaWebAppSoftwareProcess[][] { new JavaWebAppSoftwareProcess[] {jboss6}, - new JavaWebAppSoftwareProcess[] {jboss7} - + new JavaWebAppSoftwareProcess[] {jboss7}, + new JavaWebAppSoftwareProcess[] {wildfly8} }; } From 25856a86a984ee9bafaf3a1609de8cb2e50fe996 Mon Sep 17 00:00:00 2001 From: Mike Zaccardo Date: Thu, 30 Apr 2015 18:35:01 -0400 Subject: [PATCH 08/18] Rename all Wildfly* resources to Wildfly8* --- ...WildflyDriver.java => Wildfly8Driver.java} | 4 +-- ...WildflyServer.java => Wildfly8Server.java} | 8 +++--- ...erverImpl.java => Wildfly8ServerImpl.java} | 16 +++++------ ...ySshDriver.java => Wildfly8SshDriver.java} | 28 +++++++++---------- ...standalone.xml => wildfly8-standalone.xml} | 0 .../webapp/WebAppLiveIntegrationTest.groovy | 6 ++-- ...tiVersionWebAppFixtureIntegrationTest.java | 4 +-- 7 files changed, 33 insertions(+), 33 deletions(-) rename software/webapp/src/main/java/brooklyn/entity/webapp/jboss/{WildflyDriver.java => Wildfly8Driver.java} (88%) rename software/webapp/src/main/java/brooklyn/entity/webapp/jboss/{WildflyServer.java => Wildfly8Server.java} (92%) rename software/webapp/src/main/java/brooklyn/entity/webapp/jboss/{WildflyServerImpl.java => Wildfly8ServerImpl.java} (93%) rename software/webapp/src/main/java/brooklyn/entity/webapp/jboss/{WildflySshDriver.java => Wildfly8SshDriver.java} (90%) rename software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/{wildfly-standalone.xml => wildfly8-standalone.xml} (100%) diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8Driver.java similarity index 88% rename from software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyDriver.java rename to software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8Driver.java index ad9bbe374b..0b1eb453ba 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyDriver.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8Driver.java @@ -20,10 +20,10 @@ import brooklyn.entity.webapp.JavaWebAppDriver; -public interface WildflyDriver extends JavaWebAppDriver{ +public interface Wildfly8Driver extends JavaWebAppDriver{ /** - * The path to the keystore file on the AS7 server machine. + * The path to the keystore file on the Wildfly 8 server machine. * Result is undefined if SSL is not enabled/configured. */ public String getSslKeystoreFile(); diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServer.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8Server.java similarity index 92% rename from software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServer.java rename to software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8Server.java index 4087e7a334..8186a76759 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServer.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8Server.java @@ -33,9 +33,9 @@ import brooklyn.util.flags.SetFromFlag; import brooklyn.util.javalang.JavaClassNames; -@Catalog(name="Wildfly Application Server", description="Wildfly: an open source Java application server from JBoss", iconUrl="classpath:///jboss-logo.png") -@ImplementedBy(WildflyServerImpl.class) -public interface WildflyServer extends JavaWebAppSoftwareProcess, HasShortName { +@Catalog(name="Wildfly 8 Application Server", description="Wildfly: an open source Java application server from JBoss", iconUrl="classpath:///jboss-logo.png") +@ImplementedBy(Wildfly8ServerImpl.class) +public interface Wildfly8Server extends JavaWebAppSoftwareProcess, HasShortName { @SetFromFlag("version") ConfigKey SUGGESTED_VERSION = @@ -76,7 +76,7 @@ public interface WildflyServer extends JavaWebAppSoftwareProcess, HasShortName { ConfigKey TEMPLATE_CONFIGURATION_URL = ConfigKeys.newConfigKey( "webapp.jboss.templateConfigurationUrl", "Template file (in freemarker format) for the standalone.xml file", - JavaClassNames.resolveClasspathUrl(WildflyServer.class, "wildfly-standalone.xml")); + JavaClassNames.resolveClasspathUrl(Wildfly8Server.class, "wildfly8-standalone.xml")); @SetFromFlag("managementUser") ConfigKey MANAGEMENT_USER = ConfigKeys.newConfigKey("webapp.jboss.managementUser", diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServerImpl.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8ServerImpl.java similarity index 93% rename from software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServerImpl.java rename to software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8ServerImpl.java index 793160af00..d2dee7561f 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflyServerImpl.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8ServerImpl.java @@ -35,32 +35,32 @@ import java.util.Map; -public class WildflyServerImpl extends JavaWebAppSoftwareProcessImpl implements WildflyServer { +public class Wildfly8ServerImpl extends JavaWebAppSoftwareProcessImpl implements Wildfly8Server { - public static final Logger log = LoggerFactory.getLogger(WildflyServerImpl.class); + public static final Logger log = LoggerFactory.getLogger(Wildfly8ServerImpl.class); private volatile HttpFeed httpFeed; - public WildflyServerImpl(){ + public Wildfly8ServerImpl(){ super(); } - public WildflyServerImpl(@SuppressWarnings("rawtypes") Map flags){ + public Wildfly8ServerImpl(@SuppressWarnings("rawtypes") Map flags){ this(flags, null); } - public WildflyServerImpl(@SuppressWarnings("rawtypes") Map flags, Entity parent) { + public Wildfly8ServerImpl(@SuppressWarnings("rawtypes") Map flags, Entity parent) { super(flags, parent); } @Override public Class getDriverInterface() { - return WildflyDriver.class; + return Wildfly8Driver.class; } @Override - public WildflyDriver getDriver() { - return (WildflyDriver) super.getDriver(); + public Wildfly8Driver getDriver() { + return (Wildfly8Driver) super.getDriver(); } static { diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflySshDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8SshDriver.java similarity index 90% rename from software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflySshDriver.java rename to software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8SshDriver.java index a458af9ac7..b55e1b80a6 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/WildflySshDriver.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8SshDriver.java @@ -42,9 +42,9 @@ import static java.lang.String.format; -public class WildflySshDriver extends JavaWebAppSshDriver implements WildflyDriver { +public class Wildfly8SshDriver extends JavaWebAppSshDriver implements Wildfly8Driver { - private static final Logger LOG = LoggerFactory.getLogger(WildflySshDriver.class); + private static final Logger LOG = LoggerFactory.getLogger(Wildfly8SshDriver.class); // TODO more configurability of config files, java memory, etc @@ -53,13 +53,13 @@ public class WildflySshDriver extends JavaWebAppSshDriver implements WildflyDriv public static final String KEYSTORE_FILE = ".keystore"; public static final String MANAGEMENT_REALM = "ManagementRealm"; - public WildflySshDriver(WildflyServerImpl entity, SshMachineLocation machine) { + public Wildfly8SshDriver(Wildfly8ServerImpl entity, SshMachineLocation machine) { super(entity, machine); } @Override - public WildflyServerImpl getEntity() { - return (WildflyServerImpl) super.getEntity(); + public Wildfly8ServerImpl getEntity() { + return (Wildfly8ServerImpl) super.getEntity(); } @Override @@ -68,7 +68,7 @@ public String getSslKeystoreFile() { } protected String getTemplateConfigurationUrl() { - return entity.getConfig(WildflyServer.TEMPLATE_CONFIGURATION_URL); + return entity.getConfig(Wildfly8Server.TEMPLATE_CONFIGURATION_URL); } @Override @@ -82,23 +82,23 @@ protected String getDeploySubdir() { } private Integer getManagementHttpPort() { - return entity.getAttribute(WildflyServer.MANAGEMENT_HTTP_PORT); + return entity.getAttribute(Wildfly8Server.MANAGEMENT_HTTP_PORT); } private Integer getManagementHttpsPort() { - return entity.getAttribute(WildflyServer.MANAGEMENT_HTTPS_PORT); + return entity.getAttribute(Wildfly8Server.MANAGEMENT_HTTPS_PORT); } private Integer getManagementNativePort() { - return entity.getAttribute(WildflyServer.MANAGEMENT_NATIVE_PORT); + return entity.getAttribute(Wildfly8Server.MANAGEMENT_NATIVE_PORT); } private String getManagementUsername() { - return entity.getConfig(WildflyServer.MANAGEMENT_USER); + return entity.getConfig(Wildfly8Server.MANAGEMENT_USER); } private String getManagementPassword() { - return entity.getConfig(WildflyServer.MANAGEMENT_PASSWORD); + return entity.getConfig(Wildfly8Server.MANAGEMENT_PASSWORD); } @Override @@ -143,8 +143,8 @@ public void customize() { Preconditions.checkState(Strings.isNonBlank(getManagementUsername()), "User for management realm required"); String managementPassword = getManagementPassword(); if (Strings.isBlank(managementPassword)) { - LOG.debug(this+" has no password specified for "+WildflyServer.MANAGEMENT_PASSWORD.getName()+"; using a random string"); - entity.setConfig(WildflyServer.MANAGEMENT_PASSWORD, Strings.makeRandomId(8)); + LOG.debug(this+" has no password specified for "+Wildfly8Server.MANAGEMENT_PASSWORD.getName()+"; using a random string"); + entity.setConfig(Wildfly8Server.MANAGEMENT_PASSWORD, Strings.makeRandomId(8)); } String hashedPassword = hashPassword(getManagementUsername(), getManagementPassword(), MANAGEMENT_REALM); @@ -195,7 +195,7 @@ public void customize() { @Override public void launch() { - entity.setAttribute(WildflyServer.PID_FILE, Os.mergePathsUnix(getRunDir(), PID_FILENAME)); + entity.setAttribute(Wildfly8Server.PID_FILE, Os.mergePathsUnix(getRunDir(), PID_FILENAME)); // We wait for evidence of JBoss running because, using // brooklyn.ssh.config.tool.class=brooklyn.util.internal.ssh.cli.SshCliTool, diff --git a/software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/wildfly-standalone.xml b/software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/wildfly8-standalone.xml similarity index 100% rename from software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/wildfly-standalone.xml rename to software/webapp/src/main/resources/brooklyn/entity/webapp/jboss/wildfly8-standalone.xml diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy b/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy index 6b21ad0969..e5adaa6cca 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy @@ -42,8 +42,8 @@ import brooklyn.entity.webapp.jboss.JBoss6Server import brooklyn.entity.webapp.jboss.JBoss6ServerImpl import brooklyn.entity.webapp.jboss.JBoss7Server import brooklyn.entity.webapp.jboss.JBoss7ServerImpl -import brooklyn.entity.webapp.jboss.WildflyServer -import brooklyn.entity.webapp.jboss.WildflyServerImpl +import brooklyn.entity.webapp.jboss.Wildfly8Server +import brooklyn.entity.webapp.jboss.Wildfly8ServerImpl import brooklyn.entity.webapp.tomcat.TomcatServer import brooklyn.entity.webapp.tomcat.TomcatServerImpl import brooklyn.location.Location @@ -83,7 +83,7 @@ public class WebAppLiveIntegrationTest { TomcatServer tomcat = new TomcatServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT) JBoss6Server jboss6 = new JBoss6ServerImpl(parent:application, portIncrement:PORT_INCREMENT, jmxPort:DEFAULT_JMX_PORT) JBoss7Server jboss7 = new JBoss7ServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT) - WildflyServer wildfly8 = new WildflyServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT) + Wildfly8Server wildfly8 = new Wildfly8ServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT, jmxPort:DEFAULT_JMX_PORT) return [ [ tomcat ], [ jboss6 ], [ jboss7 ], [ wildfly8 ] ] } diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServersMultiVersionWebAppFixtureIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServersMultiVersionWebAppFixtureIntegrationTest.java index 30c3cf530d..5a1e8adaed 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServersMultiVersionWebAppFixtureIntegrationTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServersMultiVersionWebAppFixtureIntegrationTest.java @@ -46,8 +46,8 @@ public Object[][] basicEntities() { .configure(JBoss7Server.HTTP_PORT, PortRanges.fromString(DEFAULT_HTTP_PORT))); TestApplication wildfly8App = newTestApplication(); - WildflyServer wildfly8 = wildfly8App.createAndManageChild(EntitySpec.create(WildflyServer.class) - .configure(WildflyServer.HTTP_PORT, PortRanges.fromString(DEFAULT_HTTP_PORT))); + Wildfly8Server wildfly8 = wildfly8App.createAndManageChild(EntitySpec.create(Wildfly8Server.class) + .configure(Wildfly8Server.HTTP_PORT, PortRanges.fromString(DEFAULT_HTTP_PORT))); return new JavaWebAppSoftwareProcess[][] { new JavaWebAppSoftwareProcess[] {jboss6}, From e17c7459a6f68e4933f66192b43dd36ceb5263c7 Mon Sep 17 00:00:00 2001 From: Mike Zaccardo Date: Thu, 30 Apr 2015 19:33:56 -0400 Subject: [PATCH 09/18] Refactor JBoss test structure and add Wildfly 8 test classes --- .../jboss/JBoss6ServerAwsEc2LiveTest.java | 50 ++++---------- .../jboss/JBoss7ServerAwsEc2LiveTest.java | 44 +++--------- .../jboss/JBoss7ServerDockerLiveTest.java | 45 +++--------- .../JBoss7ServerGoogleComputeLiveTest.java | 46 +++---------- .../jboss/JBossServerAwsEc2LiveTest.java | 68 +++++++++++++++++++ .../jboss/JBossServerDockerLiveTest.java | 68 +++++++++++++++++++ .../JBossServerGoogleComputeLiveTest.java | 68 +++++++++++++++++++ .../jboss/Wildfly8ServerAwsEc2LiveTest.java | 49 +++++++++++++ .../jboss/Wildfly8ServerDockerLiveTest.java | 44 ++++++++++++ .../Wildfly8ServerGoogleComputeLiveTest.java | 49 +++++++++++++ 10 files changed, 388 insertions(+), 143 deletions(-) create mode 100644 software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServerAwsEc2LiveTest.java create mode 100644 software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServerDockerLiveTest.java create mode 100644 software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServerGoogleComputeLiveTest.java create mode 100644 software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerAwsEc2LiveTest.java create mode 100644 software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerDockerLiveTest.java create mode 100644 software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerGoogleComputeLiveTest.java diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java index 1230d1b1a8..fb9dfc77d6 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java @@ -18,52 +18,32 @@ */ package brooklyn.entity.webapp.jboss; -import static org.testng.Assert.assertNotNull; - import org.testng.annotations.Test; -import brooklyn.entity.AbstractEc2LiveTest; -import brooklyn.entity.proxying.EntitySpec; +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess; import brooklyn.location.Location; -import brooklyn.test.Asserts; -import brooklyn.test.HttpTestUtils; -import brooklyn.test.TestResourceUnavailableException; - -import com.google.common.collect.ImmutableList; /** - * A simple test of installing+running on AWS-EC2, using various OS distros and versions. + * A simple test of installing+running JBoss AS6 on AWS-EC2, using various OS distros and versions. */ -public class JBoss6ServerAwsEc2LiveTest extends AbstractEc2LiveTest { - - public String getTestWar() { - TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world-no-mapping.war"); - return "classpath://hello-world-no-mapping.war"; - } +public class JBoss6ServerAwsEc2LiveTest extends JBossServerAwsEc2LiveTest { @Override protected void doTest(Location loc) throws Exception { - final JBoss6Server server = app.createAndManageChild(EntitySpec.create(JBoss6Server.class) - .configure("war", getTestWar())); - - app.start(ImmutableList.of(loc)); - - String url = server.getAttribute(JBoss6Server.ROOT_URL); - - HttpTestUtils.assertHttpStatusCodeEventuallyEquals(url, 200); - HttpTestUtils.assertContentContainsText(url, "Hello"); - - Asserts.succeedsEventually(new Runnable() { - @Override public void run() { - assertNotNull(server.getAttribute(JBoss6Server.REQUEST_COUNT)); - assertNotNull(server.getAttribute(JBoss6Server.ERROR_COUNT)); - assertNotNull(server.getAttribute(JBoss6Server.TOTAL_PROCESSING_TIME)); - assertNotNull(server.getAttribute(JBoss6Server.MAX_PROCESSING_TIME)); - assertNotNull(server.getAttribute(JBoss6Server.BYTES_RECEIVED)); - assertNotNull(server.getAttribute(JBoss6Server.BYTES_SENT)); - }}); + super.doTest(loc); } + @Test(groups = {"Live", "Live-sanity"}) + @Override + public void test_CentOS_6_3() throws Exception { + super.test_CentOS_6_3(); + } + @Test(enabled=false) public void testDummy() {} // Convince testng IDE integration that this really does have test methods + + @Override + protected Class getServerType() { + return JBoss6Server.class; + } } diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerAwsEc2LiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerAwsEc2LiveTest.java index 73fb1b5770..827853d9c2 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerAwsEc2LiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerAwsEc2LiveTest.java @@ -18,50 +18,19 @@ */ package brooklyn.entity.webapp.jboss; -import static org.testng.Assert.assertNotNull; - import org.testng.annotations.Test; -import brooklyn.entity.AbstractEc2LiveTest; -import brooklyn.entity.proxying.EntitySpec; +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess; import brooklyn.location.Location; -import brooklyn.test.Asserts; -import brooklyn.test.HttpTestUtils; -import brooklyn.test.TestResourceUnavailableException; - -import com.google.common.collect.ImmutableList; /** - * A simple test of installing+running on AWS-EC2, using various OS distros and versions. + * A simple test of installing+running JBoss AS7 on AWS-EC2, using various OS distros and versions. */ -public class JBoss7ServerAwsEc2LiveTest extends AbstractEc2LiveTest { - - public String getTestWar() { - TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war"); - return "classpath://hello-world.war"; - } +public class JBoss7ServerAwsEc2LiveTest extends JBossServerAwsEc2LiveTest { @Override protected void doTest(Location loc) throws Exception { - final JBoss7Server server = app.createAndManageChild(EntitySpec.create(JBoss7Server.class) - .configure("war", getTestWar())); - - app.start(ImmutableList.of(loc)); - - String url = server.getAttribute(JBoss7Server.ROOT_URL); - - HttpTestUtils.assertHttpStatusCodeEventuallyEquals(url, 200); - HttpTestUtils.assertContentContainsText(url, "Hello"); - - Asserts.succeedsEventually(new Runnable() { - @Override public void run() { - assertNotNull(server.getAttribute(JBoss7Server.REQUEST_COUNT)); - assertNotNull(server.getAttribute(JBoss7Server.ERROR_COUNT)); - assertNotNull(server.getAttribute(JBoss7Server.TOTAL_PROCESSING_TIME)); - assertNotNull(server.getAttribute(JBoss7Server.MAX_PROCESSING_TIME)); - assertNotNull(server.getAttribute(JBoss7Server.BYTES_RECEIVED)); - assertNotNull(server.getAttribute(JBoss7Server.BYTES_SENT)); - }}); + super.doTest(loc); } @Test(groups = {"Live", "Live-sanity"}) @@ -72,4 +41,9 @@ public void test_CentOS_6_3() throws Exception { @Test(enabled=false) public void testDummy() {} // Convince testng IDE integration that this really does have test methods + + @Override + protected Class getServerType() { + return JBoss7Server.class; + } } diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerDockerLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerDockerLiveTest.java index eb44475524..04c2582033 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerDockerLiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerDockerLiveTest.java @@ -18,56 +18,27 @@ */ package brooklyn.entity.webapp.jboss; -import static org.testng.Assert.assertNotNull; - import org.testng.annotations.Test; -import brooklyn.entity.proxying.EntitySpec; -import brooklyn.entity.software.AbstractDockerLiveTest; +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess; import brooklyn.location.Location; -import brooklyn.test.Asserts; -import brooklyn.test.HttpTestUtils; -import brooklyn.test.TestResourceUnavailableException; - -import com.google.common.collect.ImmutableList; /** - * A simple test of installing+running on Docker, using various OS distros and versions. + * A simple test of installing+running JBoss AS7 on Docker, using various OS distros and versions. */ -public class JBoss7ServerDockerLiveTest extends AbstractDockerLiveTest { - - public String getTestWar() { - TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war"); - return "classpath://hello-world.war"; - } +public class JBoss7ServerDockerLiveTest extends JBossServerDockerLiveTest { @Override protected void doTest(Location loc) throws Exception { - final JBoss7Server server = app.createAndManageChild(EntitySpec.create(JBoss7Server.class) - .configure("war", getTestWar())); - - app.start(ImmutableList.of(loc)); - - String url = server.getAttribute(JBoss7Server.ROOT_URL); - - HttpTestUtils.assertHttpStatusCodeEventuallyEquals(url, 200); - HttpTestUtils.assertContentContainsText(url, "Hello"); - - Asserts.succeedsEventually(new Runnable() { - @Override - public void run() { - assertNotNull(server.getAttribute(JBoss7Server.REQUEST_COUNT)); - assertNotNull(server.getAttribute(JBoss7Server.ERROR_COUNT)); - assertNotNull(server.getAttribute(JBoss7Server.TOTAL_PROCESSING_TIME)); - assertNotNull(server.getAttribute(JBoss7Server.MAX_PROCESSING_TIME)); - assertNotNull(server.getAttribute(JBoss7Server.BYTES_RECEIVED)); - assertNotNull(server.getAttribute(JBoss7Server.BYTES_SENT)); - } - }); + super.doTest(loc); } @Test(enabled = false) public void testDummy() { } // Convince testng IDE integration that this really does have test methods + @Override + protected Class getServerType() { + return JBoss7Server.class; + } } diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerGoogleComputeLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerGoogleComputeLiveTest.java index 4963b15f38..8712f0f055 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerGoogleComputeLiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerGoogleComputeLiveTest.java @@ -18,50 +18,19 @@ */ package brooklyn.entity.webapp.jboss; -import static org.testng.Assert.assertNotNull; - import org.testng.annotations.Test; -import brooklyn.entity.AbstractGoogleComputeLiveTest; -import brooklyn.entity.proxying.EntitySpec; +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess; import brooklyn.location.Location; -import brooklyn.test.Asserts; -import brooklyn.test.HttpTestUtils; -import brooklyn.test.TestResourceUnavailableException; - -import com.google.common.collect.ImmutableList; /** - * A simple test of installing+running on AWS-EC2, using various OS distros and versions. + * A simple test of installing+running JBoss AS7 on AWS-EC2, using various OS distros and versions. */ -public class JBoss7ServerGoogleComputeLiveTest extends AbstractGoogleComputeLiveTest { - - public String getTestWar() { - TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war"); - return "classpath://hello-world.war"; - } +public class JBoss7ServerGoogleComputeLiveTest extends JBossServerGoogleComputeLiveTest { @Override protected void doTest(Location loc) throws Exception { - final JBoss7Server server = app.createAndManageChild(EntitySpec.create(JBoss7Server.class) - .configure("war", getTestWar())); - - app.start(ImmutableList.of(loc)); - - String url = server.getAttribute(JBoss7Server.ROOT_URL); - - HttpTestUtils.assertHttpStatusCodeEventuallyEquals(url, 200); - HttpTestUtils.assertContentContainsText(url, "Hello"); - - Asserts.succeedsEventually(new Runnable() { - @Override public void run() { - assertNotNull(server.getAttribute(JBoss7Server.REQUEST_COUNT)); - assertNotNull(server.getAttribute(JBoss7Server.ERROR_COUNT)); - assertNotNull(server.getAttribute(JBoss7Server.TOTAL_PROCESSING_TIME)); - assertNotNull(server.getAttribute(JBoss7Server.MAX_PROCESSING_TIME)); - assertNotNull(server.getAttribute(JBoss7Server.BYTES_RECEIVED)); - assertNotNull(server.getAttribute(JBoss7Server.BYTES_SENT)); - }}); + super.doTest(loc); } @Test(groups = {"Live"}) @@ -71,5 +40,10 @@ public void test_DefaultImage() throws Exception { } @Test(enabled=false) - public void testDummy() {} // Convince testng IDE integration that this really does have test methods + public void testDummy() {} // Convince testng IDE integration that this really does have test methods + + @Override + protected Class getServerType() { + return JBoss7Server.class; + } } diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServerAwsEc2LiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServerAwsEc2LiveTest.java new file mode 100644 index 0000000000..6678506a27 --- /dev/null +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServerAwsEc2LiveTest.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package brooklyn.entity.webapp.jboss; + +import static org.testng.Assert.assertNotNull; +import brooklyn.entity.AbstractEc2LiveTest; +import brooklyn.entity.proxying.EntitySpec; +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess; +import brooklyn.entity.webapp.WebAppServiceConstants; +import brooklyn.entity.webapp.WebAppServiceMetrics; +import brooklyn.location.Location; +import brooklyn.test.Asserts; +import brooklyn.test.HttpTestUtils; +import brooklyn.test.TestResourceUnavailableException; + +import com.google.common.collect.ImmutableList; + +/** + * A simple test of installing+running JBoss type servers on AWS-EC2, using various OS distros and versions. + */ +public abstract class JBossServerAwsEc2LiveTest extends AbstractEc2LiveTest { + + public String getTestWar() { + TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war"); + return "classpath://hello-world.war"; + } + + @Override + protected void doTest(Location loc) throws Exception { + final JavaWebAppSoftwareProcess server = app.createAndManageChild(EntitySpec.create(getServerType()) + .configure("war", getTestWar())); + + app.start(ImmutableList.of(loc)); + + String url = server.getAttribute(WebAppServiceConstants.ROOT_URL); + + HttpTestUtils.assertHttpStatusCodeEventuallyEquals(url, 200); + HttpTestUtils.assertContentContainsText(url, "Hello"); + + Asserts.succeedsEventually(new Runnable() { + @Override public void run() { + assertNotNull(server.getAttribute(WebAppServiceMetrics.REQUEST_COUNT)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.ERROR_COUNT)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.TOTAL_PROCESSING_TIME)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.MAX_PROCESSING_TIME)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.BYTES_RECEIVED)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.BYTES_SENT)); + }}); + } + + protected abstract Class getServerType(); +} diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServerDockerLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServerDockerLiveTest.java new file mode 100644 index 0000000000..8b01844d4a --- /dev/null +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServerDockerLiveTest.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package brooklyn.entity.webapp.jboss; + +import static org.testng.Assert.assertNotNull; +import brooklyn.entity.proxying.EntitySpec; +import brooklyn.entity.software.AbstractDockerLiveTest; +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess; +import brooklyn.entity.webapp.WebAppServiceConstants; +import brooklyn.entity.webapp.WebAppServiceMetrics; +import brooklyn.location.Location; +import brooklyn.test.Asserts; +import brooklyn.test.HttpTestUtils; +import brooklyn.test.TestResourceUnavailableException; + +import com.google.common.collect.ImmutableList; + +/** + * A simple test of installing+running JBoss type servers on Docker, using various OS distros and versions. + */ +public abstract class JBossServerDockerLiveTest extends AbstractDockerLiveTest { + + public String getTestWar() { + TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war"); + return "classpath://hello-world.war"; + } + + @Override + protected void doTest(Location loc) throws Exception { + final JavaWebAppSoftwareProcess server = app.createAndManageChild(EntitySpec.create(getServerType()) + .configure("war", getTestWar())); + + app.start(ImmutableList.of(loc)); + + String url = server.getAttribute(WebAppServiceConstants.ROOT_URL); + + HttpTestUtils.assertHttpStatusCodeEventuallyEquals(url, 200); + HttpTestUtils.assertContentContainsText(url, "Hello"); + + Asserts.succeedsEventually(new Runnable() { + @Override public void run() { + assertNotNull(server.getAttribute(WebAppServiceMetrics.REQUEST_COUNT)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.ERROR_COUNT)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.TOTAL_PROCESSING_TIME)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.MAX_PROCESSING_TIME)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.BYTES_RECEIVED)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.BYTES_SENT)); + }}); + } + + protected abstract Class getServerType(); +} diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServerGoogleComputeLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServerGoogleComputeLiveTest.java new file mode 100644 index 0000000000..9dc0a47492 --- /dev/null +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServerGoogleComputeLiveTest.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package brooklyn.entity.webapp.jboss; + +import static org.testng.Assert.assertNotNull; +import brooklyn.entity.AbstractGoogleComputeLiveTest; +import brooklyn.entity.proxying.EntitySpec; +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess; +import brooklyn.entity.webapp.WebAppServiceConstants; +import brooklyn.entity.webapp.WebAppServiceMetrics; +import brooklyn.location.Location; +import brooklyn.test.Asserts; +import brooklyn.test.HttpTestUtils; +import brooklyn.test.TestResourceUnavailableException; + +import com.google.common.collect.ImmutableList; + +/** + * A simple test of installing+running JBoss type servers on AWS-EC2, using various OS distros and versions. + */ +public abstract class JBossServerGoogleComputeLiveTest extends AbstractGoogleComputeLiveTest { + + public String getTestWar() { + TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war"); + return "classpath://hello-world.war"; + } + + @Override + protected void doTest(Location loc) throws Exception { + final JavaWebAppSoftwareProcess server = app.createAndManageChild(EntitySpec.create(getServerType()) + .configure("war", getTestWar())); + + app.start(ImmutableList.of(loc)); + + String url = server.getAttribute(WebAppServiceConstants.ROOT_URL); + + HttpTestUtils.assertHttpStatusCodeEventuallyEquals(url, 200); + HttpTestUtils.assertContentContainsText(url, "Hello"); + + Asserts.succeedsEventually(new Runnable() { + @Override public void run() { + assertNotNull(server.getAttribute(WebAppServiceMetrics.REQUEST_COUNT)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.ERROR_COUNT)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.TOTAL_PROCESSING_TIME)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.MAX_PROCESSING_TIME)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.BYTES_RECEIVED)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.BYTES_SENT)); + }}); + } + + protected abstract Class getServerType(); +} diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerAwsEc2LiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerAwsEc2LiveTest.java new file mode 100644 index 0000000000..b230c278d9 --- /dev/null +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerAwsEc2LiveTest.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package brooklyn.entity.webapp.jboss; + +import org.testng.annotations.Test; + +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess; +import brooklyn.location.Location; + +/** + * A simple test of installing+running Wildfly 8 on AWS-EC2, using various OS distros and versions. + */ +public class Wildfly8ServerAwsEc2LiveTest extends JBossServerAwsEc2LiveTest { + + @Override + protected void doTest(Location loc) throws Exception { + super.doTest(loc); + } + + @Test(groups = {"Live", "Live-sanity"}) + @Override + public void test_CentOS_6_3() throws Exception { + super.test_CentOS_6_3(); + } + + @Test(enabled=false) + public void testDummy() {} // Convince testng IDE integration that this really does have test methods + + @Override + protected Class getServerType() { + return Wildfly8Server.class; + } +} diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerDockerLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerDockerLiveTest.java new file mode 100644 index 0000000000..bdb502e726 --- /dev/null +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerDockerLiveTest.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package brooklyn.entity.webapp.jboss; + +import org.testng.annotations.Test; + +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess; +import brooklyn.location.Location; + +/** + * A simple test of installing+running Wildfly 8 on Docker, using various OS distros and versions. + */ +public class Wildfly8ServerDockerLiveTest extends JBossServerDockerLiveTest { + + @Override + protected void doTest(Location loc) throws Exception { + super.doTest(loc); + } + + @Test(enabled = false) + public void testDummy() { + } // Convince testng IDE integration that this really does have test methods + + @Override + protected Class getServerType() { + return Wildfly8Server.class; + } +} diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerGoogleComputeLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerGoogleComputeLiveTest.java new file mode 100644 index 0000000000..a3041a3085 --- /dev/null +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerGoogleComputeLiveTest.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package brooklyn.entity.webapp.jboss; + +import org.testng.annotations.Test; + +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess; +import brooklyn.location.Location; + +/** + * A simple test of installing+running Wildfly 8 on AWS-EC2, using various OS distros and versions. + */ +public class Wildfly8ServerGoogleComputeLiveTest extends JBossServerGoogleComputeLiveTest { + + @Override + protected void doTest(Location loc) throws Exception { + super.doTest(loc); + } + + @Test(groups = {"Live"}) + @Override + public void test_DefaultImage() throws Exception { + super.test_DefaultImage(); + } + + @Test(enabled=false) + public void testDummy() {} // Convince testng IDE integration that this really does have test methods + + @Override + protected Class getServerType() { + return Wildfly8Server.class; + } +} From 16933cfe72225604e09dc7ceb4649f415ca8401e Mon Sep 17 00:00:00 2001 From: Mike Zaccardo Date: Fri, 1 May 2015 09:39:53 -0400 Subject: [PATCH 10/18] Remove unused imports --- .../entity/webapp/jboss/JBoss7SshDriver.java | 3 --- .../webapp/jboss/Wildfly8SshDriver.java | 23 +++++++++---------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7SshDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7SshDriver.java index b18649448c..29db1b124d 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7SshDriver.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7SshDriver.java @@ -39,10 +39,7 @@ import brooklyn.util.ssh.BashCommands; import brooklyn.util.text.Strings; -import com.google.common.base.Charsets; import com.google.common.base.Preconditions; -import com.google.common.hash.Hashing; -import com.google.common.io.BaseEncoding; public class JBoss7SshDriver extends JavaWebAppSshDriver implements JBoss7Driver { diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8SshDriver.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8SshDriver.java index b55e1b80a6..1a28ab37c2 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8SshDriver.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8SshDriver.java @@ -18,6 +18,16 @@ */ package brooklyn.entity.webapp.jboss; +import static java.lang.String.format; + +import java.io.InputStream; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import brooklyn.entity.basic.Entities; import brooklyn.entity.basic.SoftwareProcess; import brooklyn.entity.webapp.JavaWebAppSshDriver; @@ -28,19 +38,8 @@ import brooklyn.util.os.Os; import brooklyn.util.ssh.BashCommands; import brooklyn.util.text.Strings; -import com.google.common.base.Charsets; -import com.google.common.base.Preconditions; -import com.google.common.hash.Hashing; -import com.google.common.io.BaseEncoding; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.InputStream; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import static java.lang.String.format; +import com.google.common.base.Preconditions; public class Wildfly8SshDriver extends JavaWebAppSshDriver implements Wildfly8Driver { From 3a7ab3bf63c65648c00fc3e2d2e0435bbcb48462 Mon Sep 17 00:00:00 2001 From: Mike Zaccardo Date: Fri, 1 May 2015 12:04:44 -0400 Subject: [PATCH 11/18] Update rat check ignore for renamed file --- software/webapp/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/webapp/pom.xml b/software/webapp/pom.xml index 605f97ebce..55776d6079 100644 --- a/software/webapp/pom.xml +++ b/software/webapp/pom.xml @@ -47,7 +47,7 @@ perspective of the Brooklyn/Apache contribution. --> src/main/resources/brooklyn/entity/webapp/jboss/jboss7-standalone.xml - src/main/resources/brooklyn/entity/webapp/jboss/wildfly-standalone.xml + src/main/resources/brooklyn/entity/webapp/jboss/wildfly8-standalone.xml src/main/resources/brooklyn/entity/webapp/jetty/jetty-brooklyn.xml From 0eb1708cf7f535acb05fd03cebeb242901593f2a Mon Sep 17 00:00:00 2001 From: Mike Zaccardo Date: Fri, 1 May 2015 16:17:41 -0400 Subject: [PATCH 12/18] Add SoftLayer tests for JBoss AS7 and Wildfly 8 --- .../jboss/JBoss7ServerSoftLayerLiveTest.java | 44 ++++++++++++ .../jboss/JBossServerSoftLayerLiveTest.java | 69 +++++++++++++++++++ .../Wildfly8ServerSoftLayerLiveTest.java | 44 ++++++++++++ 3 files changed, 157 insertions(+) create mode 100644 software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerSoftLayerLiveTest.java create mode 100644 software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServerSoftLayerLiveTest.java create mode 100644 software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerSoftLayerLiveTest.java diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerSoftLayerLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerSoftLayerLiveTest.java new file mode 100644 index 0000000000..660d1c001a --- /dev/null +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerSoftLayerLiveTest.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package brooklyn.entity.webapp.jboss; + +import org.testng.annotations.Test; + +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess; +import brooklyn.location.Location; + +/** + * A simple test of installing+running JBoss AS7 on SoftLayer, using various OS distros and versions. + */ +public class JBoss7ServerSoftLayerLiveTest extends JBossServerSoftLayerLiveTest { + + @Override + protected void doTest(Location loc) throws Exception { + super.doTest(loc); + } + + @Test(enabled = false) + public void testDummy() { + } // Convince testng IDE integration that this really does have test methods + + @Override + protected Class getServerType() { + return Wildfly8Server.class; + } +} diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServerSoftLayerLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServerSoftLayerLiveTest.java new file mode 100644 index 0000000000..fa02c45ffa --- /dev/null +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossServerSoftLayerLiveTest.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package brooklyn.entity.webapp.jboss; + +import static org.testng.Assert.assertNotNull; +import brooklyn.entity.AbstractEc2LiveTest; +import brooklyn.entity.AbstractSoftlayerLiveTest; +import brooklyn.entity.proxying.EntitySpec; +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess; +import brooklyn.entity.webapp.WebAppServiceConstants; +import brooklyn.entity.webapp.WebAppServiceMetrics; +import brooklyn.location.Location; +import brooklyn.test.Asserts; +import brooklyn.test.HttpTestUtils; +import brooklyn.test.TestResourceUnavailableException; + +import com.google.common.collect.ImmutableList; + +/** + * A simple test of installing+running JBoss type servers on SoftLayer, using various OS distros and versions. + */ +public abstract class JBossServerSoftLayerLiveTest extends AbstractSoftlayerLiveTest { + + public String getTestWar() { + TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war"); + return "classpath://hello-world.war"; + } + + @Override + protected void doTest(Location loc) throws Exception { + final JavaWebAppSoftwareProcess server = app.createAndManageChild(EntitySpec.create(getServerType()) + .configure("war", getTestWar())); + + app.start(ImmutableList.of(loc)); + + String url = server.getAttribute(WebAppServiceConstants.ROOT_URL); + + HttpTestUtils.assertHttpStatusCodeEventuallyEquals(url, 200); + HttpTestUtils.assertContentContainsText(url, "Hello"); + + Asserts.succeedsEventually(new Runnable() { + @Override public void run() { + assertNotNull(server.getAttribute(WebAppServiceMetrics.REQUEST_COUNT)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.ERROR_COUNT)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.TOTAL_PROCESSING_TIME)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.MAX_PROCESSING_TIME)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.BYTES_RECEIVED)); + assertNotNull(server.getAttribute(WebAppServiceMetrics.BYTES_SENT)); + }}); + } + + protected abstract Class getServerType(); +} diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerSoftLayerLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerSoftLayerLiveTest.java new file mode 100644 index 0000000000..55c426d38e --- /dev/null +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerSoftLayerLiveTest.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package brooklyn.entity.webapp.jboss; + +import org.testng.annotations.Test; + +import brooklyn.entity.webapp.JavaWebAppSoftwareProcess; +import brooklyn.location.Location; + +/** + * A simple test of installing+running JBoss AS7 on SoftLayer, using various OS distros and versions. + */ +public class Wildfly8ServerSoftLayerLiveTest extends JBossServerSoftLayerLiveTest { + + @Override + protected void doTest(Location loc) throws Exception { + super.doTest(loc); + } + + @Test(enabled = false) + public void testDummy() { + } // Convince testng IDE integration that this really does have test methods + + @Override + protected Class getServerType() { + return JBoss7Server.class; + } +} From 4c2f0e737963b3ca9516dbda51fc095fa9f7d412 Mon Sep 17 00:00:00 2001 From: Mike Zaccardo Date: Mon, 4 May 2015 10:56:25 -0400 Subject: [PATCH 13/18] Fix JBoss7 <-> Wildfly8 class mixup --- .../entity/webapp/jboss/JBoss7ServerSoftLayerLiveTest.java | 2 +- .../entity/webapp/jboss/Wildfly8ServerSoftLayerLiveTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerSoftLayerLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerSoftLayerLiveTest.java index 660d1c001a..58a42a260f 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerSoftLayerLiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerSoftLayerLiveTest.java @@ -39,6 +39,6 @@ public void testDummy() { @Override protected Class getServerType() { - return Wildfly8Server.class; + return JBoss7Server.class; } } diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerSoftLayerLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerSoftLayerLiveTest.java index 55c426d38e..87203493f7 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerSoftLayerLiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerSoftLayerLiveTest.java @@ -39,6 +39,6 @@ public void testDummy() { @Override protected Class getServerType() { - return JBoss7Server.class; + return Wildfly8Server.class; } } From 2152de839d885f860ff36be62c644c6bb977ed5e Mon Sep 17 00:00:00 2001 From: Mike Zaccardo Date: Fri, 19 Jun 2015 17:59:37 -0400 Subject: [PATCH 14/18] Address some PR comments --- .../entity/webapp/jboss/JBoss7ServerImpl.java | 9 ------- .../entity/webapp/jboss/Wildfly8Server.java | 2 +- .../webapp/jboss/Wildfly8ServerImpl.java | 26 +++---------------- .../jboss/JBoss6ServerAwsEc2LiveTest.java | 12 ++++----- .../JBoss7ServerGoogleComputeLiveTest.java | 10 +++---- .../jboss/JBossPasswordHashingTest.java | 6 ++--- .../jboss/Wildfly8ServerAwsEc2LiveTest.java | 12 ++++----- .../Wildfly8ServerGoogleComputeLiveTest.java | 10 +++---- 8 files changed, 30 insertions(+), 57 deletions(-) diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7ServerImpl.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7ServerImpl.java index 67fe9551d4..5bbb23298b 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7ServerImpl.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7ServerImpl.java @@ -153,10 +153,6 @@ public int getManagementNativePort() { public int getPortOffset() { return getConfig(PORT_INCREMENT); } - - public boolean isWelcomeRootEnabled() { - return false; - } public String getBindAddress() { return getConfig(BIND_ADDRESS); @@ -169,11 +165,6 @@ public String getManagementBindAddress() { public String getUnsecureBindAddress() { return getConfig(BIND_ADDRESS); } - - // If empty-string, disables Management security (!) by excluding the security-realm attribute - public String getHttpManagementInterfaceSecurityRealm() { - return ""; - } public int getDeploymentTimeoutSecs() { return getConfig(DEPLOYMENT_TIMEOUT); diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8Server.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8Server.java index 8186a76759..087c156c59 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8Server.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8Server.java @@ -64,7 +64,7 @@ public interface Wildfly8Server extends JavaWebAppSoftwareProcess, HasShortName new PortAttributeSensorAndConfigKey("webapp.jboss.managementNativePort", "Management native port", "10999+"); /** - * Port increments are the standard way to run multiple instances of AS7 on the same machine. + * Port increments are the standard way to run multiple instances of Wildfly on the same machine. */ @SetFromFlag("portIncrement") ConfigKey PORT_INCREMENT = diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8ServerImpl.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8ServerImpl.java index d2dee7561f..d83e3426d4 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8ServerImpl.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8ServerImpl.java @@ -18,9 +18,11 @@ */ package brooklyn.entity.webapp.jboss; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import brooklyn.config.render.RendererHints; import brooklyn.enricher.Enrichers; -import brooklyn.entity.Entity; import brooklyn.entity.basic.Attributes; import brooklyn.entity.webapp.JavaWebAppSoftwareProcessImpl; import brooklyn.event.feed.http.HttpFeed; @@ -28,12 +30,9 @@ import brooklyn.event.feed.http.HttpValueFunctions; import brooklyn.location.access.BrooklynAccessUtils; import brooklyn.util.guava.Functionals; + import com.google.common.base.Functions; import com.google.common.net.HostAndPort; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Map; public class Wildfly8ServerImpl extends JavaWebAppSoftwareProcessImpl implements Wildfly8Server { @@ -45,14 +44,6 @@ public Wildfly8ServerImpl(){ super(); } - public Wildfly8ServerImpl(@SuppressWarnings("rawtypes") Map flags){ - this(flags, null); - } - - public Wildfly8ServerImpl(@SuppressWarnings("rawtypes") Map flags, Entity parent) { - super(flags, parent); - } - @Override public Class getDriverInterface() { return Wildfly8Driver.class; @@ -158,10 +149,6 @@ public int getManagementNativePort() { public int getPortOffset() { return getConfig(PORT_INCREMENT); } - - public boolean isWelcomeRootEnabled() { - return false; - } public String getBindAddress() { return getConfig(BIND_ADDRESS); @@ -174,11 +161,6 @@ public String getManagementBindAddress() { public String getUnsecureBindAddress() { return getConfig(BIND_ADDRESS); } - - // If empty-string, disables Management security (!) by excluding the security-realm attribute - public String getHttpManagementInterfaceSecurityRealm() { - return ""; - } public int getDeploymentTimeoutSecs() { return getConfig(DEPLOYMENT_TIMEOUT); diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java index fb9dfc77d6..62abed69a9 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss6ServerAwsEc2LiveTest.java @@ -38,12 +38,12 @@ protected void doTest(Location loc) throws Exception { public void test_CentOS_6_3() throws Exception { super.test_CentOS_6_3(); } - + @Test(enabled=false) public void testDummy() {} // Convince testng IDE integration that this really does have test methods - - @Override - protected Class getServerType() { - return JBoss6Server.class; - } + + @Override + protected Class getServerType() { + return JBoss6Server.class; + } } diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerGoogleComputeLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerGoogleComputeLiveTest.java index 8712f0f055..4e2465611b 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerGoogleComputeLiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerGoogleComputeLiveTest.java @@ -38,12 +38,12 @@ protected void doTest(Location loc) throws Exception { public void test_DefaultImage() throws Exception { super.test_DefaultImage(); } - + @Test(enabled=false) public void testDummy() {} // Convince testng IDE integration that this really does have test methods - @Override - protected Class getServerType() { - return JBoss7Server.class; - } + @Override + protected Class getServerType() { + return JBoss7Server.class; + } } diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossPasswordHashingTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossPasswordHashingTest.java index 94b8fe357a..fb727a62b7 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossPasswordHashingTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBossPasswordHashingTest.java @@ -38,17 +38,17 @@ public void testPasswordForManagementRealm() { JavaWebAppSshDriver.hashPassword("test", "123", "ManagementRealm"), "090d846d31185e54a5e8811a2ccb43ee"); } - + @Test public void testPasswordForApplicationRealm() { assertEquals( JavaWebAppSshDriver.hashPassword("username", "password", "ApplicationRealm"), "888a0504c559a34b1c3e919dcec6d941"); assertEquals( - JavaWebAppSshDriver.hashPassword("test", "321", "ApplicationRealm"), + JavaWebAppSshDriver.hashPassword("test", "321", "ApplicationRealm"), "a0fdaa45e2d509ac2d390ff6820e2a10"); } - + @Test public void testPasswordForCustomRealm() { assertEquals( diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerAwsEc2LiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerAwsEc2LiveTest.java index b230c278d9..209dee19ea 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerAwsEc2LiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerAwsEc2LiveTest.java @@ -38,12 +38,12 @@ protected void doTest(Location loc) throws Exception { public void test_CentOS_6_3() throws Exception { super.test_CentOS_6_3(); } - + @Test(enabled=false) public void testDummy() {} // Convince testng IDE integration that this really does have test methods - - @Override - protected Class getServerType() { - return Wildfly8Server.class; - } + + @Override + protected Class getServerType() { + return Wildfly8Server.class; + } } diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerGoogleComputeLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerGoogleComputeLiveTest.java index a3041a3085..f3f63a6b0e 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerGoogleComputeLiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerGoogleComputeLiveTest.java @@ -38,12 +38,12 @@ protected void doTest(Location loc) throws Exception { public void test_DefaultImage() throws Exception { super.test_DefaultImage(); } - + @Test(enabled=false) public void testDummy() {} // Convince testng IDE integration that this really does have test methods - @Override - protected Class getServerType() { - return Wildfly8Server.class; - } + @Override + protected Class getServerType() { + return Wildfly8Server.class; + } } From 146685c783d668e504d163ac222b5a566dd21cf3 Mon Sep 17 00:00:00 2001 From: Mike Zaccardo Date: Fri, 19 Jun 2015 18:07:20 -0400 Subject: [PATCH 15/18] Re-add necessary constructors --- .../entity/webapp/jboss/Wildfly8ServerImpl.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8ServerImpl.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8ServerImpl.java index d83e3426d4..84916e8963 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8ServerImpl.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8ServerImpl.java @@ -18,11 +18,14 @@ */ package brooklyn.entity.webapp.jboss; +import java.util.Map; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import brooklyn.config.render.RendererHints; import brooklyn.enricher.Enrichers; +import brooklyn.entity.Entity; import brooklyn.entity.basic.Attributes; import brooklyn.entity.webapp.JavaWebAppSoftwareProcessImpl; import brooklyn.event.feed.http.HttpFeed; @@ -43,6 +46,14 @@ public class Wildfly8ServerImpl extends JavaWebAppSoftwareProcessImpl implements public Wildfly8ServerImpl(){ super(); } + + public Wildfly8ServerImpl(@SuppressWarnings("rawtypes") Map flags) { + this(flags, null); + } + + public Wildfly8ServerImpl(@SuppressWarnings("rawtypes") Map flags, Entity parent) { + super(flags, parent); + } @Override public Class getDriverInterface() { From 32c03bd87c7571a153c29fdf52d054315d3df29a Mon Sep 17 00:00:00 2001 From: Mike Zaccardo Date: Fri, 19 Jun 2015 18:11:19 -0400 Subject: [PATCH 16/18] Add TODO for class refactor --- .../brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy b/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy index e5adaa6cca..21a0c18092 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy @@ -54,6 +54,8 @@ import brooklyn.util.internal.TimeExtras /** * This tests that we can run jboss entity on AWS. + * + * TODO Convert this class to Java and use EntitySpec to create server objects. */ public class WebAppLiveIntegrationTest { private static final Logger logger = LoggerFactory.getLogger(WebAppLiveIntegrationTest.class) From 05014dea3cc157ab3f8d698f951fdaab0e6ce914 Mon Sep 17 00:00:00 2001 From: Mike Zaccardo Date: Fri, 19 Jun 2015 18:30:58 -0400 Subject: [PATCH 17/18] Move currently failing tests to WIP group --- .../jboss/Wildfly8ServerAwsEc2LiveTest.java | 13 ++++++++- .../jboss/Wildfly8ServerDockerLiveTest.java | 28 +++++++++++-------- .../Wildfly8ServerGoogleComputeLiveTest.java | 13 ++++++++- .../Wildfly8ServerSoftLayerLiveTest.java | 28 +++++++++++-------- 4 files changed, 58 insertions(+), 24 deletions(-) diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerAwsEc2LiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerAwsEc2LiveTest.java index 209dee19ea..f847338080 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerAwsEc2LiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerAwsEc2LiveTest.java @@ -28,12 +28,23 @@ */ public class Wildfly8ServerAwsEc2LiveTest extends JBossServerAwsEc2LiveTest { + /** + * Wildfly8 does not yet support the metrics necessary for this test to pass. + * + * @see https://issues.apache.org/jira/browse/BROOKLYN-142 + */ + @Test(groups = "WIP") @Override protected void doTest(Location loc) throws Exception { super.doTest(loc); } - @Test(groups = {"Live", "Live-sanity"}) + /** + * Wildfly8 does not yet support the metrics necessary for this test to pass. + * + * @see https://issues.apache.org/jira/browse/BROOKLYN-142 + */ + @Test(groups = "WIP") @Override public void test_CentOS_6_3() throws Exception { super.test_CentOS_6_3(); diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerDockerLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerDockerLiveTest.java index bdb502e726..01ac4770be 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerDockerLiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerDockerLiveTest.java @@ -28,17 +28,23 @@ */ public class Wildfly8ServerDockerLiveTest extends JBossServerDockerLiveTest { - @Override - protected void doTest(Location loc) throws Exception { - super.doTest(loc); - } + /** + * Wildfly8 does not yet support the metrics necessary for this test to pass. + * + * @see https://issues.apache.org/jira/browse/BROOKLYN-142 + */ + @Test(groups = "WIP") + @Override + protected void doTest(Location loc) throws Exception { + super.doTest(loc); + } - @Test(enabled = false) - public void testDummy() { - } // Convince testng IDE integration that this really does have test methods + @Test(enabled = false) + public void testDummy() { + } // Convince testng IDE integration that this really does have test methods - @Override - protected Class getServerType() { - return Wildfly8Server.class; - } + @Override + protected Class getServerType() { + return Wildfly8Server.class; + } } diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerGoogleComputeLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerGoogleComputeLiveTest.java index f3f63a6b0e..90d4f90b45 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerGoogleComputeLiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerGoogleComputeLiveTest.java @@ -28,12 +28,23 @@ */ public class Wildfly8ServerGoogleComputeLiveTest extends JBossServerGoogleComputeLiveTest { + /** + * Wildfly8 does not yet support the metrics necessary for this test to pass. + * + * @see https://issues.apache.org/jira/browse/BROOKLYN-142 + */ + @Test(groups = "WIP") @Override protected void doTest(Location loc) throws Exception { super.doTest(loc); } - @Test(groups = {"Live"}) + /** + * Wildfly8 does not yet support the metrics necessary for this test to pass. + * + * @see https://issues.apache.org/jira/browse/BROOKLYN-142 + */ + @Test(groups = "WIP") @Override public void test_DefaultImage() throws Exception { super.test_DefaultImage(); diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerSoftLayerLiveTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerSoftLayerLiveTest.java index 87203493f7..5367be72af 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerSoftLayerLiveTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Wildfly8ServerSoftLayerLiveTest.java @@ -28,17 +28,23 @@ */ public class Wildfly8ServerSoftLayerLiveTest extends JBossServerSoftLayerLiveTest { - @Override - protected void doTest(Location loc) throws Exception { - super.doTest(loc); - } + /** + * Wildfly8 does not yet support the metrics necessary for this test to pass. + * + * @see https://issues.apache.org/jira/browse/BROOKLYN-142 + */ + @Test(groups = "WIP") + @Override + protected void doTest(Location loc) throws Exception { + super.doTest(loc); + } - @Test(enabled = false) - public void testDummy() { - } // Convince testng IDE integration that this really does have test methods + @Test(enabled = false) + public void testDummy() { + } // Convince testng IDE integration that this really does have test methods - @Override - protected Class getServerType() { - return Wildfly8Server.class; - } + @Override + protected Class getServerType() { + return Wildfly8Server.class; + } } From b21eab39e7c2760bf08b1d2dcaa74e71babe7b57 Mon Sep 17 00:00:00 2001 From: Mike Zaccardo Date: Tue, 23 Jun 2015 01:02:23 -0700 Subject: [PATCH 18/18] Re-add necessary method to server impl classes --- .../java/brooklyn/entity/webapp/jboss/JBoss7ServerImpl.java | 4 ++++ .../java/brooklyn/entity/webapp/jboss/Wildfly8ServerImpl.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7ServerImpl.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7ServerImpl.java index 5bbb23298b..b901861c60 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7ServerImpl.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/JBoss7ServerImpl.java @@ -153,6 +153,10 @@ public int getManagementNativePort() { public int getPortOffset() { return getConfig(PORT_INCREMENT); } + + public boolean isWelcomeRootEnabled() { + return false; + } public String getBindAddress() { return getConfig(BIND_ADDRESS); diff --git a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8ServerImpl.java b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8ServerImpl.java index 84916e8963..cbb6cf5dfb 100644 --- a/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8ServerImpl.java +++ b/software/webapp/src/main/java/brooklyn/entity/webapp/jboss/Wildfly8ServerImpl.java @@ -160,6 +160,10 @@ public int getManagementNativePort() { public int getPortOffset() { return getConfig(PORT_INCREMENT); } + + public boolean isWelcomeRootEnabled() { + return false; + } public String getBindAddress() { return getConfig(BIND_ADDRESS);