mirror of https://github.com/apache/jclouds.git
Issue 740:update tests to use JDK7
This commit is contained in:
parent
29ee165de2
commit
0f8a2eec17
|
@ -32,6 +32,9 @@ import static java.lang.String.format;
|
||||||
import static java.lang.System.currentTimeMillis;
|
import static java.lang.System.currentTimeMillis;
|
||||||
import static java.util.logging.Logger.getAnonymousLogger;
|
import static java.util.logging.Logger.getAnonymousLogger;
|
||||||
import static org.jclouds.compute.ComputeTestUtils.buildScript;
|
import static org.jclouds.compute.ComputeTestUtils.buildScript;
|
||||||
|
import static org.jclouds.compute.RunScriptData.JBOSS7_URL;
|
||||||
|
import static org.jclouds.compute.RunScriptData.JBOSS_HOME;
|
||||||
|
import static org.jclouds.compute.RunScriptData.JDK7_URL;
|
||||||
import static org.jclouds.compute.RunScriptData.installAdminUserJBossAndOpenPorts;
|
import static org.jclouds.compute.RunScriptData.installAdminUserJBossAndOpenPorts;
|
||||||
import static org.jclouds.compute.RunScriptData.startJBoss;
|
import static org.jclouds.compute.RunScriptData.startJBoss;
|
||||||
import static org.jclouds.compute.options.RunScriptOptions.Builder.nameTask;
|
import static org.jclouds.compute.options.RunScriptOptions.Builder.nameTask;
|
||||||
|
@ -49,15 +52,19 @@ import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URI;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.Map.Entry;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -85,6 +92,7 @@ import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.jclouds.predicates.SocketOpen;
|
import org.jclouds.predicates.SocketOpen;
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
import org.jclouds.rest.RestContextFactory;
|
||||||
|
import org.jclouds.scriptbuilder.domain.SaveHttpResponseTo;
|
||||||
import org.jclouds.scriptbuilder.domain.Statements;
|
import org.jclouds.scriptbuilder.domain.Statements;
|
||||||
import org.jclouds.scriptbuilder.statements.login.AdminAccess;
|
import org.jclouds.scriptbuilder.statements.login.AdminAccess;
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
|
@ -97,11 +105,13 @@ import org.testng.annotations.Test;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Stopwatch;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.net.InetAddresses;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
@ -148,7 +158,8 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
setServiceDefaults();
|
setServiceDefaults();
|
||||||
if (group == null)
|
if (group == null)
|
||||||
group = checkNotNull(provider, "provider");
|
group = checkNotNull(provider, "provider");
|
||||||
// groups need to work with hyphens in them, so let's make sure there is one!
|
// groups need to work with hyphens in them, so let's make sure there is
|
||||||
|
// one!
|
||||||
if (group.indexOf('-') == -1)
|
if (group.indexOf('-') == -1)
|
||||||
group = group + "-";
|
group = group + "-";
|
||||||
setupCredentials();
|
setupCredentials();
|
||||||
|
@ -176,8 +187,8 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
if (context != null)
|
if (context != null)
|
||||||
context.close();
|
context.close();
|
||||||
Properties props = setupProperties();
|
Properties props = setupProperties();
|
||||||
context = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, ImmutableSet.of(
|
context = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider,
|
||||||
new Log4JLoggingModule(), getSshModule()), props);
|
ImmutableSet.of(new Log4JLoggingModule(), getSshModule()), props);
|
||||||
client = context.getComputeService();
|
client = context.getComputeService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +204,7 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
long interval = 50;
|
long interval = 50;
|
||||||
// get more precise than default socket tester
|
// get more precise than default socket tester
|
||||||
preciseSocketTester = new RetryablePredicate<IPSocket>(socketOpen, maxWait, interval, interval,
|
preciseSocketTester = new RetryablePredicate<IPSocket>(socketOpen, maxWait, interval, interval,
|
||||||
TimeUnit.MILLISECONDS);
|
TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected Module getSshModule();
|
abstract protected Module getSshModule();
|
||||||
|
@ -204,7 +215,7 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
ComputeServiceContext context = null;
|
ComputeServiceContext context = null;
|
||||||
try {
|
try {
|
||||||
context = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, "MOMMA", "MIA",
|
context = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, "MOMMA", "MIA",
|
||||||
ImmutableSet.<Module> of(new Log4JLoggingModule()));
|
ImmutableSet.<Module> of(new Log4JLoggingModule()));
|
||||||
context.getComputeService().listNodes();
|
context.getComputeService().listNodes();
|
||||||
} catch (AuthorizationException e) {
|
} catch (AuthorizationException e) {
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -229,7 +240,7 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
@Test(enabled = true, expectedExceptions = NoSuchElementException.class)
|
@Test(enabled = true, expectedExceptions = NoSuchElementException.class)
|
||||||
public void testCorrectExceptionRunningNodesNotFound() throws Exception {
|
public void testCorrectExceptionRunningNodesNotFound() throws Exception {
|
||||||
client.runScriptOnNodesMatching(runningInGroup("zebras-are-awesome"), buildScript(new OperatingSystem.Builder()
|
client.runScriptOnNodesMatching(runningInGroup("zebras-are-awesome"), buildScript(new OperatingSystem.Builder()
|
||||||
.family(OsFamily.UBUNTU).description("ffoo").build()));
|
.family(OsFamily.UBUNTU).description("ffoo").build()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// since surefire and eclipse don't otherwise guarantee the order, we are
|
// since surefire and eclipse don't otherwise guarantee the order, we are
|
||||||
|
@ -252,14 +263,14 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
assert good.credential != null : nodes;
|
assert good.credential != null : nodes;
|
||||||
|
|
||||||
for (Entry<? extends NodeMetadata, ExecResponse> response : client.runScriptOnNodesMatching(
|
for (Entry<? extends NodeMetadata, ExecResponse> response : client.runScriptOnNodesMatching(
|
||||||
runningInGroup(group), Statements.exec("hostname"),
|
runningInGroup(group), Statements.exec("hostname"),
|
||||||
wrapInInitScript(false).runAsRoot(false).overrideCredentialsWith(good)).entrySet()) {
|
wrapInInitScript(false).runAsRoot(false).overrideCredentialsWith(good)).entrySet()) {
|
||||||
checkResponseEqualsHostname(response.getValue(), response.getKey());
|
checkResponseEqualsHostname(response.getValue(), response.getKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
// test single-node execution
|
// test single-node execution
|
||||||
ExecResponse response = client.runScriptOnNode(node.getId(), "hostname", wrapInInitScript(false).runAsRoot(
|
ExecResponse response = client.runScriptOnNode(node.getId(), "hostname",
|
||||||
false));
|
wrapInInitScript(false).runAsRoot(false));
|
||||||
checkResponseEqualsHostname(response, node);
|
checkResponseEqualsHostname(response, node);
|
||||||
OperatingSystem os = node.getOperatingSystem();
|
OperatingSystem os = node.getOperatingSystem();
|
||||||
|
|
||||||
|
@ -270,9 +281,10 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
|
|
||||||
checkNodes(nodes, group, "runScriptWithCreds");
|
checkNodes(nodes, group, "runScriptWithCreds");
|
||||||
|
|
||||||
// test adding AdminAccess later changes the default boot user, in this case to foo
|
// test adding AdminAccess later changes the default boot user, in this
|
||||||
|
// case to foo
|
||||||
ListenableFuture<ExecResponse> future = client.submitScriptOnNode(node.getId(), AdminAccess.builder()
|
ListenableFuture<ExecResponse> future = client.submitScriptOnNode(node.getId(), AdminAccess.builder()
|
||||||
.adminUsername("foo").build(), nameTask("adminUpdate"));
|
.adminUsername("foo").build(), nameTask("adminUpdate"));
|
||||||
|
|
||||||
response = future.get(3, TimeUnit.MINUTES);
|
response = future.get(3, TimeUnit.MINUTES);
|
||||||
|
|
||||||
|
@ -300,20 +312,22 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
protected void tryBadPassword(String group, Credentials good) throws AssertionError {
|
protected void tryBadPassword(String group, Credentials good) throws AssertionError {
|
||||||
try {
|
try {
|
||||||
Map<? extends NodeMetadata, ExecResponse> responses = client.runScriptOnNodesMatching(runningInGroup(group),
|
Map<? extends NodeMetadata, ExecResponse> responses = client.runScriptOnNodesMatching(runningInGroup(group),
|
||||||
"echo I put a bad password", wrapInInitScript(false).runAsRoot(false).overrideCredentialsWith(
|
"echo I put a bad password",
|
||||||
new Credentials(good.identity, "romeo")));
|
wrapInInitScript(false).runAsRoot(false)
|
||||||
|
.overrideCredentialsWith(new Credentials(good.identity, "romeo")));
|
||||||
assert responses.size() == 0 : "shouldn't pass with a bad password\n" + responses;
|
assert responses.size() == 0 : "shouldn't pass with a bad password\n" + responses;
|
||||||
} catch (AssertionError e) {
|
} catch (AssertionError e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (RunScriptOnNodesException e) {
|
} catch (RunScriptOnNodesException e) {
|
||||||
assert Iterables.any(e.getNodeErrors().values(), Predicates.instanceOf(AuthorizationException.class)) : e
|
assert Iterables.any(e.getNodeErrors().values(), Predicates.instanceOf(AuthorizationException.class)) : e
|
||||||
+ " not authexception!";
|
+ " not authexception!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void weCanCancelTasks(NodeMetadata node) throws InterruptedException, ExecutionException {
|
public void weCanCancelTasks(NodeMetadata node) throws InterruptedException, ExecutionException {
|
||||||
ListenableFuture<ExecResponse> future = client.submitScriptOnNode(node.getId(), Statements.exec("sleep 300"), nameTask("sleeper").runAsRoot(false));
|
ListenableFuture<ExecResponse> future = client.submitScriptOnNode(node.getId(), Statements.exec("sleep 300"),
|
||||||
|
nameTask("sleeper").runAsRoot(false));
|
||||||
ExecResponse response = null;
|
ExecResponse response = null;
|
||||||
try {
|
try {
|
||||||
response = future.get(1, TimeUnit.MILLISECONDS);
|
response = future.get(1, TimeUnit.MILLISECONDS);
|
||||||
|
@ -321,11 +335,11 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
} catch (TimeoutException e) {
|
} catch (TimeoutException e) {
|
||||||
assert !future.isDone();
|
assert !future.isDone();
|
||||||
response = client.runScriptOnNode(node.getId(), Statements.exec("./sleeper status"), wrapInInitScript(false)
|
response = client.runScriptOnNode(node.getId(), Statements.exec("./sleeper status"), wrapInInitScript(false)
|
||||||
.runAsRoot(false));
|
.runAsRoot(false));
|
||||||
assert !response.getOutput().trim().equals("") : node.getId() + ": " + response;
|
assert !response.getOutput().trim().equals("") : node.getId() + ": " + response;
|
||||||
future.cancel(true);
|
future.cancel(true);
|
||||||
response = client.runScriptOnNode(node.getId(), Statements.exec("./sleeper status"), wrapInInitScript(false)
|
response = client.runScriptOnNode(node.getId(), Statements.exec("./sleeper status"), wrapInInitScript(false)
|
||||||
.runAsRoot(false));
|
.runAsRoot(false));
|
||||||
assert response.getOutput().trim().equals("") : node.getId() + ": " + response;
|
assert response.getOutput().trim().equals("") : node.getId() + ": " + response;
|
||||||
try {
|
try {
|
||||||
future.get();
|
future.get();
|
||||||
|
@ -386,8 +400,7 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
|
|
||||||
protected static Template addRunScriptToTemplate(Template template) {
|
protected static Template addRunScriptToTemplate(Template template) {
|
||||||
template.getOptions().runScript(
|
template.getOptions().runScript(
|
||||||
Statements.newStatementList(AdminAccess.standard(),
|
Statements.newStatementList(AdminAccess.standard(), buildScript(template.getImage().getOperatingSystem())));
|
||||||
buildScript(template.getImage().getOperatingSystem())));
|
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,8 +412,8 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
protected void checkOsMatchesTemplate(NodeMetadata node) {
|
protected void checkOsMatchesTemplate(NodeMetadata node) {
|
||||||
if (node.getOperatingSystem() != null)
|
if (node.getOperatingSystem() != null)
|
||||||
assert node.getOperatingSystem().getFamily().equals(template.getImage().getOperatingSystem().getFamily()) : String
|
assert node.getOperatingSystem().getFamily().equals(template.getImage().getOperatingSystem().getFamily()) : String
|
||||||
.format("expecting family %s but got %s", template.getImage().getOperatingSystem().getFamily(), node
|
.format("expecting family %s but got %s", template.getImage().getOperatingSystem().getFamily(),
|
||||||
.getOperatingSystem());
|
node.getOperatingSystem());
|
||||||
}
|
}
|
||||||
|
|
||||||
void assertLocationSameOrChild(Location test, Location expected) {
|
void assertLocationSameOrChild(Location test, Location expected) {
|
||||||
|
@ -416,18 +429,18 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
initializeContextAndClient();
|
initializeContextAndClient();
|
||||||
|
|
||||||
Location existingLocation = Iterables.get(this.nodes, 0).getLocation();
|
Location existingLocation = Iterables.get(this.nodes, 0).getLocation();
|
||||||
boolean existingLocationIsAssignable = Iterables.any(client.listAssignableLocations(), Predicates
|
boolean existingLocationIsAssignable = Iterables.any(client.listAssignableLocations(),
|
||||||
.equalTo(existingLocation));
|
Predicates.equalTo(existingLocation));
|
||||||
|
|
||||||
if (existingLocationIsAssignable) {
|
if (existingLocationIsAssignable) {
|
||||||
getAnonymousLogger().info("creating another node based on existing nodes' location: " + existingLocation);
|
getAnonymousLogger().info("creating another node based on existing nodes' location: " + existingLocation);
|
||||||
template = addRunScriptToTemplate(client.templateBuilder().fromTemplate(template).locationId(
|
template = addRunScriptToTemplate(client.templateBuilder().fromTemplate(template)
|
||||||
existingLocation.getId()).build());
|
.locationId(existingLocation.getId()).build());
|
||||||
} else {
|
} else {
|
||||||
refreshTemplate();
|
refreshTemplate();
|
||||||
getAnonymousLogger().info(
|
getAnonymousLogger().info(
|
||||||
format("%s is not assignable; using template's location %s as ", existingLocation, template
|
format("%s is not assignable; using template's location %s as ", existingLocation,
|
||||||
.getLocation()));
|
template.getLocation()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, template);
|
Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, template);
|
||||||
|
@ -450,9 +463,9 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<? extends NodeMetadata, ExecResponse> runScriptWithCreds(final String group, OperatingSystem os,
|
protected Map<? extends NodeMetadata, ExecResponse> runScriptWithCreds(final String group, OperatingSystem os,
|
||||||
Credentials creds) throws RunScriptOnNodesException {
|
Credentials creds) throws RunScriptOnNodesException {
|
||||||
return client.runScriptOnNodesMatching(runningInGroup(group), buildScript(os), overrideCredentialsWith(creds)
|
return client.runScriptOnNodesMatching(runningInGroup(group), buildScript(os), overrideCredentialsWith(creds)
|
||||||
.nameTask("runScriptWithCreds"));
|
.nameTask("runScriptWithCreds"));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkNodes(Iterable<? extends NodeMetadata> nodes, String group, String taskName) throws IOException {
|
protected void checkNodes(Iterable<? extends NodeMetadata> nodes, String group, String taskName) throws IOException {
|
||||||
|
@ -479,16 +492,16 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired")
|
@Test(enabled = true, dependsOnMethods = "testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired")
|
||||||
public void testGet() throws Exception {
|
public void testGet() throws Exception {
|
||||||
Map<String, ? extends NodeMetadata> metadataMap = newLinkedHashMap(uniqueIndex(filter(client
|
Map<String, ? extends NodeMetadata> metadataMap = newLinkedHashMap(uniqueIndex(
|
||||||
.listNodesDetailsMatching(all()), and(inGroup(group), not(TERMINATED))),
|
filter(client.listNodesDetailsMatching(all()), and(inGroup(group), not(TERMINATED))),
|
||||||
new Function<NodeMetadata, String>() {
|
new Function<NodeMetadata, String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apply(NodeMetadata from) {
|
public String apply(NodeMetadata from) {
|
||||||
return from.getId();
|
return from.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
for (NodeMetadata node : nodes) {
|
for (NodeMetadata node : nodes) {
|
||||||
metadataMap.remove(node.getId());
|
metadataMap.remove(node.getId());
|
||||||
NodeMetadata metadata = client.getNodeMetadata(node.getId());
|
NodeMetadata metadata = client.getNodeMetadata(node.getId());
|
||||||
|
@ -507,7 +520,7 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
|
|
||||||
protected void assertNodeZero(Collection<? extends NodeMetadata> metadataSet) {
|
protected void assertNodeZero(Collection<? extends NodeMetadata> metadataSet) {
|
||||||
assert metadataSet.size() == 0 : format("nodes left in set: [%s] which didn't match set: [%s]", metadataSet,
|
assert metadataSet.size() == 0 : format("nodes left in set: [%s] which didn't match set: [%s]", metadataSet,
|
||||||
nodes);
|
nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testGet")
|
@Test(enabled = true, dependsOnMethods = "testGet")
|
||||||
|
@ -577,7 +590,7 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
for (NodeMetadata node : filter(client.listNodesDetailsMatching(all()), inGroup(group))) {
|
for (NodeMetadata node : filter(client.listNodesDetailsMatching(all()), inGroup(group))) {
|
||||||
assert node.getState() == NodeState.TERMINATED : node;
|
assert node.getState() == NodeState.TERMINATED : node;
|
||||||
assert context.getCredentialStore().get("node#" + node.getId()) == null : "credential should have been null for "
|
assert context.getCredentialStore().get("node#" + node.getId()) == null : "credential should have been null for "
|
||||||
+ "node#" + node.getId();
|
+ "node#" + node.getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,32 +599,33 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ServiceStats {
|
static class ServiceStats {
|
||||||
long backgroundProcessSeconds;
|
long backgroundProcessMilliseconds;
|
||||||
long socketOpenMilliseconds;
|
long socketOpenMilliseconds;
|
||||||
long reportedStartupTimeMilliseconds;
|
long reportedStartupTimeMilliseconds;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format(
|
return String.format(
|
||||||
"[backgroundProcessSeconds=%s, socketOpenMilliseconds=%s, reportedStartupTimeMilliseconds=%s]",
|
"[backgroundProcessMilliseconds=%s, socketOpenMilliseconds=%s, reportedStartupTimeMilliseconds=%s]",
|
||||||
backgroundProcessSeconds, socketOpenMilliseconds, reportedStartupTimeMilliseconds);
|
backgroundProcessMilliseconds, socketOpenMilliseconds, reportedStartupTimeMilliseconds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ServiceStats trackAvailabilityOfProcessOnNode(Supplier<ExecResponse> bgProcess, String processName,
|
protected ServiceStats trackAvailabilityOfProcessOnNode(Future<ExecResponse> bgProcess, String processName,
|
||||||
NodeMetadata node, Pattern parseReported) {
|
NodeMetadata node, Pattern parseReported) throws InterruptedException, ExecutionException {
|
||||||
ServiceStats stats = new ServiceStats();
|
ServiceStats stats = new ServiceStats();
|
||||||
long startSeconds = currentTimeMillis();
|
Stopwatch watch = new Stopwatch().start();
|
||||||
|
|
||||||
ExecResponse exec = bgProcess.get();
|
ExecResponse exec = bgProcess.get();
|
||||||
stats.backgroundProcessSeconds = (currentTimeMillis() - startSeconds) / 1000;
|
stats.backgroundProcessMilliseconds = watch.elapsedTime(TimeUnit.MILLISECONDS);
|
||||||
|
watch.reset().start();
|
||||||
|
|
||||||
IPSocket socket = new IPSocket(Iterables.get(node.getPublicAddresses(), 0), 8080);
|
IPSocket socket = new IPSocket(Iterables.get(node.getPublicAddresses(), 0), 8080);
|
||||||
assert preciseSocketTester.apply(socket) : String.format("failed to open socket %s on node %s", socket, node);
|
assert preciseSocketTester.apply(socket) : String.format("failed to open socket %s on node %s", socket, node);
|
||||||
stats.socketOpenMilliseconds = currentTimeMillis() - startSeconds;
|
stats.socketOpenMilliseconds = watch.elapsedTime(TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
exec = client.runScriptOnNode(node.getId(), "./" + processName + " tail", runAsRoot(false)
|
exec = client.runScriptOnNode(node.getId(), "./" + processName + " tail", runAsRoot(false)
|
||||||
.wrapInInitScript(false));
|
.wrapInInitScript(false));
|
||||||
|
|
||||||
Matcher matcher = parseReported.matcher(exec.getOutput());
|
Matcher matcher = parseReported.matcher(exec.getOutput());
|
||||||
if (matcher.find())
|
if (matcher.find())
|
||||||
|
@ -624,8 +638,19 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
// started in 6462ms -
|
// started in 6462ms -
|
||||||
public static final Pattern JBOSS_PATTERN = Pattern.compile("started in ([0-9]+)ms -");
|
public static final Pattern JBOSS_PATTERN = Pattern.compile("started in ([0-9]+)ms -");
|
||||||
|
|
||||||
protected ServiceStats trackAvailabilityOfJBossProcessOnNode(Supplier<ExecResponse> startProcess, NodeMetadata node) {
|
private static class FreeGeoIPLocation {
|
||||||
return trackAvailabilityOfProcessOnNode(startProcess, "jboss", node, JBOSS_PATTERN);
|
private String ip;
|
||||||
|
@SerializedName("countrycode")
|
||||||
|
private String countryCode;
|
||||||
|
@SerializedName("regioncode")
|
||||||
|
private String regionCode;
|
||||||
|
private String city;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return format("FreeGeoIPLocation [ip=%s, countryCode=%s, regionCode=%s, city=%s]", ip, countryCode,
|
||||||
|
regionCode, city);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true)
|
@Test(enabled = true)
|
||||||
|
@ -633,7 +658,7 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
|
|
||||||
String group = this.group + "s";
|
String group = this.group + "s";
|
||||||
final String configuration = Strings2.toStringAndClose(RunScriptData.class
|
final String configuration = Strings2.toStringAndClose(RunScriptData.class
|
||||||
.getResourceAsStream("/standalone-basic.xml"));
|
.getResourceAsStream("/standalone-basic.xml"));
|
||||||
try {
|
try {
|
||||||
client.destroyNodesMatching(inGroup(group));
|
client.destroyNodesMatching(inGroup(group));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -642,40 +667,71 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ImmutableMap<String, String> userMetadata = ImmutableMap.<String, String> of("Name", group);
|
ImmutableMap<String, String> userMetadata = ImmutableMap.<String, String> of("Name", group);
|
||||||
long startSeconds = currentTimeMillis();
|
Stopwatch watch = new Stopwatch().start();
|
||||||
NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1, inboundPorts(22, 8080).blockOnPort(22,
|
NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1,
|
||||||
300).userMetadata(userMetadata)));
|
inboundPorts(22, 8080).blockOnPort(22, 300).userMetadata(userMetadata)));
|
||||||
|
long createSeconds = watch.elapsedTime(TimeUnit.SECONDS);
|
||||||
|
|
||||||
final String nodeId = node.getId();
|
final String nodeId = node.getId();
|
||||||
long createSeconds = (currentTimeMillis() - startSeconds) / 1000;
|
|
||||||
|
|
||||||
checkUserMetadataInNodeEquals(node, userMetadata);
|
checkUserMetadataInNodeEquals(node, userMetadata);
|
||||||
|
|
||||||
getAnonymousLogger()
|
getAnonymousLogger().info(
|
||||||
.info(
|
format("<< available node(%s) os(%s) in %ss", node.getId(), node.getOperatingSystem(), createSeconds));
|
||||||
format("<< available node(%s) os(%s) in %ss", node.getId(), node.getOperatingSystem(),
|
|
||||||
createSeconds));
|
|
||||||
|
|
||||||
startSeconds = currentTimeMillis();
|
watch.reset().start();
|
||||||
|
|
||||||
// note this is a dependency on the template resolution so we have the right process per
|
// note this is a dependency on the template resolution so we have the
|
||||||
// operating system. moreover, we wish this to run as root, so that it can change ip
|
// right process per
|
||||||
|
// operating system. moreover, we wish this to run as root, so that it
|
||||||
|
// can change ip
|
||||||
// tables rules and setup our admin user
|
// tables rules and setup our admin user
|
||||||
client.runScriptOnNode(nodeId, installAdminUserJBossAndOpenPorts(node.getOperatingSystem()),
|
client.runScriptOnNode(nodeId, installAdminUserJBossAndOpenPorts(node.getOperatingSystem()),
|
||||||
nameTask("configure-jboss"));
|
nameTask("configure-jboss"));
|
||||||
|
|
||||||
long configureSeconds = (currentTimeMillis() - startSeconds) / 1000;
|
long configureSeconds = watch.elapsedTime(TimeUnit.SECONDS);
|
||||||
|
|
||||||
getAnonymousLogger().info(
|
getAnonymousLogger().info(
|
||||||
format("<< configured node(%s) with %s in %ss", nodeId, client.runScriptOnNode(nodeId,
|
format(
|
||||||
"java -fullversion", runAsRoot(false).wrapInInitScript(false)).getOutput().trim(),
|
"<< configured node(%s) with %s and JBoss %s in %ss",
|
||||||
configureSeconds));
|
nodeId,
|
||||||
|
exec(nodeId, "java -fullversion"),
|
||||||
|
// version of the jboss jar
|
||||||
|
exec(nodeId,
|
||||||
|
format("ls %s/bundles/org/jboss/as/osgi/configadmin/main|sed -e 's/.*-//g' -e 's/.jar//g'",
|
||||||
|
JBOSS_HOME)), configureSeconds));
|
||||||
|
|
||||||
trackAvailabilityOfJBossProcessOnNode(new Supplier<ExecResponse>() {
|
for (Entry<String, URI> download : ImmutableMap.<String, URI> of("jboss7", JBOSS7_URL, "jdk7", JDK7_URL)
|
||||||
|
.entrySet()) {
|
||||||
|
// note we cannot use nslookup until we've configured the system, as
|
||||||
|
// it may have not been present checking the address of the download
|
||||||
|
// host using the local node's DNS config
|
||||||
|
String downloadSourceIp = exec(
|
||||||
|
nodeId,
|
||||||
|
format("nslookup -query=a -timeout=5 %s|grep Address|tail -1|sed 's/.* //g'", download.getValue()
|
||||||
|
.getHost()));
|
||||||
|
if (InetAddresses.isInetAddress(downloadSourceIp)) {
|
||||||
|
getAnonymousLogger().info(
|
||||||
|
format("<< location of %s(%s) from perpective of node(%s): %s", download.getKey(), download
|
||||||
|
.getValue().getHost(), nodeId, getLocationForIp(downloadSourceIp)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// the current IP configuration could show NAT destinations, as opposed
|
||||||
|
// to the real ip address of the host, so we'll use checkip to see what
|
||||||
|
// the world view this host as.
|
||||||
|
String nodeIp = exec(nodeId, SaveHttpResponseTo.CURL + " http://checkip.amazonaws.com/");
|
||||||
|
if (InetAddresses.isInetAddress(nodeIp)) {
|
||||||
|
getAnonymousLogger()
|
||||||
|
.info(format("<< location of node(%s) from perspective of amazonaws: %s", nodeId,
|
||||||
|
getLocationForIp(nodeIp)));
|
||||||
|
}
|
||||||
|
|
||||||
|
trackAvailabilityOfProcessOnNode(context.utils().userExecutor().submit(new Callable<ExecResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public ExecResponse get() {
|
public ExecResponse call() {
|
||||||
return client.runScriptOnNode(nodeId, startJBoss(configuration), runAsRoot(false).blockOnComplete(false)
|
return client.runScriptOnNode(nodeId, startJBoss(configuration), runAsRoot(false).blockOnComplete(false)
|
||||||
.nameTask("jboss"));
|
.nameTask("jboss"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -683,14 +739,14 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
return "initial start of jboss";
|
return "initial start of jboss";
|
||||||
}
|
}
|
||||||
|
|
||||||
}, node);
|
}), "jboss", node, JBOSS_PATTERN);
|
||||||
|
|
||||||
client.runScriptOnNode(nodeId, "./jboss stop", runAsRoot(false).wrapInInitScript(false));
|
client.runScriptOnNode(nodeId, "./jboss stop", runAsRoot(false).wrapInInitScript(false));
|
||||||
|
|
||||||
trackAvailabilityOfJBossProcessOnNode(new Supplier<ExecResponse>() {
|
trackAvailabilityOfProcessOnNode(context.utils().userExecutor().submit(new Callable<ExecResponse>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExecResponse get() {
|
public ExecResponse call() {
|
||||||
return client.runScriptOnNode(nodeId, "./jboss start", runAsRoot(false).wrapInInitScript(false));
|
return client.runScriptOnNode(nodeId, "./jboss start", runAsRoot(false).wrapInInitScript(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -699,7 +755,7 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
return "warm start of jboss";
|
return "warm start of jboss";
|
||||||
}
|
}
|
||||||
|
|
||||||
}, node);
|
}), "jboss", node, JBOSS_PATTERN);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
client.destroyNodesMatching(inGroup(group));
|
client.destroyNodesMatching(inGroup(group));
|
||||||
|
@ -707,9 +763,24 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getLocationForIp(String ip) throws IOException {
|
||||||
|
InputStream json = context.utils().http().get(URI.create("http://freegeoip.appspot.com/" + ip));
|
||||||
|
String text = null;
|
||||||
|
if (json != null && (text = Strings2.toStringAndClose(json)).indexOf("}") != -1) {
|
||||||
|
return context.utils().json().fromJson(text, FreeGeoIPLocation.class).toString();
|
||||||
|
} else {
|
||||||
|
getAnonymousLogger().warning("could not get info on ip " + ip + "; check freegeoip");
|
||||||
|
}
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String exec(final String nodeId, String command) {
|
||||||
|
return client.runScriptOnNode(nodeId, command, runAsRoot(false).wrapInInitScript(false)).getOutput().trim();
|
||||||
|
}
|
||||||
|
|
||||||
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||||
assert node.getUserMetadata().equals(userMetadata) : String.format("node userMetadata did not match %s %s",
|
assert node.getUserMetadata().equals(userMetadata) : String.format("node userMetadata did not match %s %s",
|
||||||
userMetadata, node);
|
userMetadata, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testListImages() throws Exception {
|
public void testListImages() throws Exception {
|
||||||
|
@ -728,26 +799,26 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
assert location != location.getParent() : location;
|
assert location != location.getParent() : location;
|
||||||
assert location.getScope() != null : location;
|
assert location.getScope() != null : location;
|
||||||
switch (location.getScope()) {
|
switch (location.getScope()) {
|
||||||
case PROVIDER:
|
case PROVIDER:
|
||||||
assertProvider(location);
|
assertProvider(location);
|
||||||
break;
|
break;
|
||||||
case REGION:
|
case REGION:
|
||||||
assertProvider(location.getParent());
|
assertProvider(location.getParent());
|
||||||
break;
|
break;
|
||||||
case ZONE:
|
case ZONE:
|
||||||
Location provider = location.getParent().getParent();
|
Location provider = location.getParent().getParent();
|
||||||
// zone can be a direct descendant of provider
|
// zone can be a direct descendant of provider
|
||||||
if (provider == null)
|
if (provider == null)
|
||||||
provider = location.getParent();
|
provider = location.getParent();
|
||||||
assertProvider(provider);
|
assertProvider(provider);
|
||||||
break;
|
break;
|
||||||
case HOST:
|
case HOST:
|
||||||
Location provider2 = location.getParent().getParent().getParent();
|
Location provider2 = location.getParent().getParent().getParent();
|
||||||
// zone can be a direct descendant of provider
|
// zone can be a direct descendant of provider
|
||||||
if (provider2 == null)
|
if (provider2 == null)
|
||||||
provider2 = location.getParent().getParent();
|
provider2 = location.getParent().getParent();
|
||||||
assertProvider(provider2);
|
assertProvider(provider2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -770,7 +841,7 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
assert node.getState() != NodeState.RUNNING : node;
|
assert node.getState() != NodeState.RUNNING : node;
|
||||||
long duration = (currentTimeMillis() - time) / 1000;
|
long duration = (currentTimeMillis() - time) / 1000;
|
||||||
assert duration < nonBlockDurationSeconds : format("duration(%d) longer than expected(%d) seconds! ",
|
assert duration < nonBlockDurationSeconds : format("duration(%d) longer than expected(%d) seconds! ",
|
||||||
duration, nonBlockDurationSeconds);
|
duration, nonBlockDurationSeconds);
|
||||||
} finally {
|
} finally {
|
||||||
client.destroyNodesMatching(inGroup(group));
|
client.destroyNodesMatching(inGroup(group));
|
||||||
}
|
}
|
||||||
|
@ -837,8 +908,9 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
ExecResponse hello = ssh.exec("echo hello");
|
ExecResponse hello = ssh.exec("echo hello");
|
||||||
assertEquals(hello.getOutput().trim(), "hello");
|
assertEquals(hello.getOutput().trim(), "hello");
|
||||||
ExecResponse exec = ssh.exec("java -version");
|
ExecResponse exec = ssh.exec("java -version");
|
||||||
assert exec.getError().indexOf("1.6") != -1 || exec.getOutput().indexOf("1.6") != -1 : exec + "\n"
|
assert exec.getError().indexOf("1.7") != -1 || exec.getOutput().indexOf("1.7") != -1 : exec + "\n"
|
||||||
+ ssh.exec("cat /tmp/" + taskName + "/stdout.log /tmp/" + taskName + "/stderr.log");
|
+ ssh.exec("cat /tmp/" + taskName + "/" + taskName + ".sh /tmp/" + taskName + "/stdout.log /tmp/"
|
||||||
|
+ taskName + "/stderr.log");
|
||||||
} finally {
|
} finally {
|
||||||
if (ssh != null)
|
if (ssh != null)
|
||||||
ssh.disconnect();
|
ssh.disconnect();
|
||||||
|
|
|
@ -39,6 +39,7 @@ import com.google.common.base.Splitter;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableList.Builder;
|
import com.google.common.collect.ImmutableList.Builder;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -46,7 +47,12 @@ import com.google.common.collect.ImmutableMap;
|
||||||
*/
|
*/
|
||||||
public class RunScriptData {
|
public class RunScriptData {
|
||||||
|
|
||||||
private static String jbossHome = "/usr/local/jboss";
|
public static final URI JDK7_URL = URI.create(System.getProperty("test.jdk7-url",
|
||||||
|
"http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-x64.tar.gz"));
|
||||||
|
public static final URI JBOSS7_URL = URI.create(System.getProperty("test.jboss7-url",//
|
||||||
|
"http://download.jboss.org/jbossas/7.0/jboss-as-7.0.2.Final/jboss-as-web-7.0.2.Final.tar.gz"));
|
||||||
|
|
||||||
|
public static String JBOSS_HOME = "/usr/local/jboss";
|
||||||
|
|
||||||
public static Statement installJavaAndCurl(OperatingSystem os) {
|
public static Statement installJavaAndCurl(OperatingSystem os) {
|
||||||
if (os == null || OperatingSystemPredicates.supportsApt().apply(os))
|
if (os == null || OperatingSystemPredicates.supportsApt().apply(os))
|
||||||
|
@ -72,22 +78,21 @@ public class RunScriptData {
|
||||||
AdminAccess.builder().adminUsername("web").build(),//
|
AdminAccess.builder().adminUsername("web").build(),//
|
||||||
installJavaAndCurl(os),//
|
installJavaAndCurl(os),//
|
||||||
authorizePortsInIpTables(22, 8080),//
|
authorizePortsInIpTables(22, 8080),//
|
||||||
extractTargzIntoDirectory(URI.create(System.getProperty("test.jboss-url",//
|
extractTargzIntoDirectory(JBOSS7_URL, "/usr/local"),//
|
||||||
"http://download.jboss.org/jbossas/7.0/jboss-as-7.0.2.Final/jboss-as-web-7.0.2.Final.tar.gz")), "/usr/local"),//
|
exec("{md} " + JBOSS_HOME), exec("mv /usr/local/jboss-*/* " + JBOSS_HOME),//
|
||||||
exec("{md} " + jbossHome), exec("mv /usr/local/jboss-*/* " + jbossHome),//
|
|
||||||
changeStandaloneConfigToListenOnAllIPAddresses(),
|
changeStandaloneConfigToListenOnAllIPAddresses(),
|
||||||
exec("chmod -R oug+r+w " + jbossHome),
|
exec("chmod -R oug+r+w " + JBOSS_HOME),
|
||||||
exec("chown -R web " + jbossHome));
|
exec("chown -R web " + JBOSS_HOME));
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE do not name this the same as your login user, or the init process may kill you!
|
// NOTE do not name this the same as your login user, or the init process may kill you!
|
||||||
public static InitBuilder startJBoss(String configuration) {
|
public static InitBuilder startJBoss(String configuration) {
|
||||||
return new InitBuilder(
|
return new InitBuilder(
|
||||||
"jboss",
|
"jboss",
|
||||||
jbossHome,
|
JBOSS_HOME,
|
||||||
jbossHome,
|
JBOSS_HOME,
|
||||||
ImmutableMap.of("jbossHome", jbossHome),
|
ImmutableMap.of("jbossHome", JBOSS_HOME),
|
||||||
ImmutableList.<Statement>of(appendFile(jbossHome + "/standalone/configuration/standalone-custom.xml", Splitter.on('\n').split(configuration))),
|
ImmutableList.<Statement>of(appendFile(JBOSS_HOME + "/standalone/configuration/standalone-custom.xml", Splitter.on('\n').split(configuration))),
|
||||||
ImmutableList
|
ImmutableList
|
||||||
.<Statement> of(interpret(new StringBuilder().append("java ").append(' ')
|
.<Statement> of(interpret(new StringBuilder().append("java ").append(' ')
|
||||||
.append("-server -Xms128m -Xmx128m -XX:MaxPermSize=128m -Djava.net.preferIPv4Stack=true -XX:+UseFastAccessorMethods -XX:+TieredCompilation -Xverify:none -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000").append(' ')
|
.append("-server -Xms128m -Xmx128m -XX:MaxPermSize=128m -Djava.net.preferIPv4Stack=true -XX:+UseFastAccessorMethods -XX:+TieredCompilation -Xverify:none -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000").append(' ')
|
||||||
|
@ -122,30 +127,44 @@ public class RunScriptData {
|
||||||
private static Statement changeStandaloneConfigToListenOnAllIPAddresses() {
|
private static Statement changeStandaloneConfigToListenOnAllIPAddresses() {
|
||||||
return exec(format(
|
return exec(format(
|
||||||
"(cd %s/standalone/configuration && sed 's~inet-address value=.*/~any-address/~g' standalone.xml > standalone.xml.new && mv standalone.xml.new standalone.xml)",
|
"(cd %s/standalone/configuration && sed 's~inet-address value=.*/~any-address/~g' standalone.xml > standalone.xml.new && mv standalone.xml.new standalone.xml)",
|
||||||
jbossHome));
|
JBOSS_HOME));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final ImmutableSet<String> exportJavaHomeAndAddToPath = ImmutableSet.of(
|
||||||
|
"export JAVA_HOME=/usr/local/jdk", "export PATH=$JAVA_HOME/bin:$PATH");
|
||||||
|
|
||||||
|
public static final Statement JDK7_INSTALL_TGZ = newStatementList(//
|
||||||
|
exec("{md} /usr/local/jdk"), extractTargzIntoDirectory(JDK7_URL, "/usr/local"),//
|
||||||
|
exec("mv /usr/local/jdk1.7*/* /usr/local/jdk/"),//
|
||||||
|
exec("test -n \"$SUDO_USER\" && "), appendFile("/home/$SUDO_USER/.bashrc", exportJavaHomeAndAddToPath),//
|
||||||
|
appendFile("/etc/bashrc", exportJavaHomeAndAddToPath),//
|
||||||
|
appendFile("$HOME/.bashrc", exportJavaHomeAndAddToPath),//
|
||||||
|
appendFile("/etc/skel/.bashrc", exportJavaHomeAndAddToPath),//
|
||||||
|
// TODO:
|
||||||
|
// eventhough we are setting the above, sometimes images (ex.
|
||||||
|
// cloudservers ubuntu) kick out of .bashrc (ex. [ -z "$PS1" ] &&
|
||||||
|
// return), for this reason, we should also explicitly link.
|
||||||
|
// A better way would be to update using alternatives or the like
|
||||||
|
exec("ln -fs /usr/local/jdk/bin/java /usr/bin/java"));
|
||||||
|
|
||||||
public static String aptInstall = "apt-get install -f -y -qq --force-yes";
|
public static String aptInstall = "apt-get install -f -y -qq --force-yes";
|
||||||
|
|
||||||
|
|
||||||
public static final Statement APT_RUN_SCRIPT = newStatementList(//
|
public static final Statement APT_RUN_SCRIPT = newStatementList(//
|
||||||
normalizeHostAndDNSConfig(),//
|
normalizeHostAndDNSConfig(),//
|
||||||
exec("apt-get update -qq"),
|
exec("which curl >&- 2>&-|| " + aptInstall + " curl"),//
|
||||||
exec("which curl || " + aptInstall + " curl"),//
|
exec("which nslookup >&- 2>&-|| " + aptInstall + " dnsutils"),//
|
||||||
exec(aptInstall + " openjdk-6-jdk"),//
|
JDK7_INSTALL_TGZ);
|
||||||
exec("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> $HOME/.bashrc"));
|
|
||||||
|
|
||||||
public static String yumInstall = "yum --nogpgcheck -y install";
|
public static String yumInstall = "yum --nogpgcheck -y install";
|
||||||
|
|
||||||
public static final Statement YUM_RUN_SCRIPT = newStatementList(//
|
public static final Statement YUM_RUN_SCRIPT = newStatementList(//
|
||||||
normalizeHostAndDNSConfig(),//
|
normalizeHostAndDNSConfig(),//
|
||||||
exec("which curl || " + yumInstall + " curl"),//
|
exec("which curl >&- 2>&-|| " + yumInstall + " curl"),//
|
||||||
exec(yumInstall + " java-1.6.0-openjdk-devel"),//
|
exec("which nslookup >&- 2>&-|| " + yumInstall + " bind-utils"),//
|
||||||
exec("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /etc/bashrc"));
|
JDK7_INSTALL_TGZ);
|
||||||
|
|
||||||
public static final Statement ZYPPER_RUN_SCRIPT = newStatementList(//
|
public static final Statement ZYPPER_RUN_SCRIPT = newStatementList(//
|
||||||
normalizeHostAndDNSConfig(),//
|
normalizeHostAndDNSConfig(),//
|
||||||
exec("which curl || zypper install curl"),//
|
exec("which curl >&- 2>&-|| zypper install curl"),//
|
||||||
exec("zypper install java-1.6.0-openjdk"),//
|
JDK7_INSTALL_TGZ);
|
||||||
exec("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /etc/bashrc"));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
|
||||||
expect(factory.create(new IPSocket("144.175.1.1", 22), new Credentials("root", "password1"))).andReturn(
|
expect(factory.create(new IPSocket("144.175.1.1", 22), new Credentials("root", "password1"))).andReturn(
|
||||||
client1);
|
client1);
|
||||||
expect(factory.create(new IPSocket("144.175.1.1", 22), new Credentials("web", "privateKey"))).andReturn(
|
expect(factory.create(new IPSocket("144.175.1.1", 22), new Credentials("web", "privateKey"))).andReturn(
|
||||||
client1New).times(6);
|
client1New).times(10);
|
||||||
runScriptAndService(client1, client1New);
|
runScriptAndService(client1, client1New);
|
||||||
|
|
||||||
expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("root", "password2"))).andReturn(
|
expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("root", "password2"))).andReturn(
|
||||||
|
@ -257,6 +257,22 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
|
||||||
// note we have to reconnect here, as we updated the login user.
|
// note we have to reconnect here, as we updated the login user.
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
|
|
||||||
|
clientNew.connect();
|
||||||
|
expect(clientNew.exec("ls /usr/local/jboss/bundles/org/jboss/as/osgi/configadmin/main|sed -e 's/.*-//g' -e 's/.jar//g'\n")).andReturn(EXEC_GOOD);
|
||||||
|
clientNew.disconnect();
|
||||||
|
|
||||||
|
clientNew.connect();
|
||||||
|
expect(clientNew.exec("nslookup -query=a -timeout=5 download.jboss.org|grep Address|tail -1|sed 's/.* //g'\n")).andReturn(EXEC_GOOD);
|
||||||
|
clientNew.disconnect();
|
||||||
|
|
||||||
|
clientNew.connect();
|
||||||
|
expect(clientNew.exec("nslookup -query=a -timeout=5 download.oracle.com|grep Address|tail -1|sed 's/.* //g'\n")).andReturn(EXEC_GOOD);
|
||||||
|
clientNew.disconnect();
|
||||||
|
|
||||||
|
clientNew.connect();
|
||||||
|
expect(clientNew.exec("curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 http://checkip.amazonaws.com/\n")).andReturn(EXEC_GOOD);
|
||||||
|
clientNew.disconnect();
|
||||||
|
|
||||||
clientNew.connect();
|
clientNew.connect();
|
||||||
expect(clientNew.exec("java -fullversion\n")).andReturn(EXEC_GOOD);
|
expect(clientNew.exec("java -fullversion\n")).andReturn(EXEC_GOOD);
|
||||||
clientNew.disconnect();
|
clientNew.disconnect();
|
||||||
|
@ -328,7 +344,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
|
||||||
client.connect();
|
client.connect();
|
||||||
|
|
||||||
expect(client.exec("echo hello")).andReturn(new ExecResponse("hello", "", 0));
|
expect(client.exec("echo hello")).andReturn(new ExecResponse("hello", "", 0));
|
||||||
expect(client.exec("java -version")).andReturn(new ExecResponse("", "1.6", 0));
|
expect(client.exec("java -version")).andReturn(new ExecResponse("", "1.7", 0));
|
||||||
|
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,9 +84,9 @@ root ALL = (ALL) ALL
|
||||||
%wheel ALL = (ALL) NOPASSWD:ALL
|
%wheel ALL = (ALL) NOPASSWD:ALL
|
||||||
END_OF_FILE
|
END_OF_FILE
|
||||||
chmod 0440 /etc/sudoers
|
chmod 0440 /etc/sudoers
|
||||||
mkdir -p /home/users/defaultAdminUsername
|
mkdir -p /home/users
|
||||||
groupadd -f wheel
|
groupadd -f wheel
|
||||||
useradd -s /bin/bash -g wheel -d /home/users/defaultAdminUsername -p 'crypt(randompassword)' defaultAdminUsername
|
useradd -s /bin/bash -g wheel -m -d /home/users/defaultAdminUsername -p 'crypt(randompassword)' defaultAdminUsername
|
||||||
mkdir -p /home/users/defaultAdminUsername/.ssh
|
mkdir -p /home/users/defaultAdminUsername/.ssh
|
||||||
cat >> /home/users/defaultAdminUsername/.ssh/authorized_keys <<'END_OF_FILE'
|
cat >> /home/users/defaultAdminUsername/.ssh/authorized_keys <<'END_OF_FILE'
|
||||||
publicKey
|
publicKey
|
||||||
|
@ -101,10 +101,29 @@ awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(randompassword)' 'BEGIN {
|
||||||
test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow
|
test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow
|
||||||
grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts
|
grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts
|
||||||
nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf
|
nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf
|
||||||
apt-get update -qq
|
which curl >&- 2>&-|| apt-get install -f -y -qq --force-yes curl
|
||||||
which curl || apt-get install -f -y -qq --force-yes curl
|
which nslookup >&- 2>&-|| apt-get install -f -y -qq --force-yes dnsutils
|
||||||
apt-get install -f -y -qq --force-yes openjdk-6-jdk
|
mkdir -p /usr/local/jdk
|
||||||
echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> $HOME/.bashrc
|
curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-x64.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -)
|
||||||
|
mv /usr/local/jdk1.7*/* /usr/local/jdk/
|
||||||
|
test -n "$SUDO_USER" &&
|
||||||
|
cat >> /home/$SUDO_USER/.bashrc <<'END_OF_FILE'
|
||||||
|
export JAVA_HOME=/usr/local/jdk
|
||||||
|
export PATH=$JAVA_HOME/bin:$PATH
|
||||||
|
END_OF_FILE
|
||||||
|
cat >> /etc/bashrc <<'END_OF_FILE'
|
||||||
|
export JAVA_HOME=/usr/local/jdk
|
||||||
|
export PATH=$JAVA_HOME/bin:$PATH
|
||||||
|
END_OF_FILE
|
||||||
|
cat >> $HOME/.bashrc <<'END_OF_FILE'
|
||||||
|
export JAVA_HOME=/usr/local/jdk
|
||||||
|
export PATH=$JAVA_HOME/bin:$PATH
|
||||||
|
END_OF_FILE
|
||||||
|
cat >> /etc/skel/.bashrc <<'END_OF_FILE'
|
||||||
|
export JAVA_HOME=/usr/local/jdk
|
||||||
|
export PATH=$JAVA_HOME/bin:$PATH
|
||||||
|
END_OF_FILE
|
||||||
|
ln -fs /usr/local/jdk/bin/java /usr/bin/java
|
||||||
|
|
||||||
END_OF_SCRIPT
|
END_OF_SCRIPT
|
||||||
|
|
||||||
|
|
|
@ -84,9 +84,9 @@ root ALL = (ALL) ALL
|
||||||
%wheel ALL = (ALL) NOPASSWD:ALL
|
%wheel ALL = (ALL) NOPASSWD:ALL
|
||||||
END_OF_FILE
|
END_OF_FILE
|
||||||
chmod 0440 /etc/sudoers
|
chmod 0440 /etc/sudoers
|
||||||
mkdir -p /home/users/web
|
mkdir -p /home/users
|
||||||
groupadd -f wheel
|
groupadd -f wheel
|
||||||
useradd -s /bin/bash -g wheel -d /home/users/web -p 'crypt(randompassword)' web
|
useradd -s /bin/bash -g wheel -m -d /home/users/web -p 'crypt(randompassword)' web
|
||||||
mkdir -p /home/users/web/.ssh
|
mkdir -p /home/users/web/.ssh
|
||||||
cat >> /home/users/web/.ssh/authorized_keys <<'END_OF_FILE'
|
cat >> /home/users/web/.ssh/authorized_keys <<'END_OF_FILE'
|
||||||
publicKey
|
publicKey
|
||||||
|
@ -101,10 +101,29 @@ awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(randompassword)' 'BEGIN {
|
||||||
test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow
|
test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow
|
||||||
grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts
|
grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts
|
||||||
nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf
|
nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf
|
||||||
apt-get update -qq
|
which curl >&- 2>&-|| apt-get install -f -y -qq --force-yes curl
|
||||||
which curl || apt-get install -f -y -qq --force-yes curl
|
which nslookup >&- 2>&-|| apt-get install -f -y -qq --force-yes dnsutils
|
||||||
apt-get install -f -y -qq --force-yes openjdk-6-jdk
|
mkdir -p /usr/local/jdk
|
||||||
echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> $HOME/.bashrc
|
curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-x64.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -)
|
||||||
|
mv /usr/local/jdk1.7*/* /usr/local/jdk/
|
||||||
|
test -n "$SUDO_USER" &&
|
||||||
|
cat >> /home/$SUDO_USER/.bashrc <<'END_OF_FILE'
|
||||||
|
export JAVA_HOME=/usr/local/jdk
|
||||||
|
export PATH=$JAVA_HOME/bin:$PATH
|
||||||
|
END_OF_FILE
|
||||||
|
cat >> /etc/bashrc <<'END_OF_FILE'
|
||||||
|
export JAVA_HOME=/usr/local/jdk
|
||||||
|
export PATH=$JAVA_HOME/bin:$PATH
|
||||||
|
END_OF_FILE
|
||||||
|
cat >> $HOME/.bashrc <<'END_OF_FILE'
|
||||||
|
export JAVA_HOME=/usr/local/jdk
|
||||||
|
export PATH=$JAVA_HOME/bin:$PATH
|
||||||
|
END_OF_FILE
|
||||||
|
cat >> /etc/skel/.bashrc <<'END_OF_FILE'
|
||||||
|
export JAVA_HOME=/usr/local/jdk
|
||||||
|
export PATH=$JAVA_HOME/bin:$PATH
|
||||||
|
END_OF_FILE
|
||||||
|
ln -fs /usr/local/jdk/bin/java /usr/bin/java
|
||||||
iptables -I INPUT 1 -p tcp --dport 22 -j ACCEPT
|
iptables -I INPUT 1 -p tcp --dport 22 -j ACCEPT
|
||||||
iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT
|
iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT
|
||||||
iptables-save
|
iptables-save
|
||||||
|
|
|
@ -80,10 +80,29 @@ END_OF_SCRIPT
|
||||||
cd $INSTANCE_HOME
|
cd $INSTANCE_HOME
|
||||||
grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts
|
grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts
|
||||||
nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf
|
nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf
|
||||||
apt-get update -qq
|
which curl >&- 2>&-|| apt-get install -f -y -qq --force-yes curl
|
||||||
which curl || apt-get install -f -y -qq --force-yes curl
|
which nslookup >&- 2>&-|| apt-get install -f -y -qq --force-yes dnsutils
|
||||||
apt-get install -f -y -qq --force-yes openjdk-6-jdk
|
mkdir -p /usr/local/jdk
|
||||||
echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> $HOME/.bashrc
|
curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-x64.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -)
|
||||||
|
mv /usr/local/jdk1.7*/* /usr/local/jdk/
|
||||||
|
test -n "$SUDO_USER" &&
|
||||||
|
cat >> /home/$SUDO_USER/.bashrc <<'END_OF_FILE'
|
||||||
|
export JAVA_HOME=/usr/local/jdk
|
||||||
|
export PATH=$JAVA_HOME/bin:$PATH
|
||||||
|
END_OF_FILE
|
||||||
|
cat >> /etc/bashrc <<'END_OF_FILE'
|
||||||
|
export JAVA_HOME=/usr/local/jdk
|
||||||
|
export PATH=$JAVA_HOME/bin:$PATH
|
||||||
|
END_OF_FILE
|
||||||
|
cat >> $HOME/.bashrc <<'END_OF_FILE'
|
||||||
|
export JAVA_HOME=/usr/local/jdk
|
||||||
|
export PATH=$JAVA_HOME/bin:$PATH
|
||||||
|
END_OF_FILE
|
||||||
|
cat >> /etc/skel/.bashrc <<'END_OF_FILE'
|
||||||
|
export JAVA_HOME=/usr/local/jdk
|
||||||
|
export PATH=$JAVA_HOME/bin:$PATH
|
||||||
|
END_OF_FILE
|
||||||
|
ln -fs /usr/local/jdk/bin/java /usr/bin/java
|
||||||
|
|
||||||
END_OF_SCRIPT
|
END_OF_SCRIPT
|
||||||
|
|
||||||
|
|
|
@ -84,9 +84,9 @@ root ALL = (ALL) ALL
|
||||||
%wheel ALL = (ALL) NOPASSWD:ALL
|
%wheel ALL = (ALL) NOPASSWD:ALL
|
||||||
END_OF_FILE
|
END_OF_FILE
|
||||||
chmod 0440 /etc/sudoers
|
chmod 0440 /etc/sudoers
|
||||||
mkdir -p /home/users/foo
|
mkdir -p /home/users
|
||||||
groupadd -f wheel
|
groupadd -f wheel
|
||||||
useradd -s /bin/bash -g wheel -d /home/users/foo -p 'crypt(randompassword)' foo
|
useradd -s /bin/bash -g wheel -m -d /home/users/foo -p 'crypt(randompassword)' foo
|
||||||
mkdir -p /home/users/foo/.ssh
|
mkdir -p /home/users/foo/.ssh
|
||||||
cat >> /home/users/foo/.ssh/authorized_keys <<'END_OF_FILE'
|
cat >> /home/users/foo/.ssh/authorized_keys <<'END_OF_FILE'
|
||||||
publicKey
|
publicKey
|
||||||
|
|
Loading…
Reference in New Issue