mirror of https://github.com/apache/jclouds.git
Merge pull request #1132 from jclouds/literal-statement
get compute live test back in business
This commit is contained in:
commit
b0703a6976
|
@ -45,7 +45,7 @@ public class CloudSigmaComputeServiceLiveTest extends BaseComputeServiceLiveTest
|
|||
|
||||
// cloudsigma does not support metadata
|
||||
@Override
|
||||
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
assert node.getUserMetadata().equals(ImmutableMap.<String, String> of()) : String.format(
|
||||
"node userMetadata did not match %s %s", userMetadata, node);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class CloudStackComputeServiceLiveTest extends BaseComputeServiceLiveTest
|
|||
|
||||
// cloudstack does not support metadata
|
||||
@Override
|
||||
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
assert node.getUserMetadata().equals(ImmutableMap.<String, String> of()) : String.format(
|
||||
"node userMetadata did not match %s %s", userMetadata, node);
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
|||
|
||||
// normal ec2 does not support metadata
|
||||
@Override
|
||||
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
assert node.getUserMetadata().equals(ImmutableMap.<String, String> of()) : String.format(
|
||||
"node userMetadata did not match %s %s", userMetadata, node);
|
||||
}
|
||||
|
|
|
@ -349,6 +349,9 @@ public interface ComputeService {
|
|||
* @see org.jclouds.compute.predicates.NodePredicates#runningInGroup(String)
|
||||
* @see org.jclouds.scriptbuilder.domain.Statements
|
||||
*/
|
||||
@Beta
|
||||
ListenableFuture<ExecResponse> submitScriptOnNode(String id, String runScript, RunScriptOptions options);
|
||||
|
||||
@Beta
|
||||
ListenableFuture<ExecResponse> submitScriptOnNode(String id, Statement runScript, RunScriptOptions options);
|
||||
|
||||
|
@ -377,4 +380,5 @@ public interface ComputeService {
|
|||
@Beta
|
||||
Optional<ImageExtension> getImageExtension();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -512,7 +512,7 @@ public class BaseComputeService implements ComputeService {
|
|||
@Override
|
||||
public Map<NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<NodeMetadata> filter, String runScript)
|
||||
throws RunScriptOnNodesException {
|
||||
return runScriptOnNodesMatching(filter, Statements.exec(checkNotNull(runScript, "runScript")));
|
||||
return runScriptOnNodesMatching(filter, Statements.literal(checkNotNull(runScript, "runScript")));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -527,7 +527,7 @@ public class BaseComputeService implements ComputeService {
|
|||
@Override
|
||||
public Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<NodeMetadata> filter,
|
||||
String runScript, RunScriptOptions options) throws RunScriptOnNodesException {
|
||||
return runScriptOnNodesMatching(filter, Statements.exec(checkNotNull(runScript, "runScript")), options);
|
||||
return runScriptOnNodesMatching(filter, Statements.literal(checkNotNull(runScript, "runScript")), options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -585,7 +585,7 @@ public class BaseComputeService implements ComputeService {
|
|||
*/
|
||||
@Override
|
||||
public ExecResponse runScriptOnNode(String id, String runScript, RunScriptOptions options) {
|
||||
return runScriptOnNode(id, Statements.exec(checkNotNull(runScript, "runScript")), options);
|
||||
return runScriptOnNode(id, Statements.literal(checkNotNull(runScript, "runScript")), options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -614,6 +614,14 @@ public class BaseComputeService implements ComputeService {
|
|||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ListenableFuture<ExecResponse> submitScriptOnNode(String id, String runScript, RunScriptOptions options) {
|
||||
return submitScriptOnNode(id, Statements.literal(checkNotNull(runScript, "runScript")), options);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.compute;
|
|||
|
||||
import static org.jclouds.scriptbuilder.domain.Statements.exec;
|
||||
import static org.jclouds.scriptbuilder.domain.Statements.extractTargzAndFlattenIntoDirectory;
|
||||
import static org.jclouds.scriptbuilder.domain.Statements.literal;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
|
@ -35,7 +36,7 @@ import org.jclouds.scriptbuilder.statements.login.AdminAccess;
|
|||
public class JettyStatements {
|
||||
|
||||
public static final URI JETTY_URL = URI.create(System.getProperty("test.jetty-url",//
|
||||
"http://download.eclipse.org/jetty/8.1.5.v20120716/dist/jetty-distribution-8.1.5.v20120716.tar.gz"));
|
||||
"http://download.eclipse.org/jetty/8.1.8.v20121106/dist/jetty-distribution-8.1.8.v20121106.tar.gz"));
|
||||
|
||||
public static final String JETTY_HOME = "/usr/local/jetty";
|
||||
|
||||
|
@ -56,19 +57,20 @@ public class JettyStatements {
|
|||
|
||||
private static Statement authorizePortInIpTables() {
|
||||
return new StatementList(
|
||||
exec("iptables -I INPUT 1 -p tcp --dport " + port + " -j ACCEPT"),
|
||||
exec("iptables-save"));
|
||||
exec("iptables -I INPUT 1 -p tcp --dport " + port + " -j ACCEPT"),
|
||||
exec("iptables-save"));
|
||||
}
|
||||
|
||||
public static Statement start() {
|
||||
return new StatementList(
|
||||
exec("cd " + JETTY_HOME),
|
||||
exec("./bin/jetty.sh start"));
|
||||
literal("cd " + JETTY_HOME),
|
||||
literal("nohup java -jar start.jar jetty.port=" + port + " > start.out 2> start.err < /dev/null &"),
|
||||
literal("test $? && sleep 1")); // in case it is slow starting the proc
|
||||
}
|
||||
|
||||
public static Statement stop() {
|
||||
return new StatementList(
|
||||
exec("cd " + JETTY_HOME),
|
||||
exec("./bin/jetty.sh stop"));
|
||||
literal("cd " + JETTY_HOME),
|
||||
literal("./bin/jetty.sh stop"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -319,8 +319,13 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
|
|||
expect(clientNew.exec("java -fullversion\n")).andReturn(EXEC_GOOD);
|
||||
clientNew.disconnect();
|
||||
|
||||
String startJetty = new StringBuilder()
|
||||
.append("cd /usr/local/jetty").append('\n')
|
||||
.append("nohup java -jar start.jar jetty.port=8080 > start.out 2> start.err < /dev/null &").append('\n')
|
||||
.append("test $? && sleep 1").append('\n').toString();
|
||||
|
||||
clientNew.connect();
|
||||
expect(clientNew.exec("cd /usr/local/jetty\n./bin/jetty.sh start\n")).andReturn(EXEC_GOOD);
|
||||
expect(clientNew.exec(startJetty)).andReturn(EXEC_GOOD);
|
||||
clientNew.disconnect();
|
||||
|
||||
clientNew.connect();
|
||||
|
@ -328,7 +333,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
|
|||
clientNew.disconnect();
|
||||
|
||||
clientNew.connect();
|
||||
expect(clientNew.exec("cd /usr/local/jetty\n./bin/jetty.sh start\n")).andReturn(EXEC_GOOD);
|
||||
expect(clientNew.exec(startJetty)).andReturn(EXEC_GOOD);
|
||||
clientNew.disconnect();
|
||||
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -103,6 +103,7 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.net.HostAndPort;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
@ -225,7 +226,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
|||
assert good.credential != null : nodes;
|
||||
|
||||
for (Entry<? extends NodeMetadata, ExecResponse> response : client.runScriptOnNodesMatching(
|
||||
runningInGroup(group), Statements.exec("hostname"),
|
||||
runningInGroup(group), "hostname",
|
||||
wrapInInitScript(false).runAsRoot(false).overrideLoginCredentials(good)).entrySet()) {
|
||||
checkResponseEqualsHostname(response.getValue(), response.getKey());
|
||||
}
|
||||
|
@ -289,7 +290,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
|||
|
||||
@Test(enabled = false)
|
||||
public void weCanCancelTasks(NodeMetadata node) throws InterruptedException, ExecutionException {
|
||||
ListenableFuture<ExecResponse> future = client.submitScriptOnNode(node.getId(), Statements.exec("sleep 300"),
|
||||
ListenableFuture<ExecResponse> future = client.submitScriptOnNode(node.getId(), "sleep 300",
|
||||
nameTask("sleeper").runAsRoot(false));
|
||||
ExecResponse response = null;
|
||||
try {
|
||||
|
@ -297,11 +298,11 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
|||
fail(node.getId() + ": " + response);
|
||||
} catch (TimeoutException e) {
|
||||
assert !future.isDone();
|
||||
response = client.runScriptOnNode(node.getId(), Statements.exec("/tmp/init-sleeper status"),
|
||||
response = client.runScriptOnNode(node.getId(), "/tmp/init-sleeper status",
|
||||
wrapInInitScript(false).runAsRoot(false));
|
||||
assert !response.getOutput().trim().equals("") : node.getId() + ": " + response;
|
||||
future.cancel(true);
|
||||
response = client.runScriptOnNode(node.getId(), Statements.exec("/tmp/init-sleeper status"),
|
||||
response = client.runScriptOnNode(node.getId(), "/tmp/init-sleeper status",
|
||||
wrapInInitScript(false).runAsRoot(false));
|
||||
assert response.getOutput().trim().equals("") : node.getId() + ": " + response;
|
||||
try {
|
||||
|
@ -508,9 +509,9 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
|||
checkOsMatchesTemplate(metadata);
|
||||
assert (metadata.getStatus() == Status.RUNNING) : metadata;
|
||||
// due to DHCP the addresses can actually change in-between runs.
|
||||
assertEquals(metadata.getPrivateAddresses().size(), node.getPrivateAddresses().size(), String.format(
|
||||
assertEquals(metadata.getPrivateAddresses().size(), node.getPrivateAddresses().size(), format(
|
||||
"[%s] didn't match: [%s]", metadata.getPrivateAddresses(), node.getPrivateAddresses().size()));
|
||||
assertEquals(metadata.getPublicAddresses().size(), node.getPublicAddresses().size(), String.format(
|
||||
assertEquals(metadata.getPublicAddresses().size(), node.getPublicAddresses().size(), format(
|
||||
"[%s] didn't match: [%s]", metadata.getPublicAddresses(), node.getPublicAddresses().size()));
|
||||
}
|
||||
assertNodeZero(metadataMap.values());
|
||||
|
@ -602,7 +603,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[backgroundProcessMilliseconds=%s, socketOpenMilliseconds=%s]",
|
||||
return format("[backgroundProcessMilliseconds=%s, socketOpenMilliseconds=%s]",
|
||||
backgroundProcessMilliseconds, socketOpenMilliseconds);
|
||||
}
|
||||
}
|
||||
|
@ -618,7 +619,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
|||
try {
|
||||
socket = openSocketFinder.findOpenSocketOnNode(node, 8080, 60, TimeUnit.SECONDS);
|
||||
} catch (NoSuchElementException e) {
|
||||
throw new NoSuchElementException(String.format("%s%n%s%s", e.getMessage(), exec.getOutput(), exec.getError()));
|
||||
throw new NoSuchElementException(format("%s%n%s%s", e.getMessage(), exec.getOutput(), exec.getError()));
|
||||
}
|
||||
|
||||
stats.socketOpenMilliseconds = watch.elapsedTime(TimeUnit.MILLISECONDS);
|
||||
|
@ -647,7 +648,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
|||
|
||||
protected void createAndRunAServiceInGroup(String group) throws RunNodesException {
|
||||
// note that some cloud providers do not support mixed case tag names
|
||||
ImmutableMap<String, String> userMetadata = ImmutableMap.<String, String> of("name", group);
|
||||
ImmutableMap<String, String> userMetadata = ImmutableMap.<String, String> of("test", group);
|
||||
|
||||
ImmutableSet<String> tags = ImmutableSet. of(group);
|
||||
Stopwatch watch = new Stopwatch().start();
|
||||
|
@ -657,7 +658,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
|||
|
||||
final String nodeId = node.getId();
|
||||
|
||||
checkUserMetadataInNodeEquals(node, userMetadata);
|
||||
checkUserMetadataContains(node, userMetadata);
|
||||
checkTagsInNodeEquals(node, tags);
|
||||
|
||||
getAnonymousLogger().info(
|
||||
|
@ -691,13 +692,13 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
|||
return client.runScriptOnNode(nodeId, command, runAsRoot(false).wrapInInitScript(false)).getOutput().trim();
|
||||
}
|
||||
|
||||
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
assert node.getUserMetadata().equals(userMetadata) : String.format("node userMetadata did not match %s %s",
|
||||
userMetadata, node);
|
||||
protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
Map<String, String> missing = Maps.difference(node.getUserMetadata(), userMetadata).entriesOnlyOnRight();
|
||||
assert missing.isEmpty() : format("node userMetadata did not contain %s %s", missing, node);
|
||||
}
|
||||
|
||||
protected void checkTagsInNodeEquals(NodeMetadata node, ImmutableSet<String> tags) {
|
||||
assert node.getTags().equals(tags) : String.format("node tags did not match %s %s", tags, node);
|
||||
assert node.getTags().equals(tags) : format("node tags did not match %s %s", tags, node);
|
||||
}
|
||||
|
||||
public void testListImages() throws Exception {
|
||||
|
|
|
@ -222,7 +222,7 @@ END_OF_JCLOUDS_SCRIPT
|
|||
iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT
|
||||
iptables-save
|
||||
mkdir /tmp/$$
|
||||
curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.eclipse.org/jetty/8.1.5.v20120716/dist/jetty-distribution-8.1.5.v20120716.tar.gz |(mkdir -p /tmp/$$ &&cd /tmp/$$ &&tar -xpzf -)
|
||||
curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.eclipse.org/jetty/8.1.8.v20121106/dist/jetty-distribution-8.1.8.v20121106.tar.gz |(mkdir -p /tmp/$$ &&cd /tmp/$$ &&tar -xpzf -)
|
||||
mkdir -p /usr/local/jetty
|
||||
mv /tmp/$$/*/* /usr/local/jetty
|
||||
rm -rf /tmp/$$
|
||||
|
|
|
@ -112,7 +112,7 @@ public abstract class AbiquoComputeServiceLiveTest extends BaseComputeServiceLiv
|
|||
|
||||
// Abiquo does not support metadata
|
||||
@Override
|
||||
protected void checkUserMetadataInNodeEquals(final NodeMetadata node, final ImmutableMap<String, String> userMetadata) {
|
||||
protected void checkUserMetadataContains(final NodeMetadata node, final ImmutableMap<String, String> userMetadata) {
|
||||
assert node.getUserMetadata().equals(ImmutableMap.<String, String> of()) : String.format(
|
||||
"node userMetadata did not match %s %s", userMetadata, node);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public abstract class FGCPBaseComputeServiceLiveTest extends
|
|||
|
||||
// fgcp does not support metadata
|
||||
@Override
|
||||
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
assert node.getUserMetadata().isEmpty() : String.format(
|
||||
"node userMetadata not empty: %s %s", node,
|
||||
node.getUserMetadata());
|
||||
|
|
|
@ -51,7 +51,7 @@ public class VPDCComputeServiceLiveTestDisabled extends BaseComputeServiceLiveTe
|
|||
|
||||
// savvis does not support metadata
|
||||
@Override
|
||||
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
assert node.getUserMetadata().equals(ImmutableMap.<String, String> of()) : String.format(
|
||||
"node userMetadata did not match %s %s", userMetadata, node);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class SmartOSManagerComputeServiceLiveTest extends BaseComputeServiceLive
|
|||
|
||||
// smartos-ssh does not support metadata
|
||||
@Override
|
||||
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
assert node.getUserMetadata().equals(ImmutableMap.<String, String> of()) : String.format(
|
||||
"node userMetadata did not match %s %s", userMetadata, node);
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
|||
|
||||
// aws-ec2 supports userMetadata
|
||||
@Override
|
||||
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
assert node.getUserMetadata().equals(userMetadata) : String.format("node userMetadata did not match %s %s",
|
||||
userMetadata, node);
|
||||
}
|
||||
|
@ -102,11 +102,12 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
|||
|
||||
Date before = new Date();
|
||||
|
||||
ImmutableMap<String, String> userMetadata = ImmutableMap.<String, String> of("Name", group);
|
||||
ImmutableMap<String, String> userMetadata = ImmutableMap.<String, String> of("test", group);
|
||||
ImmutableSet<String> tags = ImmutableSet. of(group);
|
||||
|
||||
// note that if you change the location, you must also specify image parameters
|
||||
Template template = client.templateBuilder().locationId(region).osFamily(AMZN_LINUX).os64Bit(true).build();
|
||||
template.getOptions().tags(tags);
|
||||
template.getOptions().userMetadata(userMetadata);
|
||||
template.getOptions().as(AWSEC2TemplateOptions.class).enableMonitoring();
|
||||
template.getOptions().as(AWSEC2TemplateOptions.class).spotPrice(0.3f);
|
||||
|
@ -139,7 +140,7 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
|||
// Name metadata should turn into node.name
|
||||
assertEquals(first.getName(), group);
|
||||
|
||||
checkUserMetadataInNodeEquals(first, userMetadata);
|
||||
checkUserMetadataContains(first, userMetadata);
|
||||
checkTagsInNodeEquals(first, tags);
|
||||
|
||||
assert first.getCredentials() != null : first;
|
||||
|
|
|
@ -48,6 +48,6 @@ public class GleSYSComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
|||
|
||||
// GleSYS does not support metadata
|
||||
@Override
|
||||
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
|||
|
||||
// gogrid does not support metadata
|
||||
@Override
|
||||
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
assert node.getUserMetadata().equals(ImmutableMap.<String, String> of()) : String.format(
|
||||
"node userMetadata did not match %s %s", userMetadata, node);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class SoftLayerComputeServiceLiveTest extends BaseComputeServiceLiveTest
|
|||
|
||||
// softlayer does not support metadata
|
||||
@Override
|
||||
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
assert node.getUserMetadata().equals(ImmutableMap.<String, String> of()) : String.format(
|
||||
"node userMetadata did not match %s %s", userMetadata, node);
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv
|
|||
|
||||
// terremark does not support metadata
|
||||
@Override
|
||||
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
assert node.getUserMetadata().equals(ImmutableMap.<String, String> of()) : String.format(
|
||||
"node userMetadata did not match %s %s", userMetadata, node);
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class TerremarkVCloudExpressComputeServiceLiveTest extends BaseComputeSer
|
|||
|
||||
// terremark does not support metadata
|
||||
@Override
|
||||
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
assert node.getUserMetadata().equals(ImmutableMap.<String, String> of()) : String.format(
|
||||
"node userMetadata did not match %s %s", userMetadata, node);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds 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 org.jclouds.scriptbuilder.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* Statement used in a shell script without modifications apart from a trailing newline.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class LiteralStatement implements Statement {
|
||||
|
||||
private String statement;
|
||||
|
||||
public LiteralStatement(String statement) {
|
||||
this.statement = checkNotNull(statement, "statement");
|
||||
}
|
||||
|
||||
public String render(OsFamily family) {
|
||||
return statement + ShellToken.LF.to(family);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> functionDependencies(OsFamily family) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(statement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (!(obj instanceof LiteralStatement))
|
||||
return false;
|
||||
LiteralStatement other = LiteralStatement.class.cast(obj);
|
||||
return Objects.equal(statement, other.statement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return statement + "{lf}";
|
||||
}
|
||||
}
|
|
@ -148,6 +148,13 @@ public class Statements {
|
|||
return new InterpretableStatement(portableStatements);
|
||||
}
|
||||
|
||||
/**
|
||||
* sends statement only appending a newline
|
||||
*/
|
||||
public static Statement literal(String literalStatement) {
|
||||
return new LiteralStatement(literalStatement);
|
||||
}
|
||||
|
||||
/**
|
||||
* interprets and adds a newline to the statement
|
||||
*/
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ServerManagerComputeServiceLiveTest extends BaseComputeServiceLiveT
|
|||
|
||||
// servermanager does not support metadata
|
||||
@Override
|
||||
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
|
||||
assert node.getUserMetadata().equals(ImmutableMap.<String, String> of()) : String.format(
|
||||
"node userMetadata did not match %s %s", userMetadata, node);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue