Merge V2 and V2.1 Agent 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 Agent functional tests.

Change-Id: Ibfbe20f6c0b773ec7cf39d532074075c722deb63
This commit is contained in:
ghanshyam 2015-03-24 14:10:46 +09:00
parent e69a74f365
commit 0012f8bde2
12 changed files with 18 additions and 197 deletions

View File

@ -1,10 +0,0 @@
{
"agent": {
"hypervisor": "hypervisor",
"os": "os",
"architecture": "x86",
"version": "8.0",
"md5hash": "add6bb58e139be103324d04d82d8f545",
"url": "http://example.com/path/to/resource"
}
}

View File

@ -1,11 +0,0 @@
{
"agent": {
"agent_id": 1,
"architecture": "x86",
"hypervisor": "hypervisor",
"md5hash": "add6bb58e139be103324d04d82d8f545",
"os": "os",
"url": "http://example.com/path/to/resource",
"version": "8.0"
}
}

View File

@ -1,7 +0,0 @@
{
"para": {
"url": "http://example.com/path/to/resource",
"md5hash": "add6bb58e139be103324d04d82d8f545",
"version": "7.0"
}
}

View File

@ -1,8 +0,0 @@
{
"agent": {
"agent_id": "1",
"md5hash": "add6bb58e139be103324d04d82d8f545",
"url": "http://example.com/path/to/resource",
"version": "7.0"
}
}

View File

@ -1,13 +0,0 @@
{
"agents": [
{
"agent_id": 1,
"architecture": "x86",
"hypervisor": "hypervisor",
"md5hash": "add6bb58e139be103324d04d82d8f545",
"os": "os",
"url": "http://example.com/path/to/resource",
"version": "8.0"
}
]
}

View File

@ -1,10 +0,0 @@
{
"agent": {
"hypervisor": "%(hypervisor)s",
"os": "%(os)s",
"architecture": "%(architecture)s",
"version": "%(version)s",
"md5hash": "%(md5hash)s",
"url": "%(url)s"
}
}

View File

@ -1,12 +0,0 @@
{
"agent": {
"hypervisor": "%(hypervisor)s",
"os": "%(os)s",
"architecture": "%(architecture)s",
"version": "%(version)s",
"md5hash": "%(md5hash)s",
"url": "%(url)s",
"agent_id": 1
}
}

View File

@ -1,7 +0,0 @@
{
"para": {
"url": "%(url)s",
"md5hash": "%(md5hash)s",
"version": "%(version)s"
}
}

View File

@ -1,8 +0,0 @@
{
"agent": {
"agent_id": "%(agent_id)d",
"url": "%(url)s",
"md5hash": "%(md5hash)s",
"version": "%(version)s"
}
}

View File

@ -1,13 +0,0 @@
{
"agents": [
{
"hypervisor": "%(hypervisor)s",
"os": "%(os)s",
"architecture": "%(architecture)s",
"version": "%(version)s",
"md5hash": "%(md5hash)s",
"url": "%(url)s",
"agent_id": 1
}
]
}

View File

@ -44,7 +44,6 @@ from nova.conductor import manager as conductor_manager
from nova.console import manager as console_manager # noqa - only for cfg
from nova import context
from nova import db
from nova.db.sqlalchemy import models
from nova import exception
from nova.network import api as network_api
from nova.network.neutronv2 import api as neutron_api # noqa - only for cfg
@ -1041,103 +1040,6 @@ class CloudPipeUpdateJsonTest(ApiSampleTestBaseV2):
self.assertEqual(response.content, "")
class AgentsJsonTest(ApiSampleTestBaseV2):
ADMIN_API = True
extension_name = "nova.api.openstack.compute.contrib.agents.Agents"
def _get_flags(self):
f = super(AgentsJsonTest, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
return f
def setUp(self):
super(AgentsJsonTest, self).setUp()
fake_agents_list = [{'url': 'http://example.com/path/to/resource',
'hypervisor': 'hypervisor',
'architecture': 'x86',
'os': 'os',
'version': '8.0',
'md5hash': 'add6bb58e139be103324d04d82d8f545',
'id': 1}]
def fake_agent_build_create(context, values):
values['id'] = 1
agent_build_ref = models.AgentBuild()
agent_build_ref.update(values)
return agent_build_ref
def fake_agent_build_get_all(context, hypervisor):
agent_build_all = []
for agent in fake_agents_list:
if hypervisor and hypervisor != agent['hypervisor']:
continue
agent_build_ref = models.AgentBuild()
agent_build_ref.update(agent)
agent_build_all.append(agent_build_ref)
return agent_build_all
def fake_agent_build_update(context, agent_build_id, values):
pass
def fake_agent_build_destroy(context, agent_update_id):
pass
self.stubs.Set(db, "agent_build_create",
fake_agent_build_create)
self.stubs.Set(db, "agent_build_get_all",
fake_agent_build_get_all)
self.stubs.Set(db, "agent_build_update",
fake_agent_build_update)
self.stubs.Set(db, "agent_build_destroy",
fake_agent_build_destroy)
def test_agent_create(self):
# Creates a new agent build.
project = {'url': 'http://example.com/path/to/resource',
'hypervisor': 'hypervisor',
'architecture': 'x86',
'os': 'os',
'version': '8.0',
'md5hash': 'add6bb58e139be103324d04d82d8f545'
}
response = self._do_post('os-agents', 'agent-post-req',
project)
project['agent_id'] = 1
self._verify_response('agent-post-resp', project, response, 200)
return project
def test_agent_list(self):
# Return a list of all agent builds.
response = self._do_get('os-agents')
project = {'url': 'http://example.com/path/to/resource',
'hypervisor': 'hypervisor',
'architecture': 'x86',
'os': 'os',
'version': '8.0',
'md5hash': 'add6bb58e139be103324d04d82d8f545',
'agent_id': 1
}
self._verify_response('agents-get-resp', project, response, 200)
def test_agent_update(self):
# Update an existing agent build.
agent_id = 1
subs = {'version': '7.0',
'url': 'http://example.com/path/to/resource',
'md5hash': 'add6bb58e139be103324d04d82d8f545'}
response = self._do_put('os-agents/%s' % agent_id,
'agent-update-put-req', subs)
subs['agent_id'] = 1
self._verify_response('agent-update-put-resp', subs, response, 200)
def test_agent_delete(self):
# Deletes an existing agent build.
agent_id = 1
response = self._do_delete('os-agents/%s' % agent_id)
self.assertEqual(response.status_code, 200)
class FixedIpJsonTest(ApiSampleTestBaseV2):
extension_name = "nova.api.openstack.compute.contrib.fixed_ips.Fixed_ips"

View File

@ -13,13 +13,31 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from nova import db
from nova.db.sqlalchemy import models
from nova.tests.functional.v3 import api_sample_base
CONF = cfg.CONF
CONF.import_opt('osapi_compute_extension',
'nova.api.openstack.compute.extensions')
class AgentsJsonTest(api_sample_base.ApiSampleTestBaseV3):
ADMIN_API = True
extension_name = "os-agents"
# 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(AgentsJsonTest, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.agents.Agents')
return f
def setUp(self):
super(AgentsJsonTest, self).setUp()