本文整理汇总了Python中sahara.service.periodic._make_periodic_tasks函数的典型用法代码示例。如果您正苦于以下问题:Python _make_periodic_tasks函数的具体用法?Python _make_periodic_tasks怎么用?Python _make_periodic_tasks使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_make_periodic_tasks函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_transient_cluster_terminate
def test_transient_cluster_terminate(self, terminate_cluster,
use_os_admin_auth_token):
timeutils.set_time_override(datetime.datetime(2005, 2, 1, 0, 0))
ctx = context.ctx()
job = self.api.job_create(ctx, te.SAMPLE_JOB)
ds = self.api.data_source_create(ctx, te.SAMPLE_DATA_SOURCE)
self._make_cluster('1')
self._make_cluster('2')
self._create_job_execution({"end_time": timeutils.utcnow(),
"id": 1,
"cluster_id": "1"},
job, ds, ds)
self._create_job_execution({"end_time": None,
"id": 2,
"cluster_id": "2"},
job, ds, ds)
self._create_job_execution({"end_time": None,
"id": 3,
"cluster_id": "2"},
job, ds, ds)
timeutils.set_time_override(datetime.datetime(2005, 2, 1, 0, 1))
p._make_periodic_tasks().terminate_unneeded_transient_clusters(None)
self.assertEqual(1, terminate_cluster.call_count)
terminate_cluster.assert_has_calls([mock.call(u'1')])
self.assertEqual(1, use_os_admin_auth_token.call_count)
示例2: test_check_for_zombie_proxy_users
def test_check_for_zombie_proxy_users(self, mock_conductor_je_get,
mock_user_delete,
mock_users_list):
user_0 = mock.MagicMock()
user_0.name = "admin"
user_0.id = 0
user_1 = mock.MagicMock()
user_1.name = "job_0"
user_1.id = 1
user_2 = mock.MagicMock()
user_2.name = "job_1"
user_2.id = 2
mock_users_list.return_value = [user_0, user_1, user_2]
je_0 = mock.MagicMock()
je_0.id = 0
je_0.info = {"status": "KILLED"}
je_1 = mock.MagicMock()
je_1.id = 1
je_1.info = {"status": "WAITING"}
mock_conductor_je_get.side_effect = [je_0, je_1]
p._make_periodic_tasks().check_for_zombie_proxy_users(None)
mock_user_delete.assert_called_once_with(user_id=1)
示例3: test_cluster_terminate
def test_cluster_terminate(self, terminate_cluster, utcnow):
utcnow.return_value = datetime.datetime(2005, 2, 1, 0, 0)
ctx = context.ctx()
job = self.api.job_create(ctx, te.SAMPLE_JOB)
ds = self.api.data_source_create(ctx, te.SAMPLE_DATA_SOURCE)
self._make_cluster('1')
self._make_cluster('2')
self._create_job_execution({"end_time": timeutils.utcnow(),
"id": 1,
"cluster_id": "1"},
job, ds, ds)
self._create_job_execution({"end_time": None,
"id": 2,
"cluster_id": "2"},
job, ds, ds)
self._create_job_execution({"end_time": None,
"id": 3,
"cluster_id": "2"},
job, ds, ds)
utcnow.return_value = datetime.datetime(2005, 2, 1, 0, 1)
p._make_periodic_tasks().terminate_unneeded_clusters(None)
self.assertEqual(terminate_cluster.call_count, 1)
terminate_cluster.assert_has_calls([mock.call(u'1')])
示例4: test_not_transient_cluster_does_not_terminate
def test_not_transient_cluster_does_not_terminate(self, terminate_cluster):
timeutils.set_time_override(datetime.datetime(2005, 2, 1, 0, 0))
self._make_cluster('1', is_transient=False)
timeutils.set_time_override(datetime.datetime(2005, 2, 1, 0, 1))
p._make_periodic_tasks().terminate_unneeded_transient_clusters(None)
self.assertEqual(0, terminate_cluster.call_count)
示例5: test_transient_cluster_not_killed_too_early
def test_transient_cluster_not_killed_too_early(self, terminate_cluster):
timeutils.set_time_override(datetime.datetime(2005, 2, 1, second=0))
self._make_cluster('1')
timeutils.set_time_override(datetime.datetime(2005, 2, 1, second=20))
p._make_periodic_tasks().terminate_unneeded_transient_clusters(None)
self.assertEqual(0, terminate_cluster.call_count)
示例6: test_cluster_not_killed_too_early
def test_cluster_not_killed_too_early(self, terminate_cluster, utcnow):
utcnow.return_value = datetime.datetime(2005, 2, 1, second=0)
self._make_cluster('1')
utcnow.return_value = datetime.datetime(2005, 2, 1, second=20)
p._make_periodic_tasks().terminate_unneeded_clusters(None)
self.assertEqual(terminate_cluster.call_count, 0)
示例7: test_cluster_killed_in_time
def test_cluster_killed_in_time(self, terminate_cluster, utcnow):
utcnow.return_value = datetime.datetime(2005, 2, 1, second=0)
self._make_cluster('1')
utcnow.return_value = datetime.datetime(2005, 2, 1, second=40)
p._make_periodic_tasks().terminate_unneeded_clusters(None)
self.assertEqual(terminate_cluster.call_count, 1)
terminate_cluster.assert_has_calls([mock.call(u'1')])
示例8: test_transient_cluster_killed_in_time
def test_transient_cluster_killed_in_time(self, terminate_cluster):
timeutils.set_time_override(datetime.datetime(2005, 2, 1, second=0))
self._make_cluster('1')
timeutils.set_time_override(datetime.datetime(2005, 2, 1, second=40))
p._make_periodic_tasks().terminate_unneeded_transient_clusters(None)
self.assertEqual(1, terminate_cluster.call_count)
terminate_cluster.assert_has_calls([mock.call(u'1')])
示例9: test_active_cluster_not_killed_as_inactive
def test_active_cluster_not_killed_as_inactive(
self, terminate_cluster):
self.override_config('cleanup_time_for_incomplete_clusters', 1)
timeutils.set_time_override(datetime.datetime(2005, 2, 1, second=0))
self._make_cluster('1')
timeutils.set_time_override(datetime.datetime(
2005, 2, 1, hour=1, second=10))
p._make_periodic_tasks().terminate_incomplete_clusters(None)
self.assertEqual(0, terminate_cluster.call_count)
示例10: test_incomplete_cluster_not_killed_too_early
def test_incomplete_cluster_not_killed_too_early(self, terminate_cluster):
self.override_config('cleanup_time_for_incomplete_clusters', 1)
timeutils.set_time_override(datetime.datetime(2005, 2, 1, second=0))
self._make_cluster('1', c_u.CLUSTER_STATUS_SPAWNING)
timeutils.set_time_override(datetime.datetime(
2005, 2, 1, minute=59, second=50))
p._make_periodic_tasks().terminate_incomplete_clusters(None)
self.assertEqual(0, terminate_cluster.call_count)
示例11: test_incomplete_cluster_killed_in_time
def test_incomplete_cluster_killed_in_time(self, terminate_cluster):
self.override_config('cleanup_time_for_incomplete_clusters', 1)
timeutils.set_time_override(datetime.datetime(2005, 2, 1, second=0))
self._make_cluster('1', status='Pending')
timeutils.set_time_override(datetime.datetime(
2005, 2, 1, hour=1, second=10))
p._make_periodic_tasks().terminate_incomplete_clusters(None)
self.assertEqual(1, terminate_cluster.call_count)
terminate_cluster.assert_has_calls([mock.call(u'1')])
示例12: test_incomplete_cluster_killed_in_time
def test_incomplete_cluster_killed_in_time(self, terminate_cluster,
use_os_admin_auth_token):
self.override_config('cleanup_time_for_incomplete_clusters', 1)
timeutils.set_time_override(datetime.datetime(2005, 2, 1, second=0))
self._make_cluster('1', c_u.CLUSTER_STATUS_SPAWNING)
timeutils.set_time_override(datetime.datetime(
2005, 2, 1, hour=1, second=10))
p._make_periodic_tasks().terminate_incomplete_clusters(None)
self.assertEqual(1, terminate_cluster.call_count)
terminate_cluster.assert_has_calls([mock.call(u'1')])
self.assertEqual(1, use_os_admin_auth_token.call_count)
示例13: test_job_status_update
def test_job_status_update(self, get_job_status):
ctx = context.ctx()
job = self.api.job_create(ctx, te.SAMPLE_JOB)
ds = self.api.data_source_create(ctx, te.SAMPLE_DATA_SOURCE)
self._create_job_execution({"end_time": datetime.datetime.now(),
"id": 1},
job, ds, ds)
self._create_job_execution({"end_time": None,
"id": 2},
job, ds, ds)
self._create_job_execution({"end_time": None,
"id": 3},
job, ds, ds)
p._make_periodic_tasks().update_job_statuses(None)
self.assertEqual(2, get_job_status.call_count)
get_job_status.assert_has_calls([mock.call(u'2'),
mock.call(u'3')])
示例14: test_run_verifications_not_executed
def test_run_verifications_not_executed(self, cluster_update, ver_valid):
self._make_cluster('1', status=c_u.CLUSTER_STATUS_ERROR)
p._make_periodic_tasks().run_verifications(None)
ver_valid.assert_not_called()
cluster_update.assert_not_called()
示例15: test_run_verifications_executed
def test_run_verifications_executed(self, cluster_update, ver_valid):
self._make_cluster('1')
p._make_periodic_tasks().run_verifications(None)
self.assertEqual(1, ver_valid.call_count)
cluster_update.assert_called_once_with(
'1', {'verification': {'status': 'START'}})