コード例 #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'])))
コード例 #2
0
ファイル: test_sqlalchemy_api.py プロジェクト: sbauza/climate
 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"])))
コード例 #3
0
ファイル: test_sqlalchemy_api.py プロジェクト: sbauza/climate
    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"])))
コード例 #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'])))
コード例 #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%'])))
コード例 #6
0
ファイル: test_sqlalchemy_api.py プロジェクト: hshah19/blazar
 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'])
コード例 #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'])
コード例 #8
0
ファイル: test_sqlalchemy_api.py プロジェクト: hshah19/blazar
    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'])))
コード例 #9
0
ファイル: test_sqlalchemy_api.py プロジェクト: sbauza/climate
    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%"])))