def test_scheduler_event_handlers(mocker):
    sched = mocker.Mock()
    driver = mocker.Mock()
    proxy = SchedulerProxy(sched)

    proxy.executorLost(driver, mesos_pb2.ExecutorInfo(),
                       mesos_pb2.ExecutorID(), 1)
    proxy.frameworkMessage(driver, mesos_pb2.ExecutorID(),
                           mesos_pb2.SlaveID(), 'message')
    proxy.offerRescinded(driver, mesos_pb2.OfferID())
    proxy.registered(driver, mesos_pb2.FrameworkID(), mesos_pb2.MasterInfo())
    proxy.resourceOffers(driver, [mesos_pb2.Offer(), mesos_pb2.Offer()])
    proxy.slaveLost(driver, mesos_pb2.SlaveID())
    proxy.statusUpdate(driver, mesos_pb2.TaskStatus())
    proxy.reregistered(driver, mesos_pb2.MasterInfo())
    proxy.error(driver, 'message')
    proxy.disconnected(driver)

    sched.on_executor_lost.assert_called_once()
    sched.on_message.assert_called_once()
    sched.on_rescinded.assert_called_once()
    sched.on_registered.assert_called_once()
    sched.on_offers.assert_called_once()
    sched.on_slave_lost.assert_called_once()
    sched.on_update.assert_called_once()
    sched.on_reregistered.assert_called_once()
    sched.on_error.assert_called_once()
    sched.on_disconnected.assert_called_once()
Beispiel #2
0
    def setUp(self):
        self._driver = FakeDriver()
        self._storage = FakeStorage(SequentialThreadingHandler())
        self._zk_client = FakeClient(storage=self._storage)
        self._zk_client.start()

        self._framework_id = mesos_pb2.FrameworkID()
        self._framework_id.value = "framework_id_0"

        self._offer = mesos_pb2.Offer()
        self._offer.id.value = "offer_id_0"
        self._offer.framework_id.value = self._framework_id.value
        self._offer.slave_id.value = "slave_id_0"
        self._offer.hostname = "localhost"

        resources = create_resources(cpus=4,
                                     mem=512 * 3,
                                     ports=set([10000, 10001, 10002]))
        self._offer.resources.extend(resources)

        self._framework_user = "******"

        self._zk_url = "zk://host/mysos/test"
        self._cluster = MySQLCluster("cluster0", "user", "pass", 3)

        self._tmpdir = tempfile.mkdtemp()
        self._state_provider = LocalStateProvider(self._tmpdir)

        framework_info = mesos_pb2.FrameworkInfo(user=getpass.getuser(),
                                                 name="mysos",
                                                 checkpoint=False)
        self._state = Scheduler(framework_info)
Beispiel #3
0
def test_decode_framework_info():
    message = mesos_pb2.FrameworkInfo(id=mesos_pb2.FrameworkID(value='test'))
    wrapped = decode(message)

    assert isinstance(wrapped, MessageProxy)
    assert isinstance(wrapped, FrameworkInfo)
    assert isinstance(wrapped.id, MessageProxy)
    assert isinstance(wrapped.id, FrameworkID)
Beispiel #4
0
    def __init__(self, executor):
        Process.__init__(self, 'executor')
        self.executor = executor

        env = os.environ
        self.local = bool(env.get('MESOS_LOCAL'))
        slave_pid = env.get('MESOS_SLAVE_PID')
        assert slave_pid, 'expecting MESOS_SLAVE_PID in environment'
        self.slave = UPID(slave_pid)
        self.framework_id = mesos_pb2.FrameworkID()
        self.framework_id.value = env.get('MESOS_FRAMEWORK_ID')
        self.executor_id = mesos_pb2.ExecutorID()
        self.executor_id.value = env.get('MESOS_EXECUTOR_ID')
        self.workDirectory = env.get('MESOS_DIRECTORY')
 def setUp(self):
     self.framework_id = mesos_pb2.FrameworkID(value=self.FRAMEWORK_ID)
     self.framework_info = mesos_pb2.FrameworkInfo(
         user='******',
         name='fake_framework_name',
     )
     self.command_info = mesos_pb2.CommandInfo(value='fake-command')
     self.executor_id = mesos_pb2.ExecutorID(value='fake-executor-id')
     self.executor_info = mesos_pb2.ExecutorInfo(
         executor_id=self.executor_id,
         framework_id=self.framework_id,
         command=self.command_info,
     )
     self.slave_id = mesos_pb2.SlaveID(value='fake-slave-id')
     self.offer_id = mesos_pb2.OfferID(value='1')
Beispiel #6
0
                    print "NASEL FRAMEWORK"
                    reuse_framework_id = framework['id']
                    #exit(1)

        #exit(1)
    except ZookeeperNoMaster as ex:
        logging.error("Could not find any Mesos Master: {}".format(ex.message))
        exit(1)

    framework = mesos_pb2.FrameworkInfo()
    framework.user = "******"  # Have Mesos fill in the current user.
    framework.name = "vizceral"
    framework.failover_timeout=300

    #print framework

    if reuse_framework_id!="":
        mesos_framework = mesos_pb2.FrameworkID()
        mesos_framework.value=reuse_framework_id
        framework.id.MergeFrom(mesos_framework)
        logging.error("re-registring existing framework "+reuse_framework_id)

    driver = MesosSchedulerDriver(
        VizCeralScheduler(),
        framework,
        ZK_HOSTS

    )

    driver.run()