Esempio n. 1
0
    def test_search_for_hosts_by_composed_queries(self):
        """Create one host and test composed queries."""

        db_api.host_create(_get_fake_host_values(mem=8192))
        self.assertEqual(
            1,
            len(
                db_api.host_get_all_by_queries(
                    ['memory_mb > 2048', 'cpu_info like %Westmere%'])))
        self.assertEqual(
            0,
            len(
                db_api.host_get_all_by_queries(
                    ['memory_mb < 2048', 'cpu_info like %Westmere%'])))
        self.assertRaises(db_exceptions.ClimateDBInvalidFilter,
                          db_api.host_get_all_by_queries, ['memory_mb <'])
        self.assertRaises(db_exceptions.ClimateDBNotFound,
                          db_api.host_get_all_by_queries, ['apples < 2048'])
        self.assertRaises(db_exceptions.ClimateDBInvalidFilterOperator,
                          db_api.host_get_all_by_queries,
                          ['memory_mb wrongop 2048'])
        self.assertEqual(
            1, len(db_api.host_get_all_by_queries(['memory_mb in 4096,8192'])))
        self.assertEqual(
            1, len(db_api.host_get_all_by_queries(['memory_mb != null'])))
Esempio n. 2
0
 def test_search_for_hosts_by_ram(self):
     """Create two hosts and check that we can find a host per its RAM info.
     """
     db_api.host_create(_get_fake_host_values(id=1, mem=2048))
     db_api.host_create(_get_fake_host_values(id=2, mem=4096))
     self.assertEqual(2, len(db_api.host_get_all_by_queries(["memory_mb >= 2048"])))
     self.assertEqual(0, len(db_api.host_get_all_by_queries(["memory_mb lt 2048"])))
Esempio n. 3
0
    def test_search_for_hosts_by_composed_queries(self):
        """Create one host and test composed queries."""

        db_api.host_create(_get_fake_host_values(mem=8192))
        self.assertEqual(1, len(db_api.host_get_all_by_queries(["memory_mb > 2048", "cpu_info like %Westmere%"])))
        self.assertEqual(0, len(db_api.host_get_all_by_queries(["memory_mb < 2048", "cpu_info like %Westmere%"])))
        self.assertRaises(RuntimeError, db_api.host_get_all_by_queries, ["memory_mb <"])
        self.assertRaises(RuntimeError, db_api.host_get_all_by_queries, ["apples < 2048"])
        self.assertRaises(RuntimeError, db_api.host_get_all_by_queries, ["memory_mb wrongop 2048"])
        self.assertEqual(1, len(db_api.host_get_all_by_queries(["memory_mb in 4096,8192"])))
        self.assertEqual(1, len(db_api.host_get_all_by_queries(["memory_mb != null"])))
Esempio n. 4
0
    def test_search_for_hosts_by_ram(self):
        """Check RAM info search

        Create two hosts and check that we can find a host per its RAM
        info.
        """
        db_api.host_create(_get_fake_host_values(id=1, mem=2048))
        db_api.host_create(_get_fake_host_values(id=2, mem=4096))
        self.assertEqual(
            2, len(db_api.host_get_all_by_queries(['memory_mb >= 2048'])))
        self.assertEqual(
            0, len(db_api.host_get_all_by_queries(['memory_mb lt 2048'])))
Esempio n. 5
0
    def test_search_for_hosts_by_cpu_info(self):
        """Create one host and search within cpu_info."""

        db_api.host_create(_get_fake_host_values())
        self.assertEqual(
            1,
            len(db_api.host_get_all_by_queries(['cpu_info like %Westmere%'])))
Esempio n. 6
0
 def test_search_for_hosts_by_extra_capability(self):
     """Create one host and test extra capability queries."""
     db_api.host_create(_get_fake_host_values(id=1))
     db_api.host_extra_capability_create(
         _get_fake_host_extra_capabilities(computehost_id=1))
     self.assertEqual(1, len(
         db_api.host_get_all_by_queries(['vgpu == 2'])))
     self.assertEqual(0, len(
         db_api.host_get_all_by_queries(['vgpu != 2'])))
     self.assertEqual(1, len(
         db_api.host_get_all_by_queries(['cpu_info like %Westmere%',
                                         'vgpu == 2'])))
     self.assertEqual(0, len(
         db_api.host_get_all_by_queries(['cpu_info like %wrongcpu%',
                                         'vgpu == 2'])))
     self.assertRaises(db_exceptions.ClimateDBNotFound,
                       db_api.host_get_all_by_queries, ['apples < 2048'])
Esempio n. 7
0
 def test_search_for_hosts_by_extra_capability(self):
     """Create one host and test extra capability queries."""
     db_api.host_create(_get_fake_host_values(id=1))
     db_api.host_extra_capability_create(
         _get_fake_host_extra_capabilities(computehost_id=1))
     self.assertEqual(1, len(db_api.host_get_all_by_queries(['vgpu == 2'])))
     self.assertEqual(0, len(db_api.host_get_all_by_queries(['vgpu != 2'])))
     self.assertEqual(
         1,
         len(
             db_api.host_get_all_by_queries(
                 ['cpu_info like %Westmere%', 'vgpu == 2'])))
     self.assertEqual(
         0,
         len(
             db_api.host_get_all_by_queries(
                 ['cpu_info like %wrongcpu%', 'vgpu == 2'])))
     self.assertRaises(db_exceptions.ClimateDBNotFound,
                       db_api.host_get_all_by_queries, ['apples < 2048'])
Esempio n. 8
0
    def test_search_for_hosts_by_composed_queries(self):
        """Create one host and test composed queries."""

        db_api.host_create(_get_fake_host_values(mem=8192))
        self.assertEqual(1, len(
            db_api.host_get_all_by_queries(['memory_mb > 2048',
                                            'cpu_info like %Westmere%'])))
        self.assertEqual(0, len(
            db_api.host_get_all_by_queries(['memory_mb < 2048',
                                            'cpu_info like %Westmere%'])))
        self.assertRaises(db_exceptions.ClimateDBInvalidFilter,
                          db_api.host_get_all_by_queries, ['memory_mb <'])
        self.assertRaises(db_exceptions.ClimateDBNotFound,
                          db_api.host_get_all_by_queries, ['apples < 2048'])
        self.assertRaises(db_exceptions.ClimateDBInvalidFilterOperator,
                          db_api.host_get_all_by_queries,
                          ['memory_mb wrongop 2048'])
        self.assertEqual(1, len(
            db_api.host_get_all_by_queries(['memory_mb in 4096,8192'])))
        self.assertEqual(1, len(
            db_api.host_get_all_by_queries(['memory_mb != null'])))
Esempio n. 9
0
    def test_search_for_hosts_by_cpu_info(self):
        """Create one host and search within cpu_info."""

        db_api.host_create(_get_fake_host_values())
        self.assertEqual(1, len(db_api.host_get_all_by_queries(["cpu_info like %Westmere%"])))