Merge server rescue tests between v2 and v2.1

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 servers rescue functional tests.

V2 has two extensions
- os-rescue
- os-extended-rescue-with-image
which are merged in single rescue plugins in v2.1

In rescue tests, enabling some more v2 extension which are required for
POST/GET sevrer.

Change-Id: I3a38b1a6cf21a3e5774e5704303ba64979c04e56
This commit is contained in:
ghanshyam
2015-04-15 11:06:42 +09:00
committed by Ghanshyam Mann
parent 93811b5ee2
commit 3f2d390c3b
16 changed files with 56 additions and 338 deletions

View File

@@ -1,53 +0,0 @@
{
"server": {
"accessIPv4": "",
"accessIPv6": "",
"addresses": {
"private": [
{
"addr": "192.168.0.3",
"version": 4
}
]
},
"created": "2012-09-19T09:22:27Z",
"flavor": {
"id": "1",
"links": [
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
]
},
"hostId": "c02c15d17499304e9893d9fc41c415f5096f8aa880bc651cac092650",
"id": "7e21a264-6cc1-4d90-b7b5-f9f49cec3a85",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]
},
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/7e21a264-6cc1-4d90-b7b5-f9f49cec3a85",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/7e21a264-6cc1-4d90-b7b5-f9f49cec3a85",
"rel": "bookmark"
}
],
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"status": "RESCUE",
"tenant_id": "openstack",
"updated": "2012-09-19T09:22:27Z",
"user_id": "fake"
}
}

View File

@@ -1,54 +0,0 @@
{
"server": {
"accessIPv4": "",
"accessIPv6": "",
"addresses": {
"private": [
{
"addr": "192.168.0.3",
"version": 4
}
]
},
"created": "2012-09-19T09:22:28Z",
"flavor": {
"id": "1",
"links": [
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
]
},
"hostId": "a9410a6a8cb87328b1c43cda5c5a15fc860e977d14feb2c9528a2450",
"id": "f1ec6ac3-5379-4cdc-af9a-6ddc29656e4f",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]
},
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/f1ec6ac3-5379-4cdc-af9a-6ddc29656e4f",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/f1ec6ac3-5379-4cdc-af9a-6ddc29656e4f",
"rel": "bookmark"
}
],
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"progress": 0,
"status": "ACTIVE",
"tenant_id": "openstack",
"updated": "2012-09-19T09:22:28Z",
"user_id": "fake"
}
}

View File

@@ -1,5 +0,0 @@
{
"rescue": {
"adminPass": "MySecretPass"
}
}

View File

@@ -1,3 +0,0 @@
{
"adminPass": "MySecretPass"
}

View File

@@ -1,3 +0,0 @@
{
"unrescue": null
}

View File

