added tests to ensure the easy api works as a backend for Compute API
This commit is contained in:
@@ -22,6 +22,7 @@ import logging
|
|||||||
from M2Crypto import BIO
|
from M2Crypto import BIO
|
||||||
from M2Crypto import RSA
|
from M2Crypto import RSA
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@@ -293,6 +294,7 @@ class CloudTestCase(test.TestCase):
|
|||||||
self.assertEqual('Foo Img', img.metadata['description'])
|
self.assertEqual('Foo Img', img.metadata['description'])
|
||||||
self._fake_set_image_description(self.context, 'ami-testing', '')
|
self._fake_set_image_description(self.context, 'ami-testing', '')
|
||||||
self.assertEqual('', img.metadata['description'])
|
self.assertEqual('', img.metadata['description'])
|
||||||
|
shutil.rmtree(pathdir)
|
||||||
|
|
||||||
def test_update_of_instance_display_fields(self):
|
def test_update_of_instance_display_fields(self):
|
||||||
inst = db.instance_create(self.context, {})
|
inst = db.instance_create(self.context, {})
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class ComputeTestCase(test.TestCase):
|
|||||||
ref = self.compute_api.create_instances(self.context,
|
ref = self.compute_api.create_instances(self.context,
|
||||||
FLAGS.default_instance_type, None, **instance)
|
FLAGS.default_instance_type, None, **instance)
|
||||||
try:
|
try:
|
||||||
self.assertNotEqual(ref[0].display_name, None)
|
self.assertNotEqual(ref[0]['display_name'], None)
|
||||||
finally:
|
finally:
|
||||||
db.instance_destroy(self.context, ref[0]['id'])
|
db.instance_destroy(self.context, ref[0]['id'])
|
||||||
|
|
||||||
@@ -87,9 +87,12 @@ class ComputeTestCase(test.TestCase):
|
|||||||
'project_id': self.project.id}
|
'project_id': self.project.id}
|
||||||
group = db.security_group_create(self.context, values)
|
group = db.security_group_create(self.context, values)
|
||||||
ref = self.compute_api.create_instances(self.context,
|
ref = self.compute_api.create_instances(self.context,
|
||||||
FLAGS.default_instance_type, None, security_group=['default'])
|
instance_type=FLAGS.default_instance_type,
|
||||||
|
image_id=None,
|
||||||
|
security_group=['default'])
|
||||||
try:
|
try:
|
||||||
self.assertEqual(len(ref[0]['security_groups']), 1)
|
self.assertEqual(len(db.security_group_get_by_instance(
|
||||||
|
self.context, ref[0]['id'])), 1)
|
||||||
finally:
|
finally:
|
||||||
db.security_group_destroy(self.context, group['id'])
|
db.security_group_destroy(self.context, group['id'])
|
||||||
db.instance_destroy(self.context, ref[0]['id'])
|
db.instance_destroy(self.context, ref[0]['id'])
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ from nova import exception
|
|||||||
from nova import test
|
from nova import test
|
||||||
from nova import utils
|
from nova import utils
|
||||||
from nova.api import easy
|
from nova.api import easy
|
||||||
|
from nova.compute import api as compute_api
|
||||||
|
from nova.tests import cloud_unittest
|
||||||
|
|
||||||
class FakeService(object):
|
class FakeService(object):
|
||||||
def echo(self, context, data):
|
def echo(self, context, data):
|
||||||
@@ -83,3 +84,19 @@ class EasyTestCase(test.TestCase):
|
|||||||
proxy = easy.Proxy(self.router)
|
proxy = easy.Proxy(self.router)
|
||||||
rv = proxy.fake.echo(self.context, data='baz')
|
rv = proxy.fake.echo(self.context, data='baz')
|
||||||
self.assertEqual(rv['data'], 'baz')
|
self.assertEqual(rv['data'], 'baz')
|
||||||
|
|
||||||
|
|
||||||
|
class EasyCloudTestCase(cloud_unittest.CloudTestCase):
|
||||||
|
def setUp(self):
|
||||||
|
super(EasyCloudTestCase, self).setUp()
|
||||||
|
compute_handle = compute_api.ComputeAPI(self.cloud.network_manager,
|
||||||
|
self.cloud.image_service)
|
||||||
|
easy.register_service('compute', compute_handle)
|
||||||
|
self.router = easy.JsonParamsMiddleware(easy.SundayMorning())
|
||||||
|
proxy = easy.Proxy(self.router)
|
||||||
|
self.cloud.compute_api = proxy.compute
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
super(EasyCloudTestCase, self).tearDown()
|
||||||
|
easy.EASY_ROUTES = {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user