Fix for bug 887712
Check weather the instance_id passed into instance_update() is a model id or a UUID. Change-Id: Ic361299cdbfa5c3786815753c47a8e4f3ba6d494
This commit is contained in:
		
							
								
								
									
										1
									
								
								Authors
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								Authors
									
									
									
									
									
								
							@@ -1,6 +1,7 @@
 | 
			
		||||
Aaron Lee <aaron.lee@rackspace.com>
 | 
			
		||||
Adam Gandelman <adamg@canonical.com>
 | 
			
		||||
Adam Johnson <adjohn@gmail.com>
 | 
			
		||||
Adrian Smith <adrian_f_smith@dell.com>
 | 
			
		||||
Ahmad Hassan <ahmad.hassan@hp.com>
 | 
			
		||||
Alex Meade <alex.meade@rackspace.com>
 | 
			
		||||
Alexander Sakhnov <asakhnov@mirantis.com>
 | 
			
		||||
 
 | 
			
		||||
@@ -156,3 +156,39 @@ class DbApiTestCase(test.TestCase):
 | 
			
		||||
        self.assertEqual(36, len(network.uuid))
 | 
			
		||||
        db_network = db.network_get(ctxt, network.id)
 | 
			
		||||
        self.assertEqual(network.uuid, db_network.uuid)
 | 
			
		||||
 | 
			
		||||
    def test_instance_update_with_instance_id(self):
 | 
			
		||||
        """ test instance_update() works when an instance id is passed """
 | 
			
		||||
        ctxt = context.get_admin_context()
 | 
			
		||||
 | 
			
		||||
        # Create an instance with some metadata
 | 
			
		||||
        metadata = {'host': 'foo'}
 | 
			
		||||
        values = {'metadata': metadata}
 | 
			
		||||
        instance = db.instance_create(ctxt, values)
 | 
			
		||||
 | 
			
		||||
        # Update the metadata
 | 
			
		||||
        metadata = {'host': 'bar'}
 | 
			
		||||
        values = {'metadata': metadata}
 | 
			
		||||
        db.instance_update(ctxt, instance.id, values)
 | 
			
		||||
 | 
			
		||||
        # Retrieve the metadata to ensure it was successfully updated
 | 
			
		||||
        instance_meta = db.instance_metadata_get(ctxt, instance.id)
 | 
			
		||||
        self.assertEqual('bar', instance_meta['host'])
 | 
			
		||||
 | 
			
		||||
    def test_instance_update_with_instance_uuid(self):
 | 
			
		||||
        """ test instance_update() works when an instance UUID is passed """
 | 
			
		||||
        ctxt = context.get_admin_context()
 | 
			
		||||
 | 
			
		||||
        # Create an instance with some metadata
 | 
			
		||||
        metadata = {'host': 'foo'}
 | 
			
		||||
        values = {'metadata': metadata}
 | 
			
		||||
        instance = db.instance_create(ctxt, values)
 | 
			
		||||
 | 
			
		||||
        # Update the metadata
 | 
			
		||||
        metadata = {'host': 'bar'}
 | 
			
		||||
        values = {'metadata': metadata}
 | 
			
		||||
        db.instance_update(ctxt, instance.uuid, values)
 | 
			
		||||
 | 
			
		||||
        # Retrieve the metadata to ensure it was successfully updated
 | 
			
		||||
        instance_meta = db.instance_metadata_get(ctxt, instance.id)
 | 
			
		||||
        self.assertEqual('bar', instance_meta['host'])
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user