@@ -1,5 +1,7 @@
{
"server": {
"accessIPv4": "1.2.3.4",
"accessIPv6": "80fe::",
"addresses": {
"private": [
{
@@ -15,7 +17,7 @@
"id": "1",
"links": [
{
"href": "http://openstack.example.com/flavors/1",
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
]
@@ -26,7 +28,7 @@
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]
@@ -34,11 +36,11 @@
"key_name": null,
"links": [
{
"href": "http://openstack.example.com/v3/servers/2fd0c66b-50af-41d2-9253-9fa41e7e8dd8",
"href": "http://openstack.example.com/v2/openstack/servers/2fd0c66b-50af-41d2-9253-9fa41e7e8dd8",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/2fd0c66b-50af-41d2-9253-9fa41e7e8dd8",
"href": "http://openstack.example.com/openstack/servers/2fd0c66b-50af-41d2-9253-9fa41e7e8dd8",
"rel": "bookmark"
}
],

View File

@@ -1,5 +1,7 @@
{
"server": {
"accessIPv4": "1.2.3.4",
"accessIPv6": "80fe::",
"addresses": {
"private": [
{
@@ -15,7 +17,7 @@
"id": "1",
"links": [
{
"href": "http://openstack.example.com/flavors/1",
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
]
@@ -26,7 +28,7 @@
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]
@@ -34,11 +36,11 @@
"key_name": null,
"links": [
{
"href": "http://openstack.example.com/v3/servers/edfc3905-1f3c-4819-8fc3-a7d8131cfa22",
"href": "http://openstack.example.com/v2/openstack/servers/edfc3905-1f3c-4819-8fc3-a7d8131cfa22",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/edfc3905-1f3c-4819-8fc3-a7d8131cfa22",
"href": "http://openstack.example.com/openstack/servers/edfc3905-1f3c-4819-8fc3-a7d8131cfa22",
"rel": "bookmark"
}
],

View File

@@ -1,53 +0,0 @@
{
"server": {
"accessIPv4": "",
"accessIPv6": "",
"addresses": {
"private": [
{
"addr": "%(ip)s",
"version": 4
}
]
},
"created": "%(isotime)s",
"flavor": {
"id": "1",
"links": [
{
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
]
},
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/openstack/images/%(uuid)s",
"rel": "bookmark"
}
]
},
"links": [
{
"href": "%(host)s/v2/openstack/servers/%(id)s",
"rel": "self"
},
{
"href": "%(host)s/openstack/servers/%(id)s",
"rel": "bookmark"
}
],
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"status": "%(status)s",
"tenant_id": "openstack",
"updated": "%(isotime)s",
"user_id": "fake"
}
}

View File

@@ -1,54 +0,0 @@
{
"server": {
"accessIPv4": "",
"accessIPv6": "",
"addresses": {
"private": [
{
"addr": "%(ip)s",
"version": 4
}
]
},
"created": "%(isotime)s",
"flavor": {
"id": "1",
"links": [
{
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
]
},
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/openstack/images/%(uuid)s",
"rel": "bookmark"
}
]
},
"links": [
{
"href": "%(host)s/v2/openstack/servers/%(id)s",
"rel": "self"
},
{
"href": "%(host)s/openstack/servers/%(id)s",
"rel": "bookmark"
}
],
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"progress": 0,
"status": "%(status)s",
"tenant_id": "openstack",
"updated": "%(isotime)s",
"user_id": "fake"
}
}

View File

@@ -1,5 +0,0 @@
{
"rescue": {
"adminPass": "%(password)s"
}
}

View File

@@ -1,3 +0,0 @@
{
"adminPass": "%(password)s"
}

View File

@@ -1,3 +0,0 @@
{
"unrescue": null
}

View File

@@ -357,89 +357,6 @@ class KeyPairsSampleJsonTest(ApiSampleTestBaseV2):
self._verify_response('keypairs-get-resp', subs, response, 200)
class RescueJsonTest(ServersSampleBase):
extension_name = ("nova.api.openstack.compute.contrib"
".rescue.Rescue")
def _rescue(self, uuid):
req_subs = {
'password': 'MySecretPass'
}
response = self._do_post('servers/%s/action' % uuid,
'server-rescue-req', req_subs)
self._verify_response('server-rescue', req_subs, response, 200)
def _unrescue(self, uuid):
response = self._do_post('servers/%s/action' % uuid,
'server-unrescue-req', {})
self.assertEqual(response.status_code, 202)
def test_server_rescue(self):
uuid = self._post_server()
self._rescue(uuid)
# Do a server get to make sure that the 'RESCUE' state is set
response = self._do_get('servers/%s' % uuid)
subs = self._get_regexes()
subs['hostid'] = '[a-f0-9]+'
subs['id'] = uuid
subs['status'] = 'RESCUE'
self._verify_response('server-get-resp-rescue', subs, response, 200)
def test_server_unrescue(self):
uuid = self._post_server()
self._rescue(uuid)
self._unrescue(uuid)
# Do a server get to make sure that the 'ACTIVE' state is back
response = self._do_get('servers/%s' % uuid)
subs = self._get_regexes()
subs['hostid'] = '[a-f0-9]+'
subs['id'] = uuid
subs['status'] = 'ACTIVE'
self._verify_response('server-get-resp-unrescue', subs, response, 200)
class ExtendedRescueWithImageJsonTest(ServersSampleBase):
extension_name = ("nova.api.openstack.compute.contrib"
".extended_rescue_with_image.Extended_rescue_with_image")
def _get_flags(self):
f = super(ExtendedRescueWithImageJsonTest, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
# ExtendedRescueWithImage extension also needs Rescue to be loaded.
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.rescue.Rescue')
return f
def _rescue(self, uuid):
req_subs = {
'password': 'MySecretPass',
'rescue_image_ref': fake.get_valid_image_id()
}
response = self._do_post('servers/%s/action' % uuid,
'server-rescue-req', req_subs)
self._verify_response('server-rescue', req_subs, response, 200)
def test_server_rescue(self):
uuid = self._post_server()
self._rescue(uuid)
# Do a server get to make sure that the 'RESCUE' state is set
response = self._do_get('servers/%s' % uuid)
subs = self._get_regexes()
subs['hostid'] = '[a-f0-9]+'
subs['id'] = uuid
subs['status'] = 'RESCUE'
self._verify_response('server-get-resp-rescue', subs, response, 200)
class VirtualInterfacesJsonTest(ServersSampleBase):
extension_name = ("nova.api.openstack.compute.contrib"
".virtual_interfaces.Virtual_interfaces")

View File

@@ -1,5 +1,7 @@
{
"server": {
"accessIPv4": "%(access_ip_v4)s",
"accessIPv6": "%(access_ip_v6)s",
"addresses": {
"private": [
{
@@ -15,7 +17,7 @@
"id": "1",
"links": [
{
"href": "%(host)s/flavors/1",
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
]
@@ -26,18 +28,18 @@
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/images/%(uuid)s",
"href": "%(host)s/openstack/images/%(uuid)s",
"rel": "bookmark"
}
]
},
"links": [
{
"href": "%(host)s/v3/servers/%(id)s",
"href": "%(host)s/v2/openstack/servers/%(id)s",
"rel": "self"
},
{
"href": "%(host)s/servers/%(id)s",
"href": "%(host)s/openstack/servers/%(id)s",
"rel": "bookmark"
}
],

View File

@@ -1,5 +1,7 @@
{
"server": {
"accessIPv4": "%(access_ip_v4)s",
"accessIPv6": "%(access_ip_v6)s",
"addresses": {
"private": [
{
@@ -15,7 +17,7 @@
"id": "1",
"links": [
{
"href": "%(host)s/flavors/1",
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
]
@@ -26,18 +28,18 @@
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/images/%(uuid)s",
"href": "%(host)s/openstack/images/%(uuid)s",
"rel": "bookmark"
}
]
},
"links": [
{
"href": "%(host)s/v3/servers/%(id)s",
"href": "%(host)s/v2/openstack/servers/%(id)s",
"rel": "self"
},
{
"href": "%(host)s/servers/%(id)s",
"href": "%(host)s/openstack/servers/%(id)s",
"rel": "bookmark"
}
],

View File

@@ -13,11 +13,37 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from nova.tests.functional.v3 import test_servers
CONF = cfg.CONF
CONF.import_opt('osapi_compute_extension',
'nova.api.openstack.compute.extensions')
class RescueJsonTest(test_servers.ServersSampleBase):
extension_name = "os-rescue"
extra_extensions_to_load = ["os-access-ips"]
_api_version = 'v2'
def _get_flags(self):
f = super(RescueJsonTest, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.rescue.Rescue')
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.extended_rescue_with_image.'
'Extended_rescue_with_image')
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.keypairs.Keypairs')
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.extended_ips.Extended_ips')
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.extended_ips_mac.'
'Extended_ips_mac')
return f
def _rescue(self, uuid):
req_subs = {
@@ -43,7 +69,8 @@ class RescueJsonTest(test_servers.ServersSampleBase):
subs['hostid'] = '[a-f0-9]+'
subs['id'] = uuid
subs['status'] = 'RESCUE'
subs['access_ip_v4'] = '1.2.3.4'
subs['access_ip_v6'] = '80fe::'
self._verify_response('server-get-resp-rescue', subs, response, 200)
def test_server_rescue_with_image_ref_specified(self):
@@ -63,7 +90,8 @@ class RescueJsonTest(test_servers.ServersSampleBase):
subs['hostid'] = '[a-f0-9]+'
subs['id'] = uuid
subs['status'] = 'RESCUE'
subs['access_ip_v4'] = '1.2.3.4'
subs['access_ip_v6'] = '80fe::'
self._verify_response('server-get-resp-rescue', subs, response, 200)
def test_server_unrescue(self):
@@ -78,5 +106,6 @@ class RescueJsonTest(test_servers.ServersSampleBase):
subs['hostid'] = '[a-f0-9]+'
subs['id'] = uuid
subs['status'] = 'ACTIVE'
subs['access_ip_v4'] = '1.2.3.4'
subs['access_ip_v6'] = '80fe::'
self._verify_response('server-get-resp-unrescue', subs, response, 200)