diff options
author | linggao <linggao@us.ibm.com> | 2013-10-22 21:13:39 +0000 |
---|---|---|
committer | linggao <linggao@us.ibm.com> | 2013-10-23 21:29:31 +0000 |
commit | 5f2bac17b6e5515f7fc81933ea565b76c37c1e6d (patch) | |
tree | e30768c423e2e878305a8cdad2108fda2f36a94e /ironic/tests/db | |
parent | 1eedfc290fcda6f7fa91a1d7ce164133b97312dc (diff) | |
download | ironic-5f2bac17b6e5515f7fc81933ea565b76c37c1e6d.tar.gz |
Supports paginate query for two get nodes DB APIs
In DB APIs that return a list of nodes, limiting and sorting the
output is necessary for a large number of output nodes. This is
especially important for the GUI that uses the APIs where the view
is limited. This patch adds limit, marker, sort_key and sort_dir
to get_associated_nodes and get_unassociated_nodes DB APIs.
Change-Id: Ia2c616fff65a03bace1244fe646bdf0cf5f30a29
Diffstat (limited to 'ironic/tests/db')
-rw-r--r-- | ironic/tests/db/test_nodes.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ironic/tests/db/test_nodes.py b/ironic/tests/db/test_nodes.py index 206b3a219..7b09bad42 100644 --- a/ironic/tests/db/test_nodes.py +++ b/ironic/tests/db/test_nodes.py @@ -331,6 +331,15 @@ class DbNodeTestCase(base.DbTestCase): res_uuids.sort() self.assertEqual(uuids_with_instance, res_uuids) + def test_get_associated_nodes_with_limit(self): + (uuids, uuids_with_instance) = self._create_associated_nodes() + + res = self.dbapi.get_associated_nodes(limit=1) + + res_uuids = [r.uuid for r in res] + self.assertEqual(len(res_uuids), 1) + self.assertTrue(len(uuids_with_instance) > len(res_uuids)) + def test_get_unassociated_nodes(self): (uuids, uuids_with_instance) = self._create_associated_nodes() uuids_without_instance = list(set(uuids) - set(uuids_with_instance)) @@ -340,3 +349,13 @@ class DbNodeTestCase(base.DbTestCase): res_uuids = [r.uuid for r in res] res_uuids.sort() self.assertEqual(uuids_without_instance, res_uuids) + + def test_get_unassociated_nodes_with_limit(self): + (uuids, uuids_with_instance) = self._create_associated_nodes() + uuids_without_instance = list(set(uuids) - set(uuids_with_instance)) + + res = self.dbapi.get_unassociated_nodes(limit=1) + + res_uuids = [r.uuid for r in res] + self.assertEqual(len(res_uuids), 1) + self.assertTrue(len(uuids_without_instance) > len(res_uuids)) |