Merge "Implement api samples test for os-baremetal-nodes"

This commit is contained in:
Jenkins
2015-02-12 14:27:01 +00:00
committed by Gerrit Code Review
6 changed files with 162 additions and 18 deletions
@@ -1,23 +1,22 @@
{
"nodes": [
{
"cpus": 8,
"id": 1,
"instance_uuid": null,
"interfaces": [
{
"address": "aa:aa:aa:aa:aa:aa",
"datapath_id": null,
"id": 1,
"port_no": null
}
],
"local_gb": 128,
"memory_mb": 8192,
"pm_address": "10.1.2.3",
"pm_user": "pm_user",
"service_host": "host",
"terminal_port": 8000
"cpus": "2",
"disk_gb": "10",
"host": "IRONIC MANAGED",
"id": "058d27fa-241b-445a-a386-08c04f96db43",
"interfaces": [],
"memory_mb": "1024",
"task_state": "active"
},
{
"cpus": "2",
"disk_gb": "10",
"host": "IRONIC MANAGED",
"id": "e2025409-f3ce-4d6a-9788-c565cf3b1b1c",
"interfaces": [],
"memory_mb": "1024",
"task_state": "active"
}
]
}
@@ -0,0 +1,22 @@
{
"nodes": [
{
"cpus": "2",
"disk_gb": "10",
"host": "IRONIC MANAGED",
"id": "058d27fa-241b-445a-a386-08c04f96db43",
"interfaces": [],
"memory_mb": "1024",
"task_state": "active"
},
{
"cpus": "2",
"disk_gb": "10",
"host": "IRONIC MANAGED",
"id": "e2025409-f3ce-4d6a-9788-c565cf3b1b1c",
"interfaces": [],
"memory_mb": "1024",
"task_state": "active"
}
]
}
@@ -0,0 +1,22 @@
{
"nodes": [
{
"cpus": "2",
"disk_gb": "10",
"host": "IRONIC MANAGED",
"id": "058d27fa-241b-445a-a386-08c04f96db43",
"interfaces": [],
"memory_mb": "1024",
"task_state": "active"
},
{
"cpus": "2",
"disk_gb": "10",
"host": "IRONIC MANAGED",
"id": "e2025409-f3ce-4d6a-9788-c565cf3b1b1c",
"interfaces": [],
"memory_mb": "1024",
"task_state": "active"
}
]
}
+32 -1
View File
@@ -139,7 +139,6 @@ class ApiSamplesTrap(ApiSampleTestBaseV2):
do_not_approve_additions = []
do_not_approve_additions.append('os-create-server-ext')
do_not_approve_additions.append('os-baremetal-ext-status')
do_not_approve_additions.append('os-baremetal-nodes')
tests = self._get_extensions_tested()
extensions = self._get_extensions()
@@ -2545,6 +2544,38 @@ class QuotaClassesSampleJsonTests(ApiSampleTestBaseV2):
{}, response, 200)
class FakeNode(object):
def __init__(self, uuid='058d27fa-241b-445a-a386-08c04f96db43'):
self.uuid = uuid
self.provision_state = 'active'
self.properties = {'cpus': '2',
'memory_mb': '1024',
'local_gb': '10'}
class NodeManager(object):
def list(self, detail=False):
return [FakeNode(), FakeNode('e2025409-f3ce-4d6a-9788-c565cf3b1b1c')]
class fake_client(object):
node = NodeManager()
class BaremetalNodesJsonTest(ApiSampleTestBaseV2):
extension_name = ("nova.api.openstack.compute.contrib"
".baremetal_nodes.Baremetal_nodes")
@mock.patch("nova.api.openstack.compute.contrib.baremetal_nodes"
"._get_ironic_client")
def test_baremetal_nodes_list(self, mock_get_irc):
mock_get_irc.return_value = fake_client()
response = self._do_get('os-baremetal-nodes')
subs = self._get_regexes()
self._verify_response('baremetal-node-list-resp', subs, response, 200)
class CellsSampleJsonTest(ApiSampleTestBaseV2):
extension_name = "nova.api.openstack.compute.contrib.cells.Cells"
@@ -0,0 +1,22 @@
{
"nodes": [
{
"cpus": "2",
"disk_gb": "10",
"host": "IRONIC MANAGED",
"id": "058d27fa-241b-445a-a386-08c04f96db43",
"interfaces": [],
"memory_mb": "1024",
"task_state": "active"
},
{
"cpus": "2",
"disk_gb": "10",
"host": "IRONIC MANAGED",
"id": "e2025409-f3ce-4d6a-9788-c565cf3b1b1c",
"interfaces": [],
"memory_mb": "1024",
"task_state": "active"
}
]
}
@@ -0,0 +1,48 @@
# Copyright 2015 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
from nova.tests.functional.v3 import api_sample_base
class FakeNode(object):
def __init__(self, uuid='058d27fa-241b-445a-a386-08c04f96db43'):
self.uuid = uuid
self.provision_state = 'active'
self.properties = {'cpus': '2',
'memory_mb': '1024',
'local_gb': '10'}
class NodeManager(object):
def list(self, detail=False):
return [FakeNode(), FakeNode('e2025409-f3ce-4d6a-9788-c565cf3b1b1c')]
class fake_client(object):
node = NodeManager()
class BareMetalNodesSampleJsonTest(api_sample_base.ApiSampleTestBaseV3):
extension_name = "os-baremetal-nodes"
@mock.patch("nova.api.openstack.compute.plugins.v3.baremetal_nodes"
"._get_ironic_client")
def test_baremetal_nodes_list(self, mock_get_irc):
mock_get_irc.return_value = fake_client()
response = self._do_get('os-baremetal-nodes')
subs = self._get_regexes()
self._verify_response('baremetal-node-list-resp', subs, response, 200)