Example #1
0
 def _test_dependency_graph(
     self, components, expected_output, action, subcomponents=None):
   saved_stdout = sys.stdout
   group = sandlet.ComponentGroup()
   for c in components:
     group.add_component(c)
   try:
     out = StringIO.StringIO()
     sys.stdout = out
     group.execute(action, subcomponents)
     output = out.getvalue().strip()
     self.assertEquals(output, expected_output)
   finally:
     sys.stdout = saved_stdout
Example #2
0
 def __init__(self, sandbox_options):
   self.sandbox_options = sandbox_options
   self.name = sandbox_options.get('name')
   self.cluster_type = sandbox_options.get('cluster_type')
   if self.cluster_type not in self._cluster_envs.keys():
     raise SandboxError('Invalid cluster type %s.' % self.cluster_type)
   cluster_config = [c for c in sandbox_options.get('clusters')
                     if c['type'] == self.cluster_type]
   if not cluster_config:
     raise SandboxError(
         'Cluster config %s not listed in sandbox config.' % cluster_config)
   self.cluster_config = cluster_config[0]
   self.cluster_env = self._cluster_envs[self.cluster_type]
   self.cluster = self.cluster_env.Cluster(self.cluster_config)
   self.sandlets = sandlet.ComponentGroup()