Beispiel #1
0
 def test_uses_step_request(self):
     """Steps are converted to requests."""
     steps = [TestStep(Effect(Constant((StepResult.SUCCESS, 'foo')))),
              TestStep(Effect(Error(RuntimeError('uh oh'))))]
     effect = steps_to_effect(steps)
     self.assertIs(type(effect.intent), ParallelEffects)
     expected_exc_info = matches(MatchesException(RuntimeError('uh oh')))
     self.assertEqual(
         sync_perform(test_dispatcher(), effect),
         [(StepResult.SUCCESS, 'foo'),
          (StepResult.RETRY,
           [ErrorReason.Exception(expected_exc_info)])])
Beispiel #2
0
 def test_uses_step_request(self):
     """Steps are converted to requests."""
     steps = [
         TestStep(Effect(Constant((StepResult.SUCCESS, 'foo')))),
         TestStep(Effect(Error(RuntimeError('uh oh'))))
     ]
     effect = steps_to_effect(steps)
     self.assertIs(type(effect.intent), ParallelEffects)
     expected_exc_info = matches(MatchesException(RuntimeError('uh oh')))
     self.assertEqual(
         sync_perform(test_dispatcher(), effect),
         [(StepResult.SUCCESS, 'foo'),
          (StepResult.RETRY, [ErrorReason.Exception(expected_exc_info)])])
Beispiel #3
0
    def test_first_error_extraction(self):
        """
        If the GetScalingGroupInfo effect fails, its exception is raised
        directly, without the FirstError wrapper.
        """
        # Perform the GetScalingGroupInfo by raising an exception
        sequence = [
            (Log("begin-convergence", {}), noop),
            (Func(datetime.utcnow), lambda i: self.now),
            (MsgWithTime("gather-convergence-data", mock.ANY),
             nested_sequence([
                parallel_sequence([
                    [(self.gsgi, lambda i: raise_(RuntimeError('foo')))],
                    [("anything", noop)]
                ])
             ]))
        ]

        # And make sure that exception isn't wrapped in FirstError.
        e = self.assertRaises(
            RuntimeError, perform_sequence, sequence, self._invoke(),
            test_dispatcher())
        self.assertEqual(str(e), 'foo')
Beispiel #4
0
 def _gcws(self, path):
     eff = Effect(GetChildrenWithStats(path))
     dispatcher = ComposedDispatcher([test_dispatcher(),
                                      get_zk_dispatcher(self.model)])
     return sync_perform(dispatcher, eff)
Beispiel #5
0
 def assert_logs(self, steps, intents):
     """Log some steps and ensure they result in the given Log intents."""
     sequence = SequenceDispatcher([(intent, noop) for intent in intents])
     with sequence.consume():
         sync_perform(test_dispatcher(sequence), log_steps(steps))
Beispiel #6
0
 def _gcws(self, path):
     eff = Effect(GetChildrenWithStats(path))
     dispatcher = ComposedDispatcher(
         [test_dispatcher(),
          get_zk_dispatcher(self.model)])
     return sync_perform(dispatcher, eff)
Beispiel #7
0
 def assert_logs(self, steps, intents):
     """Log some steps and ensure they result in the given Log intents."""
     sequence = SequenceDispatcher([(intent, noop) for intent in intents])
     with sequence.consume():
         sync_perform(test_dispatcher(sequence), log_steps(steps))