Merge V2 and V2.1 floating ips functional tests

Currently v2 and v2.1 have separate functional tests and their
corresponding sample files. As v2 and v2.1 are supposed to be identical,
there is overhead to maintain two set of functional tests and sample files.
We can have one set of tests which can run for both v2 and v2.1.

This commit merges all floating ip functional tests.
Below APIs tests are megred-
-floating_ip_dns
-floating-ips-bulk
-floating-ips
-floating-ip-pools

Change-Id: Ibde0b152949559dec90ea0e7ee6668ab05b4927f
This commit is contained in:
ghanshyam
2015-03-25 15:42:35 +09:00
parent 20c47ea3d5
commit d98aa4fadc
44 changed files with 62 additions and 607 deletions
@@ -1,6 +0,0 @@
{
"dns_entry": {
"ip": "192.168.53.11",
"dns_type": "A"
}
}
@@ -1,9 +0,0 @@
{
"dns_entry": {
"domain": "domain1.example.org",
"id": null,
"ip": "192.168.1.1",
"name": "instance1",
"type": "A"
}
}
@@ -1,7 +0,0 @@
{
"domain_entry": {
"domain": "domain1.example.org",
"scope": "public",
"project": "project1"
}
}
@@ -1,8 +0,0 @@
{
"domain_entry": {
"availability_zone": null,
"domain": "domain1.example.org",
"project": "project1",
"scope": "public"
}
}
@@ -1,9 +0,0 @@
{
"dns_entry": {
"domain": "domain1.example.org",
"id": null,
"ip": "192.168.1.1",
"name": "instance1",
"type": null
}
}
@@ -1,11 +0,0 @@
{
"dns_entries": [
{
"domain": "domain1.example.org",
"id": null,
"ip": "192.168.1.1",
"name": "instance1",
"type": null
}
]
}
@@ -1,10 +0,0 @@
{
"domain_entries": [
{
"availability_zone": null,
"domain": "domain1.example.org",
"project": "project1",
"scope": "public"
}
]
}
@@ -1,10 +0,0 @@
{
"floating_ip_pools": [
{
"name": "pool1"
},
{
"name": "pool2"
}
]
}
@@ -1,8 +0,0 @@
{
"floating_ips_bulk_create" :
{
"ip_range": "192.168.1.0/24",
"pool": "nova",
"interface": "eth0"
}
}
@@ -1,7 +0,0 @@
{
"floating_ips_bulk_create": {
"interface": "eth0",
"ip_range": "192.168.1.0/24",
"pool": "nova"
}
}
@@ -1,3 +0,0 @@
{
"ip_range": "192.168.1.0/24"
}
@@ -1,3 +0,0 @@
{
"floating_ips_bulk_delete": "192.168.1.0/24"
}
@@ -1,12 +0,0 @@
{
"floating_ip_info": [
{
"address": "10.10.10.3",
"instance_uuid": null,
"fixed_ip": null,
"interface": "eth0",
"pool": "nova",
"project_id": null
}
]
}
@@ -1,28 +0,0 @@
{
"floating_ip_info": [
{
"address": "10.10.10.1",
"instance_uuid": null,
"fixed_ip": null,
"interface": "eth0",
"pool": "nova",
"project_id": null
},
{
"address": "10.10.10.2",
"instance_uuid": null,
"fixed_ip": null,
"interface": "eth0",
"pool": "nova",
"project_id": null
},
{
"address": "10.10.10.3",
"instance_uuid": null,
"fixed_ip": null,
"interface": "eth0",
"pool": "nova",
"project_id": null
}
]
}
@@ -1,3 +0,0 @@
{
"pool": "nova"
}
@@ -1,9 +0,0 @@
{
"floating_ip": {
"fixed_ip": null,
"id": 1,
"instance_id": null,
"ip": "10.10.10.1",
"pool": "nova"
}
}
@@ -1,9 +0,0 @@
{
"floating_ip": {
"fixed_ip": null,
"id": 1,
"instance_id": null,
"ip": "10.10.10.1",
"pool": "nova"
}
}
@@ -1,3 +0,0 @@
{
"floating_ips": []
}
@@ -1,18 +0,0 @@
{
"floating_ips": [
{
"fixed_ip": null,
"id": 1,
"instance_id": null,
"ip": "10.10.10.1",
"pool": "nova"
},
{
"fixed_ip": null,
"id": 2,
"instance_id": null,
"ip": "10.10.10.2",
"pool": "nova"
}
]
}
@@ -1,7 +0,0 @@
{
"dns_entry" :
{
"ip": "%(ip)s",
"dns_type": "%(dns_type)s"
}
}
@@ -1,9 +0,0 @@
{
"dns_entry": {
"domain": "%(domain)s",
"id": null,
"ip": "%(ip)s",
"name": "%(name)s",
"type": "%(dns_type)s"
}
}
@@ -1,8 +0,0 @@
{
"domain_entry" :
{
"domain": "%(domain)s",
"scope": "%(scope)s",
"project": "%(project)s"
}
}
@@ -1,8 +0,0 @@
{
"domain_entry": {
"availability_zone": null,
"domain": "%(domain)s",
"project": "%(project)s",
"scope": "%(scope)s"
}
}
@@ -1,9 +0,0 @@
{
"dns_entry": {
"domain": "%(domain)s",
"id": null,
"ip": "%(ip)s",
"name": "%(name)s",
"type": null
}
}
@@ -1,11 +0,0 @@
{
"dns_entries": [
{
"domain": "%(domain)s",
"id": null,
"ip": "%(ip)s",
"name": "%(name)s",
"type": null
}
]
}
@@ -1,10 +0,0 @@
{
"domain_entries": [
{
"availability_zone": null,
"domain": "%(domain)s",
"project": "%(project)s",
"scope": "%(scope)s"
}
]
}
@@ -1,10 +0,0 @@
{
"floating_ip_pools": [
{
"name": "%(pool1)s"
},
{
"name": "%(pool2)s"
}
]
}
@@ -1,8 +0,0 @@
{
"floating_ips_bulk_create" :
{
"ip_range": "%(ip_range)s",
"pool": "%(pool)s",
"interface": "%(interface)s"
}
}
@@ -1,7 +0,0 @@
{
"floating_ips_bulk_create": {
"interface": "eth0",
"ip_range": "192.168.1.0/24",
"pool": "nova"
}
}
@@ -1,3 +0,0 @@
{
"ip_range": "%(ip_range)s"
}
@@ -1,3 +0,0 @@
{
"floating_ips_bulk_delete": "192.168.1.0/24"
}
@@ -1,12 +0,0 @@
{
"floating_ip_info": [
{
"address": "10.10.10.3",
"instance_uuid": null,
"fixed_ip": null,
"interface": "eth0",
"pool": "nova",
"project_id": null
}
]
}
@@ -1,28 +0,0 @@
{
"floating_ip_info": [
{
"address": "10.10.10.1",
"instance_uuid": null,
"fixed_ip": null,
"interface": "eth0",
"pool": "nova",
"project_id": null
},
{
"address": "10.10.10.2",
"instance_uuid": null,
"fixed_ip": null,
"interface": "eth0",
"pool": "nova",
"project_id": null
},
{
"address": "10.10.10.3",
"instance_uuid": null,
"fixed_ip": null,
"interface": "eth0",
"pool": "nova",
"project_id": null
}
]
}
@@ -1,3 +0,0 @@
{
"pool": "%(pool)s"
}
@@ -1,9 +0,0 @@
{
"floating_ip": {
"fixed_ip": null,
"id": 1,
"instance_id": null,
"ip": "10.10.10.1",
"pool": "nova"
}
}
@@ -1,9 +0,0 @@
{
"floating_ip": {
"fixed_ip": null,
"id": 1,
"instance_id": null,
"ip": "10.10.10.1",
"pool": "nova"
}
}
@@ -1,3 +0,0 @@
{
"floating_ips": []
}
@@ -1,19 +0,0 @@
{
"floating_ips": [
{
"fixed_ip": null,
"id": 1,
"instance_id": null,
"ip": "10.10.10.1",
"pool": "nova"
},
{
"fixed_ip": null,
"id": 2,
"instance_id": null,
"ip": "10.10.10.2",
"pool": "nova"
}
]
}
-258
View File
@@ -793,166 +793,6 @@ class ExtendedServerAttributesJsonTest(ServersSampleBase):
self._verify_response('servers-detail-resp', subs, response, 200)
class FloatingIpsJsonTest(ApiSampleTestBaseV2):
extension_name = "nova.api.openstack.compute.contrib." \
"floating_ips.Floating_ips"
def setUp(self):
super(FloatingIpsJsonTest, self).setUp()
pool = CONF.default_floating_pool
interface = CONF.public_interface
self.ip_pool = [
{
'address': "10.10.10.1",
'pool': pool,
'interface': interface
},
{
'address': "10.10.10.2",
'pool': pool,
'interface': interface
},
{
'address': "10.10.10.3",
'pool': pool,
'interface': interface
},
]
self.compute.db.floating_ip_bulk_create(
context.get_admin_context(), self.ip_pool)
def tearDown(self):
self.compute.db.floating_ip_bulk_destroy(
context.get_admin_context(), self.ip_pool)
super(FloatingIpsJsonTest, self).tearDown()
def test_floating_ips_list_empty(self):
response = self._do_get('os-floating-ips')
subs = self._get_regexes()
self._verify_response('floating-ips-list-empty-resp',
subs, response, 200)
def test_floating_ips_list(self):
self._do_post('os-floating-ips',
'floating-ips-create-nopool-req',
{})
self._do_post('os-floating-ips',
'floating-ips-create-nopool-req',
{})
response = self._do_get('os-floating-ips')
subs = self._get_regexes()
self._verify_response('floating-ips-list-resp',
subs, response, 200)
def test_floating_ips_create_nopool(self):
response = self._do_post('os-floating-ips',
'floating-ips-create-nopool-req',
{})
subs = self._get_regexes()
self._verify_response('floating-ips-create-resp',
subs, response, 200)
def test_floating_ips_create(self):
response = self._do_post('os-floating-ips',
'floating-ips-create-req',
{"pool": CONF.default_floating_pool})
subs = self._get_regexes()
self._verify_response('floating-ips-create-resp', subs, response, 200)
def test_floating_ips_get(self):
self.test_floating_ips_create()
# NOTE(sdague): the first floating ip will always have 1 as an id,
# but it would be better if we could get this from the create
response = self._do_get('os-floating-ips/%d' % 1)
subs = self._get_regexes()
self._verify_response('floating-ips-get-resp', subs, response, 200)
def test_floating_ips_delete(self):
self.test_floating_ips_create()
response = self._do_delete('os-floating-ips/%d' % 1)
self.assertEqual(response.status_code, 202)
self.assertEqual(response.content, "")
class ExtendedFloatingIpsJsonTest(FloatingIpsJsonTest):
extends_name = ("nova.api.openstack.compute.contrib."
"floating_ips.Floating_ips")
extension_name = ("nova.api.openstack.compute.contrib."
"extended_floating_ips.Extended_floating_ips")
class FloatingIpsBulkJsonTest(ApiSampleTestBaseV2):
ADMIN_API = True
extension_name = "nova.api.openstack.compute.contrib." \
"floating_ips_bulk.Floating_ips_bulk"
def setUp(self):
super(FloatingIpsBulkJsonTest, self).setUp()
pool = CONF.default_floating_pool
interface = CONF.public_interface
self.ip_pool = [
{
'address': "10.10.10.1",
'pool': pool,
'interface': interface,
'host': None
},
{
'address': "10.10.10.2",
'pool': pool,
'interface': interface,
'host': None
},
{
'address': "10.10.10.3",
'pool': pool,
'interface': interface,
'host': "testHost"
},
]
self.compute.db.floating_ip_bulk_create(
context.get_admin_context(), self.ip_pool)
def tearDown(self):
self.compute.db.floating_ip_bulk_destroy(
context.get_admin_context(), self.ip_pool)
super(FloatingIpsBulkJsonTest, self).tearDown()
def test_floating_ips_bulk_list(self):
response = self._do_get('os-floating-ips-bulk')
subs = self._get_regexes()
self._verify_response('floating-ips-bulk-list-resp',
subs, response, 200)
def test_floating_ips_bulk_list_by_host(self):
response = self._do_get('os-floating-ips-bulk/testHost')
subs = self._get_regexes()
self._verify_response('floating-ips-bulk-list-by-host-resp',
subs, response, 200)
def test_floating_ips_bulk_create(self):
response = self._do_post('os-floating-ips-bulk',
'floating-ips-bulk-create-req',
{"ip_range": "192.168.1.0/24",
"pool": CONF.default_floating_pool,
"interface": CONF.public_interface})
subs = self._get_regexes()
self._verify_response('floating-ips-bulk-create-resp', subs,
response, 200)
def test_floating_ips_bulk_delete(self):
response = self._do_put('os-floating-ips-bulk/delete',
'floating-ips-bulk-delete-req',
{"ip_range": "192.168.1.0/24"})
subs = self._get_regexes()
self._verify_response('floating-ips-bulk-delete-resp', subs,
response, 200)
class KeyPairsSampleJsonTest(ApiSampleTestBaseV2):
extension_name = "nova.api.openstack.compute.contrib.keypairs.Keypairs"
@@ -2677,26 +2517,6 @@ class BlockDeviceMappingV2BootJsonTest(ServersSampleBase):
return self._post_server()
class FloatingIPPoolsSampleJsonTests(ApiSampleTestBaseV2):
extension_name = ("nova.api.openstack.compute.contrib.floating_ip_pools."
"Floating_ip_pools")
def test_list_floatingippools(self):
pool_list = ["pool1", "pool2"]
def fake_get_floating_ip_pools(self, context):
return pool_list
self.stubs.Set(network_api.API, "get_floating_ip_pools",
fake_get_floating_ip_pools)
response = self._do_get('os-floating-ip-pools')
subs = {
'pool1': pool_list[0],
'pool2': pool_list[1]
}
self._verify_response('floatingippools-list-resp', subs, response, 200)
class MultinicSampleJsonTest(ServersSampleBase):
ADMIN_API = True
extension_name = "nova.api.openstack.compute.contrib.multinic.Multinic"
@@ -2938,84 +2758,6 @@ class EvacuateFindHostSampleJsonTest(ServersSampleBase):
host=None)
class FloatingIpDNSJsonTest(ApiSampleTestBaseV2):
ADMIN_API = True
extension_name = ("nova.api.openstack.compute.contrib.floating_ip_dns."
"Floating_ip_dns")
domain = 'domain1.example.org'
name = 'instance1'
scope = 'public'
project = 'project1'
dns_type = 'A'
ip = '192.168.1.1'
def _create_or_update(self):
subs = {'domain': self.domain,
'project': self.project,
'scope': self.scope}
response = self._do_put('os-floating-ip-dns/%s' % self.domain,
'floating-ip-dns-create-or-update-req', subs)
self._verify_response('floating-ip-dns-create-or-update-resp', subs,
response, 200)
def _create_or_update_entry(self):
subs = {'ip': self.ip, 'dns_type': self.dns_type}
response = self._do_put('os-floating-ip-dns/%s/entries/%s'
% (self.domain, self.name),
'floating-ip-dns-create-or-update-entry-req',
subs)
subs.update({'name': self.name, 'domain': self.domain})
self._verify_response('floating-ip-dns-create-or-update-entry-resp',
subs, response, 200)
def test_floating_ip_dns_list(self):
self._create_or_update()
response = self._do_get('os-floating-ip-dns')
subs = {'domain': self.domain,
'project': self.project,
'scope': self.scope}
self._verify_response('floating-ip-dns-list-resp', subs,
response, 200)
def test_floating_ip_dns_create_or_update(self):
self._create_or_update()
def test_floating_ip_dns_delete(self):
self._create_or_update()
response = self._do_delete('os-floating-ip-dns/%s' % self.domain)
self.assertEqual(response.status_code, 202)
def test_floating_ip_dns_create_or_update_entry(self):
self._create_or_update_entry()
def test_floating_ip_dns_entry_get(self):
self._create_or_update_entry()
response = self._do_get('os-floating-ip-dns/%s/entries/%s'
% (self.domain, self.name))
subs = {'domain': self.domain,
'ip': self.ip,
'name': self.name}
self._verify_response('floating-ip-dns-entry-get-resp', subs,
response, 200)
def test_floating_ip_dns_entry_delete(self):
self._create_or_update_entry()
response = self._do_delete('os-floating-ip-dns/%s/entries/%s'
% (self.domain, self.name))
self.assertEqual(response.status_code, 202)
def test_floating_ip_dns_entry_list(self):
self._create_or_update_entry()
response = self._do_get('os-floating-ip-dns/%s/entries/%s'
% (self.domain, self.ip))
subs = {'domain': self.domain,
'ip': self.ip,
'name': self.name}
self._verify_response('floating-ip-dns-entry-list-resp', subs,
response, 200)
class InstanceActionsSampleJsonTest(ApiSampleTestBaseV2):
ADMIN_API = True
extension_name = ('nova.api.openstack.compute.contrib.instance_actions.'
@@ -12,8 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from nova.tests.functional.v3 import api_sample_base
CONF = cfg.CONF
CONF.import_opt('osapi_compute_extension',
'nova.api.openstack.compute.extensions')
class FloatingIpDNSTest(api_sample_base.ApiSampleTestBaseV3):
ADMIN_API = True
@@ -25,6 +31,17 @@ class FloatingIpDNSTest(api_sample_base.ApiSampleTestBaseV3):
project = 'project1'
dns_type = 'A'
ip = '192.168.1.1'
# TODO(gmann): Overriding '_api_version' till all functional tests
# are merged between v2 and v2.1. After that base class variable
# itself can be changed to 'v2'
_api_version = 'v2'
def _get_flags(self):
f = super(FloatingIpDNSTest, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
f['osapi_compute_extension'].append('nova.api.openstack.compute.'
'contrib.floating_ip_dns.Floating_ip_dns')
return f
def _create_or_update(self):
subs = {'project': self.project,
@@ -12,12 +12,29 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from nova.network import api as network_api
from nova.tests.functional.v3 import api_sample_base
CONF = cfg.CONF
CONF.import_opt('osapi_compute_extension',
'nova.api.openstack.compute.extensions')
class FloatingIPPoolsSampleTests(api_sample_base.ApiSampleTestBaseV3):
extension_name = "os-floating-ip-pools"
# TODO(gmann): Overriding '_api_version' till all functional tests
# are merged between v2 and v2.1. After that base class variable
# itself can be changed to 'v2'
_api_version = 'v2'
def _get_flags(self):
f = super(FloatingIPPoolsSampleTests, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
f['osapi_compute_extension'].append('nova.api.openstack.compute.'
'contrib.floating_ip_pools.Floating_ip_pools')
return f
def test_list_floatingippools(self):
pool_list = ["pool1", "pool2"]
@@ -21,10 +21,25 @@ from nova.tests.functional.v3 import api_sample_base
CONF = cfg.CONF
CONF.import_opt('default_floating_pool', 'nova.network.floating_ips')
CONF.import_opt('public_interface', 'nova.network.linux_net')
CONF.import_opt('osapi_compute_extension',
'nova.api.openstack.compute.extensions')
class FloatingIpsTest(api_sample_base.ApiSampleTestBaseV3):
extension_name = "os-floating-ips"
# TODO(gmann): Overriding '_api_version' till all functional tests
# are merged between v2 and v2.1. After that base class variable
# itself can be changed to 'v2'
_api_version = 'v2'
def _get_flags(self):
f = super(FloatingIpsTest, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
f['osapi_compute_extension'].append('nova.api.openstack.compute.'
'contrib.floating_ips.Floating_ips')
f['osapi_compute_extension'].append('nova.api.openstack.compute.'
'contrib.extended_floating_ips.Extended_floating_ips')
return f
def setUp(self):
super(FloatingIpsTest, self).setUp()
@@ -21,11 +21,24 @@ from nova.tests.functional.v3 import api_sample_base
CONF = cfg.CONF
CONF.import_opt('default_floating_pool', 'nova.network.floating_ips')
CONF.import_opt('public_interface', 'nova.network.linux_net')
CONF.import_opt('osapi_compute_extension',
'nova.api.openstack.compute.extensions')
class FloatingIpsBulkTest(api_sample_base.ApiSampleTestBaseV3):
ADMIN_API = True
extension_name = "os-floating-ips-bulk"
# TODO(gmann): Overriding '_api_version' till all functional tests
# are merged between v2 and v2.1. After that base class variable
# itself can be changed to 'v2'
_api_version = 'v2'
def _get_flags(self):
f = super(FloatingIpsBulkTest, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
f['osapi_compute_extension'].append('nova.api.openstack.compute.'
'contrib.floating_ips_bulk.Floating_ips_bulk')
return f
def setUp(self):
super(FloatingIpsBulkTest, self).setUp()