mirror of https://github.com/apache/jclouds.git
commit
c4dde78b0c
|
@ -26,6 +26,7 @@ import static org.jclouds.nodepool.config.NodePoolProperties.MIN_SIZE;
|
||||||
import static org.jclouds.nodepool.config.NodePoolProperties.POOL_ADMIN_ACCESS;
|
import static org.jclouds.nodepool.config.NodePoolProperties.POOL_ADMIN_ACCESS;
|
||||||
import static org.jclouds.nodepool.config.NodePoolProperties.REMOVE_DESTROYED;
|
import static org.jclouds.nodepool.config.NodePoolProperties.REMOVE_DESTROYED;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -62,7 +63,6 @@ public class NodePoolApiMetadata extends BaseApiMetadata {
|
||||||
|
|
||||||
public static Properties defaultProperties() {
|
public static Properties defaultProperties() {
|
||||||
Properties properties = BaseRestApiMetadata.defaultProperties();
|
Properties properties = BaseRestApiMetadata.defaultProperties();
|
||||||
properties.setProperty("nodepool.identity", "nodepool-user");
|
|
||||||
properties.setProperty(BACKEND_GROUP, "nodepool");
|
properties.setProperty(BACKEND_GROUP, "nodepool");
|
||||||
properties.setProperty(METADATA_CONTAINER, "nodes");
|
properties.setProperty(METADATA_CONTAINER, "nodes");
|
||||||
properties.setProperty(BACKEND_MODULES,
|
properties.setProperty(BACKEND_MODULES,
|
||||||
|
@ -70,9 +70,12 @@ public class NodePoolApiMetadata extends BaseApiMetadata {
|
||||||
properties.setProperty(MAX_SIZE, 10 + "");
|
properties.setProperty(MAX_SIZE, 10 + "");
|
||||||
properties.setProperty(MIN_SIZE, 5 + "");
|
properties.setProperty(MIN_SIZE, 5 + "");
|
||||||
properties.setProperty(REMOVE_DESTROYED, "true");
|
properties.setProperty(REMOVE_DESTROYED, "true");
|
||||||
// by default use the current user's user and private key
|
// by default use the current user's user and private key if one exists, if not the properties
|
||||||
properties.setProperty(POOL_ADMIN_ACCESS, "adminUsername=" + System.getProperty("user.name")
|
// will need to be set (no default passwords)
|
||||||
+ ",adminPrivateKeyFile=" + System.getProperty("user.home") + "/.ssh/id_rsa");
|
if (new File(System.getProperty("user.home") + "/.ssh/id_rsa").exists()) {
|
||||||
|
properties.setProperty(POOL_ADMIN_ACCESS, "adminUsername=" + System.getProperty("user.name")
|
||||||
|
+ ",adminPrivateKeyFile=" + System.getProperty("user.home") + "/.ssh/id_rsa");
|
||||||
|
}
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
/*
|
||||||
|
* 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.nodepool.config;
|
package org.jclouds.nodepool.config;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -44,6 +63,7 @@ public class NodePoolComputeServiceContextModule extends JCloudsNativeComputeSer
|
||||||
bind(ComputeServiceContext.class).to(NodePoolComputeServiceContext.class);
|
bind(ComputeServiceContext.class).to(NodePoolComputeServiceContext.class);
|
||||||
install(new LocationsFromComputeServiceAdapterModule<NodeMetadata, Hardware, Image, Location>() {
|
install(new LocationsFromComputeServiceAdapterModule<NodeMetadata, Hardware, Image, Location>() {
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -61,8 +61,10 @@ public abstract class BaseNodePoolComputeServiceAdapter implements NodePoolCompu
|
||||||
protected final AdminAccess.Builder initialCredentialsBuilder;
|
protected final AdminAccess.Builder initialCredentialsBuilder;
|
||||||
|
|
||||||
public BaseNodePoolComputeServiceAdapter(@Backend Supplier<ComputeService> backendComputeService,
|
public BaseNodePoolComputeServiceAdapter(@Backend Supplier<ComputeService> backendComputeService,
|
||||||
@Backend Supplier<Template> backendTemplate, @Named(BACKEND_GROUP) String poolGroupName,
|
|
||||||
NodeMetadataStore metadataStore, @Named(POOL_ADMIN_ACCESS) String poolNodeAdminAccess,
|
@Backend Supplier<Template> backendTemplate, @Named(BACKEND_GROUP) String poolGroupName,
|
||||||
|
|
||||||
|
NodeMetadataStore metadataStore, @Named(POOL_ADMIN_ACCESS) String poolNodeAdminAccess,
|
||||||
AdminAccess.Configuration configuration) {
|
AdminAccess.Configuration configuration) {
|
||||||
this.backendComputeService = backendComputeService;
|
this.backendComputeService = backendComputeService;
|
||||||
this.poolGroupName = poolGroupName;
|
this.poolGroupName = poolGroupName;
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
/*
|
||||||
|
* 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.nodepool.internal;
|
package org.jclouds.nodepool.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
/*
|
||||||
|
* 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.nodepool.internal;
|
package org.jclouds.nodepool.internal;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
|
@ -23,6 +23,7 @@ import static org.jclouds.nodepool.config.NodePoolProperties.BACKEND_PROVIDER;
|
||||||
import static org.jclouds.nodepool.config.NodePoolProperties.BASEDIR;
|
import static org.jclouds.nodepool.config.NodePoolProperties.BASEDIR;
|
||||||
import static org.jclouds.nodepool.config.NodePoolProperties.MAX_SIZE;
|
import static org.jclouds.nodepool.config.NodePoolProperties.MAX_SIZE;
|
||||||
import static org.jclouds.nodepool.config.NodePoolProperties.MIN_SIZE;
|
import static org.jclouds.nodepool.config.NodePoolProperties.MIN_SIZE;
|
||||||
|
import static org.jclouds.nodepool.config.NodePoolProperties.REMOVE_DESTROYED;
|
||||||
import static org.jclouds.scriptbuilder.domain.Statements.exec;
|
import static org.jclouds.scriptbuilder.domain.Statements.exec;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -41,7 +42,7 @@ import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole, David Alves
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "BYONBackendLiveTest")
|
@Test(groups = "live", testName = "BYONBackendLiveTest")
|
||||||
public class BYONBackendLiveTest extends BaseComputeServiceContextLiveTest {
|
public class BYONBackendLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
|
@ -61,6 +62,7 @@ public class BYONBackendLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
contextProperties.setProperty(BASEDIR, basedir);
|
contextProperties.setProperty(BASEDIR, basedir);
|
||||||
contextProperties.setProperty(MAX_SIZE, 1 + "");
|
contextProperties.setProperty(MAX_SIZE, 1 + "");
|
||||||
contextProperties.setProperty(MIN_SIZE, 1 + "");
|
contextProperties.setProperty(MIN_SIZE, 1 + "");
|
||||||
|
contextProperties.setProperty(REMOVE_DESTROYED, false + "");
|
||||||
contextProperties.setProperty("nodepool.identity", System.getProperty("user.name"));
|
contextProperties.setProperty("nodepool.identity", System.getProperty("user.name"));
|
||||||
|
|
||||||
StringBuilder nodes = new StringBuilder();
|
StringBuilder nodes = new StringBuilder();
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.nodepool;
|
package org.jclouds.nodepool;
|
||||||
|
|
||||||
|
import static org.jclouds.nodepool.config.NodePoolProperties.POOL_ADMIN_ACCESS;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNull;
|
import static org.testng.Assert.assertNull;
|
||||||
import static org.testng.Assert.assertSame;
|
import static org.testng.Assert.assertSame;
|
||||||
|
@ -38,7 +39,6 @@ import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadata.Status;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate;
|
|
||||||
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
||||||
import org.jclouds.nodepool.config.NodePoolProperties;
|
import org.jclouds.nodepool.config.NodePoolProperties;
|
||||||
import org.jclouds.nodepool.internal.NodeMetadataStore;
|
import org.jclouds.nodepool.internal.NodeMetadataStore;
|
||||||
|
@ -53,10 +53,8 @@ import com.google.inject.Injector;
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole, David Alves
|
* @author Adrian Cole, David Alves
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit")
|
@Test(groups = "unit", testName = "NodeMetadataStoreTest")
|
||||||
public class NodeMetadataStoreTestDisabled {
|
public class NodeMetadataStoreTest {
|
||||||
// unit tests should have no dependencies, yet this one is failing on cloudbees:
|
|
||||||
// Guice creation errors: 1) Error injecting constructor, java.lang.IllegalArgumentException: key adminPrivateKeyFile value set to /home/hudson/.ssh/id_rsa, must be an existing file at org.jclouds.nodepool.internal.EagerNodePoolComputeServiceAdapter.<init>(EagerNodePoolComputeServiceAdapter.java:77) at
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
NodeMetadataStore store;
|
NodeMetadataStore store;
|
||||||
|
@ -84,6 +82,7 @@ public class NodeMetadataStoreTestDisabled {
|
||||||
overrides.setProperty(NodePoolProperties.BACKEND_PROVIDER, "stub");
|
overrides.setProperty(NodePoolProperties.BACKEND_PROVIDER, "stub");
|
||||||
overrides.setProperty(NodePoolProperties.MIN_SIZE, "0");
|
overrides.setProperty(NodePoolProperties.MIN_SIZE, "0");
|
||||||
overrides.setProperty(NodePoolProperties.BASEDIR, baseDir);
|
overrides.setProperty(NodePoolProperties.BASEDIR, baseDir);
|
||||||
|
overrides.setProperty(POOL_ADMIN_ACCESS, "adminUsername=pooluser,adminPassword=poolpass");
|
||||||
// note no ssh module since we are stub and not trying ssh, yet
|
// note no ssh module since we are stub and not trying ssh, yet
|
||||||
overrides.setProperty(NodePoolProperties.BACKEND_MODULES, SLF4JLoggingModule.class.getName());
|
overrides.setProperty(NodePoolProperties.BACKEND_MODULES, SLF4JLoggingModule.class.getName());
|
||||||
Context nodePoolCtx = ContextBuilder.newBuilder("nodepool").credentials("foo", "bar").overrides(overrides)
|
Context nodePoolCtx = ContextBuilder.newBuilder("nodepool").credentials("foo", "bar").overrides(overrides)
|
||||||
|
@ -102,13 +101,6 @@ public class NodeMetadataStoreTestDisabled {
|
||||||
+ "\"user\":\"testuser\",\"password\":\"testpass\",\"privateKey\":\"pk\",\"authenticateSudo\":true}");
|
+ "\"user\":\"testuser\",\"password\":\"testpass\",\"privateKey\":\"pk\",\"authenticateSudo\":true}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = "unit", dependsOnMethods = "testStore")
|
|
||||||
public void testCredentialsFromStoreOverrideBackendCredentials() {
|
|
||||||
// test that node store credentials are not overriden from somewhere else
|
|
||||||
assertNull(createInjector().getBinding(PrioritizeCredentialsFromTemplate.class).getProvider().get()
|
|
||||||
.apply(null, null));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(groups = "unit", dependsOnMethods = "testStore")
|
@Test(groups = "unit", dependsOnMethods = "testStore")
|
||||||
public void testLoad() {
|
public void testLoad() {
|
||||||
NodeMetadata loaded = store.load(nodeMeta1);
|
NodeMetadata loaded = store.load(nodeMeta1);
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.nodepool;
|
package org.jclouds.nodepool;
|
||||||
|
|
||||||
|
import static org.jclouds.nodepool.config.NodePoolProperties.POOL_ADMIN_ACCESS;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -41,9 +42,6 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit", testName = "NodePoolComputeServiceContextTest")
|
@Test(groups = "unit", testName = "NodePoolComputeServiceContextTest")
|
||||||
public class NodePoolComputeServiceContextTest {
|
public class NodePoolComputeServiceContextTest {
|
||||||
|
|
||||||
|
|
||||||
//TODO: identity became nodepool-user
|
|
||||||
@Test(enabled = false)
|
|
||||||
public void testBinds() {
|
public void testBinds() {
|
||||||
final String basedir = "target/" + this.getClass().getSimpleName();
|
final String basedir = "target/" + this.getClass().getSimpleName();
|
||||||
new File(basedir).delete();
|
new File(basedir).delete();
|
||||||
|
@ -53,14 +51,12 @@ public class NodePoolComputeServiceContextTest {
|
||||||
overrides.setProperty(NodePoolProperties.BASEDIR, basedir);
|
overrides.setProperty(NodePoolProperties.BASEDIR, basedir);
|
||||||
// note no ssh module since we are stub and not trying ssh, yet
|
// note no ssh module since we are stub and not trying ssh, yet
|
||||||
overrides.setProperty(NodePoolProperties.BACKEND_MODULES, SLF4JLoggingModule.class.getName());
|
overrides.setProperty(NodePoolProperties.BACKEND_MODULES, SLF4JLoggingModule.class.getName());
|
||||||
|
overrides.setProperty(POOL_ADMIN_ACCESS, "adminUsername=pooluser,adminPassword=poolpass");
|
||||||
|
|
||||||
ComputeService stub = ContextBuilder.newBuilder("nodepool")
|
ComputeService stub = ContextBuilder.newBuilder("nodepool").credentials("foo", "bar").endpoint("gooend")
|
||||||
.credentials("foo", "bar")
|
.apiVersion("1.1").buildVersion("1.1-2").overrides(overrides).buildInjector()
|
||||||
.endpoint("gooend")
|
.getInstance(Key.get(new TypeLiteral<Supplier<ComputeService>>() {
|
||||||
.apiVersion("1.1")
|
}, Backend.class)).get();
|
||||||
.buildVersion("1.1-2")
|
|
||||||
.overrides(overrides)
|
|
||||||
.buildInjector().getInstance(Key.get(new TypeLiteral<Supplier<ComputeService>>(){}, Backend.class)).get();
|
|
||||||
|
|
||||||
assertEquals(stub.getContext().unwrap().getIdentity(), "foo");
|
assertEquals(stub.getContext().unwrap().getIdentity(), "foo");
|
||||||
assertEquals(stub.getContext().utils().injector().getInstance(Key.get(String.class, Credential.class)), "bar");
|
assertEquals(stub.getContext().utils().injector().getInstance(Key.get(String.class, Credential.class)), "bar");
|
||||||
|
@ -73,5 +69,4 @@ public class NodePoolComputeServiceContextTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -67,7 +67,8 @@ import com.google.common.io.Closeables;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
public class NodePoolComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
public class NodePoolComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
final String basedir = "target/" + this.getClass().getSimpleName().toLowerCase();
|
|
||||||
|
private final String basedir = "target/" + this.getClass().getSimpleName().toLowerCase();
|
||||||
|
|
||||||
public NodePoolComputeServiceLiveTest() {
|
public NodePoolComputeServiceLiveTest() {
|
||||||
provider = "nodepool";
|
provider = "nodepool";
|
||||||
|
@ -76,6 +77,9 @@ public class NodePoolComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
@Override
|
@Override
|
||||||
protected Properties setupProperties() {
|
protected Properties setupProperties() {
|
||||||
Properties contextProperties = super.setupProperties();
|
Properties contextProperties = super.setupProperties();
|
||||||
|
contextProperties.setProperty(BASEDIR, basedir);
|
||||||
|
contextProperties.setProperty("nodepool.identity", "pooluser");
|
||||||
|
contextProperties.setProperty(POOL_ADMIN_ACCESS, "adminUsername=pooluser,adminPassword=poolpassword");
|
||||||
contextProperties.setProperty(TIMEOUT_SCRIPT_COMPLETE, (1200 * 1000) + "");
|
contextProperties.setProperty(TIMEOUT_SCRIPT_COMPLETE, (1200 * 1000) + "");
|
||||||
contextProperties.setProperty(TIMEOUT_PORT_OPEN, (1200 * 1000) + "");
|
contextProperties.setProperty(TIMEOUT_PORT_OPEN, (1200 * 1000) + "");
|
||||||
contextProperties.setProperty(BASEDIR, basedir);
|
contextProperties.setProperty(BASEDIR, basedir);
|
||||||
|
@ -102,7 +106,7 @@ public class NodePoolComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Test(enabled = true)
|
@Test(enabled = true, groups = "live")
|
||||||
public void testCreateAndRunAService() throws Exception {
|
public void testCreateAndRunAService() throws Exception {
|
||||||
this.group = this.group + "s";
|
this.group = this.group + "s";
|
||||||
final String configuration = Strings2.toStringAndClose(RunScriptData.class
|
final String configuration = Strings2.toStringAndClose(RunScriptData.class
|
||||||
|
@ -125,6 +129,11 @@ public class NodePoolComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
|
|
||||||
watch.reset().start();
|
watch.reset().start();
|
||||||
|
|
||||||
|
// note this is a dependency on the template resolution so we have the
|
||||||
|
// 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
|
||||||
client.runScriptOnNode(nodeId, installAdminUserJBossAndOpenPorts(node.getOperatingSystem()),
|
client.runScriptOnNode(nodeId, installAdminUserJBossAndOpenPorts(node.getOperatingSystem()),
|
||||||
nameTask("configure-jboss"));
|
nameTask("configure-jboss"));
|
||||||
|
|
||||||
|
@ -170,7 +179,7 @@ public class NodePoolComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
}), "jboss", node, JBOSS_PATTERN);
|
}), "jboss", node, JBOSS_PATTERN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testCreateAndRunAService")
|
@Test(enabled = true, groups = "live", dependsOnMethods = "testCreateAndRunAService")
|
||||||
public void testRebuildPoolStateFromStore() {
|
public void testRebuildPoolStateFromStore() {
|
||||||
tearDownContext();
|
tearDownContext();
|
||||||
setupContext();
|
setupContext();
|
||||||
|
@ -178,13 +187,13 @@ public class NodePoolComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
assertEquals(((NodeMetadata) Iterables.get(client.listNodes(), 0)).getGroup(), this.group);
|
assertEquals(((NodeMetadata) Iterables.get(client.listNodes(), 0)).getGroup(), this.group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false, dependsOnMethods = "testRebuildPoolStateFromStore")
|
@Test(enabled = true, groups = "live", dependsOnMethods = "testRebuildPoolStateFromStore")
|
||||||
public void testIncreasePoolAllowed() throws RunNodesException {
|
public void testIncreasePoolAllowed() throws RunNodesException {
|
||||||
client.createNodesInGroup(this.group, 1);
|
client.createNodesInGroup(this.group, 1);
|
||||||
assertSame(client.listNodes().size(), 2);
|
assertSame(client.listNodes().size(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false, dependsOnMethods = "testIncreasePoolAllowed")
|
@Test(enabled = true, groups = "live", dependsOnMethods = "testIncreasePoolAllowed")
|
||||||
public void testIncreasePoolNotAllowed() throws RunNodesException {
|
public void testIncreasePoolNotAllowed() throws RunNodesException {
|
||||||
boolean caughtException = false;
|
boolean caughtException = false;
|
||||||
try {
|
try {
|
||||||
|
@ -195,7 +204,7 @@ public class NodePoolComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
assertTrue(caughtException, "expected an exception to be thrown");
|
assertTrue(caughtException, "expected an exception to be thrown");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testRebuildPoolStateFromStore")
|
@Test(enabled = true, groups = "live", dependsOnMethods = "testIncreasePoolNotAllowed")
|
||||||
public void testGetBackendComputeServiceContext() {
|
public void testGetBackendComputeServiceContext() {
|
||||||
NodePoolComputeServiceContext ctx = context.utils().injector().getInstance(NodePoolComputeServiceContext.class);
|
NodePoolComputeServiceContext ctx = context.utils().injector().getInstance(NodePoolComputeServiceContext.class);
|
||||||
assertNotNull(ctx.getBackendContext());
|
assertNotNull(ctx.getBackendContext());
|
||||||
|
@ -204,7 +213,7 @@ public class NodePoolComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
NodePredicates.inGroup(ctx.getPoolGroupName())).size(), 2);
|
NodePredicates.inGroup(ctx.getPoolGroupName())).size(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false, dependsOnMethods = "testGetBackendComputeServiceContext")
|
@Test(enabled = false, groups = "live", dependsOnMethods = "testGetBackendComputeServiceContext")
|
||||||
public void testDestroyPoolNodes() {
|
public void testDestroyPoolNodes() {
|
||||||
client.destroyNodesMatching(NodePredicates.inGroup(this.group));
|
client.destroyNodesMatching(NodePredicates.inGroup(this.group));
|
||||||
// after we destroy all nodes we should still have minsize nodes in the pool
|
// after we destroy all nodes we should still have minsize nodes in the pool
|
||||||
|
@ -212,7 +221,7 @@ public class NodePoolComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
assertSame(ctx.getPoolStats().currentSize(), 1);
|
assertSame(ctx.getPoolStats().currentSize(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testGetBackendComputeServiceContext")
|
@Test(enabled = true, groups = "live", dependsOnMethods = "testGetBackendComputeServiceContext")
|
||||||
public void testDestroyPool() {
|
public void testDestroyPool() {
|
||||||
// TODO get the ctx without the injector
|
// TODO get the ctx without the injector
|
||||||
NodePoolComputeServiceContext ctx = context.utils().injector().getInstance(NodePoolComputeServiceContext.class);
|
NodePoolComputeServiceContext ctx = context.utils().injector().getInstance(NodePoolComputeServiceContext.class);
|
||||||
|
@ -223,7 +232,7 @@ public class NodePoolComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Test(enabled = false, dependsOnMethods = "testCompareSizes")
|
@Test(enabled = false)
|
||||||
public void testAScriptExecutionAfterBootWithBasicTemplate() throws Exception {
|
public void testAScriptExecutionAfterBootWithBasicTemplate() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +242,7 @@ public class NodePoolComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Test(enabled = false, dependsOnMethods = "testCompareSizes")
|
@Test(enabled = false)
|
||||||
public void testConcurrentUseOfComputeServiceToCreateNodes() throws Exception {
|
public void testConcurrentUseOfComputeServiceToCreateNodes() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.nodepool.config;
|
package org.jclouds.nodepool.config;
|
||||||
|
|
||||||
|
import static org.easymock.EasyMock.createNiceMock;
|
||||||
|
import static org.jclouds.nodepool.config.NodePoolProperties.POOL_ADMIN_ACCESS;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -25,13 +27,19 @@ import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.ContextBuilder;
|
import org.jclouds.ContextBuilder;
|
||||||
import org.jclouds.compute.ComputeService;
|
import org.jclouds.compute.ComputeService;
|
||||||
|
import org.jclouds.domain.Credentials;
|
||||||
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
||||||
import org.jclouds.nodepool.Backend;
|
import org.jclouds.nodepool.Backend;
|
||||||
import org.jclouds.rest.annotations.Credential;
|
import org.jclouds.rest.annotations.Credential;
|
||||||
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.net.HostAndPort;
|
||||||
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Key;
|
import com.google.inject.Key;
|
||||||
|
import com.google.inject.Scopes;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,8 +48,6 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit", testName = "BindBackendComputeServiceTest")
|
@Test(groups = "unit", testName = "BindBackendComputeServiceTest")
|
||||||
public class BindBackendComputeServiceTest {
|
public class BindBackendComputeServiceTest {
|
||||||
|
|
||||||
//TODO: identity became nodepool-user
|
|
||||||
@Test(enabled = false)
|
|
||||||
public void testBinds() {
|
public void testBinds() {
|
||||||
final String basedir = "target/" + this.getClass().getSimpleName();
|
final String basedir = "target/" + this.getClass().getSimpleName();
|
||||||
new File(basedir).delete();
|
new File(basedir).delete();
|
||||||
|
@ -50,15 +56,14 @@ public class BindBackendComputeServiceTest {
|
||||||
overrides.setProperty(NodePoolProperties.BACKEND_PROVIDER, "stub");
|
overrides.setProperty(NodePoolProperties.BACKEND_PROVIDER, "stub");
|
||||||
overrides.setProperty(NodePoolProperties.BASEDIR, basedir);
|
overrides.setProperty(NodePoolProperties.BASEDIR, basedir);
|
||||||
// note no ssh module since we are stub and not trying ssh, yet
|
// note no ssh module since we are stub and not trying ssh, yet
|
||||||
overrides.setProperty(NodePoolProperties.BACKEND_MODULES, SLF4JLoggingModule.class.getName());
|
overrides.setProperty(NodePoolProperties.BACKEND_MODULES, SLF4JLoggingModule.class.getName() + ","
|
||||||
|
+ StubSshClientModule.class.getName());
|
||||||
|
overrides.setProperty(POOL_ADMIN_ACCESS, "adminUsername=pooluser,adminPassword=poolpass");
|
||||||
|
|
||||||
ComputeService stub = ContextBuilder.newBuilder("nodepool")
|
ComputeService stub = ContextBuilder.newBuilder("nodepool").credentials("foo", "bar").endpoint("gooend")
|
||||||
.credentials("foo", "bar")
|
.apiVersion("1.1").buildVersion("1.1-2").overrides(overrides).buildInjector()
|
||||||
.endpoint("gooend")
|
.getInstance(Key.get(new TypeLiteral<Supplier<ComputeService>>() {
|
||||||
.apiVersion("1.1")
|
}, Backend.class)).get();
|
||||||
.buildVersion("1.1-2")
|
|
||||||
.overrides(overrides)
|
|
||||||
.buildInjector().getInstance(Key.get(new TypeLiteral<Supplier<ComputeService>>(){}, Backend.class)).get();
|
|
||||||
|
|
||||||
assertEquals(stub.getContext().unwrap().getIdentity(), "foo");
|
assertEquals(stub.getContext().unwrap().getIdentity(), "foo");
|
||||||
assertEquals(stub.getContext().utils().injector().getInstance(Key.get(String.class, Credential.class)), "bar");
|
assertEquals(stub.getContext().utils().injector().getInstance(Key.get(String.class, Credential.class)), "bar");
|
||||||
|
@ -71,5 +76,23 @@ public class BindBackendComputeServiceTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class StubSshClientModule extends AbstractModule {
|
||||||
|
|
||||||
|
protected void configure() {
|
||||||
|
bind(SshClient.Factory.class).to(Factory.class).in(Scopes.SINGLETON);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Factory implements SshClient.Factory {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SshClient create(HostAndPort socket, LoginCredentials credentials) {
|
||||||
|
return createNiceMock(SshClient.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SshClient create(HostAndPort socket, Credentials credentials) {
|
||||||
|
return createNiceMock(SshClient.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -41,24 +41,23 @@ import com.google.inject.name.Names;
|
||||||
@Test(groups = "unit", testName = "BindInputStreamToFilesystemBlobStoreTest")
|
@Test(groups = "unit", testName = "BindInputStreamToFilesystemBlobStoreTest")
|
||||||
public class BindInputStreamToFilesystemBlobStoreTest {
|
public class BindInputStreamToFilesystemBlobStoreTest {
|
||||||
|
|
||||||
//TODO: binding error
|
|
||||||
@Test(enabled = false)
|
|
||||||
public void testCreatesDir() {
|
public void testCreatesDir() {
|
||||||
final String basedir = "target/" + this.getClass().getSimpleName();
|
final String basedir = "target/" + this.getClass().getSimpleName();
|
||||||
new File(basedir).delete();
|
new File(basedir).delete();
|
||||||
Map<String, InputStream> file = Guice.createInjector(new AbstractModule() {
|
Map<String, InputStream> file = Guice
|
||||||
|
.createInjector(new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bindConstant().annotatedWith(Names.named(NodePoolProperties.BASEDIR)).to(basedir);
|
bindConstant().annotatedWith(Names.named(NodePoolProperties.BASEDIR)).to(basedir);
|
||||||
bindConstant().annotatedWith(Names.named(NodePoolProperties.METADATA_CONTAINER)).to("barr");
|
bindConstant().annotatedWith(Names.named(NodePoolProperties.METADATA_CONTAINER)).to("barr");
|
||||||
bindConstant().annotatedWith(Names.named(NodePoolProperties.BACKEND_MODULES)).to(
|
bindConstant().annotatedWith(Names.named(NodePoolProperties.POOL_ADMIN_ACCESS)).to(
|
||||||
SLF4JLoggingModule.class.getName());
|
"adminUsername=pooluser,adminPassword=poolpass");
|
||||||
}
|
bindConstant().annotatedWith(Names.named(NodePoolProperties.BACKEND_MODULES)).to(
|
||||||
|
SLF4JLoggingModule.class.getName());
|
||||||
}, new BindInputStreamToFilesystemBlobStore()).getInstance(
|
}
|
||||||
Key.get(new TypeLiteral<Supplier<Map<String, InputStream>>>() {
|
}, new BindInputStreamToFilesystemBlobStore())
|
||||||
})).get();
|
.getInstance(Key.get(new TypeLiteral<Supplier<Map<String, InputStream>>>() {
|
||||||
|
}, Names.named("METADATA"))).get();
|
||||||
|
|
||||||
assert (new File(basedir + "/barr").exists());
|
assert (new File(basedir + "/barr").exists());
|
||||||
assertEquals(file.keySet(), ImmutableSet.of());
|
assertEquals(file.keySet(), ImmutableSet.of());
|
||||||
|
|
|
@ -10,6 +10,8 @@ import java.util.List;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import clojure.main;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
|
@ -64,6 +66,8 @@ import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
public class AdminAccessBuilderSpec {
|
public class AdminAccessBuilderSpec {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -379469670373111569L;
|
||||||
|
|
||||||
/** Parses a single value. */
|
/** Parses a single value. */
|
||||||
protected static interface ValueParser {
|
protected static interface ValueParser {
|
||||||
void parse(AdminAccessBuilderSpec spec, String key, @Nullable String value);
|
void parse(AdminAccessBuilderSpec spec, String key, @Nullable String value);
|
||||||
|
|
Loading…
Reference in New Issue