Esempio n. 1
0
 def test_callable_raises_negative_clients(self):
   unplaced_factory = python_executor_stacks.UnplacedExecutorFactory()
   federating_factory = python_executor_stacks.FederatingExecutorFactory(
       clients_per_thread=1, unplaced_ex_factory=unplaced_factory)
   flat_stack_fn = python_executor_stacks.create_minimal_length_flat_stack_fn(
       2, federating_factory)
   with self.assertRaises(ValueError):
     flat_stack_fn({placements.CLIENTS: -1})
Esempio n. 2
0
 def test_returns_singleton_list_for_zero_clients(self):
   unplaced_factory = python_executor_stacks.UnplacedExecutorFactory()
   federating_factory = python_executor_stacks.FederatingExecutorFactory(
       clients_per_thread=1, unplaced_ex_factory=unplaced_factory)
   flat_stack_fn = python_executor_stacks.create_minimal_length_flat_stack_fn(
       3, federating_factory)
   executor_list = flat_stack_fn({placements.CLIENTS: 0})
   self.assertLen(executor_list, 1)
Esempio n. 3
0
 def test_returns_empty_list_of_sizing_executors_if_configured(self):
   unplaced_factory = python_executor_stacks.UnplacedExecutorFactory()
   federating_factory = python_executor_stacks.FederatingExecutorFactory(
       clients_per_thread=1,
       unplaced_ex_factory=unplaced_factory,
       use_sizing=True)
   sizing_ex_list = federating_factory.sizing_executors
   self.assertIsInstance(sizing_ex_list, list)
   self.assertEmpty(sizing_ex_list)
Esempio n. 4
0
 def test_constructs_correct_length_list(self, max_clients_per_stack,
                                         num_clients):
   unplaced_factory = python_executor_stacks.UnplacedExecutorFactory()
   federating_factory = python_executor_stacks.FederatingExecutorFactory(
       clients_per_thread=1, unplaced_ex_factory=unplaced_factory)
   flat_stack_fn = python_executor_stacks.create_minimal_length_flat_stack_fn(
       max_clients_per_stack, federating_factory)
   executor_list = flat_stack_fn({placements.CLIENTS: num_clients})
   self.assertLen(executor_list,
                  math.ceil(num_clients / max_clients_per_stack))
Esempio n. 5
0
 def test_constructs_as_many_sizing_executors_as_client_executors(self):
   unplaced_factory = python_executor_stacks.UnplacedExecutorFactory()
   federating_factory = python_executor_stacks.FederatingExecutorFactory(
       clients_per_thread=2,
       unplaced_ex_factory=unplaced_factory,
       use_sizing=True)
   federating_factory.create_executor(cardinalities={placements.CLIENTS: 10})
   sizing_ex_list = federating_factory.sizing_executors
   self.assertIsInstance(sizing_ex_list, list)
   self.assertLen(sizing_ex_list, 5)
Esempio n. 6
0
 def test_construction_raises_with_max_fanout_one(self):
   unplaced_factory = python_executor_stacks.UnplacedExecutorFactory()
   federating_factory = python_executor_stacks.FederatingExecutorFactory(
       clients_per_thread=1, unplaced_ex_factory=unplaced_factory)
   flat_stack_fn = python_executor_stacks.create_minimal_length_flat_stack_fn(
       2, federating_factory)
   with self.assertRaises(ValueError):
     python_executor_stacks.ComposingExecutorFactory(
         max_fanout=1,
         unplaced_ex_factory=unplaced_factory,
         flat_stack_fn=flat_stack_fn)
Esempio n. 7
0
 def test_reinvocation_of_create_executor_extends_sizing_executors(self):
   unplaced_factory = python_executor_stacks.UnplacedExecutorFactory()
   federating_factory = python_executor_stacks.FederatingExecutorFactory(
       clients_per_thread=2,
       unplaced_ex_factory=unplaced_factory,
       use_sizing=True)
   federating_factory.create_executor(cardinalities={placements.CLIENTS: 10})
   federating_factory.create_executor(cardinalities={placements.CLIENTS: 12})
   sizing_ex_list = federating_factory.sizing_executors
   self.assertIsInstance(sizing_ex_list, list)
   self.assertLen(sizing_ex_list, 5 + 6)
Esempio n. 8
0
 def test_creates_executor_with_small_fanout(self):
   unplaced_factory = python_executor_stacks.UnplacedExecutorFactory()
   federating_factory = python_executor_stacks.FederatingExecutorFactory(
       clients_per_thread=1, unplaced_ex_factory=unplaced_factory)
   flat_stack_fn = python_executor_stacks.create_minimal_length_flat_stack_fn(
       2, federating_factory)
   composing_ex_factory = python_executor_stacks.ComposingExecutorFactory(
       max_fanout=2,
       unplaced_ex_factory=unplaced_factory,
       flat_stack_fn=flat_stack_fn)
   ex = composing_ex_factory.create_executor({placements.CLIENTS: 10})
   self.assertIsInstance(ex, executor_base.Executor)
Esempio n. 9
0
 def test_constructs_executor_factory_with_federated_factory(self):
   unplaced_factory = python_executor_stacks.UnplacedExecutorFactory()
   federating_factory = python_executor_stacks.FederatingExecutorFactory(
       clients_per_thread=1, unplaced_ex_factory=unplaced_factory)
   flat_stack_fn = python_executor_stacks.create_minimal_length_flat_stack_fn(
       2, federating_factory)
   composing_ex_factory = python_executor_stacks.ComposingExecutorFactory(
       max_fanout=2,
       unplaced_ex_factory=unplaced_factory,
       flat_stack_fn=flat_stack_fn)
   self.assertIsInstance(composing_ex_factory,
                         executor_factory.ExecutorFactory)
Esempio n. 10
0
 def test_executor_with_small_fanout_calls_correct_number_of_composing_strategies(
     self, composing_strategy_mock):
   num_clients = 10
   max_fanout = 2
   clients_per_thread = 1
   unplaced_factory = python_executor_stacks.UnplacedExecutorFactory()
   federating_factory = python_executor_stacks.FederatingExecutorFactory(
       clients_per_thread=clients_per_thread,
       unplaced_ex_factory=unplaced_factory)
   flat_stack_fn = python_executor_stacks.create_minimal_length_flat_stack_fn(
       2, federating_factory)
   composing_ex_factory = python_executor_stacks.ComposingExecutorFactory(
       max_fanout=max_fanout,
       unplaced_ex_factory=unplaced_factory,
       flat_stack_fn=flat_stack_fn)
   composing_ex_factory.create_executor({placements.CLIENTS: num_clients})
   args_list = composing_strategy_mock.call_args_list
   # 5 at the first layer, 1 at the second
   self.assertLen(args_list, 6)
Esempio n. 11
0
 def test_raises_on_access_of_nonexistent_sizing_executors(self):
   unplaced_factory = python_executor_stacks.UnplacedExecutorFactory()
   federating_factory = python_executor_stacks.FederatingExecutorFactory(
       clients_per_thread=1, unplaced_ex_factory=unplaced_factory)
   with self.assertRaisesRegex(ValueError, 'not configured'):
     _ = federating_factory.sizing_executors
Esempio n. 12
0
 def test_constructs_executor_factory(self):
   unplaced_factory = python_executor_stacks.UnplacedExecutorFactory()
   federating_factory = python_executor_stacks.FederatingExecutorFactory(
       clients_per_thread=1, unplaced_ex_factory=unplaced_factory)
   self.assertIsInstance(federating_factory, executor_factory.ExecutorFactory)