Merge "Fix unit tests for volume connector and target"
This commit is contained in:
commit
a800e0cda7
|
@ -61,12 +61,12 @@ PORTGROUP = {'uuid': '11111111-2222-3333-4444-555555555555',
|
||||||
'address': 'AA:BB:CC:DD:EE:FF',
|
'address': 'AA:BB:CC:DD:EE:FF',
|
||||||
'extra': {}}
|
'extra': {}}
|
||||||
CONNECTOR = {'uuid': 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
|
CONNECTOR = {'uuid': 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
|
||||||
'node_uuid': 'bbbbbbbb-cccc-dddd-eeee-ffffffffffff',
|
'node_uuid': NODE1['uuid'],
|
||||||
'type': 'iqn',
|
'type': 'iqn',
|
||||||
'connector_id': 'iqn.2010-10.org.openstack:test',
|
'connector_id': 'iqn.2010-10.org.openstack:test',
|
||||||
'extra': {}}
|
'extra': {}}
|
||||||
TARGET = {'uuid': 'cccccccc-dddd-eeee-ffff-000000000000',
|
TARGET = {'uuid': 'cccccccc-dddd-eeee-ffff-000000000000',
|
||||||
'node_uuid': 'dddddddd-eeee-ffff-0000-111111111111',
|
'node_uuid': NODE1['uuid'],
|
||||||
'volume_type': 'iscsi',
|
'volume_type': 'iscsi',
|
||||||
'properties': {'target_iqn': 'iqn.foo'},
|
'properties': {'target_iqn': 'iqn.foo'},
|
||||||
'boot_index': 0,
|
'boot_index': 0,
|
||||||
|
|
|
@ -112,10 +112,20 @@ fake_responses_pagination = {
|
||||||
'GET': (
|
'GET': (
|
||||||
{},
|
{},
|
||||||
{"connectors": [CONNECTOR1],
|
{"connectors": [CONNECTOR1],
|
||||||
"next": "http://127.0.0.1:6385/v1/volume/connectors/?limit=1"}
|
"next": "http://127.0.0.1:6385/v1/volume/connectors/?marker=%s" %
|
||||||
|
CONNECTOR1['uuid']}
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
'/v1/volume/connectors/?limit=1':
|
'/v1/volume/connectors/?limit=1':
|
||||||
|
{
|
||||||
|
'GET': (
|
||||||
|
{},
|
||||||
|
{"connectors": [CONNECTOR1],
|
||||||
|
"next": "http://127.0.0.1:6385/v1/volume/connectors/?limit=1"
|
||||||
|
"&marker=%s" % CONNECTOR1['uuid']}
|
||||||
|
),
|
||||||
|
},
|
||||||
|
'/v1/volume/connectors/?limit=1&marker=%s' % CONNECTOR1['uuid']:
|
||||||
{
|
{
|
||||||
'GET': (
|
'GET': (
|
||||||
{},
|
{},
|
||||||
|
@ -149,13 +159,7 @@ fake_responses_sorting = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class VolumeConnectorManagerTest(testtools.TestCase):
|
class VolumeConnectorManagerTestBase(testtools.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super(VolumeConnectorManagerTest, self).setUp()
|
|
||||||
self.api = utils.FakeAPI(fake_responses)
|
|
||||||
self.mgr = ironicclient.v1.volume_connector.VolumeConnectorManager(
|
|
||||||
self.api)
|
|
||||||
|
|
||||||
def _validate_obj(self, expect, obj):
|
def _validate_obj(self, expect, obj):
|
||||||
self.assertEqual(expect['uuid'], obj.uuid)
|
self.assertEqual(expect['uuid'], obj.uuid)
|
||||||
|
@ -170,6 +174,15 @@ class VolumeConnectorManagerTest(testtools.TestCase):
|
||||||
for expect, obj in zip(expect_connectors, actual_connectors):
|
for expect, obj in zip(expect_connectors, actual_connectors):
|
||||||
self._validate_obj(expect, obj)
|
self._validate_obj(expect, obj)
|
||||||
|
|
||||||
|
|
||||||
|
class VolumeConnectorManagerTest(VolumeConnectorManagerTestBase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(VolumeConnectorManagerTest, self).setUp()
|
||||||
|
self.api = utils.FakeAPI(fake_responses)
|
||||||
|
self.mgr = ironicclient.v1.volume_connector.VolumeConnectorManager(
|
||||||
|
self.api)
|
||||||
|
|
||||||
def test_volume_connectors_list(self):
|
def test_volume_connectors_list(self):
|
||||||
volume_connectors = self.mgr.list()
|
volume_connectors = self.mgr.list()
|
||||||
expect = [
|
expect = [
|
||||||
|
@ -218,63 +231,6 @@ class VolumeConnectorManagerTest(testtools.TestCase):
|
||||||
self.assertRaises(exc.InvalidAttribute, self.mgr.list,
|
self.assertRaises(exc.InvalidAttribute, self.mgr.list,
|
||||||
detail=True, fields=['uuid', 'connector_id'])
|
detail=True, fields=['uuid', 'connector_id'])
|
||||||
|
|
||||||
def test_volume_connectors_list_limit(self):
|
|
||||||
self.api = utils.FakeAPI(fake_responses_pagination)
|
|
||||||
self.mgr = ironicclient.v1.volume_connector.VolumeConnectorManager(
|
|
||||||
self.api)
|
|
||||||
volume_connectors = self.mgr.list(limit=1)
|
|
||||||
expect = [
|
|
||||||
('GET', '/v1/volume/connectors/?limit=1', {}, None),
|
|
||||||
]
|
|
||||||
expect_connectors = [CONNECTOR2]
|
|
||||||
self._validate_list(expect, expect_connectors, volume_connectors)
|
|
||||||
|
|
||||||
def test_volume_connectors_list_marker(self):
|
|
||||||
self.api = utils.FakeAPI(fake_responses_pagination)
|
|
||||||
self.mgr = ironicclient.v1.volume_connector.VolumeConnectorManager(
|
|
||||||
self.api)
|
|
||||||
volume_connectors = self.mgr.list(marker=CONNECTOR1['uuid'])
|
|
||||||
expect = [
|
|
||||||
('GET', '/v1/volume/connectors/?marker=%s' % CONNECTOR1['uuid'],
|
|
||||||
{}, None),
|
|
||||||
]
|
|
||||||
expect_connectors = [CONNECTOR2]
|
|
||||||
self._validate_list(expect, expect_connectors, volume_connectors)
|
|
||||||
|
|
||||||
def test_volume_connectors_list_pagination_no_limit(self):
|
|
||||||
self.api = utils.FakeAPI(fake_responses_pagination)
|
|
||||||
self.mgr = ironicclient.v1.volume_connector.VolumeConnectorManager(
|
|
||||||
self.api)
|
|
||||||
volume_connectors = self.mgr.list(limit=0)
|
|
||||||
expect = [
|
|
||||||
('GET', '/v1/volume/connectors', {}, None),
|
|
||||||
('GET', '/v1/volume/connectors/?limit=1', {}, None)
|
|
||||||
]
|
|
||||||
expect_connectors = [CONNECTOR1, CONNECTOR2]
|
|
||||||
self._validate_list(expect, expect_connectors, volume_connectors)
|
|
||||||
|
|
||||||
def test_volume_connectors_list_sort_key(self):
|
|
||||||
self.api = utils.FakeAPI(fake_responses_sorting)
|
|
||||||
self.mgr = ironicclient.v1.volume_connector.VolumeConnectorManager(
|
|
||||||
self.api)
|
|
||||||
volume_connectors = self.mgr.list(sort_key='updated_at')
|
|
||||||
expect = [
|
|
||||||
('GET', '/v1/volume/connectors/?sort_key=updated_at', {}, None)
|
|
||||||
]
|
|
||||||
expect_connectors = [CONNECTOR2, CONNECTOR1]
|
|
||||||
self._validate_list(expect, expect_connectors, volume_connectors)
|
|
||||||
|
|
||||||
def test_volume_connectors_list_sort_dir(self):
|
|
||||||
self.api = utils.FakeAPI(fake_responses_sorting)
|
|
||||||
self.mgr = ironicclient.v1.volume_connector.VolumeConnectorManager(
|
|
||||||
self.api)
|
|
||||||
volume_connectors = self.mgr.list(sort_dir='desc')
|
|
||||||
expect = [
|
|
||||||
('GET', '/v1/volume/connectors/?sort_dir=desc', {}, None)
|
|
||||||
]
|
|
||||||
expect_connectors = [CONNECTOR2, CONNECTOR1]
|
|
||||||
self._validate_list(expect, expect_connectors, volume_connectors)
|
|
||||||
|
|
||||||
def test_volume_connectors_show(self):
|
def test_volume_connectors_show(self):
|
||||||
volume_connector = self.mgr.get(CONNECTOR1['uuid'])
|
volume_connector = self.mgr.get(CONNECTOR1['uuid'])
|
||||||
expect = [
|
expect = [
|
||||||
|
@ -332,3 +288,64 @@ class VolumeConnectorManagerTest(testtools.TestCase):
|
||||||
]
|
]
|
||||||
self.assertEqual(expect, self.api.calls)
|
self.assertEqual(expect, self.api.calls)
|
||||||
self._validate_obj(UPDATED_CONNECTOR, volume_connector)
|
self._validate_obj(UPDATED_CONNECTOR, volume_connector)
|
||||||
|
|
||||||
|
|
||||||
|
class VolumeConnectorManagerPaginationTest(VolumeConnectorManagerTestBase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(VolumeConnectorManagerPaginationTest, self).setUp()
|
||||||
|
self.api = utils.FakeAPI(fake_responses_pagination)
|
||||||
|
self.mgr = ironicclient.v1.volume_connector.VolumeConnectorManager(
|
||||||
|
self.api)
|
||||||
|
|
||||||
|
def test_volume_connectors_list_limit(self):
|
||||||
|
volume_connectors = self.mgr.list(limit=1)
|
||||||
|
expect = [
|
||||||
|
('GET', '/v1/volume/connectors/?limit=1', {}, None),
|
||||||
|
]
|
||||||
|
expect_connectors = [CONNECTOR1]
|
||||||
|
self._validate_list(expect, expect_connectors, volume_connectors)
|
||||||
|
|
||||||
|
def test_volume_connectors_list_marker(self):
|
||||||
|
volume_connectors = self.mgr.list(marker=CONNECTOR1['uuid'])
|
||||||
|
expect = [
|
||||||
|
('GET', '/v1/volume/connectors/?marker=%s' % CONNECTOR1['uuid'],
|
||||||
|
{}, None),
|
||||||
|
]
|
||||||
|
expect_connectors = [CONNECTOR2]
|
||||||
|
self._validate_list(expect, expect_connectors, volume_connectors)
|
||||||
|
|
||||||
|
def test_volume_connectors_list_pagination_no_limit(self):
|
||||||
|
volume_connectors = self.mgr.list(limit=0)
|
||||||
|
expect = [
|
||||||
|
('GET', '/v1/volume/connectors', {}, None),
|
||||||
|
('GET', '/v1/volume/connectors/?marker=%s' % CONNECTOR1['uuid'],
|
||||||
|
{}, None)
|
||||||
|
]
|
||||||
|
expect_connectors = [CONNECTOR1, CONNECTOR2]
|
||||||
|
self._validate_list(expect, expect_connectors, volume_connectors)
|
||||||
|
|
||||||
|
|
||||||
|
class VolumeConnectorManagerSortingTest(VolumeConnectorManagerTestBase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(VolumeConnectorManagerSortingTest, self).setUp()
|
||||||
|
self.api = utils.FakeAPI(fake_responses_sorting)
|
||||||
|
self.mgr = ironicclient.v1.volume_connector.VolumeConnectorManager(
|
||||||
|
self.api)
|
||||||
|
|
||||||
|
def test_volume_connectors_list_sort_key(self):
|
||||||
|
volume_connectors = self.mgr.list(sort_key='updated_at')
|
||||||
|
expect = [
|
||||||
|
('GET', '/v1/volume/connectors/?sort_key=updated_at', {}, None)
|
||||||
|
]
|
||||||
|
expect_connectors = [CONNECTOR2, CONNECTOR1]
|
||||||
|
self._validate_list(expect, expect_connectors, volume_connectors)
|
||||||
|
|
||||||
|
def test_volume_connectors_list_sort_dir(self):
|
||||||
|
volume_connectors = self.mgr.list(sort_dir='desc')
|
||||||
|
expect = [
|
||||||
|
('GET', '/v1/volume/connectors/?sort_dir=desc', {}, None)
|
||||||
|
]
|
||||||
|
expect_connectors = [CONNECTOR2, CONNECTOR1]
|
||||||
|
self._validate_list(expect, expect_connectors, volume_connectors)
|
||||||
|
|
|
@ -116,10 +116,20 @@ fake_responses_pagination = {
|
||||||
'GET': (
|
'GET': (
|
||||||
{},
|
{},
|
||||||
{"targets": [TARGET1],
|
{"targets": [TARGET1],
|
||||||
"next": "http://127.0.0.1:6385/v1/volume/targets/?limit=1"}
|
"next": "http://127.0.0.1:6385/v1/volume/targets/?marker=%s" %
|
||||||
|
TARGET1['uuid']}
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
'/v1/volume/targets/?limit=1':
|
'/v1/volume/targets/?limit=1':
|
||||||
|
{
|
||||||
|
'GET': (
|
||||||
|
{},
|
||||||
|
{"targets": [TARGET1],
|
||||||
|
"next": "http://127.0.0.1:6385/v1/volume/targets/?limit=1"
|
||||||
|
"&marker=%s" % TARGET1['uuid']}
|
||||||
|
),
|
||||||
|
},
|
||||||
|
'/v1/volume/targets/?limit=1&marker=%s' % TARGET1['uuid']:
|
||||||
{
|
{
|
||||||
'GET': (
|
'GET': (
|
||||||
{},
|
{},
|
||||||
|
@ -153,12 +163,7 @@ fake_responses_sorting = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class VolumeTargetManagerTest(testtools.TestCase):
|
class VolumeTargetManagerTestBase(testtools.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super(VolumeTargetManagerTest, self).setUp()
|
|
||||||
self.api = utils.FakeAPI(fake_responses)
|
|
||||||
self.mgr = ironicclient.v1.volume_target.VolumeTargetManager(self.api)
|
|
||||||
|
|
||||||
def _validate_obj(self, expect, obj):
|
def _validate_obj(self, expect, obj):
|
||||||
self.assertEqual(expect['uuid'], obj.uuid)
|
self.assertEqual(expect['uuid'], obj.uuid)
|
||||||
|
@ -174,6 +179,14 @@ class VolumeTargetManagerTest(testtools.TestCase):
|
||||||
for expect, obj in zip(expect_targets, actual_targets):
|
for expect, obj in zip(expect_targets, actual_targets):
|
||||||
self._validate_obj(expect, obj)
|
self._validate_obj(expect, obj)
|
||||||
|
|
||||||
|
|
||||||
|
class VolumeTargetManagerTest(VolumeTargetManagerTestBase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(VolumeTargetManagerTest, self).setUp()
|
||||||
|
self.api = utils.FakeAPI(fake_responses)
|
||||||
|
self.mgr = ironicclient.v1.volume_target.VolumeTargetManager(self.api)
|
||||||
|
|
||||||
def test_volume_targets_list(self):
|
def test_volume_targets_list(self):
|
||||||
volume_targets = self.mgr.list()
|
volume_targets = self.mgr.list()
|
||||||
expect = [
|
expect = [
|
||||||
|
@ -219,58 +232,6 @@ class VolumeTargetManagerTest(testtools.TestCase):
|
||||||
self.assertRaises(exc.InvalidAttribute, self.mgr.list,
|
self.assertRaises(exc.InvalidAttribute, self.mgr.list,
|
||||||
detail=True, fields=['uuid', 'boot_index'])
|
detail=True, fields=['uuid', 'boot_index'])
|
||||||
|
|
||||||
def test_volume_targets_list_limit(self):
|
|
||||||
self.api = utils.FakeAPI(fake_responses_pagination)
|
|
||||||
self.mgr = ironicclient.v1.volume_target.VolumeTargetManager(self.api)
|
|
||||||
volume_targets = self.mgr.list(limit=1)
|
|
||||||
expect = [
|
|
||||||
('GET', '/v1/volume/targets/?limit=1', {}, None),
|
|
||||||
]
|
|
||||||
expect_targets = [TARGET2]
|
|
||||||
self._validate_list(expect, expect_targets, volume_targets)
|
|
||||||
|
|
||||||
def test_volume_targets_list_marker(self):
|
|
||||||
self.api = utils.FakeAPI(fake_responses_pagination)
|
|
||||||
self.mgr = ironicclient.v1.volume_target.VolumeTargetManager(self.api)
|
|
||||||
volume_targets = self.mgr.list(marker=TARGET1['uuid'])
|
|
||||||
expect = [
|
|
||||||
('GET', '/v1/volume/targets/?marker=%s' % TARGET1['uuid'],
|
|
||||||
{}, None),
|
|
||||||
]
|
|
||||||
expect_targets = [TARGET2]
|
|
||||||
self._validate_list(expect, expect_targets, volume_targets)
|
|
||||||
|
|
||||||
def test_volume_targets_list_pagination_no_limit(self):
|
|
||||||
self.api = utils.FakeAPI(fake_responses_pagination)
|
|
||||||
self.mgr = ironicclient.v1.volume_target.VolumeTargetManager(self.api)
|
|
||||||
volume_targets = self.mgr.list(limit=0)
|
|
||||||
expect = [
|
|
||||||
('GET', '/v1/volume/targets', {}, None),
|
|
||||||
('GET', '/v1/volume/targets/?limit=1', {}, None)
|
|
||||||
]
|
|
||||||
expect_targets = [TARGET1, TARGET2]
|
|
||||||
self._validate_list(expect, expect_targets, volume_targets)
|
|
||||||
|
|
||||||
def test_volume_targets_list_sort_key(self):
|
|
||||||
self.api = utils.FakeAPI(fake_responses_sorting)
|
|
||||||
self.mgr = ironicclient.v1.volume_target.VolumeTargetManager(self.api)
|
|
||||||
volume_targets = self.mgr.list(sort_key='updated_at')
|
|
||||||
expect = [
|
|
||||||
('GET', '/v1/volume/targets/?sort_key=updated_at', {}, None)
|
|
||||||
]
|
|
||||||
expect_targets = [TARGET2, TARGET1]
|
|
||||||
self._validate_list(expect, expect_targets, volume_targets)
|
|
||||||
|
|
||||||
def test_volume_targets_list_sort_dir(self):
|
|
||||||
self.api = utils.FakeAPI(fake_responses_sorting)
|
|
||||||
self.mgr = ironicclient.v1.volume_target.VolumeTargetManager(self.api)
|
|
||||||
volume_targets = self.mgr.list(sort_dir='desc')
|
|
||||||
expect = [
|
|
||||||
('GET', '/v1/volume/targets/?sort_dir=desc', {}, None)
|
|
||||||
]
|
|
||||||
expect_targets = [TARGET2, TARGET1]
|
|
||||||
self._validate_list(expect, expect_targets, volume_targets)
|
|
||||||
|
|
||||||
def test_volume_targets_show(self):
|
def test_volume_targets_show(self):
|
||||||
volume_target = self.mgr.get(TARGET1['uuid'])
|
volume_target = self.mgr.get(TARGET1['uuid'])
|
||||||
expect = [
|
expect = [
|
||||||
|
@ -327,3 +288,62 @@ class VolumeTargetManagerTest(testtools.TestCase):
|
||||||
]
|
]
|
||||||
self.assertEqual(expect, self.api.calls)
|
self.assertEqual(expect, self.api.calls)
|
||||||
self._validate_obj(UPDATED_TARGET, volume_target)
|
self._validate_obj(UPDATED_TARGET, volume_target)
|
||||||
|
|
||||||
|
|
||||||
|
class VolumeTargetManagerPaginationTest(VolumeTargetManagerTestBase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(VolumeTargetManagerPaginationTest, self).setUp()
|
||||||
|
self.api = utils.FakeAPI(fake_responses_pagination)
|
||||||
|
self.mgr = ironicclient.v1.volume_target.VolumeTargetManager(self.api)
|
||||||
|
|
||||||
|
def test_volume_targets_list_limit(self):
|
||||||
|
volume_targets = self.mgr.list(limit=1)
|
||||||
|
expect = [
|
||||||
|
('GET', '/v1/volume/targets/?limit=1', {}, None),
|
||||||
|
]
|
||||||
|
expect_targets = [TARGET1]
|
||||||
|
self._validate_list(expect, expect_targets, volume_targets)
|
||||||
|
|
||||||
|
def test_volume_targets_list_marker(self):
|
||||||
|
volume_targets = self.mgr.list(marker=TARGET1['uuid'])
|
||||||
|
expect = [
|
||||||
|
('GET', '/v1/volume/targets/?marker=%s' % TARGET1['uuid'],
|
||||||
|
{}, None),
|
||||||
|
]
|
||||||
|
expect_targets = [TARGET2]
|
||||||
|
self._validate_list(expect, expect_targets, volume_targets)
|
||||||
|
|
||||||
|
def test_volume_targets_list_pagination_no_limit(self):
|
||||||
|
volume_targets = self.mgr.list(limit=0)
|
||||||
|
expect = [
|
||||||
|
('GET', '/v1/volume/targets', {}, None),
|
||||||
|
('GET', '/v1/volume/targets/?marker=%s' % TARGET1['uuid'],
|
||||||
|
{}, None)
|
||||||
|
]
|
||||||
|
expect_targets = [TARGET1, TARGET2]
|
||||||
|
self._validate_list(expect, expect_targets, volume_targets)
|
||||||
|
|
||||||
|
|
||||||
|
class VolumeTargetManagerSortingTest(VolumeTargetManagerTestBase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(VolumeTargetManagerSortingTest, self).setUp()
|
||||||
|
self.api = utils.FakeAPI(fake_responses_sorting)
|
||||||
|
self.mgr = ironicclient.v1.volume_target.VolumeTargetManager(self.api)
|
||||||
|
|
||||||
|
def test_volume_targets_list_sort_key(self):
|
||||||
|
volume_targets = self.mgr.list(sort_key='updated_at')
|
||||||
|
expect = [
|
||||||
|
('GET', '/v1/volume/targets/?sort_key=updated_at', {}, None)
|
||||||
|
]
|
||||||
|
expect_targets = [TARGET2, TARGET1]
|
||||||
|
self._validate_list(expect, expect_targets, volume_targets)
|
||||||
|
|
||||||
|
def test_volume_targets_list_sort_dir(self):
|
||||||
|
volume_targets = self.mgr.list(sort_dir='desc')
|
||||||
|
expect = [
|
||||||
|
('GET', '/v1/volume/targets/?sort_dir=desc', {}, None)
|
||||||
|
]
|
||||||
|
expect_targets = [TARGET2, TARGET1]
|
||||||
|
self._validate_list(expect, expect_targets, volume_targets)
|
||||||
|
|
Loading…
Reference in New Issue