Ejemplo n.º 1
0
 def test_dont_suspend_unexistent_stack(self):
     task = SuspendStackTask()
     mock_heat_client = Mock()
     mock_heat_client.stacks.get.side_effect = [HTTPNotFound]
     with patch.multiple(
             task, sleep=0,
             get_heat_client=Mock(return_value=mock_heat_client)):
         res = task.run(self.stack_name, self.auth_url)
         mock_heat_client.actions.suspend.assert_not_called()
Ejemplo n.º 2
0
 def test_dont_suspend_suspended_stack(self):
     task = SuspendStackTask()
     mock_heat_client = Mock()
     mock_heat_client.stacks.get.side_effect = [
             self.stacks['SUSPEND_COMPLETE']]
     with patch.multiple(task,
             sleep=0,
             get_heat_client=Mock(return_value=mock_heat_client)):
         res = task.run(self.stack_name, self.auth_url)
         mock_heat_client.actions.suspend.assert_not_called()
Ejemplo n.º 3
0
 def test_dont_suspend_unexistent_stack(self):
     task = SuspendStackTask()
     mock_heat_client = Mock()
     mock_heat_client.stacks.get.side_effect = [
             HTTPNotFound]
     with patch.multiple(task,
             sleep=0,
             get_heat_client=Mock(return_value=mock_heat_client)):
         res = task.run(self.stack_name, self.auth_url)
         mock_heat_client.actions.suspend.assert_not_called()
Ejemplo n.º 4
0
 def test_dont_suspend_suspending_stack(self):
     task = SuspendStackTask()
     mock_heat_client = Mock()
     mock_heat_client.stacks.get.side_effect = [
         self.stacks['SUSPEND_IN_PROGRESS']
     ]
     with patch.multiple(task,
         get_heat_client=Mock(return_value=mock_heat_client)
     ):
         res = task.run(self.configuration, self.stack_name)
         mock_heat_client.actions.suspend.assert_not_called()
Ejemplo n.º 5
0
 def test_suspend_stack_for_the_second_time(self):
     task = SuspendStackTask()
     mock_heat_client = Mock()
     mock_heat_client.stacks.get.side_effect = [
             self.stacks['RESUME_COMPLETE']]
     with patch.multiple(task,
             sleep=0,
             get_heat_client=Mock(return_value=mock_heat_client)):
         res = task.run(self.stack_name, self.auth_url)
         mock_heat_client.actions.suspend.assert_called_with(
                 stack_id=self.stack_name)
Ejemplo n.º 6
0
 def test_dont_suspend_suspended_stack(self):
     task = SuspendStackTask()
     mock_heat_client = Mock()
     mock_heat_client.stacks.get.side_effect = [
         self.stacks['SUSPEND_COMPLETE']
     ]
     with patch.multiple(
             task, sleep=0,
             get_heat_client=Mock(return_value=mock_heat_client)):
         res = task.run(self.stack_name, self.auth_url)
         mock_heat_client.actions.suspend.assert_not_called()
Ejemplo n.º 7
0
 def test_suspend_stack_for_the_second_time(self):
     task = SuspendStackTask()
     mock_heat_client = Mock()
     mock_heat_client.stacks.get.side_effect = [
         self.stacks['RESUME_COMPLETE']
     ]
     with patch.multiple(
             task, sleep=0,
             get_heat_client=Mock(return_value=mock_heat_client)):
         res = task.run(self.stack_name, self.auth_url)
         mock_heat_client.actions.suspend.assert_called_with(
             stack_id=self.stack_name)
Ejemplo n.º 8
0
 def test_suspend_stack_for_the_first_time(self):
     task = SuspendStackTask()
     mock_heat_client = Mock()
     mock_heat_client.stacks.get.side_effect = [
         self.stacks['CREATE_COMPLETE']
     ]
     with patch.multiple(task,
         get_heat_client=Mock(return_value=mock_heat_client)
     ):
         res = task.run(self.configuration, self.stack_name)
         mock_heat_client.actions.suspend.assert_called_with(
             stack_id=self.stack_name
         )
