コード例 #1
0
    def test_ansible_failure(self, git_checkout, git_working_dir):
        """
        Ensure failures in the ansible flow are reflected in the instance
        """
        git_working_dir.return_value = os.path.join(os.path.dirname(__file__), "ansible")

        instance = OpenEdXInstanceFactory(
            name='Integration - test_ansible_failure',
            configuration_playbook_name='playbooks/failure.yml'
        )
        spawn_appserver(instance.ref.pk, mark_active_on_success=True, num_attempts=1)
        instance.refresh_from_db()
        self.assertFalse(instance.get_active_appservers().exists())
        appserver = instance.appserver_set.last()
        self.assertFalse(appserver.is_active)
        self.assertEqual(appserver.status, AppServerStatus.ConfigurationFailed)
        self.assertEqual(appserver.server.status, ServerStatus.Ready)
コード例 #2
0
 def test_ansible_failignore(self, heartbeat_active, git_checkout,
                             git_working_dir):
     """
     Ensure failures that are ignored aren't reflected in the instance
     """
     git_working_dir.return_value = os.path.join(os.path.dirname(__file__),
                                                 "ansible")
     heartbeat_active.return_value = True
     instance = OpenEdXInstanceFactory(
         name='Integration - test_ansible_failignore')
     with patch.object(OpenEdXAppServer, 'CONFIGURATION_PLAYBOOK', new="playbooks/failignore.yml"), \
             self.settings(ANSIBLE_APPSERVER_PLAYBOOK='playbooks/failignore.yml'):
         spawn_appserver(instance.ref.pk,
                         mark_active_on_success=True,
                         num_attempts=1)
     instance.refresh_from_db()
     active_appservers = list(instance.get_active_appservers().all())
     self.assertEqual(len(active_appservers), 1)
     self.assertTrue(active_appservers[0].is_active)
     self.assertEqual(active_appservers[0].status, AppServerStatus.Running)
     self.assertEqual(active_appservers[0].server.status,
                      ServerStatus.Ready)