[
https://issues.apache.org/jira/browse/WHIRR-243?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13000525#comment-13000525
]
Adrian Cole commented on WHIRR-243:
-----------------------------------
I wouldn't recommend creating a different impl for testing, as it is redundant
to the existing jclouds stub.
it is possible to use the jclouds stub to test runScriptOnNodes type of
behaviour. In fact, that's what it is used for in our test case:
https://github.com/jclouds/jclouds/blob/master/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java
Main idea is that the stub provider exposes the lifecycle functionality. if
you want to test scripts, you have to supply expectation behaviour. This would
be assigned via a guice module you'd pass during createContext()
ex. ComputeServiceContextFactory().createContext("stub",
ImmutableSet.<Module> of(new HBaseTestExpectationsModule()), new
Properties());
In this test module, you'd need to bind 2 things, SocketOpen and
SshClient.Factory
I'd expect you'd like to just tell SocketOpen to always return true;
SocketOpen is called directly before a ssh connection is attempted.
To bind SocketOpen to always true, add this to your configure method of the
module extending com.google.inject.AbstractModule
bind(SocketOpen.class).toInstance(new SocketOpen() {
@Override
public boolean apply(IPSocket arg0) {
return true;
}
});
The ssh factory is important. it is here that you can test your expectations
properly, as we do in the above test. factory.create will be called for any
script execution, whether it is during createNode or runScriptOnNodesMatching.
You can feel free to not use mocks and use some sort of hash = return map, but
this is where to hook in. I'd recommend paying attention to order when it
matters.
At the end of the day, the only code you'd need to maintain would be the ssh
expectations, which is the point in the first place, I believe. I hope this
helps.
> Allow to run component tests in isolation from JClouds
> ------------------------------------------------------
>
> Key: WHIRR-243
> URL: https://issues.apache.org/jira/browse/WHIRR-243
> Project: Whirr
> Issue Type: Improvement
> Components: core
> Reporter: David Alves
> Priority: Minor
> Attachments: WHIRR-243.patch
>
>
> While jclouds now features the awesome BYON mode it might be useful to be
> able to run compoenent and systems tests without jclouds.
> I tried jclouds stub features but unless I'm missing something (I might)
> there is no way of stubbing a compute service that allows to call
> runOnNodesMatching.
> So my idea is to alter ComputeServiceContextBuilder a bit to account for a
> new provider ("test") in which case an instance of a
> StubComputeServiceContext is returned (which features a StubComputeService
> internal class). This allows to make assertion regarding which nodes were
> started or not and on which order, which I think is useful.
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira