def test_get_service_status_failed_service(self, mock_get): scheduler = scheduling.APISchedulingService() mock_get.return_value = self.fake_service service_status = scheduler.get_service_status(mock.ANY, self.fake_service.id) mock_get.assert_called_once_with(mock.ANY, self.fake_service.id) self.assertEqual('FAILED', service_status)
def test_get_services_status_without_services_in_list( self, mock_service_update, mock_get_list, mock_service_status): scheduler = scheduling.APISchedulingService() mock_get_list.return_value = [self.fake_service] mock_service_status.return_value = 'ACTIVE' scheduler.get_services_status(mock.ANY) mock_service_status.assert_called_once_with(mock.ANY, self.fake_service.id) mock_service_update.assert_not_called()
def test_get_services_status_with_services_in_list_diff_status( self, mock_service_update, mock_get_list, mock_service_status): scheduler = scheduling.APISchedulingService() mock_get_list.return_value = [self.fake_service] scheduler.services_status = {1: 'FAILED'} mock_service_status.return_value = 'ACTIVE' scheduler.get_services_status(mock.ANY) mock_service_status.assert_called_once_with(mock.ANY, self.fake_service.id) mock_service_update.assert_called_once_with(mock.ANY, self.fake_service, state='ACTIVE')
def main(): service.prepare_service(sys.argv, CONF) host, port = cfg.CONF.api.host, cfg.CONF.api.port protocol = "http" if not CONF.api.enable_ssl_api else "https" # Build and start the WSGI app server = service.WSGIService('watcher-api', CONF.api.enable_ssl_api) if host == '127.0.0.1': LOG.info('serving on 127.0.0.1:%(port)s, ' 'view at %(protocol)s://127.0.0.1:%(port)s' % dict(protocol=protocol, port=port)) else: LOG.info('serving on %(protocol)s://%(host)s:%(port)s' % dict(protocol=protocol, host=host, port=port)) api_schedule = scheduling.APISchedulingService() api_schedule.start() launcher = service.launch(CONF, server, workers=server.workers) launcher.wait()
def test_start_scheduling_service(self, m_start): scheduler = scheduling.APISchedulingService() scheduler.start() m_start.assert_called_once_with(scheduler) jobs = scheduler.get_jobs() self.assertEqual(1, len(jobs))