Пример #1
0
    def setUp(self):
        super(CloudTestCase, self).setUp()
        self.flags(fake_libvirt=True,
                   fake_storage=True,
                   fake_users=True)

        self.conn = rpc.Connection.instance()
        logging.getLogger().setLevel(logging.DEBUG)

        # set up our cloud
        self.cloud = cloud.CloudController()
        self.cloud_consumer = rpc.AdapterConsumer(connection=self.conn,
                                                      topic=FLAGS.cloud_topic,
                                                      proxy=self.cloud)
        self.injected.append(self.cloud_consumer.attach_to_tornado(self.ioloop))

        # set up a node
        self.node = node.Node()
        self.node_consumer = rpc.AdapterConsumer(connection=self.conn,
                                                     topic=FLAGS.compute_topic,
                                                     proxy=self.node)
        self.injected.append(self.node_consumer.attach_to_tornado(self.ioloop))

        try:
            users.UserManager.instance().create_user('admin', 'admin', 'admin')
        except: pass
        admin = users.UserManager.instance().get_user('admin')
        project = users.UserManager.instance().create_project('proj', 'admin', 'proj')
        self.context = api.APIRequestContext(handler=None,project=project,user=admin)
Пример #2
0
    def setUp(self):
        super(CloudTestCase, self).setUp()

        self.conn = rpc.Connection.instance()
        logging.getLogger().setLevel(logging.DEBUG)

        # set up our cloud
        self.cloud = cloud.CloudController()
        self.cloud_consumer = rpc.AdapterConsumer(connection=self.conn,
                                                  topic=FLAGS.cloud_topic,
                                                  proxy=self.cloud)
        self.injected.append(self.cloud_consumer.attach_to_tornado(
            self.ioloop))

        # set up a node
        self.node = node.Node()
        self.node_consumer = rpc.AdapterConsumer(connection=self.conn,
                                                 topic=FLAGS.compute_topic,
                                                 proxy=self.node)
        self.injected.append(self.node_consumer.attach_to_tornado(self.ioloop))

        user_mocker = mox.Mox()
        self.admin = user_mocker.CreateMock(users.User)
        self.admin.is_authorized(mox.IgnoreArg()).AndReturn(True)
        self.context = api.APIRequestContext(handler=None, user=self.admin)
Пример #3
0
 def setUp(self):
     logging.getLogger().setLevel(logging.DEBUG)
     super(NodeConnectionTestCase, self).setUp()
     self.flags(fake_libvirt=True,
                fake_storage=True,
                fake_users=True,
                redis_db=8)
     self.node = node.Node()
Пример #4
0
 def setUp(self):
     logging.getLogger().setLevel(logging.DEBUG)
     super(StorageTestCase, self).setUp()
     self.mynode = node.Node()
     self.mystorage = None
     if FLAGS.fake_storage:
         self.mystorage = storage.FakeBlockStore()
     else:
         self.mystorage = storage.BlockStore()
Пример #5
0
 def setUp(self):
     logging.getLogger().setLevel(logging.DEBUG)
     super(StorageTestCase, self).setUp()
     self.mynode = node.Node()
     self.mystorage = None
     self.flags(fake_libvirt=True, fake_storage=True, redis_db=8)
     if FLAGS.fake_storage:
         self.mystorage = storage.FakeBlockStore()
     else:
         self.mystorage = storage.BlockStore()
Пример #6
0
    def test_serialization(self):
        return
        # This doesn't work b/c of the spawn approach
        instance_id = 'foo'
        first_node = node.Node()
        inst = yield first_node.run_instance(instance_id)
        
        # force the state so that we can verify that it changes
        inst._s['state'] = node.Instance.NOSTATE
        xml = inst.toXml()
        self.assert_(ElementTree.parse(StringIO.StringIO(xml)))
        
        # spawn the instance to push its state along, so that we can test
        # that state is being set to the new state after fromXml
        # TODO(termie): this will probably break if inst.spawn() gets
        #               much smarter
        self.assertEqual(inst.state, node.Instance.NOSTATE)
        yield inst.spawn()
        self.assertEqual(inst.state, node.Instance.RUNNING)

        second_node = node.Node()
        new_inst = node.Instance.fromXml(second_node._conn, xml)
        self.assertEqual(new_inst.state, node.Instance.RUNNING)
        rv = first_node.terminate_instance(instance_id)
Пример #7
0
 def setUp(self):
     logging.getLogger().setLevel(logging.DEBUG)
     super(NodeConnectionTestCase, self).setUp()
     self.node = node.Node()