Пример #1
0
 def run(events_dir):
     """Run Treadmill master scheduler."""
     scheduler.DIMENSION_COUNT = 3
     cell_master = master.Master(
         zkbackend.ZkBackend(context.GLOBAL.zk.conn), context.GLOBAL.cell,
         events_dir)
     cell_master.run()
Пример #2
0
    def run(root):
        """Run scheduler with fs backend."""
        treadmill_sched.DIMENSION_COUNT = 3

        cell_master = master.Master(fsbackend.FsBackend(root),
                                    context.GLOBAL.cell)
        cell_master.run_loop()
Пример #3
0
    def setUp(self):
        super(MasterTest, self).setUp()

        scheduler.DIMENSION_COUNT = 3

        self.root = tempfile.mkdtemp()
        os.environ['TREADMILL_MASTER_ROOT'] = self.root
        backend = zkbackend.ZkBackend(kazoo.client.KazooClient())
        self.master = master.Master(backend, 'test-cell')
        # Use 111 to assert on zkhandle value.
        # Disable the exit on exception hack for tests
        self.old_exit_on_unhandled = treadmill.utils.exit_on_unhandled
        treadmill.utils.exit_on_unhandled = mock.Mock(side_effect=lambda x: x)
Пример #4
0
    def test_readonly_master(self):
        """Tests the ZK operations of a readonly master."""
        zk_content = {
            'server.presence': {
                'test1.xx.com': {},
                'test2.xx.com': {},
            },
            'cell': {
                'pod:pod1': {},
            },
            'buckets': {
                'pod:pod1': {
                    'traits': None,
                },
                'rack:1234': {
                    'traits': None,
                    'parent': 'pod:pod1',
                },
            },
            'identity-groups': {},
            'partitions': {},
            'servers': {
                'test1.xx.com': {
                    'memory': '16G',
                    'disk': '128G',
                    'cpu': '400%',
                    'parent': 'rack:1234',
                    'up_since': 100,
                },
                'test2.xx.com': {
                    'memory': '16G',
                    'disk': '128G',
                    'cpu': '400%',
                    'parent': 'rack:1234',
                    'up_since': 200,
                },
            },
            # Comments indicate zkutils functions that would get called
            # for each entity if the master weren't in readonly mode
            'placement': {  # ensure_exists and put on each placement
                'test1.xx.com': {
                    '.data': """
                        state: up
                        since: 100
                    """,
                    'xxx.app1#1234': '',  # on two servers: ensure_deleted
                    'xxx.app2#2345': '',  # not scheduled: ensure_deleted
                },
                'test2.xx.com': {
                    '.data': """
                        state: up
                        since: 100
                    """,
                    'xxx.app1#1234': '',  # on two servers: ensure_deleted
                }
            },
            'scheduled': {
                'xxx.app1#1234': {
                    'affinity': 'app1',
                    'memory': '1G',
                    'disk': '1G',
                    'cpu': '100%',
                },
                'xxx.app3#6789': {  # gets scheduled by init_schedule: put
                    'affinity': 'app3',
                    'memory': '1G',
                    'disk': '1G',
                    'cpu': '100%',
                },
            }
        }

        time.time.return_value = 500
        self.make_mock_zk(zk_content)
        ro_master = master.Master(
            zkbackend.ZkReadonlyBackend(kazoo.client.KazooClient()),
            'test-cell',

        )
        ro_master.load_model()
        ro_master.init_schedule()

        self.assertFalse(treadmill.zkutils.ensure_deleted.called)
        self.assertFalse(treadmill.zkutils.ensure_exists.called)
        self.assertFalse(treadmill.zkutils.put.called)