Created
July 10, 2012 00:23
-
-
Save vishvananda/3080062 to your computer and use it in GitHub Desktop.
repro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note, make sure to run nova-manage db sync first to create a sqlite database | |
from nova import db | |
from nova.db.sqlalchemy import models | |
from nova.db.sqlalchemy import session as sess | |
from nova import context | |
from sqlalchemy.orm import joinedload | |
def instance_get_joined(uuid, session): | |
with session.begin(): | |
val = session.query(models.Instance).filter_by(deleted=False).options(joinedload('instance_type')).filter_by(uuid=uuid).first() | |
return val | |
def instance_get(uuid, session): | |
with session.begin(): | |
val = session.query(models.Instance).filter_by(deleted=False).filter_by(uuid=uuid).first() | |
return val | |
ctxt = context.get_admin_context() | |
it = db.instance_type_get_by_flavor_id(ctxt, 1) | |
i = db.instance_create(ctxt, {'instance_type_id': it['id']}) | |
uuid = i['uuid'] | |
session = sess.get_session() | |
i1 = instance_get_joined(uuid, session) | |
print 'OK: joined' | |
print i1['uuid'], i1['instance_type']['name'] | |
session = sess.get_session() | |
i1 = instance_get(uuid, session) | |
print 'OK: object still in session' | |
print i1['uuid'], i1['instance_type']['name'] | |
session = sess.get_session() | |
i1 = instance_get_joined(uuid, session) | |
i1 = instance_get(uuid, session) | |
session.expunge_all() | |
print 'OK: object previously joined in same session' | |
print i1['uuid'], i1['instance_type']['name'] | |
session = sess.get_session() | |
i1 = instance_get(uuid, session) | |
session.expunge_all() | |
print 'FAIL: no join and not joined in this session' | |
print i1['uuid'], i1['instance_type']['name'] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment