Esempio n. 1
0
    def setUp(self):
        setup_config('data/config.py')

        self.address = ("localhost", 9001)

        with patch(
                'core.connection.Virsh',
                Mock(),
        ), patch('core.network.Network',
                 Mock()), patch('core.db.Database', DatabaseMock()):
            from vmmaster.server import VMMasterServer
            self.vmmaster = VMMasterServer(reactor, self.address[1])

        self.pool = self.vmmaster.app.pool

        server_is_up(self.address)

        self.desired_caps = {
            'desiredCapabilities': {
                'platform': self.pool.platforms.platforms.keys()[0]
            }
        }

        from core.config import config
        config.SESSION_TIMEOUT = 1

        self.ctx = self.vmmaster.app.app_context()
        self.ctx.push()
Esempio n. 2
0
 def test_server_shutdown(self):
     """
     - shutdown current instance
     Expected: server is down
     """
     del self.vmmaster
     with self.assertRaises(RuntimeError):
         server_is_up(self.address, wait=1)
Esempio n. 3
0
    def setUp(self):
        setup_config('data/config_with_preloaded.py')

        self.address = ("localhost", 9001)

        self.desired_caps = {'desiredCapabilities': {'platform': 'origin_1'}}

        mocked_image = Mock(id=1,
                            status='active',
                            get=Mock(return_value='snapshot'),
                            min_disk=20,
                            min_ram=2,
                            instance_type_flavorid=1)
        type(mocked_image).name = PropertyMock(return_value='test_origin_1')

        with patch(
                'core.connection.Virsh',
                Mock(),
        ), patch('core.network.Network', Mock()), patch(
                'core.db.Database',
                Mock(add=Mock(side_effect=set_primary_key))), patch.multiple(
                    'core.utils.openstack_utils',
                    neutron_client=Mock(return_value=Mock()),
                    glance_client=Mock(return_value=Mock()),
                    nova_client=Mock(return_value=Mock())), patch.multiple(
                        'vmpool.clone.OpenstackClone',
                        _wait_for_activated_service=custom_wait,
                        get_network_id=Mock(return_value=1),
                        get_network_name=Mock(
                            return_value='Local-Net')), patch.multiple(
                                'vmpool.platforms.OpenstackPlatforms',
                                images=Mock(return_value=[mocked_image]),
                                flavor_params=Mock(return_value={
                                    'vcpus': 1,
                                    'ram': 2
                                }),
                                limits=Mock(
                                    return_value={
                                        'maxTotalCores': 10,
                                        'maxTotalInstances': 10,
                                        'maxTotalRAMSize': 100,
                                        'totalCoresUsed': 0,
                                        'totalInstancesUsed': 0,
                                        'totalRAMUsed': 0
                                    })):
            from vmmaster.server import VMMasterServer
            self.vmmaster = VMMasterServer(reactor, self.address[1])

            self.ctx = self.vmmaster.app.app_context()
            self.ctx.push()

            self.pool = self.vmmaster.app.pool

        server_is_up(self.address)
Esempio n. 4
0
    def setUp(self):
        with patch(
                'core.connection.Virsh',
                Mock(),
        ), patch('core.network.Network',
                 Mock()), patch('core.db.Database', DatabaseMock()), patch(
                     'core.sessions.SessionWorker', Mock()):
            from vmmaster.server import VMMasterServer
            self.vmmaster = VMMasterServer(reactor, self.address[1])

        self.pool = self.vmmaster.app.pool

        server_is_up(self.address)