def test_api_version_mismatch(self):
     resp = Response(serverInfo=ServerInfo(
         thriftAPIVersion=THRIFT_API_VERSION + 1))
     self.mock_thrift_client.getQuota(IgnoreArg()).AndReturn(resp)
     self.mox.ReplayAll()
     with pytest.raises(
             scheduler_client.SchedulerProxy.ThriftInternalError):
         self.make_scheduler_proxy().getQuota(ROLE)
from apache.aurora.common.cluster import Cluster
from apache.aurora.common.transport import TRequestsTransport

import gen.apache.aurora.api.AuroraAdmin as AuroraAdmin
import gen.apache.aurora.api.AuroraSchedulerManager as AuroraSchedulerManager
from gen.apache.aurora.api.constants import THRIFT_API_VERSION
from gen.apache.aurora.api.ttypes import (
    Hosts, JobConfiguration, JobKey, JobUpdateQuery, JobUpdateRequest, Lock,
    LockValidation, ResourceAggregate, Response, ResponseCode, ResponseDetail,
    RewriteConfigsRequest, ScheduleStatus, ServerInfo, SessionKey, TaskQuery)

ROLE = 'foorole'
JOB_NAME = 'barjobname'
JOB_ENV = 'devel'
JOB_KEY = JobKey(role=ROLE, environment=JOB_ENV, name=JOB_NAME)
DEFAULT_RESPONSE = Response(serverInfo=ServerInfo(
    thriftAPIVersion=THRIFT_API_VERSION))


def test_coverage():
    """Make sure a new thrift RPC doesn't get added without minimal test coverage."""
    for name, klass in inspect.getmembers(AuroraAdmin) + inspect.getmembers(
            AuroraSchedulerManager):
        if name.endswith('_args'):
            rpc_name = name[:-len('_args')]
            assert hasattr(TestSchedulerProxyAdminInjection, 'test_%s' %
                           rpc_name), ('No test defined for RPC %s' % rpc_name)


class TestSchedulerProxy(scheduler_client.SchedulerProxy):
    """In testing we shouldn't use the real SSHAgentAuthenticator."""
    def session_key(self):
Beispiel #3
0
 def create_blank_response(cls, code, msg):
     return Response(
         responseCode=code,
         details=[ResponseDetail(message=msg)],
         serverInfo=ServerInfo(thriftAPIVersion=CURRENT_API_VERSION.major))
Beispiel #4
0
    AcquireLockResult, AddInstancesConfig, AssignedTask, Constraint,
    ExecutorConfig, Identity, JobConfiguration, JobKey, LimitConstraint,
    LockKey, LockValidation, Metadata, PopulateJobResult, ResourceAggregate,
    Response, ResponseCode, ResponseDetail, Result, ScheduledTask,
    ScheduleStatusResult, ServerInfo, SessionKey, TaskConfig, TaskConstraint,
    TaskQuery, ValueConstraint)

# Debug output helper -> enables log.* in source.
if 'UPDATER_DEBUG' in environ:
    from twitter.common import log
    from twitter.common.log.options import LogOptions
    LogOptions.set_disk_log_level('NONE')
    LogOptions.set_stderr_log_level('DEBUG')
    log.init('test_updater')

SERVER_INFO = ServerInfo(thriftAPIVersion=THRIFT_API_VERSION)


def make_response(code, msg='test'):
    return Response(responseCode=code,
                    serverInfo=SERVER_INFO,
                    details=[ResponseDetail(message=msg)])


class FakeConfig(object):
    def __init__(self, role, name, env, update_config):
        self._role = role
        self._env = env
        self._name = name
        self._update_config = update_config
        self.job_config = None
Beispiel #5
0
def make_response(code=ResponseCode.OK, message='test', result=None):
  return Response(
    responseCode=code,
    details=[ResponseDetail(message=message)],
    result=result,
    serverInfo=ServerInfo(clusterName='test'))
 def getRoleSummary(self):  # noqa
     server_info = ServerInfo(clusterName='west', thriftAPIVersion=3)
     return Response(responseCode=ResponseCode.OK, serverInfo=server_info)
Beispiel #7
0
def make_response(code=ResponseCode.OK, message='test', result=None):
  return Response(
    responseCode=code,
    details=[ResponseDetail(message=message)],
    result=result,
    serverInfo=ServerInfo(clusterName='test', thriftAPIVersion=THRIFT_API_VERSION))