本文整理汇总了Python中gen.apache.aurora.api.ttypes.Response类的典型用法代码示例。如果您正苦于以下问题:Python Response类的具体用法?Python Response怎么用?Python Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Response类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_update_details_response
def get_update_details_response(cls):
query_response = Response()
query_response.responseCode = ResponseCode.OK
query_response.result = Result()
details = JobUpdateDetails(
update=JobUpdate(
summary=JobUpdateSummary(
key=UPDATE_KEY,
user="me",
state=JobUpdateState(
status=JobUpdateStatus.ROLLING_FORWARD, createdTimestampMs=1000, lastModifiedTimestampMs=2000
),
)
),
updateEvents=[
JobUpdateEvent(status=JobUpdateStatus.ROLLING_FORWARD, timestampMs=3000),
JobUpdateEvent(
status=JobUpdateStatus.ROLL_FORWARD_PAUSED, message="Investigating issues", timestampMs=4000
),
JobUpdateEvent(status=JobUpdateStatus.ROLLING_FORWARD, timestampMs=5000),
],
instanceEvents=[
JobInstanceUpdateEvent(instanceId=1, timestampMs=6000, action=JobUpdateAction.INSTANCE_UPDATING),
JobInstanceUpdateEvent(instanceId=2, timestampMs=7000, action=JobUpdateAction.INSTANCE_UPDATING),
JobInstanceUpdateEvent(instanceId=1, timestampMs=8000, action=JobUpdateAction.INSTANCE_UPDATED),
JobInstanceUpdateEvent(instanceId=2, timestampMs=9000, action=JobUpdateAction.INSTANCE_UPDATED),
],
)
query_response.result.getJobUpdateDetailsResult = GetJobUpdateDetailsResult(details=details)
return query_response
示例2: mock_scheduler
def mock_scheduler(cls, response_code=None):
scheduler = Mock()
response_code = ResponseCode.OK if response_code is None else response_code
resp = Response(responseCode=response_code, messageDEPRECATED='test')
resp.result = Result(scheduleStatusResult=ScheduleStatusResult(tasks=cls.create_tasks()))
scheduler.getTasksWithoutConfigs.return_value = resp
return scheduler
示例3: mock_scheduler
def mock_scheduler(cls, response_code=None):
scheduler = create_autospec(spec=SchedulerThriftApiSpec, instance=True)
response_code = ResponseCode.OK if response_code is None else response_code
resp = Response(responseCode=response_code, details=[ResponseDetail(message='test')])
resp.result = Result(scheduleStatusResult=ScheduleStatusResult(tasks=cls.create_tasks()))
scheduler.getTasksWithoutConfigs.return_value = resp
return scheduler
示例4: expect_start
def expect_start(self, response_code=None):
response_code = ResponseCode.OK if response_code is None else response_code
response = Response(responseCode=response_code,
messageDEPRECATED='test',
serverInfo=SERVER_INFO)
response.result = Result(acquireLockResult=AcquireLockResult(lock=self._lock))
self._scheduler.acquireLock(LockKey(job=self._job_key), self._session_key).AndReturn(response)
示例5: get_update_details_response
def get_update_details_response(cls):
query_response = Response()
query_response.responseCode = ResponseCode.OK
query_response.result = Result()
details = JobUpdateDetails()
query_response.result.getJobUpdateDetailsResult = GetJobUpdateDetailsResult(details=details)
details.update = JobUpdate()
details.update.summary = JobUpdateSummary(
jobKey=AuroraJobKey("west", "mcc", "test", "hello"),
updateId="fake-update-identifier",
user="me",
state=JobUpdateState(
status=JobUpdateStatus.ROLLING_FORWARD,
createdTimestampMs=1411404927,
lastModifiedTimestampMs=14114056030,
),
)
details.updateEvents = [
JobUpdateEvent(status=JobUpdateStatus.ROLLING_FORWARD, timestampMs=1411404927),
JobUpdateEvent(status=JobUpdateStatus.ROLL_FORWARD_PAUSED, timestampMs=1411405000),
JobUpdateEvent(status=JobUpdateStatus.ROLLING_FORWARD, timestampMs=1411405100),
]
details.instanceEvents = [
JobInstanceUpdateEvent(instanceId=1, timestampMs=1411404930, action=JobUpdateAction.INSTANCE_UPDATING),
JobInstanceUpdateEvent(instanceId=2, timestampMs=1411404940, action=JobUpdateAction.INSTANCE_UPDATING),
JobInstanceUpdateEvent(instanceId=1, timestampMs=1411404950, action=JobUpdateAction.INSTANCE_UPDATED),
JobInstanceUpdateEvent(instanceId=2, timestampMs=1411404960, action=JobUpdateAction.INSTANCE_UPDATED),
]
return query_response
示例6: mock_get_quota
def mock_get_quota(self, allocated, consumed, response_code=None):
response_code = ResponseCode.OK if response_code is None else response_code
resp = Response(responseCode=response_code, details=[ResponseDetail(message='test')])
resp.result = Result(
getQuotaResult=GetQuotaResult(
quota=deepcopy(allocated), prodSharedConsumption=deepcopy(consumed)))
self._scheduler.getQuota.return_value = resp
示例7: mock_get_quota
def mock_get_quota(self, allocated, consumed, response_code=None):
response_code = ResponseCode.OK if response_code is None else response_code
resp = Response(responseCode=response_code, messageDEPRECATED="test")
resp.result = Result(
getQuotaResult=GetQuotaResult(quota=deepcopy(allocated), prodConsumption=deepcopy(consumed))
)
self._scheduler.getQuota.return_value = resp
示例8: mock_restart_fails
def mock_restart_fails(self):
response = Response(responseCode=ResponseCode.ERROR, messageDEPRECATED='test error')
response.serverInfo = ServerInfo(thriftAPIVersion=THRIFT_API_VERSION)
self.mock_scheduler.restartShards(
JOB.to_thrift(),
IgnoreArg(),
self.lock,
SESSION_KEY).AndReturn(response)
示例9: expect_get_statuses
def expect_get_statuses(self, instance_ids=WATCH_INSTANCES, num_calls=EXPECTED_CYCLES):
tasks = [self.create_task(instance_id) for instance_id in instance_ids]
response = Response(responseCode=ResponseCode.OK, messageDEPRECATED="test")
response.result = Result()
response.result.scheduleStatusResult = ScheduleStatusResult(tasks=tasks)
query = self.get_tasks_status_query(instance_ids)
for _ in range(int(num_calls)):
self._scheduler.getTasksWithoutConfigs(query).AndReturn(response)
示例10: mock_restart_instances
def mock_restart_instances(self, instances, lock=None):
response = Response(responseCode=ResponseCode.OK, messageDEPRECATED='test')
response.serverInfo = ServerInfo(thriftAPIVersion=THRIFT_API_VERSION)
self.mock_scheduler.restartShards(
JOB.to_thrift(),
instances,
lock,
SESSION_KEY).AndReturn(response)
self.mock_instance_watcher.watch(instances).AndReturn([])
示例11: expect_get_tasks
def expect_get_tasks(self, tasks, ignore_ids=None, response_code=None):
response_code = ResponseCode.OK if response_code is None else response_code
response = Response(responseCode=response_code,
messageDEPRECATED='test',
serverInfo=SERVER_INFO)
scheduled = []
for index, task in enumerate(tasks):
if not ignore_ids or index not in ignore_ids:
scheduled.append(ScheduledTask(assignedTask=AssignedTask(task=task, instanceId=index)))
response.result = Result(scheduleStatusResult=ScheduleStatusResult(tasks=scheduled))
query = TaskQuery(jobKeys=[self._job_key], statuses=ACTIVE_STATES)
self._scheduler.getTasksStatus(query).AndReturn(response)
示例12: mock_status_active_tasks
def mock_status_active_tasks(self, instance_ids):
tasks = []
for i in instance_ids:
tasks.append(ScheduledTask(
status=ScheduleStatus.RUNNING,
assignedTask=AssignedTask(task=TaskConfig(), instanceId=i)
))
response = Response(responseCode=ResponseCode.OK, messageDEPRECATED='test')
response.result = Result()
response.result.scheduleStatusResult = ScheduleStatusResult(tasks=tasks)
self.mock_scheduler.getTasksWithoutConfigs(IgnoreArg()).AndReturn(response)
示例13: expect_get_tasks
def expect_get_tasks(self, tasks, ignore_ids=None, response_code=None):
response_code = ResponseCode.OK if response_code is None else response_code
response = Response(responseCode=response_code, messageDEPRECATED='test')
scheduled = []
for index, task in enumerate(tasks):
if not ignore_ids or index not in ignore_ids:
scheduled.append(ScheduledTask(assignedTask=AssignedTask(task=task, instanceId=index)))
response.result = Result(scheduleStatusResult=ScheduleStatusResult(tasks=scheduled))
query = TaskQuery(
owner=Identity(role=self._job_key.role),
environment=self._job_key.environment,
jobName=self._job_key.name,
statuses=ACTIVE_STATES)
self._scheduler.getTasksStatus(query).AndReturn(response)
示例14: get_status_query_response
def get_status_query_response(self, count=3):
query_response = Response()
query_response.responseCode = ResponseCode.OK
query_response.result = Result()
summaries = GetJobUpdateSummariesResult()
query_response.result.getJobUpdateSummariesResult = summaries
summaries.updateSummaries = [JobUpdateSummary(
updateId="%s" % i,
jobKey=self.TEST_JOBKEY.to_thrift(),
user="me",
state=JobUpdateState(
status=JobUpdateStatus.ROLLED_FORWARD,
createdTimestampMs=1411404927,
lastModifiedTimestampMs=14114056030)) for i in range(count)]
return query_response
示例15: setUp
def setUp(self):
self.mox = Mox()
self.mox.StubOutClassWithMocks(AuroraAdmin, 'Client')
self.mox.StubOutClassWithMocks(scheduler_client, 'SchedulerClient')
self.mock_scheduler_client = self.mox.CreateMock(scheduler_client.SchedulerClient)
self.mock_thrift_client = self.mox.CreateMock(AuroraAdmin.Client)
scheduler_client.SchedulerClient.get(IgnoreArg(), verbose=IgnoreArg()).AndReturn(
self.mock_scheduler_client)
self.mock_scheduler_client.get_thrift_client().AndReturn(self.mock_thrift_client)
version_resp = Response(responseCode=ResponseCode.OK)
version_resp.result = Result(getVersionResult=CURRENT_API_VERSION)
self.mock_thrift_client.getVersion().AndReturn(version_resp)