Ejemplo n.º 9
0
 def test_dont_wait_forever_during_suspend(self):
     task = SuspendStackTask()
     mock_heat_client = Mock()
     mock_heat_client.stacks.get.side_effect = [
             self.stacks['CREATE_IN_PROGRESS'],
             self.stacks['CREATE_IN_PROGRESS'],
             self.stacks['CREATE_IN_PROGRESS'],
             self.stacks['CREATE_IN_PROGRESS'],
             self.stacks['CREATE_IN_PROGRESS']]
     with patch.multiple(task,
             sleep=0, retries=3,
             get_heat_client=Mock(return_value=mock_heat_client)):
         res = task.run(self.stack_name, self.auth_url)
         mock_heat_client.actions.suspend.assert_not_called()
Ejemplo n.º 10
0
 def test_wait_for_create_during_suspend(self):
     task = SuspendStackTask()
     mock_heat_client = Mock()
     mock_heat_client.stacks.get.side_effect = [
             self.stacks['CREATE_IN_PROGRESS'],
             self.stacks['CREATE_IN_PROGRESS'],
             self.stacks['CREATE_IN_PROGRESS'],
             self.stacks['CREATE_COMPLETE']]
     with patch.multiple(task,
             sleep=0,
             get_heat_client=Mock(return_value=mock_heat_client)):
         res = task.run(self.stack_name, self.auth_url)
         mock_heat_client.actions.suspend.assert_called_with(
                 stack_id=self.stack_name)
Ejemplo n.º 11
0
 def test_wait_for_create_during_suspend(self):
     task = SuspendStackTask()
     mock_heat_client = Mock()
     mock_heat_client.stacks.get.side_effect = [
         self.stacks['CREATE_IN_PROGRESS'],
         self.stacks['CREATE_IN_PROGRESS'],
         self.stacks['CREATE_IN_PROGRESS'], self.stacks['CREATE_COMPLETE']
     ]
     with patch.multiple(
             task, sleep=0,
             get_heat_client=Mock(return_value=mock_heat_client)):
         res = task.run(self.stack_name, self.auth_url)
         mock_heat_client.actions.suspend.assert_called_with(
             stack_id=self.stack_name)
Ejemplo n.º 12
0
 def test_dont_wait_forever_during_suspend(self):
     task = SuspendStackTask()
     mock_heat_client = Mock()
     mock_heat_client.stacks.get.side_effect = [
         self.stacks['CREATE_IN_PROGRESS'],
         self.stacks['CREATE_IN_PROGRESS'],
         self.stacks['CREATE_IN_PROGRESS'],
         self.stacks['CREATE_IN_PROGRESS'],
         self.stacks['CREATE_IN_PROGRESS']
     ]
     with patch.multiple(task,
         get_heat_client=Mock(return_value=mock_heat_client)
     ):
         self.configuration['task_timeouts']['retries'] = 3
         res = task.run(self.configuration, self.stack_name)
         mock_heat_client.actions.suspend.assert_not_called()
Ejemplo n.º 13
0
 def test_dont_wait_forever_during_suspend(self):
     task = SuspendStackTask()
     mock_heat_client = Mock()
     mock_heat_client.stacks.get.side_effect = [
         self.stacks['CREATE_IN_PROGRESS'],
         self.stacks['CREATE_IN_PROGRESS'],
         self.stacks['CREATE_IN_PROGRESS'],
         self.stacks['CREATE_IN_PROGRESS'],
         self.stacks['CREATE_IN_PROGRESS']
     ]
     with patch.multiple(
             task,
             sleep=0,
             retries=3,
             get_heat_client=Mock(return_value=mock_heat_client)):
         res = task.run(self.stack_name, self.auth_url)
         mock_heat_client.actions.suspend.assert_not_called()