ComputeConnectionTestCase is almost working again
This commit is contained in:
@@ -528,7 +528,11 @@ class AuthManager(object):
|
||||
member_users)
|
||||
if project_dict:
|
||||
project = Project(**project_dict)
|
||||
# FIXME(ja): create network?
|
||||
# FIXME(ja): EVIL HACK - this should poll from a pool
|
||||
session = models.create_session()
|
||||
net = models.Network(project_id=project.id, kind='vlan')
|
||||
session.add(net)
|
||||
session.commit()
|
||||
return project
|
||||
|
||||
def add_to_project(self, user, project):
|
||||
|
||||
@@ -22,7 +22,6 @@ class Image(Base):
|
||||
created_at = Column(DateTime)
|
||||
updated_at = Column(DateTime) # auto update on change FIXME
|
||||
|
||||
|
||||
@validates('image_type')
|
||||
def validate_image_type(self, key, image_type):
|
||||
assert(image_type in ['machine', 'kernel', 'ramdisk', 'raw'])
|
||||
@@ -46,6 +45,7 @@ class Network(Base):
|
||||
id = Column(Integer, primary_key=True)
|
||||
bridge = Column(String)
|
||||
vlan = Column(String)
|
||||
kind = Column(String)
|
||||
#vpn_port = Column(Integer)
|
||||
project_id = Column(String) #, ForeignKey('projects.id'), nullable=False)
|
||||
|
||||
@@ -77,7 +77,8 @@ class Instance(Base):
|
||||
key_data = Column(Text)
|
||||
security_group = Column(String)
|
||||
|
||||
state = Column(String)
|
||||
state = Column(Integer)
|
||||
state_description = Column(String)
|
||||
|
||||
hostname = Column(String)
|
||||
physical_node_id = Column(Integer)
|
||||
@@ -86,6 +87,13 @@ class Instance(Base):
|
||||
|
||||
user_data = Column(Text)
|
||||
|
||||
def set_state(self, state_code, state_description=None):
|
||||
from nova.compute import power_state
|
||||
self.state = state_code
|
||||
if not state_description:
|
||||
state_description = power_state.name(state_code)
|
||||
self.state_description = state_description
|
||||
|
||||
# ramdisk = relationship(Ramdisk, backref=backref('instances', order_by=id))
|
||||
# kernel = relationship(Kernel, backref=backref('instances', order_by=id))
|
||||
# project = relationship(Project, backref=backref('instances', order_by=id))
|
||||
@@ -95,9 +103,9 @@ class Instance(Base):
|
||||
# power_state = what we have
|
||||
# task_state = transitory and may trigger power state transition
|
||||
|
||||
@validates('state')
|
||||
def validate_state(self, key, state):
|
||||
assert(state in ['nostate', 'running', 'blocked', 'paused', 'shutdown', 'shutoff', 'crashed'])
|
||||
#@validates('state')
|
||||
#def validate_state(self, key, state):
|
||||
# assert(state in ['nostate', 'running', 'blocked', 'paused', 'shutdown', 'shutoff', 'crashed'])
|
||||
|
||||
class Volume(Base):
|
||||
__tablename__ = 'volumes'
|
||||
|
||||
@@ -91,31 +91,25 @@ class ComputeConnectionTestCase(test.TrialTestCase):
|
||||
def test_run_describe_terminate(self):
|
||||
instance_id = self.create_instance()
|
||||
|
||||
rv = yield self.compute.run_instance(instance_id)
|
||||
yield self.compute.run_instance(instance_id)
|
||||
|
||||
rv = yield self.compute.describe_instances()
|
||||
logging.info("Running instances: %s", rv)
|
||||
self.assertEqual(rv[instance_id].name, instance_id)
|
||||
session = models.create_session()
|
||||
instances = session.query(models.Instance).all()
|
||||
logging.info("Running instances: %s", instances)
|
||||
self.assertEqual(len(instances), 1)
|
||||
|
||||
rv = yield self.compute.terminate_instance(instance_id)
|
||||
yield self.compute.terminate_instance(instance_id)
|
||||
|
||||
rv = yield self.compute.describe_instances()
|
||||
logging.info("After terminating instances: %s", rv)
|
||||
self.assertEqual(rv, {})
|
||||
instances = session.query(models.Instance).all()
|
||||
logging.info("After terminating instances: %s", instances)
|
||||
self.assertEqual(len(instances), 0)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_reboot(self):
|
||||
instance_id = self.create_instance()
|
||||
rv = yield self.compute.run_instance(instance_id)
|
||||
|
||||
rv = yield self.compute.describe_instances()
|
||||
self.assertEqual(rv[instance_id].name, instance_id)
|
||||
|
||||
yield self.compute.run_instance(instance_id)
|
||||
yield self.compute.reboot_instance(instance_id)
|
||||
|
||||
rv = yield self.compute.describe_instances()
|
||||
self.assertEqual(rv[instance_id].name, instance_id)
|
||||
rv = yield self.compute.terminate_instance(instance_id)
|
||||
yield self.compute.terminate_instance(instance_id)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_console_output(self):
|
||||
@@ -129,10 +123,6 @@ class ComputeConnectionTestCase(test.TrialTestCase):
|
||||
@defer.inlineCallbacks
|
||||
def test_run_instance_existing(self):
|
||||
instance_id = self.create_instance()
|
||||
rv = yield self.compute.run_instance(instance_id)
|
||||
|
||||
rv = yield self.compute.describe_instances()
|
||||
self.assertEqual(rv[instance_id].name, instance_id)
|
||||
|
||||
self.assertRaises(exception.Error, self.compute.run_instance, instance_id)
|
||||
rv = yield self.compute.terminate_instance(instance_id)
|
||||
yield self.compute.run_instance(instance_id)
|
||||
self.assertFailure(self.compute.run_instance(instance_id), exception.Error)
|
||||
yield self.compute.terminate_instance(instance_id)
|
||||
|
||||
Reference in New Issue
Block a user