Ejemplo n.º 1
0
 def test_empty_index_host_list_single(self):
     self.host.name = self.host.name.replace(".", "\.")
     result = self.client.hosts.get(self.host)
     assert_not_equal(result, None,
                      "Get host should not be empty for: %s" % self.host)
     with Check() as check:
         used_ram = int(result.usedRAM)
         total_ram = int(result.totalRAM)
         percent_used = int(result.percentUsed)
         lower, upper = percent_boundary(used_ram, total_ram)
         check.true(
             percent_used > lower,
             "percentUsed %r is below the lower boundary %r" %
             (percent_used, lower))
         check.true(
             percent_used < upper,
             "percentUsed %r is above the upper boundary %r" %
             (percent_used, upper))
         check.true(
             used_ram < total_ram,
             "usedRAM %r should be less than totalRAM %r" %
             (used_ram, total_ram))
         check.true(
             percent_used < 100,
             "percentUsed should be less than 100 but was %r" %
             percent_used)
         check.true(
             total_ram > 0,
             "totalRAM should be greater than 0 but was %r" % total_ram)
         check.true(
             used_ram < total_ram,
             "usedRAM %r should be less than totalRAM %r" %
             (used_ram, total_ram))
Ejemplo n.º 2
0
    def test_mgmt_instance_index_fields_present(self):
        """
        Verify that all the expected fields are returned by the index method.
        """
        expected_fields = [
            'created', 'deleted', 'deleted_at', 'flavor', 'datastore', 'id',
            'links', 'name', 'server', 'status', 'task_description',
            'tenant_id', 'updated', 'region'
        ]
        raise SkipTest("test disabled")

        if CONFIG.trove_volume_support:
            expected_fields.append('volume')

        index = self.client.management.index()

        if not hasattr(index, "deleted"):
            raise SkipTest("instance index must have a "
                           "deleted label for this test")

        for instance in index:
            with Check() as check:
                for field in expected_fields:
                    check.true(hasattr(instance, field),
                               "Index lacks field %s" % field)
Ejemplo n.º 3
0
    def test_mgmt_instance_index_fields_present(self):
        """
        Verify that all the expected fields are returned by the index method.
        """
        expected_fields = [
            'created',
            'deleted',
            'deleted_at',
            'flavor',
            'id',
            'links',
            'name',
            'server',
            'status',
            'task_description',
            'tenant_id',
            'updated',
        ]
        if CONFIG.reddwarf_volume_support:
            expected_fields.append('volume')

        index = self.client.management.index()
        for instance in index:
            with Check() as check:
                for field in expected_fields:
                    check.true(hasattr(instance, field),
                               "Index lacks field %s" % field)
Ejemplo n.º 4
0
 def test_index_host_list_single(self):
     self.host.name = self.host.name.replace(".", "\.")
     myresult = self.client.hosts.get(self.host)
     assert_not_equal(myresult, None,
                      "list hosts should not be empty: %s" % str(myresult))
     assert_true(len(myresult.instances) > 0,
                 "instance list on the host should not be empty: %r" %
                 myresult.instances)
     with Check() as check:
         check.true(myresult.totalRAM == instance_info.host_info.totalRAM,
                    "totalRAM should be the same as before : %r == %r" %
                    (myresult.totalRAM, instance_info.host_info.totalRAM))
         diff = instance_info.host_info.usedRAM\
                + instance_info.dbaas_flavor.ram
         check.true(myresult.usedRAM == diff,
                    "usedRAM should be : %r == %r" %
                    (myresult.usedRAM, diff))
         calc = float((1.0 * myresult.usedRAM / myresult.totalRAM) * 100)
         low_bound = calc - (calc * 0.25)
         high_bound = calc + (calc * 0.25)
         check.true(myresult.percentUsed > low_bound,
                    "percentUsed should be : %r > %r" %
                    (myresult.percentUsed, low_bound))
         check.true(myresult.percentUsed < high_bound,
                    "percentUsed should be : %r < %r" %
                    (myresult.percentUsed, high_bound))
         print("test_index_host_list_single result instances: %s" %
             str(myresult.instances))
         for index, instance in enumerate(myresult.instances, start=1):
             print("%d instance: %s" % (index, instance))
             check.equal(sorted(['id', 'name', 'status', 'server_id',
                                 'tenant_id']),
                         sorted(instance.keys()))
             for key in instance.keys():
                 check.is_not_none(instance[key])
Ejemplo n.º 5
0
    def test_index_host_list_single(self):
        self.host.name = self.host.name.replace(".", "\.")
        result = self.client.hosts.get(self.host)
        assert_not_equal(result, None,
                         "list hosts should not be empty: %s" % str(result))
        assert_true(
            len(result.instances) > 0,
            "instance list on the host should not be empty: %r" %
            result.instances)
        with Check() as check:
            used_ram = int(result.usedRAM)
            total_ram = int(result.totalRAM)
            percent_used = int(result.percentUsed)
            lower, upper = percent_boundary(used_ram, total_ram)
            check.true(
                percent_used > lower,
                "percentUsed %r is below the lower boundary %r" %
                (percent_used, lower))
            check.true(
                percent_used < upper,
                "percentUsed %r is above the upper boundary %r" %
                (percent_used, upper))
            check.true(
                used_ram < total_ram,
                "usedRAM %r should be less than totalRAM %r" %
                (used_ram, total_ram))
            check.true(
                percent_used < 100,
                "percentUsed should be less than 100 but was %r" %
                percent_used)
            check.true(
                total_ram > 0,
                "totalRAM should be greater than 0 but was %r" % total_ram)
            check.true(
                used_ram < total_ram,
                "usedRAM %r should be less than totalRAM %r" %
                (used_ram, total_ram))

            # Check all active instances and validate all the fields exist
            active_instance = None
            for instance in result.instances:
                print("instance: %s" % instance)
                if instance['status'] != 'ACTIVE':
                    continue
                active_instance = instance
                check.is_not_none(instance['id'])
                check.is_not_none(instance['name'])
                check.is_not_none(instance['status'])
                check.is_not_none(instance['server_id'])
                check.is_not_none(instance['tenant_id'])
            check.true(active_instance is not None, "No active instances")
Ejemplo n.º 6
0
 def test_empty_index_host_list_single(self):
     self.host.name = self.host.name.replace(".", "\.")
     single_host = self.client.hosts.get(self.host)
     assert_not_equal(single_host, None,
                      "Get host should not be empty for: %s" % self.host)
     print("test_index_host_list_single result: %r" % single_host.__dict__)
     with Check() as check:
         check.true(single_host.percentUsed < 50,
                    "percentUsed should be around 40 but was  %r"
                    % single_host.percentUsed)
         check.true(single_host.totalRAM,
                    "totalRAM should exist > 0 : %r" % single_host.totalRAM)
         check.true(single_host.usedRAM < 1000, "usedRAM should be less "
                    "than 1000 : %r" % single_host.usedRAM)
         check.true(instance_info.name not in
                    [dbc.name for dbc in single_host.instances])
         instance_info.host_info = single_host
         for index, instance in enumerate(single_host.instances, start=1):
             print("%r instance: %r" % (index, instance))
Ejemplo n.º 7
0
    def test_mgmt_ds_version_list_fields_present(self):
        """Verify that all expected fields are returned by list method."""

        expected_fields = [
            'id',
            'name',
            'datastore_id',
            'datastore_name',
            'datastore_manager',
            'image',
            'packages',
            'active',
            'default',
        ]

        for ds_version in self.ds_versions:
            with Check() as check:
                for field in expected_fields:
                    check.true(hasattr(ds_version, field),
                               "List lacks field %s." % field)