[Maas-devel] Tests and cluster RPC commands

Raphaël Badin raphael.badin at canonical.com
Tue Sep 9 10:14:21 UTC 2014


More and more we're using cluster RPC commands from the region… which 
means that the region and the cluster code are more and more dependant 
on one another.  In the test code, the division between cluster and 
region is still very much there because we have to stub things out 
manually every time we call a cluster RPC method.  This mismatch is 
starting to be more and more painful because each change involving 
adding a call to a cluster RPC method can possibly force you to update a 
lot of existing tests.

For example, this is the kind of setup we have to do to get the cluster 
to respond to 'CreateHostMaps' and 'PowerOn'.

def prepare_rpc_to_cluster(self, nodegroup):
     self.useFixture(RegionEventLoopFixture("rpc"))
     self.useFixture(RunningEventLoopFixture())
     rpc_fixture = self.useFixture(MockLiveRegionToClusterRPCFixture())
     protocol = rpc_fixture.makeCluster(
          nodegroup, cluster.CreateHostMaps, cluster.PowerOn)
     return protocol

I wondering if we couldn't have something more systematic and have this 
done, for all the available cluster RPC methods, in the base test class 
(and for every cluster created in the tests).  Of course you'll have to 
configure mock objects if you're expecting a particular response from 
one of the RPC methods. But if all you need is the code not to blow up 
because a cluster RPC method has been called as a side-effect of what 
you're actually testing, this will be taken care of.

Thoughts?  Gavin?






More information about the Maas-devel mailing list