mirror of
https://github.com/apache/jclouds.git
synced 2025-02-16 15:08:28 +00:00
refactored test logic
This commit is contained in:
parent
3921856973
commit
c1f6eab2c4
@ -474,6 +474,7 @@ public abstract class BaseComputeServiceLiveTest {
|
|||||||
|
|
||||||
template = client.templateBuilder().options(blockOnComplete(false).blockOnPort(8080, 600).inboundPorts(22, 8080))
|
template = client.templateBuilder().options(blockOnComplete(false).blockOnPort(8080, 600).inboundPorts(22, 8080))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// note this is a dependency on the template resolution
|
// note this is a dependency on the template resolution
|
||||||
template.getOptions().runScript(
|
template.getOptions().runScript(
|
||||||
RunScriptData.createScriptInstallAndStartJBoss(keyPair.get("public"), template.getImage()
|
RunScriptData.createScriptInstallAndStartJBoss(keyPair.get("public"), template.getImage()
|
||||||
|
@ -33,6 +33,7 @@ import org.jclouds.compute.predicates.OperatingSystemPredicates;
|
|||||||
import org.jclouds.scriptbuilder.InitBuilder;
|
import org.jclouds.scriptbuilder.InitBuilder;
|
||||||
import org.jclouds.scriptbuilder.domain.AuthorizeRSAPublicKey;
|
import org.jclouds.scriptbuilder.domain.AuthorizeRSAPublicKey;
|
||||||
import org.jclouds.scriptbuilder.domain.Statement;
|
import org.jclouds.scriptbuilder.domain.Statement;
|
||||||
|
import org.jclouds.scriptbuilder.domain.Statements;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
@ -56,32 +57,34 @@ public class RunScriptData {
|
|||||||
throw new IllegalArgumentException("don't know how to handle" + os.toString());
|
throw new IllegalArgumentException("don't know how to handle" + os.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Statement authorizePortInIpTables(int port) {
|
||||||
|
return Statements.newStatementList(// just in case iptables are being used, try to open 8080
|
||||||
|
exec("iptables -I INPUT 1 -p tcp --dport " + port + " -j ACCEPT"),//
|
||||||
|
// TODO gogrid rules only allow ports 22, 3389, 80 and 443.
|
||||||
|
// the above rule will be ignored, so we have to apply this
|
||||||
|
// directly
|
||||||
|
exec("iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport " + port + " -j ACCEPT"),//
|
||||||
|
exec("iptables-save"));
|
||||||
|
}
|
||||||
|
|
||||||
public static Statement createScriptInstallAndStartJBoss(String publicKey, OperatingSystem os) {
|
public static Statement createScriptInstallAndStartJBoss(String publicKey, OperatingSystem os) {
|
||||||
Map<String, String> envVariables = ImmutableMap.of("jbossHome", jbossHome);
|
Map<String, String> envVariables = ImmutableMap.of("jbossHome", jbossHome);
|
||||||
Statement toReturn = new InitBuilder(
|
Statement toReturn = new InitBuilder(
|
||||||
"jboss",
|
"jboss",
|
||||||
jbossHome,
|
jbossHome,
|
||||||
jbossHome,
|
jbossHome,
|
||||||
envVariables,
|
envVariables,
|
||||||
ImmutableList
|
ImmutableList.<Statement> of(
|
||||||
.<Statement> of(
|
new AuthorizeRSAPublicKey(publicKey),//
|
||||||
new AuthorizeRSAPublicKey(publicKey),//
|
installJavaAndCurl(os),//
|
||||||
installJavaAndCurl(os),//
|
authorizePortInIpTables(8080),//
|
||||||
// just in case iptables are being used, try to open 8080
|
extractTargzIntoDirectory(
|
||||||
exec("iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT"),//
|
URI.create("http://commondatastorage.googleapis.com/jclouds-repo/jboss-as-distribution-6.0.0.20100911-M5.tar.gz"),
|
||||||
// TODO gogrid rules only allow ports 22, 3389, 80 and 443.
|
"/usr/local"),//
|
||||||
// the above rule will be ignored, so we have to apply this
|
exec("{md} " + jbossHome), exec("mv /usr/local/jboss-*/* " + jbossHome),//
|
||||||
// directly
|
exec("chmod -R oug+r+w " + jbossHome)),//
|
||||||
exec("iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport 8080 -j ACCEPT"),//
|
ImmutableList
|
||||||
exec("iptables-save"),//
|
.<Statement> of(interpret("java -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.endorsed.dirs=lib/endorsed -classpath bin/run.jar org.jboss.Main -b 0.0.0.0")));
|
||||||
extractTargzIntoDirectory(
|
|
||||||
URI
|
|
||||||
.create("http://commondatastorage.googleapis.com/jclouds-repo/jboss-as-distribution-6.0.0.20100911-M5.tar.gz"),
|
|
||||||
"/usr/local"), exec("{md} " + jbossHome), exec("mv /usr/local/jboss-*/* "
|
|
||||||
+ jbossHome),//
|
|
||||||
exec("chmod -R oug+r+w " + jbossHome)),//
|
|
||||||
ImmutableList
|
|
||||||
.<Statement> of(interpret("java -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.endorsed.dirs=lib/endorsed -classpath bin/run.jar org.jboss.Main -b 0.0.0.0")));
|
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,28 +96,28 @@ public class RunScriptData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final Statement APT_RUN_SCRIPT = newStatementList(//
|
public static final Statement APT_RUN_SCRIPT = newStatementList(//
|
||||||
exec(installAfterUpdatingIfNotPresent("curl")),//
|
exec(installAfterUpdatingIfNotPresent("curl")),//
|
||||||
exec("(which java && java -fullversion 2>&1|egrep -q 1.6 ) ||"),//
|
exec("(which java && java -fullversion 2>&1|egrep -q 1.6 ) ||"),//
|
||||||
execHttpResponse(URI.create("http://whirr.s3.amazonaws.com/0.2.0-incubating-SNAPSHOT/sun/java/install")),//
|
execHttpResponse(URI.create("http://whirr.s3.amazonaws.com/0.2.0-incubating-SNAPSHOT/sun/java/install")),//
|
||||||
exec(new StringBuilder()//
|
exec(new StringBuilder()//
|
||||||
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")//
|
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")//
|
||||||
// jeos hasn't enough room!
|
// jeos hasn't enough room!
|
||||||
.append("rm -rf /var/cache/apt /usr/lib/vmware-tools\n")//
|
.append("rm -rf /var/cache/apt /usr/lib/vmware-tools\n")//
|
||||||
.append("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /root/.bashrc")//
|
.append("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /root/.bashrc")//
|
||||||
.toString()));
|
.toString()));
|
||||||
|
|
||||||
public static final Statement YUM_RUN_SCRIPT = newStatementList(
|
public static final Statement YUM_RUN_SCRIPT = newStatementList(
|
||||||
exec("which curl ||yum --nogpgcheck -y install curl"),//
|
exec("which curl ||yum --nogpgcheck -y install curl"),//
|
||||||
exec("(which java && java -fullversion 2>&1|egrep -q 1.6 ) ||"),//
|
exec("(which java && java -fullversion 2>&1|egrep -q 1.6 ) ||"),//
|
||||||
execHttpResponse(URI.create("http://whirr.s3.amazonaws.com/0.2.0-incubating-SNAPSHOT/sun/java/install")),//
|
execHttpResponse(URI.create("http://whirr.s3.amazonaws.com/0.2.0-incubating-SNAPSHOT/sun/java/install")),//
|
||||||
exec(new StringBuilder()//
|
exec(new StringBuilder()//
|
||||||
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n") //
|
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n") //
|
||||||
.append("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /root/.bashrc")//
|
.append("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /root/.bashrc")//
|
||||||
.toString()));
|
.toString()));
|
||||||
|
|
||||||
public static final Statement ZYPPER_RUN_SCRIPT = exec(new StringBuilder()//
|
public static final Statement ZYPPER_RUN_SCRIPT = exec(new StringBuilder()//
|
||||||
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")//
|
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")//
|
||||||
.append("which curl || zypper install curl\n")//
|
.append("which curl || zypper install curl\n")//
|
||||||
.append("(which java && java -fullversion 2>&1|egrep -q 1.6 ) || zypper install java-1.6.0-openjdk\n")//
|
.append("(which java && java -fullversion 2>&1|egrep -q 1.6 ) || zypper install java-1.6.0-openjdk\n")//
|
||||||
.toString());
|
.toString());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user