Fixed transient context creation and live tests

This commit is contained in:
Ignasi Barrera 2013-03-09 19:30:19 +01:00
parent 3ffdd3cde2
commit 15538035ff
4 changed files with 20 additions and 8 deletions

View File

@ -63,8 +63,9 @@ public class UpdateAutomaticAttributesOnNodeImpl implements UpdateAutomaticAttri
public void execute(String nodeName) {
logger.trace("updating node %s", nodeName);
Node node = chef.getNode(nodeName);
node.getAutomatic().putAll(automaticSupplier.get());
chef.updateNode(node);
Node mutable = new Node(node.getName(), node.getNormal(), node.getOverride(), node.getDefault(),
automaticSupplier.get(), node.getRunList(), node.getChefEnvironment());
chef.updateNode(mutable);
logger.debug("updated node %s", nodeName);
}
}

View File

@ -20,6 +20,7 @@ package org.jclouds.chef.test;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.chef.ChefApiMetadata;
import org.jclouds.chef.config.ChefBootstrapModule;
import org.jclouds.chef.config.ChefParserModule;
import org.jclouds.chef.test.config.TransientChefApiModule;
import org.jclouds.ohai.config.JMXOhaiModule;
@ -59,7 +60,7 @@ public class TransientChefApiMetadata extends ChefApiMetadata {
.defaultEndpoint("transientchef")
.defaultModules(
ImmutableSet.<Class<? extends Module>> of(TransientChefApiModule.class, ChefParserModule.class,
JMXOhaiModule.class));
ChefBootstrapModule.class, JMXOhaiModule.class));
}
@Override

View File

@ -35,8 +35,8 @@ import org.jclouds.chef.ChefApi;
import org.jclouds.chef.ChefAsyncApi;
import org.jclouds.chef.config.Validator;
import org.jclouds.chef.domain.Client;
import org.jclouds.chef.functions.ClientForGroup;
import org.jclouds.chef.functions.BootstrapConfigForGroup;
import org.jclouds.chef.functions.ClientForGroup;
import org.jclouds.chef.functions.RunListForGroup;
import org.jclouds.chef.test.TransientChefApi;
import org.jclouds.chef.test.TransientChefAsyncApi;
@ -45,10 +45,9 @@ import org.jclouds.crypto.Crypto;
import org.jclouds.domain.JsonBall;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.config.RestModule;
import org.jclouds.scriptbuilder.domain.Statement;
import org.jclouds.scriptbuilder.statements.chef.InstallChefGems;
import com.google.common.base.Optional;
import com.google.common.base.Supplier;
import com.google.common.cache.CacheLoader;
import com.google.common.collect.ImmutableSet;
import com.google.inject.AbstractModule;
@ -80,7 +79,17 @@ public class TransientChefApiModule extends AbstractModule {
.modules(
ImmutableSet.<Module> of(new ExecutorServiceModule(sameThreadExecutor(),
sameThreadExecutor()))).buildInjector().getInstance(LocalAsyncBlobStore.class));
bind(Statement.class).annotatedWith(Names.named("installChefGems")).to(InstallChefGems.class);
}
@Provides
@Singleton
public Supplier<PrivateKey> supplyKey() {
return new Supplier<PrivateKey>() {
@Override
public PrivateKey get() {
return null;
}
};
}
@Provides

View File

@ -26,6 +26,7 @@ import org.jclouds.apis.ApiMetadata;
import org.jclouds.chef.ChefApi;
import org.jclouds.chef.ChefApiMetadata;
import org.jclouds.chef.ChefContext;
import org.jclouds.chef.config.ChefBootstrapModule;
import org.jclouds.chef.config.ChefParserModule;
import org.jclouds.chef.config.ChefRestClientModule;
import org.jclouds.domain.JsonBall;
@ -64,7 +65,7 @@ public class BaseStubbedOhaiLiveTest extends BaseChefContextLiveTest<ChefContext
.toBuilder()
.defaultModules(
ImmutableSet.<Class<? extends Module>> of(ChefRestClientModule.class, ChefParserModule.class,
TestOhaiModule.class)).build();
ChefBootstrapModule.class, TestOhaiModule.class)).build();
}
@Override